Hjm1a commited on
Commit
b72f5af
·
verified ·
1 Parent(s): 3a73660

Upload 259 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .dockerignore +3 -0
  2. .gitattributes +3 -35
  3. .gitignore +7 -0
  4. Dockerfile +30 -0
  5. LICENSE.txt +661 -0
  6. build.js +3 -0
  7. dev-server.js +57 -0
  8. docker-compose.yml +7 -0
  9. docs/prod.md +137 -0
  10. package-lock.json +2510 -0
  11. package.json +33 -0
  12. src/IPC.js +972 -0
  13. src/UI/PuterDialog.js +81 -0
  14. src/UI/UIAlert.js +115 -0
  15. src/UI/UIContextMenu.js +230 -0
  16. src/UI/UIDesktop.js +1447 -0
  17. src/UI/UIItem.js +1620 -0
  18. src/UI/UINotification.js +76 -0
  19. src/UI/UIPopover.js +104 -0
  20. src/UI/UIPrompt.js +122 -0
  21. src/UI/UITaskbar.js +304 -0
  22. src/UI/UITaskbarItem.js +365 -0
  23. src/UI/UIWindow.js +0 -0
  24. src/UI/UIWindowChangePassword.js +128 -0
  25. src/UI/UIWindowChangeUsername.js +129 -0
  26. src/UI/UIWindowClaimReferral.js +73 -0
  27. src/UI/UIWindowColorPicker.js +128 -0
  28. src/UI/UIWindowConfirmDownload.js +91 -0
  29. src/UI/UIWindowCopyProgress.js +81 -0
  30. src/UI/UIWindowDesktopBGSettings.js +207 -0
  31. src/UI/UIWindowDownloadDirProg.js +70 -0
  32. src/UI/UIWindowDownloadProgress.js +81 -0
  33. src/UI/UIWindowEmailConfirmationRequired.js +275 -0
  34. src/UI/UIWindowFeedback.js +98 -0
  35. src/UI/UIWindowFontPicker.js +121 -0
  36. src/UI/UIWindowGetCopyLink.js +117 -0
  37. src/UI/UIWindowItemProperties.js +243 -0
  38. src/UI/UIWindowLogin.js +202 -0
  39. src/UI/UIWindowLoginInProgress.js +77 -0
  40. src/UI/UIWindowMoveProgress.js +81 -0
  41. src/UI/UIWindowMyWebsites.js +196 -0
  42. src/UI/UIWindowNewFolderProgress.js +74 -0
  43. src/UI/UIWindowNewPassword.js +144 -0
  44. src/UI/UIWindowProgressEmptyTrash.js +74 -0
  45. src/UI/UIWindowPublishWebsite.js +134 -0
  46. src/UI/UIWindowQR.js +78 -0
  47. src/UI/UIWindowRecoverPassword.js +128 -0
  48. src/UI/UIWindowRefer.js +120 -0
  49. src/UI/UIWindowRequestFiles.js +93 -0
  50. src/UI/UIWindowRequestPermission.js +143 -0
.dockerignore ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ .dockerignore
2
+ Dockerfile
3
+ node_modules
.gitattributes CHANGED
@@ -1,35 +1,3 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
3
+ src/images/screenshot.png filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.gitignore ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ .DS_Store
2
+ node_modules/
3
+ *.zip
4
+ *.tgz
5
+ license.config.json
6
+ license-header.txt
7
+ dist/
Dockerfile ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:21-alpine
2
+
3
+ # Set labels
4
+ LABEL repo="https://github.com/HeyPuter/puter"
5
+ LABEL license="AGPL-3.0,https://github.com/HeyPuter/puter/blob/master/LICENSE.txt"
6
+ LABEL version="v1.2.40-beta"
7
+
8
+ # Debugging
9
+ RUN apk add --no-cache bash # useful for debugging
10
+
11
+ # Setup working directory
12
+ RUN mkdir -p /opt/puter/app
13
+ WORKDIR /opt/puter/app
14
+
15
+ # Add source files
16
+ # NOTE: This might change (https://github.com/HeyPuter/puter/discussions/32)
17
+ COPY . .
18
+
19
+ # Set permissions
20
+ RUN chown -R node:node /opt/puter/app
21
+ USER node
22
+
23
+ # Install node modules
24
+ RUN npm cache clean --force \
25
+ && npm install
26
+
27
+ EXPOSE 4000
28
+
29
+
30
+ CMD [ "npm", "start" ]
LICENSE.txt ADDED
@@ -0,0 +1,661 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU AFFERO GENERAL PUBLIC LICENSE
2
+ Version 3, 19 November 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU Affero General Public License is a free, copyleft license for
11
+ software and other kinds of works, specifically designed to ensure
12
+ cooperation with the community in the case of network server software.
13
+
14
+ The licenses for most software and other practical works are designed
15
+ to take away your freedom to share and change the works. By contrast,
16
+ our General Public Licenses are intended to guarantee your freedom to
17
+ share and change all versions of a program--to make sure it remains free
18
+ software for all its users.
19
+
20
+ When we speak of free software, we are referring to freedom, not
21
+ price. Our General Public Licenses are designed to make sure that you
22
+ have the freedom to distribute copies of free software (and charge for
23
+ them if you wish), that you receive source code or can get it if you
24
+ want it, that you can change the software or use pieces of it in new
25
+ free programs, and that you know you can do these things.
26
+
27
+ Developers that use our General Public Licenses protect your rights
28
+ with two steps: (1) assert copyright on the software, and (2) offer
29
+ you this License which gives you legal permission to copy, distribute
30
+ and/or modify the software.
31
+
32
+ A secondary benefit of defending all users' freedom is that
33
+ improvements made in alternate versions of the program, if they
34
+ receive widespread use, become available for other developers to
35
+ incorporate. Many developers of free software are heartened and
36
+ encouraged by the resulting cooperation. However, in the case of
37
+ software used on network servers, this result may fail to come about.
38
+ The GNU General Public License permits making a modified version and
39
+ letting the public access it on a server without ever releasing its
40
+ source code to the public.
41
+
42
+ The GNU Affero General Public License is designed specifically to
43
+ ensure that, in such cases, the modified source code becomes available
44
+ to the community. It requires the operator of a network server to
45
+ provide the source code of the modified version running there to the
46
+ users of that server. Therefore, public use of a modified version, on
47
+ a publicly accessible server, gives the public access to the source
48
+ code of the modified version.
49
+
50
+ An older license, called the Affero General Public License and
51
+ published by Affero, was designed to accomplish similar goals. This is
52
+ a different license, not a version of the Affero GPL, but Affero has
53
+ released a new version of the Affero GPL which permits relicensing under
54
+ this license.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ TERMS AND CONDITIONS
60
+
61
+ 0. Definitions.
62
+
63
+ "This License" refers to version 3 of the GNU Affero General Public License.
64
+
65
+ "Copyright" also means copyright-like laws that apply to other kinds of
66
+ works, such as semiconductor masks.
67
+
68
+ "The Program" refers to any copyrightable work licensed under this
69
+ License. Each licensee is addressed as "you". "Licensees" and
70
+ "recipients" may be individuals or organizations.
71
+
72
+ To "modify" a work means to copy from or adapt all or part of the work
73
+ in a fashion requiring copyright permission, other than the making of an
74
+ exact copy. The resulting work is called a "modified version" of the
75
+ earlier work or a work "based on" the earlier work.
76
+
77
+ A "covered work" means either the unmodified Program or a work based
78
+ on the Program.
79
+
80
+ To "propagate" a work means to do anything with it that, without
81
+ permission, would make you directly or secondarily liable for
82
+ infringement under applicable copyright law, except executing it on a
83
+ computer or modifying a private copy. Propagation includes copying,
84
+ distribution (with or without modification), making available to the
85
+ public, and in some countries other activities as well.
86
+
87
+ To "convey" a work means any kind of propagation that enables other
88
+ parties to make or receive copies. Mere interaction with a user through
89
+ a computer network, with no transfer of a copy, is not conveying.
90
+
91
+ An interactive user interface displays "Appropriate Legal Notices"
92
+ to the extent that it includes a convenient and prominently visible
93
+ feature that (1) displays an appropriate copyright notice, and (2)
94
+ tells the user that there is no warranty for the work (except to the
95
+ extent that warranties are provided), that licensees may convey the
96
+ work under this License, and how to view a copy of this License. If
97
+ the interface presents a list of user commands or options, such as a
98
+ menu, a prominent item in the list meets this criterion.
99
+
100
+ 1. Source Code.
101
+
102
+ The "source code" for a work means the preferred form of the work
103
+ for making modifications to it. "Object code" means any non-source
104
+ form of a work.
105
+
106
+ A "Standard Interface" means an interface that either is an official
107
+ standard defined by a recognized standards body, or, in the case of
108
+ interfaces specified for a particular programming language, one that
109
+ is widely used among developers working in that language.
110
+
111
+ The "System Libraries" of an executable work include anything, other
112
+ than the work as a whole, that (a) is included in the normal form of
113
+ packaging a Major Component, but which is not part of that Major
114
+ Component, and (b) serves only to enable use of the work with that
115
+ Major Component, or to implement a Standard Interface for which an
116
+ implementation is available to the public in source code form. A
117
+ "Major Component", in this context, means a major essential component
118
+ (kernel, window system, and so on) of the specific operating system
119
+ (if any) on which the executable work runs, or a compiler used to
120
+ produce the work, or an object code interpreter used to run it.
121
+
122
+ The "Corresponding Source" for a work in object code form means all
123
+ the source code needed to generate, install, and (for an executable
124
+ work) run the object code and to modify the work, including scripts to
125
+ control those activities. However, it does not include the work's
126
+ System Libraries, or general-purpose tools or generally available free
127
+ programs which are used unmodified in performing those activities but
128
+ which are not part of the work. For example, Corresponding Source
129
+ includes interface definition files associated with source files for
130
+ the work, and the source code for shared libraries and dynamically
131
+ linked subprograms that the work is specifically designed to require,
132
+ such as by intimate data communication or control flow between those
133
+ subprograms and other parts of the work.
134
+
135
+ The Corresponding Source need not include anything that users
136
+ can regenerate automatically from other parts of the Corresponding
137
+ Source.
138
+
139
+ The Corresponding Source for a work in source code form is that
140
+ same work.
141
+
142
+ 2. Basic Permissions.
143
+
144
+ All rights granted under this License are granted for the term of
145
+ copyright on the Program, and are irrevocable provided the stated
146
+ conditions are met. This License explicitly affirms your unlimited
147
+ permission to run the unmodified Program. The output from running a
148
+ covered work is covered by this License only if the output, given its
149
+ content, constitutes a covered work. This License acknowledges your
150
+ rights of fair use or other equivalent, as provided by copyright law.
151
+
152
+ You may make, run and propagate covered works that you do not
153
+ convey, without conditions so long as your license otherwise remains
154
+ in force. You may convey covered works to others for the sole purpose
155
+ of having them make modifications exclusively for you, or provide you
156
+ with facilities for running those works, provided that you comply with
157
+ the terms of this License in conveying all material for which you do
158
+ not control copyright. Those thus making or running the covered works
159
+ for you must do so exclusively on your behalf, under your direction
160
+ and control, on terms that prohibit them from making any copies of
161
+ your copyrighted material outside their relationship with you.
162
+
163
+ Conveying under any other circumstances is permitted solely under
164
+ the conditions stated below. Sublicensing is not allowed; section 10
165
+ makes it unnecessary.
166
+
167
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
168
+
169
+ No covered work shall be deemed part of an effective technological
170
+ measure under any applicable law fulfilling obligations under article
171
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
172
+ similar laws prohibiting or restricting circumvention of such
173
+ measures.
174
+
175
+ When you convey a covered work, you waive any legal power to forbid
176
+ circumvention of technological measures to the extent such circumvention
177
+ is effected by exercising rights under this License with respect to
178
+ the covered work, and you disclaim any intention to limit operation or
179
+ modification of the work as a means of enforcing, against the work's
180
+ users, your or third parties' legal rights to forbid circumvention of
181
+ technological measures.
182
+
183
+ 4. Conveying Verbatim Copies.
184
+
185
+ You may convey verbatim copies of the Program's source code as you
186
+ receive it, in any medium, provided that you conspicuously and
187
+ appropriately publish on each copy an appropriate copyright notice;
188
+ keep intact all notices stating that this License and any
189
+ non-permissive terms added in accord with section 7 apply to the code;
190
+ keep intact all notices of the absence of any warranty; and give all
191
+ recipients a copy of this License along with the Program.
192
+
193
+ You may charge any price or no price for each copy that you convey,
194
+ and you may offer support or warranty protection for a fee.
195
+
196
+ 5. Conveying Modified Source Versions.
197
+
198
+ You may convey a work based on the Program, or the modifications to
199
+ produce it from the Program, in the form of source code under the
200
+ terms of section 4, provided that you also meet all of these conditions:
201
+
202
+ a) The work must carry prominent notices stating that you modified
203
+ it, and giving a relevant date.
204
+
205
+ b) The work must carry prominent notices stating that it is
206
+ released under this License and any conditions added under section
207
+ 7. This requirement modifies the requirement in section 4 to
208
+ "keep intact all notices".
209
+
210
+ c) You must license the entire work, as a whole, under this
211
+ License to anyone who comes into possession of a copy. This
212
+ License will therefore apply, along with any applicable section 7
213
+ additional terms, to the whole of the work, and all its parts,
214
+ regardless of how they are packaged. This License gives no
215
+ permission to license the work in any other way, but it does not
216
+ invalidate such permission if you have separately received it.
217
+
218
+ d) If the work has interactive user interfaces, each must display
219
+ Appropriate Legal Notices; however, if the Program has interactive
220
+ interfaces that do not display Appropriate Legal Notices, your
221
+ work need not make them do so.
222
+
223
+ A compilation of a covered work with other separate and independent
224
+ works, which are not by their nature extensions of the covered work,
225
+ and which are not combined with it such as to form a larger program,
226
+ in or on a volume of a storage or distribution medium, is called an
227
+ "aggregate" if the compilation and its resulting copyright are not
228
+ used to limit the access or legal rights of the compilation's users
229
+ beyond what the individual works permit. Inclusion of a covered work
230
+ in an aggregate does not cause this License to apply to the other
231
+ parts of the aggregate.
232
+
233
+ 6. Conveying Non-Source Forms.
234
+
235
+ You may convey a covered work in object code form under the terms
236
+ of sections 4 and 5, provided that you also convey the
237
+ machine-readable Corresponding Source under the terms of this License,
238
+ in one of these ways:
239
+
240
+ a) Convey the object code in, or embodied in, a physical product
241
+ (including a physical distribution medium), accompanied by the
242
+ Corresponding Source fixed on a durable physical medium
243
+ customarily used for software interchange.
244
+
245
+ b) Convey the object code in, or embodied in, a physical product
246
+ (including a physical distribution medium), accompanied by a
247
+ written offer, valid for at least three years and valid for as
248
+ long as you offer spare parts or customer support for that product
249
+ model, to give anyone who possesses the object code either (1) a
250
+ copy of the Corresponding Source for all the software in the
251
+ product that is covered by this License, on a durable physical
252
+ medium customarily used for software interchange, for a price no
253
+ more than your reasonable cost of physically performing this
254
+ conveying of source, or (2) access to copy the
255
+ Corresponding Source from a network server at no charge.
256
+
257
+ c) Convey individual copies of the object code with a copy of the
258
+ written offer to provide the Corresponding Source. This
259
+ alternative is allowed only occasionally and noncommercially, and
260
+ only if you received the object code with such an offer, in accord
261
+ with subsection 6b.
262
+
263
+ d) Convey the object code by offering access from a designated
264
+ place (gratis or for a charge), and offer equivalent access to the
265
+ Corresponding Source in the same way through the same place at no
266
+ further charge. You need not require recipients to copy the
267
+ Corresponding Source along with the object code. If the place to
268
+ copy the object code is a network server, the Corresponding Source
269
+ may be on a different server (operated by you or a third party)
270
+ that supports equivalent copying facilities, provided you maintain
271
+ clear directions next to the object code saying where to find the
272
+ Corresponding Source. Regardless of what server hosts the
273
+ Corresponding Source, you remain obligated to ensure that it is
274
+ available for as long as needed to satisfy these requirements.
275
+
276
+ e) Convey the object code using peer-to-peer transmission, provided
277
+ you inform other peers where the object code and Corresponding
278
+ Source of the work are being offered to the general public at no
279
+ charge under subsection 6d.
280
+
281
+ A separable portion of the object code, whose source code is excluded
282
+ from the Corresponding Source as a System Library, need not be
283
+ included in conveying the object code work.
284
+
285
+ A "User Product" is either (1) a "consumer product", which means any
286
+ tangible personal property which is normally used for personal, family,
287
+ or household purposes, or (2) anything designed or sold for incorporation
288
+ into a dwelling. In determining whether a product is a consumer product,
289
+ doubtful cases shall be resolved in favor of coverage. For a particular
290
+ product received by a particular user, "normally used" refers to a
291
+ typical or common use of that class of product, regardless of the status
292
+ of the particular user or of the way in which the particular user
293
+ actually uses, or expects or is expected to use, the product. A product
294
+ is a consumer product regardless of whether the product has substantial
295
+ commercial, industrial or non-consumer uses, unless such uses represent
296
+ the only significant mode of use of the product.
297
+
298
+ "Installation Information" for a User Product means any methods,
299
+ procedures, authorization keys, or other information required to install
300
+ and execute modified versions of a covered work in that User Product from
301
+ a modified version of its Corresponding Source. The information must
302
+ suffice to ensure that the continued functioning of the modified object
303
+ code is in no case prevented or interfered with solely because
304
+ modification has been made.
305
+
306
+ If you convey an object code work under this section in, or with, or
307
+ specifically for use in, a User Product, and the conveying occurs as
308
+ part of a transaction in which the right of possession and use of the
309
+ User Product is transferred to the recipient in perpetuity or for a
310
+ fixed term (regardless of how the transaction is characterized), the
311
+ Corresponding Source conveyed under this section must be accompanied
312
+ by the Installation Information. But this requirement does not apply
313
+ if neither you nor any third party retains the ability to install
314
+ modified object code on the User Product (for example, the work has
315
+ been installed in ROM).
316
+
317
+ The requirement to provide Installation Information does not include a
318
+ requirement to continue to provide support service, warranty, or updates
319
+ for a work that has been modified or installed by the recipient, or for
320
+ the User Product in which it has been modified or installed. Access to a
321
+ network may be denied when the modification itself materially and
322
+ adversely affects the operation of the network or violates the rules and
323
+ protocols for communication across the network.
324
+
325
+ Corresponding Source conveyed, and Installation Information provided,
326
+ in accord with this section must be in a format that is publicly
327
+ documented (and with an implementation available to the public in
328
+ source code form), and must require no special password or key for
329
+ unpacking, reading or copying.
330
+
331
+ 7. Additional Terms.
332
+
333
+ "Additional permissions" are terms that supplement the terms of this
334
+ License by making exceptions from one or more of its conditions.
335
+ Additional permissions that are applicable to the entire Program shall
336
+ be treated as though they were included in this License, to the extent
337
+ that they are valid under applicable law. If additional permissions
338
+ apply only to part of the Program, that part may be used separately
339
+ under those permissions, but the entire Program remains governed by
340
+ this License without regard to the additional permissions.
341
+
342
+ When you convey a copy of a covered work, you may at your option
343
+ remove any additional permissions from that copy, or from any part of
344
+ it. (Additional permissions may be written to require their own
345
+ removal in certain cases when you modify the work.) You may place
346
+ additional permissions on material, added by you to a covered work,
347
+ for which you have or can give appropriate copyright permission.
348
+
349
+ Notwithstanding any other provision of this License, for material you
350
+ add to a covered work, you may (if authorized by the copyright holders of
351
+ that material) supplement the terms of this License with terms:
352
+
353
+ a) Disclaiming warranty or limiting liability differently from the
354
+ terms of sections 15 and 16 of this License; or
355
+
356
+ b) Requiring preservation of specified reasonable legal notices or
357
+ author attributions in that material or in the Appropriate Legal
358
+ Notices displayed by works containing it; or
359
+
360
+ c) Prohibiting misrepresentation of the origin of that material, or
361
+ requiring that modified versions of such material be marked in
362
+ reasonable ways as different from the original version; or
363
+
364
+ d) Limiting the use for publicity purposes of names of licensors or
365
+ authors of the material; or
366
+
367
+ e) Declining to grant rights under trademark law for use of some
368
+ trade names, trademarks, or service marks; or
369
+
370
+ f) Requiring indemnification of licensors and authors of that
371
+ material by anyone who conveys the material (or modified versions of
372
+ it) with contractual assumptions of liability to the recipient, for
373
+ any liability that these contractual assumptions directly impose on
374
+ those licensors and authors.
375
+
376
+ All other non-permissive additional terms are considered "further
377
+ restrictions" within the meaning of section 10. If the Program as you
378
+ received it, or any part of it, contains a notice stating that it is
379
+ governed by this License along with a term that is a further
380
+ restriction, you may remove that term. If a license document contains
381
+ a further restriction but permits relicensing or conveying under this
382
+ License, you may add to a covered work material governed by the terms
383
+ of that license document, provided that the further restriction does
384
+ not survive such relicensing or conveying.
385
+
386
+ If you add terms to a covered work in accord with this section, you
387
+ must place, in the relevant source files, a statement of the
388
+ additional terms that apply to those files, or a notice indicating
389
+ where to find the applicable terms.
390
+
391
+ Additional terms, permissive or non-permissive, may be stated in the
392
+ form of a separately written license, or stated as exceptions;
393
+ the above requirements apply either way.
394
+
395
+ 8. Termination.
396
+
397
+ You may not propagate or modify a covered work except as expressly
398
+ provided under this License. Any attempt otherwise to propagate or
399
+ modify it is void, and will automatically terminate your rights under
400
+ this License (including any patent licenses granted under the third
401
+ paragraph of section 11).
402
+
403
+ However, if you cease all violation of this License, then your
404
+ license from a particular copyright holder is reinstated (a)
405
+ provisionally, unless and until the copyright holder explicitly and
406
+ finally terminates your license, and (b) permanently, if the copyright
407
+ holder fails to notify you of the violation by some reasonable means
408
+ prior to 60 days after the cessation.
409
+
410
+ Moreover, your license from a particular copyright holder is
411
+ reinstated permanently if the copyright holder notifies you of the
412
+ violation by some reasonable means, this is the first time you have
413
+ received notice of violation of this License (for any work) from that
414
+ copyright holder, and you cure the violation prior to 30 days after
415
+ your receipt of the notice.
416
+
417
+ Termination of your rights under this section does not terminate the
418
+ licenses of parties who have received copies or rights from you under
419
+ this License. If your rights have been terminated and not permanently
420
+ reinstated, you do not qualify to receive new licenses for the same
421
+ material under section 10.
422
+
423
+ 9. Acceptance Not Required for Having Copies.
424
+
425
+ You are not required to accept this License in order to receive or
426
+ run a copy of the Program. Ancillary propagation of a covered work
427
+ occurring solely as a consequence of using peer-to-peer transmission
428
+ to receive a copy likewise does not require acceptance. However,
429
+ nothing other than this License grants you permission to propagate or
430
+ modify any covered work. These actions infringe copyright if you do
431
+ not accept this License. Therefore, by modifying or propagating a
432
+ covered work, you indicate your acceptance of this License to do so.
433
+
434
+ 10. Automatic Licensing of Downstream Recipients.
435
+
436
+ Each time you convey a covered work, the recipient automatically
437
+ receives a license from the original licensors, to run, modify and
438
+ propagate that work, subject to this License. You are not responsible
439
+ for enforcing compliance by third parties with this License.
440
+
441
+ An "entity transaction" is a transaction transferring control of an
442
+ organization, or substantially all assets of one, or subdividing an
443
+ organization, or merging organizations. If propagation of a covered
444
+ work results from an entity transaction, each party to that
445
+ transaction who receives a copy of the work also receives whatever
446
+ licenses to the work the party's predecessor in interest had or could
447
+ give under the previous paragraph, plus a right to possession of the
448
+ Corresponding Source of the work from the predecessor in interest, if
449
+ the predecessor has it or can get it with reasonable efforts.
450
+
451
+ You may not impose any further restrictions on the exercise of the
452
+ rights granted or affirmed under this License. For example, you may
453
+ not impose a license fee, royalty, or other charge for exercise of
454
+ rights granted under this License, and you may not initiate litigation
455
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
456
+ any patent claim is infringed by making, using, selling, offering for
457
+ sale, or importing the Program or any portion of it.
458
+
459
+ 11. Patents.
460
+
461
+ A "contributor" is a copyright holder who authorizes use under this
462
+ License of the Program or a work on which the Program is based. The
463
+ work thus licensed is called the contributor's "contributor version".
464
+
465
+ A contributor's "essential patent claims" are all patent claims
466
+ owned or controlled by the contributor, whether already acquired or
467
+ hereafter acquired, that would be infringed by some manner, permitted
468
+ by this License, of making, using, or selling its contributor version,
469
+ but do not include claims that would be infringed only as a
470
+ consequence of further modification of the contributor version. For
471
+ purposes of this definition, "control" includes the right to grant
472
+ patent sublicenses in a manner consistent with the requirements of
473
+ this License.
474
+
475
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
476
+ patent license under the contributor's essential patent claims, to
477
+ make, use, sell, offer for sale, import and otherwise run, modify and
478
+ propagate the contents of its contributor version.
479
+
480
+ In the following three paragraphs, a "patent license" is any express
481
+ agreement or commitment, however denominated, not to enforce a patent
482
+ (such as an express permission to practice a patent or covenant not to
483
+ sue for patent infringement). To "grant" such a patent license to a
484
+ party means to make such an agreement or commitment not to enforce a
485
+ patent against the party.
486
+
487
+ If you convey a covered work, knowingly relying on a patent license,
488
+ and the Corresponding Source of the work is not available for anyone
489
+ to copy, free of charge and under the terms of this License, through a
490
+ publicly available network server or other readily accessible means,
491
+ then you must either (1) cause the Corresponding Source to be so
492
+ available, or (2) arrange to deprive yourself of the benefit of the
493
+ patent license for this particular work, or (3) arrange, in a manner
494
+ consistent with the requirements of this License, to extend the patent
495
+ license to downstream recipients. "Knowingly relying" means you have
496
+ actual knowledge that, but for the patent license, your conveying the
497
+ covered work in a country, or your recipient's use of the covered work
498
+ in a country, would infringe one or more identifiable patents in that
499
+ country that you have reason to believe are valid.
500
+
501
+ If, pursuant to or in connection with a single transaction or
502
+ arrangement, you convey, or propagate by procuring conveyance of, a
503
+ covered work, and grant a patent license to some of the parties
504
+ receiving the covered work authorizing them to use, propagate, modify
505
+ or convey a specific copy of the covered work, then the patent license
506
+ you grant is automatically extended to all recipients of the covered
507
+ work and works based on it.
508
+
509
+ A patent license is "discriminatory" if it does not include within
510
+ the scope of its coverage, prohibits the exercise of, or is
511
+ conditioned on the non-exercise of one or more of the rights that are
512
+ specifically granted under this License. You may not convey a covered
513
+ work if you are a party to an arrangement with a third party that is
514
+ in the business of distributing software, under which you make payment
515
+ to the third party based on the extent of your activity of conveying
516
+ the work, and under which the third party grants, to any of the
517
+ parties who would receive the covered work from you, a discriminatory
518
+ patent license (a) in connection with copies of the covered work
519
+ conveyed by you (or copies made from those copies), or (b) primarily
520
+ for and in connection with specific products or compilations that
521
+ contain the covered work, unless you entered into that arrangement,
522
+ or that patent license was granted, prior to 28 March 2007.
523
+
524
+ Nothing in this License shall be construed as excluding or limiting
525
+ any implied license or other defenses to infringement that may
526
+ otherwise be available to you under applicable patent law.
527
+
528
+ 12. No Surrender of Others' Freedom.
529
+
530
+ If conditions are imposed on you (whether by court order, agreement or
531
+ otherwise) that contradict the conditions of this License, they do not
532
+ excuse you from the conditions of this License. If you cannot convey a
533
+ covered work so as to satisfy simultaneously your obligations under this
534
+ License and any other pertinent obligations, then as a consequence you may
535
+ not convey it at all. For example, if you agree to terms that obligate you
536
+ to collect a royalty for further conveying from those to whom you convey
537
+ the Program, the only way you could satisfy both those terms and this
538
+ License would be to refrain entirely from conveying the Program.
539
+
540
+ 13. Remote Network Interaction; Use with the GNU General Public License.
541
+
542
+ Notwithstanding any other provision of this License, if you modify the
543
+ Program, your modified version must prominently offer all users
544
+ interacting with it remotely through a computer network (if your version
545
+ supports such interaction) an opportunity to receive the Corresponding
546
+ Source of your version by providing access to the Corresponding Source
547
+ from a network server at no charge, through some standard or customary
548
+ means of facilitating copying of software. This Corresponding Source
549
+ shall include the Corresponding Source for any work covered by version 3
550
+ of the GNU General Public License that is incorporated pursuant to the
551
+ following paragraph.
552
+
553
+ Notwithstanding any other provision of this License, you have
554
+ permission to link or combine any covered work with a work licensed
555
+ under version 3 of the GNU General Public License into a single
556
+ combined work, and to convey the resulting work. The terms of this
557
+ License will continue to apply to the part which is the covered work,
558
+ but the work with which it is combined will remain governed by version
559
+ 3 of the GNU General Public License.
560
+
561
+ 14. Revised Versions of this License.
562
+
563
+ The Free Software Foundation may publish revised and/or new versions of
564
+ the GNU Affero General Public License from time to time. Such new versions
565
+ will be similar in spirit to the present version, but may differ in detail to
566
+ address new problems or concerns.
567
+
568
+ Each version is given a distinguishing version number. If the
569
+ Program specifies that a certain numbered version of the GNU Affero General
570
+ Public License "or any later version" applies to it, you have the
571
+ option of following the terms and conditions either of that numbered
572
+ version or of any later version published by the Free Software
573
+ Foundation. If the Program does not specify a version number of the
574
+ GNU Affero General Public License, you may choose any version ever published
575
+ by the Free Software Foundation.
576
+
577
+ If the Program specifies that a proxy can decide which future
578
+ versions of the GNU Affero General Public License can be used, that proxy's
579
+ public statement of acceptance of a version permanently authorizes you
580
+ to choose that version for the Program.
581
+
582
+ Later license versions may give you additional or different
583
+ permissions. However, no additional obligations are imposed on any
584
+ author or copyright holder as a result of your choosing to follow a
585
+ later version.
586
+
587
+ 15. Disclaimer of Warranty.
588
+
589
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
590
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
591
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
592
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
593
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
594
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
595
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
596
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
597
+
598
+ 16. Limitation of Liability.
599
+
600
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
601
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
602
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
603
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
604
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
605
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
606
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
607
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
608
+ SUCH DAMAGES.
609
+
610
+ 17. Interpretation of Sections 15 and 16.
611
+
612
+ If the disclaimer of warranty and limitation of liability provided
613
+ above cannot be given local legal effect according to their terms,
614
+ reviewing courts shall apply local law that most closely approximates
615
+ an absolute waiver of all civil liability in connection with the
616
+ Program, unless a warranty or assumption of liability accompanies a
617
+ copy of the Program in return for a fee.
618
+
619
+ END OF TERMS AND CONDITIONS
620
+
621
+ How to Apply These Terms to Your New Programs
622
+
623
+ If you develop a new program, and you want it to be of the greatest
624
+ possible use to the public, the best way to achieve this is to make it
625
+ free software which everyone can redistribute and change under these terms.
626
+
627
+ To do so, attach the following notices to the program. It is safest
628
+ to attach them to the start of each source file to most effectively
629
+ state the exclusion of warranty; and each file should have at least
630
+ the "copyright" line and a pointer to where the full notice is found.
631
+
632
+ <one line to give the program's name and a brief idea of what it does.>
633
+ Copyright (C) <year> <name of author>
634
+
635
+ This program is free software: you can redistribute it and/or modify
636
+ it under the terms of the GNU Affero General Public License as published by
637
+ the Free Software Foundation, either version 3 of the License, or
638
+ (at your option) any later version.
639
+
640
+ This program is distributed in the hope that it will be useful,
641
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
642
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
643
+ GNU Affero General Public License for more details.
644
+
645
+ You should have received a copy of the GNU Affero General Public License
646
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
647
+
648
+ Also add information on how to contact you by electronic and paper mail.
649
+
650
+ If your software can interact with users remotely through a computer
651
+ network, you should also make sure that it provides a way for users to
652
+ get its source. For example, if your program is a web application, its
653
+ interface could display a "Source" link that leads users to an archive
654
+ of the code. There are many ways you could offer source, and different
655
+ solutions will be better for different programs; see section 13 for the
656
+ specific requirements.
657
+
658
+ You should also get your employer (if you work as a programmer) or school,
659
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
660
+ For more information on this, and how to apply and follow the GNU AGPL, see
661
+ <https://www.gnu.org/licenses/>.
build.js ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ const {build} = require("./utils.js")
2
+
3
+ build();
dev-server.js ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require("express");
2
+ const { generateDevHtml, build } = require("./utils.js");
3
+ const { argv } = require('node:process');
4
+ const chalk = require('chalk');
5
+
6
+ const app = express();
7
+ let port = 4000; // Starting port
8
+ const maxAttempts = 10; // Maximum number of ports to try
9
+ const env = argv[2] ?? "dev";
10
+
11
+ const startServer = (attempt) => {
12
+ if (attempt > maxAttempts) {
13
+ console.error(chalk.red(`ERROR: Unable to find an available port after ${maxAttempts} attempts.`));
14
+ return;
15
+ }
16
+
17
+ app.listen(port, () => {
18
+ console.log("\n-----------------------------------------------------------\n");
19
+ console.log(`Puter is now live at: `, chalk.underline.blue(`http://localhost:${port}`));
20
+ console.log("\n-----------------------------------------------------------\n");
21
+ }).on('error', (err) => {
22
+ if (err.code === 'EADDRINUSE') { // Check if the error is because the port is already in use
23
+ console.error(chalk.red(`ERROR: Port ${port} is already in use. Trying next port...`));
24
+ port++; // Increment the port number
25
+ startServer(attempt + 1); // Try the next port
26
+ }
27
+ });
28
+ };
29
+
30
+ // Start the server with the first attempt
31
+ startServer(1);
32
+
33
+ // build the GUI
34
+ build();
35
+
36
+ app.get(["/", "/app/*", "/action/*"], (req, res) => {
37
+ res.send(generateDevHtml({
38
+ env: env,
39
+ api_origin: "https://api.puter.com",
40
+ title: "Puter",
41
+ max_item_name_length: 150,
42
+ require_email_verification_to_publish_website: false,
43
+ short_description: `Puter is a privacy-first personal cloud that houses all your files, apps, and games in one private and secure place, accessible from anywhere at any time.`,
44
+ }));
45
+ })
46
+ app.use(express.static('./'));
47
+
48
+ if(env === "prod"){
49
+ // make sure to serve the ./dist/ folder maps to the root of the website
50
+ app.use(express.static('./dist/'));
51
+ }
52
+
53
+ if(env === "dev"){
54
+ app.use(express.static('./src/'));
55
+ }
56
+
57
+ module.exports = app;
docker-compose.yml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ version: '3'
2
+
3
+ services:
4
+ app:
5
+ build: ./
6
+ ports:
7
+ - 4000:4000
docs/prod.md ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Puter in Production
2
+
3
+ ## Building
4
+
5
+ ```bash
6
+ npm run build
7
+ ```
8
+
9
+ ## Usage
10
+
11
+ Will build Puter in the `dist` directory. Include the generated `./dist/gui.js` file in your HTML page and call `gui()` when the page is loaded:
12
+
13
+ ```html
14
+ <script type="text/javascript" src="./dist/gui.js"></script>
15
+ <script type="text/javascript">
16
+ window.addEventListener('load', function() {
17
+ // Initialize the GUI. All options are optional!
18
+ gui({
19
+ // The origin of the app. This is the base URL of the GUI.
20
+ gui_origin: "https://puter.com",
21
+
22
+ // The origin of the API. This is the base URL of the API endpoints that the GUI will call for all its operations.
23
+ api_origin: "https://api.puter.com",
24
+
25
+ // The domain under which user websites are hosted.
26
+ hosting_domain: "puter.site",
27
+
28
+ // The maximum length of file/directory names.
29
+ max_item_name_length: 500,
30
+
31
+ // If GUI has to enforce email verification before allowing user to publish a website.
32
+ require_email_verification_to_publish_website: true,
33
+ })
34
+ });
35
+ </script>
36
+ ```
37
+
38
+ ## Full Production Example
39
+
40
+ Assuming the following directory structure in production:
41
+
42
+ ```
43
+ .
44
+ ├── dist/
45
+ │ ├── favicons/
46
+ │ ├── images/
47
+ │ ├── bundle.min.css
48
+ │ ├── bundle.min.js
49
+ │ ├── gui.js
50
+ │ └── ...
51
+ └── index.html
52
+ ```
53
+
54
+ The `index.html` file below will load Puter and all the necessary meta tags, favicons, and branding assets:
55
+
56
+ ```html
57
+ <!DOCTYPE html>
58
+ <html lang="en">
59
+
60
+ <head>
61
+ <title>Puter</title>
62
+ <meta name="author" content="Puter Technologies Inc.">
63
+ <meta name="description" content="Puter is a privacy-first personal cloud to keep all your files, apps, and games in one private and secure place, accessible from anywhere at any time.">
64
+ <meta name="facebook-domain-verification" content="e29w3hjbnnnypf4kzk2cewcdaxym1y" />
65
+ <link rel="canonical" href="https://puter.com">
66
+
67
+ <!-- Meta meta tags -->
68
+ <meta property="og:url" content="https://puter.com">
69
+ <meta property="og:type" content="website">
70
+ <meta property="og:title" content="Puter">
71
+ <meta property="og:description" content="Puter is a privacy-first personal cloud to keep all your files, apps, and games in one private and secure place, accessible from anywhere at any time.">
72
+ <meta property="og:image" content="./dist/images/screenshot.png">
73
+
74
+ <!-- Twitter meta tags -->
75
+ <meta name="twitter:card" content="summary_large_image">
76
+ <meta property="twitter:domain" content="puter.com">
77
+ <meta property="twitter:url" content="https://puter.com">
78
+ <meta name="twitter:title" content="Puter">
79
+ <meta name="twitter:description" content="Puter is a privacy-first personal cloud to keep all your files, apps, and games in one private and secure place, accessible from anywhere at any time.">
80
+ <meta name="twitter:image" content="./dist/images/screenshot.png">
81
+
82
+ <!-- favicons -->
83
+ <link rel="apple-touch-icon" sizes="57x57" href="./dist/favicons/apple-icon-57x57.png">
84
+ <link rel="apple-touch-icon" sizes="60x60" href="./dist/favicons/apple-icon-60x60.png">
85
+ <link rel="apple-touch-icon" sizes="72x72" href="./dist/favicons/apple-icon-72x72.png">
86
+ <link rel="apple-touch-icon" sizes="76x76" href="./dist/favicons/apple-icon-76x76.png">
87
+ <link rel="apple-touch-icon" sizes="114x114" href="./dist/favicons/apple-icon-114x114.png">
88
+ <link rel="apple-touch-icon" sizes="120x120" href="./dist/favicons/apple-icon-120x120.png">
89
+ <link rel="apple-touch-icon" sizes="144x144" href="./dist/favicons/apple-icon-144x144.png">
90
+ <link rel="apple-touch-icon" sizes="152x152" href="./dist/favicons/apple-icon-152x152.png">
91
+ <link rel="apple-touch-icon" sizes="180x180" href="./dist/favicons/apple-icon-180x180.png">
92
+ <link rel="icon" type="image/png" sizes="192x192" href="./dist/favicons/android-icon-192x192.png">
93
+ <link rel="icon" type="image/png" sizes="32x32" href="./dist/favicons/favicon-32x32.png">
94
+ <link rel="icon" type="image/png" sizes="96x96" href="./dist/favicons/favicon-96x96.png">
95
+ <link rel="icon" type="image/png" sizes="16x16" href="./dist/favicons/favicon-16x16.png">
96
+ <link rel="manifest" href="./dist/manifest.json">
97
+ <meta name="msapplication-TileColor" content="#ffffff">
98
+ <meta name="msapplication-TileImage" content="./dist/favicons/ms-icon-144x144.png">
99
+ <meta name="theme-color" content="#ffffff">
100
+
101
+ <!-- Preload images when applicable -->
102
+ <link rel="preload" as="image" href="./dist/images/wallpaper.webp">
103
+ </head>
104
+
105
+ <body>
106
+ <!-- Load the GUI script -->
107
+ <script type="text/javascript" src="./dist/gui.js"></script>
108
+ <!-- Initialize GUI when document is loaded -->
109
+ <script type="text/javascript">
110
+ window.addEventListener('load', function() {
111
+ gui()
112
+ });
113
+ </script>
114
+ </body>
115
+
116
+ </html>
117
+ ```
118
+
119
+ ### Server settings
120
+
121
+ The GUI is a single page application (SPA) and as best practice any route under root (`/*`) should preferably load the `index.html` file. However, there are situations where we want to load a custom page for a specific route: for example, the `/privacy` route may need to load a page that contains your privacy policy and has nothing to do with the GUI application. In these cases it is ok to load a custom page as long as the following essential GUI routes are loaded with the GUI (i.e. `index.html` file):
122
+ - `/app/*`
123
+ - `/action/*`
124
+
125
+ In other words, consider the routes above as "reserved" for Puter.
126
+
127
+ ### Best Practices
128
+
129
+ - The `title` tags and meta tags (`<title></title>`, `<meta property="og:title"`, `<meta name="twitter:title"`, ...) should be dynamically set by the server. For example, if the URL is of an app (e.g. `https://puter.com/app/editor`) the `title` tags and meta tags should contain the app's title rather than the generic Puter title.
130
+
131
+ - The `description` meta tags (`<meta name="description"`, `<meta property="og:description"`, `<meta name="twitter:description"`, ...) should be dynamically set by the server. For example, if the URL is of an app (e.g. `https://puter.com/app/editor`) the `description` meta tags should contain the app's description rather than the generic Puter description.
132
+
133
+ - Make sure to escape any HTML code that is dynamically added to the HTML page. For example, if the app's description is `Puter is a <b>privacy-first</b> personal cloud to keep all your files, apps, and games in one private and secure place, accessible from anywhere at any time.` the `<b>` tag should be escaped to `&lt;b&gt;` so that the browser doesn't interpret it as an HTML tag.
134
+
135
+ - Make sure to replace all new line characters with space when dynamically adding text to the HTML page.
136
+
137
+ - Generally, for UX and SEO reasons make sure that the tags are filled with relevant information about the state the URL is representing. E.g. is the user on the desktop or an app?
package-lock.json ADDED
@@ -0,0 +1,2510 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "puter.com",
3
+ "version": "1.0.0",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "puter.com",
9
+ "version": "1.0.0",
10
+ "license": "AGPL-3.0-only",
11
+ "devDependencies": {
12
+ "chalk": "^4.1.0",
13
+ "clean-css": "^5.3.2",
14
+ "express": "^4.18.2",
15
+ "html-entities": "^2.3.3",
16
+ "nodemon": "^2.0.22",
17
+ "uglify-js": "^3.17.4",
18
+ "webpack": "^5.88.2",
19
+ "webpack-cli": "^5.1.1"
20
+ }
21
+ },
22
+ "node_modules/@discoveryjs/json-ext": {
23
+ "version": "0.5.7",
24
+ "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz",
25
+ "integrity": "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==",
26
+ "dev": true,
27
+ "engines": {
28
+ "node": ">=10.0.0"
29
+ }
30
+ },
31
+ "node_modules/@jridgewell/gen-mapping": {
32
+ "version": "0.3.5",
33
+ "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz",
34
+ "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==",
35
+ "dev": true,
36
+ "dependencies": {
37
+ "@jridgewell/set-array": "^1.2.1",
38
+ "@jridgewell/sourcemap-codec": "^1.4.10",
39
+ "@jridgewell/trace-mapping": "^0.3.24"
40
+ },
41
+ "engines": {
42
+ "node": ">=6.0.0"
43
+ }
44
+ },
45
+ "node_modules/@jridgewell/resolve-uri": {
46
+ "version": "3.1.2",
47
+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
48
+ "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
49
+ "dev": true,
50
+ "engines": {
51
+ "node": ">=6.0.0"
52
+ }
53
+ },
54
+ "node_modules/@jridgewell/set-array": {
55
+ "version": "1.2.1",
56
+ "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz",
57
+ "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==",
58
+ "dev": true,
59
+ "engines": {
60
+ "node": ">=6.0.0"
61
+ }
62
+ },
63
+ "node_modules/@jridgewell/source-map": {
64
+ "version": "0.3.5",
65
+ "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.5.tgz",
66
+ "integrity": "sha512-UTYAUj/wviwdsMfzoSJspJxbkH5o1snzwX0//0ENX1u/55kkZZkcTZP6u9bwKGkv+dkk9at4m1Cpt0uY80kcpQ==",
67
+ "dev": true,
68
+ "dependencies": {
69
+ "@jridgewell/gen-mapping": "^0.3.0",
70
+ "@jridgewell/trace-mapping": "^0.3.9"
71
+ }
72
+ },
73
+ "node_modules/@jridgewell/sourcemap-codec": {
74
+ "version": "1.4.15",
75
+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz",
76
+ "integrity": "sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==",
77
+ "dev": true
78
+ },
79
+ "node_modules/@jridgewell/trace-mapping": {
80
+ "version": "0.3.25",
81
+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz",
82
+ "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==",
83
+ "dev": true,
84
+ "dependencies": {
85
+ "@jridgewell/resolve-uri": "^3.1.0",
86
+ "@jridgewell/sourcemap-codec": "^1.4.14"
87
+ }
88
+ },
89
+ "node_modules/@types/eslint": {
90
+ "version": "8.56.5",
91
+ "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.5.tgz",
92
+ "integrity": "sha512-u5/YPJHo1tvkSF2CE0USEkxon82Z5DBy2xR+qfyYNszpX9qcs4sT6uq2kBbj4BXY1+DBGDPnrhMZV3pKWGNukw==",
93
+ "dev": true,
94
+ "dependencies": {
95
+ "@types/estree": "*",
96
+ "@types/json-schema": "*"
97
+ }
98
+ },
99
+ "node_modules/@types/eslint-scope": {
100
+ "version": "3.7.7",
101
+ "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.7.tgz",
102
+ "integrity": "sha512-MzMFlSLBqNF2gcHWO0G1vP/YQyfvrxZ0bF+u7mzUdZ1/xK4A4sru+nraZz5i3iEIk1l1uyicaDVTB4QbbEkAYg==",
103
+ "dev": true,
104
+ "dependencies": {
105
+ "@types/eslint": "*",
106
+ "@types/estree": "*"
107
+ }
108
+ },
109
+ "node_modules/@types/estree": {
110
+ "version": "1.0.5",
111
+ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
112
+ "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==",
113
+ "dev": true
114
+ },
115
+ "node_modules/@types/json-schema": {
116
+ "version": "7.0.15",
117
+ "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
118
+ "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
119
+ "dev": true
120
+ },
121
+ "node_modules/@types/node": {
122
+ "version": "20.11.24",
123
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.24.tgz",
124
+ "integrity": "sha512-Kza43ewS3xoLgCEpQrsT+xRo/EJej1y0kVYGiLFE1NEODXGzTfwiC6tXTLMQskn1X4/Rjlh0MQUvx9W+L9long==",
125
+ "dev": true,
126
+ "dependencies": {
127
+ "undici-types": "~5.26.4"
128
+ }
129
+ },
130
+ "node_modules/@webassemblyjs/ast": {
131
+ "version": "1.11.6",
132
+ "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.6.tgz",
133
+ "integrity": "sha512-IN1xI7PwOvLPgjcf180gC1bqn3q/QaOCwYUahIOhbYUu8KA/3tw2RT/T0Gidi1l7Hhj5D/INhJxiICObqpMu4Q==",
134
+ "dev": true,
135
+ "dependencies": {
136
+ "@webassemblyjs/helper-numbers": "1.11.6",
137
+ "@webassemblyjs/helper-wasm-bytecode": "1.11.6"
138
+ }
139
+ },
140
+ "node_modules/@webassemblyjs/floating-point-hex-parser": {
141
+ "version": "1.11.6",
142
+ "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.6.tgz",
143
+ "integrity": "sha512-ejAj9hfRJ2XMsNHk/v6Fu2dGS+i4UaXBXGemOfQ/JfQ6mdQg/WXtwleQRLLS4OvfDhv8rYnVwH27YJLMyYsxhw==",
144
+ "dev": true
145
+ },
146
+ "node_modules/@webassemblyjs/helper-api-error": {
147
+ "version": "1.11.6",
148
+ "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.6.tgz",
149
+ "integrity": "sha512-o0YkoP4pVu4rN8aTJgAyj9hC2Sv5UlkzCHhxqWj8butaLvnpdc2jOwh4ewE6CX0txSfLn/UYaV/pheS2Txg//Q==",
150
+ "dev": true
151
+ },
152
+ "node_modules/@webassemblyjs/helper-buffer": {
153
+ "version": "1.11.6",
154
+ "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.6.tgz",
155
+ "integrity": "sha512-z3nFzdcp1mb8nEOFFk8DrYLpHvhKC3grJD2ardfKOzmbmJvEf/tPIqCY+sNcwZIY8ZD7IkB2l7/pqhUhqm7hLA==",
156
+ "dev": true
157
+ },
158
+ "node_modules/@webassemblyjs/helper-numbers": {
159
+ "version": "1.11.6",
160
+ "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.6.tgz",
161
+ "integrity": "sha512-vUIhZ8LZoIWHBohiEObxVm6hwP034jwmc9kuq5GdHZH0wiLVLIPcMCdpJzG4C11cHoQ25TFIQj9kaVADVX7N3g==",
162
+ "dev": true,
163
+ "dependencies": {
164
+ "@webassemblyjs/floating-point-hex-parser": "1.11.6",
165
+ "@webassemblyjs/helper-api-error": "1.11.6",
166
+ "@xtuc/long": "4.2.2"
167
+ }
168
+ },
169
+ "node_modules/@webassemblyjs/helper-wasm-bytecode": {
170
+ "version": "1.11.6",
171
+ "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.6.tgz",
172
+ "integrity": "sha512-sFFHKwcmBprO9e7Icf0+gddyWYDViL8bpPjJJl0WHxCdETktXdmtWLGVzoHbqUcY4Be1LkNfwTmXOJUFZYSJdA==",
173
+ "dev": true
174
+ },
175
+ "node_modules/@webassemblyjs/helper-wasm-section": {
176
+ "version": "1.11.6",
177
+ "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.6.tgz",
178
+ "integrity": "sha512-LPpZbSOwTpEC2cgn4hTydySy1Ke+XEu+ETXuoyvuyezHO3Kjdu90KK95Sh9xTbmjrCsUwvWwCOQQNta37VrS9g==",
179
+ "dev": true,
180
+ "dependencies": {
181
+ "@webassemblyjs/ast": "1.11.6",
182
+ "@webassemblyjs/helper-buffer": "1.11.6",
183
+ "@webassemblyjs/helper-wasm-bytecode": "1.11.6",
184
+ "@webassemblyjs/wasm-gen": "1.11.6"
185
+ }
186
+ },
187
+ "node_modules/@webassemblyjs/ieee754": {
188
+ "version": "1.11.6",
189
+ "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.11.6.tgz",
190
+ "integrity": "sha512-LM4p2csPNvbij6U1f19v6WR56QZ8JcHg3QIJTlSwzFcmx6WSORicYj6I63f9yU1kEUtrpG+kjkiIAkevHpDXrg==",
191
+ "dev": true,
192
+ "dependencies": {
193
+ "@xtuc/ieee754": "^1.2.0"
194
+ }
195
+ },
196
+ "node_modules/@webassemblyjs/leb128": {
197
+ "version": "1.11.6",
198
+ "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.11.6.tgz",
199
+ "integrity": "sha512-m7a0FhE67DQXgouf1tbN5XQcdWoNgaAuoULHIfGFIEVKA6tu/edls6XnIlkmS6FrXAquJRPni3ZZKjw6FSPjPQ==",
200
+ "dev": true,
201
+ "dependencies": {
202
+ "@xtuc/long": "4.2.2"
203
+ }
204
+ },
205
+ "node_modules/@webassemblyjs/utf8": {
206
+ "version": "1.11.6",
207
+ "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.11.6.tgz",
208
+ "integrity": "sha512-vtXf2wTQ3+up9Zsg8sa2yWiQpzSsMyXj0qViVP6xKGCUT8p8YJ6HqI7l5eCnWx1T/FYdsv07HQs2wTFbbof/RA==",
209
+ "dev": true
210
+ },
211
+ "node_modules/@webassemblyjs/wasm-edit": {
212
+ "version": "1.11.6",
213
+ "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.6.tgz",
214
+ "integrity": "sha512-Ybn2I6fnfIGuCR+Faaz7YcvtBKxvoLV3Lebn1tM4o/IAJzmi9AWYIPWpyBfU8cC+JxAO57bk4+zdsTjJR+VTOw==",
215
+ "dev": true,
216
+ "dependencies": {
217
+ "@webassemblyjs/ast": "1.11.6",
218
+ "@webassemblyjs/helper-buffer": "1.11.6",
219
+ "@webassemblyjs/helper-wasm-bytecode": "1.11.6",
220
+ "@webassemblyjs/helper-wasm-section": "1.11.6",
221
+ "@webassemblyjs/wasm-gen": "1.11.6",
222
+ "@webassemblyjs/wasm-opt": "1.11.6",
223
+ "@webassemblyjs/wasm-parser": "1.11.6",
224
+ "@webassemblyjs/wast-printer": "1.11.6"
225
+ }
226
+ },
227
+ "node_modules/@webassemblyjs/wasm-gen": {
228
+ "version": "1.11.6",
229
+ "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.6.tgz",
230
+ "integrity": "sha512-3XOqkZP/y6B4F0PBAXvI1/bky7GryoogUtfwExeP/v7Nzwo1QLcq5oQmpKlftZLbT+ERUOAZVQjuNVak6UXjPA==",
231
+ "dev": true,
232
+ "dependencies": {
233
+ "@webassemblyjs/ast": "1.11.6",
234
+ "@webassemblyjs/helper-wasm-bytecode": "1.11.6",
235
+ "@webassemblyjs/ieee754": "1.11.6",
236
+ "@webassemblyjs/leb128": "1.11.6",
237
+ "@webassemblyjs/utf8": "1.11.6"
238
+ }
239
+ },
240
+ "node_modules/@webassemblyjs/wasm-opt": {
241
+ "version": "1.11.6",
242
+ "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.6.tgz",
243
+ "integrity": "sha512-cOrKuLRE7PCe6AsOVl7WasYf3wbSo4CeOk6PkrjS7g57MFfVUF9u6ysQBBODX0LdgSvQqRiGz3CXvIDKcPNy4g==",
244
+ "dev": true,
245
+ "dependencies": {
246
+ "@webassemblyjs/ast": "1.11.6",
247
+ "@webassemblyjs/helper-buffer": "1.11.6",
248
+ "@webassemblyjs/wasm-gen": "1.11.6",
249
+ "@webassemblyjs/wasm-parser": "1.11.6"
250
+ }
251
+ },
252
+ "node_modules/@webassemblyjs/wasm-parser": {
253
+ "version": "1.11.6",
254
+ "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.6.tgz",
255
+ "integrity": "sha512-6ZwPeGzMJM3Dqp3hCsLgESxBGtT/OeCvCZ4TA1JUPYgmhAx38tTPR9JaKy0S5H3evQpO/h2uWs2j6Yc/fjkpTQ==",
256
+ "dev": true,
257
+ "dependencies": {
258
+ "@webassemblyjs/ast": "1.11.6",
259
+ "@webassemblyjs/helper-api-error": "1.11.6",
260
+ "@webassemblyjs/helper-wasm-bytecode": "1.11.6",
261
+ "@webassemblyjs/ieee754": "1.11.6",
262
+ "@webassemblyjs/leb128": "1.11.6",
263
+ "@webassemblyjs/utf8": "1.11.6"
264
+ }
265
+ },
266
+ "node_modules/@webassemblyjs/wast-printer": {
267
+ "version": "1.11.6",
268
+ "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.11.6.tgz",
269
+ "integrity": "sha512-JM7AhRcE+yW2GWYaKeHL5vt4xqee5N2WcezptmgyhNS+ScggqcT1OtXykhAb13Sn5Yas0j2uv9tHgrjwvzAP4A==",
270
+ "dev": true,
271
+ "dependencies": {
272
+ "@webassemblyjs/ast": "1.11.6",
273
+ "@xtuc/long": "4.2.2"
274
+ }
275
+ },
276
+ "node_modules/@webpack-cli/configtest": {
277
+ "version": "2.1.1",
278
+ "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-2.1.1.tgz",
279
+ "integrity": "sha512-wy0mglZpDSiSS0XHrVR+BAdId2+yxPSoJW8fsna3ZpYSlufjvxnP4YbKTCBZnNIcGN4r6ZPXV55X4mYExOfLmw==",
280
+ "dev": true,
281
+ "engines": {
282
+ "node": ">=14.15.0"
283
+ },
284
+ "peerDependencies": {
285
+ "webpack": "5.x.x",
286
+ "webpack-cli": "5.x.x"
287
+ }
288
+ },
289
+ "node_modules/@webpack-cli/info": {
290
+ "version": "2.0.2",
291
+ "resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-2.0.2.tgz",
292
+ "integrity": "sha512-zLHQdI/Qs1UyT5UBdWNqsARasIA+AaF8t+4u2aS2nEpBQh2mWIVb8qAklq0eUENnC5mOItrIB4LiS9xMtph18A==",
293
+ "dev": true,
294
+ "engines": {
295
+ "node": ">=14.15.0"
296
+ },
297
+ "peerDependencies": {
298
+ "webpack": "5.x.x",
299
+ "webpack-cli": "5.x.x"
300
+ }
301
+ },
302
+ "node_modules/@webpack-cli/serve": {
303
+ "version": "2.0.5",
304
+ "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-2.0.5.tgz",
305
+ "integrity": "sha512-lqaoKnRYBdo1UgDX8uF24AfGMifWK19TxPmM5FHc2vAGxrJ/qtyUyFBWoY1tISZdelsQ5fBcOusifo5o5wSJxQ==",
306
+ "dev": true,
307
+ "engines": {
308
+ "node": ">=14.15.0"
309
+ },
310
+ "peerDependencies": {
311
+ "webpack": "5.x.x",
312
+ "webpack-cli": "5.x.x"
313
+ },
314
+ "peerDependenciesMeta": {
315
+ "webpack-dev-server": {
316
+ "optional": true
317
+ }
318
+ }
319
+ },
320
+ "node_modules/@xtuc/ieee754": {
321
+ "version": "1.2.0",
322
+ "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz",
323
+ "integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==",
324
+ "dev": true
325
+ },
326
+ "node_modules/@xtuc/long": {
327
+ "version": "4.2.2",
328
+ "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz",
329
+ "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==",
330
+ "dev": true
331
+ },
332
+ "node_modules/abbrev": {
333
+ "version": "1.1.1",
334
+ "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
335
+ "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==",
336
+ "dev": true
337
+ },
338
+ "node_modules/accepts": {
339
+ "version": "1.3.8",
340
+ "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
341
+ "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
342
+ "dev": true,
343
+ "dependencies": {
344
+ "mime-types": "~2.1.34",
345
+ "negotiator": "0.6.3"
346
+ },
347
+ "engines": {
348
+ "node": ">= 0.6"
349
+ }
350
+ },
351
+ "node_modules/acorn": {
352
+ "version": "8.11.3",
353
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.3.tgz",
354
+ "integrity": "sha512-Y9rRfJG5jcKOE0CLisYbojUjIrIEE7AGMzA/Sm4BslANhbS+cDMpgBdcPT91oJ7OuJ9hYJBx59RjbhxVnrF8Xg==",
355
+ "dev": true,
356
+ "bin": {
357
+ "acorn": "bin/acorn"
358
+ },
359
+ "engines": {
360
+ "node": ">=0.4.0"
361
+ }
362
+ },
363
+ "node_modules/acorn-import-assertions": {
364
+ "version": "1.9.0",
365
+ "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz",
366
+ "integrity": "sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==",
367
+ "dev": true,
368
+ "peerDependencies": {
369
+ "acorn": "^8"
370
+ }
371
+ },
372
+ "node_modules/ajv": {
373
+ "version": "6.12.6",
374
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz",
375
+ "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==",
376
+ "dev": true,
377
+ "dependencies": {
378
+ "fast-deep-equal": "^3.1.1",
379
+ "fast-json-stable-stringify": "^2.0.0",
380
+ "json-schema-traverse": "^0.4.1",
381
+ "uri-js": "^4.2.2"
382
+ },
383
+ "funding": {
384
+ "type": "github",
385
+ "url": "https://github.com/sponsors/epoberezkin"
386
+ }
387
+ },
388
+ "node_modules/ajv-keywords": {
389
+ "version": "3.5.2",
390
+ "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz",
391
+ "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==",
392
+ "dev": true,
393
+ "peerDependencies": {
394
+ "ajv": "^6.9.1"
395
+ }
396
+ },
397
+ "node_modules/ansi-styles": {
398
+ "version": "4.3.0",
399
+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
400
+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
401
+ "dev": true,
402
+ "dependencies": {
403
+ "color-convert": "^2.0.1"
404
+ },
405
+ "engines": {
406
+ "node": ">=8"
407
+ },
408
+ "funding": {
409
+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"
410
+ }
411
+ },
412
+ "node_modules/anymatch": {
413
+ "version": "3.1.3",
414
+ "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
415
+ "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
416
+ "dev": true,
417
+ "dependencies": {
418
+ "normalize-path": "^3.0.0",
419
+ "picomatch": "^2.0.4"
420
+ },
421
+ "engines": {
422
+ "node": ">= 8"
423
+ }
424
+ },
425
+ "node_modules/array-flatten": {
426
+ "version": "1.1.1",
427
+ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
428
+ "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
429
+ "dev": true
430
+ },
431
+ "node_modules/balanced-match": {
432
+ "version": "1.0.2",
433
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
434
+ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
435
+ "dev": true
436
+ },
437
+ "node_modules/binary-extensions": {
438
+ "version": "2.2.0",
439
+ "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
440
+ "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
441
+ "dev": true,
442
+ "engines": {
443
+ "node": ">=8"
444
+ }
445
+ },
446
+ "node_modules/body-parser": {
447
+ "version": "1.20.2",
448
+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz",
449
+ "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==",
450
+ "dev": true,
451
+ "dependencies": {
452
+ "bytes": "3.1.2",
453
+ "content-type": "~1.0.5",
454
+ "debug": "2.6.9",
455
+ "depd": "2.0.0",
456
+ "destroy": "1.2.0",
457
+ "http-errors": "2.0.0",
458
+ "iconv-lite": "0.4.24",
459
+ "on-finished": "2.4.1",
460
+ "qs": "6.11.0",
461
+ "raw-body": "2.5.2",
462
+ "type-is": "~1.6.18",
463
+ "unpipe": "1.0.0"
464
+ },
465
+ "engines": {
466
+ "node": ">= 0.8",
467
+ "npm": "1.2.8000 || >= 1.4.16"
468
+ }
469
+ },
470
+ "node_modules/brace-expansion": {
471
+ "version": "1.1.11",
472
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
473
+ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
474
+ "dev": true,
475
+ "dependencies": {
476
+ "balanced-match": "^1.0.0",
477
+ "concat-map": "0.0.1"
478
+ }
479
+ },
480
+ "node_modules/braces": {
481
+ "version": "3.0.2",
482
+ "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
483
+ "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
484
+ "dev": true,
485
+ "dependencies": {
486
+ "fill-range": "^7.0.1"
487
+ },
488
+ "engines": {
489
+ "node": ">=8"
490
+ }
491
+ },
492
+ "node_modules/browserslist": {
493
+ "version": "4.23.0",
494
+ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.23.0.tgz",
495
+ "integrity": "sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==",
496
+ "dev": true,
497
+ "funding": [
498
+ {
499
+ "type": "opencollective",
500
+ "url": "https://opencollective.com/browserslist"
501
+ },
502
+ {
503
+ "type": "tidelift",
504
+ "url": "https://tidelift.com/funding/github/npm/browserslist"
505
+ },
506
+ {
507
+ "type": "github",
508
+ "url": "https://github.com/sponsors/ai"
509
+ }
510
+ ],
511
+ "dependencies": {
512
+ "caniuse-lite": "^1.0.30001587",
513
+ "electron-to-chromium": "^1.4.668",
514
+ "node-releases": "^2.0.14",
515
+ "update-browserslist-db": "^1.0.13"
516
+ },
517
+ "bin": {
518
+ "browserslist": "cli.js"
519
+ },
520
+ "engines": {
521
+ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7"
522
+ }
523
+ },
524
+ "node_modules/buffer-from": {
525
+ "version": "1.1.2",
526
+ "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
527
+ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
528
+ "dev": true
529
+ },
530
+ "node_modules/bytes": {
531
+ "version": "3.1.2",
532
+ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
533
+ "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
534
+ "dev": true,
535
+ "engines": {
536
+ "node": ">= 0.8"
537
+ }
538
+ },
539
+ "node_modules/call-bind": {
540
+ "version": "1.0.7",
541
+ "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz",
542
+ "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==",
543
+ "dev": true,
544
+ "dependencies": {
545
+ "es-define-property": "^1.0.0",
546
+ "es-errors": "^1.3.0",
547
+ "function-bind": "^1.1.2",
548
+ "get-intrinsic": "^1.2.4",
549
+ "set-function-length": "^1.2.1"
550
+ },
551
+ "engines": {
552
+ "node": ">= 0.4"
553
+ },
554
+ "funding": {
555
+ "url": "https://github.com/sponsors/ljharb"
556
+ }
557
+ },
558
+ "node_modules/caniuse-lite": {
559
+ "version": "1.0.30001591",
560
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001591.tgz",
561
+ "integrity": "sha512-PCzRMei/vXjJyL5mJtzNiUCKP59dm8Apqc3PH8gJkMnMXZGox93RbE76jHsmLwmIo6/3nsYIpJtx0O7u5PqFuQ==",
562
+ "dev": true,
563
+ "funding": [
564
+ {
565
+ "type": "opencollective",
566
+ "url": "https://opencollective.com/browserslist"
567
+ },
568
+ {
569
+ "type": "tidelift",
570
+ "url": "https://tidelift.com/funding/github/npm/caniuse-lite"
571
+ },
572
+ {
573
+ "type": "github",
574
+ "url": "https://github.com/sponsors/ai"
575
+ }
576
+ ]
577
+ },
578
+ "node_modules/chalk": {
579
+ "version": "4.1.2",
580
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
581
+ "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
582
+ "dev": true,
583
+ "dependencies": {
584
+ "ansi-styles": "^4.1.0",
585
+ "supports-color": "^7.1.0"
586
+ },
587
+ "engines": {
588
+ "node": ">=10"
589
+ },
590
+ "funding": {
591
+ "url": "https://github.com/chalk/chalk?sponsor=1"
592
+ }
593
+ },
594
+ "node_modules/chokidar": {
595
+ "version": "3.6.0",
596
+ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
597
+ "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
598
+ "dev": true,
599
+ "dependencies": {
600
+ "anymatch": "~3.1.2",
601
+ "braces": "~3.0.2",
602
+ "glob-parent": "~5.1.2",
603
+ "is-binary-path": "~2.1.0",
604
+ "is-glob": "~4.0.1",
605
+ "normalize-path": "~3.0.0",
606
+ "readdirp": "~3.6.0"
607
+ },
608
+ "engines": {
609
+ "node": ">= 8.10.0"
610
+ },
611
+ "funding": {
612
+ "url": "https://paulmillr.com/funding/"
613
+ },
614
+ "optionalDependencies": {
615
+ "fsevents": "~2.3.2"
616
+ }
617
+ },
618
+ "node_modules/chrome-trace-event": {
619
+ "version": "1.0.3",
620
+ "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz",
621
+ "integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==",
622
+ "dev": true,
623
+ "engines": {
624
+ "node": ">=6.0"
625
+ }
626
+ },
627
+ "node_modules/clean-css": {
628
+ "version": "5.3.3",
629
+ "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.3.tgz",
630
+ "integrity": "sha512-D5J+kHaVb/wKSFcyyV75uCn8fiY4sV38XJoe4CUyGQ+mOU/fMVYUdH1hJC+CJQ5uY3EnW27SbJYS4X8BiLrAFg==",
631
+ "dev": true,
632
+ "dependencies": {
633
+ "source-map": "~0.6.0"
634
+ },
635
+ "engines": {
636
+ "node": ">= 10.0"
637
+ }
638
+ },
639
+ "node_modules/clone-deep": {
640
+ "version": "4.0.1",
641
+ "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz",
642
+ "integrity": "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==",
643
+ "dev": true,
644
+ "dependencies": {
645
+ "is-plain-object": "^2.0.4",
646
+ "kind-of": "^6.0.2",
647
+ "shallow-clone": "^3.0.0"
648
+ },
649
+ "engines": {
650
+ "node": ">=6"
651
+ }
652
+ },
653
+ "node_modules/color-convert": {
654
+ "version": "2.0.1",
655
+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
656
+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
657
+ "dev": true,
658
+ "dependencies": {
659
+ "color-name": "~1.1.4"
660
+ },
661
+ "engines": {
662
+ "node": ">=7.0.0"
663
+ }
664
+ },
665
+ "node_modules/color-name": {
666
+ "version": "1.1.4",
667
+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
668
+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
669
+ "dev": true
670
+ },
671
+ "node_modules/colorette": {
672
+ "version": "2.0.20",
673
+ "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.20.tgz",
674
+ "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==",
675
+ "dev": true
676
+ },
677
+ "node_modules/commander": {
678
+ "version": "2.20.3",
679
+ "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
680
+ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
681
+ "dev": true
682
+ },
683
+ "node_modules/concat-map": {
684
+ "version": "0.0.1",
685
+ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
686
+ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
687
+ "dev": true
688
+ },
689
+ "node_modules/content-disposition": {
690
+ "version": "0.5.4",
691
+ "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
692
+ "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
693
+ "dev": true,
694
+ "dependencies": {
695
+ "safe-buffer": "5.2.1"
696
+ },
697
+ "engines": {
698
+ "node": ">= 0.6"
699
+ }
700
+ },
701
+ "node_modules/content-type": {
702
+ "version": "1.0.5",
703
+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
704
+ "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
705
+ "dev": true,
706
+ "engines": {
707
+ "node": ">= 0.6"
708
+ }
709
+ },
710
+ "node_modules/cookie": {
711
+ "version": "0.5.0",
712
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz",
713
+ "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==",
714
+ "dev": true,
715
+ "engines": {
716
+ "node": ">= 0.6"
717
+ }
718
+ },
719
+ "node_modules/cookie-signature": {
720
+ "version": "1.0.6",
721
+ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
722
+ "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==",
723
+ "dev": true
724
+ },
725
+ "node_modules/cross-spawn": {
726
+ "version": "7.0.3",
727
+ "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
728
+ "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
729
+ "dev": true,
730
+ "dependencies": {
731
+ "path-key": "^3.1.0",
732
+ "shebang-command": "^2.0.0",
733
+ "which": "^2.0.1"
734
+ },
735
+ "engines": {
736
+ "node": ">= 8"
737
+ }
738
+ },
739
+ "node_modules/debug": {
740
+ "version": "2.6.9",
741
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
742
+ "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
743
+ "dev": true,
744
+ "dependencies": {
745
+ "ms": "2.0.0"
746
+ }
747
+ },
748
+ "node_modules/define-data-property": {
749
+ "version": "1.1.4",
750
+ "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
751
+ "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
752
+ "dev": true,
753
+ "dependencies": {
754
+ "es-define-property": "^1.0.0",
755
+ "es-errors": "^1.3.0",
756
+ "gopd": "^1.0.1"
757
+ },
758
+ "engines": {
759
+ "node": ">= 0.4"
760
+ },
761
+ "funding": {
762
+ "url": "https://github.com/sponsors/ljharb"
763
+ }
764
+ },
765
+ "node_modules/depd": {
766
+ "version": "2.0.0",
767
+ "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
768
+ "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
769
+ "dev": true,
770
+ "engines": {
771
+ "node": ">= 0.8"
772
+ }
773
+ },
774
+ "node_modules/destroy": {
775
+ "version": "1.2.0",
776
+ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
777
+ "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
778
+ "dev": true,
779
+ "engines": {
780
+ "node": ">= 0.8",
781
+ "npm": "1.2.8000 || >= 1.4.16"
782
+ }
783
+ },
784
+ "node_modules/ee-first": {
785
+ "version": "1.1.1",
786
+ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
787
+ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
788
+ "dev": true
789
+ },
790
+ "node_modules/electron-to-chromium": {
791
+ "version": "1.4.690",
792
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.690.tgz",
793
+ "integrity": "sha512-+2OAGjUx68xElQhydpcbqH50hE8Vs2K6TkAeLhICYfndb67CVH0UsZaijmRUE3rHlIxU1u0jxwhgVe6fK3YANA==",
794
+ "dev": true
795
+ },
796
+ "node_modules/encodeurl": {
797
+ "version": "1.0.2",
798
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
799
+ "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
800
+ "dev": true,
801
+ "engines": {
802
+ "node": ">= 0.8"
803
+ }
804
+ },
805
+ "node_modules/enhanced-resolve": {
806
+ "version": "5.15.1",
807
+ "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.15.1.tgz",
808
+ "integrity": "sha512-3d3JRbwsCLJsYgvb6NuWEG44jjPSOMuS73L/6+7BZuoKm3W+qXnSoIYVHi8dG7Qcg4inAY4jbzkZ7MnskePeDg==",
809
+ "dev": true,
810
+ "dependencies": {
811
+ "graceful-fs": "^4.2.4",
812
+ "tapable": "^2.2.0"
813
+ },
814
+ "engines": {
815
+ "node": ">=10.13.0"
816
+ }
817
+ },
818
+ "node_modules/envinfo": {
819
+ "version": "7.11.1",
820
+ "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.11.1.tgz",
821
+ "integrity": "sha512-8PiZgZNIB4q/Lw4AhOvAfB/ityHAd2bli3lESSWmWSzSsl5dKpy5N1d1Rfkd2teq/g9xN90lc6o98DOjMeYHpg==",
822
+ "dev": true,
823
+ "bin": {
824
+ "envinfo": "dist/cli.js"
825
+ },
826
+ "engines": {
827
+ "node": ">=4"
828
+ }
829
+ },
830
+ "node_modules/es-define-property": {
831
+ "version": "1.0.0",
832
+ "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz",
833
+ "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==",
834
+ "dev": true,
835
+ "dependencies": {
836
+ "get-intrinsic": "^1.2.4"
837
+ },
838
+ "engines": {
839
+ "node": ">= 0.4"
840
+ }
841
+ },
842
+ "node_modules/es-errors": {
843
+ "version": "1.3.0",
844
+ "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
845
+ "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
846
+ "dev": true,
847
+ "engines": {
848
+ "node": ">= 0.4"
849
+ }
850
+ },
851
+ "node_modules/es-module-lexer": {
852
+ "version": "1.4.1",
853
+ "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.4.1.tgz",
854
+ "integrity": "sha512-cXLGjP0c4T3flZJKQSuziYoq7MlT+rnvfZjfp7h+I7K9BNX54kP9nyWvdbwjQ4u1iWbOL4u96fgeZLToQlZC7w==",
855
+ "dev": true
856
+ },
857
+ "node_modules/escalade": {
858
+ "version": "3.1.2",
859
+ "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz",
860
+ "integrity": "sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==",
861
+ "dev": true,
862
+ "engines": {
863
+ "node": ">=6"
864
+ }
865
+ },
866
+ "node_modules/escape-html": {
867
+ "version": "1.0.3",
868
+ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
869
+ "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
870
+ "dev": true
871
+ },
872
+ "node_modules/eslint-scope": {
873
+ "version": "5.1.1",
874
+ "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
875
+ "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==",
876
+ "dev": true,
877
+ "dependencies": {
878
+ "esrecurse": "^4.3.0",
879
+ "estraverse": "^4.1.1"
880
+ },
881
+ "engines": {
882
+ "node": ">=8.0.0"
883
+ }
884
+ },
885
+ "node_modules/esrecurse": {
886
+ "version": "4.3.0",
887
+ "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz",
888
+ "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==",
889
+ "dev": true,
890
+ "dependencies": {
891
+ "estraverse": "^5.2.0"
892
+ },
893
+ "engines": {
894
+ "node": ">=4.0"
895
+ }
896
+ },
897
+ "node_modules/esrecurse/node_modules/estraverse": {
898
+ "version": "5.3.0",
899
+ "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
900
+ "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
901
+ "dev": true,
902
+ "engines": {
903
+ "node": ">=4.0"
904
+ }
905
+ },
906
+ "node_modules/estraverse": {
907
+ "version": "4.3.0",
908
+ "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz",
909
+ "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==",
910
+ "dev": true,
911
+ "engines": {
912
+ "node": ">=4.0"
913
+ }
914
+ },
915
+ "node_modules/etag": {
916
+ "version": "1.8.1",
917
+ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
918
+ "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
919
+ "dev": true,
920
+ "engines": {
921
+ "node": ">= 0.6"
922
+ }
923
+ },
924
+ "node_modules/events": {
925
+ "version": "3.3.0",
926
+ "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
927
+ "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==",
928
+ "dev": true,
929
+ "engines": {
930
+ "node": ">=0.8.x"
931
+ }
932
+ },
933
+ "node_modules/express": {
934
+ "version": "4.18.3",
935
+ "resolved": "https://registry.npmjs.org/express/-/express-4.18.3.tgz",
936
+ "integrity": "sha512-6VyCijWQ+9O7WuVMTRBTl+cjNNIzD5cY5mQ1WM8r/LEkI2u8EYpOotESNwzNlyCn3g+dmjKYI6BmNneSr/FSRw==",
937
+ "dev": true,
938
+ "dependencies": {
939
+ "accepts": "~1.3.8",
940
+ "array-flatten": "1.1.1",
941
+ "body-parser": "1.20.2",
942
+ "content-disposition": "0.5.4",
943
+ "content-type": "~1.0.4",
944
+ "cookie": "0.5.0",
945
+ "cookie-signature": "1.0.6",
946
+ "debug": "2.6.9",
947
+ "depd": "2.0.0",
948
+ "encodeurl": "~1.0.2",
949
+ "escape-html": "~1.0.3",
950
+ "etag": "~1.8.1",
951
+ "finalhandler": "1.2.0",
952
+ "fresh": "0.5.2",
953
+ "http-errors": "2.0.0",
954
+ "merge-descriptors": "1.0.1",
955
+ "methods": "~1.1.2",
956
+ "on-finished": "2.4.1",
957
+ "parseurl": "~1.3.3",
958
+ "path-to-regexp": "0.1.7",
959
+ "proxy-addr": "~2.0.7",
960
+ "qs": "6.11.0",
961
+ "range-parser": "~1.2.1",
962
+ "safe-buffer": "5.2.1",
963
+ "send": "0.18.0",
964
+ "serve-static": "1.15.0",
965
+ "setprototypeof": "1.2.0",
966
+ "statuses": "2.0.1",
967
+ "type-is": "~1.6.18",
968
+ "utils-merge": "1.0.1",
969
+ "vary": "~1.1.2"
970
+ },
971
+ "engines": {
972
+ "node": ">= 0.10.0"
973
+ }
974
+ },
975
+ "node_modules/fast-deep-equal": {
976
+ "version": "3.1.3",
977
+ "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
978
+ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
979
+ "dev": true
980
+ },
981
+ "node_modules/fast-json-stable-stringify": {
982
+ "version": "2.1.0",
983
+ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
984
+ "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==",
985
+ "dev": true
986
+ },
987
+ "node_modules/fastest-levenshtein": {
988
+ "version": "1.0.16",
989
+ "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz",
990
+ "integrity": "sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==",
991
+ "dev": true,
992
+ "engines": {
993
+ "node": ">= 4.9.1"
994
+ }
995
+ },
996
+ "node_modules/fill-range": {
997
+ "version": "7.0.1",
998
+ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
999
+ "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
1000
+ "dev": true,
1001
+ "dependencies": {
1002
+ "to-regex-range": "^5.0.1"
1003
+ },
1004
+ "engines": {
1005
+ "node": ">=8"
1006
+ }
1007
+ },
1008
+ "node_modules/finalhandler": {
1009
+ "version": "1.2.0",
1010
+ "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz",
1011
+ "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==",
1012
+ "dev": true,
1013
+ "dependencies": {
1014
+ "debug": "2.6.9",
1015
+ "encodeurl": "~1.0.2",
1016
+ "escape-html": "~1.0.3",
1017
+ "on-finished": "2.4.1",
1018
+ "parseurl": "~1.3.3",
1019
+ "statuses": "2.0.1",
1020
+ "unpipe": "~1.0.0"
1021
+ },
1022
+ "engines": {
1023
+ "node": ">= 0.8"
1024
+ }
1025
+ },
1026
+ "node_modules/find-up": {
1027
+ "version": "4.1.0",
1028
+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",
1029
+ "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",
1030
+ "dev": true,
1031
+ "dependencies": {
1032
+ "locate-path": "^5.0.0",
1033
+ "path-exists": "^4.0.0"
1034
+ },
1035
+ "engines": {
1036
+ "node": ">=8"
1037
+ }
1038
+ },
1039
+ "node_modules/flat": {
1040
+ "version": "5.0.2",
1041
+ "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz",
1042
+ "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==",
1043
+ "dev": true,
1044
+ "bin": {
1045
+ "flat": "cli.js"
1046
+ }
1047
+ },
1048
+ "node_modules/forwarded": {
1049
+ "version": "0.2.0",
1050
+ "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
1051
+ "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
1052
+ "dev": true,
1053
+ "engines": {
1054
+ "node": ">= 0.6"
1055
+ }
1056
+ },
1057
+ "node_modules/fresh": {
1058
+ "version": "0.5.2",
1059
+ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
1060
+ "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
1061
+ "dev": true,
1062
+ "engines": {
1063
+ "node": ">= 0.6"
1064
+ }
1065
+ },
1066
+ "node_modules/fsevents": {
1067
+ "version": "2.3.3",
1068
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
1069
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
1070
+ "dev": true,
1071
+ "hasInstallScript": true,
1072
+ "optional": true,
1073
+ "os": [
1074
+ "darwin"
1075
+ ],
1076
+ "engines": {
1077
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
1078
+ }
1079
+ },
1080
+ "node_modules/function-bind": {
1081
+ "version": "1.1.2",
1082
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
1083
+ "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
1084
+ "dev": true,
1085
+ "funding": {
1086
+ "url": "https://github.com/sponsors/ljharb"
1087
+ }
1088
+ },
1089
+ "node_modules/get-intrinsic": {
1090
+ "version": "1.2.4",
1091
+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
1092
+ "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==",
1093
+ "dev": true,
1094
+ "dependencies": {
1095
+ "es-errors": "^1.3.0",
1096
+ "function-bind": "^1.1.2",
1097
+ "has-proto": "^1.0.1",
1098
+ "has-symbols": "^1.0.3",
1099
+ "hasown": "^2.0.0"
1100
+ },
1101
+ "engines": {
1102
+ "node": ">= 0.4"
1103
+ },
1104
+ "funding": {
1105
+ "url": "https://github.com/sponsors/ljharb"
1106
+ }
1107
+ },
1108
+ "node_modules/glob-parent": {
1109
+ "version": "5.1.2",
1110
+ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
1111
+ "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
1112
+ "dev": true,
1113
+ "dependencies": {
1114
+ "is-glob": "^4.0.1"
1115
+ },
1116
+ "engines": {
1117
+ "node": ">= 6"
1118
+ }
1119
+ },
1120
+ "node_modules/glob-to-regexp": {
1121
+ "version": "0.4.1",
1122
+ "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz",
1123
+ "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==",
1124
+ "dev": true
1125
+ },
1126
+ "node_modules/gopd": {
1127
+ "version": "1.0.1",
1128
+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
1129
+ "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
1130
+ "dev": true,
1131
+ "dependencies": {
1132
+ "get-intrinsic": "^1.1.3"
1133
+ },
1134
+ "funding": {
1135
+ "url": "https://github.com/sponsors/ljharb"
1136
+ }
1137
+ },
1138
+ "node_modules/graceful-fs": {
1139
+ "version": "4.2.11",
1140
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
1141
+ "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
1142
+ "dev": true
1143
+ },
1144
+ "node_modules/has-flag": {
1145
+ "version": "4.0.0",
1146
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
1147
+ "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
1148
+ "dev": true,
1149
+ "engines": {
1150
+ "node": ">=8"
1151
+ }
1152
+ },
1153
+ "node_modules/has-property-descriptors": {
1154
+ "version": "1.0.2",
1155
+ "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
1156
+ "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
1157
+ "dev": true,
1158
+ "dependencies": {
1159
+ "es-define-property": "^1.0.0"
1160
+ },
1161
+ "funding": {
1162
+ "url": "https://github.com/sponsors/ljharb"
1163
+ }
1164
+ },
1165
+ "node_modules/has-proto": {
1166
+ "version": "1.0.3",
1167
+ "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz",
1168
+ "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==",
1169
+ "dev": true,
1170
+ "engines": {
1171
+ "node": ">= 0.4"
1172
+ },
1173
+ "funding": {
1174
+ "url": "https://github.com/sponsors/ljharb"
1175
+ }
1176
+ },
1177
+ "node_modules/has-symbols": {
1178
+ "version": "1.0.3",
1179
+ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
1180
+ "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
1181
+ "dev": true,
1182
+ "engines": {
1183
+ "node": ">= 0.4"
1184
+ },
1185
+ "funding": {
1186
+ "url": "https://github.com/sponsors/ljharb"
1187
+ }
1188
+ },
1189
+ "node_modules/hasown": {
1190
+ "version": "2.0.1",
1191
+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.1.tgz",
1192
+ "integrity": "sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==",
1193
+ "dev": true,
1194
+ "dependencies": {
1195
+ "function-bind": "^1.1.2"
1196
+ },
1197
+ "engines": {
1198
+ "node": ">= 0.4"
1199
+ }
1200
+ },
1201
+ "node_modules/html-entities": {
1202
+ "version": "2.4.0",
1203
+ "resolved": "https://registry.npmjs.org/html-entities/-/html-entities-2.4.0.tgz",
1204
+ "integrity": "sha512-igBTJcNNNhvZFRtm8uA6xMY6xYleeDwn3PeBCkDz7tHttv4F2hsDI2aPgNERWzvRcNYHNT3ymRaQzllmXj4YsQ==",
1205
+ "dev": true,
1206
+ "funding": [
1207
+ {
1208
+ "type": "github",
1209
+ "url": "https://github.com/sponsors/mdevils"
1210
+ },
1211
+ {
1212
+ "type": "patreon",
1213
+ "url": "https://patreon.com/mdevils"
1214
+ }
1215
+ ]
1216
+ },
1217
+ "node_modules/http-errors": {
1218
+ "version": "2.0.0",
1219
+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
1220
+ "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
1221
+ "dev": true,
1222
+ "dependencies": {
1223
+ "depd": "2.0.0",
1224
+ "inherits": "2.0.4",
1225
+ "setprototypeof": "1.2.0",
1226
+ "statuses": "2.0.1",
1227
+ "toidentifier": "1.0.1"
1228
+ },
1229
+ "engines": {
1230
+ "node": ">= 0.8"
1231
+ }
1232
+ },
1233
+ "node_modules/iconv-lite": {
1234
+ "version": "0.4.24",
1235
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
1236
+ "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
1237
+ "dev": true,
1238
+ "dependencies": {
1239
+ "safer-buffer": ">= 2.1.2 < 3"
1240
+ },
1241
+ "engines": {
1242
+ "node": ">=0.10.0"
1243
+ }
1244
+ },
1245
+ "node_modules/ignore-by-default": {
1246
+ "version": "1.0.1",
1247
+ "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz",
1248
+ "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==",
1249
+ "dev": true
1250
+ },
1251
+ "node_modules/import-local": {
1252
+ "version": "3.1.0",
1253
+ "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz",
1254
+ "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==",
1255
+ "dev": true,
1256
+ "dependencies": {
1257
+ "pkg-dir": "^4.2.0",
1258
+ "resolve-cwd": "^3.0.0"
1259
+ },
1260
+ "bin": {
1261
+ "import-local-fixture": "fixtures/cli.js"
1262
+ },
1263
+ "engines": {
1264
+ "node": ">=8"
1265
+ },
1266
+ "funding": {
1267
+ "url": "https://github.com/sponsors/sindresorhus"
1268
+ }
1269
+ },
1270
+ "node_modules/inherits": {
1271
+ "version": "2.0.4",
1272
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
1273
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
1274
+ "dev": true
1275
+ },
1276
+ "node_modules/interpret": {
1277
+ "version": "3.1.1",
1278
+ "resolved": "https://registry.npmjs.org/interpret/-/interpret-3.1.1.tgz",
1279
+ "integrity": "sha512-6xwYfHbajpoF0xLW+iwLkhwgvLoZDfjYfoFNu8ftMoXINzwuymNLd9u/KmwtdT2GbR+/Cz66otEGEVVUHX9QLQ==",
1280
+ "dev": true,
1281
+ "engines": {
1282
+ "node": ">=10.13.0"
1283
+ }
1284
+ },
1285
+ "node_modules/ipaddr.js": {
1286
+ "version": "1.9.1",
1287
+ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
1288
+ "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
1289
+ "dev": true,
1290
+ "engines": {
1291
+ "node": ">= 0.10"
1292
+ }
1293
+ },
1294
+ "node_modules/is-binary-path": {
1295
+ "version": "2.1.0",
1296
+ "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
1297
+ "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
1298
+ "dev": true,
1299
+ "dependencies": {
1300
+ "binary-extensions": "^2.0.0"
1301
+ },
1302
+ "engines": {
1303
+ "node": ">=8"
1304
+ }
1305
+ },
1306
+ "node_modules/is-core-module": {
1307
+ "version": "2.13.1",
1308
+ "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.1.tgz",
1309
+ "integrity": "sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==",
1310
+ "dev": true,
1311
+ "dependencies": {
1312
+ "hasown": "^2.0.0"
1313
+ },
1314
+ "funding": {
1315
+ "url": "https://github.com/sponsors/ljharb"
1316
+ }
1317
+ },
1318
+ "node_modules/is-extglob": {
1319
+ "version": "2.1.1",
1320
+ "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
1321
+ "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
1322
+ "dev": true,
1323
+ "engines": {
1324
+ "node": ">=0.10.0"
1325
+ }
1326
+ },
1327
+ "node_modules/is-glob": {
1328
+ "version": "4.0.3",
1329
+ "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
1330
+ "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
1331
+ "dev": true,
1332
+ "dependencies": {
1333
+ "is-extglob": "^2.1.1"
1334
+ },
1335
+ "engines": {
1336
+ "node": ">=0.10.0"
1337
+ }
1338
+ },
1339
+ "node_modules/is-number": {
1340
+ "version": "7.0.0",
1341
+ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
1342
+ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
1343
+ "dev": true,
1344
+ "engines": {
1345
+ "node": ">=0.12.0"
1346
+ }
1347
+ },
1348
+ "node_modules/is-plain-object": {
1349
+ "version": "2.0.4",
1350
+ "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
1351
+ "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
1352
+ "dev": true,
1353
+ "dependencies": {
1354
+ "isobject": "^3.0.1"
1355
+ },
1356
+ "engines": {
1357
+ "node": ">=0.10.0"
1358
+ }
1359
+ },
1360
+ "node_modules/isexe": {
1361
+ "version": "2.0.0",
1362
+ "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
1363
+ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
1364
+ "dev": true
1365
+ },
1366
+ "node_modules/isobject": {
1367
+ "version": "3.0.1",
1368
+ "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
1369
+ "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==",
1370
+ "dev": true,
1371
+ "engines": {
1372
+ "node": ">=0.10.0"
1373
+ }
1374
+ },
1375
+ "node_modules/jest-worker": {
1376
+ "version": "27.5.1",
1377
+ "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.5.1.tgz",
1378
+ "integrity": "sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==",
1379
+ "dev": true,
1380
+ "dependencies": {
1381
+ "@types/node": "*",
1382
+ "merge-stream": "^2.0.0",
1383
+ "supports-color": "^8.0.0"
1384
+ },
1385
+ "engines": {
1386
+ "node": ">= 10.13.0"
1387
+ }
1388
+ },
1389
+ "node_modules/jest-worker/node_modules/supports-color": {
1390
+ "version": "8.1.1",
1391
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
1392
+ "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
1393
+ "dev": true,
1394
+ "dependencies": {
1395
+ "has-flag": "^4.0.0"
1396
+ },
1397
+ "engines": {
1398
+ "node": ">=10"
1399
+ },
1400
+ "funding": {
1401
+ "url": "https://github.com/chalk/supports-color?sponsor=1"
1402
+ }
1403
+ },
1404
+ "node_modules/json-parse-even-better-errors": {
1405
+ "version": "2.3.1",
1406
+ "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz",
1407
+ "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==",
1408
+ "dev": true
1409
+ },
1410
+ "node_modules/json-schema-traverse": {
1411
+ "version": "0.4.1",
1412
+ "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
1413
+ "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==",
1414
+ "dev": true
1415
+ },
1416
+ "node_modules/kind-of": {
1417
+ "version": "6.0.3",
1418
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
1419
+ "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
1420
+ "dev": true,
1421
+ "engines": {
1422
+ "node": ">=0.10.0"
1423
+ }
1424
+ },
1425
+ "node_modules/loader-runner": {
1426
+ "version": "4.3.0",
1427
+ "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz",
1428
+ "integrity": "sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==",
1429
+ "dev": true,
1430
+ "engines": {
1431
+ "node": ">=6.11.5"
1432
+ }
1433
+ },
1434
+ "node_modules/locate-path": {
1435
+ "version": "5.0.0",
1436
+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",
1437
+ "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",
1438
+ "dev": true,
1439
+ "dependencies": {
1440
+ "p-locate": "^4.1.0"
1441
+ },
1442
+ "engines": {
1443
+ "node": ">=8"
1444
+ }
1445
+ },
1446
+ "node_modules/media-typer": {
1447
+ "version": "0.3.0",
1448
+ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
1449
+ "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
1450
+ "dev": true,
1451
+ "engines": {
1452
+ "node": ">= 0.6"
1453
+ }
1454
+ },
1455
+ "node_modules/merge-descriptors": {
1456
+ "version": "1.0.1",
1457
+ "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
1458
+ "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==",
1459
+ "dev": true
1460
+ },
1461
+ "node_modules/merge-stream": {
1462
+ "version": "2.0.0",
1463
+ "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz",
1464
+ "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==",
1465
+ "dev": true
1466
+ },
1467
+ "node_modules/methods": {
1468
+ "version": "1.1.2",
1469
+ "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
1470
+ "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
1471
+ "dev": true,
1472
+ "engines": {
1473
+ "node": ">= 0.6"
1474
+ }
1475
+ },
1476
+ "node_modules/mime": {
1477
+ "version": "1.6.0",
1478
+ "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
1479
+ "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
1480
+ "dev": true,
1481
+ "bin": {
1482
+ "mime": "cli.js"
1483
+ },
1484
+ "engines": {
1485
+ "node": ">=4"
1486
+ }
1487
+ },
1488
+ "node_modules/mime-db": {
1489
+ "version": "1.52.0",
1490
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
1491
+ "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
1492
+ "dev": true,
1493
+ "engines": {
1494
+ "node": ">= 0.6"
1495
+ }
1496
+ },
1497
+ "node_modules/mime-types": {
1498
+ "version": "2.1.35",
1499
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
1500
+ "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
1501
+ "dev": true,
1502
+ "dependencies": {
1503
+ "mime-db": "1.52.0"
1504
+ },
1505
+ "engines": {
1506
+ "node": ">= 0.6"
1507
+ }
1508
+ },
1509
+ "node_modules/minimatch": {
1510
+ "version": "3.1.2",
1511
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
1512
+ "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
1513
+ "dev": true,
1514
+ "dependencies": {
1515
+ "brace-expansion": "^1.1.7"
1516
+ },
1517
+ "engines": {
1518
+ "node": "*"
1519
+ }
1520
+ },
1521
+ "node_modules/ms": {
1522
+ "version": "2.0.0",
1523
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
1524
+ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
1525
+ "dev": true
1526
+ },
1527
+ "node_modules/negotiator": {
1528
+ "version": "0.6.3",
1529
+ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
1530
+ "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
1531
+ "dev": true,
1532
+ "engines": {
1533
+ "node": ">= 0.6"
1534
+ }
1535
+ },
1536
+ "node_modules/neo-async": {
1537
+ "version": "2.6.2",
1538
+ "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
1539
+ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
1540
+ "dev": true
1541
+ },
1542
+ "node_modules/node-releases": {
1543
+ "version": "2.0.14",
1544
+ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz",
1545
+ "integrity": "sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==",
1546
+ "dev": true
1547
+ },
1548
+ "node_modules/nodemon": {
1549
+ "version": "2.0.22",
1550
+ "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.22.tgz",
1551
+ "integrity": "sha512-B8YqaKMmyuCO7BowF1Z1/mkPqLk6cs/l63Ojtd6otKjMx47Dq1utxfRxcavH1I7VSaL8n5BUaoutadnsX3AAVQ==",
1552
+ "dev": true,
1553
+ "dependencies": {
1554
+ "chokidar": "^3.5.2",
1555
+ "debug": "^3.2.7",
1556
+ "ignore-by-default": "^1.0.1",
1557
+ "minimatch": "^3.1.2",
1558
+ "pstree.remy": "^1.1.8",
1559
+ "semver": "^5.7.1",
1560
+ "simple-update-notifier": "^1.0.7",
1561
+ "supports-color": "^5.5.0",
1562
+ "touch": "^3.1.0",
1563
+ "undefsafe": "^2.0.5"
1564
+ },
1565
+ "bin": {
1566
+ "nodemon": "bin/nodemon.js"
1567
+ },
1568
+ "engines": {
1569
+ "node": ">=8.10.0"
1570
+ },
1571
+ "funding": {
1572
+ "type": "opencollective",
1573
+ "url": "https://opencollective.com/nodemon"
1574
+ }
1575
+ },
1576
+ "node_modules/nodemon/node_modules/debug": {
1577
+ "version": "3.2.7",
1578
+ "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
1579
+ "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
1580
+ "dev": true,
1581
+ "dependencies": {
1582
+ "ms": "^2.1.1"
1583
+ }
1584
+ },
1585
+ "node_modules/nodemon/node_modules/has-flag": {
1586
+ "version": "3.0.0",
1587
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
1588
+ "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
1589
+ "dev": true,
1590
+ "engines": {
1591
+ "node": ">=4"
1592
+ }
1593
+ },
1594
+ "node_modules/nodemon/node_modules/ms": {
1595
+ "version": "2.1.3",
1596
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
1597
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1598
+ "dev": true
1599
+ },
1600
+ "node_modules/nodemon/node_modules/supports-color": {
1601
+ "version": "5.5.0",
1602
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
1603
+ "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
1604
+ "dev": true,
1605
+ "dependencies": {
1606
+ "has-flag": "^3.0.0"
1607
+ },
1608
+ "engines": {
1609
+ "node": ">=4"
1610
+ }
1611
+ },
1612
+ "node_modules/nopt": {
1613
+ "version": "1.0.10",
1614
+ "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz",
1615
+ "integrity": "sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg==",
1616
+ "dev": true,
1617
+ "dependencies": {
1618
+ "abbrev": "1"
1619
+ },
1620
+ "bin": {
1621
+ "nopt": "bin/nopt.js"
1622
+ },
1623
+ "engines": {
1624
+ "node": "*"
1625
+ }
1626
+ },
1627
+ "node_modules/normalize-path": {
1628
+ "version": "3.0.0",
1629
+ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
1630
+ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
1631
+ "dev": true,
1632
+ "engines": {
1633
+ "node": ">=0.10.0"
1634
+ }
1635
+ },
1636
+ "node_modules/object-inspect": {
1637
+ "version": "1.13.1",
1638
+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz",
1639
+ "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==",
1640
+ "dev": true,
1641
+ "funding": {
1642
+ "url": "https://github.com/sponsors/ljharb"
1643
+ }
1644
+ },
1645
+ "node_modules/on-finished": {
1646
+ "version": "2.4.1",
1647
+ "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
1648
+ "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
1649
+ "dev": true,
1650
+ "dependencies": {
1651
+ "ee-first": "1.1.1"
1652
+ },
1653
+ "engines": {
1654
+ "node": ">= 0.8"
1655
+ }
1656
+ },
1657
+ "node_modules/p-limit": {
1658
+ "version": "2.3.0",
1659
+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",
1660
+ "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",
1661
+ "dev": true,
1662
+ "dependencies": {
1663
+ "p-try": "^2.0.0"
1664
+ },
1665
+ "engines": {
1666
+ "node": ">=6"
1667
+ },
1668
+ "funding": {
1669
+ "url": "https://github.com/sponsors/sindresorhus"
1670
+ }
1671
+ },
1672
+ "node_modules/p-locate": {
1673
+ "version": "4.1.0",
1674
+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",
1675
+ "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",
1676
+ "dev": true,
1677
+ "dependencies": {
1678
+ "p-limit": "^2.2.0"
1679
+ },
1680
+ "engines": {
1681
+ "node": ">=8"
1682
+ }
1683
+ },
1684
+ "node_modules/p-try": {
1685
+ "version": "2.2.0",
1686
+ "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",
1687
+ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",
1688
+ "dev": true,
1689
+ "engines": {
1690
+ "node": ">=6"
1691
+ }
1692
+ },
1693
+ "node_modules/parseurl": {
1694
+ "version": "1.3.3",
1695
+ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
1696
+ "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
1697
+ "dev": true,
1698
+ "engines": {
1699
+ "node": ">= 0.8"
1700
+ }
1701
+ },
1702
+ "node_modules/path-exists": {
1703
+ "version": "4.0.0",
1704
+ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
1705
+ "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
1706
+ "dev": true,
1707
+ "engines": {
1708
+ "node": ">=8"
1709
+ }
1710
+ },
1711
+ "node_modules/path-key": {
1712
+ "version": "3.1.1",
1713
+ "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
1714
+ "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
1715
+ "dev": true,
1716
+ "engines": {
1717
+ "node": ">=8"
1718
+ }
1719
+ },
1720
+ "node_modules/path-parse": {
1721
+ "version": "1.0.7",
1722
+ "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz",
1723
+ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==",
1724
+ "dev": true
1725
+ },
1726
+ "node_modules/path-to-regexp": {
1727
+ "version": "0.1.7",
1728
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
1729
+ "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==",
1730
+ "dev": true
1731
+ },
1732
+ "node_modules/picocolors": {
1733
+ "version": "1.0.0",
1734
+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
1735
+ "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
1736
+ "dev": true
1737
+ },
1738
+ "node_modules/picomatch": {
1739
+ "version": "2.3.1",
1740
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
1741
+ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
1742
+ "dev": true,
1743
+ "engines": {
1744
+ "node": ">=8.6"
1745
+ },
1746
+ "funding": {
1747
+ "url": "https://github.com/sponsors/jonschlinkert"
1748
+ }
1749
+ },
1750
+ "node_modules/pkg-dir": {
1751
+ "version": "4.2.0",
1752
+ "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz",
1753
+ "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==",
1754
+ "dev": true,
1755
+ "dependencies": {
1756
+ "find-up": "^4.0.0"
1757
+ },
1758
+ "engines": {
1759
+ "node": ">=8"
1760
+ }
1761
+ },
1762
+ "node_modules/proxy-addr": {
1763
+ "version": "2.0.7",
1764
+ "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
1765
+ "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
1766
+ "dev": true,
1767
+ "dependencies": {
1768
+ "forwarded": "0.2.0",
1769
+ "ipaddr.js": "1.9.1"
1770
+ },
1771
+ "engines": {
1772
+ "node": ">= 0.10"
1773
+ }
1774
+ },
1775
+ "node_modules/pstree.remy": {
1776
+ "version": "1.1.8",
1777
+ "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz",
1778
+ "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==",
1779
+ "dev": true
1780
+ },
1781
+ "node_modules/punycode": {
1782
+ "version": "2.3.1",
1783
+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
1784
+ "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
1785
+ "dev": true,
1786
+ "engines": {
1787
+ "node": ">=6"
1788
+ }
1789
+ },
1790
+ "node_modules/qs": {
1791
+ "version": "6.11.0",
1792
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
1793
+ "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==",
1794
+ "dev": true,
1795
+ "dependencies": {
1796
+ "side-channel": "^1.0.4"
1797
+ },
1798
+ "engines": {
1799
+ "node": ">=0.6"
1800
+ },
1801
+ "funding": {
1802
+ "url": "https://github.com/sponsors/ljharb"
1803
+ }
1804
+ },
1805
+ "node_modules/randombytes": {
1806
+ "version": "2.1.0",
1807
+ "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
1808
+ "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==",
1809
+ "dev": true,
1810
+ "dependencies": {
1811
+ "safe-buffer": "^5.1.0"
1812
+ }
1813
+ },
1814
+ "node_modules/range-parser": {
1815
+ "version": "1.2.1",
1816
+ "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
1817
+ "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
1818
+ "dev": true,
1819
+ "engines": {
1820
+ "node": ">= 0.6"
1821
+ }
1822
+ },
1823
+ "node_modules/raw-body": {
1824
+ "version": "2.5.2",
1825
+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
1826
+ "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
1827
+ "dev": true,
1828
+ "dependencies": {
1829
+ "bytes": "3.1.2",
1830
+ "http-errors": "2.0.0",
1831
+ "iconv-lite": "0.4.24",
1832
+ "unpipe": "1.0.0"
1833
+ },
1834
+ "engines": {
1835
+ "node": ">= 0.8"
1836
+ }
1837
+ },
1838
+ "node_modules/readdirp": {
1839
+ "version": "3.6.0",
1840
+ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
1841
+ "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
1842
+ "dev": true,
1843
+ "dependencies": {
1844
+ "picomatch": "^2.2.1"
1845
+ },
1846
+ "engines": {
1847
+ "node": ">=8.10.0"
1848
+ }
1849
+ },
1850
+ "node_modules/rechoir": {
1851
+ "version": "0.8.0",
1852
+ "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.8.0.tgz",
1853
+ "integrity": "sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==",
1854
+ "dev": true,
1855
+ "dependencies": {
1856
+ "resolve": "^1.20.0"
1857
+ },
1858
+ "engines": {
1859
+ "node": ">= 10.13.0"
1860
+ }
1861
+ },
1862
+ "node_modules/resolve": {
1863
+ "version": "1.22.8",
1864
+ "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz",
1865
+ "integrity": "sha512-oKWePCxqpd6FlLvGV1VU0x7bkPmmCNolxzjMf4NczoDnQcIWrAF+cPtZn5i6n+RfD2d9i0tzpKnG6Yk168yIyw==",
1866
+ "dev": true,
1867
+ "dependencies": {
1868
+ "is-core-module": "^2.13.0",
1869
+ "path-parse": "^1.0.7",
1870
+ "supports-preserve-symlinks-flag": "^1.0.0"
1871
+ },
1872
+ "bin": {
1873
+ "resolve": "bin/resolve"
1874
+ },
1875
+ "funding": {
1876
+ "url": "https://github.com/sponsors/ljharb"
1877
+ }
1878
+ },
1879
+ "node_modules/resolve-cwd": {
1880
+ "version": "3.0.0",
1881
+ "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz",
1882
+ "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==",
1883
+ "dev": true,
1884
+ "dependencies": {
1885
+ "resolve-from": "^5.0.0"
1886
+ },
1887
+ "engines": {
1888
+ "node": ">=8"
1889
+ }
1890
+ },
1891
+ "node_modules/resolve-from": {
1892
+ "version": "5.0.0",
1893
+ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz",
1894
+ "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==",
1895
+ "dev": true,
1896
+ "engines": {
1897
+ "node": ">=8"
1898
+ }
1899
+ },
1900
+ "node_modules/safe-buffer": {
1901
+ "version": "5.2.1",
1902
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
1903
+ "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
1904
+ "dev": true,
1905
+ "funding": [
1906
+ {
1907
+ "type": "github",
1908
+ "url": "https://github.com/sponsors/feross"
1909
+ },
1910
+ {
1911
+ "type": "patreon",
1912
+ "url": "https://www.patreon.com/feross"
1913
+ },
1914
+ {
1915
+ "type": "consulting",
1916
+ "url": "https://feross.org/support"
1917
+ }
1918
+ ]
1919
+ },
1920
+ "node_modules/safer-buffer": {
1921
+ "version": "2.1.2",
1922
+ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
1923
+ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
1924
+ "dev": true
1925
+ },
1926
+ "node_modules/schema-utils": {
1927
+ "version": "3.3.0",
1928
+ "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.3.0.tgz",
1929
+ "integrity": "sha512-pN/yOAvcC+5rQ5nERGuwrjLlYvLTbCibnZ1I7B1LaiAz9BRBlE9GMgE/eqV30P7aJQUf7Ddimy/RsbYO/GrVGg==",
1930
+ "dev": true,
1931
+ "dependencies": {
1932
+ "@types/json-schema": "^7.0.8",
1933
+ "ajv": "^6.12.5",
1934
+ "ajv-keywords": "^3.5.2"
1935
+ },
1936
+ "engines": {
1937
+ "node": ">= 10.13.0"
1938
+ },
1939
+ "funding": {
1940
+ "type": "opencollective",
1941
+ "url": "https://opencollective.com/webpack"
1942
+ }
1943
+ },
1944
+ "node_modules/semver": {
1945
+ "version": "5.7.2",
1946
+ "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz",
1947
+ "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==",
1948
+ "dev": true,
1949
+ "bin": {
1950
+ "semver": "bin/semver"
1951
+ }
1952
+ },
1953
+ "node_modules/send": {
1954
+ "version": "0.18.0",
1955
+ "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz",
1956
+ "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==",
1957
+ "dev": true,
1958
+ "dependencies": {
1959
+ "debug": "2.6.9",
1960
+ "depd": "2.0.0",
1961
+ "destroy": "1.2.0",
1962
+ "encodeurl": "~1.0.2",
1963
+ "escape-html": "~1.0.3",
1964
+ "etag": "~1.8.1",
1965
+ "fresh": "0.5.2",
1966
+ "http-errors": "2.0.0",
1967
+ "mime": "1.6.0",
1968
+ "ms": "2.1.3",
1969
+ "on-finished": "2.4.1",
1970
+ "range-parser": "~1.2.1",
1971
+ "statuses": "2.0.1"
1972
+ },
1973
+ "engines": {
1974
+ "node": ">= 0.8.0"
1975
+ }
1976
+ },
1977
+ "node_modules/send/node_modules/ms": {
1978
+ "version": "2.1.3",
1979
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
1980
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1981
+ "dev": true
1982
+ },
1983
+ "node_modules/serialize-javascript": {
1984
+ "version": "6.0.2",
1985
+ "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz",
1986
+ "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==",
1987
+ "dev": true,
1988
+ "dependencies": {
1989
+ "randombytes": "^2.1.0"
1990
+ }
1991
+ },
1992
+ "node_modules/serve-static": {
1993
+ "version": "1.15.0",
1994
+ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz",
1995
+ "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==",
1996
+ "dev": true,
1997
+ "dependencies": {
1998
+ "encodeurl": "~1.0.2",
1999
+ "escape-html": "~1.0.3",
2000
+ "parseurl": "~1.3.3",
2001
+ "send": "0.18.0"
2002
+ },
2003
+ "engines": {
2004
+ "node": ">= 0.8.0"
2005
+ }
2006
+ },
2007
+ "node_modules/set-function-length": {
2008
+ "version": "1.2.1",
2009
+ "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.1.tgz",
2010
+ "integrity": "sha512-j4t6ccc+VsKwYHso+kElc5neZpjtq9EnRICFZtWyBsLojhmeF/ZBd/elqm22WJh/BziDe/SBiOeAt0m2mfLD0g==",
2011
+ "dev": true,
2012
+ "dependencies": {
2013
+ "define-data-property": "^1.1.2",
2014
+ "es-errors": "^1.3.0",
2015
+ "function-bind": "^1.1.2",
2016
+ "get-intrinsic": "^1.2.3",
2017
+ "gopd": "^1.0.1",
2018
+ "has-property-descriptors": "^1.0.1"
2019
+ },
2020
+ "engines": {
2021
+ "node": ">= 0.4"
2022
+ }
2023
+ },
2024
+ "node_modules/setprototypeof": {
2025
+ "version": "1.2.0",
2026
+ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
2027
+ "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
2028
+ "dev": true
2029
+ },
2030
+ "node_modules/shallow-clone": {
2031
+ "version": "3.0.1",
2032
+ "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz",
2033
+ "integrity": "sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==",
2034
+ "dev": true,
2035
+ "dependencies": {
2036
+ "kind-of": "^6.0.2"
2037
+ },
2038
+ "engines": {
2039
+ "node": ">=8"
2040
+ }
2041
+ },
2042
+ "node_modules/shebang-command": {
2043
+ "version": "2.0.0",
2044
+ "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
2045
+ "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
2046
+ "dev": true,
2047
+ "dependencies": {
2048
+ "shebang-regex": "^3.0.0"
2049
+ },
2050
+ "engines": {
2051
+ "node": ">=8"
2052
+ }
2053
+ },
2054
+ "node_modules/shebang-regex": {
2055
+ "version": "3.0.0",
2056
+ "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
2057
+ "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
2058
+ "dev": true,
2059
+ "engines": {
2060
+ "node": ">=8"
2061
+ }
2062
+ },
2063
+ "node_modules/side-channel": {
2064
+ "version": "1.0.6",
2065
+ "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz",
2066
+ "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==",
2067
+ "dev": true,
2068
+ "dependencies": {
2069
+ "call-bind": "^1.0.7",
2070
+ "es-errors": "^1.3.0",
2071
+ "get-intrinsic": "^1.2.4",
2072
+ "object-inspect": "^1.13.1"
2073
+ },
2074
+ "engines": {
2075
+ "node": ">= 0.4"
2076
+ },
2077
+ "funding": {
2078
+ "url": "https://github.com/sponsors/ljharb"
2079
+ }
2080
+ },
2081
+ "node_modules/simple-update-notifier": {
2082
+ "version": "1.1.0",
2083
+ "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz",
2084
+ "integrity": "sha512-VpsrsJSUcJEseSbMHkrsrAVSdvVS5I96Qo1QAQ4FxQ9wXFcB+pjj7FB7/us9+GcgfW4ziHtYMc1J0PLczb55mg==",
2085
+ "dev": true,
2086
+ "dependencies": {
2087
+ "semver": "~7.0.0"
2088
+ },
2089
+ "engines": {
2090
+ "node": ">=8.10.0"
2091
+ }
2092
+ },
2093
+ "node_modules/simple-update-notifier/node_modules/semver": {
2094
+ "version": "7.0.0",
2095
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz",
2096
+ "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==",
2097
+ "dev": true,
2098
+ "bin": {
2099
+ "semver": "bin/semver.js"
2100
+ }
2101
+ },
2102
+ "node_modules/source-map": {
2103
+ "version": "0.6.1",
2104
+ "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
2105
+ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
2106
+ "dev": true,
2107
+ "engines": {
2108
+ "node": ">=0.10.0"
2109
+ }
2110
+ },
2111
+ "node_modules/source-map-support": {
2112
+ "version": "0.5.21",
2113
+ "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
2114
+ "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
2115
+ "dev": true,
2116
+ "dependencies": {
2117
+ "buffer-from": "^1.0.0",
2118
+ "source-map": "^0.6.0"
2119
+ }
2120
+ },
2121
+ "node_modules/statuses": {
2122
+ "version": "2.0.1",
2123
+ "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
2124
+ "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
2125
+ "dev": true,
2126
+ "engines": {
2127
+ "node": ">= 0.8"
2128
+ }
2129
+ },
2130
+ "node_modules/supports-color": {
2131
+ "version": "7.2.0",
2132
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
2133
+ "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
2134
+ "dev": true,
2135
+ "dependencies": {
2136
+ "has-flag": "^4.0.0"
2137
+ },
2138
+ "engines": {
2139
+ "node": ">=8"
2140
+ }
2141
+ },
2142
+ "node_modules/supports-preserve-symlinks-flag": {
2143
+ "version": "1.0.0",
2144
+ "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz",
2145
+ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==",
2146
+ "dev": true,
2147
+ "engines": {
2148
+ "node": ">= 0.4"
2149
+ },
2150
+ "funding": {
2151
+ "url": "https://github.com/sponsors/ljharb"
2152
+ }
2153
+ },
2154
+ "node_modules/tapable": {
2155
+ "version": "2.2.1",
2156
+ "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz",
2157
+ "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==",
2158
+ "dev": true,
2159
+ "engines": {
2160
+ "node": ">=6"
2161
+ }
2162
+ },
2163
+ "node_modules/terser": {
2164
+ "version": "5.28.1",
2165
+ "resolved": "https://registry.npmjs.org/terser/-/terser-5.28.1.tgz",
2166
+ "integrity": "sha512-wM+bZp54v/E9eRRGXb5ZFDvinrJIOaTapx3WUokyVGZu5ucVCK55zEgGd5Dl2fSr3jUo5sDiERErUWLY6QPFyA==",
2167
+ "dev": true,
2168
+ "dependencies": {
2169
+ "@jridgewell/source-map": "^0.3.3",
2170
+ "acorn": "^8.8.2",
2171
+ "commander": "^2.20.0",
2172
+ "source-map-support": "~0.5.20"
2173
+ },
2174
+ "bin": {
2175
+ "terser": "bin/terser"
2176
+ },
2177
+ "engines": {
2178
+ "node": ">=10"
2179
+ }
2180
+ },
2181
+ "node_modules/terser-webpack-plugin": {
2182
+ "version": "5.3.10",
2183
+ "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.10.tgz",
2184
+ "integrity": "sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w==",
2185
+ "dev": true,
2186
+ "dependencies": {
2187
+ "@jridgewell/trace-mapping": "^0.3.20",
2188
+ "jest-worker": "^27.4.5",
2189
+ "schema-utils": "^3.1.1",
2190
+ "serialize-javascript": "^6.0.1",
2191
+ "terser": "^5.26.0"
2192
+ },
2193
+ "engines": {
2194
+ "node": ">= 10.13.0"
2195
+ },
2196
+ "funding": {
2197
+ "type": "opencollective",
2198
+ "url": "https://opencollective.com/webpack"
2199
+ },
2200
+ "peerDependencies": {
2201
+ "webpack": "^5.1.0"
2202
+ },
2203
+ "peerDependenciesMeta": {
2204
+ "@swc/core": {
2205
+ "optional": true
2206
+ },
2207
+ "esbuild": {
2208
+ "optional": true
2209
+ },
2210
+ "uglify-js": {
2211
+ "optional": true
2212
+ }
2213
+ }
2214
+ },
2215
+ "node_modules/to-regex-range": {
2216
+ "version": "5.0.1",
2217
+ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
2218
+ "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
2219
+ "dev": true,
2220
+ "dependencies": {
2221
+ "is-number": "^7.0.0"
2222
+ },
2223
+ "engines": {
2224
+ "node": ">=8.0"
2225
+ }
2226
+ },
2227
+ "node_modules/toidentifier": {
2228
+ "version": "1.0.1",
2229
+ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
2230
+ "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
2231
+ "dev": true,
2232
+ "engines": {
2233
+ "node": ">=0.6"
2234
+ }
2235
+ },
2236
+ "node_modules/touch": {
2237
+ "version": "3.1.0",
2238
+ "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.0.tgz",
2239
+ "integrity": "sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA==",
2240
+ "dev": true,
2241
+ "dependencies": {
2242
+ "nopt": "~1.0.10"
2243
+ },
2244
+ "bin": {
2245
+ "nodetouch": "bin/nodetouch.js"
2246
+ }
2247
+ },
2248
+ "node_modules/type-is": {
2249
+ "version": "1.6.18",
2250
+ "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
2251
+ "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
2252
+ "dev": true,
2253
+ "dependencies": {
2254
+ "media-typer": "0.3.0",
2255
+ "mime-types": "~2.1.24"
2256
+ },
2257
+ "engines": {
2258
+ "node": ">= 0.6"
2259
+ }
2260
+ },
2261
+ "node_modules/uglify-js": {
2262
+ "version": "3.17.4",
2263
+ "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.4.tgz",
2264
+ "integrity": "sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==",
2265
+ "dev": true,
2266
+ "bin": {
2267
+ "uglifyjs": "bin/uglifyjs"
2268
+ },
2269
+ "engines": {
2270
+ "node": ">=0.8.0"
2271
+ }
2272
+ },
2273
+ "node_modules/undefsafe": {
2274
+ "version": "2.0.5",
2275
+ "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz",
2276
+ "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==",
2277
+ "dev": true
2278
+ },
2279
+ "node_modules/undici-types": {
2280
+ "version": "5.26.5",
2281
+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
2282
+ "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==",
2283
+ "dev": true
2284
+ },
2285
+ "node_modules/unpipe": {
2286
+ "version": "1.0.0",
2287
+ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
2288
+ "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
2289
+ "dev": true,
2290
+ "engines": {
2291
+ "node": ">= 0.8"
2292
+ }
2293
+ },
2294
+ "node_modules/update-browserslist-db": {
2295
+ "version": "1.0.13",
2296
+ "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.13.tgz",
2297
+ "integrity": "sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==",
2298
+ "dev": true,
2299
+ "funding": [
2300
+ {
2301
+ "type": "opencollective",
2302
+ "url": "https://opencollective.com/browserslist"
2303
+ },
2304
+ {
2305
+ "type": "tidelift",
2306
+ "url": "https://tidelift.com/funding/github/npm/browserslist"
2307
+ },
2308
+ {
2309
+ "type": "github",
2310
+ "url": "https://github.com/sponsors/ai"
2311
+ }
2312
+ ],
2313
+ "dependencies": {
2314
+ "escalade": "^3.1.1",
2315
+ "picocolors": "^1.0.0"
2316
+ },
2317
+ "bin": {
2318
+ "update-browserslist-db": "cli.js"
2319
+ },
2320
+ "peerDependencies": {
2321
+ "browserslist": ">= 4.21.0"
2322
+ }
2323
+ },
2324
+ "node_modules/uri-js": {
2325
+ "version": "4.4.1",
2326
+ "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
2327
+ "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==",
2328
+ "dev": true,
2329
+ "dependencies": {
2330
+ "punycode": "^2.1.0"
2331
+ }
2332
+ },
2333
+ "node_modules/utils-merge": {
2334
+ "version": "1.0.1",
2335
+ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
2336
+ "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
2337
+ "dev": true,
2338
+ "engines": {
2339
+ "node": ">= 0.4.0"
2340
+ }
2341
+ },
2342
+ "node_modules/vary": {
2343
+ "version": "1.1.2",
2344
+ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
2345
+ "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
2346
+ "dev": true,
2347
+ "engines": {
2348
+ "node": ">= 0.8"
2349
+ }
2350
+ },
2351
+ "node_modules/watchpack": {
2352
+ "version": "2.4.0",
2353
+ "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz",
2354
+ "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==",
2355
+ "dev": true,
2356
+ "dependencies": {
2357
+ "glob-to-regexp": "^0.4.1",
2358
+ "graceful-fs": "^4.1.2"
2359
+ },
2360
+ "engines": {
2361
+ "node": ">=10.13.0"
2362
+ }
2363
+ },
2364
+ "node_modules/webpack": {
2365
+ "version": "5.90.3",
2366
+ "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.90.3.tgz",
2367
+ "integrity": "sha512-h6uDYlWCctQRuXBs1oYpVe6sFcWedl0dpcVaTf/YF67J9bKvwJajFulMVSYKHrksMB3I/pIagRzDxwxkebuzKA==",
2368
+ "dev": true,
2369
+ "dependencies": {
2370
+ "@types/eslint-scope": "^3.7.3",
2371
+ "@types/estree": "^1.0.5",
2372
+ "@webassemblyjs/ast": "^1.11.5",
2373
+ "@webassemblyjs/wasm-edit": "^1.11.5",
2374
+ "@webassemblyjs/wasm-parser": "^1.11.5",
2375
+ "acorn": "^8.7.1",
2376
+ "acorn-import-assertions": "^1.9.0",
2377
+ "browserslist": "^4.21.10",
2378
+ "chrome-trace-event": "^1.0.2",
2379
+ "enhanced-resolve": "^5.15.0",
2380
+ "es-module-lexer": "^1.2.1",
2381
+ "eslint-scope": "5.1.1",
2382
+ "events": "^3.2.0",
2383
+ "glob-to-regexp": "^0.4.1",
2384
+ "graceful-fs": "^4.2.9",
2385
+ "json-parse-even-better-errors": "^2.3.1",
2386
+ "loader-runner": "^4.2.0",
2387
+ "mime-types": "^2.1.27",
2388
+ "neo-async": "^2.6.2",
2389
+ "schema-utils": "^3.2.0",
2390
+ "tapable": "^2.1.1",
2391
+ "terser-webpack-plugin": "^5.3.10",
2392
+ "watchpack": "^2.4.0",
2393
+ "webpack-sources": "^3.2.3"
2394
+ },
2395
+ "bin": {
2396
+ "webpack": "bin/webpack.js"
2397
+ },
2398
+ "engines": {
2399
+ "node": ">=10.13.0"
2400
+ },
2401
+ "funding": {
2402
+ "type": "opencollective",
2403
+ "url": "https://opencollective.com/webpack"
2404
+ },
2405
+ "peerDependenciesMeta": {
2406
+ "webpack-cli": {
2407
+ "optional": true
2408
+ }
2409
+ }
2410
+ },
2411
+ "node_modules/webpack-cli": {
2412
+ "version": "5.1.4",
2413
+ "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-5.1.4.tgz",
2414
+ "integrity": "sha512-pIDJHIEI9LR0yxHXQ+Qh95k2EvXpWzZ5l+d+jIo+RdSm9MiHfzazIxwwni/p7+x4eJZuvG1AJwgC4TNQ7NRgsg==",
2415
+ "dev": true,
2416
+ "dependencies": {
2417
+ "@discoveryjs/json-ext": "^0.5.0",
2418
+ "@webpack-cli/configtest": "^2.1.1",
2419
+ "@webpack-cli/info": "^2.0.2",
2420
+ "@webpack-cli/serve": "^2.0.5",
2421
+ "colorette": "^2.0.14",
2422
+ "commander": "^10.0.1",
2423
+ "cross-spawn": "^7.0.3",
2424
+ "envinfo": "^7.7.3",
2425
+ "fastest-levenshtein": "^1.0.12",
2426
+ "import-local": "^3.0.2",
2427
+ "interpret": "^3.1.1",
2428
+ "rechoir": "^0.8.0",
2429
+ "webpack-merge": "^5.7.3"
2430
+ },
2431
+ "bin": {
2432
+ "webpack-cli": "bin/cli.js"
2433
+ },
2434
+ "engines": {
2435
+ "node": ">=14.15.0"
2436
+ },
2437
+ "funding": {
2438
+ "type": "opencollective",
2439
+ "url": "https://opencollective.com/webpack"
2440
+ },
2441
+ "peerDependencies": {
2442
+ "webpack": "5.x.x"
2443
+ },
2444
+ "peerDependenciesMeta": {
2445
+ "@webpack-cli/generators": {
2446
+ "optional": true
2447
+ },
2448
+ "webpack-bundle-analyzer": {
2449
+ "optional": true
2450
+ },
2451
+ "webpack-dev-server": {
2452
+ "optional": true
2453
+ }
2454
+ }
2455
+ },
2456
+ "node_modules/webpack-cli/node_modules/commander": {
2457
+ "version": "10.0.1",
2458
+ "resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz",
2459
+ "integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==",
2460
+ "dev": true,
2461
+ "engines": {
2462
+ "node": ">=14"
2463
+ }
2464
+ },
2465
+ "node_modules/webpack-merge": {
2466
+ "version": "5.10.0",
2467
+ "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.10.0.tgz",
2468
+ "integrity": "sha512-+4zXKdx7UnO+1jaN4l2lHVD+mFvnlZQP/6ljaJVb4SZiwIKeUnrT5l0gkT8z+n4hKpC+jpOv6O9R+gLtag7pSA==",
2469
+ "dev": true,
2470
+ "dependencies": {
2471
+ "clone-deep": "^4.0.1",
2472
+ "flat": "^5.0.2",
2473
+ "wildcard": "^2.0.0"
2474
+ },
2475
+ "engines": {
2476
+ "node": ">=10.0.0"
2477
+ }
2478
+ },
2479
+ "node_modules/webpack-sources": {
2480
+ "version": "3.2.3",
2481
+ "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz",
2482
+ "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==",
2483
+ "dev": true,
2484
+ "engines": {
2485
+ "node": ">=10.13.0"
2486
+ }
2487
+ },
2488
+ "node_modules/which": {
2489
+ "version": "2.0.2",
2490
+ "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
2491
+ "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
2492
+ "dev": true,
2493
+ "dependencies": {
2494
+ "isexe": "^2.0.0"
2495
+ },
2496
+ "bin": {
2497
+ "node-which": "bin/node-which"
2498
+ },
2499
+ "engines": {
2500
+ "node": ">= 8"
2501
+ }
2502
+ },
2503
+ "node_modules/wildcard": {
2504
+ "version": "2.0.1",
2505
+ "resolved": "https://registry.npmjs.org/wildcard/-/wildcard-2.0.1.tgz",
2506
+ "integrity": "sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ==",
2507
+ "dev": true
2508
+ }
2509
+ }
2510
+ }
package.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "puter.com",
3
+ "version": "1.0.0",
4
+ "author": "Puter Technologies Inc.",
5
+ "license": "AGPL-3.0-only",
6
+ "description": "Desktop environment in the browser!",
7
+ "homepage": "https://puter.com",
8
+ "directories": {
9
+ "lib": "lib"
10
+ },
11
+ "devDependencies": {
12
+ "chalk": "^4.1.0",
13
+ "clean-css": "^5.3.2",
14
+ "html-entities": "^2.3.3",
15
+ "webpack": "^5.88.2",
16
+ "express": "^4.18.2",
17
+ "nodemon": "^2.0.22",
18
+ "uglify-js": "^3.17.4",
19
+ "webpack-cli": "^5.1.1"
20
+ },
21
+ "scripts": {
22
+ "test": "echo \"Error: no test specified\" && exit 1",
23
+ "start": "nodemon --exec \"node dev-server.js\" ",
24
+ "build": "node ./build.js"
25
+ },
26
+ "nodemonConfig": {
27
+ "ext": "js, json, mjs, jsx, svg, css",
28
+ "ignore": [
29
+ "./dist/",
30
+ "./node_modules/"
31
+ ]
32
+ }
33
+ }
src/IPC.js ADDED
@@ -0,0 +1,972 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIAlert from './UI/UIAlert.js';
21
+ import UIWindow from './UI/UIWindow.js';
22
+ import UIWindowSignup from './UI/UIWindowSignup.js';
23
+ import UIWindowRequestPermission from './UI/UIWindowRequestPermission.js';
24
+ import UIItem from './UI/UIItem.js'
25
+ import UIWindowFontPicker from './UI/UIWindowFontPicker.js';
26
+ import UIWindowColorPicker from './UI/UIWindowColorPicker.js';
27
+ import UIPrompt from './UI/UIPrompt.js';
28
+ import download from './helpers/download.js';
29
+ import path from "./lib/path.js";
30
+
31
+ /**
32
+ * In Puter, apps are loaded in iframes and communicate with the graphical user interface (GUI) aand each other using the postMessage API.
33
+ * The following sets up an Inter-Process Messaging System between apps and the GUI that enables communication
34
+ * for various tasks such as displaying alerts, prompts, managing windows, handling file operations, and more.
35
+ *
36
+ * The system listens for 'message' events on the window object, handling different types of messages from the app (which is loaded in an iframe),
37
+ * such as ALERT, createWindow, showOpenFilePicker, ...
38
+ * Each message handler performs specific actions, including creating UI windows, handling file saves and reads, and responding to user interactions.
39
+ *
40
+ * Precautions are taken to ensure proper usage of appInstanceIDs and other sensitive information.
41
+ */
42
+ window.addEventListener('message', async (event) => {
43
+ const app_env = event.data?.env ?? 'app';
44
+
45
+ // Only process messages from apps
46
+ if(app_env !== 'app')
47
+ return;
48
+
49
+ // --------------------------------------------------------
50
+ // A response to a GUI message received from the app.
51
+ // --------------------------------------------------------
52
+ if (typeof event.data.original_msg_id !== "undefined" && typeof appCallbackFunctions[event.data.original_msg_id] !== "undefined") {
53
+ // Execute callback
54
+ appCallbackFunctions[event.data.original_msg_id](event.data);
55
+ // Remove this callback function since it won't be needed again
56
+ delete appCallbackFunctions[event.data.original_msg_id];
57
+
58
+ // Done
59
+ return;
60
+ }
61
+
62
+ // --------------------------------------------------------
63
+ // Message from apps
64
+ // --------------------------------------------------------
65
+
66
+ // `data` and `msg` are required
67
+ if(!event.data || !event.data.msg){
68
+ return;
69
+ }
70
+
71
+ // `appInstanceID` is required
72
+ if(!event.data.appInstanceID){
73
+ console.log(`appInstanceID is needed`);
74
+ return;
75
+ }
76
+
77
+ const $el_parent_window = $(`.window[data-element_uuid="${event.data.appInstanceID}"]`);
78
+ const parent_window_id = $el_parent_window.attr('data-id');
79
+ const $el_parent_disable_mask = $el_parent_window.find('.window-disable-mask');
80
+ const target_iframe = $(`.window[data-element_uuid="${event.data.appInstanceID}"]`).find('.window-app-iframe').get(0);
81
+ const msg_id = event.data.uuid;
82
+ const app_name = $(target_iframe).attr('data-app');
83
+ const app_uuid = $el_parent_window.attr('data-app_uuid');
84
+
85
+ // todo validate all event.data stuff coming from the client (e.g. event.data.message, .msg, ...)
86
+ //-------------------------------------------------
87
+ // READY
88
+ //-------------------------------------------------
89
+ if(event.data.msg === 'READY'){
90
+ $(target_iframe).attr('data-appUsesSDK', 'true');
91
+ }
92
+ //-------------------------------------------------
93
+ // windowFocused
94
+ //-------------------------------------------------
95
+ else if(event.data.msg === 'windowFocused'){
96
+ console.log('windowFocused');
97
+ }
98
+ //--------------------------------------------------------
99
+ // ALERT
100
+ //--------------------------------------------------------
101
+ else if(event.data.msg === 'ALERT' && event.data.message !== undefined){
102
+ const alert_resp = await UIAlert({
103
+ message: html_encode(event.data.message),
104
+ buttons: event.data.buttons,
105
+ type: event.data.options?.type,
106
+ window_options: {
107
+ parent_uuid: event.data.appInstanceID,
108
+ disable_parent_window: true,
109
+ }
110
+ })
111
+
112
+ target_iframe.contentWindow.postMessage({
113
+ original_msg_id: msg_id,
114
+ msg: 'alertResponded',
115
+ response: alert_resp,
116
+ }, '*');
117
+ }
118
+ //--------------------------------------------------------
119
+ // PROMPT
120
+ //--------------------------------------------------------
121
+ else if(event.data.msg === 'PROMPT' && event.data.message !== undefined){
122
+ const prompt_resp = await UIPrompt({
123
+ message: html_encode(event.data.message),
124
+ placeholder: html_encode(event.data.placeholder),
125
+ window_options: {
126
+ parent_uuid: event.data.appInstanceID,
127
+ disable_parent_window: true,
128
+ }
129
+ })
130
+
131
+ target_iframe.contentWindow.postMessage({
132
+ original_msg_id: msg_id,
133
+ msg: 'promptResponded',
134
+ response: prompt_resp,
135
+ }, '*');
136
+ }
137
+ //--------------------------------------------------------
138
+ // env
139
+ //--------------------------------------------------------
140
+ else if(event.data.msg === 'env'){
141
+ target_iframe.contentWindow.postMessage({
142
+ original_msg_id: msg_id,
143
+ }, '*');
144
+ }
145
+ //--------------------------------------------------------
146
+ // createWindow
147
+ //--------------------------------------------------------
148
+ else if(event.data.msg === 'createWindow'){
149
+ // todo: validate as many of these as possible
150
+ if(event.data.options){
151
+ UIWindow({
152
+ title: event.data.options.title,
153
+ disable_parent_window: event.data.options.disable_parent_window,
154
+ width: event.data.options.width,
155
+ height: event.data.options.height,
156
+ is_resizable: event.data.options.is_resizable,
157
+ has_head: event.data.options.has_head,
158
+ center: event.data.options.center,
159
+ show_in_taskbar: event.data.options.show_in_taskbar,
160
+ iframe_srcdoc: event.data.options.content,
161
+ iframe_url: event.data.options.url,
162
+ parent_uuid: event.data.appInstanceID,
163
+ })
164
+ }
165
+ }
166
+ //--------------------------------------------------------
167
+ // setItem
168
+ //--------------------------------------------------------
169
+ else if(event.data.msg === 'setItem' && event.data.key && event.data.value){
170
+ // todo: validate key and value to avoid unnecessary api calls
171
+ return await $.ajax({
172
+ url: api_origin + "/setItem",
173
+ type: 'POST',
174
+ data: JSON.stringify({
175
+ app: app_uuid,
176
+ key: event.data.key,
177
+ value: event.data.value,
178
+ }),
179
+ async: true,
180
+ contentType: "application/json",
181
+ headers: {
182
+ "Authorization": "Bearer "+auth_token
183
+ },
184
+ statusCode: {
185
+ 401: function () {
186
+ logout();
187
+ },
188
+ },
189
+ success: function (fsentry){
190
+ }
191
+ })
192
+ }
193
+ //--------------------------------------------------------
194
+ // getItem
195
+ //--------------------------------------------------------
196
+ else if(event.data.msg === 'getItem' && event.data.key){
197
+ // todo: validate key to avoid unnecessary api calls
198
+ $.ajax({
199
+ url: api_origin + "/getItem",
200
+ type: 'POST',
201
+ data: JSON.stringify({
202
+ key: event.data.key,
203
+ app: app_uuid,
204
+ }),
205
+ async: true,
206
+ contentType: "application/json",
207
+ headers: {
208
+ "Authorization": "Bearer "+auth_token
209
+ },
210
+ statusCode: {
211
+ 401: function () {
212
+ logout();
213
+ },
214
+ },
215
+ success: function (result){
216
+ // send confirmation to requester window
217
+ target_iframe.contentWindow.postMessage({
218
+ original_msg_id: msg_id,
219
+ msg: 'getItemSucceeded',
220
+ value: result ? result.value : null,
221
+ }, '*');
222
+ }
223
+ })
224
+ }
225
+ //--------------------------------------------------------
226
+ // removeItem
227
+ //--------------------------------------------------------
228
+ else if(event.data.msg === 'removeItem' && event.data.key){
229
+ // todo: validate key to avoid unnecessary api calls
230
+ $.ajax({
231
+ url: api_origin + "/removeItem",
232
+ type: 'POST',
233
+ data: JSON.stringify({
234
+ key: event.data.key,
235
+ app: app_uuid,
236
+ }),
237
+ async: true,
238
+ contentType: "application/json",
239
+ headers: {
240
+ "Authorization": "Bearer "+auth_token
241
+ },
242
+ statusCode: {
243
+ 401: function () {
244
+ logout();
245
+ },
246
+ },
247
+ success: function (result){
248
+ // send confirmation to requester window
249
+ target_iframe.contentWindow.postMessage({
250
+ original_msg_id: msg_id,
251
+ }, '*');
252
+ }
253
+ })
254
+ }
255
+ //--------------------------------------------------------
256
+ // showOpenFilePicker
257
+ //--------------------------------------------------------
258
+ else if(event.data.msg === 'showOpenFilePicker'){
259
+ // Auth
260
+ if(!is_auth() && !(await UIWindowSignup({referrer: app_name})))
261
+ return;
262
+
263
+ // Disable parent window
264
+ $el_parent_window.addClass('window-disabled')
265
+ $el_parent_disable_mask.show();
266
+ $el_parent_disable_mask.css('z-index', parseInt($el_parent_window.css('z-index')) + 1);
267
+ $(target_iframe).blur();
268
+
269
+ // Allowed_file_types
270
+ let allowed_file_types = "";
271
+ if(event.data.options && event.data.options.accept)
272
+ allowed_file_types = event.data.options.accept;
273
+
274
+ // selectable_body
275
+ let is_selectable_body = false;
276
+ if(event.data.options && event.data.options.multiple && event.data.options.multiple === true)
277
+ is_selectable_body = true;
278
+
279
+ // Open dialog
280
+ UIWindow({
281
+ allowed_file_types: allowed_file_types,
282
+ path: '/' + window.user.username + '/Desktop',
283
+ // this is the uuid of the window to which this dialog will return
284
+ parent_uuid: event.data.appInstanceID,
285
+ show_maximize_button: false,
286
+ show_minimize_button: false,
287
+ title: 'Open',
288
+ is_dir: true,
289
+ is_openFileDialog: true,
290
+ selectable_body: is_selectable_body,
291
+ iframe_msg_uid: msg_id,
292
+ initiating_app_uuid: app_uuid,
293
+ center: true,
294
+ });
295
+ }
296
+ //--------------------------------------------------------
297
+ // showDirectoryPicker
298
+ //--------------------------------------------------------
299
+ else if(event.data.msg === 'showDirectoryPicker'){
300
+ // Auth
301
+ if(!is_auth() && !(await UIWindowSignup({referrer: app_name})))
302
+ return;
303
+
304
+ // Disable parent window
305
+ $el_parent_window.addClass('window-disabled')
306
+ $el_parent_disable_mask.show();
307
+ $el_parent_disable_mask.css('z-index', parseInt($el_parent_window.css('z-index')) + 1);
308
+ $(target_iframe).blur();
309
+
310
+ // allowed_file_types
311
+ let allowed_file_types = "";
312
+ if(event.data.options && event.data.options.accept)
313
+ allowed_file_types = event.data.options.accept;
314
+
315
+ // selectable_body
316
+ let is_selectable_body = false;
317
+ if(event.data.options && event.data.options.multiple && event.data.options.multiple === true)
318
+ is_selectable_body = true;
319
+
320
+ // open dialog
321
+ UIWindow({
322
+ path: '/' + window.user.username + '/Desktop',
323
+ // this is the uuid of the window to which this dialog will return
324
+ parent_uuid: event.data.appInstanceID,
325
+ show_maximize_button: false,
326
+ show_minimize_button: false,
327
+ title: 'Open',
328
+ is_dir: true,
329
+ is_directoryPicker: true,
330
+ selectable_body: is_selectable_body,
331
+ iframe_msg_uid: msg_id,
332
+ center: true,
333
+ initiating_app_uuid: app_uuid,
334
+ });
335
+ }
336
+
337
+ //--------------------------------------------------------
338
+ // setWindowTitle
339
+ //--------------------------------------------------------
340
+ else if(event.data.msg === 'setWindowTitle' && event.data.new_title !== undefined){
341
+ const el_window = $(`.window[data-element_uuid="${event.data.appInstanceID}"]`).get(0);
342
+ // set window title
343
+ $(el_window).find(`.window-head-title`).html(html_encode(event.data.new_title));
344
+ // send confirmation to requester window
345
+ target_iframe.contentWindow.postMessage({
346
+ original_msg_id: msg_id,
347
+ }, '*');
348
+ }
349
+ //--------------------------------------------------------
350
+ // watchItem
351
+ //--------------------------------------------------------
352
+ else if(event.data.msg === 'watchItem' && event.data.item_uid !== undefined){
353
+ if(!window.watchItems[event.data.item_uid])
354
+ window.watchItems[event.data.item_uid] = [];
355
+
356
+ window.watchItems[event.data.item_uid].push(event.data.appInstanceID);
357
+ }
358
+ //--------------------------------------------------------
359
+ // openItem
360
+ //--------------------------------------------------------
361
+ else if(event.data.msg === 'openItem'){
362
+ // check if readURL returns 200
363
+ $.ajax({
364
+ url: event.data.metadataURL + '&return_suggested_apps=true&return_path=true',
365
+ type: 'GET',
366
+ headers: {
367
+ "Authorization": "Bearer "+auth_token
368
+ },
369
+ success: async function(metadata){
370
+ $.ajax({
371
+ url: api_origin + "/open_item",
372
+ type: 'POST',
373
+ contentType: "application/json",
374
+ data: JSON.stringify({
375
+ uid: metadata.uid ?? undefined,
376
+ path: metadata.path ?? undefined,
377
+ }),
378
+ headers: {
379
+ "Authorization": "Bearer "+auth_token
380
+ },
381
+ statusCode: {
382
+ 401: function () {
383
+ logout();
384
+ },
385
+ },
386
+ success: function(open_item_meta){
387
+ setTimeout(function(){
388
+ launch_app({
389
+ name: metadata.name,
390
+ file_path: metadata.path,
391
+ app_obj: open_item_meta.suggested_apps[0],
392
+ window_title: metadata.name,
393
+ file_uid: metadata.uid,
394
+ file_signature: open_item_meta.signature,
395
+ });
396
+ // todo: this is done because sometimes other windows such as openFileDialog
397
+ // bring focus to their apps and steal the focus from the newly-opened app
398
+ }, 800);
399
+ },
400
+ });
401
+ }
402
+ })
403
+ }
404
+ //--------------------------------------------------------
405
+ // launchApp
406
+ //--------------------------------------------------------
407
+ else if(event.data.msg === 'launchApp'){
408
+ // launch app
409
+ launch_app({
410
+ name: event.data.app_name ?? app_name,
411
+ args: event.data.args ?? {},
412
+ });
413
+
414
+ // send confirmation to requester window
415
+ target_iframe.contentWindow.postMessage({
416
+ original_msg_id: msg_id,
417
+ }, '*');
418
+ }
419
+ //--------------------------------------------------------
420
+ // readAppDataFile
421
+ //--------------------------------------------------------
422
+ else if(event.data.msg === 'readAppDataFile' && event.data.path !== undefined){
423
+ // resolve path to absolute
424
+ event.data.path = path.resolve(event.data.path);
425
+
426
+ // join with appdata dir
427
+ const file_path = path.join(appdata_path, app_uuid, event.data.path);
428
+
429
+ puter.fs.sign(app_uuid, {
430
+ path: file_path,
431
+ action: 'write',
432
+ },
433
+ function(signature){
434
+ signature = signature.items;
435
+ signature.signatures = signature.signatures ?? [signature];
436
+ if(signature.signatures.length > 0 && signature.signatures[0].path){
437
+ signature.signatures[0].path = `~/` + signature.signatures[0].path.split('/').slice(2).join('/')
438
+ // send confirmation to requester window
439
+ target_iframe.contentWindow.postMessage({
440
+ msg: "readAppDataFileSucceeded",
441
+ original_msg_id: msg_id,
442
+ item: signature.signatures[0],
443
+ }, '*');
444
+ }else{
445
+ // send error to requester window
446
+ target_iframe.contentWindow.postMessage({
447
+ msg: "readAppDataFileFailed",
448
+ original_msg_id: msg_id,
449
+ }, '*');
450
+ }
451
+ }
452
+ )
453
+ }
454
+ //--------------------------------------------------------
455
+ // getAppData
456
+ //--------------------------------------------------------
457
+ // todo appdata should be provided from the /open_item api call
458
+ else if(event.data.msg === 'getAppData'){
459
+ if(appdata_signatures[app_uuid]){
460
+ target_iframe.contentWindow.postMessage({
461
+ msg: "getAppDataSucceeded",
462
+ original_msg_id: msg_id,
463
+ item: appdata_signatures[app_uuid],
464
+ }, '*');
465
+ }
466
+ // make app directory if it doesn't exist
467
+ puter.fs.mkdir({
468
+ path: path.join( appdata_path, app_uuid),
469
+ rename: false,
470
+ overwrite: false,
471
+ success: function(dir){
472
+ puter.fs.sign(app_uuid, {
473
+ uid: dir.uid,
474
+ action: 'write',
475
+ success: function(signature){
476
+ signature = signature.items;
477
+ appdata_signatures[app_uuid] = signature;
478
+ // send confirmation to requester window
479
+ target_iframe.contentWindow.postMessage({
480
+ msg: "getAppDataSucceeded",
481
+ original_msg_id: msg_id,
482
+ item: signature,
483
+ }, '*');
484
+ }
485
+ })
486
+ },
487
+ error: function(err){
488
+ if(err.existing_fsentry || err.code === 'path_exists'){
489
+ puter.fs.sign(app_uuid, {
490
+ uid: err.existing_fsentry.uid,
491
+ action: 'write',
492
+ success: function(signature){
493
+ signature = signature.items;
494
+ appdata_signatures[app_uuid] = signature;
495
+ // send confirmation to requester window
496
+ target_iframe.contentWindow.postMessage({
497
+ msg: "getAppDataSucceeded",
498
+ original_msg_id: msg_id,
499
+ item: signature,
500
+ }, '*');
501
+ }
502
+ })
503
+ }
504
+ }
505
+ });
506
+ }
507
+ //--------------------------------------------------------
508
+ // requestPermission
509
+ //--------------------------------------------------------
510
+ else if(event.data.msg === 'requestPermission'){
511
+ // auth
512
+ if(!is_auth() && !(await UIWindowSignup({referrer: app_name})))
513
+ return;
514
+
515
+ // options must be an object
516
+ if(event.data.options === undefined || typeof event.data.options !== 'object')
517
+ event.data.options = {};
518
+
519
+ // clear window_options for security reasons
520
+ event.data.options.window_options = {}
521
+
522
+ // Set app as parent window of font picker window
523
+ event.data.options.window_options.parent_uuid = event.data.appInstanceID;
524
+
525
+ // disable parent window
526
+ event.data.options.window_options.disable_parent_window = true;
527
+
528
+ let granted = await UIWindowRequestPermission({
529
+ origin: event.origin,
530
+ permission: event.data.options.permission,
531
+ window_options: event.data.options.window_options,
532
+ });
533
+
534
+ // send selected font to requester window
535
+ target_iframe.contentWindow.postMessage({
536
+ msg: "permissionGranted",
537
+ granted: granted,
538
+ original_msg_id: msg_id,
539
+ }, '*');
540
+ $(target_iframe).get(0).focus({preventScroll:true});
541
+ }
542
+ //--------------------------------------------------------
543
+ // showFontPicker
544
+ //--------------------------------------------------------
545
+ else if(event.data.msg === 'showFontPicker'){
546
+ // auth
547
+ if(!is_auth() && !(await UIWindowSignup({referrer: app_name})))
548
+ return;
549
+
550
+ // set options
551
+ event.data.options = event.data.options ?? {};
552
+
553
+ // clear window_options for security reasons
554
+ event.data.options.window_options = {}
555
+
556
+ // Set app as parent window of font picker window
557
+ event.data.options.window_options.parent_uuid = event.data.appInstanceID;
558
+
559
+ // Open font picker
560
+ let selected_font = await UIWindowFontPicker(event.data.options);
561
+
562
+ // send selected font to requester window
563
+ target_iframe.contentWindow.postMessage({
564
+ msg: "fontPicked",
565
+ original_msg_id: msg_id,
566
+ font: selected_font,
567
+ }, '*');
568
+ $(target_iframe).get(0).focus({preventScroll:true});
569
+ }
570
+ //--------------------------------------------------------
571
+ // showColorPicker
572
+ //--------------------------------------------------------
573
+ else if(event.data.msg === 'showColorPicker'){
574
+ // Auth
575
+ if(!is_auth() && !(await UIWindowSignup({referrer: app_name})))
576
+ return;
577
+
578
+ // set options
579
+ event.data.options = event.data.options ?? {};
580
+
581
+ // Clear window_options for security reasons
582
+ event.data.options.window_options = {}
583
+
584
+ // Set app as parent window of the font picker window
585
+ event.data.options.window_options.parent_uuid = event.data.appInstanceID;
586
+
587
+ // Open color picker
588
+ let selected_color = await UIWindowColorPicker(event.data.options);
589
+
590
+ // Send selected color to requester window
591
+ target_iframe.contentWindow.postMessage({
592
+ msg: "colorPicked",
593
+ original_msg_id: msg_id,
594
+ color: selected_color ? selected_color.color : undefined,
595
+ }, '*');
596
+ $(target_iframe).get(0).focus({preventScroll:true});
597
+ }
598
+ //--------------------------------------------------------
599
+ // setWallpaper
600
+ //--------------------------------------------------------
601
+ else if(event.data.msg === 'setWallpaper'){
602
+ // Auth
603
+ if(!is_auth() && !(await UIWindowSignup({referrer: app_name})))
604
+ return;
605
+
606
+ // No options?
607
+ if(!event.data.options)
608
+ event.data.options = {};
609
+
610
+ // /set-desktop-bg
611
+ try{
612
+ await $.ajax({
613
+ url: api_origin + "/set-desktop-bg",
614
+ type: 'POST',
615
+ data: JSON.stringify({
616
+ url: event.data.readURL,
617
+ fit: event.data.options.fit ?? 'cover',
618
+ color: event.data.options.color,
619
+ }),
620
+ async: true,
621
+ contentType: "application/json",
622
+ headers: {
623
+ "Authorization": "Bearer "+auth_token
624
+ },
625
+ statusCode: {
626
+ 401: function () {
627
+ logout();
628
+ },
629
+ },
630
+ });
631
+
632
+ // Set wallpaper
633
+ window.set_desktop_background({
634
+ url: event.data.readURL,
635
+ fit: event.data.options.fit ?? 'cover',
636
+ color: event.data.options.color,
637
+ })
638
+
639
+ // Send success to app
640
+ target_iframe.contentWindow.postMessage({
641
+ msg: "wallpaperSet",
642
+ original_msg_id: msg_id,
643
+ }, '*');
644
+ $(target_iframe).get(0).focus({preventScroll:true});
645
+ }catch(err){
646
+ console.error(err);
647
+ }
648
+ }
649
+
650
+ //--------------------------------------------------------
651
+ // showSaveFilePicker
652
+ //--------------------------------------------------------
653
+ else if(event.data.msg === 'showSaveFilePicker'){
654
+ //auth
655
+ if(!is_auth() && !(await UIWindowSignup({referrer: app_name})))
656
+ return;
657
+
658
+ //disable parent window
659
+ $el_parent_window.addClass('window-disabled')
660
+ $el_parent_disable_mask.show();
661
+ $el_parent_disable_mask.css('z-index', parseInt($el_parent_window.css('z-index')) + 1);
662
+ $(target_iframe).blur();
663
+
664
+ await UIWindow({
665
+ path: '/' + window.user.username + '/Desktop',
666
+ // this is the uuid of the window to which this dialog will return
667
+ parent_uuid: event.data.appInstanceID,
668
+ show_maximize_button: false,
669
+ show_minimize_button: false,
670
+ title: 'Save As…',
671
+ is_dir: true,
672
+ is_saveFileDialog: true,
673
+ saveFileDialog_default_filename: event.data.suggestedName ?? '',
674
+ selectable_body: false,
675
+ iframe_msg_uid: msg_id,
676
+ center: true,
677
+ initiating_app_uuid: app_uuid,
678
+ onSaveFileDialogSave: async function(target_path, el_filedialog_window){
679
+ $(el_filedialog_window).find('.window-disable-mask, .busy-indicator').show();
680
+ let busy_init_ts = Date.now();
681
+
682
+ // -------------------------------------
683
+ // URL
684
+ // -------------------------------------
685
+ if(event.data.url){
686
+ // download progress tracker
687
+ let dl_op_id = operation_id++;
688
+
689
+ // upload progress tracker defaults
690
+ window.progress_tracker[dl_op_id] = [];
691
+ window.progress_tracker[dl_op_id][0] = {};
692
+ window.progress_tracker[dl_op_id][0].total = 0;
693
+ window.progress_tracker[dl_op_id][0].ajax_uploaded = 0;
694
+ window.progress_tracker[dl_op_id][0].cloud_uploaded = 0;
695
+
696
+ let item_with_same_name_already_exists = true;
697
+ while(item_with_same_name_already_exists){
698
+ await download({
699
+ url: event.data.url,
700
+ name: path.basename(target_path),
701
+ dest_path: path.dirname(target_path),
702
+ auth_token: auth_token,
703
+ api_origin: api_origin,
704
+ dedupe_name: false,
705
+ overwrite: false,
706
+ operation_id: dl_op_id,
707
+ item_upload_id: 0,
708
+ success: function(res){
709
+ },
710
+ error: function(err){
711
+ UIAlert(err && err.message ? err.message : "Download failed.");
712
+ }
713
+ });
714
+ item_with_same_name_already_exists = false;
715
+ }
716
+ }
717
+ // -------------------------------------
718
+ // File
719
+ // -------------------------------------
720
+ else{
721
+ let overwrite = false;
722
+ let file_to_upload = new File([event.data.content], path.basename(target_path));
723
+ let item_with_same_name_already_exists = true;
724
+ while(item_with_same_name_already_exists){
725
+ // overwrite?
726
+ if(overwrite)
727
+ item_with_same_name_already_exists = false;
728
+ // upload
729
+ try{
730
+ const res = await puter.fs.write(
731
+ target_path,
732
+ file_to_upload,
733
+ {
734
+ dedupeName: false,
735
+ overwrite: overwrite
736
+ }
737
+ );
738
+
739
+ let file_signature = await puter.fs.sign(app_uuid, {uid: res.uid, action: 'write'});
740
+ file_signature = file_signature.items;
741
+
742
+ item_with_same_name_already_exists = false;
743
+ target_iframe.contentWindow.postMessage({
744
+ msg: "fileSaved",
745
+ original_msg_id: msg_id,
746
+ filename: res.name,
747
+ saved_file: {
748
+ name: file_signature.fsentry_name,
749
+ readURL: file_signature.read_url,
750
+ writeURL: file_signature.write_url,
751
+ metadataURL: file_signature.metadata_url,
752
+ type: file_signature.type,
753
+ uid: file_signature.uid,
754
+ path: `~/` + res.path.split('/').slice(2).join('/'),
755
+ },
756
+ }, '*');
757
+
758
+ $(target_iframe).get(0).focus({preventScroll:true});
759
+ // Update matching items on open windows
760
+ // todo don't blanket-update, mostly files with thumbnails really need to be updated
761
+ // first remove overwritten items
762
+ $(`.item[data-uid="${res.uid}"]`).removeItems();
763
+ // now add new items
764
+ UIItem({
765
+ appendTo: $(`.item-container[data-path="${html_encode(path.dirname(target_path))}" i]`),
766
+ immutable: res.immutable,
767
+ associated_app_name: res.associated_app?.name,
768
+ path: target_path,
769
+ icon: await item_icon(res),
770
+ name: path.basename(target_path),
771
+ uid: res.uid,
772
+ size: res.size,
773
+ modified: res.modified,
774
+ type: res.type,
775
+ is_dir: false,
776
+ is_shared: res.is_shared,
777
+ suggested_apps: res.suggested_apps,
778
+ });
779
+ // sort each window
780
+ $(`.item-container[data-path="${html_encode(path.dirname(target_path))}" i]`).each(function(){
781
+ sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order'))
782
+ });
783
+ $(el_filedialog_window).close();
784
+ show_save_account_notice_if_needed();
785
+ }
786
+ catch(err){
787
+ // item with same name exists
788
+ if(err.code === 'item_with_same_name_exists'){
789
+ const alert_resp = await UIAlert({
790
+ message: `<strong>${html_encode(err.entry_name)}</strong> already exists.`,
791
+ buttons:[
792
+ {
793
+ label: 'Replace',
794
+ value: 'replace',
795
+ type: 'primary',
796
+ },
797
+ {
798
+ label: 'Cancel',
799
+ value: 'cancel',
800
+ },
801
+ ],
802
+ parent_uuid: $(el_filedialog_window).attr('data-element_uuid'),
803
+ })
804
+ if(alert_resp === 'replace'){
805
+ overwrite = true;
806
+ }else if(alert_resp === 'cancel'){
807
+ // enable parent window
808
+ $(el_filedialog_window).find('.window-disable-mask, .busy-indicator').hide();
809
+ return;
810
+ }
811
+ }
812
+ else{
813
+ // show error
814
+ await UIAlert({
815
+ message: err.message ?? "Upload failed.",
816
+ parent_uuid: $(el_filedialog_window).attr('data-element_uuid'),
817
+ });
818
+ // enable parent window
819
+ $(el_filedialog_window).find('.window-disable-mask, .busy-indicator').hide();
820
+ return;
821
+ }
822
+ }
823
+ }
824
+ }
825
+
826
+ // done
827
+ let busy_duration = (Date.now() - busy_init_ts);
828
+ if( busy_duration >= busy_indicator_hide_delay){
829
+ $(el_filedialog_window).close();
830
+ }else{
831
+ setTimeout(() => {
832
+ // close this dialog
833
+ $(el_filedialog_window).close();
834
+ }, Math.abs(busy_indicator_hide_delay - busy_duration));
835
+ }
836
+ }
837
+ });
838
+ }
839
+ //--------------------------------------------------------
840
+ // saveToPictures/Desktop/Documents/Videos/Audio/AppData
841
+ //--------------------------------------------------------
842
+ else if((event.data.msg === 'saveToPictures' || event.data.msg === 'saveToDesktop' || event.data.msg === 'saveToAppData' ||
843
+ event.data.msg === 'saveToDocuments' || event.data.msg === 'saveToVideos' || event.data.msg === 'saveToAudio')){
844
+ let target_path;
845
+ let create_missing_ancestors = false;
846
+
847
+ if(event.data.msg === 'saveToPictures')
848
+ target_path = path.join(pictures_path, event.data.filename);
849
+ else if(event.data.msg === 'saveToDesktop')
850
+ target_path = path.join(desktop_path, event.data.filename);
851
+ else if(event.data.msg === 'saveToDocuments')
852
+ target_path = path.join(documents_path, event.data.filename);
853
+ else if(event.data.msg === 'saveToVideos')
854
+ target_path = path.join(videos_path, event.data.filename);
855
+ else if(event.data.msg === 'saveToAudio')
856
+ target_path = path.join(audio_path, event.data.filename);
857
+ else if(event.data.msg === 'saveToAppData'){
858
+ target_path = path.join(appdata_path, app_uuid, event.data.filename);
859
+ create_missing_ancestors = true;
860
+ }
861
+ //auth
862
+ if(!is_auth() && !(await UIWindowSignup({referrer: app_name})))
863
+ return;
864
+
865
+ let item_with_same_name_already_exists = true;
866
+ let overwrite = false;
867
+
868
+ // -------------------------------------
869
+ // URL
870
+ // -------------------------------------
871
+ if(event.data.url){
872
+ let overwrite = false;
873
+ // download progress tracker
874
+ let dl_op_id = operation_id++;
875
+
876
+ // upload progress tracker defaults
877
+ window.progress_tracker[dl_op_id] = [];
878
+ window.progress_tracker[dl_op_id][0] = {};
879
+ window.progress_tracker[dl_op_id][0].total = 0;
880
+ window.progress_tracker[dl_op_id][0].ajax_uploaded = 0;
881
+ window.progress_tracker[dl_op_id][0].cloud_uploaded = 0;
882
+
883
+ let item_with_same_name_already_exists = true;
884
+ while(item_with_same_name_already_exists){
885
+ const res = await download({
886
+ url: event.data.url,
887
+ name: path.basename(target_path),
888
+ dest_path: path.dirname(target_path),
889
+ auth_token: auth_token,
890
+ api_origin: api_origin,
891
+ dedupe_name: true,
892
+ overwrite: false,
893
+ operation_id: dl_op_id,
894
+ item_upload_id: 0,
895
+ success: function(res){
896
+ },
897
+ error: function(err){
898
+ UIAlert(err && err.message ? err.message : "Download failed.");
899
+ }
900
+ });
901
+ item_with_same_name_already_exists = false;
902
+ }
903
+ }
904
+ // -------------------------------------
905
+ // File
906
+ // -------------------------------------
907
+ else{
908
+ let file_to_upload = new File([event.data.content], path.basename(target_path));
909
+
910
+ while(item_with_same_name_already_exists){
911
+ if(overwrite)
912
+ item_with_same_name_already_exists = false;
913
+ try{
914
+ const res = await puter.fs.write(target_path, file_to_upload, {
915
+ dedupeName: true,
916
+ overwrite: false,
917
+ createMissingAncestors: create_missing_ancestors,
918
+ });
919
+ item_with_same_name_already_exists = false;
920
+ let file_signature = await puter.fs.sign(app_uuid, {uid: res.uid, action: 'write'});
921
+ file_signature = file_signature.items;
922
+
923
+ target_iframe.contentWindow.postMessage({
924
+ msg: "fileSaved",
925
+ original_msg_id: msg_id,
926
+ filename: res.name,
927
+ saved_file: {
928
+ name: file_signature.fsentry_name,
929
+ readURL: file_signature.read_url,
930
+ writeURL: file_signature.write_url,
931
+ metadataURL: file_signature.metadata_url,
932
+ uid: file_signature.uid,
933
+ path: `~/` + res.path.split('/').slice(2).join('/'),
934
+ },
935
+ }, '*');
936
+ $(target_iframe).get(0).focus({preventScroll:true});
937
+ }
938
+ catch(err){
939
+ if(err.code === 'item_with_same_name_exists'){
940
+ const alert_resp = await UIAlert({
941
+ message: `<strong>${html_encode(err.entry_name)}</strong> already exists.`,
942
+ buttons:[
943
+ {
944
+ label: 'Replace',
945
+ type: 'primary',
946
+ },
947
+ {
948
+ label: 'Cancel'
949
+ },
950
+ ],
951
+ parent_uuid: event.data.appInstanceID,
952
+ })
953
+ if(alert_resp === 'Replace'){
954
+ overwrite = true;
955
+ }else if(alert_resp === 'Cancel'){
956
+ item_with_same_name_already_exists = false;
957
+ }
958
+ }else{
959
+ break;
960
+ }
961
+ }
962
+ }
963
+ }
964
+ }
965
+
966
+ //--------------------------------------------------------
967
+ // exit
968
+ //--------------------------------------------------------
969
+ else if(event.data.msg === 'exit'){
970
+ $(`.window[data-element_uuid="${event.data.appInstanceID}"]`).close({bypass_iframe_messaging: true});
971
+ }
972
+ });
src/UI/PuterDialog.js ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ async function PuterDialog(options) {
23
+ return new Promise(async (resolve) => {
24
+ let h = '';
25
+ h += `<div class="puter-auth-dialog-content">
26
+ <a href="https://puter.com" target="_blank" style="border:none; outline:none; display: block; width: 70px; height: 70px; margin: 0 auto; border-radius: 4px;"><img style="display: block; width: 70px; height: 70px; margin: 0 auto; border-radius: 4px;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAKCJJREFUeJztnQl0U3X2x5VNFFGBAqVUFlkEZAcFFdlUkEHcYEYcBQSVRREEUUQZt1EUBGEQBxUYFkFZZF+KQBfovqfN9rK2TZq9SbM3SeGc/23zFzHvJU1Km/te+3vnczzYNnnfd9+9v9/97bfccg9FIDRf8BUQCIjgKyAQEMFXQCAggq+AQEAEXwGBgAi+AgIBEXwFBAIi+AoIBETwFRAIiOArIBAQwVdAICCCr4BAQARfAYGACL4CAgERfAUEAiL4CggERPAVEAiI4CsgEBDBV0AgIIKvgEBABF8BgYAIvgICARF8BQQCIvgKCARE8BUQCIjgKyAQEMFXQCAggq+AQEAEXwGBgAi+AgIBEXwFBAIi+AoIBETwFRAIiOArIBAQwVdAICCCr4BAQARfAYGACL4CAgERfAUEAiL4CggERPAVEAiI4CvgLHf3EIx7irdoeeEXG4p27BYc+k1w4pTgxGn+wSPFP/0Pfpi7eHnW1Ocy7x1U0LKjuJE03NqB6tBLMHoib9acghUfFH69qein//F/OSQ4dkJw8ozw5Bn4B//XI8U79vA2/id/9b9y5i7MmjQ9u/eQgjadhegGZAX4CrhGt/7C+UuKfz4oKearNVqzpdLhdHqqqrxer8+Px+Nzuz02u8tosilL9Nm5sgO/5i1blT5iXFarGFGDaOjSV/DcS7wvNvBPnZPyBWqVymQy2Ww2l8tVowQE1CqpvkGP1+Goqqx06vUWhVKfX6g8fbZow+bsl1/LGPhgbqtODaOKk+Ar4A5DHhF+94OEkujAk8Cxrl69eq2uC/6kuroa/FKnrywoVO7ck/Xs7NQ7uvHrJyDmPuHchcUHDknElBaiy+Wq8vmqw5FBk3QVogICRl1ekV+gOHAwd8k7af1H5TZeTcVe8BVwgdj+os3fy9TlZihKI3W46xdEAvicSKzevS9z/FNpLSLxtvtHCzZvo0SU1hJ27IWvCgJJozFn58i2bU+fMC29dQNVU9wAXwG7gSR7zkKxUGyArKaBHO4qVCC5efJ/f50SPzC/TgGjJgh27ZWp1Kabib1wLqhMIJ0rKi7dtSdz2szU27o0j0YCvgIW0z5evGOvEvwVvLZhvQ1K8XKN+diJ3CdmXIYYY7z7A2OFe3+Ra3WWKo+vMT3/LxdUCFarSyhS7d2fOeXZ1KbfPMBXwFZ6DRWnXNFAm7KRXA18GjKi1HTxa0sSA7IOCLwvNkhVajNk6o1099AXBDyEQQGv5JvNl/uNyEF/F40IvoKo0LKTuG1XYbs4wZ3da7ijm6B1Z1GwohcYNIYSio1eX3WdjgIRYrU69XqrVFZRLDAWFJlElFmntzscVeEk65BZ8YpK13x8sV1csf/W0/8uysnXQl4eZqkPfwbZS5Wnpp/HbHGoyy0FhYbEFP25C7qzv+suJBqyck3KUis4tMvtAUnVYdcm8LV6Q+WFS0Vz30i+PbaeDXe2g6+goQG3jrlP8MgU3vwlhZ9/XdNDf+K06FKSJD1TlpOryM1X5OTK09IlFxNFR08U/7ir4NMvc15dnDluSnaXvjx/wzRuAMUrNoVIe+BX4G0lpab/7Sv5xzzp8Meojr2pNl0gzGruDv+9I47qPVQ65XnFp1+V84VWjydUNQLFvECoen9t8l3xwk/WyQxGG+QhdXtndbXTWaXXV6ZmaNZvLpm9QDb2CUnPIdRd94IScYuOlD+84b+tYqjbY6mu/aghD0un/12xaq3q1Dmj3uDweMJqTLtcHr6w7Mv1KbH9C9BfbsODr6CBaBcnenxG0afr+GcSpCJxOWTYFosDXASKRij2oDADr72BavgJ/BzeLpTfOr1FKtNmZkkOHMr/ahM/I8vgC1L2w2chb8krUC94i+rSL6xuHPC/h59UHDhkdLmChgH4okKp5xVpQXBod6yJPWdVaZlp176SF16R3PuAuGXH+pirfTw1bqr88/XlUrmtzkQLrAGt8J8PZIwYl4H+ohsYfAU3R+vO4iee4W/7UVzIU0F97axX1/i1PzrsISEBF/QFKYAh25HKdG+uEN11b336ywc/LE+4aA4WWqA5dHICH4QMJzVDNXcxFdu/wTrsb+tCTXpa8dtJiE9PiPuDvIoK+7nzhVOfg1Z7ExouwFdQX2L7C5e9L7ySVmYwWsE1G7WLEC673XX+ouyBsYKb0dyqE7Vkpdpuj6xHFSITnO/0OeWU50VtuzaW8z0wVrbtJ73DGUobGOFKqnjO64ktm0zvEL6CyLkrXrTqI0ok1tnt7gbvoGS8IO05dlLYuW/DdI1Peb7EUllHquO/IKihRirmq2fPF0BmHwXbDn9Mnp5VGayaulbbJMjKls55/VKLplEP4CuIhFYx4gVviQp4GrvD3dhF/vXLanMdPirq2u+myv4AHpqs0Orcoe/r9VZrNOZvt4lj+0e1uG0dQy16R2W2uIMZGGIgPZN6cV5iU8iF8BWEzWPTRMmXy6DNWo9S/2rt5W8B/3GF9UF42ecviLo0qPf7+fs8VQgRUPDn5pdOnsEP0VfbqPQYLL2UYglmapB3+Ypo+swkdK+4WfAVhAEkvus2yvR6a4iqOcDdvV6fw1FVYbary82ZObrDx8v/u0O1fkvZuo2qr79Vbf1B/csRbVqmUauz2uwuj8fH+Ka9vuqi4tJREwob/InuupfKzqtgDAD4mcXiOPSbOG4A8mSENp2p9Zt1wQZDahpFFwrHTk5Dd4+bAl9BXdw3TJx8Re1y1Z00gxO73R5oE19JU69aK588Q9JriLhNl1Bf3qIjFTdAMn6afNVadQHPAuX9jZGg1VreXJHb4E8EhfqR4+UQoozeb6qwbfmef2d3trQyF69QezzMMWC2OI4czeozPBtdZP3BVxCSabMoscQUuuAHp6nyeMHvLyapXlsq7TdS3KpTfe4Fn+o/Srp8taqIX9OtBLX8qbNFHXo2/AjokpVKxql1UCEYDNYNm4vaxbHF+/0seEvlcDIMYoDlyzXmjVuSrg9jcw98BcFZuFymN9hCZPzgMU5XlUxh+GKDdPBYUf38nk6rGGikyj/6XPbIk3XP1oyUB8ZItDo7ozPpDdYvNvBua7SOzpth1txSJ9NAHpRNxYKyVxdd5GqDGF8BE5AkfPCJorLSGcz3wV1cbo9coV/zKeQw7CovQ9CyE3Uh0cAY0mazY+t23u2x7H2W199We7wMVTFUlecv8IaM5eYgMb4CGuD9n6xT2uxBewmhWQY17zdbqJ5D2OsujCx6R+lmml7qcLiPneR36NXwfU0Ny1ebdYzRq9NZvt2aWO+VbpjgK6Cx5jOFPbj3Q3mTX1D21Ex+i3rNgUGkXRwlkVkZ4tnrKyhUDn2k4fuaGpzWMdTldIZHgEQoN1/x5LOX0RVGDL6CvzL/LbnNxuz9UPaYKmx79uP3D9aPT9aVeWkpBDRjylSmeYsavq+pkeg1VGYwMvTIWSode/aldurNgTD+C/gKbmDyM1KjycHo/VDGlJQalq7iN95kmEYlfpDEYGR4NPCbrf/NbxXDpYd65qVSer8cFE9iSj33jUvo8iIDX8EfxA+iZHIL49iox+MTU+XPzC7CGha9eb77SUPPnj1eX0aWpOfgInR5kXLkeAX9NUFL5shvGZ37cGrZAL6CWsCzz13QMzawoLAB75/6PA9dZL25615Kb2Ao/rVay8K3OTmKFD9IZncEtuYhnRMIVc/N5tT8CHwFtbz7UYnbzdzNLJPpZr3Ctczyr7z9PkPOANVaUrKgcx+uDiH9uNtIf18Wi+OHHcltu7K9O+tP8BXUTMGVmkxOBu+vvqosMcxbVMDdzMdPRraF/nQareWNpVno2uoNYyUArfzUNPGQsZno8sIFXUHLTlRiipE+LQx+Uq4xv/1eQUQbSLGQYY/KXLSJD16vDxwlbgCH8zpg/2GGlkCZyrR05UV0beGCrmDuYuaxocpK5/c/FrbtyrGhLjrrt5TTw7vCbP/4C24Ond7AyPEKeseu3eE+8Gvqnd05ktrh3r51Z6qIX0n3fsiP0zI42T1CJzc/8AFrGosi1UOTONP3H4LCosB5TdDaScsQDx7DkSwI9/YL3iqhb0kA/gGp/8xXmoJ/dLtf4qStsnW7PafO5LWL405LMTifrNPS6ze5Qv/SfI70BSHeG7L/Ah5D69Bmc+3cnX9bF84nP8CrS0rpe0xodZbX3uJIAVkXXftL6U1hs8W+5TuOLBpGvPcLc5T04h8qUF5RyfBxDT8PGYWd+/QB5WN19dVCnnLw2Dx0bQ1FRraNVsV5j5/M4ca0CMR7/55ooo/7mips//p3Dtd7fq6TnRvYAICYP5tQcNe9HGkjhsGmbfrAUqz6akamZNBDXOjkxbrx8HFSmz1wThUU/zm58r4juFByhEGrTlSFOXBin9Xm/HZrKleXjzAxa25ZwBA+lGuUpHz6TC5MDsW68dYfNPTGk8Xi+HpjJteHva4z9gm5h7bwV6O1LFjM8YXkf6XXUBl9fbNOZ1n1IRcmxqHcFVyckgYmjk2pc9DPgqWBRSNcEqlm4t+aSAvYT5sulNEUWJlbKp2btiRxoKJDueuoCTL6vvtut+fYibzbYzk515+Rf28IrOUgHvIKFIMeajpB7kcgCpzq53C4d++90pr9Z1Gi3PXDz9X0otFgsC5b1RRyg/bxwocm895cKSwsZhgCE1PlS97JHj0hp0PPptMOTk4NXCYGxdmR3zI5sFsEyl3P/B44hwQ8gy8oGzmew0XjvYMEb64s/uUQVcxXqcsrrFaXj2l2N3iGVmuBMLiSJtr+U/a8hWk9B3O+z/fYaXPAY3o83lNn8jr2Yv1kJ5S7qjWBcz89Hl/C74X39GB9gcHEhL/x9+yXKpUGq80V9vGpV32+arvDrVKb0jKoTf9Jn/BUOncP5Dpw2BTwgGCHS0nFXfqSAKDRc4iU3gCwWms6B/HNESETpwtPnVNC8hbmaSuMl9dbs/F/Ia9k2/a0MZPSudgJtvtA4NqA2rXOxh27syY/ncrqvdSjf8tnZivpq0M0GvPchVwKgDu7i7/7QQ6uX+c5YmFeYJMKsz0jS/LBx0kcyBz+yv9oAXDtjwNh8wuVX2+83GswW5Pb6N/yg08ZpgdTkvLHpnJh4LCWkePFaZmahjo5+MbL4/UpSwy79qQPeZhLXaWMAeC/ILC1Osup0wUzX05uxcIjuKN/yx17DPTpMdm5sv4j2VpI/JXX35aqyy1h7lNdj6tm9xeT7WxCwdRngx4hzDZCBMC12oFhh8NdUKj88OOku+9l2RT36N/yVEJgj4G/wdS1LwdmQHz4mcJS6Qyd7deeW+pzumoOLS3XWoQiU2GRsYhvksgsBoPd4fQfnxryG65ds9ldKVeEs15O4sS0qF0/G+oMbHhquUK3ZVtKbD829XpF/5YpqYG949AmPnEqh/1riD74VBliy7prtYd52WyuYr7uy42KqS9I+gyn2nev2WoXCnKgdQy0HKg+I6TTZinWb9FIZPbQ1QiESnoG9c/5l9gfA49Mkf36m8FiqePEKrBPmcq0/afLcQNYMxk2+rfMyQ+cBOFyeQ4eTm/D7lHDWXPllZWuYK8WXNlUYUu4UPLcP8X39AzLXyEYnnu5NCc/1IFcTmdVUopg0t+4MKus9lCZV5eU5eRZ6DOgboiBqyq1aev3KWyZLB39WxYWBy6ig9e878BlNpdz4/8mLdfYGPMW+KHd7srIKn1qphAK+0i/uWUn6vlXShUljmC9qFar8+TpPA7tvdyiAzVhujIzJ2hgQz2gUOg/+/ISK3ZPif4t+cLAAHA4qvbsS8G3RRA69KIEIjOjg9Z0cWjNGzYL7+l5U/0bd/eQbN/FfDo33NZosu3dnxY/MAfdFOEDgT1vSZnRxJwxQnugkFcy942L+K386N+ySEAPADcEAL4tgrBzr4bRNeEtSqXaF18tbtmpAeouePxl75dXVTEkD9BGupImHjWeS+MkfvqOlBUWMdectacKFA4eg12zRf+W+TxaAEAKtP9yS1amQA9NljHuVg0hIZFqn3mxgRPZ5R+UB2w0At5fyCsbP41jQ2PX6dBLkpUb2OrzXzq95dutl9rGoiZC0b9lZk7gzEFoBP9yKO22LizICGmc/d1AT36gJVdaZnx1ScNvWQdf+PG6PyscKCavpMqHPcr2/rHQdO0v5dPmS/sLkZw8+eMzULPf6N/yQhJDN+jxkzmsGyKp7d0DF6S/OaPJ+tm6xtrT/NaaraRr2gNmi2P/QXH3gWwsFyLl/tFyxoPBLRbHrj1XOvTE6xGK/i0P03bWhmT6wqWi7uzpG/6Dg0f19OIf6qszCfyOjXmcUasYat8v6q82FbPtuMib4cnnGfaAgrqUV1Qy7QW8SiD6t9z838BNBMAKWdnSB8away5Q5z6SiorAjn+QSkk0E6c3eqzeHituzalTM8Jh577AWdPXak4HtH//Q2IbrAQ4+rd86111QLEK/ycSqyc/za5ejqXvldE7f2x2947d2dw60IU9dB8otdnpG0r7kpL5/UYinZMQ/VuOe0pB3yxNXV6xaFki+hu6kcycwF3rIG4lUs34adyYtMdO9v7CUAnI5LrZryJtpRj9W97ZXUI/C6Oy0vnfH5NadmRLytt7mBRy/QCR0Fg/e67gzu5NoVWKxcgJCnq9Ck3h/2xDmvKEYgW+MLBTrMa3Egri7mdLO/i9f5XS97oxGq0r16Sja+M6QjHD2z95OhfncDEUExw4EtgR5O8NeGwqW5oBsf0lS1aWZWSbnS6Pf4aj/wCsBydyaT4CO9m5L3DxAFg4IwtpK0UUEyxYqqJ3L2p1lg8/YdfJIi06Uv1HSd98tywt02w2O86cy78rnoOHobOM194OfPvwf0KxevJ0jOIPxQQxfaQuWjMAcu5jJ7LZecgmREKPwZJR49mSoXGaUUzNgJJSw4tzMUYDsKyQkhY4IQLqwWJ+GeaYCCEqdOwtoY+IaTTmxcuSEfRgWWHFh8wnZ33/QyI7JwURGorWMRT9VDi9vnLF6uYUADF9JHpj4DQbr7c6PYN6cCLpaWni0PvBjUbr6rXNKQCAn/YwbCVgMFg3b026oxtpazZZbuvKEADw3lc2qxoA6DdK7nIFGgKaR/kFiumzMGxBiAqd+0joWwNqdZZFy5pTI9jP0VOBW6Rcq10Fe+Bgepe+bOwOItw8D06S0wcZVWrTPxdcQdCDa4uxjysYj0mVynVL373IjWMGCREyb3EpffcUqUz7+NMYyyNxbXFrzT5ZDCelQo6YnCJ4+HG2DAwTGpCf9gSenAlFXkGhcsjDGKPs6OYYNEbuoB00e612mvj+X9JZuEqGcJPw+IFDQD6fLzGZH9sPY10YujmATd8xLLyCn6hUpo1bku/uwbqlkoR6M3qijN4F5HBU7d6X3oxmgwZwZ3eJVB54ZEZtwVAtk+s+X8eOHZQIDcGun3UM08C05tfeRBr8QbeIn7FPKF1uhi1xvF4fX6hasfoSyzdOJIRD574So4lhlWkBTzl4LFKui26U63y8Tsu4tWqVx8crLoUYIFMkuM72XRr6K3a5PEeOZt/WBamAQzfKdVp0pE4nmBl3EfN4fHxB2drPEtvHc3uHnObMw1NkVqYtxlRq00vz8fZDQLfLjXToKSkWMOyg5M+F5HLd9z+m9sdaPU24CboPpIRihv1Vq6q8Cb8Xx9yHV66hmyaA+x+UG4zMO6pC7ak3VJ44lTtpeioHjiAn/EHbWOpCkp6+BgDCoUxlemkBaomGbh06j05VMu4i5jeZ1ebMzJK8uyYl5j6ubpfZrGjblfr5oJo+3n+tduPHo8cL28c3s71Bw2H0JIVGG/QsFrBmaZnx6PH8l+ZfbhdH5o2yl469xUdPqukd/7X1ebVIrB4/DXugE91GwRjyiLykLOiJLJBNOpxVlFRz4GDOzJdT23cnYcA6Jk4X5eTpGMt+qMn1+srVH+fin4qCbqYQ9B4mE1GOEOfJQRjYHW6JVHv8ZMGSd1J7DcYuTgi1dLtftH1nzSHK9B3Q/Be8tcNHee3jWTC2g6+gDlNKTyVUhD5MDsLA5fKoyyvSMqj/fJ/14rz03kPz8YuWZknfEYJP1lESqYE+4//65XJ7UtOl/UayY4YLvoK6aNGRWvlRudNZ96nUXm/NIY1lKlNevvzEKd5XG3NeX5r1+IzsQQ/lxfYrurO7oFUnMWvPoeEErWLEbWOFbTqLWtZasnWMCJqwfYcXTX2Bt/Zz/tkERZnKCE3bYOed+b0/I1M28EHWjOfgKwiPkRMUvGJr6FM4r1/wZ1Uer83uglq4pNQgpsoLeSU5ufLMLEl6JhWa8xd4b7x1OiJty1cL0jPq+NrQXEwsXrXmRJRvmpQi+OKrYxHddMZsYVaONCtbmpElycySgkmLikvlCh3Y2eGogoo69PnH8DfJl6X9R7KpwYavIGzadqVWfKg2VbhDW5l+wd9DmQRREQ56g3X12sg2at34nc7nC/f7GTGb7Rs2RfumVptr157IbvrG8pods2/8ktorrFdQaXUePcm+8z7wFURI76Gyfb8a6IuJG+oymWyr/xXZiuRvvw888SDSq7LS+c230b4ptER3743spkvfC9zaPpyr5ixNnWXTVn77eLZsfvwn+ArqxbBx8v2HDDZ7qHSzfhcJgBC8+1FkAQB/DIloembptFkClh6qgK/gJug5RLrms3KF0ubx+BoqEEgAhOCDT8vDtDNkRw6HW0xpV3wguslDlBsXfAU3TdtYavIMxX9+0CpLbO4qb5gN5WAXCYAQ/OtLTegAgN9CYVRRYU/LVC14i+rSl8Wu7wdfQcMBreThj8nefLfsYrLRVGF3OqvgZfgbbf62WjilV30CYBtGANz0TesRAJ+v11y3pL9robZ3odrr9YG1jSZbsUD72VfSEePFrTvj+0NY4CtoHG7vRvUfLX3iOfm8JSVrvyjb+oN6/yHN0ZPak+e0pxN0wNnzupRUCz2jrUcAvLFMfjrh/782NGfO65KuWDyewHG9egRAZDe9bHY6A6ck1CMA/vGqDMx46Jjm+GntiTPaX4+U79ynXr+lZOFyxZTnpb2HiVt1wn/1kYGvABX6TJV6BECk0Oe61iMAIkUoDlx1XY8AaILgK0CFPlExCgFQrkEIAL7QTgKAAXwFqJAAQH8FyOArQIUEAPorQAZfASokANBfATL4ClAhAYD+CpDBV4AKCQD0V4AMvgJUSACgvwJk8BWgQgIA/RUgg68AFRIA6K8AGXwFqJAAQH8FyOArQIUEAPorQAZfASokANBfATL4ClAhAYD+CpDBV4AKCQD0V4AMvgJUSACgvwJk8BWgQgIA/RUgg68AFRIA6K8AGXwFqJAAQH8FyOArQIUEAPorQAZfASokANBfATL4CvDo1FtC38W7+QSAy+U5dCQD7XxSloCvAIl7elIpqQb6LlrNJwB8vmqhSL38/UttmnMM4CvAALz/UrLW62U4vaf5BMA1/yHkRaXL32vGMYCvIOqE8H64tDrzO+9Html4pKAEQF6hlfF5m3sM4CuILvf0FCdcDOr9TmfV+QuiuPsb9/QelAAY84Si0sp8yo4/Bt5pnrkQvoIoAmX/xSQt47mFfu9PTJb0GtLo55egBAAw8WllsBgAm/CKm2U9gK8gWoTOfOx299nzVBS8/xa8ALilNgb0hqoQ9UCziwF8BVGhA3h/SijvP3VW1O3+KJ3egxgAwKiJChIDf4KvoPHp0EscwvsdDvfps+Koef8t2AFwS20MGIwkBmrBV9DIdKjN+0O0ei8mUr2GRvXUTvQAACY/U2K2BG8T80qWrWoeMYCvIHJi+wtmvsz7dF3Rjj2CI8cEx0/yD/zK27wtb/n7mRP/lnn3vX96c+jMx+EA75f0HhbtUzvZEADApBlKszmCeiB8s3MJfAVh06IDNelp/q69Ekqi9R8AU+XxgnMDVVU+8GajyUZR5WcTeKs+TH3godyOITMfyPtPnxPHDUA4tZMlAXBLGO2BlWuSbo8Vhm/2AaOyOXYUOb6C8Og/SnToqNJgsNaehxf0qCP4VVWVV6ezwMsTUcYQ3n/yjAiKNJRnYU8AAKMmhIoBuUKXma0K0+xaneVyqnDl6uSOvXjoDhMu+ArC4KmZEpncFKz/nvHynwvG+Csowy5cEscPRDuvnFUBADwyRVlZydweqK49YDx8s0PMKJX6nbtT+wzPQXebsMBXUBdzFkn1eltDnQcM3n8pKRqjXSFgWwAAE6YHjYFILwgYnd7y66HMoQ9noDtP3eArCMm8xTKz2dFQZwBD5nMmIUqjXSFgYQAAj04NOkYW6QWllclkO3os+4ExrI8BfAXBGTVRqtMzzGGs34Wb998IOwPglpDtgUgvKLOg5bBz95XO9xWgP1co8BUEoWUnKjXDFCzz8fmqHQ633mAViU28YpOyxOpwVoXIVn0+X2aWHKXPhw5rAwAY+6SSfoprgNmhsZuWqf/9kqGIb3E4gpodfi6VaZetutCigxj9uYKCryAIryxU0pdr+c0KSdG58yXT/0HF9he3iqFu7UC16Uz1GCx97W2VQsmcL3m9vuQUYb8RrGiZsTkA5i0uBS9nMPvVq2ZLrdn/TnWtMbv4RrPLa8zOYHeXy3PufGGf4dnozxUUfAVMtOhI5eRZmEqgq2Uq0zur+W27Mhcq9/SUHD5WwVgmlZQalq+6wIZeatYGQDCzgz1VatPKNaHMfuCwKZjZl7HD7MzgK2Di4Sly+nJ1KIRUKtMbbxfCewrx2TZdqINHK+gFktNZdeRYVgwLUlLWBgCj2cGSKnXFkhWFLTuGymSgKt5/iNVmZwZfARMbv9PQTQlV8IbNBa07151QtouTFBY76MVYfoHikSdT0Z+OtQEQzOzfbGkKZmcGXwETyamBFbGvujo3T95vRGGY3/DCK2X0Ghnq8YVLE9GfjrUBkBLE7H2bhNmZwVdAAzKc0jJngBEdzqrd+zJbhKyFbwTaZ6aKwJEds9n+1TeJt2J3SrAzAJq82ZnBV0CjfTxltQb2RhuM1mWrIqtGr2QELgN31GwFlXp7LBkIa45mZwZfAY2Y+yT0pphabXppfmRv4nSCOeBL4GuPHM26K75x17zXCT0ArFbX5u8uE7MjgK+Axt09JHZHYDVaXl4xf3FKRN9zMTkwo3W5PAcPZ7WLw5m53rIj9eRz/H2/lrndgbP6qqq8GVmylR+kPzAmGytVaKpmrwN8BTQgj9QbAstIU4Xt319H1pCSyGi7Ydrd23ekteokivITgev/Y54g4UKJf17xNaarZha3vjIjU/L1xrTREzKiHwZNz+xhga+AiQIew0aWR49ndeodbnfE0EdlboZ9P+1rPo52pnHfMNHxU6XQEGQcYQ24vF6fyWRLy6BWrUm6u0e0c4amZPZwwVfAxJ4DpgAjVldfFQpVs19NujWMj9/agTp8XE/v0lYq9dNnRXV+4uQZFCUNui4n2OXxeOUK3X9/vNzjgVxi9sYFXwETM+eW0ruTnc6qhN8LRz6WXufH335PCUVXwMehAE7PpHoNid6Q5PMvSzQaa0QLSm70PI3WvO9A+v2jsjhv9oyomj0y8BUwcUc3iU4fmI9eq0lJ7dCcGjA61OSqWfNkFebA/my4bHbXDzszWkYrEx09UarV2m5mJQMUpdAq2LH7cuc+UfKe27tRjGavqLAf+i174IOhzD57vswczOw7omf2iMFXEISN3+np3gM+YTRZzyUUvjjvyh3dAuc2d+0nWr9FDm+L8YMSqWby01GaDdoujsrnMUyMuVEPFI011K7dDPZn8EuFUv/hJxdaxURph5IgZr9mNNnqMDvTuqUom70+4CsIQqfeEjWtv9z/MqBSlsq0584Xfb0pZ+m7uYuX53/wcdGeAxKZ3OByM6/rg3Jo196827pGyY3WbVIFy/v9a/bPnFev+bRkzkLl/DdLv9xYXlBU6Qny9x6PLy1DPG7KFWL2RgFfQXDmLFIF6zmBogU8w253WywOAP4BDhSsKAVfzC9QDHk4SolE3ACJ3sCQDEBxDtXXrn2S+0cH5gPQfHx0qiK/0Mr4CCaTbdv2pKiNpHLU7PUEX0Fwbr2H2vuL8SaXw4PblZQZ5rwRve6Uz9er6U1JeApo1L63tijEtMp2cZLTCWb644I7ZmRKHpyQFjWz7/q5IcxeYvjna3noXlQH+ApCAq3ho6eYF7iEc/mqr6rLTSvXFLaKidK4EpTl+bxKupIKs/2bLYW3damjLXh3D0k+rTMeLnV5xYrVF4nZGx58BXXRpgu1fZch0q50uKB2lit0C97khV7J0bD0Gip1OgMTYsj7L1wSdOod1orkgWPkDmfgWJLD4f75l9Q7ozibgFtmrz/4CsIAitU5C8v0BleY9TIUXVarKyVV+egUfpQX4704v6S6OjCBLteY57wRQXf+0ZOB88m83urEZH7vIVHtTuGQ2esPvoKwiRsg/XKjxmB0hdz9odpqdebkqV9bKrrrXoS+50+/Kg9wF/+SqIEPRpANL1iqCvgS+N+CQuWYSXWPRjVPs9cffAUR0rmP5PVlZWd/NxiNNpvd7XRWATaby1RhkysM//tZ+exL4ju7o1W+3/0Y2I8OWcTFxOLOfcKdTnNLzV6FioB+GPhOiUTz1PNR6gzlnNnrD76C+nJ7LNVriGT4OMmDkyRDHqHiB4khbUVX9dMeQ0Dp6PH4zp7L79Azgv1iR4yX0zsiFUr9c7PRAoDlZq8/+AqaFpu26QIc118DdB+QH/6XTHleyVgDPDEjSj2hzQh8BU2LZavVgW2A/0/fI5gO+eWmwN0ZIP+GLxkylsVzCjgKvoKmxaSnlYy9QKvXhtuLf2sHqoA2kgAVQlIyv1t/do+qchF8BU2L9vESC22fcbfbc/FS8fBHw6oE3lyprKKtGqvdnSGjdQynOlg4Ab6CJsfp8wy7CxpNtj370uMH1tEZ+vgzUr0hcG+p2jqkYu5Ctq4p4TT4Cpocz71cSs+CIImHRAhK8cFjmEfEIPOZNVeiUlvpg07emrlALF5TwmnwFTQ5WnaicgsY5vNADJhMtqQU4btr0oY9mtsuTnBrB3HLjuJ7egifeJa//6Cy9igQ5tmgaz/P4szYKrfAV9AUmf6PUq+XeUaxf/cHvqDsYqLot+OixGSpQKg2GoPuFuHx+mpXcnLn2Dluga+giRJ6RjH8ChIbr9fn89WxIqyk1PDPBVFdGt+8wFfQRGkXJ7mcXnnza4I/+bKgNfsnFXMXfAVNl/bxkoSLlnrvCgGN5o8+K6pzCQHhpsBX0KS5rQu1+4DRG8aWWDdekBopSwyL3ylq2YmU/Y0MvoKmTouO1CsLy8o1znCqAmgSWCodicnKx57izpR6ToOvoHnQqbdk0TsqXnGl2+0JaPfCv8HvXW6PTmc5ebZkxouiO7qRgj9a4CtoTrSKoYY9Knv97dJtP2nO/a5Pz9JfSdcdO1W+fnPJ3+dJ+o4Qhz7+jNDw4CsgEBDBV0AgIIKvgEBABF8BgYAIvgICARF8BQQCIvgKCARE8BUQCIjgKyAQEMFXQCAggq+AQEAEXwGBgAi+AgIBEXwFBAIi+AoIBETwFRAIiOArIBAQwVdAICCCr4BAQARfAYGACL4CAgERfAUEAiL4CggERPAVEAiI4CsgEBDBV0AgIIKvgEBABF8BgYAIvgICARF8BQQCIvgKCARE8BUQCIjgKyAQEMFXQCAggq+AQEAEXwGBgAi+AgIBEXwFBAIi+AoIBETwFRAIiOArIBAQwVdAIODxf/VVGcawPhaZAAAAAElFTkSuQmCC"/></a>
27
+ <p class="about">This website uses Puter to bring you safe, secure, and private AI and Cloud features.</p>
28
+ <div class="buttons">
29
+ <button class="button button-auth" id="launch-auth-popup-cancel">Cancel</button>
30
+ <button class="button button-primary button-auth" id="launch-auth-popup" style="margin-left:10px;">Continue</button>
31
+ </div>
32
+ <p style="text-align: center; font-size: 14px;">Powered by <a href="https://docs.puter.com/" target="_blank">Puter.js</a></p>
33
+ <p class="launch-auth-popup-footnote">By clicking 'Continue' you agree to Puter's <a href="https://puter.com/terms" target="_blank">Terms of Service</a> and <a href="https://puter.com/privacy" target="_blank">Privacy Policy</a>.</p>
34
+ </div>`;
35
+
36
+ const el_window = await UIWindow({
37
+ title: `Upload`,
38
+ icon: window.icons[`app-icon-uploader.svg`],
39
+ uid: null,
40
+ is_dir: false,
41
+ body_content: h,
42
+ has_head: false,
43
+ selectable_body: false,
44
+ draggable_body: true,
45
+ allow_context_menu: false,
46
+ is_resizable: false,
47
+ is_droppable: false,
48
+ init_center: true,
49
+ allow_native_ctxmenu: false,
50
+ allow_user_select: false,
51
+ window_class: 'window-puter-dialog window-cover-page',
52
+ width: '100%',
53
+ top: '0',
54
+ dominant: true,
55
+ window_css:{
56
+ height: '100%',
57
+ width: '100%',
58
+ top: '0 !important',
59
+ left: '0 !important',
60
+ },
61
+ body_css: {
62
+ padding: '22px',
63
+ width: 'initial',
64
+ 'background-color': 'rgba(231, 238, 245, .95)',
65
+ 'backdrop-filter': 'blur(3px)',
66
+ }
67
+ });
68
+
69
+ $(el_window).find('#launch-auth-popup').on('click submit', function (e) {
70
+ $(el_window).close();
71
+ resolve(true);
72
+ })
73
+
74
+ $(el_window).find('#launch-auth-popup-cancel').on('click submit', function (e) {
75
+ $(el_window).close();
76
+ resolve(false);
77
+ })
78
+ })
79
+ }
80
+ // export as default
81
+ export default PuterDialog;
src/UI/UIAlert.js ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ function UIAlert(options){
23
+ // set sensible defaults
24
+ if(arguments.length > 0){
25
+ // if first argument is a string, then assume it is the message
26
+ if(isString(arguments[0])){
27
+ options = {};
28
+ options.message = arguments[0];
29
+ }
30
+ // if second argument is an array, then assume it is the buttons
31
+ if(arguments[1] && Array.isArray(arguments[1])){
32
+ options.buttons = arguments[1];
33
+ }
34
+ }
35
+
36
+ return new Promise(async (resolve) => {
37
+ // provide an 'OK' button if no buttons are provided
38
+ if(!options.buttons || options.buttons.length === 0){
39
+ options.buttons = [
40
+ {label: 'OK', value: true, type: 'primary'}
41
+ ]
42
+ }
43
+
44
+ // set body icon
45
+ options.body_icon = options.body_icon ?? window.icons['warning-sign.svg'];
46
+ if(options.type === 'success')
47
+ options.body_icon = window.icons['c-check.svg'];
48
+
49
+ let h = '';
50
+ // icon
51
+ h += `<img class="window-alert-icon" src="${html_encode(options.body_icon)}">`;
52
+ // message
53
+ h += `<div class="window-alert-message">${options.message}</div>`;
54
+ // buttons
55
+ if(options.buttons && options.buttons.length > 0){
56
+ h += `<div style="overflow:hidden; margin-top:20px;">`;
57
+ for(let y=0; y<options.buttons.length; y++){
58
+ h += `<button class="button button-block button-${html_encode(options.buttons[y].type)} alert-resp-button"
59
+ data-label="${html_encode(options.buttons[y].label)}"
60
+ data-value="${html_encode(options.buttons[y].value ?? options.buttons[y].label)}"
61
+ ${options.buttons[y].type === 'primary' ? 'autofocus' : ''}
62
+ >${html_encode(options.buttons[y].label)}</button>`;
63
+ }
64
+ h += `</div>`;
65
+ }
66
+
67
+ const el_window = await UIWindow({
68
+ title: null,
69
+ icon: null,
70
+ uid: null,
71
+ is_dir: false,
72
+ message: options.message,
73
+ body_icon: options.body_icon,
74
+ backdrop: options.backdrop ?? false,
75
+ is_resizable: false,
76
+ is_droppable: false,
77
+ has_head: false,
78
+ stay_on_top: options.stay_on_top ?? false,
79
+ selectable_body: false,
80
+ draggable_body: options.draggable_body ?? true,
81
+ allow_context_menu: false,
82
+ show_in_taskbar: false,
83
+ window_class: 'window-alert',
84
+ dominant: true,
85
+ body_content: h,
86
+ width: 350,
87
+ parent_uuid: options.parent_uuid,
88
+ ...options.window_options,
89
+ window_css:{
90
+ height: 'initial',
91
+ },
92
+ body_css: {
93
+ width: 'initial',
94
+ padding: '20px',
95
+ 'background-color': 'rgba(231, 238, 245, .95)',
96
+ 'backdrop-filter': 'blur(3px)',
97
+ }
98
+ });
99
+ // focus to primary btn
100
+ $(el_window).find('.button-primary').focus();
101
+
102
+ // --------------------------------------------------------
103
+ // Button pressed
104
+ // --------------------------------------------------------
105
+ $(el_window).find('.alert-resp-button').on('click', async function(event){
106
+ event.preventDefault();
107
+ event.stopPropagation();
108
+ resolve($(this).attr('data-value'));
109
+ $(el_window).close();
110
+ return false;
111
+ })
112
+ })
113
+ }
114
+
115
+ export default UIAlert;
src/UI/UIContextMenu.js ADDED
@@ -0,0 +1,230 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ function UIContextMenu(options){
21
+ $('.window-active .window-app-iframe').css('pointer-events', 'none');
22
+
23
+ const menu_id = global_element_id++;
24
+
25
+ let h = '';
26
+ h += `<div
27
+ id="context-menu-${menu_id}"
28
+ data-is-submenu="${options.is_submenu ? 'true' : 'false'}"
29
+ data-element-id="${menu_id}"
30
+ data-id="${options.id ?? ''}"
31
+ ${options.parent_id ? `data-parent-id="${options.parent_id}"` : ``}
32
+ ${!options.parent_id && options.parent_element ? `data-parent-id="${$(options.parent_element).attr('data-element-id')}"` : ``}
33
+ class="context-menu context-menu-active ${options.is_submenu ? 'context-menu-submenu-open' : ''}"
34
+ >`;
35
+
36
+ for(let i=0; i < options.items.length; i++){
37
+ // item
38
+ if(!options.items[i].is_divider && options.items[i] !== '-'){
39
+ // single item
40
+ if(options.items[i].items === undefined){
41
+ h += `<li data-action="${i}"
42
+ class="context-menu-item ${options.items[i].disabled ? ' context-menu-item-disabled' : ''}"
43
+ >`;
44
+ // icon
45
+ h += `<span class="context-menu-item-icon">${options.items[i].icon ?? ''}</span>`;
46
+ h += `<span class="context-menu-item-icon-active">${options.items[i].icon_active ?? (options.items[i].icon ?? '')}</span>`;
47
+ // label
48
+ h += `<span class="contextmenu-label">${options.items[i].html}</span>`;
49
+ h += `<span class="contextmenu-label-active">${options.items[i].html_active ?? options.items[i].html}</span>`;
50
+
51
+ h += `</li>`;
52
+ }
53
+ // submenu
54
+ else{
55
+ h += `<li data-action="${i}"
56
+ data-menu-id="${menu_id}-${i}"
57
+ data-has-submenu="true"
58
+ data-parent-element-id="${menu_id}"
59
+ class="context-menu-item-submenu context-menu-item${options.items[i].disabled ? ' context-menu-item-disabled' : ''}"
60
+ >`;
61
+ // icon
62
+ h += `<span class="context-menu-item-icon">${options.items[i].icon ?? ''}</span>`;
63
+ h += `<span class="context-menu-item-icon-active">${options.items[i].icon_active ?? (options.items[i].icon ?? '')}</span>`;
64
+ // label
65
+ h += `${html_encode(options.items[i].html)}`;
66
+ // arrow
67
+ h += `<img class="submenu-arrow" src="${html_encode(window.icons['chevron-right.svg'])}"><img class="submenu-arrow submenu-arrow-active" src="${html_encode(window.icons['chevron-right-active.svg'])}">`;
68
+ h += `</li>`;
69
+ }
70
+ }
71
+ // divider
72
+ else if(options.items[i].is_divider || options.items[i] === '-')
73
+ h += `<li class="context-menu-divider"><hr></li>`;
74
+ }
75
+ h += `</div>`
76
+ $('body').append(h)
77
+
78
+ const contextMenu = document.getElementById(`context-menu-${menu_id}`);
79
+ const menu_width = $(contextMenu).width();
80
+ const menu_height = $(contextMenu).outerHeight();
81
+ let start_x, start_y;
82
+ //--------------------------------
83
+ // Auto position
84
+ //--------------------------------
85
+ if(!options.position){
86
+ if(isMobile.phone || isMobile.tablet){
87
+ start_x = window.last_touch_x;
88
+ start_y = window.last_touch_y;
89
+
90
+ }else{
91
+ start_x = window.mouseX;
92
+ start_y = window.mouseY;
93
+ }
94
+ }
95
+ //--------------------------------
96
+ // custom position
97
+ //--------------------------------
98
+ else{
99
+ start_x = options.position.left;
100
+ start_y = options.position.top;
101
+ }
102
+
103
+ // X position
104
+ let x_pos;
105
+ if( start_x + menu_width > window.innerWidth){
106
+ x_pos = start_x - menu_width;
107
+ // if this is a child menu, the width of parent must be also considered
108
+ if(options.parent_id){
109
+ x_pos -= $(`.context-menu[data-element-id="${options.parent_id}"]`).width() + 30;
110
+ }
111
+ }else
112
+ x_pos = start_x
113
+
114
+ // Y position
115
+ let y_pos;
116
+ // is the menu going to go out of the window from the bottom?
117
+ if( (start_y + menu_height) > (window.innerHeight - taskbar_height - 10))
118
+ y_pos = window.innerHeight - menu_height - taskbar_height - 10;
119
+ else
120
+ y_pos = start_y;
121
+
122
+ // Show ContextMenu
123
+ $(contextMenu).delay(100).show(0)
124
+ // In the right position (the mouse)
125
+ .css({
126
+ top: y_pos + "px",
127
+ left: x_pos + "px"
128
+ });
129
+
130
+ // mark other context menus as inactive
131
+ $('.context-menu').not(contextMenu).removeClass('context-menu-active');
132
+
133
+ // An item is clicked
134
+ $(`#context-menu-${menu_id} > li:not(.context-menu-item-disabled)`).on('click', function (e) {
135
+
136
+ // onClick
137
+ if(options.items[$(this).attr("data-action")].onClick && typeof options.items[$(this).attr("data-action")].onClick === 'function'){
138
+ let event = e;
139
+ event.value = options.items[$(this).attr("data-action")]['val'] ?? undefined;
140
+ options.items[$(this).attr("data-action")].onClick(event);
141
+ }
142
+ // close menu and, if exists, its parent
143
+ if(!$(this).hasClass('context-menu-item-submenu')){
144
+ $(`#context-menu-${menu_id}, .context-menu[data-element-id="${$(this).closest('.context-menu').attr('data-parent-id')}"]`).fadeOut(200, function(){
145
+ $(contextMenu).remove();
146
+ });
147
+ }
148
+
149
+ return false;
150
+ });
151
+
152
+ // when mouse is over an item
153
+ $(contextMenu).find('.context-menu-item').on('mouseover', function (e) {
154
+ // mark other items as inactive
155
+ $(contextMenu).find('.context-menu-item').removeClass('context-menu-item-active');
156
+ // mark this item as active
157
+ $(this).addClass('context-menu-item-active');
158
+ // close any submenu that doesn't belong to this item
159
+ $(`.context-menu[data-parent-id="${menu_id}"]`).remove();
160
+ // mark this context menu as active
161
+ $(contextMenu).addClass('context-menu-active');
162
+ })
163
+
164
+ // open submenu if applicable
165
+ $(`#context-menu-${menu_id} > li.context-menu-item-submenu`).on('mouseover', function (e) {
166
+
167
+ // open submenu only if it's not already open
168
+ if($(`.context-menu[data-id="${menu_id}-${$(this).attr('data-action')}"]`).length === 0){
169
+ let item_rect_box = this.getBoundingClientRect();
170
+
171
+ // close other submenus
172
+ $(`.context-menu[parent-element-id="${menu_id}"]`).remove();
173
+
174
+ // open the new submenu
175
+ UIContextMenu({
176
+ items: options.items[parseInt($(this).attr('data-action'))].items,
177
+ parent_id: menu_id,
178
+ is_submenu: true,
179
+ id: menu_id + '-' + $(this).attr('data-action'),
180
+ position:{
181
+ top: item_rect_box.top - 5,
182
+ left: x_pos + item_rect_box.width + 15,
183
+ }
184
+ })
185
+ }
186
+ return false;
187
+ });
188
+
189
+ // useful in cases such as where a menue item is over a window, this prevents from the mousedown event
190
+ // reaching the window underneath
191
+ $(`#context-menu-${menu_id} > li:not(.context-menu-item-disabled)`).on('mousedown', function (e) {
192
+ e.preventDefault();
193
+ e.stopPropagation();
194
+ return false;
195
+ })
196
+
197
+ //disable parent scroll
198
+ if(options.parent_element){
199
+ $(options.parent_element).css('overflow', 'hidden');
200
+ $(options.parent_element).parent().addClass('children-have-open-contextmenu');
201
+ $(options.parent_element).addClass('has-open-contextmenu');
202
+ }
203
+
204
+ $(contextMenu).on("remove", function () {
205
+ // when removing, make parent scrollable again
206
+ if(options.parent_element){
207
+ $(options.parent_element).parent().removeClass('children-have-open-contextmenu');
208
+
209
+ $(options.parent_element).css('overflow', 'scroll');
210
+ $(options.parent_element).removeClass('has-open-contextmenu');
211
+ if($(options.parent_element).hasClass('taskbar-item')){
212
+ make_taskbar_sortable()
213
+ }
214
+ }
215
+ })
216
+ $(contextMenu).on("contextmenu", function (e) {
217
+ e.preventDefault();
218
+ e.stopPropagation();
219
+ return false;
220
+ })
221
+ }
222
+
223
+ window.select_ctxmenu_item = function ($ctxmenu_item){
224
+ // remove active class from other items
225
+ $($ctxmenu_item).siblings('.context-menu-item').removeClass('context-menu-item-active');
226
+ // add active class to the selected item
227
+ $($ctxmenu_item).addClass('context-menu-item-active');
228
+ }
229
+
230
+ export default UIContextMenu;
src/UI/UIDesktop.js ADDED
@@ -0,0 +1,1447 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import path from "../lib/path.js"
21
+ import UIWindowClaimReferral from "./UIWindowClaimReferral.js"
22
+ import UIContextMenu from './UIContextMenu.js'
23
+ import UIItem from './UIItem.js'
24
+ import UIAlert from './UIAlert.js'
25
+ import UIWindow from './UIWindow.js'
26
+ import UIWindowSaveAccount from './UIWindowSaveAccount.js';
27
+ import UIWindowDesktopBGSettings from "./UIWindowDesktopBGSettings.js"
28
+ import UIWindowMyWebsites from "./UIWindowMyWebsites.js"
29
+ import UIWindowChangePassword from "./UIWindowChangePassword.js"
30
+ import UIWindowChangeUsername from "./UIWindowChangeUsername.js"
31
+ import UIWindowFeedback from "./UIWindowFeedback.js"
32
+ import UIWindowLogin from "./UIWindowLogin.js"
33
+ import UIWindowQR from "./UIWindowQR.js"
34
+ import UIWindowRefer from "./UIWindowRefer.js"
35
+ import UITaskbar from "./UITaskbar.js"
36
+
37
+ async function UIDesktop(options){
38
+ let h = '';
39
+
40
+ // connect socket.
41
+ window.socket = io(gui_origin + '/', {
42
+ query: {
43
+ auth_token: auth_token
44
+ }
45
+ });
46
+
47
+ window.socket.on('error', (error) => {
48
+ console.error('GUI Socket Error:', error);
49
+ });
50
+
51
+ window.socket.on('connect', function(){
52
+ console.log('GUI Socket: Connected', window.socket.id);
53
+ });
54
+
55
+ window.socket.on('reconnect', function(){
56
+ console.log('GUI Socket: Reconnected', window.socket.id);
57
+ });
58
+
59
+ window.socket.on('disconnect', () => {
60
+ console.log('GUI Socket: Disconnected');
61
+ });
62
+
63
+ window.socket.on('reconnect', (attempt) => {
64
+ console.log('GUI Socket: Reconnection', attempt);
65
+ });
66
+
67
+ window.socket.on('reconnect_attempt', (attempt) => {
68
+ console.log('GUI Socket: Reconnection Attemps', attempt);
69
+ });
70
+
71
+ window.socket.on('reconnect_error', (error) => {
72
+ console.log('GUI Socket: Reconnection Error', error);
73
+ });
74
+
75
+ window.socket.on('reconnect_failed', () => {
76
+ console.log('GUI Socket: Reconnection Failed');
77
+ });
78
+
79
+ window.socket.on('error', (error) => {
80
+ console.error('GUI Socket Error:', error);
81
+ });
82
+
83
+ socket.on('upload.progress', (msg) => {
84
+ if(window.progress_tracker[msg.operation_id]){
85
+ window.progress_tracker[msg.operation_id].cloud_uploaded += msg.loaded_diff
86
+ if(window.progress_tracker[msg.operation_id][msg.item_upload_id]){
87
+ window.progress_tracker[msg.operation_id][msg.item_upload_id].cloud_uploaded = msg.loaded;
88
+ }
89
+ }
90
+ });
91
+
92
+ socket.on('download.progress', (msg) => {
93
+ if(window.progress_tracker[msg.operation_id]){
94
+ if(window.progress_tracker[msg.operation_id][msg.item_upload_id]){
95
+ window.progress_tracker[msg.operation_id][msg.item_upload_id].downloaded = msg.loaded;
96
+ window.progress_tracker[msg.operation_id][msg.item_upload_id].total = msg.total;
97
+ }
98
+ }
99
+ });
100
+
101
+ socket.on('trash.is_empty', async (msg) => {
102
+ $(`.item[data-path="${html_encode(trash_path)}" i]`).find('.item-icon > img').attr('src', msg.is_empty ? window.icons['trash.svg'] : window.icons['trash-full.svg']);
103
+ $(`.window[data-path="${html_encode(trash_path)}" i]`).find('.window-head-icon').attr('src', msg.is_empty ? window.icons['trash.svg'] : window.icons['trash-full.svg']);
104
+ // empty trash windows if needed
105
+ if(msg.is_empty)
106
+ $(`.window[data-path="${html_encode(trash_path)}" i]`).find('.item-container').empty();
107
+ })
108
+
109
+ socket.on('app.opened', async (app) => {
110
+ // don't update if this is the original client that initiated the action
111
+ if(app.original_client_socket_id === window.socket.id)
112
+ return;
113
+
114
+ // add the app to the beginning of the array
115
+ launch_apps.recent.unshift(app);
116
+
117
+ // dedupe the array by uuid, uid, and id
118
+ launch_apps.recent = _.uniqBy(launch_apps.recent, 'name');
119
+
120
+ // limit to 5
121
+ launch_apps.recent = launch_apps.recent.slice(0, window.launch_recent_apps_count);
122
+ })
123
+
124
+ socket.on('item.removed', async (item) => {
125
+ // don't update if this is the original client that initiated the action
126
+ if(item.original_client_socket_id === window.socket.id)
127
+ return;
128
+
129
+ // don't remove items if this was a descendants_only operation
130
+ if(item.descendants_only)
131
+ return;
132
+
133
+ // hide all UIItems with matching uids
134
+ $(`.item[data-path='${item.path}']`).fadeOut(150, function(){
135
+ // close all windows with matching uids
136
+ // $('.window-' + item.uid).close();
137
+ // close all windows that belong to a descendant of this item
138
+ // todo this has to be case-insensitive but the `i` selector doesn't work on ^=
139
+ $(`.window[data-path^="${item.path}/"]`).close();
140
+ });
141
+ })
142
+
143
+ socket.on('item.updated', async (item) => {
144
+ // Don't update if this is the original client that initiated the action
145
+ if(item.original_client_socket_id === window.socket.id)
146
+ return;
147
+
148
+ // Update matching items
149
+ // set new item name
150
+ $(`.item[data-uid='${html_encode(item.uid)}'] .item-name`).html(html_encode(truncate_filename(item.name, TRUNCATE_LENGTH)).replaceAll(' ', '&nbsp;'));
151
+
152
+ // Set new icon
153
+ const new_icon = (item.is_dir ? window.icons['folder.svg'] : (await item_icon(item)).image);
154
+ $(`.item[data-uid='${item.uid}']`).find('.item-icon-thumb').attr('src', new_icon);
155
+ $(`.item[data-uid='${item.uid}']`).find('.item-icon-icon').attr('src', new_icon);
156
+
157
+ // Set new data-name
158
+ $(`.item[data-uid='${item.uid}']`).attr('data-name', html_encode(item.name));
159
+ $(`.window-${item.uid}`).attr('data-name', html_encode(item.name));
160
+
161
+ // Set new title attribute
162
+ $(`.item[data-uid='${item.uid}']`).attr('title', html_encode(item.name));
163
+ $(`.window-${options.uid}`).attr('title', html_encode(item.name));
164
+
165
+ // Set new value for item-name-editor
166
+ $(`.item[data-uid='${item.uid}'] .item-name-editor`).val(html_encode(item.name));
167
+ $(`.item[data-uid='${item.uid}'] .item-name`).attr('title', html_encode(item.name));
168
+
169
+ // Set new data-path
170
+ const new_path = item.path;
171
+ $(`.item[data-uid='${item.uid}']`).attr('data-path', new_path);
172
+ $(`.window-${item.uid}`).attr('data-path', new_path);
173
+
174
+ // Update all elements that have matching paths
175
+ $(`[data-path="${html_encode(item.old_path)}" i]`).each(function(){
176
+ $(this).attr('data-path', new_path)
177
+ if($(this).hasClass('window-navbar-path-dirname'))
178
+ $(this).text(item.name);
179
+ });
180
+
181
+ // Update all elements whose paths start with old_path
182
+ $(`[data-path^="${html_encode(item.old_path) + '/'}"]`).each(function(){
183
+ const new_el_path = _.replace($(this).attr('data-path'), item.old_path + '/', new_path+'/');
184
+ $(this).attr('data-path', new_el_path);
185
+ });
186
+
187
+ // Update all exact-matching windows
188
+ $(`.window-${item.uid}`).each(function(){
189
+ update_window_path(this, new_path);
190
+ })
191
+ // Set new name for matching open windows
192
+ $(`.window-${item.uid} .window-head-title`).text(item.name);
193
+
194
+ // Re-sort all matching item containers
195
+ $(`.item[data-uid='${item.uid}']`).parent('.item-container').each(function(){
196
+ sort_items(this, $(this).closest('.item-container').attr('data-sort_by'), $(this).closest('.item-container').attr('data-sort_order'));
197
+ })
198
+ })
199
+
200
+ socket.on('item.moved', async (resp) => {
201
+ let fsentry = resp;
202
+ // Notify all apps that are watching this item
203
+ sendItemChangeEventToWatchingApps(fsentry.uid, {
204
+ event: 'moved',
205
+ uid: fsentry.uid,
206
+ name: fsentry.name,
207
+ })
208
+
209
+ // don't update if this is the original client that initiated the action
210
+ if(resp.original_client_socket_id === window.socket.id)
211
+ return;
212
+
213
+ let dest_path = path.dirname(fsentry.path);
214
+ let metadata = fsentry.metadata;
215
+
216
+ // path must use the real name from DB
217
+ fsentry.path = fsentry.path;
218
+
219
+ // update all shortcut_to_path
220
+ $(`.item[data-shortcut_to_path="${html_encode(resp.old_path)}" i]`).attr(`data-shortcut_to_path`, html_encode(fsentry.path));
221
+
222
+ // remove all items with matching uids
223
+ $(`.item[data-uid='${fsentry.uid}']`).fadeOut(150, function(){
224
+ // find all parent windows that contain this item
225
+ let parent_windows = $(`.item[data-uid='${fsentry.uid}']`).closest('.window');
226
+ // remove this item
227
+ $(this).removeItems();
228
+ // update parent windows' item counts
229
+ $(parent_windows).each(function(index){
230
+ update_explorer_footer_item_count(this);
231
+ update_explorer_footer_selected_items_count(this)
232
+ });
233
+ })
234
+
235
+ // if trashing, close windows of trashed items and its descendants
236
+ if(dest_path === trash_path){
237
+ $(`.window[data-path="${html_encode(resp.old_path)}" i]`).close();
238
+ // todo this has to be case-insensitive but the `i` selector doesn't work on ^=
239
+ $(`.window[data-path^="${html_encode(resp.old_path)}/"]`).close();
240
+ }
241
+
242
+ // update all paths of its and its descendants' open windows
243
+ else{
244
+ // todo this has to be case-insensitive but the `i` selector doesn't work on ^=
245
+ $(`.window[data-path^="${html_encode(resp.old_path)}/"], .window[data-path="${html_encode(resp.old_path)}" i]`).each(function(){
246
+ update_window_path(this, $(this).attr('data-path').replace(resp.old_path, fsentry.path));
247
+ })
248
+ }
249
+
250
+ if(dest_path === trash_path){
251
+ $(`.item[data-uid="${fsentry.uid}"]`).find('.item-is-shared').fadeOut(300);
252
+
253
+ // if trashing dir...
254
+ if(fsentry.is_dir){
255
+ // remove website badge
256
+ $(`.mywebsites-dir-path[data-uuid="${fsentry.uid}"]`).remove();
257
+ // remove the website badge from all instances of the dir
258
+ $(`.item[data-uid="${fsentry.uid}"]`).find('.item-has-website-badge').fadeOut(300);
259
+
260
+ // remove File Rrequest Token
261
+ // todo, some client-side check to see if this dir has an FR associated with it before sending a whole ajax req
262
+ }
263
+ }
264
+ // if replacing an existing item, remove the old item that was just replaced
265
+ if(fsentry.overwritten_uid !== undefined)
266
+ $(`.item[data-uid=${fsentry.overwritten_uid}]`).removeItems();
267
+
268
+ // if this is trash, get original name from item metadata
269
+ fsentry.name = (metadata && metadata.original_name) ? metadata.original_name : fsentry.name;
270
+
271
+ // create new item on matching containers
272
+ UIItem({
273
+ appendTo: $(`.item-container[data-path='${html_encode(dest_path)}' i]`),
274
+ immutable: fsentry.immutable,
275
+ uid: fsentry.uid,
276
+ path: fsentry.path,
277
+ icon: await item_icon(fsentry),
278
+ name: (dest_path === trash_path) ? metadata.original_name : fsentry.name,
279
+ is_dir: fsentry.is_dir,
280
+ size: fsentry.size,
281
+ type: fsentry.type,
282
+ modified: fsentry.modified,
283
+ is_selected: false,
284
+ is_shared: (dest_path === trash_path) ? false : fsentry.is_shared,
285
+ is_shortcut: fsentry.is_shortcut,
286
+ shortcut_to: fsentry.shortcut_to,
287
+ shortcut_to_path: fsentry.shortcut_to_path,
288
+ // has_website: $(el_item).attr('data-has_website') === '1',
289
+ metadata: JSON.stringify(fsentry.metadata) ?? '',
290
+ });
291
+
292
+ if(fsentry.parent_dirs_created && fsentry.parent_dirs_created.length > 0){
293
+ // this operation may have created some missing directories,
294
+ // see if any of the directories in the path of this file is new AND
295
+ // if these new path have any open parents that need to be updated
296
+
297
+ fsentry.parent_dirs_created.forEach(async dir => {
298
+ let item_container = $(`.item-container[data-path='${html_encode(path.dirname(dir.path))}' i]`);
299
+ if(item_container.length > 0 && $(`.item[data-path="${html_encode(dir.path)}" i]`).length === 0){
300
+ UIItem({
301
+ appendTo: item_container,
302
+ immutable: false,
303
+ uid: dir.uid,
304
+ path: dir.path,
305
+ icon: await item_icon(dir),
306
+ name: dir.name,
307
+ size: dir.size,
308
+ type: dir.type,
309
+ modified: dir.modified,
310
+ is_dir: true,
311
+ is_selected: false,
312
+ is_shared: dir.is_shared,
313
+ has_website: false,
314
+ });
315
+ }
316
+ sort_items(item_container, $(item_container).attr('data-sort_by'), $(item_container).attr('data-sort_order'));
317
+ });
318
+ }
319
+ //sort each container
320
+ $(`.item-container[data-path='${html_encode(dest_path)}' i]`).each(function(){
321
+ sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order'))
322
+ })
323
+ });
324
+
325
+ socket.on('user.email_confirmed', (msg) => {
326
+ // don't update if this is the original client that initiated the action
327
+ if(msg.original_client_socket_id === window.socket.id)
328
+ return;
329
+
330
+ refresh_user_data(window.auth_token);
331
+ });
332
+
333
+ socket.on('item.renamed', async (item) => {
334
+ // Notify all apps that are watching this item
335
+ sendItemChangeEventToWatchingApps(item.uid, {
336
+ event: 'rename',
337
+ uid: item.uid,
338
+ // path: item.path,
339
+ new_name: item.name,
340
+ // old_path: item.old_path,
341
+ })
342
+
343
+ // Don't update if this is the original client that initiated the action
344
+ if(item.original_client_socket_id === window.socket.id)
345
+ return;
346
+
347
+ // Update matching items
348
+ // Set new item name
349
+ $(`.item[data-uid='${html_encode(item.uid)}'] .item-name`).html(html_encode(truncate_filename(item.name, TRUNCATE_LENGTH)).replaceAll(' ', '&nbsp;'));
350
+
351
+ // Set new icon
352
+ const new_icon = (item.is_dir ? window.icons['folder.svg'] : (await item_icon(item)).image);
353
+ $(`.item[data-uid='${item.uid}']`).find('.item-icon-icon').attr('src', new_icon);
354
+
355
+ // Set new data-name
356
+ $(`.item[data-uid='${item.uid}']`).attr('data-name', html_encode(item.name));
357
+ $(`.window-${item.uid}`).attr('data-name', html_encode(item.name));
358
+
359
+ // Set new title attribute
360
+ $(`.item[data-uid='${item.uid}']`).attr('title', html_encode(item.name));
361
+ $(`.window-${options.uid}`).attr('title', html_encode(item.name));
362
+
363
+ // Set new value for item-name-editor
364
+ $(`.item[data-uid='${item.uid}'] .item-name-editor`).val(html_encode(item.name));
365
+ $(`.item[data-uid='${item.uid}'] .item-name`).attr('title', html_encode(item.name));
366
+
367
+ // Set new data-path
368
+ const new_path = item.path;
369
+ $(`.item[data-uid='${item.uid}']`).attr('data-path', new_path);
370
+ $(`.window-${item.uid}`).attr('data-path', new_path);
371
+
372
+ // Update all elements that have matching paths
373
+ $(`[data-path="${html_encode(item.old_path)}" i]`).each(function(){
374
+ $(this).attr('data-path', new_path)
375
+ if($(this).hasClass('window-navbar-path-dirname'))
376
+ $(this).text(item.name);
377
+ });
378
+
379
+ // Update all elements whose paths start with old_path
380
+ $(`[data-path^="${html_encode(item.old_path) + '/'}"]`).each(function(){
381
+ const new_el_path = _.replace($(this).attr('data-path'), item.old_path + '/', new_path+'/');
382
+ $(this).attr('data-path', new_el_path);
383
+ });
384
+
385
+ // Update all exact-matching windows
386
+ $(`.window-${item.uid}`).each(function(){
387
+ update_window_path(this, new_path);
388
+ })
389
+ // Set new name for matching open windows
390
+ $(`.window-${item.uid} .window-head-title`).text(item.name);
391
+
392
+ // Re-sort all matching item containers
393
+ $(`.item[data-uid='${item.uid}']`).parent('.item-container').each(function(){
394
+ sort_items(this, $(this).closest('.item-container').attr('data-sort_by'), $(this).closest('.item-container').attr('data-sort_order'));
395
+ })
396
+ });
397
+
398
+ socket.on('item.added', async (item) => {
399
+ // if item is empty, don't proceed
400
+ if(_.isEmpty(item))
401
+ return;
402
+
403
+ // Notify all apps that are watching this item
404
+ sendItemChangeEventToWatchingApps(item.uid, {
405
+ event: 'write',
406
+ uid: item.uid,
407
+ // path: item.path,
408
+ new_size: item.size,
409
+ modified: item.modified,
410
+ // old_path: item.old_path,
411
+ });
412
+
413
+ // Don't update if this is the original client that initiated the action
414
+ if(item.original_client_socket_id === window.socket.id)
415
+ return;
416
+
417
+ // Update replaced items with matching uids
418
+ if(item.overwritten_uid){
419
+ $(`.item[data-uid='${item.overwritten_uid}']`).attr({
420
+ 'data-immutable': item.immutable,
421
+ 'data-path': item.path,
422
+ 'data-name': item.name,
423
+ 'data-size': item.size,
424
+ 'data-modified': item.modified,
425
+ 'data-is_shared': item.is_shared,
426
+ 'data-type': item.type,
427
+ })
428
+ // set new icon
429
+ const new_icon = (item.is_dir ? window.icons['folder.svg'] : (await item_icon(item)).image);
430
+ $(`.item[data-uid="${item.overwritten_uid}"]`).find('.item-icon > img').attr('src', new_icon);
431
+
432
+ //sort each window
433
+ $(`.item-container[data-path='${html_encode(item.dirpath)}' i]`).each(function(){
434
+ sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order'))
435
+ })
436
+ }
437
+ else{
438
+ UIItem({
439
+ appendTo: $(`.item-container[data-path='${html_encode(item.dirpath)}' i]`),
440
+ uid: item.uid,
441
+ immutable: item.immutable,
442
+ associated_app_name: item.associated_app?.name,
443
+ path: item.path,
444
+ icon: await item_icon(item),
445
+ name: item.name,
446
+ size: item.size,
447
+ type: item.type,
448
+ modified: item.modified,
449
+ is_dir: item.is_dir,
450
+ is_shared: item.is_shared,
451
+ is_shortcut: item.is_shortcut,
452
+ associated_app_name: item.associated_app?.name,
453
+ shortcut_to: item.shortcut_to,
454
+ shortcut_to_path: item.shortcut_to_path,
455
+ });
456
+
457
+ //sort each window
458
+ $(`.item-container[data-path='${html_encode(item.dirpath)}' i]`).each(function(){
459
+ sort_items(this, $(this).attr('data-sort_by'), $(this).attr('data-sort_order'))
460
+ })
461
+ }
462
+ });
463
+
464
+ // Hidden file dialog
465
+ h += `<form name="upload-form" id="upload-form" style="display:hidden;">
466
+ <input type="hidden" name="name" id="upload-filename" value="">
467
+ <input type="hidden" name="path" id="upload-target-path" value="">
468
+ <input type="file" name="file" id="upload-file-dialog" style="display: none;" multiple="multiple">
469
+ </form>`;
470
+
471
+ h += `<div class="window-container"></div>`;
472
+
473
+ // Desktop
474
+ // If desktop is not in fullpage/embedded mode, we hide it until files and directories are loaded and then fade in the UI
475
+ // This gives a calm and smooth experience for the user
476
+ h += `<div class="desktop item-container disable-user-select"
477
+ data-uid="${options.desktop_fsentry.uid}"
478
+ data-sort_by="${!options.desktop_fsentry.sort_by ? 'name' : options.desktop_fsentry.sort_by}"
479
+ data-sort_order="${!options.desktop_fsentry.sort_order ? 'asc' : options.desktop_fsentry.sort_order}"
480
+ data-path="${html_encode(desktop_path)}"
481
+ >`;
482
+ h += `</div>`;
483
+
484
+ // Get window sidebar width
485
+ getItem({
486
+ key: "window_sidebar_width",
487
+ success: async function(res){
488
+ let value = parseInt(res.value);
489
+ // if value is a valid number
490
+ if(!isNaN(value) && value > 0){
491
+ window.window_sidebar_width = value;
492
+ }
493
+ }
494
+ })
495
+
496
+ // Remove `?ref=...` from navbar URL
497
+ if(url_query_params.has('ref')){
498
+ window.history.pushState(null, document.title, '/');
499
+ }
500
+
501
+ // Append to <body>
502
+ $('body').append(h);
503
+
504
+ // Set desktop height based on taskbar height
505
+ $('.desktop').css('height', `calc(100vh - ${window.taskbar_height + window.toolbar_height}px)`)
506
+
507
+ // ---------------------------------------------------------------
508
+ // Taskbar
509
+ // ---------------------------------------------------------------
510
+ UITaskbar();
511
+
512
+ const el_desktop = document.querySelector('.desktop');
513
+
514
+ window.active_element = el_desktop;
515
+ window.active_item_container = el_desktop;
516
+ // --------------------------------------------------------
517
+ // Dragster
518
+ // Allow dragging of local files onto desktop.
519
+ // --------------------------------------------------------
520
+ $(el_desktop).dragster({
521
+ enter: function (dragsterEvent, event) {
522
+ $('.context-menu').remove();
523
+ },
524
+ leave: function (dragsterEvent, event) {
525
+ },
526
+ drop: async function (dragsterEvent, event) {
527
+ const e = event.originalEvent;
528
+ // no drop on item
529
+ if($(event.target).hasClass('item') || $(event.target).parent('.item').length > 0)
530
+ return false;
531
+ // recursively create directories and upload files
532
+ if(e.dataTransfer?.items?.length>0){
533
+ upload_items(e.dataTransfer.items, desktop_path);
534
+ }
535
+
536
+ e.stopPropagation();
537
+ e.preventDefault();
538
+ return false;
539
+ }
540
+ });
541
+
542
+ // --------------------------------------------------------
543
+ // Droppable
544
+ // --------------------------------------------------------
545
+ $(el_desktop).droppable({
546
+ accept: '.item',
547
+ tolerance: "intersect",
548
+ drop: function( event, ui ) {
549
+ // Check if item was actually dropped on desktop and not a window
550
+ if(mouseover_window !== undefined)
551
+ return;
552
+
553
+ // Can't drop anything but UIItems on desktop
554
+ if(!$(ui.draggable).hasClass('item'))
555
+ return;
556
+
557
+ // Don't move an item to its current directory
558
+ if( path.dirname($(ui.draggable).attr('data-path')) === desktop_path && !event.ctrlKey)
559
+ return;
560
+
561
+ // If ctrl is pressed and source is Trashed, cancel whole operation
562
+ if(event.ctrlKey && path.dirname($(ui.draggable).attr('data-path')) === window.trash_path)
563
+ return;
564
+
565
+ // Unselect previously selected items
566
+ $(el_desktop).children('.item-selected').removeClass('item-selected');
567
+
568
+ const items_to_move = []
569
+ // first item
570
+ items_to_move.push(ui.draggable);
571
+
572
+ // all subsequent items
573
+ const cloned_items = document.getElementsByClassName('item-selected-clone');
574
+ for(let i =0; i<cloned_items.length; i++){
575
+ const source_item = document.getElementById('item-' + $(cloned_items[i]).attr('data-id'));
576
+ if(source_item !== null)
577
+ items_to_move.push(source_item);
578
+ }
579
+
580
+ // if ctrl key is down, copy items
581
+ if(event.ctrlKey){
582
+ // unless source is Trash
583
+ if(path.dirname($(ui.draggable).attr('data-path')) === window.trash_path)
584
+ return;
585
+
586
+ copy_items(items_to_move, desktop_path)
587
+ }
588
+ // otherwise, move items
589
+ else{
590
+ move_items(items_to_move, desktop_path);
591
+ }
592
+ }
593
+ });
594
+
595
+ //--------------------------------------------------
596
+ // ContextMenu
597
+ //--------------------------------------------------
598
+ $(el_desktop).bind("contextmenu taphold", function (event) {
599
+ // dismiss taphold on regular devices
600
+ if(event.type==='taphold' && !isMobile.phone && !isMobile.tablet)
601
+ return;
602
+
603
+ const $target = $(event.target);
604
+
605
+ // elements that should retain native ctxmenu
606
+ if($target.is('input') || $target.is('textarea'))
607
+ return true
608
+
609
+ // custom ctxmenu for all other elements
610
+ if(event.target === el_desktop){
611
+ event.preventDefault();
612
+ UIContextMenu({
613
+ items: [
614
+ // -------------------------------------------
615
+ // Sort by
616
+ // -------------------------------------------
617
+ {
618
+ html: "Sort by",
619
+ items: [
620
+ {
621
+ html: `Name`,
622
+ icon: $(el_desktop).attr('data-sort_by') === 'name' ? '✓' : '',
623
+ onClick: async function(){
624
+ sort_items(el_desktop, 'name', $(el_desktop).attr('data-sort_order'));
625
+ set_sort_by(options.desktop_fsentry.uid, 'name', $(el_desktop).attr('data-sort_order'))
626
+ }
627
+ },
628
+ {
629
+ html: `Date modified`,
630
+ icon: $(el_desktop).attr('data-sort_by') === 'modified' ? '✓' : '',
631
+ onClick: async function(){
632
+ sort_items(el_desktop, 'modified', $(el_desktop).attr('data-sort_order'));
633
+ set_sort_by(options.desktop_fsentry.uid, 'modified', $(el_desktop).attr('data-sort_order'))
634
+ }
635
+ },
636
+ {
637
+ html: `Type`,
638
+ icon: $(el_desktop).attr('data-sort_by') === 'type' ? '✓' : '',
639
+ onClick: async function(){
640
+ sort_items(el_desktop, 'type', $(el_desktop).attr('data-sort_order'));
641
+ set_sort_by(options.desktop_fsentry.uid, 'type', $(el_desktop).attr('data-sort_order'))
642
+ }
643
+ },
644
+ {
645
+ html: `Size`,
646
+ icon: $(el_desktop).attr('data-sort_by') === 'size' ? '✓' : '',
647
+ onClick: async function(){
648
+ sort_items(el_desktop, 'size', $(el_desktop).attr('data-sort_order'));
649
+ set_sort_by(options.desktop_fsentry.uid, 'size', $(el_desktop).attr('data-sort_order'))
650
+ }
651
+ },
652
+ // -------------------------------------------
653
+ // -
654
+ // -------------------------------------------
655
+ '-',
656
+ {
657
+ html: `Ascending`,
658
+ icon: $(el_desktop).attr('data-sort_order') === 'asc' ? '✓' : '',
659
+ onClick: async function(){
660
+ const sort_by = $(el_desktop).attr('data-sort_by')
661
+ sort_items(el_desktop, sort_by, 'asc');
662
+ set_sort_by(options.desktop_fsentry.uid, sort_by, 'asc')
663
+ }
664
+ },
665
+ {
666
+ html: `Descending`,
667
+ icon: $(el_desktop).attr('data-sort_order') === 'desc' ? '✓' : '',
668
+ onClick: async function(){
669
+ const sort_by = $(el_desktop).attr('data-sort_by')
670
+ sort_items(el_desktop, sort_by, 'desc');
671
+ set_sort_by(options.desktop_fsentry.uid, sort_by, 'desc')
672
+ }
673
+ },
674
+ ]
675
+ },
676
+ // -------------------------------------------
677
+ // Refresh
678
+ // -------------------------------------------
679
+ {
680
+ html: "Refresh",
681
+ onClick: function(){
682
+ refresh_item_container(el_desktop);
683
+ }
684
+ },
685
+ // -------------------------------------------
686
+ // -
687
+ // -------------------------------------------
688
+ '-',
689
+ // -------------------------------------------
690
+ // New File
691
+ // -------------------------------------------
692
+ window.new_context_menu_item(desktop_path, el_desktop),
693
+ // -------------------------------------------
694
+ // -
695
+ // -------------------------------------------
696
+ '-',
697
+ // -------------------------------------------
698
+ // Paste
699
+ // -------------------------------------------
700
+ {
701
+ html: "Paste",
702
+ disabled: clipboard.length > 0 ? false : true,
703
+ onClick: function(){
704
+ if(clipboard_op === 'copy')
705
+ copy_clipboard_items(desktop_path, el_desktop);
706
+ else if(clipboard_op === 'move')
707
+ move_clipboard_items(el_desktop)
708
+ }
709
+ },
710
+ // -------------------------------------------
711
+ // Upload Here
712
+ // -------------------------------------------
713
+ {
714
+ html: "Upload Here",
715
+ onClick: function(){
716
+ init_upload_using_dialog(el_desktop);
717
+ }
718
+ },
719
+ // -------------------------------------------
720
+ // Request Files
721
+ // -------------------------------------------
722
+ // {
723
+ // html: "Request Files",
724
+ // onClick: function(){
725
+ // UIWindowRequestFiles({dir_path: desktop_path})
726
+ // }
727
+ // },
728
+ // -------------------------------------------
729
+ // -
730
+ // -------------------------------------------
731
+ '-',
732
+ // -------------------------------------------
733
+ // Change Desktop Background…
734
+ // -------------------------------------------
735
+ {
736
+ html: "Change Desktop Background…",
737
+ onClick: function(){
738
+ UIWindowDesktopBGSettings();
739
+ }
740
+ },
741
+
742
+ ]
743
+ });
744
+ }
745
+ });
746
+
747
+ //-------------------------------------------
748
+ // Desktop Files/Folders
749
+ // we don't need to get the desktop items if we're in embedded or fullpage mode
750
+ // because the items aren't visible anyway and we don't need to waste bandwidth/server resources
751
+ //-------------------------------------------
752
+ if(!is_embedded && !window.is_fullpage_mode){
753
+ refresh_item_container(el_desktop, {fadeInItems: true})
754
+ window.launch_download_from_url();
755
+ }
756
+
757
+ // -------------------------------------------
758
+ // Selectable
759
+ // Only for desktop
760
+ // -------------------------------------------
761
+ if(!isMobile.phone && !isMobile.tablet){
762
+ let selected_ctrl_items = [];
763
+ const selection = new SelectionArea({
764
+ selectionContainerClass: '.selection-area-container',
765
+ container: '.desktop',
766
+ selectables: ['.desktop.item-container > .item'],
767
+ startareas: ['.desktop'],
768
+ boundaries: ['.desktop'],
769
+ behaviour: {
770
+ overlap: 'drop',
771
+ intersect: 'touch',
772
+ startThreshold: 10,
773
+ scrolling: {
774
+ speedDivider: 10,
775
+ manualSpeed: 750,
776
+ startScrollMargins: {x: 0, y: 0}
777
+ }
778
+ },
779
+ features: {
780
+ touch: true,
781
+ range: true,
782
+ singleTap: {
783
+ allow: true,
784
+ intersect: 'native'
785
+ }
786
+ }
787
+ });
788
+
789
+ selection.on('beforestart', ({event}) => {
790
+ selected_ctrl_items = [];
791
+ // Returning false prevents a selection
792
+ return $(event.target).hasClass('item-container');
793
+ })
794
+ .on('beforedrag', evt => {
795
+ })
796
+ .on('start', ({store, event}) => {
797
+ if (!event.ctrlKey && !event.metaKey) {
798
+ for (const el of store.stored) {
799
+ el.classList.remove('item-selected');
800
+ }
801
+
802
+ selection.clearSelection();
803
+ }
804
+ })
805
+ .on('move', ({store: {changed: {added, removed}}, event}) => {
806
+ for (const el of added) {
807
+ // if ctrl or meta key is pressed and the item is already selected, then unselect it
808
+ if((event.ctrlKey || event.metaKey) && $(el).hasClass('item-selected')){
809
+ el.classList.remove('item-selected');
810
+ selected_ctrl_items.push(el);
811
+ }
812
+ // otherwise select it
813
+ else{
814
+ el.classList.add('item-selected');
815
+ }
816
+ }
817
+
818
+ for (const el of removed) {
819
+ el.classList.remove('item-selected');
820
+ // in case this item was selected by ctrl+click before, then reselect it again
821
+ if(selected_ctrl_items.includes(el))
822
+ $(el).not('.item-disabled').addClass('item-selected');
823
+ }
824
+ })
825
+ .on('stop', evt => {
826
+ });
827
+ }
828
+ // ----------------------------------------------------
829
+ // User options
830
+ // ----------------------------------------------------
831
+ let ht = '';
832
+ ht += `<div class="toolbar" style="height:${window.toolbar_height}px;">`;
833
+ // logo
834
+ ht += `<div class="toolbar-btn toolbar-puter-logo" title="Puter" style="margin-left: 10px; margin-right: auto;"><img src="${window.icons['logo-white.svg']}" draggable="false" style="display:block; width:17px; height:17px"></div>`;
835
+ // create account button
836
+ ht += `<div class="toolbar-btn user-options-create-account-btn ${window.user.is_temp ? '' : 'hidden' }" style="padding:0; opacity:1;" title="Save Account">`;
837
+ ht += `<svg style="width: 17px; height: 17px;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="48px" height="48px" viewBox="0 0 48 48"><g transform="translate(0, 0)"><path d="M45.521,39.04L27.527,5.134c-1.021-1.948-3.427-2.699-5.375-1.679-.717,.376-1.303,.961-1.679,1.679L2.479,39.04c-.676,1.264-.635,2.791,.108,4.017,.716,1.207,2.017,1.946,3.42,1.943H41.993c1.403,.003,2.704-.736,3.42-1.943,.743-1.226,.784-2.753,.108-4.017ZM23.032,15h1.937c.565,0,1.017,.467,1,1.031l-.438,14c-.017,.54-.459,.969-1,.969h-1.062c-.54,0-.983-.429-1-.969l-.438-14c-.018-.564,.435-1.031,1-1.031Zm.968,25c-1.657,0-3-1.343-3-3s1.343-3,3-3,3,1.343,3,3-1.343,3-3,3Z" fill="#ffbb00"></path></g></svg>`;
838
+ ht += `</div>`;
839
+
840
+ // 'show desktop'
841
+ if(window.is_fullpage_mode){
842
+ ht += `<a href="/" class="show-desktop-btn toolbar-btn antialiased" target="_blank" title="Open Desktop">Open Desktop</a>`;
843
+ }
844
+
845
+ // refer
846
+ if(user.referral_code){
847
+ ht += `<div class="toolbar-btn refer-btn" title="Refer" style="background-image:url(${window.icons['gift.svg']});"></div>`;
848
+ }
849
+
850
+ // do not show the fullscreen button on mobile devices since it's broken
851
+ if(!isMobile.phone){
852
+ // fullscreen button
853
+ ht += `<div class="toolbar-btn fullscreen-btn" title="Enter Full Screen" style="background-image:url(${window.icons['fullscreen.svg']})"></div>`;
854
+ }
855
+
856
+ // qr code button -- only show if not embedded
857
+ if(!is_embedded)
858
+ ht += `<div class="toolbar-btn qr-btn" title="QR code" style="background-image:url(${window.icons['qr.svg']})"></div>`;
859
+
860
+ // user options menu
861
+ ht += `<div class="toolbar-btn user-options-menu-btn" style="background-image:url(${window.icons['profile.svg']})">`;
862
+ h += `<span class="user-options-menu-username">${window.user.username}</span>`;
863
+ ht += `</div>`;
864
+ ht += `</div>`;
865
+
866
+ // prepend toolbar to desktop
867
+ $(ht).insertBefore(el_desktop);
868
+
869
+ // adjust window container to take into account the toolbar height
870
+ $('.window-container').css('top', window.toolbar_height);
871
+
872
+ // ---------------------------------------------
873
+ // Run apps from insta-login URL
874
+ // ---------------------------------------------
875
+ if(url_query_params.has('app')){
876
+ let url_app_name = url_query_params.get('app');
877
+ if(url_app_name === 'explorer'){
878
+ let predefined_path = home_path;
879
+ if(url_query_params.has('path'))
880
+ predefined_path =url_query_params.get('path')
881
+ // launch explorer
882
+ UIWindow({
883
+ path: predefined_path,
884
+ title: path.basename(predefined_path),
885
+ icon: await item_icon({is_dir: true, path: predefined_path}),
886
+ // todo
887
+ // uid: $(el_item).attr('data-uid'),
888
+ is_dir: true,
889
+ // todo
890
+ // sort_by: $(el_item).attr('data-sort_by'),
891
+ app: 'explorer',
892
+ });
893
+ }
894
+ }
895
+ // ---------------------------------------------
896
+ // load from direct app URLs: /app/app-name
897
+ // ---------------------------------------------
898
+ else if(window.app_launched_from_url){
899
+ let qparams = new URLSearchParams(window.location.search);
900
+ if(!qparams.has('c')){
901
+ launch_app({
902
+ name: app_launched_from_url,
903
+ readURL: qparams.get('readURL'),
904
+ maximized: qparams.get('maximized'),
905
+ is_fullpage: window.is_fullpage_mode,
906
+ window_options: {
907
+ stay_on_top: false,
908
+ }
909
+ });
910
+ }
911
+ }
912
+
913
+ $(el_desktop).on('mousedown touchstart', function(e){
914
+ // dimiss touchstart on regular devices
915
+ if(e.type==='taphold' && !isMobile.phone && !isMobile.tablet)
916
+ return;
917
+
918
+ // disable pointer-events for all app iframes, this is to make sure selectable works
919
+ $('.window-app-iframe').css('pointer-events', 'none');
920
+ $('.window').find('.item-selected').addClass('item-blurred');
921
+ $('.desktop').find('.item-blurred').removeClass('item-blurred');
922
+ })
923
+
924
+ $(el_desktop).on('click', function(e){
925
+ // blur all windows
926
+ $('.window-active').removeClass('window-active');
927
+ })
928
+
929
+ function display_ct() {
930
+ var x = new Date()
931
+ var ampm = x.getHours( ) >= 12 ? ' PM' : ' AM';
932
+ let hours = x.getHours( ) % 12;
933
+ hours = hours ? hours : 12;
934
+ hours=hours.toString().length==1? 0+hours.toString() : hours;
935
+
936
+ var minutes=x.getMinutes().toString()
937
+ minutes=minutes.length==1 ? 0+minutes : minutes;
938
+
939
+ var seconds=x.getSeconds().toString()
940
+ seconds=seconds.length==1 ? 0+seconds : seconds;
941
+
942
+ var month=(x.getMonth() +1).toString();
943
+ month=month.length==1 ? 0+month : month;
944
+
945
+ var dt=x.getDate().toString();
946
+ dt=dt.length==1 ? 0+dt : dt;
947
+
948
+ var x1=month + "/" + dt + "/" + x.getFullYear();
949
+ x1 = x1 + " - " + hours + ":" + minutes + ":" + seconds + " " + ampm;
950
+ $('#clock').html(x1);
951
+ $('#clock').css('line-height', taskbar_height + 'px');
952
+ }
953
+
954
+ setInterval(display_ct, 1000);
955
+
956
+ // show referral notice window
957
+ if(window.show_referral_notice && !user.email_confirmed){
958
+ getItem({
959
+ key: "shown_referral_notice",
960
+ success: async function(res){
961
+ if(!res){
962
+ setTimeout(() => {
963
+ UIWindowClaimReferral();
964
+ }, 1000);
965
+ setItem({
966
+ key: "shown_referral_notice",
967
+ value: true,
968
+ })
969
+ }
970
+ }
971
+ })
972
+ }
973
+
974
+ }
975
+
976
+ $(document).on('contextmenu taphold', '.taskbar', function(event){
977
+ // dismiss taphold on regular devices
978
+ if(event.type==='taphold' && !isMobile.phone && !isMobile.tablet)
979
+ return;
980
+
981
+ event.preventDefault();
982
+ event.stopPropagation();
983
+ UIContextMenu({
984
+ parent_element: $('.taskbar'),
985
+ items: [
986
+ //--------------------------------------------------
987
+ // Show open windows
988
+ //--------------------------------------------------
989
+ {
990
+ html: "Show open windows",
991
+ onClick: function(){
992
+ $(`.window`).showWindow();
993
+ }
994
+ },
995
+ //--------------------------------------------------
996
+ // Show the desktop
997
+ //--------------------------------------------------
998
+ {
999
+ html: "Show the desktop",
1000
+ onClick: function(){
1001
+ $(`.window`).hideWindow();
1002
+ }
1003
+ }
1004
+ ]
1005
+ });
1006
+ return false;
1007
+ })
1008
+
1009
+ $(document).on('click', '.qr-btn', async function (e) {
1010
+ UIWindowQR();
1011
+ })
1012
+
1013
+ $(document).on('click', '.user-options-menu-btn', async function(e){
1014
+ const pos = this.getBoundingClientRect();
1015
+ if($('.context-menu[data-id="user-options-menu"]').length > 0)
1016
+ return;
1017
+
1018
+ let items = [];
1019
+ let parent_element = this;
1020
+ //--------------------------------------------------
1021
+ // Save Session
1022
+ //--------------------------------------------------
1023
+ if(window.user.is_temp){
1024
+ items.push(
1025
+ {
1026
+ html: `Save Session`,
1027
+ icon: `<svg style="margin-bottom: -4px; width: 16px; height: 16px;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="48px" height="48px" viewBox="0 0 48 48"><g transform="translate(0, 0)"><path d="M45.521,39.04L27.527,5.134c-1.021-1.948-3.427-2.699-5.375-1.679-.717,.376-1.303,.961-1.679,1.679L2.479,39.04c-.676,1.264-.635,2.791,.108,4.017,.716,1.207,2.017,1.946,3.42,1.943H41.993c1.403,.003,2.704-.736,3.42-1.943,.743-1.226,.784-2.753,.108-4.017ZM23.032,15h1.937c.565,0,1.017,.467,1,1.031l-.438,14c-.017,.54-.459,.969-1,.969h-1.062c-.54,0-.983-.429-1-.969l-.438-14c-.018-.564,.435-1.031,1-1.031Zm.968,25c-1.657,0-3-1.343-3-3s1.343-3,3-3,3,1.343,3,3-1.343,3-3,3Z" fill="#ffbb00"></path></g></svg>`,
1028
+ icon_active: `<svg style="margin-bottom: -4px; width: 16px; height: 16px;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="48px" height="48px" viewBox="0 0 48 48"><g transform="translate(0, 0)"><path d="M45.521,39.04L27.527,5.134c-1.021-1.948-3.427-2.699-5.375-1.679-.717,.376-1.303,.961-1.679,1.679L2.479,39.04c-.676,1.264-.635,2.791,.108,4.017,.716,1.207,2.017,1.946,3.42,1.943H41.993c1.403,.003,2.704-.736,3.42-1.943,.743-1.226,.784-2.753,.108-4.017ZM23.032,15h1.937c.565,0,1.017,.467,1,1.031l-.438,14c-.017,.54-.459,.969-1,.969h-1.062c-.54,0-.983-.429-1-.969l-.438-14c-.018-.564,.435-1.031,1-1.031Zm.968,25c-1.657,0-3-1.343-3-3s1.343-3,3-3,3,1.343,3,3-1.343,3-3,3Z" fill="#ffbb00"></path></g></svg>`,
1029
+ onClick: async function(){
1030
+ UIWindowSaveAccount({
1031
+ send_confirmation_code: false,
1032
+ default_username: window.user.username
1033
+ });
1034
+ }
1035
+ },
1036
+ )
1037
+ // -------------------------------------------
1038
+ // -
1039
+ // -------------------------------------------
1040
+ items.push('-')
1041
+ }
1042
+
1043
+ // -------------------------------------------
1044
+ // Logged in users
1045
+ // -------------------------------------------
1046
+ if(window.logged_in_users.length > 0){
1047
+ let users_arr = window.logged_in_users;
1048
+
1049
+ // bring logged in user's item to top
1050
+ users_arr.sort(function(x,y){ return x.uuid === window.user.uuid ? -1 : y.uuid == window.user.uuid ? 1 : 0; });
1051
+
1052
+ // create menu items
1053
+ users_arr.forEach(l_user => {
1054
+ items.push(
1055
+ {
1056
+ html: l_user.username,
1057
+ icon: l_user.username === user.username ? '✓' : '',
1058
+ onClick: async function(val){
1059
+ // don't reload everything if clicked on already-logged-in user
1060
+ if(l_user.username === user.username)
1061
+ return;
1062
+ // update auth data
1063
+ update_auth_data(l_user.auth_token, l_user);
1064
+ // refresh
1065
+ location.reload();
1066
+ }
1067
+
1068
+ },
1069
+ )
1070
+ });
1071
+ // -------------------------------------------
1072
+ // -
1073
+ // -------------------------------------------
1074
+ items.push('-')
1075
+
1076
+ items.push(
1077
+ {
1078
+ html: 'Add existing account',
1079
+ // icon: l_user.username === user.username ? '✓' : '',
1080
+ onClick: async function(val){
1081
+ await UIWindowLogin({
1082
+ reload_on_success: true,
1083
+ send_confirmation_code: false,
1084
+ window_options:{
1085
+ has_head: true
1086
+ }
1087
+ });
1088
+ }
1089
+ },
1090
+ )
1091
+
1092
+ // -------------------------------------------
1093
+ // -
1094
+ // -------------------------------------------
1095
+ items.push('-')
1096
+
1097
+ }
1098
+
1099
+ UIContextMenu({
1100
+ id: 'user-options-menu',
1101
+ parent_element: parent_element,
1102
+ position: {top: pos.top + 28, left: pos.left + pos.width - 15},
1103
+ items: [
1104
+ ...items,
1105
+ //--------------------------------------------------
1106
+ // My Websites
1107
+ //--------------------------------------------------
1108
+ {
1109
+ html: "My Websites",
1110
+ onClick: async function(){
1111
+ UIWindowMyWebsites();
1112
+ }
1113
+ },
1114
+ //--------------------------------------------------
1115
+ // Change Username
1116
+ //--------------------------------------------------
1117
+ {
1118
+ html: "Change Username",
1119
+ onClick: async function(){
1120
+ UIWindowChangeUsername();
1121
+ }
1122
+ },
1123
+
1124
+ //--------------------------------------------------
1125
+ // Change Password
1126
+ //--------------------------------------------------
1127
+ {
1128
+ html: "Change Password",
1129
+ onClick: async function(){
1130
+ UIWindowChangePassword();
1131
+ }
1132
+ },
1133
+ //--------------------------------------------------
1134
+ // Contact Us
1135
+ //--------------------------------------------------
1136
+ {
1137
+ html: "Contact Us",
1138
+ onClick: async function(){
1139
+ UIWindowFeedback();
1140
+ }
1141
+ },
1142
+ // -------------------------------------------
1143
+ // -
1144
+ // -------------------------------------------
1145
+ '-',
1146
+
1147
+ //--------------------------------------------------
1148
+ // Log Out
1149
+ //--------------------------------------------------
1150
+ {
1151
+ html: "Log Out",
1152
+ onClick: async function(){
1153
+ // see if there are any open windows, if yes notify user
1154
+ if($('.window-app').length > 0){
1155
+ const alert_resp = await UIAlert({
1156
+ message: `<p>You have open apps. Are you sure you want to log out?</p>`,
1157
+ buttons:[
1158
+ {
1159
+ label: 'Close Windows and Log Out',
1160
+ type: 'primary',
1161
+ },
1162
+ {
1163
+ label: 'Cancel'
1164
+ },
1165
+ ]
1166
+ })
1167
+ if(alert_resp === 'Close Windows and Log Out')
1168
+ logout();
1169
+ }
1170
+ // no open windows
1171
+ else
1172
+ logout();
1173
+ }
1174
+ },
1175
+ ]
1176
+ });
1177
+ })
1178
+
1179
+ $(document).on('click', '.fullscreen-btn', async function (e) {
1180
+ if(!is_fullscreen()) {
1181
+ var elem = document.documentElement;
1182
+ if (elem.requestFullscreen) {
1183
+ elem.requestFullscreen();
1184
+ } else if (elem.webkitRequestFullscreen) { /* Safari */
1185
+ elem.webkitRequestFullscreen();
1186
+ } else if (elem.mozRequestFullScreen) { /* moz */
1187
+ elem.mozRequestFullScreen();
1188
+ } else if (elem.msRequestFullscreen) { /* IE11 */
1189
+ elem.msRequestFullscreen();
1190
+ }
1191
+ }
1192
+ else{
1193
+ if (document.exitFullscreen) {
1194
+ document.exitFullscreen();
1195
+ } else if (document.webkitExitFullscreen) {
1196
+ document.webkitExitFullscreen();
1197
+ } else if (document.mozCancelFullScreen) {
1198
+ document.mozCancelFullScreen();
1199
+ } else if (document.msExitFullscreen) {
1200
+ document.msExitFullscreen();
1201
+ }
1202
+ }
1203
+ })
1204
+
1205
+ $(document).on('click', '.close-launch-popover', function(){
1206
+ $(".launch-popover").closest('.popover').fadeOut(200, function(){
1207
+ $(".launch-popover").closest('.popover').remove();
1208
+ });
1209
+ });
1210
+
1211
+ $(document).on('click', '.toolbar-puter-logo', function(){
1212
+ // launch the about app
1213
+ launch_app({name: 'about', window_options:{
1214
+ single_instance: true,
1215
+ }});
1216
+ })
1217
+
1218
+ $(document).on('click', '.user-options-create-account-btn', async function(e){
1219
+ UIWindowSaveAccount({
1220
+ send_confirmation_code: false,
1221
+ default_username: window.user.username,
1222
+ });
1223
+ })
1224
+
1225
+ $(document).on('click', '.refer-btn', async function(e){
1226
+ UIWindowRefer();
1227
+ })
1228
+
1229
+ $(document).on('click', '.start-app', async function(e){
1230
+ launch_app({
1231
+ name: $(this).attr('data-app-name')
1232
+ })
1233
+ // close popovers
1234
+ $(".popover").fadeOut(200, function(){
1235
+ $(".popover").remove();
1236
+ });
1237
+ })
1238
+
1239
+ $(document).on('click', '.user-options-login-btn', async function(e){
1240
+ const alert_resp = await UIAlert({
1241
+ message: `<strong>Save session before exiting!</strong><p>You are in a temporary session and logging into another account will erase all data in your current session.</p>`,
1242
+ buttons:[
1243
+ {
1244
+ label: 'Save session',
1245
+ value: 'save-session',
1246
+ type: 'primary',
1247
+ },
1248
+ {
1249
+ label: 'Log into another account anyway',
1250
+ value: 'login',
1251
+ },
1252
+ {
1253
+ label: 'Cancel'
1254
+ },
1255
+ ]
1256
+ })
1257
+
1258
+ if(alert_resp === 'save-session'){
1259
+ let saved = await UIWindowSaveAccount({
1260
+ send_confirmation_code: false,
1261
+ });
1262
+ if(saved)
1263
+ UIWindowLogin({show_signup_button: false, reload_on_success: true});
1264
+ }else if (alert_resp === 'login'){
1265
+ UIWindowLogin({
1266
+ show_signup_button: false,
1267
+ reload_on_success: true,
1268
+ window_options: {
1269
+ backdrop: true,
1270
+ close_on_backdrop_click: false,
1271
+ }
1272
+ });
1273
+ }
1274
+ })
1275
+
1276
+ $(document).on('click mousedown', '.launch-search, .launch-popover', function(e){
1277
+ $(this).focus();
1278
+ e.stopPropagation();
1279
+ e.preventDefault();
1280
+ // don't let click bubble up to window
1281
+ e.stopImmediatePropagation();
1282
+ })
1283
+
1284
+ $(document).on('focus', '.launch-search', function(e){
1285
+ // remove all selected items in start menu
1286
+ $('.launch-app-selected').removeClass('launch-app-selected');
1287
+ // scroll popover to top
1288
+ $('.launch-popover').scrollTop(0);
1289
+ })
1290
+
1291
+ $(document).on('change keyup keypress keydown paste', '.launch-search', function(e){
1292
+ // search launch_apps.recommended for query
1293
+ const query = $(this).val().toLowerCase();
1294
+ if(query === ''){
1295
+ $('.launch-search-clear').hide();
1296
+ $(`.start-app-card`).show();
1297
+ $('.launch-apps-recent').show();
1298
+ $('.start-section-heading').show();
1299
+ }else{
1300
+ $('.launch-apps-recent').hide();
1301
+ $('.start-section-heading').hide();
1302
+ $('.launch-search-clear').show();
1303
+ launch_apps.recommended.forEach((app)=>{
1304
+ if(app.title.toLowerCase().includes(query.toLowerCase())){
1305
+ $(`.start-app-card[data-name="${app.name}"]`).show();
1306
+ }else{
1307
+ $(`.start-app-card[data-name="${app.name}"]`).hide();
1308
+ }
1309
+ })
1310
+ }
1311
+ })
1312
+
1313
+ $(document).on('click', '.launch-search-clear', function(e){
1314
+ $('.launch-search').val('');
1315
+ $('.launch-search').trigger('change');
1316
+ $('.launch-search').focus();
1317
+ })
1318
+
1319
+ document.addEventListener('fullscreenchange', (event) => {
1320
+ // document.fullscreenElement will point to the element that
1321
+ // is in fullscreen mode if there is one. If there isn't one,
1322
+ // the value of the property is null.
1323
+ if (document.fullscreenElement) {
1324
+ $('.fullscreen-btn').css('background-image', `url(${window.icons['shrink.svg']})`);
1325
+ $('.fullscreen-btn').attr('title', 'Exit Full Screen');
1326
+ $('#clock').show();
1327
+ } else {
1328
+ $('.fullscreen-btn').css('background-image', `url(${window.icons['fullscreen.svg']})`);
1329
+ $('.fullscreen-btn').attr('title', 'Enter Full Screen');
1330
+ $('#clock').hide();
1331
+ }
1332
+ })
1333
+
1334
+ window.set_desktop_background = function(options){
1335
+ if(options.fit){
1336
+ let fit = options.fit;
1337
+ if(fit === 'cover' || fit === 'contain'){
1338
+ $('body').css('background-size', fit);
1339
+ $('body').css('background-repeat', `no-repeat`);
1340
+ $('body').css('background-position', `center center`);
1341
+ }
1342
+ else if(fit === 'center'){
1343
+ $('body').css('background-size', 'auto');
1344
+ $('body').css('background-repeat', `no-repeat`);
1345
+ $('body').css('background-position', `center center`);
1346
+ }
1347
+
1348
+ else if( fit === 'repeat'){
1349
+ $('body').css('background-size', `auto`);
1350
+ $('body').css('background-repeat', `repeat`);
1351
+ }
1352
+ window.desktop_bg_fit = fit;
1353
+ }
1354
+
1355
+ if(options.url){
1356
+ $('body').css('background-image', `url(${options.url})`);
1357
+ window.desktop_bg_url = options.url;
1358
+ window.desktop_bg_color = undefined;
1359
+ }
1360
+ else if(options.color){
1361
+ $('body').css({
1362
+ 'background-image': `none`,
1363
+ 'background-color': options.color,
1364
+ });
1365
+ window.desktop_bg_color = options.color;
1366
+ window.desktop_bg_url = undefined;
1367
+ }
1368
+ }
1369
+
1370
+ window.update_taskbar = function(){
1371
+ let items = []
1372
+ $('.taskbar-item-sortable[data-keep-in-taskbar="true"]').each(function(index){
1373
+ items.push({
1374
+ name: $( this ).attr('data-app'),
1375
+ type: 'app',
1376
+ })
1377
+ })
1378
+
1379
+ // update taskbar in the server-side
1380
+ $.ajax({
1381
+ url: api_origin + "/update-taskbar-items",
1382
+ type: 'POST',
1383
+ data: JSON.stringify({
1384
+ items: items,
1385
+ }),
1386
+ async: true,
1387
+ contentType: "application/json",
1388
+ headers: {
1389
+ "Authorization": "Bearer "+auth_token
1390
+ },
1391
+ })
1392
+ }
1393
+
1394
+ window.remove_taskbar_item = function(item){
1395
+ $(item).find('*').fadeOut(100, function(){});
1396
+
1397
+ $(item).animate({width: 0}, 200, function(){
1398
+ $(item).remove();
1399
+ })
1400
+ }
1401
+
1402
+ window.enter_fullpage_mode = (el_window)=>{
1403
+ $('.taskbar').hide();
1404
+ $(el_window).find('.window-head').hide();
1405
+ $('body').addClass('fullpage-mode');
1406
+ $(el_window).css({
1407
+ width: '100%',
1408
+ height: '100%',
1409
+ top: toolbar_height + 'px',
1410
+ left: 0,
1411
+ 'border-radius': 0,
1412
+ });
1413
+ }
1414
+
1415
+ window.exit_fullpage_mode = (el_window)=>{
1416
+ $('body').removeClass('fullpage-mode');
1417
+ window.taskbar_height = window.default_taskbar_height;
1418
+ $('.taskbar').css('height', window.taskbar_height);
1419
+ $('.taskbar').show();
1420
+ refresh_item_container($('.desktop.item-container'), {fadeInItems: true});
1421
+ $(el_window).removeAttr('data-is_fullpage');
1422
+ if(el_window){
1423
+ reset_window_size_and_position(el_window)
1424
+ $(el_window).find('.window-head').show();
1425
+ }
1426
+
1427
+ // reset dektop height to take into account the taskbar height
1428
+ $('.desktop').css('height', `calc(100vh - ${window.taskbar_height + window.toolbar_height}px)`);
1429
+
1430
+ // hide the 'Show Desktop' button in toolbar
1431
+ $('.show-desktop-btn').hide();
1432
+
1433
+ // refresh desktop background
1434
+ refresh_desktop_background();
1435
+ }
1436
+
1437
+ window.reset_window_size_and_position = (el_window)=>{
1438
+ $(el_window).css({
1439
+ width: 680,
1440
+ height: 380,
1441
+ 'border-radius': window_border_radius,
1442
+ top: 'calc(50% - 190px)',
1443
+ left: 'calc(50% - 340px)',
1444
+ });
1445
+ }
1446
+
1447
+ export default UIDesktop;
src/UI/UIItem.js ADDED
@@ -0,0 +1,1620 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindowPublishWebsite from './UIWindowPublishWebsite.js';
21
+ import UIWindowItemProperties from './UIWindowItemProperties.js';
22
+ import UIWindowGetCopyLink from './UIWindowGetCopyLink.js';
23
+ import UIWindowSaveAccount from './UIWindowSaveAccount.js';
24
+ import UIPopover from './UIPopover.js';
25
+ import UIWindowEmailConfirmationRequired from './UIWindowEmailConfirmationRequired.js';
26
+ import UIContextMenu from './UIContextMenu.js'
27
+ import UIAlert from './UIAlert.js'
28
+ import path from "../lib/path.js"
29
+
30
+ function UIItem(options){
31
+ const matching_appendto_count = $(options.appendTo).length;
32
+ if(matching_appendto_count > 1){
33
+ $(options.appendTo).each(function(){
34
+ const opts = options;
35
+ opts.appendTo = this;
36
+ UIItem(opts);
37
+ })
38
+ return;
39
+ }else if(matching_appendto_count === 0){
40
+ return;
41
+ }
42
+
43
+ const item_id = global_element_id++;
44
+ let last_mousedown_ts = 999999999999999;
45
+ let rename_cancelled = false;
46
+
47
+ // set options defaults
48
+ options.disabled = options.disabled ?? false;
49
+ options.is_dir = options.is_dir ?? false;
50
+ options.is_selected = options.is_selected ?? false;
51
+ options.is_shared = options.is_shared ?? false;
52
+ options.is_shortcut = options.is_shortcut ?? 0;
53
+ options.is_trash = options.is_trash ?? false;
54
+ options.metadata = options.metadata ?? '';
55
+ options.multiselectable = options.multiselectable ?? true;
56
+ options.shortcut_to = options.shortcut_to ?? '';
57
+ options.shortcut_to_path = options.shortcut_to_path ?? '';
58
+ options.immutable = (options.immutable === false || options.immutable === 0 || options.immutable === undefined ? 0 : 1);
59
+ options.sort_container_after_append = (options.sort_container_after_append !== undefined ? options.sort_container_after_append : false);
60
+ const is_shared_with_me = (options.path !== '/'+window.user.username && !options.path.startsWith('/'+window.user.username+'/'));
61
+
62
+ let website_url = determine_website_url(options.path);
63
+
64
+ // do a quick check to see if the target parent has any file type restrictions
65
+ const appendto_allowed_file_types = $(options.appendTo).attr('data-allowed_file_types')
66
+ if(!window.check_fsentry_against_allowed_file_types_string({is_dir: options.is_dir, name:options.name, type:options.type}, appendto_allowed_file_types))
67
+ options.disabled = true;
68
+
69
+ // --------------------------------------------------------
70
+ // HTML for Item
71
+ // --------------------------------------------------------
72
+ let h = '';
73
+ h += `<div id="item-${item_id}"
74
+ class="item${options.is_selected ? ' item-selected':''} ${options.disabled ? 'item-disabled':''}"
75
+ data-id="${item_id}"
76
+ data-name="${html_encode(options.name)}"
77
+ data-metadata="${html_encode(options.metadata)}"
78
+ data-uid="${options.uid}"
79
+ data-is_dir="${options.is_dir ? 1 : 0}"
80
+ data-is_trash="${options.is_trash ? 1 : 0}"
81
+ data-has_website="${options.has_website ? 1 : 0 }"
82
+ data-website_url = "${website_url ? html_encode(website_url) : ''}"
83
+ data-immutable="${options.immutable}"
84
+ data-is_shortcut = "${options.is_shortcut}"
85
+ data-shortcut_to = "${html_encode(options.shortcut_to)}"
86
+ data-shortcut_to_path = "${html_encode(options.shortcut_to_path)}"
87
+ data-sortable = "${options.sortable ?? 'true'}"
88
+ data-sort_by = "${html_encode(options.sort_by) ?? 'name'}"
89
+ data-size = "${options.size ?? ''}"
90
+ data-type = "${html_encode(options.type) ?? ''}"
91
+ data-modified = "${options.modified ?? ''}"
92
+ data-associated_app_name = "${html_encode(options.associated_app_name) ?? ''}"
93
+ data-path="${html_encode(options.path)}">`;
94
+
95
+ // spinner
96
+ h += `<div class="item-spinner">`;
97
+ h += `</div>`;
98
+ // modified
99
+ h += `<div class="item-attr item-attr--modified">`;
100
+ h += `<span>${options.modified === 0 ? '-' : timeago.format(options.modified*1000)}</span>`;
101
+ h += `</div>`;
102
+ // size
103
+ h += `<div class="item-attr item-attr--size">`;
104
+ h += `<span>${options.size ? byte_format(options.size) : '-'}</span>`;
105
+ h += `</div>`;
106
+ // type
107
+ h += `<div class="item-attr item-attr--type">`;
108
+ if(options.is_dir)
109
+ h += `<span>Folder</span>`;
110
+ else
111
+ h += `<span>${options.type ? html_encode(options.type) : '-'}</span>`;
112
+ h += `</div>`;
113
+
114
+
115
+ // icon
116
+ h += `<div class="item-icon">`;
117
+ h += `<img src="${html_encode(options.icon.image)}" class="item-icon-${options.icon.type}" data-item-id="${item_id}">`;
118
+ h += `</div>`;
119
+ // badges
120
+ h += `<div class="item-badges">`;
121
+ // website badge
122
+ h += `<img class="item-badge item-has-website-badge long-hover"
123
+ style="${options.has_website ? 'display:block;' : ''}"
124
+ src="${html_encode(window.icons['world.svg'])}"
125
+ data-item-id="${item_id}"
126
+ >`;
127
+ // link badge
128
+ h += `<img class="item-badge item-has-website-url-badge"
129
+ style="${website_url ? 'display:block;' : ''}"
130
+ src="${html_encode(window.icons['link.svg'])}"
131
+ data-item-id="${item_id}"
132
+ >`;
133
+
134
+ // shared badge
135
+ h += `<img class="item-badge item-badge-has-permission"
136
+ style="display: ${ is_shared_with_me ? 'block' : 'none'};
137
+ background-color: #ffffff;
138
+ padding: 2px;" src="${html_encode(window.icons['shared.svg'])}"
139
+ data-item-id="${item_id}"
140
+ title="A user has shared this item with you.">`;
141
+ // owner-shared badge
142
+ h += `<img class="item-badge item-is-shared"
143
+ style="background-color: #ffffff; padding: 2px; ${!is_shared_with_me && options.is_shared ? 'display:block;' : ''}"
144
+ src="${html_encode(window.icons['owner-shared.svg'])}"
145
+ data-item-id="${item_id}"
146
+ data-item-uid="${options.uid}"
147
+ data-item-path="${html_encode(options.path)}"
148
+ title="You have shared this item with at least one other user."
149
+ >`;
150
+ // shortcut badge
151
+ h += `<img class="item-badge item-shortcut"
152
+ style="background-color: #ffffff; padding: 2px; ${options.is_shortcut !== 0 ? 'display:block;' : ''}"
153
+ src="${html_encode(window.icons['shortcut.svg'])}"
154
+ data-item-id="${item_id}"
155
+ title="Shortcut"
156
+ >`;
157
+
158
+ h += `</div>`;
159
+
160
+ // name
161
+ h += `<span class="item-name" data-item-id="${item_id}" title="${html_encode(options.name)}">${html_encode(truncate_filename(options.name, TRUNCATE_LENGTH)).replaceAll(' ', '&nbsp;')}</span>`
162
+ // name editor
163
+ h += `<textarea class="item-name-editor hide-scrollbar" spellcheck="false" autocomplete="off" autocorrect="off" autocapitalize="off" data-gramm_editor="false">${html_encode(options.name)}</textarea>`
164
+ h += `</div>`;
165
+
166
+ // append to options.appendTo
167
+ $(options.appendTo).append(h);
168
+
169
+ // updte item_container
170
+ const item_container = $(options.appendTo).closest('.item-container');
171
+ show_or_hide_empty_folder_message(item_container);
172
+
173
+ // get all the elements needed
174
+ const el_item = document.getElementById(`item-${item_id}`);
175
+ const el_item_name = document.querySelector(`#item-${item_id} > .item-name`);
176
+ const el_item_icon = document.querySelector(`#item-${item_id} .item-icon`);
177
+ const el_item_name_editor = document.querySelector(`#item-${item_id} > .item-name-editor`);
178
+ const is_trashed = $(el_item).attr('data-path').startsWith(trash_path + '/');
179
+
180
+ // update parent window's explorer item count if applicable
181
+ if(options.appendTo !== undefined){
182
+ let el_window = options.appendTo;
183
+ if(!$(el_window).hasClass('.window'))
184
+ el_window = $(el_window).closest('.window');
185
+
186
+ update_explorer_footer_item_count(el_window);
187
+ }
188
+
189
+ // --------------------------------------------------------
190
+ // Dragster
191
+ // allow dragging of local files on this window, if it's is_dir
192
+ // --------------------------------------------------------
193
+ if(options.is_dir){
194
+ $(el_item).dragster({
195
+ enter: function () {
196
+ $(el_item).not('.item-disabled').addClass('item-selected');
197
+ },
198
+ leave: function () {
199
+ $(el_item).removeClass('item-selected');
200
+ },
201
+ drop: function (dragsterEvent, event) {
202
+ const e = event.originalEvent;
203
+ $(el_item).removeClass('item-selected');
204
+ // if files were dropped...
205
+ if(e.dataTransfer?.items?.length > 0){
206
+ upload_items( e.dataTransfer.items, $(el_item).attr('data-path'))
207
+ }
208
+
209
+ e.stopPropagation();
210
+ e.preventDefault();
211
+ return false;
212
+ }
213
+ });
214
+ }
215
+
216
+ // --------------------------------------------------------
217
+ // Draggable
218
+ // --------------------------------------------------------
219
+ let longer_hover_timeout;
220
+ let last_window_dragged_over;
221
+
222
+ $(el_item).draggable({
223
+ appendTo: "body",
224
+ helper: "clone",
225
+ revert: "invalid",
226
+ //containment: "document",
227
+ zIndex: 10000,
228
+ scroll:false,
229
+ distance: 5,
230
+ revertDuration: 100,
231
+ start: function(event, ui) {
232
+ // select this item and its helper
233
+ $(el_item).addClass('item-selected');
234
+ $('.ui-draggable-dragging').addClass('item-selected');
235
+ //clone other selected items
236
+ $(el_item)
237
+ .siblings('.item-selected')
238
+ .clone()
239
+ .addClass('item-selected-clone')
240
+ .css('position', 'absolute')
241
+ .appendTo('body')
242
+ .hide();
243
+
244
+ // Bring item and clones to front
245
+ $('.item-selected-clone, .ui-draggable-dragging').css('z-index', 99999);
246
+
247
+ // count badge
248
+ const item_count = $('.item-selected-clone').length;
249
+ if(item_count > 0){
250
+ $('body').append(`<span class="draggable-count-badge">${item_count + 1}</span>`);
251
+ }
252
+
253
+ // Disable all droppable UIItems that are not a dir/app to avoid accidental cancellation
254
+ // on Items that are not droppables. In general if an item is dropped on another, if the
255
+ // target is not a dir, the source needs to be dropped on the target's container.
256
+ $(`.item[data-is_dir="0"][data-associated_app_name=""]:not(.item-selected)`).droppable('disable');
257
+
258
+ // Disable pointer events on all app iframes. This is needed because as soon as
259
+ // a dragging event enters the iframe the event is delegated to iframe which makes the item
260
+ // stuck at the edge of the iframe not allowing us to move items freely across the screen
261
+ $('.window-app-iframe').css('pointer-events', 'none')
262
+
263
+ // reset longer hover timeout and last window dragged over
264
+ longer_hover_timeout = null;
265
+ last_window_dragged_over = null;
266
+ },
267
+ drag: function(event, ui) {
268
+ // Only show drag helpers if the item has been moved more than 5px
269
+ if( Math.abs(ui.originalPosition.top - ui.offset.top) > 5
270
+ ||
271
+ Math.abs(ui.originalPosition.left - ui.offset.left) > 5 ){
272
+ $('.ui-draggable-dragging').show();
273
+ $('.item-selected-clone').show();
274
+ $('.draggable-count-badge').show();
275
+ }
276
+
277
+ const other_selected_items = $('.item-selected-clone');
278
+ const item_count = other_selected_items.length + 1;
279
+
280
+ // Move count badge with mouse
281
+ $('.draggable-count-badge').css({
282
+ top: event.pageY,
283
+ left: event.pageX + 10,
284
+ })
285
+
286
+ // Move other selected items
287
+ for(let i=0; i < item_count - 1; i++){
288
+ $(other_selected_items[i]).css({
289
+ 'left': ui.position.left + 3 * (i+1),
290
+ 'top': ui.position.top + 3 * (i+1),
291
+ 'z-index': 999 - (i),
292
+ 'opacity': 0.5 - i*0.1,
293
+ })
294
+ }
295
+
296
+ // remove all item-container active borders
297
+ $('.item-container').removeClass('item-container-active');
298
+
299
+ // if item has changed container, remove timeout for window focus and reset last target
300
+ if(longer_hover_timeout && last_window_dragged_over !== window.mouseover_window){
301
+ clearTimeout(longer_hover_timeout);
302
+ longer_hover_timeout = null;
303
+ last_window_dragged_over = window.mouseover_window;
304
+ }
305
+
306
+ // if item hover for more than 1.2s, focus the window
307
+ if(!longer_hover_timeout){
308
+ longer_hover_timeout = setTimeout(() => {
309
+ $(last_window_dragged_over).focusWindow();
310
+ }, 1200);
311
+ }
312
+
313
+ // Highlight item container to help user see more clearly where the item is going to be dropped
314
+ if($(window.mouseover_item_container).closest('.window').is(window.mouseover_window) &&
315
+ // do not highlight if the target is the same as the item being moved
316
+ $(el_item).attr('data-path') !== $(window.mouseover_item_container).attr('data-path') &&
317
+ // do not highlight if item is being moved to where it already is
318
+ $(el_item).attr('data-path') !== $(window.mouseover_item_container).attr('data-path')){
319
+
320
+ // highlight item container
321
+ $(window.mouseover_item_container).addClass('item-container-active');
322
+ }
323
+
324
+ // send drag event to iframe if mouse is inside iframe
325
+ if(mouseover_window){
326
+ const $app_iframe = $(mouseover_window).find('.window-app-iframe');
327
+ if(!$(mouseover_window).hasClass('window-disabled') && $app_iframe.length > 0){
328
+ var rect = $app_iframe.get(0).getBoundingClientRect();
329
+ // if mouse is inside iframe, send drag message to iframe
330
+ if(mouseX > rect.left && mouseX < rect.right && mouseY > rect.top && mouseY < rect.bottom){
331
+ $app_iframe.get(0).contentWindow.postMessage({msg: "drag", x: (mouseX - rect.left), y: (mouseY - rect.top)}, '*');
332
+ }
333
+ }
334
+ }
335
+ },
336
+ stop: function(event, ui){
337
+ $('.item-selected-clone').remove();
338
+ $('.draggable-count-badge').remove();
339
+ // re-enable all droppable UIItems that are not a dir
340
+ $(`.item[data-is_dir='0']:not(.item-selected)`).droppable('enable');
341
+ // remove active item-container border highlights
342
+ $('.item-container').removeClass('item-container-active');
343
+ // reset longer hover timeout and last window dragged over
344
+ clearTimeout(longer_hover_timeout);
345
+ last_window_dragged_over = null;
346
+ }
347
+ });
348
+
349
+ // --------------------------------------------------------
350
+ // Droppable
351
+ // --------------------------------------------------------
352
+ $(el_item).droppable({
353
+ accept: '.item',
354
+ // 'pointer' is very important because of active window tracking is based on the position of cursor.
355
+ tolerance: 'pointer',
356
+ drop: async function( event, ui ) {
357
+ // Check if hovering over an item that is VISIBILE
358
+ if($(event.target).closest('.window').attr('data-id') !== $(mouseover_window).attr('data-id'))
359
+ return;
360
+
361
+ // If ctrl is pressed and source is Trashed, cancel whole operation
362
+ if(event.ctrlKey && path.dirname($(ui.draggable).attr('data-path')) === window.trash_path)
363
+ return;
364
+
365
+ const items_to_move = []
366
+
367
+ // First item
368
+ items_to_move.push(ui.draggable);
369
+
370
+ // All subsequent items
371
+ const cloned_items = document.getElementsByClassName('item-selected-clone');
372
+ for(let i =0; i<cloned_items.length; i++){
373
+ const source_item = document.getElementById('item-' + $(cloned_items[i]).attr('data-id'));
374
+ if(source_item !== null)
375
+ items_to_move.push(source_item);
376
+ }
377
+
378
+ // --------------------------------------------------------
379
+ // If dropped on an app, open the app with the dropped
380
+ // items as argument
381
+ //--------------------------------------------------------
382
+ if(options.associated_app_name){
383
+ // an array that hold the items to sign
384
+ const items_to_open = [];
385
+
386
+ // prepare items to sign
387
+ for(let i=0; i < items_to_move.length; i++){
388
+ items_to_open.push({
389
+ name: $(items_to_move[i]).attr('data-name'),
390
+ uid: $(items_to_move[i]).attr('data-uid'),
391
+ action: 'write',
392
+ path: $(items_to_move[i]).attr('data-path')
393
+ });
394
+ }
395
+
396
+ // open each item
397
+ for (let i = 0; i < items_to_open.length; i++) {
398
+ const item = items_to_open[i];
399
+ launch_app({
400
+ name: options.associated_app_name,
401
+ file_path: item.path,
402
+ // app_obj: open_item_meta.suggested_apps[0],
403
+ window_title: item.name,
404
+ file_uid: item.uid,
405
+ file_signature: item,
406
+ });
407
+ }
408
+
409
+ // deselect dragged item
410
+ for(let i=0; i < items_to_move.length; i++)
411
+ $(items_to_move[i]).removeClass('item-selected');
412
+ }
413
+ //--------------------------------------------------------
414
+ // If dropped on a directory, move items to that directory
415
+ //--------------------------------------------------------
416
+ else{
417
+ // If ctrl key is down, copy items. Except if target or source is Trash
418
+ if(event.ctrlKey){
419
+ if(options.is_dir && $(el_item).attr('data-path') !== window.trash_path )
420
+ copy_items(items_to_move, $(el_item).attr('data-path'))
421
+ else if(!options.is_dir)
422
+ copy_items(items_to_move, path.dirname($(el_item).attr('data-path')));
423
+ }
424
+ // If alt key is down, create shortcut items
425
+ else if(event.altKey && window.feature_flags.create_shortcut){
426
+ items_to_move.forEach((item_to_move) => {
427
+ create_shortcut(
428
+ path.basename($(item_to_move).attr('data-path')),
429
+ $(item_to_move).attr('data-is_dir') === '1',
430
+ options.is_dir ? $(el_item).attr('data-path') : path.dirname($(el_item).attr('data-path')),
431
+ null,
432
+ $(item_to_move).attr('data-shortcut_to') === '' ? $(item_to_move).attr('data-uid') : $(item_to_move).attr('data-shortcut_to'),
433
+ $(item_to_move).attr('data-shortcut_to_path') === '' ? $(item_to_move).attr('data-path') : $(item_to_move).attr('data-shortcut_to_path'),
434
+ );
435
+ });
436
+ }
437
+ // Otherwise, move items
438
+ else if(options.is_dir){
439
+ move_items(items_to_move, $(el_item).attr('data-shortcut_to_path') !== '' ? $(el_item).attr('data-shortcut_to_path') : $(el_item).attr('data-path'));
440
+ }
441
+ }
442
+
443
+ // Re-enable droppable on all 'item-container's
444
+ $('.item-container').droppable('enable')
445
+
446
+ return false;
447
+ },
448
+ over: function(event, ui){
449
+ // Check hovering over an item that is VISIBILE
450
+ const $event_parent_win = $(event.target).closest('.window')
451
+ if( $event_parent_win.length > 0 && $event_parent_win.attr('data-id') !== $(mouseover_window).attr('data-id'))
452
+ return;
453
+ // Don't do anything if the dragged item is NOT a UIItem
454
+ if(!$(ui.draggable).hasClass('item'))
455
+ return;
456
+ // If this is a directory or an app, and an item was dragged over it, highlight it.
457
+ if(options.is_dir || options.associated_app_name){
458
+ $(el_item).addClass('item-selected');
459
+ $('.ui-draggable-dragging .item-name, .item-selected-clone .item-name').css('opacity', 0.1)
460
+ // remove all item-container active borders
461
+ $('.item-container').addClass('item-container-transparent-border')
462
+ }
463
+ // Disable all window bodies
464
+ $('.item-container').droppable( 'disable' )
465
+ },
466
+ out: function(event, ui){
467
+ // Don't do anything if the dragged item is NOT a UIItem
468
+ if(!$(ui.draggable).hasClass('item'))
469
+ return;
470
+
471
+ // Unselect directory/app if item is dragged out
472
+ if(options.is_dir || options.associated_app_name){
473
+ $(el_item).removeClass('item-selected');
474
+ $('.ui-draggable-dragging .item-name, .item-selected-clone .item-name').css('opacity', 'initial')
475
+ $('.item-container').removeClass('item-container-transparent-border')
476
+ }
477
+ $('.item-container').droppable( 'enable' )
478
+ }
479
+ });
480
+
481
+ // --------------------------------------------------------
482
+ // Double Click/Single Tap on Item
483
+ // --------------------------------------------------------
484
+ if(isMobile.phone || isMobile.tablet){
485
+ $(el_item).on('click', async function (e) {
486
+ // if item is disabled, do not allow any action
487
+ if($(el_item).hasClass('item-disabled'))
488
+ return false;
489
+
490
+ if($(e.target).hasClass('item-name-editor'))
491
+ return false;
492
+
493
+ open_item({
494
+ item: el_item,
495
+ maximized: true,
496
+ });
497
+ });
498
+
499
+ }else{
500
+ $(el_item).on('dblclick', async function (e) {
501
+ // if item is disabled, do not allow any action
502
+ if($(el_item).hasClass('item-disabled'))
503
+ return false;
504
+
505
+ if($(e.target).hasClass('item-name-editor'))
506
+ return false;
507
+
508
+ open_item({
509
+ item: el_item,
510
+ new_window: e.metaKey || e.ctrlKey,
511
+ });
512
+ });
513
+ }
514
+
515
+ // --------------------------------------------------------
516
+ // Mousedown
517
+ // --------------------------------------------------------
518
+ $(el_item).on('mousedown', function (e) {
519
+ // if item is disabled, do not allow any action
520
+ if($(el_item).hasClass('item-disabled'))
521
+ return false;
522
+
523
+ // if link badge is clicked, don't continue
524
+ if($(e.target).hasClass('item-has-website-url-badge'))
525
+ return false;
526
+
527
+ const $el_parent_window = $(el_item).closest('.window');
528
+
529
+ // first see if this is a ContextMenu call on multiple items
530
+ if(e.which === 3 && $(el_item).hasClass('item-selected') && $(el_item).siblings('.item-selected').length > 0){
531
+ $(".context-menu").remove();
532
+ return false;
533
+ }
534
+
535
+ // unselect other items if neither CTRL nor Command key are held
536
+ // or
537
+ // if parent is not multiselectable
538
+ if((!e.ctrlKey && !e.metaKey && !$(this).hasClass('item-selected')) || ($el_parent_window.length>0 && $el_parent_window.attr('data-multiselectable') !== 'true')){
539
+ $(this).closest('.item-container').find('.item-selected').removeClass('item-selected');
540
+ }
541
+ if((e.ctrlKey || e.metaKey) && $(this).hasClass('item-selected')){
542
+ $(this).removeClass('item-selected')
543
+ }
544
+ else{
545
+ $(this).addClass('item-selected')
546
+ }
547
+ update_explorer_footer_selected_items_count($el_parent_window)
548
+ });
549
+ // --------------------------------------------------------
550
+ // Click
551
+ // --------------------------------------------------------
552
+ $(el_item).on('click', function (e) {
553
+ // if item is disabled, do not allow any action
554
+ if($(el_item).hasClass('item-disabled'))
555
+ return false;
556
+
557
+ skip_a_rename_click = false;
558
+ const $el_parent_window = $(el_item).closest('.window');
559
+
560
+ // do not unselect other items if:
561
+ // CTRL/Command key is pressed or clicking an item that is already selected
562
+ if(!e.ctrlKey && !e.metaKey){
563
+ $(this).closest('.item-container').find('.item-selected').not(this).removeClass('item-selected');
564
+ update_explorer_footer_selected_items_count($el_parent_window)
565
+ }
566
+ //----------------------------------------------------------------
567
+ // On an OpenFileDialog?
568
+ //----------------------------------------------------------------
569
+ if($el_parent_window.attr('data-is_openFileDialog') === 'true'){
570
+ if(!options.is_dir)
571
+ $el_parent_window.find('.openfiledialog-open-btn').removeClass('disabled');
572
+ else
573
+ $el_parent_window.find('.openfiledialog-open-btn').addClass('disabled');
574
+ }
575
+ //----------------------------------------------------------------
576
+ // On a SaveFileDialog?
577
+ //----------------------------------------------------------------
578
+ if($el_parent_window.attr('data-is_saveFileDialog') === 'true' && !options.is_dir){
579
+ $el_parent_window.find('.savefiledialog-filename').val($(el_item).attr('data-name'));
580
+ $el_parent_window.find('.savefiledialog-save-btn').removeClass('disabled');
581
+ }
582
+ });
583
+
584
+ $(document).on('click', function(e){
585
+ if(!$(e.target).hasClass('item') && !$(e.target).hasClass('item-name') && !$(e.target).hasClass('item-icon')){
586
+ skip_a_rename_click = true;
587
+ }
588
+
589
+ if($(e.target).parents('.item').data('id') !== item_id){
590
+ skip_a_rename_click = true;
591
+ }
592
+ })
593
+
594
+ // --------------------------------------------------------
595
+ // Rename
596
+ // --------------------------------------------------------
597
+ function rename(){
598
+ if(rename_cancelled){
599
+ rename_cancelled = false;
600
+ return;
601
+ }
602
+
603
+ const old_name = $(el_item).attr('data-name');
604
+ const old_path = $(el_item).attr('data-path');
605
+ const new_name = $(el_item_name_editor).val();
606
+
607
+ // Don't send a rename request if:
608
+ // the new name is the same as the old one,
609
+ // or it's empty,
610
+ // or editable was not even active at all
611
+ if(old_name === new_name || !new_name || new_name === '.' || new_name === '..' || !$(el_item_name_editor).hasClass('item-name-editor-active')){
612
+ if(new_name === '.'){
613
+ UIAlert(`The name "." is not allowed, because it is a reserved name. Please choose another name.`);
614
+ }
615
+ else if(new_name === '..'){
616
+ UIAlert(`The name ".." is not allowed, because it is a reserved name. Please choose another name.`)
617
+ }
618
+
619
+ $(el_item_name).html(truncate_filename(options.name, TRUNCATE_LENGTH).replaceAll(' ', '&nbsp;'));
620
+ $(el_item_name).show();
621
+ $(el_item_name_editor).val($(el_item).attr('data-name'));
622
+ $(el_item_name_editor).hide();
623
+ return;
624
+ }
625
+ // deactivate item name editable
626
+ $(el_item_name_editor).removeClass('item-name-editor-active');
627
+
628
+ // Perform rename request
629
+ puter.fs.rename({
630
+ uid: options.uid === 'null' ? null : options.uid,
631
+ new_name: new_name,
632
+ excludeSocketID: window.socket.id,
633
+ success: async (fsentry)=>{
634
+ // Has the extension changed? in that case update options.sugggested_apps
635
+ const old_extension = path.extname(old_name);
636
+ const new_extension = path.extname(new_name);
637
+ if(old_extension !== new_extension){
638
+ suggest_apps_for_fsentry({
639
+ uid: options.uid,
640
+ onSuccess: function(suggested_apps){
641
+ options.suggested_apps = suggested_apps;
642
+ }
643
+ });
644
+ }
645
+
646
+ // Set new item name
647
+ $(`.item[data-uid='${$(el_item).attr('data-uid')}'] .item-name`).html(html_encode(truncate_filename(new_name, TRUNCATE_LENGTH)).replaceAll(' ', '&nbsp;'));
648
+ $(el_item_name).show();
649
+
650
+ // Hide item name editor
651
+ $(el_item_name_editor).hide();
652
+
653
+ // Set new icon
654
+ const new_icon = (options.is_dir ? window.icons['folder.svg'] : (await item_icon(fsentry)).image);
655
+ $(el_item_icon).find('.item-icon-icon').attr('src', new_icon);
656
+
657
+ // Set new data-name
658
+ options.name = new_name;
659
+ $(el_item).attr('data-name', html_encode(new_name));
660
+ $(`.item[data-uid='${$(el_item).attr('data-uid')}']`).attr('data-name', html_encode(new_name));
661
+ $(`.window-${options.uid}`).attr('data-name', html_encode(new_name));
662
+
663
+ // Set new title attribute
664
+ $(`.item[data-uid='${$(el_item).attr('data-uid')}']`).attr('title', html_encode(new_name));
665
+ $(`.window-${options.uid}`).attr('title', html_encode(new_name));
666
+
667
+ // Set new value for item-name-editor
668
+ $(`.item[data-uid='${$(el_item).attr('data-uid')}'] .item-name-editor`).val(html_encode(new_name));
669
+ $(`.item[data-uid='${$(el_item).attr('data-uid')}'] .item-name`).attr('title', html_encode(new_name));
670
+
671
+ // Set new data-path
672
+ options.path = path.join( path.dirname(options.path), options.name);
673
+ const new_path = options.path;
674
+ $(el_item).attr('data-path', new_path);
675
+ $(`.item[data-uid='${$(el_item).attr('data-uid')}']`).attr('data-path', new_path);
676
+ $(`.window-${options.uid}`).attr('data-path', new_path);
677
+
678
+ // Update all elements that have matching paths
679
+ $(`[data-path="${html_encode(old_path)}" i]`).each(function(){
680
+ $(this).attr('data-path', new_path)
681
+ if($(this).hasClass('window-navbar-path-dirname'))
682
+ $(this).text(new_name);
683
+ });
684
+
685
+ // Update the paths of all elements whose paths start with old_path
686
+ $(`[data-path^="${html_encode(old_path) + '/'}"]`).each(function(){
687
+ const new_el_path = _.replace($(this).attr('data-path'), old_path + '/', new_path+'/');
688
+ $(this).attr('data-path', new_el_path);
689
+ });
690
+
691
+ // Update the 'Sites Cache'
692
+ if($(el_item).attr('data-has_website') === '1')
693
+ await update_sites_cache();
694
+
695
+ // Update website_url
696
+ website_url = determine_website_url(new_path);
697
+ $(el_item).attr('data-website_url', website_url);
698
+
699
+ // Update all exact-matching windows
700
+ $(`.window-${options.uid}`).each(function(){
701
+ update_window_path(this, options.path);
702
+ })
703
+
704
+ // Set new name for corresponding open windows
705
+ $(`.window-${options.uid} .window-head-title`).text(new_name);
706
+
707
+ // Re-sort all matching item containers
708
+ $(`.item[data-uid='${$(el_item).attr('data-uid')}']`).parent('.item-container').each(function(){
709
+ sort_items(this, $(el_item).closest('.item-container').attr('data-sort_by'), $(el_item).closest('.item-container').attr('data-sort_order'));
710
+ })
711
+ },
712
+ error: function (err){
713
+ // reset to old name
714
+ $(el_item_name).text(truncate_filename(options.name, TRUNCATE_LENGTH));
715
+ $(el_item_name).show();
716
+
717
+ // hide item name editor
718
+ $(el_item_name_editor).hide();
719
+ $(el_item_name_editor).val(html_encode($(el_item).attr('data-name')));
720
+
721
+ //show error
722
+ if(err.message){
723
+ UIAlert(err.message)
724
+ }
725
+ },
726
+ });
727
+ }
728
+
729
+ // --------------------------------------------------------
730
+ // Rename if enter pressed on Item Name Editor
731
+ // --------------------------------------------------------
732
+ $(el_item_name_editor).on('keypress',function(e) {
733
+ // If name editor is not active don't continue
734
+ if(!$(el_item_name_editor).is(":visible"))
735
+ return;
736
+
737
+ // Enter key = rename
738
+ if(e.which === 13) {
739
+ e.stopPropagation();
740
+ e.preventDefault();
741
+ $(el_item_name_editor).blur();
742
+ $(el_item).addClass('item-selected');
743
+ last_enter_pressed_to_rename_ts = Date.now();
744
+ update_explorer_footer_selected_items_count($(el_item).closest('.item-container'));
745
+ return false;
746
+ }
747
+ })
748
+
749
+ // --------------------------------------------------------
750
+ // Cancel and undo if escape pressed on Item Name Editor
751
+ // --------------------------------------------------------
752
+ $(el_item_name_editor).on('keyup',function(e) {
753
+ if(!$(el_item_name_editor).is(":visible"))
754
+ return;
755
+
756
+ // Escape = undo rename
757
+ else if(e.which === 27){
758
+ e.stopPropagation();
759
+ e.preventDefault();
760
+ rename_cancelled = true;
761
+ $(el_item_name_editor).hide();
762
+ $(el_item_name_editor).val(options.name);
763
+ $(el_item_name).show();
764
+ }
765
+ });
766
+
767
+ $(el_item_name_editor).on('focusout',function(e) {
768
+ e.stopPropagation();
769
+ e.preventDefault();
770
+ rename();
771
+ });
772
+
773
+ /************************************************
774
+ * Takes care of 'click to edit item name'
775
+ ************************************************/
776
+ let skip_a_rename_click = true;
777
+ $(el_item_name).on('click', function(e){
778
+ if( !skip_a_rename_click && e.which !== 3 && $(el_item_name).parent('.item-selected').length > 0){
779
+ last_mousedown_ts = Date.now();
780
+ setTimeout(() => {
781
+ if(!skip_a_rename_click && (Date.now() - last_mousedown_ts) > 400){
782
+ if (!e.ctrlKey && !e.metaKey)
783
+ activate_item_name_editor(el_item)
784
+ last_mousedown_ts = 0
785
+ }else{
786
+ last_mousedown_ts = Date.now() + 500;
787
+ skip_a_rename_click= false;
788
+ }
789
+ }, 500);
790
+ }
791
+ skip_a_rename_click = false;
792
+ })
793
+ $(el_item_name).on('dblclick', function(e){
794
+ skip_a_rename_click = true;
795
+ })
796
+
797
+ // --------------------------------------------------------
798
+ // ContextMenu
799
+ // --------------------------------------------------------
800
+ $(el_item).bind("contextmenu taphold", async function (event) {
801
+ // if item is disabled, do not allow any action
802
+ if($(el_item).hasClass('item-disabled'))
803
+ return false;
804
+
805
+ // if on website link badge, don't continue
806
+ if($(event.target).hasClass('item-has-website-url-badge'))
807
+ return false;
808
+
809
+ // dimiss taphold on regular devices
810
+ if(event.type==='taphold' && !isMobile.phone && !isMobile.tablet)
811
+ return;
812
+
813
+ // if editing item name, preserve native context menu
814
+ if(event.target === el_item_name_editor)
815
+ return;
816
+
817
+ // if ctrl is pressed don't open ctxmenu, ctrl is for drag and copy
818
+ if(event.ctrlKey)
819
+ return false;
820
+
821
+ event.preventDefault();
822
+ let menu_items;
823
+ const $selected_items = $(el_item).closest('.item-container').find('.item-selected').not(el_item).addBack();
824
+ // -------------------------------------------------------
825
+ // Multiple items selected
826
+ // -------------------------------------------------------
827
+ if($selected_items.length > 1){
828
+ const are_trashed = $selected_items.attr('data-path').startsWith(trash_path + '/');
829
+ menu_items = []
830
+ // -------------------------------------------
831
+ // Restore
832
+ // -------------------------------------------
833
+ if(are_trashed){
834
+ menu_items.push({
835
+ html: "Restore",
836
+ onClick: function(){
837
+ $selected_items.each(function() {
838
+ const ell = this;
839
+ let metadata = $(ell).attr('data-metadata') === '' ? {} : JSON.parse($(ell).attr('data-metadata'))
840
+ move_items([ell], path.dirname(metadata.original_path));
841
+ })
842
+ }
843
+ });
844
+ // -------------------------------------------
845
+ // -
846
+ // -------------------------------------------
847
+ menu_items.push('-');
848
+ }
849
+ if(!are_trashed){
850
+ // -------------------------------------------
851
+ // Donwload
852
+ // -------------------------------------------
853
+ menu_items.push({
854
+ html: 'Download',
855
+ onClick: async function(){
856
+ let items = [];
857
+ for (let index = 0; index < $selected_items.length; index++) {
858
+ items.push($selected_items[index]);
859
+ }
860
+
861
+ zipItems(items, path.dirname($(el_item).attr('data-path')), true);
862
+ }
863
+ });
864
+ // -------------------------------------------
865
+ // Zip
866
+ // -------------------------------------------
867
+ menu_items.push({
868
+ html: 'Zip',
869
+ onClick: async function(){
870
+ let items = [];
871
+ for (let index = 0; index < $selected_items.length; index++) {
872
+ items.push($selected_items[index]);
873
+ }
874
+
875
+ zipItems(items, path.dirname($(el_item).attr('data-path')), false);
876
+ }
877
+ });
878
+ // -------------------------------------------
879
+ // -
880
+ // -------------------------------------------
881
+ menu_items.push('-');
882
+ }
883
+ // -------------------------------------------
884
+ // Cut
885
+ // -------------------------------------------
886
+ menu_items.push({
887
+ html: "Cut",
888
+ onClick: function(){
889
+ window.clipboard_op= 'move';
890
+ window.clipboard = [];
891
+ $selected_items.each(function() {
892
+ const ell = this;
893
+ window.clipboard.push($(ell).attr('data-path'));
894
+ })
895
+ }
896
+ });
897
+
898
+ // -------------------------------------------
899
+ // Copy
900
+ // -------------------------------------------
901
+ if(!are_trashed){
902
+ menu_items.push({
903
+ html: "Copy",
904
+ onClick: function(){
905
+ window.clipboard_op= 'copy';
906
+ window.clipboard = [];
907
+ $selected_items.each(function() {
908
+ const ell = this;
909
+ window.clipboard.push({path: $(ell).attr('data-path')});
910
+ })
911
+ }
912
+ });
913
+ }
914
+ // -------------------------------------------
915
+ // -
916
+ // -------------------------------------------
917
+ menu_items.push('-');
918
+ // -------------------------------------------
919
+ // Delete Permanently
920
+ // -------------------------------------------
921
+ if(are_trashed){
922
+ menu_items.push({
923
+ html: 'Delete Permanently',
924
+ onClick: async function(){
925
+ const alert_resp = await UIAlert({
926
+ message: `Are you sure you want to permanently delete these items?`,
927
+ buttons:[
928
+ {
929
+ label: 'Delete',
930
+ type: 'primary',
931
+ },
932
+ {
933
+ label: 'Cancel'
934
+ },
935
+ ]
936
+ })
937
+ if((alert_resp) === 'Delete'){
938
+ for (let index = 0; index < $selected_items.length; index++) {
939
+ const element = $selected_items[index];
940
+ await delete_item(element);
941
+ }
942
+ const trash = await puter.fs.stat(trash_path);
943
+
944
+ // update other clients
945
+ if(window.socket){
946
+ window.socket.emit('trash.is_empty', {is_empty: trash.is_empty});
947
+ }
948
+
949
+ if(trash.is_empty){
950
+ $(`.item[data-path="${html_encode(trash_path)}" i], .item[data-shortcut_to_path="${trash_path}" i]`).find('.item-icon > img').attr('src', window.icons['trash.svg']);
951
+ $(`.window[data-path="${html_encode(trash_path)}"]`).find('.window-head-icon').attr('src', window.icons['trash.svg']);
952
+ }
953
+ }
954
+ }
955
+ });
956
+ }
957
+ // -------------------------------------------
958
+ // Create Shortcut
959
+ // -------------------------------------------
960
+ if(!are_trashed && window.feature_flags.create_shortcut){
961
+ menu_items.push({
962
+ html: 'Create Shortcut',
963
+ onClick: async function(){
964
+ $selected_items.each(function() {
965
+ let base_dir = path.dirname($(this).attr('data-path'));
966
+ // Trash on Desktop is a special case
967
+ if($(this).attr('data-path') && $(this).closest('.item-container').attr('data-path') === window.desktop_path){
968
+ base_dir = window.desktop_path;
969
+ }
970
+ // create shortcut
971
+ create_shortcut(
972
+ path.basename($(this).attr('data-path')),
973
+ $(this).attr('data-is_dir') === '1',
974
+ base_dir,
975
+ $(this).closest('.item-container'),
976
+ $(this).attr('data-shortcut_to') === '' ? $(this).attr('data-uid') : $(this).attr('data-shortcut_to'),
977
+ $(this).attr('data-shortcut_to_path') === '' ? $(this).attr('data-path') : $(this).attr('data-shortcut_to_path'),
978
+ );
979
+ })
980
+ }
981
+ });
982
+ }
983
+ // -------------------------------------------
984
+ // Delete
985
+ // -------------------------------------------
986
+ if(!are_trashed){
987
+ menu_items.push({
988
+ html: 'Delete',
989
+ onClick: async function(){
990
+ move_items($selected_items, trash_path);
991
+ }
992
+ });
993
+ }
994
+
995
+ }
996
+
997
+ // -------------------------------------------------------
998
+ // One item selected
999
+ // -------------------------------------------------------
1000
+ else{
1001
+ const is_trash = $(el_item).attr('data-path') === trash_path || $(el_item).attr('data-shortcut_to_path') === trash_path;
1002
+ menu_items = [];
1003
+ // -------------------------------------------
1004
+ // Open
1005
+ // -------------------------------------------
1006
+ if(!is_trashed){
1007
+ menu_items.push({
1008
+ html: 'Open',
1009
+ onClick: function(){
1010
+ open_item({item: el_item});
1011
+ }
1012
+ });
1013
+
1014
+ // -------------------------------------------
1015
+ // -
1016
+ // -------------------------------------------
1017
+ if(options.associated_app_name || is_trash)
1018
+ menu_items.push('-');
1019
+ }
1020
+ // -------------------------------------------
1021
+ // Open With
1022
+ // -------------------------------------------
1023
+ if(!is_trashed && !is_trash && (options.associated_app_name === null || options.associated_app_name === undefined)){
1024
+ let items = [];
1025
+ if(!options.suggested_apps || options.suggested_apps.length === 0){
1026
+ // try to find suitable apps
1027
+ const suitable_apps = await suggest_apps_for_fsentry({
1028
+ uid: options.uid,
1029
+ path: options.path,
1030
+ });
1031
+ if(suitable_apps && suitable_apps.length > 0){
1032
+ options.suggested_apps = suitable_apps;
1033
+ }
1034
+ }
1035
+
1036
+ if(options.suggested_apps && options.suggested_apps.length > 0){
1037
+ for (let index = 0; index < options.suggested_apps.length; index++) {
1038
+ const suggested_app = options.suggested_apps[index];
1039
+ if ( ! suggested_app ) {
1040
+ console.warn(`suggested_app is null`, options.suggested_apps, index);
1041
+ continue;
1042
+ }
1043
+ items.push({
1044
+ html: suggested_app.title,
1045
+ icon: `<img src="${html_encode(suggested_app.icon ?? window.icons['app.svg'])}" style="width:16px; height: 16px; margin-bottom: -4px;">`,
1046
+ onClick: async function(){
1047
+ launch_app({
1048
+ name: suggested_app.name,
1049
+ file_path: $(el_item).attr('data-path'),
1050
+ window_title: $(el_item).attr('data-name'),
1051
+ file_uid: $(el_item).attr('data-uid'),
1052
+ });
1053
+ }
1054
+ })
1055
+ }
1056
+ }else{
1057
+ items.push({
1058
+ html: 'No suitable apps found',
1059
+ disabled: true,
1060
+ });
1061
+ }
1062
+ // add all suitable apps
1063
+ menu_items.push({
1064
+ html: 'Open With',
1065
+ items: items,
1066
+ });
1067
+
1068
+ // -------------------------------------------
1069
+ // -- separator --
1070
+ // -------------------------------------------
1071
+ menu_items.push('-');
1072
+ }
1073
+
1074
+ // -------------------------------------------
1075
+ // Open in New Window
1076
+ // (only if the item is on a window)
1077
+ // -------------------------------------------
1078
+ if($(el_item).closest('.window-body').length > 0 && options.is_dir){
1079
+ menu_items.push({
1080
+ html: 'Open in New Window',
1081
+ onClick: function(){
1082
+ if(options.is_dir){
1083
+ open_item({item: el_item, new_window: true})
1084
+ }
1085
+ }
1086
+ });
1087
+ // -------------------------------------------
1088
+ // -- separator --
1089
+ // -------------------------------------------
1090
+ if(!is_trash && !is_trashed && options.is_dir)
1091
+ menu_items.push('-');
1092
+ }
1093
+
1094
+ // -------------------------------------------
1095
+ // Publish As Website
1096
+ // -------------------------------------------
1097
+ if(!is_trashed && !is_trash && options.is_dir){
1098
+ menu_items.push({
1099
+ html: 'Publish As Website',
1100
+ disabled: !options.is_dir,
1101
+ onClick: async function () {
1102
+ if(window.require_email_verification_to_publish_website){
1103
+ if(window.user.is_temp &&
1104
+ !await UIWindowSaveAccount({
1105
+ send_confirmation_code: true,
1106
+ message: 'Please create an account to proceed.',
1107
+ window_options: {
1108
+ backdrop: true,
1109
+ close_on_backdrop_click: false,
1110
+ }
1111
+ }))
1112
+ return;
1113
+ else if(!window.user.email_confirmed && !await UIWindowEmailConfirmationRequired())
1114
+ return;
1115
+ }
1116
+ UIWindowPublishWebsite(options.uid, $(el_item).attr('data-name'), $(el_item).attr('data-path'));
1117
+ }
1118
+ });
1119
+
1120
+ }
1121
+ // -------------------------------------------
1122
+ // Deploy As App
1123
+ // -------------------------------------------
1124
+ if(!is_trashed && !is_trash && options.is_dir){
1125
+ menu_items.push({
1126
+ html: 'Deploy As App',
1127
+ disabled: !options.is_dir,
1128
+ onClick: async function () {
1129
+ launch_app({
1130
+ name: 'dev-center',
1131
+ file_path: $(el_item).attr('data-path'),
1132
+ file_uid: $(el_item).attr('data-uid'),
1133
+ params: {
1134
+ source_path: options.path,
1135
+ }
1136
+ })
1137
+ }
1138
+ });
1139
+
1140
+ menu_items.push('-');
1141
+ }
1142
+
1143
+ // -------------------------------------------
1144
+ // Empty Trash
1145
+ // -------------------------------------------
1146
+ if(is_trash){
1147
+ menu_items.push({
1148
+ html: 'Empty Trash',
1149
+ onClick: async function(){
1150
+ empty_trash();
1151
+ }
1152
+ });
1153
+
1154
+ }
1155
+ // -------------------------------------------
1156
+ // Donwload
1157
+ // -------------------------------------------
1158
+ if(!is_trash && !is_trashed && (options.associated_app_name === null || options.associated_app_name === undefined)){
1159
+ menu_items.push({
1160
+ html: 'Download',
1161
+ disabled: options.is_dir && !window.feature_flags.download_directory,
1162
+ onClick: async function(){
1163
+ if(options.is_dir)
1164
+ zipItems(el_item, path.dirname($(el_item).attr('data-path')), true);
1165
+ else
1166
+ trigger_download([options.path]);
1167
+ }
1168
+ });
1169
+ }
1170
+
1171
+
1172
+ // -------------------------------------------
1173
+ // Get Copy Link
1174
+ // -------------------------------------------
1175
+ if(!is_trashed && !is_trash && (options.associated_app_name === null || options.associated_app_name === undefined)){
1176
+ menu_items.push({
1177
+ html: 'Get Copy Link',
1178
+ onClick: async function(){
1179
+ if(window.user.is_temp &&
1180
+ !await UIWindowSaveAccount({
1181
+ message: 'Please create an account to proceed.',
1182
+ send_confirmation_code: true,
1183
+ window_options: {
1184
+ backdrop: true,
1185
+ close_on_backdrop_click: false,
1186
+ }
1187
+ }))
1188
+ return;
1189
+ else if(!window.user.email_confirmed && !await UIWindowEmailConfirmationRequired())
1190
+ return;
1191
+
1192
+ UIWindowGetCopyLink({
1193
+ name: $(el_item).attr('data-name'),
1194
+ uid: $(el_item).attr('data-uid'),
1195
+ path: $(el_item).attr('data-path'),
1196
+ is_dir: options.is_dir,
1197
+ });
1198
+ }
1199
+ });
1200
+ }
1201
+ // -------------------------------------------
1202
+ // Zip
1203
+ // -------------------------------------------
1204
+ if(!is_trash && !is_trashed && !$(el_item).attr('data-path').endsWith('.zip')){
1205
+ menu_items.push({
1206
+ html: "Zip",
1207
+ onClick: function(){
1208
+ zipItems(el_item, path.dirname($(el_item).attr('data-path')), false);
1209
+ }
1210
+ })
1211
+ }
1212
+ // -------------------------------------------
1213
+ // Unzip
1214
+ // -------------------------------------------
1215
+ if(!is_trash && !is_trashed && $(el_item).attr('data-path').endsWith('.zip')){
1216
+ menu_items.push({
1217
+ html: "Unzip",
1218
+ onClick: async function(){
1219
+ const zip = new JSZip();
1220
+ let filPath = $(el_item).attr('data-path');
1221
+ let file = puter.fs.read($(el_item).attr('data-path'));
1222
+
1223
+ zip.loadAsync(file).then(async function (zip) {
1224
+ const rootdir = await puter.fs.mkdir(path.dirname(filPath) + '/' + path.basename(filPath, '.zip'), {dedupeName: true});
1225
+ Object.keys(zip.files).forEach(async function (filename) {
1226
+ if(filename.endsWith('/'))
1227
+ await puter.fs.mkdir(rootdir.path +'/' + filename, {createMissingParents: true});
1228
+ zip.files[filename].async('blob').then(async function (fileData) {
1229
+ await puter.fs.write(rootdir.path +'/' + filename, fileData);
1230
+ }).catch(function (e) {
1231
+ // UIAlert(e.message);
1232
+ })
1233
+ })
1234
+ }).catch(function (e) {
1235
+ // UIAlert(e.message);
1236
+ })
1237
+ }
1238
+ })
1239
+ }
1240
+ // -------------------------------------------
1241
+ // Restore
1242
+ // -------------------------------------------
1243
+ if(is_trashed){
1244
+ menu_items.push({
1245
+ html: 'Restore',
1246
+ onClick: async function(){
1247
+ let metadata = $(el_item).attr('data-metadata') === '' ? {} : JSON.parse($(el_item).attr('data-metadata'))
1248
+ move_items([el_item], path.dirname(metadata.original_path));
1249
+ }
1250
+ });
1251
+ }
1252
+ // -------------------------------------------
1253
+ // -
1254
+ // -------------------------------------------
1255
+ if(!is_trash && (options.associated_app_name === null || options.associated_app_name === undefined))
1256
+ menu_items.push('-');
1257
+ // -------------------------------------------
1258
+ // Cut
1259
+ // -------------------------------------------
1260
+ if($(el_item).attr('data-immutable') === '0'){
1261
+ menu_items.push({
1262
+ html: "Cut",
1263
+ onClick: function(){
1264
+ window.clipboard_op= 'move';
1265
+ window.clipboard= [options.path];
1266
+ }
1267
+ });
1268
+ }
1269
+ // -------------------------------------------
1270
+ // Copy
1271
+ // -------------------------------------------
1272
+ if(!is_trashed && !is_trash){
1273
+ menu_items.push({
1274
+ html: "Copy",
1275
+ onClick: function(){
1276
+ window.clipboard_op= 'copy';
1277
+ window.clipboard= [{path: options.path}];
1278
+ }
1279
+ });
1280
+ }
1281
+ // -------------------------------------------
1282
+ // Paste Into Folder
1283
+ // -------------------------------------------
1284
+ if($(el_item).attr('data-is_dir') === '1' && !is_trashed && !is_trash){
1285
+ menu_items.push({
1286
+ html: "Paste Into Folder",
1287
+ disabled: clipboard.length > 0 ? false : true,
1288
+ onClick: function(){
1289
+ if(clipboard_op === 'copy')
1290
+ copy_clipboard_items($(el_item).attr('data-path'), null);
1291
+ else if(clipboard_op === 'move')
1292
+ move_clipboard_items(null, $(el_item).attr('data-path'))
1293
+ }
1294
+ })
1295
+ }
1296
+ // -------------------------------------------
1297
+ // -
1298
+ // -------------------------------------------
1299
+ if($(el_item).attr('data-immutable') === '0' && !is_trash){
1300
+ menu_items.push('-')
1301
+ }
1302
+ // -------------------------------------------
1303
+ // Create Shortcut
1304
+ // -------------------------------------------
1305
+ if(!is_trashed && window.feature_flags.create_shortcut){
1306
+ menu_items.push({
1307
+ html: 'Create Shortcut',
1308
+ onClick: async function(){
1309
+ let base_dir = path.dirname($(el_item).attr('data-path'));
1310
+ // Trash on Desktop is a special case
1311
+ if($(el_item).attr('data-path') && $(el_item).closest('.item-container').attr('data-path') === window.desktop_path){
1312
+ base_dir = window.desktop_path;
1313
+ }
1314
+
1315
+ create_shortcut(
1316
+ path.basename($(el_item).attr('data-path')),
1317
+ options.is_dir,
1318
+ base_dir,
1319
+ options.appendTo,
1320
+ options.shortcut_to === '' ? options.uid : options.shortcut_to,
1321
+ options.shortcut_to_path === '' ? options.path : options.shortcut_to_path,
1322
+ );
1323
+ }
1324
+ });
1325
+ }
1326
+ // -------------------------------------------
1327
+ // Delete
1328
+ // -------------------------------------------
1329
+ if($(el_item).attr('data-immutable') === '0' && !is_trashed){
1330
+ menu_items.push({
1331
+ html: 'Delete',
1332
+ onClick: async function(){
1333
+ move_items([el_item], trash_path);
1334
+ }
1335
+ });
1336
+ }
1337
+ // -------------------------------------------
1338
+ // Delete Permanently
1339
+ // -------------------------------------------
1340
+ if(is_trashed){
1341
+ menu_items.push({
1342
+ html: 'Delete Permanently',
1343
+ onClick: async function(){
1344
+ const alert_resp = await UIAlert({
1345
+ message: `Are you sure you want to permanently delete this item?`,
1346
+ buttons:[
1347
+ {
1348
+ label: 'Delete',
1349
+ type: 'primary',
1350
+ },
1351
+ {
1352
+ label: 'Cancel'
1353
+ },
1354
+ ]
1355
+ })
1356
+
1357
+ if((alert_resp) === 'Delete'){
1358
+ await delete_item(el_item);
1359
+ // check if trash is empty
1360
+ const trash = await puter.fs.stat(trash_path);
1361
+ // update other clients
1362
+ if(window.socket){
1363
+ window.socket.emit('trash.is_empty', {is_empty: trash.is_empty});
1364
+ }
1365
+ // update this client
1366
+ if(trash.is_empty){
1367
+ $(`.item[data-path="${html_encode(trash_path)}" i], .item[data-shortcut_to_path="${html_encode(trash_path)}" i]`).find('.item-icon > img').attr('src', window.icons['trash.svg']);
1368
+ $(`.window[data-path="${trash_path}"]`).find('.window-head-icon').attr('src', window.icons['trash.svg']);
1369
+ }
1370
+ }
1371
+ }
1372
+ });
1373
+ }
1374
+ // -------------------------------------------
1375
+ // Rename
1376
+ // -------------------------------------------
1377
+ if($(el_item).attr('data-immutable') === '0' && !is_trashed && !is_trash){
1378
+ menu_items.push({
1379
+ html: "Rename",
1380
+ onClick: function(){
1381
+ activate_item_name_editor(el_item)
1382
+ }
1383
+ });
1384
+ }
1385
+ // -------------------------------------------
1386
+ // -
1387
+ // -------------------------------------------
1388
+ menu_items.push('-');
1389
+ // -------------------------------------------
1390
+ // Properties
1391
+ // -------------------------------------------
1392
+ menu_items.push({
1393
+ html: "Properties",
1394
+ onClick: function(){
1395
+ let window_height = 500;
1396
+ let window_width = 450;
1397
+
1398
+ let left = $(el_item).position().left + $(el_item).width();
1399
+ left = left > (window.innerWidth - window_width)? (window.innerWidth - window_width) : left;
1400
+
1401
+ let top = $(el_item).position().top + $(el_item).height();
1402
+ top = top > (window.innerHeight - (window_height + window.taskbar_height + window.toolbar_height))? (window.innerHeight - (window_height + window.taskbar_height + window.toolbar_height)) : top;
1403
+
1404
+ UIWindowItemProperties(
1405
+ $(el_item).attr('data-name'),
1406
+ $(el_item).attr('data-path'),
1407
+ $(el_item).attr('data-uid'),
1408
+ left,
1409
+ top,
1410
+ window_width,
1411
+ window_height,
1412
+ );
1413
+ }
1414
+ });
1415
+ }
1416
+
1417
+ // Create ContextMenu
1418
+ UIContextMenu({
1419
+ parent_element: ($(options.appendTo).hasClass('desktop') ? undefined : options.appendTo),
1420
+ items: menu_items
1421
+ });
1422
+
1423
+ return false
1424
+ })
1425
+
1426
+ // --------------------------------------------------------
1427
+ // Resize Item Name Editor on every keystroke
1428
+ // --------------------------------------------------------
1429
+ $(el_item_name_editor).on('input keypress focus', function(){
1430
+ const val = $(el_item_name_editor).val();
1431
+ $('.item-name-shadow').html(html_encode(val).replaceAll(' ', '&nbsp;'));
1432
+ if(val !== ''){
1433
+ const w = $('.item-name-shadow').width();
1434
+ const h = $('.item-name-shadow').height();
1435
+ $(el_item_name_editor).width(w + 4)
1436
+ $(el_item_name_editor).height(h + 2)
1437
+ }
1438
+ })
1439
+
1440
+ if(options.sort_container_after_append){
1441
+ sort_items(options.appendTo, $(el_item).closest('.item-container').attr('data-sort_by'), $(el_item).closest('.item-container').attr('data-sort_order'));
1442
+ }
1443
+ if(options.editable){
1444
+ activate_item_name_editor(el_item)
1445
+ }
1446
+ }
1447
+
1448
+ // Create item-name-shadow
1449
+ // This element has the exact styling as item name editor and allows us
1450
+ // to measure the width and height of the item name editor and automatically
1451
+ // resize it to fit the text.
1452
+ $('body').append(`<span class="item-name-shadow"></span>`);
1453
+
1454
+ $(document).on('click', '.item-has-website-url-badge', async function(e){
1455
+ e.stopPropagation();
1456
+ e.preventDefault();
1457
+ const website_url = $(this).closest('.item').attr('data-website_url');
1458
+ if(website_url){
1459
+ window.open(website_url, '_blank');
1460
+ }
1461
+ return false;
1462
+ })
1463
+
1464
+ $(document).on('mousedown', '.item-has-website-url-badge', async function(e){
1465
+ console.log('mousedown')
1466
+ e.stopPropagation();
1467
+ e.preventDefault();
1468
+ return false;
1469
+ })
1470
+
1471
+ $(document).on('contextmenu', '.item-has-website-url-badge', async function(e){
1472
+ e.stopPropagation();
1473
+ e.preventDefault();
1474
+
1475
+ // close other context menus
1476
+ const $ctxmenus = $(".context-menu");
1477
+ $ctxmenus.fadeOut(200, function(){
1478
+ $ctxmenus.remove();
1479
+ });
1480
+
1481
+ UIContextMenu({
1482
+ parent_element: this,
1483
+ items: [
1484
+ // Open
1485
+ {
1486
+ html: `Open in New Tab <img src="${window.icons['launch.svg']}" style="width:10px; height:10px; margin-left: 5px;">` ,
1487
+ html_active: `Open in New Tab <img src="${window.icons['launch-white.svg']}" style="width:10px; height:10px; margin-left: 5px;">` ,
1488
+ onClick: function(){
1489
+ const website_url = $(e.target).closest('.item').attr('data-website_url');
1490
+ if(website_url){
1491
+ window.open(website_url, '_blank');
1492
+ }
1493
+ }
1494
+ },
1495
+ // Copy Link
1496
+ {
1497
+ html: 'Copy Link',
1498
+ onClick: async function(){
1499
+ const website_url = $(e.target).closest('.item').attr('data-website_url');
1500
+ if(website_url){
1501
+ await copy_to_clipboard(website_url);
1502
+ }
1503
+ }
1504
+ },
1505
+ ]
1506
+ });
1507
+
1508
+ return false;
1509
+ })
1510
+
1511
+ $(document).on('click', '.item-has-website-badge', async function(e){
1512
+ puter.fs.stat({
1513
+ uid: $(this).closest('.item').attr('data-uid'),
1514
+ returnSubdomains: true,
1515
+ returnPermissions: false,
1516
+ returnVersions: false,
1517
+ success: function (fsentry){
1518
+ if(fsentry.subdomains)
1519
+ window.open(fsentry.subdomains[0].address, '_blank');
1520
+ }
1521
+ })
1522
+ })
1523
+
1524
+ $(document).on('long-hover', '.item-has-website-badge', function(e){
1525
+ puter.fs.stat({
1526
+ uid: $(this).closest('.item').attr('data-uid'),
1527
+ returnSubdomains: true,
1528
+ returnPermissions: false,
1529
+ returnVersions: false,
1530
+ success: function (fsentry){
1531
+ var box = e.target.getBoundingClientRect();
1532
+
1533
+ var body = document.body;
1534
+ var docEl = document.documentElement;
1535
+
1536
+ var scrollTop = window.pageYOffset || docEl.scrollTop || body.scrollTop;
1537
+ var scrollLeft = window.pageXOffset || docEl.scrollLeft || body.scrollLeft;
1538
+
1539
+ var clientTop = docEl.clientTop || body.clientTop || 0;
1540
+ var clientLeft = docEl.clientLeft || body.clientLeft || 0;
1541
+
1542
+ var top = box.top + scrollTop - clientTop;
1543
+ var left = box.left + scrollLeft - clientLeft;
1544
+
1545
+
1546
+ if(fsentry.subdomains){
1547
+ let h = `<div class="allow-user-select website-badge-popover-content">`;
1548
+ h += `<div class="website-badge-popover-title">Associated website${ fsentry.subdomains.length > 1 ? 's':''}</div>`;
1549
+ fsentry.subdomains.forEach(subdomain => {
1550
+ h += `
1551
+ <a class="website-badge-popover-link" href="${subdomain.address}" style="font-size:13px;" target="_blank">${subdomain.address.replace('https://', '')}</a>
1552
+ <br>`;
1553
+ });
1554
+
1555
+ h += `</div>`;
1556
+
1557
+ // close other website popovers
1558
+ $('.website-badge-popover-content').closest('.popover').remove();
1559
+
1560
+ // show a UIPopover with the website
1561
+ UIPopover({
1562
+ target: e.target,
1563
+ content:h,
1564
+ snapToElement: e.target,
1565
+ parent_element: e.target,
1566
+ top: top - 30,
1567
+ left: left + 20,
1568
+ })
1569
+ }
1570
+ }
1571
+ })
1572
+ })
1573
+
1574
+ $(document).on('click', '.website-badge-popover-link', function(e){
1575
+ // remove the parent popover
1576
+ $(e.target).closest('.popover').remove();
1577
+ })
1578
+
1579
+ // removes item(s)
1580
+ $.fn.removeItems = async function(options) {
1581
+ options = options || {};
1582
+ $(this).each(async function() {
1583
+ const parent_container = $(this).closest('.item-container');
1584
+ $(this).remove();
1585
+ show_or_hide_empty_folder_message(parent_container);
1586
+ });
1587
+
1588
+ return this;
1589
+ }
1590
+
1591
+ window.activate_item_name_editor= function(el_item){
1592
+ // files in trash cannot be renamed, the user should be notified with an Alert.
1593
+ if($(el_item).attr('data-immutable') !== '0'){
1594
+ return;
1595
+ }
1596
+ // files in trash cannot be renamed, user should be notified with an Alert.
1597
+ else if(path.dirname($(el_item).attr('data-path')) === window.trash_path){
1598
+ UIAlert(`This item can't be renamed because it's in the trash. To rename this item, first drag it out of the Trash.`)
1599
+ return;
1600
+ }
1601
+
1602
+ const el_item_name = $(el_item).find('.item-name');
1603
+ const el_item_name_editor = $(el_item).find('.item-name-editor').get(0);
1604
+
1605
+ $(el_item_name).hide();
1606
+ $(el_item_name_editor).show();
1607
+ $(el_item_name_editor).focus();
1608
+ $(el_item_name_editor).addClass('item-name-editor-active');
1609
+
1610
+ // select all text before extension
1611
+ const item_name = $(el_item).attr('data-name');
1612
+ const is_dir = parseInt($(el_item).attr('data-is_dir'));
1613
+ const extname = path.extname('/'+item_name);
1614
+ if(extname !== '' && !is_dir)
1615
+ el_item_name_editor.setSelectionRange(0, item_name.length - extname.length)
1616
+ else
1617
+ $(el_item_name_editor).select();
1618
+ }
1619
+
1620
+ export default UIItem;
src/UI/UINotification.js ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ function UINotification(options){
21
+ global_element_id++;
22
+
23
+ options.content = options.content ?? '';
24
+
25
+ let h = '';
26
+ h += `<div id="ui-notification__${global_element_id}" class="notification antialiased animate__animated animate__fadeInRight animate__slow">`;
27
+ h += `<img class="notification-close" src="${html_encode(window.icons['close.svg'])}">`;
28
+ h += options.content;
29
+ h += `</div>`;
30
+
31
+ $('body').append(h);
32
+
33
+
34
+ const el_notification = document.getElementById(`ui-notification__${global_element_id}`);
35
+
36
+ $(el_notification).show(0, function(e){
37
+ // options.onAppend()
38
+ if(options.onAppend && typeof options.onAppend === 'function'){
39
+ options.onAppend(el_notification);
40
+ }
41
+ })
42
+
43
+ // Show Notification
44
+ $(el_notification).delay(100).show(0).
45
+ // In the right position (the mouse)
46
+ css({
47
+ top: toolbar_height + 15,
48
+ });
49
+
50
+ return el_notification;
51
+ }
52
+
53
+ $(document).on('click', '.notification', function(e){
54
+ if($(e.target).hasClass('notification')){
55
+ if(options.click && typeof options.click === 'function'){
56
+ options.click(e);
57
+ }
58
+ window.close_notification(e.target);
59
+ }else{
60
+ window.close_notification($(e.target).closest('.notification'));
61
+ }
62
+ });
63
+
64
+ $(document).on('click', '.notification-close', function(e){
65
+ window.close_notification($(e.target).closest('.notification'));
66
+ });
67
+
68
+
69
+ window.close_notification = function(el_notification){
70
+ $(el_notification).addClass('animate__fadeOutRight');
71
+ setTimeout(function(){
72
+ $(el_notification).remove();
73
+ }, 500);
74
+ }
75
+
76
+ export default UINotification;
src/UI/UIPopover.js ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ // todo change to apps popover or sth
21
+ function UIPopover(options){
22
+ // skip if popover already open
23
+ if(options.parent_element && $(options.parent_element).hasClass('has-open-popover'))
24
+ return;
25
+
26
+ $('.window-active .window-app-iframe').css('pointer-events', 'none');
27
+
28
+ global_element_id++;
29
+
30
+ options.content = options.content ?? '';
31
+
32
+ let h = '';
33
+ h += `<div id="popover-${global_element_id}" class="popover">`;
34
+ h += options.content;
35
+ h += `</div>`;
36
+
37
+ $('body').append(h);
38
+
39
+
40
+ const el_popover = document.getElementById(`popover-${global_element_id}`);
41
+
42
+ $(el_popover).show(0, function(e){
43
+ // options.onAppend()
44
+ if(options.onAppend && typeof options.onAppend === 'function'){
45
+ options.onAppend(el_popover);
46
+ }
47
+ })
48
+
49
+ let x_pos;
50
+ let y_pos;
51
+
52
+ if(options.parent_element){
53
+ $(options.parent_element).addClass('has-open-popover');
54
+ }
55
+ $(el_popover).on("remove", function () {
56
+ if(options.parent_element){
57
+ $(options.parent_element).removeClass('has-open-popover');
58
+ }
59
+ })
60
+
61
+ function position_popover(){
62
+ // X position
63
+ const popover_width = options.width ?? $(el_popover).width();
64
+ if(options.center_horizontally){
65
+ x_pos = window.innerWidth/2 - popover_width/2 - 15;
66
+ }else{
67
+ if(options.position === 'bottom' || options.position === 'top')
68
+ x_pos = options.left ?? ($(options.snapToElement).offset().left - (popover_width/ 2) + 10);
69
+ else
70
+ x_pos = options.left ?? ($(options.snapToElement).offset().left + 5);
71
+ }
72
+
73
+ // Y position
74
+ const popover_height = options.height ?? $(el_popover).height();
75
+ if(options.center_horizontally){
76
+ y_pos = options.top ?? (window.innerHeight - (taskbar_height + popover_height + 10));
77
+ }else{
78
+ y_pos = options.top ?? ($(options.snapToElement).offset().top + $(options.snapToElement).height() + 5);
79
+ }
80
+
81
+ $(el_popover).css({
82
+ left: x_pos + "px",
83
+ top: y_pos + "px",
84
+ });
85
+ }
86
+ position_popover();
87
+
88
+ // If the window is resized, reposition the popover
89
+ $(window).on('resize', function(){
90
+ position_popover();
91
+ });
92
+
93
+ // Show Popover
94
+ $(el_popover).delay(100).show(0).
95
+ // In the right position (the mouse)
96
+ css({
97
+ left: x_pos + "px",
98
+ top: y_pos + "px",
99
+ });
100
+
101
+ return el_popover;
102
+ }
103
+
104
+ export default UIPopover;
src/UI/UIPrompt.js ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ function UIPrompt(options){
23
+ // set sensible defaults
24
+ if(arguments.length > 0){
25
+ // if first argument is a string, then assume it is the message
26
+ if(isString(arguments[0])){
27
+ options = {};
28
+ options.message = arguments[0];
29
+ }
30
+ // if second argument is an array, then assume it is the buttons
31
+ if(arguments[1] && Array.isArray(arguments[1])){
32
+ options.buttons = arguments[1];
33
+ }
34
+ }
35
+
36
+ return new Promise(async (resolve) => {
37
+ // provide an 'OK' button if no buttons are provided
38
+ if(!options.buttons || options.buttons.length === 0){
39
+ options.buttons = [
40
+ {label: 'Cancel', value: false, type: 'default'},
41
+ {label: 'OK', value: true, type: 'primary'},
42
+ ]
43
+ }
44
+
45
+ let h = '';
46
+ // message
47
+ h += `<div class="window-prompt-message">${options.message}</div>`;
48
+ // prompt
49
+ h += `<div class="window-alert-prompt" style="margin-top: 20px;">`;
50
+ h += `<input type="text" class="prompt-input" placeholder="${options.placeholder ?? ''}" value="${options.value ?? ''}">`;
51
+ h += `</div>`;
52
+ // buttons
53
+ if(options.buttons && options.buttons.length > 0){
54
+ h += `<div style="overflow:hidden; margin-top:20px; float:right;">`;
55
+ h += `<button class="button button-default prompt-resp-button prompt-resp-btn-cancel" data-label="Cancel" style="padding: 0 20px;">Cancel</button>`;
56
+ h += `<button class="button button-primary prompt-resp-button prompt-resp-btn-ok" data-label="OK" data-value="true" autofocus>OK</button>`;
57
+ h += `</div>`;
58
+ }
59
+
60
+ const el_window = await UIWindow({
61
+ title: null,
62
+ icon: null,
63
+ uid: null,
64
+ is_dir: false,
65
+ message: options.message,
66
+ backdrop: options.backdrop ?? false,
67
+ is_resizable: false,
68
+ is_droppable: false,
69
+ has_head: false,
70
+ stay_on_top: options.stay_on_top ?? false,
71
+ selectable_body: false,
72
+ draggable_body: true,
73
+ allow_context_menu: false,
74
+ show_in_taskbar: false,
75
+ window_class: 'window-alert',
76
+ dominant: true,
77
+ body_content: h,
78
+ width: 450,
79
+ parent_uuid: options.parent_uuid,
80
+ onAppend: function(this_window){
81
+ setTimeout(function(){
82
+ $(this_window).find('.prompt-input').get(0).focus({preventScroll:true});
83
+ }, 30);
84
+ },
85
+ ...options.window_options,
86
+ window_css:{
87
+ height: 'initial',
88
+ },
89
+ body_css: {
90
+ width: 'initial',
91
+ padding: '20px',
92
+ 'background-color': 'rgba(231, 238, 245, .95)',
93
+ 'backdrop-filter': 'blur(3px)',
94
+ }
95
+ });
96
+ // focus to primary btn
97
+ $(el_window).find('.button-primary').focus();
98
+
99
+ // --------------------------------------------------------
100
+ // Button pressed
101
+ // --------------------------------------------------------
102
+ $(el_window).find('.prompt-resp-button').on('click', async function(event){
103
+ event.preventDefault();
104
+ event.stopPropagation();
105
+ if($(this).attr('data-value') === 'true'){
106
+ resolve($(el_window).find('.prompt-input').val());
107
+ }else{
108
+ resolve(false);
109
+ }
110
+ $(el_window).close();
111
+ return false;
112
+ })
113
+
114
+ $(el_window).find('.prompt-input').on('keyup', async function(e){
115
+ if(e.keyCode === 13){
116
+ $(el_window).find('.prompt-resp-btn-ok').click();
117
+ }
118
+ })
119
+ })
120
+ }
121
+
122
+ export default UIPrompt;
src/UI/UITaskbar.js ADDED
@@ -0,0 +1,304 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UITaskbarItem from './UITaskbarItem.js'
21
+ import UIPopover from './UIPopover.js'
22
+
23
+ async function UITaskbar(options){
24
+ global_element_id++;
25
+
26
+ options = options ?? {};
27
+ options.content = options.content ?? '';
28
+
29
+ // get launch apps
30
+ $.ajax({
31
+ url: api_origin + "/get-launch-apps",
32
+ type: 'GET',
33
+ async: true,
34
+ contentType: "application/json",
35
+ headers: {
36
+ "Authorization": "Bearer "+auth_token
37
+ },
38
+ success: function (apps){
39
+ window.launch_apps = apps;
40
+ }
41
+ });
42
+
43
+ let h = '';
44
+ h += `<div id="ui-taskbar_${global_element_id}" class="taskbar" style="height:${window.taskbar_height}px;"><span id='clock'></span></div>`;
45
+
46
+ $('.desktop').append(h);
47
+
48
+ //---------------------------------------------
49
+ // add `Start` to taskbar
50
+ //---------------------------------------------
51
+ UITaskbarItem({
52
+ icon: window.icons['start.svg'],
53
+ name: 'Start',
54
+ sortable: false,
55
+ keep_in_taskbar: true,
56
+ disable_context_menu: true,
57
+ onClick: async function(item){
58
+ // skip if popover already open
59
+ if($(item).hasClass('has-open-popover'))
60
+ return;
61
+
62
+ // show popover
63
+ let popover = UIPopover({
64
+ content: `<div class="launch-popover hide-scrollbar"><span class="close-launch-popover">✕</span></div>`,
65
+ snapToElement: item,
66
+ parent_element: item,
67
+ width: 500,
68
+ height: 500,
69
+ center_horizontally: true,
70
+ });
71
+
72
+ // In the rare case that launch_apps is not populated yet, get it from the server
73
+ // then populate the popover
74
+ if(!launch_apps || !launch_apps.recent || launch_apps.recent.length === 0){
75
+ // get launch apps
76
+ launch_apps = await $.ajax({
77
+ url: api_origin + "/get-launch-apps",
78
+ type: 'GET',
79
+ async: true,
80
+ contentType: "application/json",
81
+ headers: {
82
+ "Authorization": "Bearer "+auth_token
83
+ },
84
+ });
85
+ }
86
+
87
+ let apps_str = '';
88
+
89
+ apps_str += `<div style="margin-bottom: 10px; padding: 5px; position: relative;">`
90
+ apps_str += `<input style="background-image:url(${window.icons['magnifier-outline.svg']});" class="launch-search">`;
91
+ apps_str += `<img class="launch-search-clear" src="${window.icons['close.svg']}">`;
92
+ apps_str += `</div>`;
93
+ // -------------------------------------------
94
+ // Recent apps
95
+ // -------------------------------------------
96
+ if(launch_apps.recent.length > 0){
97
+ // heading
98
+ apps_str += `<h1 class="start-section-heading start-section-heading-recent">Recent</h1>`;
99
+
100
+ // apps
101
+ apps_str += `<div class="launch-apps-recent">`;
102
+ for (let index = 0; index < window.launch_recent_apps_count && index < launch_apps.recent.length; index++) {
103
+ const app_info = launch_apps.recent[index];
104
+ apps_str += `<div title="${html_encode(app_info.title)}" data-name="${html_encode(app_info.name)}" class="start-app-card">`;
105
+ apps_str += `<div class="start-app" data-app-name="${html_encode(app_info.name)}" data-app-uuid="${html_encode(app_info.uuid)}" data-app-icon="${html_encode(app_info.icon)}" data-app-title="${html_encode(app_info.title)}">`;
106
+ apps_str += `<img class="start-app-icon" src="${html_encode(app_info.icon ? app_info.icon : window.icons['app.svg'])}">`;
107
+ apps_str += `<span class="start-app-title">${html_encode(app_info.title)}</span>`;
108
+ apps_str += `</div>`;
109
+ apps_str += `</div>`;
110
+ }
111
+ apps_str += `</div>`;
112
+ }
113
+ // -------------------------------------------
114
+ // Reccomended apps
115
+ // -------------------------------------------
116
+ if(launch_apps.recommended.length > 0){
117
+ // heading
118
+ apps_str += `<h1 class="start-section-heading start-section-heading-recommended" style="${launch_apps.recent.length > 0 ? 'padding-top: 30px;' : ''}">Recommended</h1>`;
119
+
120
+ // apps
121
+ apps_str += `<div class="launch-apps-recommended">`;
122
+ for (let index = 0; index < launch_apps.recommended.length; index++) {
123
+ const app_info = launch_apps.recommended[index];
124
+ apps_str += `<div title="${html_encode(app_info.title)}" data-name="${html_encode(app_info.name)}" class="start-app-card">`;
125
+ apps_str += `<div class="start-app" data-app-name="${html_encode(app_info.name)}" data-app-uuid="${html_encode(app_info.uuid)}" data-app-icon="${html_encode(app_info.icon)}" data-app-title="${html_encode(app_info.title)}">`;
126
+ apps_str += `<img class="start-app-icon" src="${html_encode(app_info.icon ? app_info.icon : window.icons['app.svg'])}">`;
127
+ apps_str += `<span class="start-app-title">${html_encode(app_info.title)}</span>`;
128
+ apps_str += `</div>`;
129
+ apps_str += `</div>`;
130
+ }
131
+ apps_str += `</div>`;
132
+ }
133
+
134
+ // add apps to popover
135
+ $(popover).find('.launch-popover').append(apps_str);
136
+
137
+ // focus on search input only if not on mobile
138
+ if(!isMobile.phone)
139
+ $(popover).find('.launch-search').focus();
140
+
141
+ // make apps draggable
142
+ $(popover).find('.start-app').draggable({
143
+ appendTo: "body",
144
+ revert: "invalid",
145
+ connectToSortable: ".taskbar",
146
+ //containment: "document",
147
+ zIndex: parseInt($(popover).css('z-index')) + 1,
148
+ scroll: false,
149
+ distance: 5,
150
+ revertDuration: 100,
151
+ helper: 'clone',
152
+ cursorAt: { left: 18, top: 20 },
153
+ start: function(event, ui){
154
+ },
155
+ drag: function(event, ui){
156
+ },
157
+ stop: function(){
158
+ }
159
+ });
160
+ }
161
+ });
162
+
163
+ //---------------------------------------------
164
+ // add `Explorer` to the taskbar
165
+ //---------------------------------------------
166
+ UITaskbarItem({
167
+ icon: window.icons['folders.svg'],
168
+ app: 'explorer',
169
+ name: 'Explorer',
170
+ sortable: false,
171
+ keep_in_taskbar: true,
172
+ lock_keep_in_taskbar: true,
173
+ onClick: function(){
174
+ let open_window_count = parseInt($(`.taskbar-item[data-app="explorer"]`).attr('data-open-windows'));
175
+ if(open_window_count === 0){
176
+ launch_app({ name: 'explorer', path: window.home_path});
177
+ }else{
178
+ return false;
179
+ }
180
+ }
181
+ })
182
+
183
+ //---------------------------------------------
184
+ // Add other useful apps to the taskbar
185
+ //---------------------------------------------
186
+ if(window.user.taskbar_items && window.user.taskbar_items.length > 0){
187
+ for (let index = 0; index < window.user.taskbar_items.length; index++) {
188
+ const app_info = window.user.taskbar_items[index];
189
+ // add taskbar item for each app
190
+ UITaskbarItem({
191
+ icon: app_info.icon,
192
+ app: app_info.name,
193
+ name: app_info.title,
194
+ keep_in_taskbar: true,
195
+ onClick: function(){
196
+ let open_window_count = parseInt($(`.taskbar-item[data-app="${app_info.name}"]`).attr('data-open-windows'));
197
+ if(open_window_count === 0){
198
+ launch_app({
199
+ name: app_info.name,
200
+ })
201
+ }else{
202
+ return false;
203
+ }
204
+ }
205
+ });
206
+ }
207
+ }
208
+
209
+ //---------------------------------------------
210
+ // add `Trash` to the taskbar
211
+ //---------------------------------------------
212
+ const trash = await puter.fs.stat(trash_path);
213
+ if(window.socket){
214
+ window.socket.emit('trash.is_empty', {is_empty: trash.is_empty});
215
+ }
216
+
217
+ UITaskbarItem({
218
+ icon: trash.is_empty ? window.icons['trash.svg'] : window.icons['trash-full.svg'],
219
+ app: 'trash',
220
+ name: 'Trash',
221
+ sortable: false,
222
+ keep_in_taskbar: true,
223
+ lock_keep_in_taskbar: true,
224
+ onClick: function(){
225
+ let open_windows = $(`.window[data-path="${html_encode(trash_path)}"]`);
226
+ if(open_windows.length === 0){
227
+ launch_app({ name: 'explorer', path: window.trash_path});
228
+ }else{
229
+ open_windows.focusWindow();
230
+ }
231
+ },
232
+ onItemsDrop: function(items){
233
+ move_items(items, trash_path);
234
+ }
235
+ })
236
+
237
+ make_taskbar_sortable();
238
+ }
239
+
240
+ window.make_taskbar_sortable = function(){
241
+ //-------------------------------------------
242
+ // Taskbar is sortable
243
+ //-------------------------------------------
244
+ $('.taskbar').sortable({
245
+ axis: "x",
246
+ items: '.taskbar-item-sortable:not(.has-open-contextmenu)',
247
+ cancel: '.has-open-contextmenu',
248
+ placeholder: "taskbar-item-sortable-placeholder",
249
+ helper : 'clone',
250
+ distance: 5,
251
+ revert: 10,
252
+ receive: function(event, ui){
253
+ if(!$(ui.item).hasClass('taskbar-item')){
254
+ // if app is already in taskbar, cancel
255
+ if($(`.taskbar-item[data-app="${$(ui.item).attr('data-app-name')}"]`).length !== 0){
256
+ $(this).sortable('cancel');
257
+ $('.taskbar .start-app').remove();
258
+ return;
259
+ }else{
260
+ }
261
+ }
262
+ },
263
+ update: function(event, ui){
264
+ if(!$(ui.item).hasClass('taskbar-item')){
265
+ // if app is already in taskbar, cancel
266
+ if($(`.taskbar-item[data-app="${$(ui.item).attr('data-app-name')}"]`).length !== 0){
267
+ $(this).sortable('cancel');
268
+ $('.taskbar .start-app').remove();
269
+ return;
270
+ }
271
+
272
+ let item = UITaskbarItem({
273
+ icon: $(ui.item).attr('data-app-icon'),
274
+ app: $(ui.item).attr('data-app-name'),
275
+ name: $(ui.item).attr('data-app-title'),
276
+ append_to_taskbar: false,
277
+ keep_in_taskbar: true,
278
+ onClick: function(){
279
+ let open_window_count = parseInt($(`.taskbar-item[data-app="${$(ui.item).attr('data-app-name')}"]`).attr('data-open-windows'));
280
+ if(open_window_count === 0){
281
+ launch_app({
282
+ name: $(ui.item).attr('data-app-name'),
283
+ })
284
+ }else{
285
+ return false;
286
+ }
287
+ }
288
+ });
289
+ let el = ($(item).detach())
290
+ $(el).insertAfter(ui.item);
291
+ // $(ui.item).insertBefore(`<h1>Hello!</h1>`);
292
+ $(el).show();
293
+ $(ui.item).removeItems();
294
+ update_taskbar();
295
+ }
296
+ // only proceed to update DB if the item sorted was a pinned item otherwise no point in updating the taskbar in DB
297
+ else if($(ui.item).attr('data-keep-in-taskbar') === 'true'){
298
+ update_taskbar();
299
+ }
300
+ },
301
+ });
302
+ }
303
+
304
+ export default UITaskbar;
src/UI/UITaskbarItem.js ADDED
@@ -0,0 +1,365 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIContextMenu from './UIContextMenu.js';
21
+
22
+ let tray_item_id = 1;
23
+
24
+ function UITaskbarItem(options){
25
+ let h = ``;
26
+ tray_item_id++;
27
+ options.sortable = options.sortable ?? true;
28
+ options.open_windows_count = options.open_windows_count ?? 0;
29
+ options.lock_keep_in_taskbar = options.lock_keep_in_taskbar ?? false;
30
+ options.append_to_taskbar = options.append_to_taskbar ?? true;
31
+ const element_id = global_element_id++;
32
+
33
+ h += `<div class = "taskbar-item ${options.sortable ? 'taskbar-item-sortable' : ''} disable-user-select"
34
+ id = "taskbar-item-${tray_item_id}"
35
+ data-taskbar-item-id = "${tray_item_id}"
36
+ data-element-id = "${html_encode(element_id)}"
37
+ data-name = "${html_encode(options.name)}"
38
+ data-app = "${html_encode(options.app)}"
39
+ data-keep-in-taskbar = "${html_encode(options.keep_in_taskbar ?? 'false')}"
40
+ data-open-windows="${(options.open_windows_count)}"
41
+ title = "${html_encode(options.name)}"
42
+ style= "${options.style ? html_encode(options.style) : ''}"
43
+ >`;
44
+ let icon = options.icon ? options.icon : window.icons['app.svg'];
45
+ if(options.app === 'explorer')
46
+ icon = window.icons['folders.svg'];
47
+
48
+ // taskbar icon
49
+ h += `<div class="taskbar-icon">`;
50
+ h += `<img src="${html_encode(icon)}" style="${options.group === 'apps' ? 'filter:none;' : ''}">`;
51
+ h += `</div>`;
52
+
53
+ // active indicator
54
+ if(options.app !== 'apps')
55
+ h += `<span class="active-taskbar-indicator"></span>`;
56
+ h += `</div>`;
57
+
58
+ if(options.append_to_taskbar)
59
+ $('.taskbar').append(h);
60
+ else
61
+ $('body').prepend(h);
62
+
63
+ const el_taskbar_item = document.querySelector(`#taskbar-item-${tray_item_id}`);
64
+
65
+ // fade in the taskbar item
66
+ $(el_taskbar_item).show(50);
67
+
68
+ $(el_taskbar_item).on("click", function(){
69
+ // If this item has an open context menu, don't do anything
70
+ if($(el_taskbar_item).hasClass('has-open-contextmenu'))
71
+ return;
72
+
73
+ if(options.onClick === undefined || options.onClick(el_taskbar_item) === false){
74
+ // re-show each window in this app group
75
+ $(`.window[data-app="${options.app}"]`).showWindow();
76
+ }
77
+ })
78
+
79
+ $(el_taskbar_item).on('contextmenu taphold', function(e){
80
+ // seems like the only way to stop sortable is to destroy it
81
+ if(options.sortable) {
82
+ $('.taskbar').sortable('destroy');
83
+ }
84
+
85
+ e.preventDefault();
86
+ e.stopPropagation();
87
+
88
+ // If context menu is disabled on this item, return
89
+ if(options.disable_context_menu)
90
+ return;
91
+
92
+ // don't allow context menu to open if it's already open
93
+ if($(el_taskbar_item).hasClass('has-open-contextmenu'))
94
+ return;
95
+
96
+ const menu_items =[];
97
+ const open_windows = parseInt($(el_taskbar_item).attr('data-open-windows'));
98
+ // -------------------------------------------
99
+ // List of open windows belonging to this app
100
+ // -------------------------------------------
101
+ $(`.window[data-app="${options.app}"]`).each(function(){
102
+ menu_items.push({
103
+ html: $(this).find(`.window-head-title`).html(),
104
+ val: $(this).attr('data-id'),
105
+ onClick: function(e){
106
+ $(`.window[data-id="${e.value}"]`).showWindow();
107
+ }
108
+ })
109
+ })
110
+ // -------------------------------------------
111
+ // divider
112
+ // -------------------------------------------
113
+ if(menu_items.length > 0)
114
+ menu_items.push('-');
115
+
116
+ //------------------------------------------
117
+ // New Window
118
+ //------------------------------------------
119
+ if(options.app){
120
+ menu_items.push({
121
+ html: 'New Window',
122
+ val: $(this).attr('data-id'),
123
+ onClick: function(){
124
+ launch_app({
125
+ name: options.app,
126
+ maximized: (isMobile.phone || isMobile.tablet),
127
+ })
128
+ }
129
+ })
130
+ }
131
+ //------------------------------------------
132
+ // Empty Trash
133
+ //------------------------------------------
134
+ if(options.app === 'trash' && options.name === 'Trash'){
135
+ // divider
136
+ menu_items.push('-');
137
+
138
+ // Empty Trash menu item
139
+ menu_items.push({
140
+ html: 'Empty Trash',
141
+ val: $(this).attr('data-id'),
142
+ onClick: async function(){
143
+ empty_trash();
144
+ }
145
+ })
146
+ }
147
+
148
+ //------------------------------------------
149
+ // Remove from Taskbar
150
+ //------------------------------------------
151
+ if(options.keep_in_taskbar && !options.lock_keep_in_taskbar){
152
+ menu_items.push({
153
+ html: 'Remove from Taskbar',
154
+ val: $(this).attr('data-id'),
155
+ onClick: function(){
156
+ $(el_taskbar_item).attr('data-keep-in-taskbar', 'false');
157
+ if($(el_taskbar_item).attr('data-open-windows') === '0'){
158
+ remove_taskbar_item(el_taskbar_item);
159
+ }
160
+ update_taskbar();
161
+ options.keep_in_taskbar = false;
162
+ }
163
+ })
164
+ }
165
+ //------------------------------------------
166
+ // Keep in Taskbar
167
+ //------------------------------------------
168
+ else if(!options.keep_in_taskbar){
169
+ menu_items.push({
170
+ html: 'Keep in Taskbar',
171
+ val: $(this).attr('data-id'),
172
+ onClick: function(){
173
+ $(el_taskbar_item).attr('data-keep-in-taskbar', 'true');
174
+ update_taskbar();
175
+ options.keep_in_taskbar = true;
176
+ }
177
+ })
178
+ }
179
+
180
+ if(open_windows > 0){
181
+ // -------------------------------------------
182
+ // divider
183
+ // -------------------------------------------
184
+ menu_items.push('-');
185
+ // -------------------------------------------
186
+ // Show All Windows
187
+ // -------------------------------------------
188
+ menu_items.push({
189
+ html: "Show All Windows",
190
+ onClick: function(){
191
+ if(open_windows > 0)
192
+ $(el_taskbar_item).trigger('click');
193
+ }
194
+ })
195
+ // -------------------------------------------
196
+ // Hide All Windows
197
+ // -------------------------------------------
198
+ menu_items.push({
199
+ html: "Hide All Windows",
200
+ onClick: function(){
201
+ if(open_windows > 0)
202
+ $(`.window[data-app="${options.app}"]`).hideWindow();
203
+ }
204
+ })
205
+ // -------------------------------------------
206
+ // Close All Windows
207
+ // -------------------------------------------
208
+ menu_items.push({
209
+ html: "Close All Windows",
210
+ onClick: function(){
211
+ $(`.window[data-app="${options.app}"]`).close();
212
+ }
213
+ })
214
+ }
215
+ const pos = el_taskbar_item.getBoundingClientRect();
216
+ UIContextMenu({
217
+ parent_element: el_taskbar_item,
218
+ position: {top: pos.top - 15, left: pos.left+5},
219
+ items: menu_items
220
+ });
221
+
222
+ return false;
223
+ });
224
+
225
+ $( el_taskbar_item ).tooltip({
226
+ items: ".taskbar:not(.children-have-open-contextmenu) .taskbar-item",
227
+ position: {
228
+ my: "center bottom-20",
229
+ at: "center top",
230
+ using: function( position, feedback ) {
231
+ $( this ).css( position );
232
+ $( "<div>" )
233
+ .addClass( "arrow" )
234
+ .addClass( feedback.vertical )
235
+ .addClass( feedback.horizontal )
236
+ .appendTo( this );
237
+ }
238
+ }
239
+ });
240
+
241
+ // --------------------------------------------------------
242
+ // Droppable
243
+ // --------------------------------------------------------
244
+ $(el_taskbar_item).droppable({
245
+ accept: '.item',
246
+ // 'pointer' is very important because of active window tracking is based on the position of cursor.
247
+ tolerance: 'pointer',
248
+ drop: async function( event, ui ) {
249
+ // Check if hovering over an item that is VISIBILE
250
+ if($(event.target).closest('.window').attr('data-id') !== $(mouseover_window).attr('data-id'))
251
+ return;
252
+
253
+ // If ctrl is pressed and source is Trashed, cancel whole operation
254
+ if(event.ctrlKey && path.dirname($(ui.draggable).attr('data-path')) === window.trash_path)
255
+ return;
256
+
257
+ const items_to_move = []
258
+
259
+ // First item
260
+ items_to_move.push(ui.draggable);
261
+
262
+ // All subsequent items
263
+ const cloned_items = document.getElementsByClassName('item-selected-clone');
264
+ for(let i =0; i<cloned_items.length; i++){
265
+ const source_item = document.getElementById('item-' + $(cloned_items[i]).attr('data-id'));
266
+ if(source_item !== null)
267
+ items_to_move.push(source_item);
268
+ }
269
+
270
+ // --------------------------------------------------------
271
+ // If `options.onItemsDrop` is set, call it with the items to move
272
+ //--------------------------------------------------------
273
+ if(options.onItemsDrop && typeof options.onItemsDrop === 'function'){
274
+ options.onItemsDrop(items_to_move);
275
+ return;
276
+ }
277
+ // --------------------------------------------------------
278
+ // If dropped on an app, open the app with the dropped item as an argument
279
+ //--------------------------------------------------------
280
+ else if(options.app){
281
+ // an array that hold the items to sign
282
+ const items_to_sign = [];
283
+
284
+ // prepare items to sign
285
+ for(let i=0; i < items_to_move.length; i++){
286
+ items_to_sign.push({
287
+ name: $(items_to_move[i]).attr('data-name'),
288
+ uid: $(items_to_move[i]).attr('data-uid'),
289
+ action: 'write',
290
+ path: $(items_to_move[i]).attr('data-path')
291
+ });
292
+ }
293
+
294
+ // open each item
295
+ for (let i = 0; i < items_to_sign.length; i++) {
296
+ const item = items_to_sign[i];
297
+ launch_app({
298
+ name: options.app,
299
+ file_path: item.path,
300
+ // app_obj: open_item_meta.suggested_apps[0],
301
+ window_title: item.name,
302
+ file_uid: item.uid,
303
+ // file_signature: item,
304
+ });
305
+ }
306
+
307
+ // deselect dragged item
308
+ for(let i=0; i < items_to_move.length; i++)
309
+ $(items_to_move[i]).removeClass('item-selected');
310
+ }
311
+
312
+ // Unselect directory/app if item is dropped
313
+ if(options.is_dir || options.app){
314
+ $(el_taskbar_item).removeClass('active');
315
+ $(el_taskbar_item).tooltip('close');
316
+ $('.ui-draggable-dragging .item-name, .item-selected-clone .item-name').css('opacity', 'initial')
317
+ $('.item-container').removeClass('item-container-transparent-border')
318
+ }
319
+
320
+ // Re-enable droppable on all item-container
321
+ $('.item-container').droppable('enable')
322
+
323
+ return false;
324
+ },
325
+ over: function(event, ui){
326
+ // Check hovering over an item that is VISIBILE
327
+ const $event_parent_win = $(event.target).closest('.window')
328
+ if( $event_parent_win.length > 0 && $event_parent_win.attr('data-id') !== $(mouseover_window).attr('data-id'))
329
+ return;
330
+ // Don't do anything if the dragged item is NOT a UIItem
331
+ if(!$(ui.draggable).hasClass('item'))
332
+ return;
333
+ // If this is a directory or an app, and an item was dragged over it, highlight it.
334
+ if(options.is_dir || options.app){
335
+ $(el_taskbar_item).addClass('active');
336
+ // show tooltip of this item
337
+ $(el_taskbar_item).tooltip().mouseover();
338
+ // make item name partially transparent
339
+ $('.ui-draggable-dragging .item-name, .item-selected-clone .item-name').css('opacity', 0.1)
340
+ // remove all item-container active borders
341
+ $('.item-container').addClass('item-container-transparent-border')
342
+ }
343
+ // Disable all window bodies
344
+ $('.item-container').droppable( 'disable' )
345
+ },
346
+ out: function(event, ui){
347
+ // Don't do anything if the dragged item is NOT a UIItem
348
+ if(!$(ui.draggable).hasClass('item'))
349
+ return;
350
+
351
+ // Unselect directory/app if item is dragged out
352
+ if(options.is_dir || options.app){
353
+ $(el_taskbar_item).removeClass('active');
354
+ $(el_taskbar_item).tooltip('close');
355
+ $('.ui-draggable-dragging .item-name, .item-selected-clone .item-name').css('opacity', 'initial')
356
+ $('.item-container').removeClass('item-container-transparent-border')
357
+ }
358
+ $('.item-container').droppable( 'enable' )
359
+ }
360
+ });
361
+
362
+ return el_taskbar_item;
363
+ }
364
+
365
+ export default UITaskbarItem
src/UI/UIWindow.js ADDED
The diff for this file is too large to render. See raw diff
 
src/UI/UIWindowChangePassword.js ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ async function UIWindowChangePassword(){
23
+ const internal_id = window.uuidv4();
24
+ let h = '';
25
+ h += `<div class="change-password" style="padding: 20px; border-bottom: 1px solid #ced7e1;">`;
26
+ // error msg
27
+ h += `<div class="form-error-msg"></div>`;
28
+ // success msg
29
+ h += `<div class="form-success-msg"></div>`;
30
+ // current password
31
+ h += `<div style="overflow: hidden; margin-bottom: 20px;">`;
32
+ h += `<label for="current-password-${internal_id}">Current Password</label>`;
33
+ h += `<input id="current-password-${internal_id}" class="current-password" type="password" name="current-password" autocomplete="current-password" />`;
34
+ h += `</div>`;
35
+ // new password
36
+ h += `<div style="overflow: hidden; margin-top: 20px; margin-bottom: 20px;">`;
37
+ h += `<label for="new-password-${internal_id}">New Password</label>`;
38
+ h += `<input id="new-password-${internal_id}" type="password" class="new-password" name="new-password" autocomplete="off" />`;
39
+ h += `</div>`;
40
+ // confirm new password
41
+ h += `<div style="overflow: hidden; margin-top: 20px; margin-bottom: 20px;">`;
42
+ h += `<label for="confirm-new-password-${internal_id}">Confirm New Password</label>`;
43
+ h += `<input id="confirm-new-password-${internal_id}" type="password" name="confirm-new-password" class="confirm-new-password" autocomplete="off" />`;
44
+ h += `</div>`;
45
+
46
+ // Change Password
47
+ h += `<button class="change-password-btn button button-primary button-block button-normal">Change Password</button>`;
48
+ h += `</div>`;
49
+
50
+ const el_window = await UIWindow({
51
+ title: 'Change Password',
52
+ app: 'change-passowrd',
53
+ single_instance: true,
54
+ icon: null,
55
+ uid: null,
56
+ is_dir: false,
57
+ body_content: h,
58
+ has_head: true,
59
+ selectable_body: false,
60
+ draggable_body: false,
61
+ allow_context_menu: false,
62
+ is_resizable: false,
63
+ is_droppable: false,
64
+ init_center: true,
65
+ allow_native_ctxmenu: false,
66
+ allow_user_select: false,
67
+ width: 350,
68
+ height: 'auto',
69
+ dominant: true,
70
+ show_in_taskbar: false,
71
+ onAppend: function(this_window){
72
+ $(this_window).find(`.current-password`).get(0).focus({preventScroll:true});
73
+ },
74
+ window_class: 'window-publishWebsite',
75
+ body_css: {
76
+ width: 'initial',
77
+ height: '100%',
78
+ 'background-color': 'rgb(245 247 249)',
79
+ 'backdrop-filter': 'blur(3px)',
80
+ }
81
+ })
82
+
83
+ $(el_window).find('.change-password-btn').on('click', function(e){
84
+ const current_password = $(el_window).find('.current-password').val();
85
+ const new_password = $(el_window).find('.new-password').val();
86
+ const confirm_new_password = $(el_window).find('.confirm-new-password').val();
87
+
88
+ let data;
89
+
90
+ if(current_password === '' || new_password === '' || confirm_new_password === ''){
91
+ $(el_window).find('.form-error-msg').html('All fields are required.');
92
+ $(el_window).find('.form-error-msg').fadeIn();
93
+ return;
94
+ }
95
+ else if(new_password !== confirm_new_password){
96
+ $(el_window).find('.form-error-msg').html('`New Password` and `Confirm New Password` do not match.');
97
+ $(el_window).find('.form-error-msg').fadeIn();
98
+ return;
99
+ }
100
+
101
+ $(el_window).find('.form-error-msg').hide();
102
+
103
+ $.ajax({
104
+ url: api_origin + "/passwd",
105
+ type: 'POST',
106
+ async: true,
107
+ headers: {
108
+ "Authorization": "Bearer "+auth_token
109
+ },
110
+ contentType: "application/json",
111
+ data: JSON.stringify({
112
+ old_pass: current_password,
113
+ new_pass: new_password,
114
+ }),
115
+ success: function (data){
116
+ $(el_window).find('.form-success-msg').html('Password changed successfully.');
117
+ $(el_window).find('.form-success-msg').fadeIn();
118
+ $(el_window).find('input').val('');
119
+ },
120
+ error: function (err){
121
+ $(el_window).find('.form-error-msg').html(err.responseText);
122
+ $(el_window).find('.form-error-msg').fadeIn();
123
+ }
124
+ });
125
+ })
126
+ }
127
+
128
+ export default UIWindowChangePassword
src/UI/UIWindowChangeUsername.js ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+ import update_username_in_gui from '../helpers/update_username_in_gui.js'
22
+
23
+ async function UIWindowChangeUsername(){
24
+ const internal_id = window.uuidv4();
25
+ let h = '';
26
+ h += `<div class="change-username" style="padding: 20px; border-bottom: 1px solid #ced7e1;">`;
27
+ // error msg
28
+ h += `<div class="form-error-msg"></div>`;
29
+ // success msg
30
+ h += `<div class="form-success-msg"></div>`;
31
+ // new username
32
+ h += `<div style="overflow: hidden; margin-top: 10px; margin-bottom: 30px;">`;
33
+ h += `<label for="confirm-new-username-${internal_id}">New Username</label>`;
34
+ h += `<input id="confirm-new-username-${internal_id}" type="text" name="new-username" class="new-username" autocomplete="off" />`;
35
+ h += `</div>`;
36
+
37
+ // Change Username
38
+ h += `<button class="change-username-btn button button-primary button-block button-normal">Change Username</button>`;
39
+ h += `</div>`;
40
+
41
+ const el_window = await UIWindow({
42
+ title: 'Change Username',
43
+ app: 'change-username',
44
+ single_instance: true,
45
+ icon: null,
46
+ uid: null,
47
+ is_dir: false,
48
+ body_content: h,
49
+ has_head: true,
50
+ selectable_body: false,
51
+ draggable_body: false,
52
+ allow_context_menu: false,
53
+ is_resizable: false,
54
+ is_droppable: false,
55
+ init_center: true,
56
+ allow_native_ctxmenu: false,
57
+ allow_user_select: false,
58
+ width: 350,
59
+ height: 'auto',
60
+ dominant: true,
61
+ show_in_taskbar: false,
62
+ onAppend: function(this_window){
63
+ $(this_window).find(`.new-username`).get(0)?.focus({preventScroll:true});
64
+ },
65
+ window_class: 'window-publishWebsite',
66
+ body_css: {
67
+ width: 'initial',
68
+ height: '100%',
69
+ 'background-color': 'rgb(245 247 249)',
70
+ 'backdrop-filter': 'blur(3px)',
71
+ }
72
+ })
73
+
74
+ $(el_window).find('.change-username-btn').on('click', function(e){
75
+ // hide previous error/success msg
76
+ $(el_window).find('.form-success-msg, .form-success-msg').hide();
77
+
78
+ const new_username = $(el_window).find('.new-username').val();
79
+
80
+ if(!new_username){
81
+ $(el_window).find('.form-error-msg').html('All fields are required.');
82
+ $(el_window).find('.form-error-msg').fadeIn();
83
+ return;
84
+ }
85
+
86
+ $(el_window).find('.form-error-msg').hide();
87
+
88
+ // disable button
89
+ $(el_window).find('.change-username-btn').addClass('disabled');
90
+ // disable input
91
+ $(el_window).find('.new-username').attr('disabled', true);
92
+
93
+ $.ajax({
94
+ url: api_origin + "/change_username",
95
+ type: 'POST',
96
+ async: true,
97
+ headers: {
98
+ "Authorization": "Bearer "+auth_token
99
+ },
100
+ contentType: "application/json",
101
+ data: JSON.stringify({
102
+ new_username: new_username,
103
+ }),
104
+ success: function (data){
105
+ $(el_window).find('.form-success-msg').html('Username updated successfully.');
106
+ $(el_window).find('.form-success-msg').fadeIn();
107
+ $(el_window).find('input').val('');
108
+ // update auth data
109
+ update_username_in_gui(new_username);
110
+ // update username
111
+ window.user.username = new_username;
112
+ // enable button
113
+ $(el_window).find('.change-username-btn').removeClass('disabled');
114
+ // enable input
115
+ $(el_window).find('.new-username').attr('disabled', false);
116
+ },
117
+ error: function (err){
118
+ $(el_window).find('.form-error-msg').html(html_encode(err.responseJSON?.message));
119
+ $(el_window).find('.form-error-msg').fadeIn();
120
+ // enable button
121
+ $(el_window).find('.change-username-btn').removeClass('disabled');
122
+ // enable input
123
+ $(el_window).find('.new-username').attr('disabled', false);
124
+ }
125
+ });
126
+ })
127
+ }
128
+
129
+ export default UIWindowChangeUsername
src/UI/UIWindowClaimReferral.js ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+ import UIWindowSaveAccount from './UIWindowSaveAccount.js';
22
+
23
+ async function UIWindowClaimReferral(options){
24
+ let h = '';
25
+
26
+ h += `<div>`;
27
+ h += `<div class="qr-code-window-close-btn generic-close-window-button disable-user-select"> &times; </div>`;
28
+ h += `<img src="${window.icons['present.svg']}" style="width: 70px; margin: 20px auto 20px; display: block; margin-bottom: 20px;">`;
29
+ h += `<h1 style="font-weight: 400; padding: 0 10px; font-size: 21px; text-align: center; margin-bottom: 0; color: #60626d; -webkit-font-smoothing: antialiased;">You have been referred to Puter by a friend!</h1>`;
30
+ h += `<p style="text-align: center; font-size: 16px; padding: 20px; font-weight: 400; margin: -10px 10px 0px 10px; -webkit-font-smoothing: antialiased; color: #5f626d;">Create an account and confirm your email address to receive 1 GB of free storage. Your friend will get 1 GB of free storage too.</p>`;
31
+ h += `<button class="button button-primary button-block create-account-ref-btn" style="display: block;">Create Account</button>`;
32
+ h += `</div>`;
33
+
34
+ const el_window = await UIWindow({
35
+ title: `Refer a friend!`,
36
+ icon: null,
37
+ uid: null,
38
+ is_dir: false,
39
+ body_content: h,
40
+ has_head: false,
41
+ selectable_body: false,
42
+ draggable_body: true,
43
+ allow_context_menu: false,
44
+ is_draggable: true,
45
+ is_resizable: false,
46
+ is_droppable: false,
47
+ init_center: true,
48
+ allow_native_ctxmenu: true,
49
+ allow_user_select: true,
50
+ onAppend: function(el_window){
51
+ },
52
+ width: 400,
53
+ dominant: true,
54
+ window_css: {
55
+ height: 'initial',
56
+ },
57
+ body_css: {
58
+ width: 'initial',
59
+ 'max-height': 'calc(100vh - 200px)',
60
+ 'background-color': 'rgb(241 246 251)',
61
+ 'backdrop-filter': 'blur(3px)',
62
+ 'padding': '10px 20px 20px 20px',
63
+ 'height': 'initial',
64
+ }
65
+ });
66
+
67
+ $(el_window).find('.create-account-ref-btn').on('click', function(e){
68
+ UIWindowSaveAccount();
69
+ $(el_window).close();
70
+ })
71
+ }
72
+
73
+ export default UIWindowClaimReferral
src/UI/UIWindowColorPicker.js ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ async function UIWindowColorPicker(options){
23
+ // set sensible defaults
24
+ if(arguments.length > 0){
25
+ // if first argument is a string, then assume it is the default color
26
+ if(isString(arguments[0])){
27
+ options = {};
28
+ options.default = arguments[0];
29
+ }
30
+ }
31
+ options = options ?? {};
32
+
33
+ return new Promise(async (resolve) => {
34
+ let colorPicker;
35
+
36
+ let h = ``;
37
+ h += `<div>`;
38
+ h += `<div style="padding: 20px; border-bottom: 1px solid #ced7e1; width: 100%; box-sizing: border-box;">`;
39
+ // picker
40
+ h += `<div style="padding: 0; margin-bottom: 20px;">`;
41
+ h += `<div class="picker"></div>`;
42
+ h += `</div>`;
43
+
44
+ // Select button
45
+ h += `<button class="select-btn button button-primary button-block button-normal">Select</button>`
46
+ h += `</form>`;
47
+ h += `</div>`;
48
+ h += `</div>`;
49
+
50
+ const el_window = await UIWindow({
51
+ title: 'Select color…',
52
+ app: 'color-picker',
53
+ single_instance: true,
54
+ icon: null,
55
+ uid: null,
56
+ is_dir: false,
57
+ body_content: h,
58
+ has_head: true,
59
+ selectable_body: false,
60
+ draggable_body: false,
61
+ allow_context_menu: false,
62
+ is_draggable: true,
63
+ is_droppable: false,
64
+ is_resizable: false,
65
+ stay_on_top: false,
66
+ allow_native_ctxmenu: true,
67
+ allow_user_select: true,
68
+ ...options.window_options,
69
+ width: 350,
70
+ dominant: true,
71
+ on_close: async ()=>{
72
+ resolve(false)
73
+ },
74
+ onAppend: function(window){
75
+ colorPicker = new iro.ColorPicker($(window).find('.picker').get(0), {
76
+ layout: [
77
+ {
78
+ component: iro.ui.Box,
79
+ options: {
80
+ layoutDirection: 'horizontal',
81
+ width: 265,
82
+ height: 265,
83
+ }
84
+ },
85
+ {
86
+ component: iro.ui.Slider,
87
+ options: {
88
+ sliderType: 'alpha',
89
+ layoutDirection: 'horizontal',
90
+ height: 265,
91
+ width:265,
92
+ }
93
+ },
94
+ {
95
+ component: iro.ui.Slider,
96
+ options: {
97
+ sliderType: 'hue',
98
+ }
99
+ },
100
+ ],
101
+ // Set the initial color to pure red
102
+ color: options.default ?? "#f00",
103
+ });
104
+ },
105
+ window_class: 'window-login',
106
+ window_css:{
107
+ height: 'initial',
108
+ },
109
+ body_css: {
110
+ width: 'initial',
111
+ padding: '0',
112
+ 'background-color': 'rgba(231, 238, 245, .95)',
113
+ 'backdrop-filter': 'blur(3px)',
114
+ }
115
+ })
116
+
117
+ $(el_window).find('.select-btn').on('click', function(e){
118
+ resolve({color: colorPicker.color.hex8String});
119
+ $(el_window).close();
120
+ })
121
+ $(el_window).find('.font-selector').on('click', function(e){
122
+ $(el_window).find('.font-selector').removeClass('font-selector-active');
123
+ $(this).addClass('font-selector-active');
124
+ })
125
+ })
126
+ }
127
+
128
+ export default UIWindowColorPicker
src/UI/UIWindowConfirmDownload.js ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ // todo do this using uid rather than item_path, since item_path is way mroe expensive on the DB
23
+ async function UIWindowConfirmDownload(options){
24
+ return new Promise(async (resolve) => {
25
+ let h = '';
26
+ h += `<div>`;
27
+ // Confirm download
28
+ h +=`<div style="margin-bottom:20px; float:left; padding-top:3px; font-size:15px; overflow: hidden; width: calc(100% - 40px); text-overflow: ellipsis; white-space: nowrap;">`;
29
+ // Message
30
+ h += `<p style="font-weight:bold;">Do you want to download this file?</p>`;
31
+ h += `<div style="overflow:hidden; float:left; width: 100px; height: 100px; display:flex; display: flex; justify-content: center; align-items: center;">`;
32
+ h += `<img style="float:left; margin-right: 7px; width: 60px; height: 60px; filter: drop-shadow(0px 0px 1px rgba(102, 102, 102, 1));" src="${html_encode((await item_icon({is_dir: options.is_dir === '1' || options.is_dir === 'true', type: options.type, name: options.name})).image)}" />`;
33
+ h += `</div>`;
34
+ // Item information
35
+ h += `<div style="overflow:hidden;">`;
36
+ // Name
37
+ h += `<p style="text-overflow: ellipsis; overflow: hidden;"><span class="dl-conf-item-attr">Name:</span> ${options.name ?? options.url}</p>`;
38
+ // Type
39
+ h += `<p style="text-overflow: ellipsis; overflow: hidden;"><span class="dl-conf-item-attr">Type:</span> ${options.is_dir === '1' || options.is_dir === 'true' ? 'Folder' : options.type ?? 'Unknown File Type'}</p>`;
40
+ // Source
41
+ h += `<p style="text-overflow: ellipsis; overflow: hidden;"><span class="dl-conf-item-attr">From:</span> ${options.source}</p>`;
42
+ h += `</div>`;
43
+ h += `</div>`;
44
+ // Download
45
+ h += `<button style="float:right; margin-top: 15px; margin-right: -2px; margin-left:10px;" class="button button-small button-primary btn-download-confirm">Download</button>`;
46
+ // Cancel
47
+ h += `<button style="float:right; margin-top: 15px;" class="button button-small btn-download-cancel">Cancel</button>`;
48
+ h +=`</div>`;
49
+
50
+ const el_window = await UIWindow({
51
+ title: `Upload`,
52
+ icon: window.icons[`app-icon-uploader.svg`],
53
+ uid: null,
54
+ is_dir: false,
55
+ body_content: h,
56
+ has_head: false,
57
+ selectable_body: false,
58
+ draggable_body: true,
59
+ allow_context_menu: false,
60
+ is_resizable: false,
61
+ is_droppable: false,
62
+ init_center: true,
63
+ allow_native_ctxmenu: false,
64
+ allow_user_select: false,
65
+ window_class: 'window-upload-progress',
66
+ width: 450,
67
+ dominant: true,
68
+ window_css:{
69
+ height: 'initial',
70
+ },
71
+ body_css: {
72
+ padding: '22px',
73
+ width: 'initial',
74
+ 'background-color': 'rgba(231, 238, 245, .95)',
75
+ 'backdrop-filter': 'blur(3px)',
76
+ }
77
+ });
78
+
79
+ $(el_window).find('.btn-download-confirm').on('click submit', function(e){
80
+ $(el_window).close();
81
+ resolve(true);
82
+ })
83
+
84
+ $(el_window).find('.btn-download-cancel').on('click submit', function(e){
85
+ $(el_window).close();
86
+ resolve(false);
87
+ })
88
+ })
89
+ }
90
+
91
+ export default UIWindowConfirmDownload
src/UI/UIWindowCopyProgress.js ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ // todo do this using uid rather than item_path, since item_path is way mroe expensive on the DB
23
+ async function UIWindowCopyProgress(options){
24
+ let h = '';
25
+ h += `<div data-copy-operation-id="${options.operation_id}">`;
26
+ h += `<div>`;
27
+ // spinner
28
+ h +=`<svg style="float:left; margin-right: 7px;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#212121" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#212121" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`;
29
+ // Progress report
30
+ h +=`<div style="margin-bottom:20px; float:left; padding-top:3px; font-size:15px; overflow: hidden; width: calc(100% - 40px); text-overflow: ellipsis; white-space: nowrap;">`;
31
+ // msg
32
+ h += `<span class="copy-progress-msg">Copying </span>`;
33
+ h += `<span class="copy-from" style="font-weight:strong;"></span>`;
34
+ h += `</div>`;
35
+ // progress
36
+ h += `<div class="copy-progress-bar-container" style="clear:both; margin-top:20px; border-radius:3px;">`;
37
+ h += `<div class="copy-progress-bar"></div>`;
38
+ h += `</div>`;
39
+ // cancel
40
+ // h += `<button style="float:right; margin-top: 15px; margin-right: -2px;" class="button button-small copy-cancel-btn">Cancel</button>`;
41
+ h +=`</div>`;
42
+ h += `</div>`;
43
+
44
+ const el_window = await UIWindow({
45
+ title: `Copying`,
46
+ icon: window.icons[`app-icon-copying.svg`],
47
+ uid: null,
48
+ is_dir: false,
49
+ body_content: h,
50
+ has_head: false,
51
+ selectable_body: false,
52
+ draggable_body: true,
53
+ allow_context_menu: false,
54
+ is_resizable: false,
55
+ is_droppable: false,
56
+ init_center: true,
57
+ allow_native_ctxmenu: false,
58
+ allow_user_select: false,
59
+ window_class: 'window-copy-progress',
60
+ width: 450,
61
+ dominant: true,
62
+ window_css:{
63
+ height: 'initial',
64
+ },
65
+ body_css: {
66
+ padding: '22px',
67
+ width: 'initial',
68
+ 'background-color': 'rgba(231, 238, 245, .95)',
69
+ 'backdrop-filter': 'blur(3px)',
70
+ }
71
+ });
72
+
73
+ $(el_window).find('.copy-cancel-btn').on('click', function(e){
74
+ operation_cancelled[options.operation_id] = true;
75
+ $(el_window).close();
76
+ })
77
+
78
+ return el_window;
79
+ }
80
+
81
+ export default UIWindowCopyProgress
src/UI/UIWindowDesktopBGSettings.js ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ async function UIWindowDesktopBGSettings(){
23
+ return new Promise(async (resolve) => {
24
+ let h = '';
25
+ const original_background_css = $('body').attr('style');
26
+ let bg_url = window.desktop_bg_url,
27
+ bg_color = window.desktop_bg_color,
28
+ bg_fit = window.desktop_bg_fit;
29
+
30
+ h += `<div style="padding: 10px; border-bottom: 1px solid #ced7e1;">`;
31
+
32
+ // type
33
+ h += `<label>Background:</label>`;
34
+ h += `<select class="desktop-bg-type" style="width: 150px; margin-bottom: 20px;">`
35
+ h += `<option value="picture">Picture</option>`;
36
+ h += `<option value="color">Color</option>`;
37
+ h += `</select>`;
38
+
39
+ // Picture
40
+ h += `<div class="desktop-bg-settings-wrapper desktop-bg-settings-picture">`;
41
+ h += `<label>Image:</label>`;
42
+ h += `<button class="button button-default button-small browse">Browse</button>`;
43
+ h += `<label style="margin-top: 20px;">Fit:</label>`;
44
+ h += `<select class="desktop-bg-fit" style="width: 150px;">`
45
+ h += `<option value="cover">Cover</option>`;
46
+ h += `<option value="center">Center</option>`;
47
+ h += `<option value="contain">Contain</option>`;
48
+ h += `<option value="repeat">Repeat</option>`;
49
+ h += `</select>`;
50
+ h += `</div>`
51
+
52
+ // Color
53
+ h += `<div class="desktop-bg-settings-wrapper desktop-bg-settings-color">`;
54
+ h += `<label>Color:</label>`;
55
+ h += `<div class="desktop-bg-color-blocks">`;
56
+ h += `<div class="desktop-bg-color-block" data-color="#4F7BB5" style="background-color: #4F7BB5"></div>`;
57
+ h += `<div class="desktop-bg-color-block" data-color="#545554" style="background-color: #545554"></div>`;
58
+ h += `<div class="desktop-bg-color-block" data-color="#F5D3CE" style="background-color: #F5D3CE"></div>`;
59
+ h += `<div class="desktop-bg-color-block" data-color="#52A758" style="background-color: #52A758"></div>`;
60
+ h += `<div class="desktop-bg-color-block" data-color="#ad3983" style="background-color: #ad3983"></div>`;
61
+ h += `<div class="desktop-bg-color-block" data-color="#ffffff" style="background-color: #ffffff"></div>`;
62
+ h += `<div class="desktop-bg-color-block" data-color="#000000" style="background-color: #000000"></div>`;
63
+ h += `<div class="desktop-bg-color-block" data-color="#454545" style="background-color: #454545"></div>`;
64
+ h += `<div class="desktop-bg-color-block desktop-bg-color-block-palette" data-color="" style="background-image: url(${window.icons['palette.svg']});
65
+ background-repeat: no-repeat;
66
+ background-size: contain;
67
+ background-position: center;"><input type="color" style="width:25px; height: 25px; opacity:0;"></div>`;
68
+ h += `</div>`;
69
+ h += `</div>`;
70
+
71
+ h += `<div style="padding-top: 5px; overflow:hidden; margin-top: 25px; border-top: 1px solid #CCC;">`
72
+ h += `<button class="button button-primary apply" style="float:right;">Apply</button>`;
73
+ h += `<button class="button button-default cancel" style="float:right; margin-right: 10px;">Cancel</button>`;
74
+ h += `</div>`;
75
+
76
+ h += `</div>`;
77
+
78
+ const el_window = await UIWindow({
79
+ title: 'Change Desktop Background…',
80
+ icon: null,
81
+ uid: null,
82
+ is_dir: false,
83
+ body_content: h,
84
+ has_head: true,
85
+ selectable_body: false,
86
+ draggable_body: false,
87
+ allow_context_menu: false,
88
+ is_resizable: false,
89
+ is_droppable: false,
90
+ init_center: true,
91
+ allow_native_ctxmenu: true,
92
+ allow_user_select: true,
93
+ onAppend: function(this_window){
94
+ $(this_window).find(`.access-recipient`).focus();
95
+ },
96
+ window_class: 'window-give-access',
97
+ width: 350,
98
+ window_css: {
99
+ height: 'initial',
100
+ },
101
+ body_css: {
102
+ width: 'initial',
103
+ height: '100%',
104
+ 'background-color': 'rgb(245 247 249)',
105
+ 'backdrop-filter': 'blur(3px)',
106
+ }
107
+ })
108
+
109
+ if(window.desktop_bg_url !== undefined && window.desktop_bg_url !== null){
110
+ $(el_window).find('.desktop-bg-settings-wrapper').hide();
111
+ $(el_window).find('.desktop-bg-settings-picture').show();
112
+ $(el_window).find('.desktop-bg-type').val('picture');
113
+ }else if(window.desktop_bg_color !== undefined && window.desktop_bg_color !== null){
114
+ $(el_window).find('.desktop-bg-settings-wrapper').hide();
115
+ $(el_window).find('.desktop-bg-settings-color').show();
116
+ $(el_window).find('.desktop-bg-type').val('color');
117
+ }else{
118
+ $(el_window).find('.desktop-bg-settings-wrapper').hide();
119
+ $(el_window).find('.desktop-bg-settings-picture').show();
120
+ $(el_window).find('.desktop-bg-type').val('picture');
121
+ }
122
+
123
+ $(el_window).find('.desktop-bg-color-block:not(.desktop-bg-color-block-palette').on('click', async function(e){
124
+ window.set_desktop_background({color: $(this).attr('data-color')})
125
+ })
126
+ $(el_window).find('.desktop-bg-color-block-palette input').on('change', async function(e){
127
+ window.set_desktop_background({color: $(this).val()})
128
+ })
129
+ $(el_window).on('file_opened', function(e){
130
+ let selected_file = Array.isArray(e.detail) ? e.detail[0] : e.detail;
131
+ const fit = $(el_window).find('.desktop-bg-fit').val();
132
+ bg_url = selected_file.read_url;
133
+ bg_fit = fit;
134
+ bg_color = undefined;
135
+ window.set_desktop_background({url: bg_url, fit: bg_fit})
136
+ })
137
+
138
+ $(el_window).find('.desktop-bg-fit').on('change', function(e){
139
+ const fit = $(this).val();
140
+ bg_fit = fit;
141
+ window.set_desktop_background({fit: fit})
142
+ })
143
+
144
+ $(el_window).find('.desktop-bg-type').on('change', function(e){
145
+ const type = $(this).val();
146
+ if(type === 'picture'){
147
+ $(el_window).find('.desktop-bg-settings-wrapper').hide();
148
+ $(el_window).find('.desktop-bg-settings-picture').show();
149
+ }else if(type==='color'){
150
+ $(el_window).find('.desktop-bg-settings-wrapper').hide();
151
+ $(el_window).find('.desktop-bg-settings-color').show();
152
+ }
153
+ })
154
+
155
+ $(el_window).find('.apply').on('click', async function(e){
156
+ // /set-desktop-bg
157
+ try{
158
+ $.ajax({
159
+ url: api_origin + "/set-desktop-bg",
160
+ type: 'POST',
161
+ data: JSON.stringify({
162
+ url: window.desktop_bg_url,
163
+ color: window.desktop_bg_color,
164
+ fit: window.desktop_bg_fit,
165
+ }),
166
+ async: true,
167
+ contentType: "application/json",
168
+ headers: {
169
+ "Authorization": "Bearer "+auth_token
170
+ },
171
+ statusCode: {
172
+ 401: function () {
173
+ logout();
174
+ },
175
+ },
176
+ })
177
+ $(el_window).close();
178
+ resolve(true);
179
+ }catch(err){
180
+ }
181
+ })
182
+
183
+ $(el_window).find('.browse').on('click', function(){
184
+ // open dialog
185
+ UIWindow({
186
+ path: '/' + window.user.username + '/Desktop',
187
+ // this is the uuid of the window to which this dialog will return
188
+ parent_uuid: $(el_window).attr('data-element_uuid'),
189
+ allowed_file_types: ['image/*'],
190
+ show_maximize_button: false,
191
+ show_minimize_button: false,
192
+ title: 'Open',
193
+ is_dir: true,
194
+ is_openFileDialog: true,
195
+ selectable_body: false,
196
+ });
197
+ })
198
+
199
+ $(el_window).find('.cancel').on('click', function(){
200
+ $('body').attr('style', original_background_css);
201
+ $(el_window).close();
202
+ resolve(true);
203
+ })
204
+ })
205
+ }
206
+
207
+ export default UIWindowDesktopBGSettings
src/UI/UIWindowDownloadDirProg.js ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ async function UIWindowDownloadDirProg(options){
23
+ options = options ?? {};
24
+
25
+ let h = '';
26
+ // Loading spinner
27
+ h +=`<svg style="height: 40px; width: 40px; padding: 10px; display: block; float: left;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#212121" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#212121" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`;
28
+ h += `<p style="text-align:left; padding-left:20px; padding-right:20px; overflow:hidden; width: 310px; text-overflow: ellipsis; white-space: nowrap; float:left; font-size:14px;" class="dir-dl-status">${options.defaultText ?? 'Preparing...'}</p>`;
29
+
30
+ const el_window = await UIWindow({
31
+ title: 'Instant Login!',
32
+ app: 'instant-login',
33
+ single_instance: true,
34
+ icon: null,
35
+ uid: null,
36
+ is_dir: false,
37
+ body_content: h,
38
+ has_head: false,
39
+ selectable_body: false,
40
+ allow_context_menu: false,
41
+ is_resizable: false,
42
+ is_droppable: false,
43
+ init_center: true,
44
+ allow_native_ctxmenu: false,
45
+ allow_user_select: false,
46
+ backdrop: false,
47
+ width: 460,
48
+ height: 'auto',
49
+ dominant: true,
50
+ show_in_taskbar: false,
51
+ draggable_body: true,
52
+ onAppend: function(this_window){
53
+ },
54
+ window_class: 'window-qr',
55
+ body_css: {
56
+ width: 'initial',
57
+ height: '100px',
58
+ 'background-color': 'rgb(245 247 249)',
59
+ 'backdrop-filter': 'blur(3px)',
60
+ 'display': 'flex',
61
+ "flex-direction": 'row',
62
+ 'justify-content': 'center',
63
+ 'align-items': 'center',
64
+ }
65
+ })
66
+
67
+ return el_window;
68
+ }
69
+
70
+ export default UIWindowDownloadDirProg
src/UI/UIWindowDownloadProgress.js ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ // todo do this using uid rather than item_path, since item_path is way mroe expensive on the DB
23
+ async function UIWindowDownloadProgress(options){
24
+ let h = '';
25
+ h += `<div data-download-operation-id="${options.operation_id}">`;
26
+ h += `<div>`;
27
+ // Spinner
28
+ h +=`<svg style="float:left; margin-right: 7px;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#212121" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#212121" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`;
29
+ // Progress report
30
+ h +=`<div style="margin-bottom:20px; float:left; padding-top:3px; font-size:15px; overflow: hidden; width: calc(100% - 40px); text-overflow: ellipsis; white-space: nowrap;">`;
31
+ // msg
32
+ h += `<span class="upload-progress-msg">Downloading <strong>${options.item_name ?? ''}</strong></span>`;
33
+ h += `</div>`;
34
+ // Progress
35
+ h += `<div class="download-progress-bar-container" style="clear:both; margin-top:20px; border-radius:3px;">`;
36
+ h += `<div class="download-progress-bar"></div>`;
37
+ h += `</div>`;
38
+ // Cancel
39
+ h += `<button style="float:right; margin-top: 15px; margin-right: -2px;" class="button button-small download-cancel-btn">Cancel</button>`;
40
+ h +=`</div>`;
41
+ h += `</div>`;
42
+
43
+ const el_window = await UIWindow({
44
+ title: `Upload`,
45
+ icon: window.icons[`app-icon-uploader.svg`],
46
+ uid: null,
47
+ is_dir: false,
48
+ body_content: h,
49
+ has_head: false,
50
+ selectable_body: false,
51
+ draggable_body: true,
52
+ allow_context_menu: false,
53
+ is_resizable: false,
54
+ is_droppable: false,
55
+ init_center: true,
56
+ allow_native_ctxmenu: false,
57
+ allow_user_select: false,
58
+ window_class: 'window-upload-progress',
59
+ width: 450,
60
+ dominant: true,
61
+ window_css:{
62
+ height: 'initial',
63
+ },
64
+ body_css: {
65
+ padding: '22px',
66
+ width: 'initial',
67
+ 'background-color': 'rgba(231, 238, 245, .95)',
68
+ 'backdrop-filter': 'blur(3px)',
69
+ }
70
+ });
71
+
72
+ // cancel download button clicked
73
+ $(el_window).find('.download-cancel-btn').on('click', function(){
74
+ operation_cancelled[options.operation_id] = true;
75
+ $(el_window).close();
76
+ })
77
+
78
+ return el_window;
79
+ }
80
+
81
+ export default UIWindowDownloadProgress
src/UI/UIWindowEmailConfirmationRequired.js ADDED
@@ -0,0 +1,275 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+ import UIAlert from './UIAlert.js'
22
+
23
+ function UIWindowEmailConfirmationRequired(options){
24
+ return new Promise(async (resolve) => {
25
+ options = options ?? {};
26
+ let final_code = '';
27
+ let is_checking_code = false;
28
+
29
+ const submit_btn_txt = 'Confirm Email'
30
+ let h = '';
31
+ h += `<div class="qr-code-window-close-btn generic-close-window-button"> &times; </div>`;
32
+ h += `<div style="-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; color: #3e5362;">`;
33
+ h += `<img src="${html_encode(window.icons['mail.svg'])}" style="display:block; margin:10px auto 10px;">`;
34
+ h += `<h3 style="text-align:center; font-weight: 500; font-size: 20px;">Confirm Your Email Address</h3>`;
35
+ h += `<form>`;
36
+ h += `<p style="text-align:center; padding: 0 20px;">To continue, please enter the 6-digit confirmation code sent to <strong style="font-weight: 500;">${window.user.email}</strong></p>`;
37
+ h += `<div class="error"></div>`;
38
+ h += ` <fieldset name="number-code" style="border: none; padding:0;" data-number-code-form>
39
+ <input class="digit-input" type="number" min='0' max='9' name='number-code-0' data-number-code-input='0' required />
40
+ <input class="digit-input" type="number" min='0' max='9' name='number-code-1' data-number-code-input='1' required />
41
+ <input class="digit-input" type="number" min='0' max='9' name='number-code-2' data-number-code-input='2' required />
42
+ <span class="email-confirm-code-hyphen">-</span>
43
+ <input class="digit-input" type="number" min='0' max='9' name='number-code-3' data-number-code-input='3' required />
44
+ <input class="digit-input" type="number" min='0' max='9' name='number-code-4' data-number-code-input='4' required />
45
+ <input class="digit-input" type="number" min='0' max='9' name='number-code-5' data-number-code-input='5' required />
46
+ </fieldset>`;
47
+ h += `<button type="submit" class="button button-block button-primary email-confirm-btn" style="margin-top:10px;" disabled>${submit_btn_txt}</button>`;
48
+ h += `</form>`;
49
+ h += `<div style="text-align:center; padding:10px; font-size:14px; margin-top:10px;">`;
50
+ h += `<span class="send-conf-email">Re-send Confirmation Code</span>`;
51
+ if(options.logout_in_footer){
52
+ h += ` &bull; `;
53
+ h += `<span class="conf-email-log-out">Log Out</span>`;
54
+ }
55
+ h += `</div>`;
56
+ h += `</div>`;
57
+
58
+ const el_window = await UIWindow({
59
+ title: null,
60
+ icon: null,
61
+ uid: null,
62
+ is_dir: false,
63
+ body_content: h,
64
+ has_head: false,
65
+ selectable_body: false,
66
+ draggable_body: true,
67
+ allow_context_menu: false,
68
+ is_draggable: options.is_draggable ?? true,
69
+ is_droppable: false,
70
+ is_resizable: false,
71
+ stay_on_top: options.stay_on_top ?? false,
72
+ allow_native_ctxmenu: true,
73
+ allow_user_select: true,
74
+ backdrop: true,
75
+ width: 390,
76
+ dominant: true,
77
+ onAppend: function(el_window){
78
+ $(el_window).find('.digit-input').first().focus();
79
+ },
80
+ window_class: 'window-item-properties',
81
+ window_css:{
82
+ height: 'initial',
83
+ },
84
+ body_css: {
85
+ padding: '30px',
86
+ width: 'initial',
87
+ height: 'initial',
88
+ 'background-color': 'rgb(247 251 255)',
89
+ 'backdrop-filter': 'blur(3px)',
90
+ }
91
+ })
92
+
93
+ $(el_window).find('.digit-input').first().focus();
94
+
95
+ $(el_window).find('.email-confirm-btn').on('click submit', function(e){
96
+ e.preventDefault();
97
+ e.stopPropagation();
98
+
99
+ $(el_window).find('.email-confirm-btn').prop('disabled', true);
100
+ $(el_window).find('.error').hide();
101
+
102
+ // Check if already checking code to prevent multiple requests
103
+ if(is_checking_code)
104
+ return;
105
+ // Confirm button
106
+ is_checking_code = true;
107
+
108
+ // set animation
109
+ $(el_window).find('.email-confirm-btn').html(`<svg style="width:20px; margin-top: 5px;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#fff" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#eee" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`);
110
+
111
+ setTimeout(() => {
112
+ $.ajax({
113
+ url: api_origin + "/confirm-email",
114
+ type: 'POST',
115
+ data: JSON.stringify({
116
+ code: final_code,
117
+ }),
118
+ async: true,
119
+ contentType: "application/json",
120
+ headers: {
121
+ "Authorization": "Bearer "+auth_token
122
+ },
123
+ statusCode: {
124
+ 401: function () {
125
+ logout();
126
+ },
127
+ },
128
+ success: function (res){
129
+ if(res.email_confirmed){
130
+ $(el_window).close();
131
+ refresh_user_data(window.auth_token)
132
+ resolve(true);
133
+ }else{
134
+ $(el_window).find('.error').html('Invalid confirmation code.');
135
+ $(el_window).find('.error').fadeIn();
136
+ $(el_window).find('.digit-input').val('');
137
+ $(el_window).find('.digit-input').first().focus();
138
+ $(el_window).find('.email-confirm-btn').prop('disabled', false);
139
+ $(el_window).find('.email-confirm-btn').html(submit_btn_txt);
140
+ }
141
+ },
142
+ error: function(res){
143
+ $(el_window).find('.error').html(res.responseJSON.error);
144
+ $(el_window).find('.error').fadeIn();
145
+ $(el_window).find('.digit-input').val('');
146
+ $(el_window).find('.digit-input').first().focus();
147
+ $(el_window).find('.email-confirm-btn').prop('disabled', false);
148
+ $(el_window).find('.email-confirm-btn').html(submit_btn_txt);
149
+ },
150
+ complete: function(){
151
+ is_checking_code = false;
152
+ }
153
+ })
154
+ }, 1000);
155
+ })
156
+
157
+ // send email confirmation
158
+ $(el_window).find('.send-conf-email').on('click', function(e){
159
+ $.ajax({
160
+ url: api_origin + "/send-confirm-email",
161
+ type: 'POST',
162
+ async: true,
163
+ contentType: "application/json",
164
+ headers: {
165
+ "Authorization": "Bearer "+auth_token
166
+ },
167
+ statusCode: {
168
+ 401: function () {
169
+ logout();
170
+ },
171
+ },
172
+ success: async function (res){
173
+ await UIAlert({
174
+ message: `A new confirmation code has been sent to <strong>${window.user.email}</strong>.`,
175
+ body_icon: window.icons['c-check.svg'],
176
+ stay_on_top: true,
177
+ backdrop: true,
178
+ })
179
+ $(el_window).find('.digit-input').first().focus();
180
+ },
181
+ complete: function(){
182
+ }
183
+ })
184
+ })
185
+
186
+ // logout
187
+ $(el_window).find('.conf-email-log-out').on('click', function(e){
188
+ logout();
189
+ $(el_window).close();
190
+ })
191
+
192
+ // Elements
193
+ const numberCodeForm = document.querySelector('[data-number-code-form]');
194
+ const numberCodeInputs = [...numberCodeForm.querySelectorAll('[data-number-code-input]')];
195
+
196
+ // Event listeners
197
+ numberCodeForm.addEventListener('input', ({ target }) => {
198
+ if(!target.value.length) { return target.value = null; }
199
+ const inputLength = target.value.length;
200
+ let currentIndex = Number(target.dataset.numberCodeInput);
201
+ if(inputLength === 2){
202
+ const inputValues = target.value.split('');
203
+ target.value = inputValues[0];
204
+ }
205
+ else if (inputLength > 1) {
206
+ const inputValues = target.value.split('');
207
+
208
+ inputValues.forEach((value, valueIndex) => {
209
+ const nextValueIndex = currentIndex + valueIndex;
210
+
211
+ if (nextValueIndex >= numberCodeInputs.length) { return; }
212
+
213
+ numberCodeInputs[nextValueIndex].value = value;
214
+ });
215
+ currentIndex += inputValues.length - 2;
216
+ }
217
+
218
+ const nextIndex = currentIndex + 1;
219
+
220
+ if (nextIndex < numberCodeInputs.length) {
221
+ numberCodeInputs[nextIndex].focus();
222
+ }
223
+
224
+ // Concatenate all inputs into one string to create the final code
225
+ final_code = '';
226
+ for(let i=0; i< numberCodeInputs.length; i++){
227
+ final_code += numberCodeInputs[i].value;
228
+ }
229
+ // Automatically submit if 6 digits entered
230
+ if(final_code.length === 6){
231
+ $(el_window).find('.email-confirm-btn').prop('disabled', false);
232
+ $(el_window).find('.email-confirm-btn').trigger('click');
233
+ }
234
+ });
235
+
236
+ numberCodeForm.addEventListener('keydown', (e) => {
237
+ const { code, target } = e;
238
+
239
+ const currentIndex = Number(target.dataset.numberCodeInput);
240
+ const previousIndex = currentIndex - 1;
241
+ const nextIndex = currentIndex + 1;
242
+
243
+ const hasPreviousIndex = previousIndex >= 0;
244
+ const hasNextIndex = nextIndex <= numberCodeInputs.length - 1
245
+
246
+ switch (code) {
247
+ case 'ArrowLeft':
248
+ case 'ArrowUp':
249
+ if (hasPreviousIndex) {
250
+ numberCodeInputs[previousIndex].focus();
251
+ }
252
+ e.preventDefault();
253
+ break;
254
+
255
+ case 'ArrowRight':
256
+ case 'ArrowDown':
257
+ if (hasNextIndex) {
258
+ numberCodeInputs[nextIndex].focus();
259
+ }
260
+ e.preventDefault();
261
+ break;
262
+ case 'Backspace':
263
+ if (!e.target.value.length && hasPreviousIndex) {
264
+ numberCodeInputs[previousIndex].value = null;
265
+ numberCodeInputs[previousIndex].focus();
266
+ }
267
+ break;
268
+ default:
269
+ break;
270
+ }
271
+ });
272
+ })
273
+ }
274
+
275
+ export default UIWindowEmailConfirmationRequired
src/UI/UIWindowFeedback.js ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ async function UIWindowQR(options){
23
+ return new Promise(async (resolve) => {
24
+ options = options ?? {};
25
+
26
+ let h = '';
27
+ h += `<div style="padding: 20px; margin-top: 0;">`;
28
+ // success
29
+ h += `<div class="feedback-sent-success">`;
30
+ h += `<img src="${html_encode(window.icons['c-check.svg'])}" style="width:50px; height:50px; display: block; margin:10px auto;">`;
31
+ h += `<p style="text-align:center; margin-bottom:10px; color: #005300; padding: 10px;">Thank you for contacting us. If you have an email associated with your account, you will hear back from us as soon as possible.</p>`;
32
+ h+= `</div>`;
33
+ // form
34
+ h += `<div class="feedback-form">`;
35
+ h += `<p style="margin-top:0; font-size: 15px; -webkit-font-smoothing: antialiased;">Please use the form below to send us your feedback, comments, and bug reports.</p>`;
36
+ h += `<textarea class="feedback-message" style="width:100%; height: 200px; padding: 10px; box-sizing: border-box;"></textarea>`;
37
+ h += `<button class="button button-primary send-feedback-btn" style="float: right; margin-bottom: 15px; margin-top: 10px;">Send</button>`;
38
+ h += `</div>`;
39
+ h += `</div>`;
40
+
41
+ const el_window = await UIWindow({
42
+ title: 'Contact Us',
43
+ app: 'feedback',
44
+ single_instance: true,
45
+ icon: null,
46
+ uid: null,
47
+ is_dir: false,
48
+ body_content: h,
49
+ has_head: true,
50
+ selectable_body: false,
51
+ draggable_body: false,
52
+ allow_context_menu: false,
53
+ is_resizable: false,
54
+ is_droppable: false,
55
+ init_center: true,
56
+ allow_native_ctxmenu: false,
57
+ allow_user_select: false,
58
+ width: 350,
59
+ height: 'auto',
60
+ dominant: true,
61
+ show_in_taskbar: false,
62
+ onAppend: function(this_window){
63
+ $(this_window).find('.feedback-message').get(0).focus({preventScroll:true});
64
+ },
65
+ window_class: 'window-feedback',
66
+ body_css: {
67
+ width: 'initial',
68
+ height: '100%',
69
+ 'background-color': 'rgb(245 247 249)',
70
+ 'backdrop-filter': 'blur(3px)',
71
+ }
72
+ })
73
+
74
+ $(el_window).find('.send-feedback-btn').on('click', function(e){
75
+ const message = $(el_window).find('.feedback-message').val();
76
+ if(message)
77
+ $(this).prop('disabled', true);
78
+ $.ajax({
79
+ url: api_origin + "/contactUs",
80
+ type: 'POST',
81
+ async: true,
82
+ contentType: "application/json",
83
+ headers: {
84
+ "Authorization": "Bearer "+auth_token
85
+ },
86
+ data: JSON.stringify({
87
+ message: message,
88
+ }),
89
+ success: async function (data){
90
+ $(el_window).find('.feedback-form').hide();
91
+ $(el_window).find('.feedback-sent-success').show(100);
92
+ }
93
+ })
94
+ })
95
+ })
96
+ }
97
+
98
+ export default UIWindowQR
src/UI/UIWindowFontPicker.js ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ let fontAvailable = new Set();
23
+ const font_list = new Set([
24
+ // Windows 10
25
+ 'Arial', 'Arial Black', 'Bahnschrift', 'Calibri', 'Cambria', 'Cambria Math', 'Candara', 'Comic Sans MS', 'Consolas', 'Constantia', 'Corbel', 'Courier New', 'Ebrima', 'Franklin Gothic Medium', 'Gabriola', 'Gadugi', 'Georgia', 'HoloLens MDL2 Assets', 'Impact', 'Ink Free', 'Javanese Text', 'Leelawadee UI', 'Lucida Console', 'Lucida Sans Unicode', 'Malgun Gothic', 'Marlett', 'Microsoft Himalaya', 'Microsoft JhengHei', 'Microsoft New Tai Lue', 'Microsoft PhagsPa', 'Microsoft Sans Serif', 'Microsoft Tai Le', 'Microsoft YaHei', 'Microsoft Yi Baiti', 'MingLiU-ExtB', 'Mongolian Baiti', 'MS Gothic', 'MV Boli', 'Myanmar Text', 'Nirmala UI', 'Palatino Linotype', 'Segoe MDL2 Assets', 'Segoe Print', 'Segoe Script', 'Segoe UI', 'Segoe UI Historic', 'Segoe UI Emoji', 'Segoe UI Symbol', 'SimSun', 'Sitka', 'Sylfaen', 'Symbol', 'Tahoma', 'Times New Roman', 'Trebuchet MS', 'Verdana', 'Webdings', 'Wingdings', 'Yu Gothic',
26
+ // macOS
27
+ 'American Typewriter', 'Andale Mono', 'Arial', 'Arial Black', 'Arial Narrow', 'Arial Rounded MT Bold', 'Arial Unicode MS', 'Avenir', 'Avenir Next', 'Avenir Next Condensed', 'Baskerville', 'Big Caslon', 'Bodoni 72', 'Bodoni 72 Oldstyle', 'Bodoni 72 Smallcaps', 'Bradley Hand', 'Brush Script MT', 'Chalkboard', 'Chalkboard SE', 'Chalkduster', 'Charter', 'Cochin', 'Comic Sans MS', 'Copperplate', 'Courier', 'Courier New', 'Didot', 'DIN Alternate', 'DIN Condensed', 'Futura', 'Geneva', 'Georgia', 'Gill Sans', 'Helvetica', 'Helvetica Neue', 'Herculanum', 'Hoefler Text', 'Impact', 'Lucida Grande', 'Luminari', 'Marker Felt', 'Menlo', 'Microsoft Sans Serif', 'Monaco', 'Noteworthy', 'Optima', 'Palatino', 'Papyrus', 'Phosphate', 'Rockwell', 'Savoye LET', 'SignPainter', 'Skia', 'Snell Roundhand', 'Tahoma', 'Times', 'Times New Roman', 'Trattatello', 'Trebuchet MS', 'Verdana', 'Zapfino',
28
+ ].sort());
29
+
30
+ // filter through available system fonts
31
+ (async () => {
32
+ await document.fonts.ready;
33
+
34
+ for (const font of font_list.values()) {
35
+ if (document.fonts.check(`12px "${font}"`)) {
36
+ fontAvailable.add(font);
37
+ }
38
+ }
39
+ })();
40
+
41
+ async function UIWindowFontPicker(options){
42
+ // set sensible defaults
43
+ if(arguments.length > 0){
44
+ // if first argument is a string, then assume it is the default color
45
+ if(isString(arguments[0])){
46
+ options = {};
47
+ options.default = arguments[0];
48
+ }
49
+ }
50
+ options = options || {};
51
+
52
+ return new Promise(async (resolve) => {
53
+ let h = ``;
54
+ h += `<div>`;
55
+ h += `<div style="padding: 20px; border-bottom: 1px solid #ced7e1; width: 100%; box-sizing: border-box;">`;
56
+ h += `<div class="font-list" style="margin-bottom: 10px; height: 200px; overflow-y: scroll; background-color: white; padding: 0 10px;">`;
57
+ fontAvailable.forEach(element => {
58
+ h += `<p class="font-selector disable-user-select ${options.default === element ? 'font-selector-active' : ''}" style="font-family: '${html_encode(element)}';" data-font-family="${html_encode(element)}">${element}</p>`; // 👉️ one, two, three, four
59
+ });
60
+ h += `</div>`;
61
+
62
+ // Select
63
+ h += `<button class="select-btn button button-primary button-block button-normal">Select</button>`
64
+ h += `</form>`;
65
+ h += `</div>`;
66
+ h += `</div>`;
67
+
68
+ const el_window = await UIWindow({
69
+ title: 'Select font…',
70
+ app: 'font-picker',
71
+ single_instance: true,
72
+ icon: null,
73
+ uid: null,
74
+ is_dir: false,
75
+ body_content: h,
76
+ has_head: true,
77
+ selectable_body: false,
78
+ draggable_body: false,
79
+ allow_context_menu: false,
80
+ is_draggable: true,
81
+ is_droppable: false,
82
+ is_resizable: false,
83
+ stay_on_top: false,
84
+ allow_native_ctxmenu: true,
85
+ allow_user_select: true,
86
+ ...options.window_options,
87
+ width: 350,
88
+ dominant: true,
89
+ on_close: ()=>{
90
+ resolve(false)
91
+ },
92
+ onAppend: function(window){
93
+ let active_font = $(window).find('.font-selector-active');
94
+ if(active_font.length > 0){
95
+ scrollParentToChild($(window).find('.font-list').get(0), active_font.get(0));
96
+ }
97
+ },
98
+ window_class: 'window-login',
99
+ window_css:{
100
+ height: 'initial',
101
+ },
102
+ body_css: {
103
+ width: 'initial',
104
+ padding: '0',
105
+ 'background-color': 'rgba(231, 238, 245, .95)',
106
+ 'backdrop-filter': 'blur(3px)',
107
+ }
108
+ })
109
+
110
+ $(el_window).find('.select-btn').on('click', function(e){
111
+ resolve({fontFamily: $(el_window).find('.font-selector-active').attr('data-font-family')});
112
+ $(el_window).close();
113
+ })
114
+ $(el_window).find('.font-selector').on('click', function(e){
115
+ $(el_window).find('.font-selector').removeClass('font-selector-active');
116
+ $(this).addClass('font-selector-active');
117
+ })
118
+ })
119
+ }
120
+
121
+ export default UIWindowFontPicker
src/UI/UIWindowGetCopyLink.js ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+ import UIPopover from './UIPopover.js'
22
+
23
+ async function UIWindowGetCopyLink(options){
24
+ let h = '';
25
+ let copy_btn_text = 'Copy Link';
26
+ let copied_btn_text = 'Copied!';
27
+ const signature = await puter.fs.sign(null, {uid: options.uid, action: 'read'})
28
+ const url = `${gui_origin}/?name=${encodeURIComponent(options.name)}&is_dir=${encodeURIComponent(options.is_dir)}&download=${encodeURIComponent(signature.items.read_url)}`;
29
+
30
+ h += `<div>`;
31
+ h += `<p style="font-size: 15px; font-weight: 400; -webkit-font-smoothing: antialiased; color: #474a57;">Share the following link with anyone and they will be able to receive a copy of <strong>${html_encode(options.name)}</strong></p>`;
32
+ h += `<input type="text" style="margin-bottom:10px;" class="downloadable-link" readonly />`;
33
+ h += `<button class="button button-primary copy-downloadable-link" style="width:130px;">${copy_btn_text}</button>`
34
+ h += `<img class="share-copy-link-on-social" src="${window.icons['share-outline.svg']}">`;
35
+ h += `</div>`;
36
+
37
+ const el_window = await UIWindow({
38
+ title: `Get Copy Link`,
39
+ icon: null,
40
+ uid: null,
41
+ is_dir: false,
42
+ body_content: h,
43
+ has_head: true,
44
+ selectable_body: false,
45
+ draggable_body: false,
46
+ allow_context_menu: false,
47
+ is_resizable: false,
48
+ is_droppable: false,
49
+ init_center: true,
50
+ allow_native_ctxmenu: true,
51
+ allow_user_select: true,
52
+ onAppend: function(el_window){
53
+ },
54
+ width: 500,
55
+ dominant: true,
56
+ window_css: {
57
+ height: 'initial',
58
+ },
59
+ body_css: {
60
+ width: 'initial',
61
+ 'max-height': 'calc(100vh - 200px)',
62
+ 'background-color': 'rgb(241 246 251)',
63
+ 'backdrop-filter': 'blur(3px)',
64
+ 'padding': '10px 20px 20px 20px',
65
+ 'height': 'initial',
66
+ }
67
+ });
68
+
69
+ $(el_window).find('.window-body .downloadable-link').val(url);
70
+
71
+ $(el_window).find('.window-body .share-copy-link-on-social').on('click', function(e){
72
+ const social_links = socialLink({url: url, title: `Get a copy of '${options.name}' on Puter.com!`, description: `Get a copy of '${options.name}' on Puter.com!`});
73
+
74
+ let social_links_html = ``;
75
+ social_links_html += `<div style="padding: 10px;">`;
76
+ social_links_html += `<p style="margin: 0; text-align: center; margin-bottom: 6px; color: #484a57; font-weight: bold; font-size: 14px;">Share to</p>`
77
+ social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.twitter}" style=""><svg viewBox="0 0 24 24" aria-hidden="true" style="opacity: 0.7;"><g><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"></path></g></svg></a>`
78
+ social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.whatsapp}" style=""><img src="${window.icons['logo-whatsapp.svg']}"></a>`
79
+ social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.facebook}" style=""><img src="${window.icons['logo-facebook.svg']}"></a>`
80
+ social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.linkedin}" style=""><img src="${window.icons['logo-linkedin.svg']}"></a>`
81
+ social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.reddit}" style=""><img src="${window.icons['logo-reddit.svg']}"></a>`
82
+ social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links['telegram.me']}" style=""><img src="${window.icons['logo-telegram.svg']}"></a>`
83
+ social_links_html += '</div>';
84
+
85
+ UIPopover({
86
+ content: social_links_html,
87
+ snapToElement: this,
88
+ parent_element: this,
89
+ // width: 300,
90
+ height: 100,
91
+ position: 'bottom',
92
+ });
93
+ })
94
+
95
+ $(el_window).find('.window-body .copy-downloadable-link').on('click', async function(e){
96
+ var copy_btn = this;
97
+ if (navigator.clipboard) {
98
+ // Get link text
99
+ const selected_text = $(el_window).find('.window-body .downloadable-link').val();
100
+ // copy selected text to clipboard
101
+ await navigator.clipboard.writeText(selected_text);
102
+ }
103
+ else{
104
+ // Get the text field
105
+ $(el_window).find('.window-body .downloadable-link').select();
106
+ // Copy the text inside the text field
107
+ document.execCommand('copy');
108
+ }
109
+
110
+ $(this).html(copied_btn_text);
111
+ setTimeout(function(){
112
+ $(copy_btn).html(copy_btn_text);
113
+ }, 1000);
114
+ });
115
+ }
116
+
117
+ export default UIWindowGetCopyLink
src/UI/UIWindowItemProperties.js ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ // todo do this using uid rather than item_path, since item_path is way mroe expensive on the DB
23
+ async function UIWindowItemProperties(item_name, item_path, item_uid, left, top, width, height){
24
+ let h = '';
25
+ h += `<div class="item-props-tabview" style="display: flex; flex-direction: column; height: 100%;">`;
26
+ // tabs
27
+ h += `<div class="item-props-tab">`;
28
+ h += `<div class="item-props-tab-btn antialiased disable-user-select item-props-tab-selected" data-tab="general">General</div>`;
29
+ h += `<div class="item-props-tab-btn antialiased disable-user-select item-props-tab-btn-versions" data-tab="versions">Versions</div>`;
30
+ h += `</div>`;
31
+
32
+ h+= `<div class="item-props-tab-content item-props-tab-content-selected" data-tab="general" style="border-top-left-radius:0;">`;
33
+ h += `<table class="item-props-tbl">`;
34
+ h += `<tr><td class="item-prop-label">Name</td><td class="item-prop-val item-prop-val-name"></td></tr>`;
35
+ h += `<tr><td class="item-prop-label">Path</td><td class="item-prop-val item-prop-val-path"></td></tr>`;
36
+ h += `<tr class="item-prop-original-name"><td class="item-prop-label">Original Name</td><td class="item-prop-val item-prop-val-original-name"></td></tr>`;
37
+ h += `<tr class="item-prop-original-path"><td class="item-prop-label">Original Path</td><td class="item-prop-val item-prop-val-original-path"></td></tr>`;
38
+ h += `<tr><td class="item-prop-label">Shortcut to</td><td class="item-prop-val item-prop-val-shortcut-to"></td></tr>`;
39
+ h += `<tr><td class="item-prop-label">UID</td><td class="item-prop-val item-prop-val-uid"></td></tr>`;
40
+ h += `<tr><td class="item-prop-label">Type</td><td class="item-prop-val item-prop-val-type"></td></tr>`;
41
+ h += `<tr><td class="item-prop-label">Size</td><td class="item-prop-val item-prop-val-size"></td></tr>`;
42
+ h += `<tr><td class="item-prop-label">Modified</td><td class="item-prop-val item-prop-val-modified"></td></tr>`;
43
+ h += `<tr><td class="item-prop-label">Created</td><td class="item-prop-val item-prop-val-created"></td></tr>`;
44
+ h += `<tr><td class="item-prop-label">Versions</td><td class="item-prop-val item-prop-val-versions"></td></tr>`;
45
+ h += `<tr><td class="item-prop-label">Associated Websites</td><td class="item-prop-val item-prop-val-websites">`;
46
+ h += `</td></tr>`;
47
+ h += `<tr><td class="item-prop-label">Access Granted To</td><td class="item-prop-val item-prop-val-permissions"></td></tr>`;
48
+ h += `</table>`;
49
+ h += `</div>`;
50
+
51
+ h += `<div class="item-props-tab-content" data-tab="versions" style="padding: 20px;">`
52
+ h += `<div class="item-props-version-list">`;
53
+ h += `</div>`;
54
+ h += `</div>`;
55
+ h += `</div>`;
56
+
57
+ const el_window = await UIWindow({
58
+ title: `${item_name} properties`,
59
+ app: item_uid+'-account',
60
+ single_instance: true,
61
+ icon: null,
62
+ uid: null,
63
+ is_dir: false,
64
+ body_content: h,
65
+ has_head: true,
66
+ selectable_body: false,
67
+ draggable_body: false,
68
+ allow_context_menu: false,
69
+ is_resizable: false,
70
+ is_droppable: false,
71
+ init_center: true,
72
+ allow_native_ctxmenu: true,
73
+ allow_user_select: true,
74
+ left: left,
75
+ top: top,
76
+ height: height,
77
+ onAppend: function(el_window){
78
+ },
79
+ width: 450,
80
+ window_class: 'window-item-properties',
81
+ window_css:{
82
+ // height: 'initial',
83
+ },
84
+ body_css: {
85
+ padding: '10px',
86
+ width: 'initial',
87
+ height: 'calc(100% - 50px)',
88
+ 'background-color': 'rgb(241 242 246)',
89
+ 'backdrop-filter': 'blur(3px)',
90
+ 'content-box': 'content-box',
91
+ }
92
+ })
93
+
94
+ // item props tab click handler
95
+ $(el_window).find('.item-props-tab-btn').click(function(e){
96
+ // unselect all tabs
97
+ $(el_window).find('.item-props-tab-btn').removeClass('item-props-tab-selected');
98
+ // select this tab
99
+ $(this).addClass('item-props-tab-selected');
100
+ // unselect all tab contents
101
+ $(el_window).find('.item-props-tab-content').removeClass('item-props-tab-content-selected');
102
+ // select this tab content
103
+ $(el_window).find(`.item-props-tab-content[data-tab="${$(this).attr('data-tab')}"]`).addClass('item-props-tab-content-selected');
104
+ })
105
+
106
+
107
+ // /stat
108
+ puter.fs.stat({
109
+ uid: item_uid,
110
+ returnSubdomains: true,
111
+ returnPermissions: true,
112
+ returnVersions: true,
113
+ returnSize: true,
114
+ success: function (fsentry){
115
+ // hide versions tab if item is a directory
116
+ if(fsentry.is_dir){
117
+ $(el_window).find('[data-tab="versions"]').hide();
118
+ }
119
+ // name
120
+ $(el_window).find('.item-prop-val-name').html(fsentry.name);
121
+ // path
122
+ $(el_window).find('.item-prop-val-path').html(item_path);
123
+ // original name & path
124
+ if(fsentry.metadata){
125
+ try{
126
+ let metadata = JSON.parse(fsentry.metadata);
127
+ if(metadata.original_name){
128
+ $(el_window).find('.item-prop-val-original-name').html(metadata.original_name);
129
+ $(el_window).find('.item-prop-original-name').show();
130
+ }
131
+ if(metadata.original_path){
132
+ $(el_window).find('.item-prop-val-original-path').html(metadata.original_path);
133
+ $(el_window).find('.item-prop-original-path').show();
134
+ }
135
+ }catch(e){}
136
+ }
137
+
138
+ // shortcut to
139
+ if(fsentry.shortcut_to && fsentry.shortcut_to_path){
140
+ $(el_window).find('.item-prop-val-shortcut-to').html(fsentry.shortcut_to_path);
141
+ }
142
+ // uid
143
+ $(el_window).find('.item-prop-val-uid').html(fsentry.id);
144
+ // type
145
+ $(el_window).find('.item-prop-val-type').html(fsentry.is_dir ? 'Directory' : (fsentry.type === null ? '-' : fsentry.type));
146
+ // size
147
+ $(el_window).find('.item-prop-val-size').html(fsentry.size === null || fsentry.size === undefined ? '-' : byte_format(fsentry.size));
148
+ // modified
149
+ $(el_window).find('.item-prop-val-modified').html(fsentry.modified === 0 ? '-' : timeago.format(fsentry.modified*1000));
150
+ // created
151
+ $(el_window).find('.item-prop-val-created').html(fsentry.created === 0 ? '-' : timeago.format(fsentry.created*1000));
152
+ // subdomains
153
+ if(fsentry.subdomains && fsentry.subdomains.length > 0 ){
154
+ fsentry.subdomains.forEach(subdomain => {
155
+ $(el_window).find('.item-prop-val-websites').append(`<p class="item-prop-website-entry" data-uuid="${subdomain.uuid}" style="margin-bottom:5px; margin-top:5px;"><a target="_blank" href="${subdomain.address}">${subdomain.address}</a> (<span class="disassociate-website-link" data-uuid="${subdomain.uuid}" data-subdomain="${extractSubdomain(subdomain.address)}">disassociate</span>)</p>`);
156
+ });
157
+ }
158
+ else{
159
+ $(el_window).find('.item-prop-val-websites').append('-');
160
+ }
161
+ // versions
162
+ if(fsentry.versions && fsentry.versions.length > 0 ){
163
+ fsentry.versions.reverse().forEach(version => {
164
+ $(el_window).find('.item-props-version-list')
165
+ .append(`<div class="item-prop-version-entry">${version.user? version.user.username : ''} &bull; ${timeago.format(version.timestamp*1000)}<p style="font-size:10px;">${version.id}</p></div>`);
166
+ });
167
+ }
168
+ else{
169
+ $(el_window).find('.item-props-version-list').append('-');
170
+ }
171
+
172
+ // owner
173
+ $(el_window).find('.item-prop-val-permissions').append(`<p class="item-prop-perm-entry" style="margin-bottom:5px; margin-top:5px;">${(fsentry.owner.email === undefined || fsentry.owner.email === null) ? fsentry.owner.username : fsentry.owner.email} (owner)</p>`);
174
+
175
+ // other users with access
176
+ if(fsentry.permissions && fsentry.permissions.length > 0 ){
177
+ fsentry.permissions.forEach(perm => {
178
+ let h = ``;
179
+ // username/email
180
+ h += `<p class="item-prop-perm-entry" data-perm-uid="${perm.uid}" style="margin-bottom:5px; margin-top:5px;">${perm.email ?? perm.username} `;
181
+ // remove
182
+ h += `(<span class="remove-permission-link" data-perm-uid="${perm.uid}">remove</span>)`;
183
+ $(el_window).find('.item-prop-val-permissions').append(h);
184
+ });
185
+ }
186
+ else{
187
+ $(el_window).find('.item-prop-val-permissions').append('-');
188
+ }
189
+
190
+ $(el_window).find(`.disassociate-website-link`).on('click', function(e){
191
+ puter.hosting.update(
192
+ $(e.target).attr('data-subdomain'),
193
+ null).then(()=>{
194
+ $(el_window).find(`.item-prop-website-entry[data-uuid="${$(e.target).attr('data-uuid')}"]`).remove();
195
+ if($(el_window).find(`.item-prop-website-entry`).length === 0){
196
+ $(el_window).find(`.item-prop-val-websites`).html('-');
197
+ // remove the website badge from all instances of the dir
198
+ $(`.item[data-uid="${item_uid}"]`).find('.item-has-website-badge').fadeOut(200);
199
+ }
200
+ }
201
+ )
202
+ })
203
+
204
+ $(el_window).find('.remove-permission-link').on('click', function(e){
205
+ const el_remove_perm_link= this;
206
+ const perm_uid = $(el_remove_perm_link).attr('data-perm-uid');
207
+ $.ajax({
208
+ url: api_origin + "/remove-perm",
209
+ type: 'POST',
210
+ async: true,
211
+ contentType: "application/json",
212
+ data: JSON.stringify({
213
+ uid: perm_uid,
214
+ }),
215
+ headers: {
216
+ "Authorization": "Bearer "+auth_token
217
+ },
218
+ statusCode: {
219
+ 401: function () {
220
+ logout();
221
+ },
222
+ },
223
+ success: async function (res){
224
+ $(el_window).find(`.item-prop-perm-entry[data-perm-uid="${perm_uid}"]`).remove();
225
+
226
+ if($(el_window).find(`.item-prop-perm-entry`).length === 0){
227
+ $(el_window).find(`.item-prop-val-permissions`).html('-');
228
+ // todo is it better to combine the following two queriesinto one css selector?
229
+ $(`.item[data-uid="${item_uid}"]`).find(`.item-is-shared`).fadeOut(200);
230
+ // todo optim do this only if item is a directory
231
+ // todo this has to be case-insensitive but the `i` selector doesn't work on ^=
232
+ $(`.item[data-path^="${item_path}/"]`).find(`.item-is-shared`).fadeOut(200);
233
+ }
234
+ },
235
+ complete: function(){
236
+ }
237
+ })
238
+ })
239
+ }
240
+ })
241
+ }
242
+
243
+ export default UIWindowItemProperties
src/UI/UIWindowLogin.js ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+ import UIWindowSignup from './UIWindowSignup.js'
22
+ import UIWindowRecoverPassword from './UIWindowRecoverPassword.js'
23
+
24
+ async function UIWindowLogin(options){
25
+ options = options ?? {};
26
+ options.reload_on_success = options.reload_on_success ?? false;
27
+ options.has_head = options.has_head ?? true;
28
+ options.send_confirmation_code = options.send_confirmation_code ?? false;
29
+ options.show_password = options.show_password ?? false;
30
+
31
+ return new Promise(async (resolve) => {
32
+ const internal_id = window.uuidv4();
33
+ let h = ``;
34
+ h += `<div style="max-width: 500px; min-width: 340px;">`;
35
+ if(!options.has_head && options.show_close_button !== false)
36
+ h += `<div class="generic-close-window-button"> &times; </div>`;
37
+ h += `<div style="padding: 20px; border-bottom: 1px solid #ced7e1; width: 100%; box-sizing: border-box;">`;
38
+ // title
39
+ h += `<h1 class="login-form-title">Log In</h1>`;
40
+ // login form
41
+ h += `<form class="login-form">`;
42
+ // error msg
43
+ h += `<div class="login-error-msg"></div>`;
44
+ // username/email
45
+ h += `<div style="overflow: hidden;">`;
46
+ h += `<label for="email_or_username-${internal_id}">Email or Username</label>`;
47
+ h += `<input id="email_or_username-${internal_id}" class="email_or_username" type="text" name="email_or_username" spellcheck="false" autocorrect="off" autocapitalize="off" data-gramm_editor="false" autocomplete="username"/>`;
48
+ h += `</div>`;
49
+ // password with conditional type based based on options.show_password
50
+ h += `<div style="overflow: hidden; margin-top: 20px; margin-bottom: 20px; position: relative;">`;
51
+ h += `<label for="password-${internal_id}">Password</label>`;
52
+ h += `<input id="password-${internal_id}" class="password" type="${options.show_password ? "text" : "password"}" name="password" autocomplete="current-password"/>`;
53
+ // show/hide icon
54
+ h += `<span style="position: absolute; right: 5%; top: 50%; cursor: pointer;" id="toggle-show-password-${internal_id}">
55
+ <img class="toggle-show-password-icon" src="${options.show_password ? window.icons["eye-closed.svg"] : window.icons["eye-open.svg"]}" width="20" height="20">
56
+ </span>`;
57
+ h += `</div>`;
58
+ // login
59
+ h += `<button class="login-btn button button-primary button-block button-normal">Log in</button>`;
60
+ // password recovery
61
+ h += `<p style="text-align:center; margin-bottom: 0;"><span class="forgot-password-link">Forgot password?</span></p>`;
62
+ h += `</form>`;
63
+ h += `</div>`;
64
+ // create account link
65
+ if(options.show_signup_button === undefined || options.show_signup_button){
66
+ h += `<div class="c2a-wrapper" style="padding:20px;">`;
67
+ h += `<button class="signup-c2a-clickable">Create Free Account</button>`;
68
+ h += `</div>`;
69
+ }
70
+ h += `</div>`;
71
+
72
+ const el_window = await UIWindow({
73
+ title: null,
74
+ app: 'login',
75
+ single_instance: true,
76
+ icon: null,
77
+ uid: null,
78
+ is_dir: false,
79
+ body_content: h,
80
+ has_head: true,
81
+ selectable_body: false,
82
+ draggable_body: false,
83
+ allow_context_menu: false,
84
+ is_draggable: options.is_draggable ?? true,
85
+ is_droppable: false,
86
+ is_resizable: false,
87
+ stay_on_top: false,
88
+ allow_native_ctxmenu: true,
89
+ allow_user_select: true,
90
+ ...options.window_options,
91
+ width: 350,
92
+ dominant: true,
93
+ on_close: ()=>{
94
+ resolve(false)
95
+ },
96
+ onAppend: function(this_window){
97
+ $(this_window).find(`.email_or_username`).get(0).focus({preventScroll:true});
98
+ },
99
+ window_class: 'window-login',
100
+ window_css:{
101
+ height: 'initial',
102
+ },
103
+ body_css: {
104
+ width: 'initial',
105
+ padding: '0',
106
+ 'background-color': 'rgb(255 255 255)',
107
+ 'backdrop-filter': 'blur(3px)',
108
+ 'display': 'flex',
109
+ 'flex-direction': 'column',
110
+ 'justify-content': 'center',
111
+ 'align-items': 'center',
112
+ }
113
+ })
114
+
115
+ $(el_window).find('.forgot-password-link').on('click', function(e){
116
+ UIWindowRecoverPassword({
117
+ window_options: {
118
+ backdrop: true,
119
+ close_on_backdrop_click: false,
120
+ }
121
+ });
122
+ })
123
+
124
+ $(el_window).find('.login-btn').on('click', function(e){
125
+ const email_username = $(el_window).find('.email_or_username').val();
126
+ const password = $(el_window).find('.password').val();
127
+ let data;
128
+
129
+ if(is_email(email_username)){
130
+ data = JSON.stringify({
131
+ email: email_username,
132
+ password: password
133
+ })
134
+ }else{
135
+ data = JSON.stringify({
136
+ username: email_username,
137
+ password: password
138
+ })
139
+ }
140
+
141
+ $(el_window).find('.login-error-msg').hide();
142
+
143
+ let headers = {};
144
+ if(window.custom_headers)
145
+ headers = window.custom_headers;
146
+
147
+ $.ajax({
148
+ url: gui_origin + "/login",
149
+ type: 'POST',
150
+ async: false,
151
+ headers: headers,
152
+ contentType: "application/json",
153
+ data: data,
154
+ success: function (data){
155
+ update_auth_data(data.token, data.user);
156
+
157
+ if(options.reload_on_success){
158
+ window.onbeforeunload = null;
159
+ window.location.replace('/');
160
+ }else
161
+ resolve(true);
162
+ $(el_window).close();
163
+ },
164
+ error: function (err){
165
+ $(el_window).find('.login-error-msg').html(err.responseText);
166
+ $(el_window).find('.login-error-msg').fadeIn();
167
+ }
168
+ });
169
+ })
170
+
171
+ $(el_window).find('.login-form').on('submit', function(e){
172
+ e.preventDefault();
173
+ e.stopPropagation();
174
+ return false;
175
+ })
176
+
177
+ $(el_window).find('.signup-c2a-clickable').on('click', async function(e){
178
+ //destroy this window
179
+ $(el_window).close();
180
+ // create Signup window
181
+ const signup = await UIWindowSignup({
182
+ referrer: options.referrer,
183
+ show_close_button: options.show_close_button,
184
+ reload_on_success: options.reload_on_success,
185
+ window_options: options.window_options,
186
+ send_confirmation_code: options.send_confirmation_code,
187
+ });
188
+ if(signup)
189
+ resolve(true);
190
+ })
191
+
192
+ $(el_window).find(`#toggle-show-password-${internal_id}`).on("click", function (e) {
193
+ options.show_password = !options.show_password;
194
+ // hide/show password and update icon
195
+ $(el_window).find(".password").attr("type", options.show_password ? "text" : "password");
196
+ $(el_window).find(".toggle-show-password-icon").attr("src", options.show_password ? window.icons["eye-closed.svg"] : window.icons["eye-open.svg"],
197
+ )
198
+ })
199
+ })
200
+ }
201
+
202
+ export default UIWindowLogin
src/UI/UIWindowLoginInProgress.js ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ async function UIWindowLoginInProgress(options){
23
+ return new Promise(async (resolve) => {
24
+ options = options ?? {};
25
+
26
+ let h = '';
27
+ h += `<div class="login-progress">`;
28
+ h += `<h1 style="text-align: center;
29
+ font-size: 20px;
30
+ padding: 10px;
31
+ font-weight: 300; margin: -10px 10px 20px 10px;">Logging in as <strong>${options.user_info.email === null ? options.user_info.username : options.user_info.email}</strong></h1>`;
32
+ // spinner
33
+ h +=`<svg style="float:left; margin-right: 7px;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#212121" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#212121" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`;
34
+
35
+ h += `</div>`;
36
+
37
+ const el_window = await UIWindow({
38
+ title: 'Instant Login!',
39
+ app: 'change-passowrd',
40
+ single_instance: true,
41
+ icon: null,
42
+ uid: null,
43
+ is_dir: false,
44
+ body_content: h,
45
+ has_head: false,
46
+ selectable_body: false,
47
+ draggable_body: false,
48
+ allow_context_menu: false,
49
+ is_resizable: false,
50
+ is_droppable: false,
51
+ init_center: true,
52
+ allow_native_ctxmenu: false,
53
+ allow_user_select: false,
54
+ width: 350,
55
+ height: 'auto',
56
+ dominant: true,
57
+ show_in_taskbar: false,
58
+ backdrop: true,
59
+ stay_on_top: true,
60
+ onAppend: function(this_window){
61
+ },
62
+ window_class: 'window-login-progress',
63
+ body_css: {
64
+ width: 'initial',
65
+ height: '100%',
66
+ 'background-color': 'rgb(245 247 249)',
67
+ 'backdrop-filter': 'blur(3px)',
68
+ }
69
+ })
70
+
71
+ setTimeout(() => {
72
+ $(el_window).close();
73
+ }, 3000);
74
+ })
75
+ }
76
+
77
+ export default UIWindowLoginInProgress
src/UI/UIWindowMoveProgress.js ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ // todo do this using uid rather than item_path, since item_path is way mroe expensive on the DB
23
+ async function UIWindowMoveProgress(options){
24
+ let h = '';
25
+ h += `<div data-move-operation-id="${options.operation_id}">`;
26
+ h += `<div>`;
27
+ // spinner
28
+ h +=`<svg style="float:left; margin-right: 7px;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#212121" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#212121" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`;
29
+ // Progress report
30
+ h +=`<div style="margin-bottom:20px; float:left; padding-top:3px; font-size:15px; overflow: hidden; width: calc(100% - 40px); text-overflow: ellipsis; white-space: nowrap;">`;
31
+ // msg
32
+ h += `<span class="move-progress-msg">Moving </span>`;
33
+ h += `<span class="move-from" style="font-weight:strong;"></span>`;
34
+ h += `</div>`;
35
+ // progress
36
+ h += `<div class="move-progress-bar-container" style="clear:both; margin-top:20px; border-radius:3px;">`;
37
+ h += `<div class="move-progress-bar"></div>`;
38
+ h += `</div>`;
39
+ // cancel
40
+ // h += `<button style="float:right; margin-top: 15px; margin-right: -2px;" class="button button-small move-cancel-btn">Cancel</button>`;
41
+ h +=`</div>`;
42
+ h += `</div>`;
43
+
44
+ const el_window = await UIWindow({
45
+ title: `moveing`,
46
+ icon: window.icons[`app-icon-moveing.svg`],
47
+ uid: null,
48
+ is_dir: false,
49
+ body_content: h,
50
+ has_head: false,
51
+ selectable_body: false,
52
+ draggable_body: true,
53
+ allow_context_menu: false,
54
+ is_resizable: false,
55
+ is_droppable: false,
56
+ init_center: true,
57
+ allow_native_ctxmenu: false,
58
+ allow_user_select: false,
59
+ window_class: 'window-move-progress',
60
+ width: 450,
61
+ dominant: true,
62
+ window_css:{
63
+ height: 'initial',
64
+ },
65
+ body_css: {
66
+ padding: '22px',
67
+ width: 'initial',
68
+ 'background-color': 'rgba(231, 238, 245, .95)',
69
+ 'backdrop-filter': 'blur(3px)',
70
+ }
71
+ });
72
+
73
+ $(el_window).find('.move-cancel-btn').on('click', function(e){
74
+ operation_cancelled[options.operation_id] = true;
75
+ $(el_window).close();
76
+ })
77
+
78
+ return el_window;
79
+ }
80
+
81
+ export default UIWindowMoveProgress
src/UI/UIWindowMyWebsites.js ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+ import UIContextMenu from './UIContextMenu.js'
22
+ import UIAlert from './UIAlert.js'
23
+
24
+ async function UIWindowMyWebsites(options){
25
+ let h = '';
26
+ h += `<div>`;
27
+ h += `</div>`;
28
+
29
+ const el_window = await UIWindow({
30
+ title: `My Websites`,
31
+ app: 'my-websites',
32
+ single_instance: true,
33
+ icon: null,
34
+ uid: null,
35
+ is_dir: false,
36
+ body_content: h,
37
+ has_head: true,
38
+ selectable_body: false,
39
+ draggable_body: false,
40
+ allow_context_menu: false,
41
+ is_resizable: false,
42
+ is_droppable: false,
43
+ init_center: true,
44
+ allow_native_ctxmenu: true,
45
+ allow_user_select: true,
46
+ width: 400,
47
+ dominant: true,
48
+ onAppend: function(el_window){
49
+ },
50
+ window_css:{
51
+ },
52
+ body_css: {
53
+ padding: '10px',
54
+ width: 'initial',
55
+ 'background-color': 'rgba(231, 238, 245)',
56
+ 'backdrop-filter': 'blur(3px)',
57
+ 'padding-bottom': 0,
58
+ 'height': '351px',
59
+ 'box-sizing': 'border-box',
60
+ }
61
+ });
62
+
63
+ // /sites
64
+ let init_ts = Date.now();
65
+ let loading = setTimeout(function(){
66
+ $(el_window).find('.window-body').html(`<p style="text-align: center;
67
+ margin-top: 40px;
68
+ margin-bottom: 50px;
69
+ -webkit-font-smoothing: antialiased;
70
+ -moz-osx-font-smoothing: grayscale;
71
+ color: #596c7c;">Loading...</p>`);
72
+ }, 1000);
73
+
74
+ puter.hosting.list().then(function (sites){
75
+ setTimeout(function(){
76
+ // clear loading
77
+ clearTimeout(loading);
78
+ // user has sites
79
+ if(sites.length > 0){
80
+ let h ='';
81
+ for(let i=0; i< sites.length; i++){
82
+ h += `<div class="mywebsites-card" data-uuid="${sites[i].uid}">`;
83
+ h += `<a class="mywebsites-address-link" href="https://${sites[i].subdomain}.puter.site" target="_blank">${sites[i].subdomain}.puter.site</a>`;
84
+ h += `<img class="mywebsites-site-setting" data-site-uuid="${sites[i].uid}" src="${html_encode(window.icons['cog.svg'])}">`;
85
+ // there is a directory associated with this site
86
+ if(sites[i].root_dir){
87
+ h += `<p class="mywebsites-dir-path" data-path="${html_encode(sites[i].root_dir.path)}" data-name="${sites[i].root_dir.name}" data-uuid="${sites[i].root_dir.id}">`;
88
+ h+= `<img src="${html_encode(window.icons['folder.svg'])}">`;
89
+ h+= `${sites[i].root_dir.path}`;
90
+ h += `</p>`;
91
+ h += `<p style="margin-bottom:0; margin-top: 20px; font-size: 13px;">`;
92
+ h += `<span class="mywebsites-dis-dir" data-dir-uuid="${sites[i].root_dir.id}" data-site-uuid="${sites[i].uid}">`;
93
+ h += `<img style="width: 16px; margin-bottom: -2px; margin-right: 4px;" src="${html_encode(window.icons['plug.svg'])}">Disassociate Folder</span>`;
94
+ h += `</p>`;
95
+ }
96
+ h += `<p class="mywebsites-no-dir-notice" data-site-uuid="${sites[i].uid}" style="${sites[i].root_dir ? `display:none;` : `display:block;`}">No directory associated with this address.</p>`;
97
+ h += `</div>`;
98
+ }
99
+ $(el_window).find('.window-body').html(h);
100
+ }
101
+ // has no sites
102
+ else{
103
+ $(el_window).find('.window-body').html(`<p style="text-align: center;
104
+ margin-top: 40px;
105
+ margin-bottom: 50px;
106
+ -webkit-font-smoothing: antialiased;
107
+ -moz-osx-font-smoothing: grayscale;
108
+ color: #596c7c;">You haven't published any websites!</p>`);
109
+ }
110
+ }, Date.now() - init_ts < 1000 ? 0 : 2000);
111
+ })
112
+ }
113
+
114
+ $(document).on('click', '.mywebsites-dir-path', function(e){
115
+ e = e.target;
116
+ UIWindow({
117
+ path: $(e).attr('data-path'),
118
+ title: $(e).attr('data-name'),
119
+ icon: window.icons['folder.svg'],
120
+ uid: $(e).attr('data-uuid'),
121
+ is_dir: true,
122
+ app: 'explorer',
123
+ });
124
+ })
125
+
126
+ $(document).on('click', '.mywebsites-site-setting', function(e){
127
+ const pos = e.target.getBoundingClientRect();
128
+ UIContextMenu({
129
+ parent_element: e.target,
130
+ position: {top: pos.top+25, left: pos.left-193},
131
+ items: [
132
+ //--------------------------------------------------
133
+ // Release Address
134
+ //--------------------------------------------------
135
+ {
136
+ html: `Release Address`,
137
+ onClick: async function(){
138
+ const alert_resp = await UIAlert({
139
+ message: `Are you sure you want to release this address?`,
140
+ buttons:[
141
+ {
142
+ label: 'Yes, Release It',
143
+ type: 'primary',
144
+ },
145
+ {
146
+ label: 'Cancel'
147
+ },
148
+ ]
149
+ })
150
+ if(alert_resp !== 'Yes, Release It'){
151
+ return;
152
+ }
153
+
154
+ $.ajax({
155
+ url: api_origin + "/delete-site",
156
+ type: 'POST',
157
+ data: JSON.stringify({
158
+ site_uuid: $(e.target).attr('data-site-uuid'),
159
+ }),
160
+ async: false,
161
+ contentType: "application/json",
162
+ headers: {
163
+ "Authorization": "Bearer "+auth_token
164
+ },
165
+ statusCode: {
166
+ 401: function () {
167
+ logout();
168
+ },
169
+ },
170
+ success: function (){
171
+ $(`.mywebsites-card[data-uuid="${$(e.target).attr('data-site-uuid')}"]`).fadeOut();
172
+ }
173
+ })
174
+ }
175
+ }
176
+ ]
177
+ });
178
+ })
179
+
180
+ $(document).on('click', '.mywebsites-dis-dir', function(e){
181
+ puter.hosting.delete(
182
+ // dir
183
+ $(e.target).attr('data-dir-uuid'),
184
+ // hostname
185
+ $(e.target).attr('data-site-uuid'),
186
+ // success
187
+ function (){
188
+ $(`.mywebsites-no-dir-notice[data-site-uuid="${$(e.target).attr('data-site-uuid')}"]`).show();
189
+ $(`.mywebsites-dir-path[data-uuid="${$(e.target).attr('data-dir-uuid')}"]`).remove();
190
+ // remove the website badge from all instances of the dir
191
+ $(`.item[data-uid="${$(e.target).attr('data-dir-uuid')}"]`).find('.item-has-website-badge').fadeOut(300);
192
+ $(e.target).hide();
193
+ }
194
+ )
195
+ })
196
+ export default UIWindowMyWebsites
src/UI/UIWindowNewFolderProgress.js ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ // todo do this using uid rather than item_path, since item_path is way mroe expensive on the DB
23
+ async function UIWindowNewFolderProgress(options){
24
+ let h = '';
25
+ h += `<div data-newfolder-operation-id="${options.operation_id}">`;
26
+ h += `<div>`;
27
+ // spinner
28
+ h +=`<svg style="float:left; margin-right: 7px;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#212121" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#212121" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`;
29
+ // message
30
+ h +=`<div style="margin-bottom:20px; float:left; padding-top:3px; font-size:15px; overflow: hidden; width: calc(100% - 40px); text-overflow: ellipsis; white-space: nowrap;">`;
31
+ // text
32
+ h += `<span class="newfolder-progress-msg">Taking a little longer than usual. Please wait...</span>`;
33
+ h += `</div>`;
34
+ h +=`</div>`;
35
+ h += `</div>`;
36
+
37
+ const el_window = await UIWindow({
38
+ title: `Creating New Folder`,
39
+ icon: window.icons[`app-icon-newfolder.svg`],
40
+ uid: null,
41
+ is_dir: false,
42
+ body_content: h,
43
+ has_head: false,
44
+ selectable_body: false,
45
+ draggable_body: true,
46
+ allow_context_menu: false,
47
+ is_resizable: false,
48
+ is_droppable: false,
49
+ init_center: true,
50
+ allow_native_ctxmenu: false,
51
+ allow_user_select: false,
52
+ window_class: 'window-newfolder-progress',
53
+ width: 450,
54
+ dominant: true,
55
+ window_css:{
56
+ height: 'initial',
57
+ },
58
+ body_css: {
59
+ padding: '22px',
60
+ width: 'initial',
61
+ 'background-color': 'rgba(231, 238, 245, .95)',
62
+ 'backdrop-filter': 'blur(3px)',
63
+ }
64
+ });
65
+
66
+ $(el_window).find('.newfolder-cancel-btn').on('click', function(e){
67
+ operation_cancelled[options.operation_id] = true;
68
+ $(el_window).close();
69
+ })
70
+
71
+ return el_window;
72
+ }
73
+
74
+ export default UIWindowNewFolderProgress
src/UI/UIWindowNewPassword.js ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+ import UIAlert from './UIAlert.js'
22
+ import UIWindowLogin from './UIWindowLogin.js'
23
+
24
+ async function UIWindowNewPassword(options){
25
+ return new Promise(async (resolve) => {
26
+ options = options ?? {};
27
+
28
+ const internal_id = window.uuidv4();
29
+ let h = '';
30
+ h += `<div class="change-password" style="padding: 20px; border-bottom: 1px solid #ced7e1;">`;
31
+ // error msg
32
+ h += `<div class="form-error-msg"></div>`;
33
+ // success msg
34
+ h += `<div class="form-success-msg"></div>`;
35
+ // new password
36
+ h += `<div style="overflow: hidden; margin-top: 20px; margin-bottom: 20px;">`;
37
+ h += `<label for="new-password-${internal_id}">New Password</label>`;
38
+ h += `<input class="new-password" id="new-password-${internal_id}" type="password" name="new-password" autocomplete="off" />`;
39
+ h += `</div>`;
40
+ // confirm new password
41
+ h += `<div style="overflow: hidden; margin-top: 20px; margin-bottom: 20px;">`;
42
+ h += `<label for="confirm-new-password-${internal_id}">Confirm New Password</label>`;
43
+ h += `<input class="confirm-new-password" id="confirm-new-password-${internal_id}" type="password" name="confirm-new-password" autocomplete="off" />`;
44
+ h += `</div>`;
45
+
46
+ // Change Password
47
+ h += `<button class="change-password-btn button button-primary button-block button-normal">Set New Password</button>`;
48
+ h += `</div>`;
49
+
50
+ const el_window = await UIWindow({
51
+ title: 'Set New Password',
52
+ app: 'change-passowrd',
53
+ single_instance: true,
54
+ icon: null,
55
+ uid: null,
56
+ is_dir: false,
57
+ body_content: h,
58
+ has_head: true,
59
+ selectable_body: false,
60
+ draggable_body: false,
61
+ allow_context_menu: false,
62
+ is_resizable: false,
63
+ is_droppable: false,
64
+ init_center: true,
65
+ allow_native_ctxmenu: false,
66
+ allow_user_select: false,
67
+ width: 350,
68
+ height: 'auto',
69
+ dominant: true,
70
+ show_in_taskbar: false,
71
+ onAppend: function(this_window){
72
+ $(this_window).find(`.new-password`).get(0)?.focus({preventScroll:true});
73
+ },
74
+ window_class: 'window-publishWebsite',
75
+ body_css: {
76
+ width: 'initial',
77
+ height: '100%',
78
+ 'background-color': 'rgb(245 247 249)',
79
+ 'backdrop-filter': 'blur(3px)',
80
+ }
81
+ })
82
+
83
+ $(el_window).find('.change-password-btn').on('click', function(e){
84
+ const new_password = $(el_window).find('.new-password').val();
85
+ const confirm_new_password = $(el_window).find('.confirm-new-password').val();
86
+
87
+ if(new_password === '' || confirm_new_password === ''){
88
+ $(el_window).find('.form-error-msg').html('All fields are required.');
89
+ $(el_window).find('.form-error-msg').fadeIn();
90
+ return;
91
+ }
92
+ else if(new_password !== confirm_new_password){
93
+ $(el_window).find('.form-error-msg').html('`New Password` and `Confirm New Password` do not match.');
94
+ $(el_window).find('.form-error-msg').fadeIn();
95
+ return;
96
+ }
97
+
98
+ $(el_window).find('.form-error-msg').hide();
99
+
100
+ $.ajax({
101
+ url: api_origin + "/set-pass-using-token",
102
+ type: 'POST',
103
+ async: true,
104
+ contentType: "application/json",
105
+ data: JSON.stringify({
106
+ password: new_password,
107
+ token: options.token,
108
+ user_id: options.user,
109
+ }),
110
+ success: async function (data){
111
+ $(el_window).close();
112
+ await UIAlert({
113
+ message: 'Password changed successfully.',
114
+ body_icon: window.icons['c-check.svg'],
115
+ stay_on_top: true,
116
+ backdrop: true,
117
+ buttons:[
118
+ {
119
+ label: 'Proceed to Login',
120
+ type: 'primary',
121
+ },
122
+ ],
123
+ window_options: {
124
+ backdrop: true,
125
+ close_on_backdrop_click: false,
126
+ }
127
+ })
128
+ await UIWindowLogin({
129
+ reload_on_success: true,
130
+ window_options:{
131
+ has_head: false
132
+ }
133
+ });
134
+ },
135
+ error: function (err){
136
+ $(el_window).find('.form-error-msg').html(err.responseText);
137
+ $(el_window).find('.form-error-msg').fadeIn();
138
+ }
139
+ });
140
+ })
141
+ })
142
+ }
143
+
144
+ export default UIWindowNewPassword
src/UI/UIWindowProgressEmptyTrash.js ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ // todo do this using uid rather than item_path, since item_path is way mroe expensive on the DB
23
+ async function UIWindowProgressEmptyTrash(options){
24
+ let h = '';
25
+ h += `<div data-newfolder-operation-id="${options.operation_id}">`;
26
+ h += `<div>`;
27
+ // spinner
28
+ h +=`<svg style="float:left; margin-right: 7px;" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 24 24"><title>circle anim</title><g fill="#212121" class="nc-icon-wrapper"><g class="nc-loop-circle-24-icon-f"><path d="M12 24a12 12 0 1 1 12-12 12.013 12.013 0 0 1-12 12zm0-22a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2z" fill="#212121" opacity=".4"></path><path d="M24 12h-2A10.011 10.011 0 0 0 12 2V0a12.013 12.013 0 0 1 12 12z" data-color="color-2"></path></g><style>.nc-loop-circle-24-icon-f{--animation-duration:0.5s;transform-origin:12px 12px;animation:nc-loop-circle-anim var(--animation-duration) infinite linear}@keyframes nc-loop-circle-anim{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}</style></g></svg>`;
29
+ // message
30
+ h +=`<div style="margin-bottom:20px; float:left; padding-top:3px; font-size:15px; overflow: hidden; width: calc(100% - 40px); text-overflow: ellipsis; white-space: nowrap;">`;
31
+ // text
32
+ h += `<span class="newfolder-progress-msg">Emptying the Trash...</span>`;
33
+ h += `</div>`;
34
+ h +=`</div>`;
35
+ h += `</div>`;
36
+
37
+ const el_window = await UIWindow({
38
+ title: `Creating New Folder`,
39
+ icon: window.icons[`app-icon-newfolder.svg`],
40
+ uid: null,
41
+ is_dir: false,
42
+ body_content: h,
43
+ has_head: false,
44
+ selectable_body: false,
45
+ draggable_body: true,
46
+ allow_context_menu: false,
47
+ is_resizable: false,
48
+ is_droppable: false,
49
+ init_center: true,
50
+ allow_native_ctxmenu: false,
51
+ allow_user_select: false,
52
+ window_class: 'window-newfolder-progress',
53
+ width: 450,
54
+ dominant: true,
55
+ window_css:{
56
+ height: 'initial',
57
+ },
58
+ body_css: {
59
+ padding: '22px',
60
+ width: 'initial',
61
+ 'background-color': 'rgba(231, 238, 245, .95)',
62
+ 'backdrop-filter': 'blur(3px)',
63
+ }
64
+ });
65
+
66
+ $(el_window).find('.newfolder-cancel-btn').on('click', function(e){
67
+ operation_cancelled[options.operation_id] = true;
68
+ $(el_window).close();
69
+ })
70
+
71
+ return el_window;
72
+ }
73
+
74
+ export default UIWindowProgressEmptyTrash
src/UI/UIWindowPublishWebsite.js ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+ import UIWindowMyWebsites from './UIWindowMyWebsites.js'
22
+
23
+ async function UIWindowPublishWebsite(target_dir_uid, target_dir_name, target_dir_path){
24
+ let h = '';
25
+ h += `<div class="window-publishWebsite-content" style="padding: 20px; border-bottom: 1px solid #ced7e1;">`;
26
+ // success
27
+ h += `<div class="window-publishWebsite-success">`;
28
+ h += `<img src="${html_encode(window.icons['c-check.svg'])}" style="width:80px; height:80px; display: block; margin:10px auto;">`;
29
+ h += `<p style="text-align:center;"><strong>${target_dir_name}</strong> has been published to:<p>`;
30
+ h += `<p style="text-align:center;"><a class="publishWebsite-published-link" target="_blank"></a><img class="publishWebsite-published-link-icon" src="${html_encode(window.icons['launch.svg'])}"></p>`;
31
+ h += `<button class="button button-normal button-block button-primary publish-window-ok-btn" style="margin-top:20px;">OK</button>`;
32
+ h+= `</div>`;
33
+ // form
34
+ h += `<form class="window-publishWebsite-form">`;
35
+ // error msg
36
+ h += `<div class="publish-website-error-msg"></div>`;
37
+ // subdomain
38
+ h += `<div style="overflow: hidden;">`;
39
+ h += `<label style="margin-bottom: 10px;">Pick a name for your website:</label>`;
40
+ h += `<div style="font-family: monospace;">https://<input class="publish-website-subdomain" style="width:235px;" type="text" autocomplete="subdomain" spellcheck="false" autocorrect="off" autocapitalize="off" data-gramm_editor="false"/>.${window.hosting_domain}</div>`;
41
+ h += `</div>`;
42
+ // uid
43
+ h += `<input class="publishWebsiteTargetDirUID" type="hidden" value="${target_dir_uid}"/>`;
44
+ // Publish
45
+ h += `<button class="publish-btn button button-action button-block button-normal">Publish</button>`
46
+ h += `</form>`;
47
+ h += `</div>`;
48
+
49
+ const el_window = await UIWindow({
50
+ title: 'Publish Website',
51
+ icon: null,
52
+ uid: null,
53
+ is_dir: false,
54
+ body_content: h,
55
+ has_head: true,
56
+ selectable_body: false,
57
+ draggable_body: false,
58
+ allow_context_menu: false,
59
+ is_resizable: false,
60
+ is_droppable: false,
61
+ init_center: true,
62
+ allow_native_ctxmenu: true,
63
+ allow_user_select: true,
64
+ width: 450,
65
+ dominant: true,
66
+ onAppend: function(this_window){
67
+ $(this_window).find(`.publish-website-subdomain`).val(generate_identifier());
68
+ $(this_window).find(`.publish-website-subdomain`).get(0).focus({preventScroll:true});
69
+ },
70
+ window_class: 'window-publishWebsite',
71
+ window_css:{
72
+ height: 'initial'
73
+ },
74
+ body_css: {
75
+ width: 'initial',
76
+ height: '100%',
77
+ 'background-color': 'rgb(245 247 249)',
78
+ 'backdrop-filter': 'blur(3px)',
79
+ }
80
+ })
81
+
82
+ $(el_window).find('.publish-btn').on('click', function(e){
83
+ // todo do some basic validation client-side
84
+
85
+ //Subdomain
86
+ let subdomain = $(el_window).find('.publish-website-subdomain').val();
87
+
88
+ // disable 'Publish' button
89
+ $(el_window).find('.publish-btn').prop('disabled', true);
90
+
91
+ puter.hosting.create(
92
+ subdomain,
93
+ target_dir_path).then((res)=>{
94
+ $(el_window).find('.window-publishWebsite-form').hide(100, function(){
95
+ let url = 'https://' + subdomain + '.' + window.hosting_domain + '/';
96
+ $(el_window).find('.publishWebsite-published-link').attr('href', url);
97
+ $(el_window).find('.publishWebsite-published-link').text(url);
98
+ $(el_window).find('.window-publishWebsite-success').show(100)
99
+ $(`.item[data-uid="${target_dir_uid}"] .item-has-website-badge`).show();
100
+ });
101
+
102
+ // find all items whose path starts with target_dir_path
103
+ $(`.item[data-path^="${target_dir_path}"]`).each(function(){
104
+ // show the link badge
105
+ $(this).find('.item-has-website-url-badge').show();
106
+ // update item's website_url attribute
107
+ $(this).attr('data-website_url', url + $(this).attr('data-path').substring(target_dir_path.length));
108
+ })
109
+
110
+ update_sites_cache();
111
+ }).catch((err)=>{
112
+ $(el_window).find('.publish-website-error-msg').html(
113
+ err.message + (
114
+ err.code === 'subdomain_limit_reached' ?
115
+ ' <span class="manage-your-websites-link">Manage Your Subdomains</span>' : ''
116
+ )
117
+ );
118
+ $(el_window).find('.publish-website-error-msg').fadeIn();
119
+ // re-enable 'Publish' button
120
+ $(el_window).find('.publish-btn').prop('disabled', false);
121
+ })
122
+ })
123
+
124
+ $(el_window).find('.publish-window-ok-btn').on('click', function(){
125
+ $(el_window).close();
126
+ })
127
+ }
128
+
129
+ $(document).on('click', '.manage-your-websites-link', async function(e){
130
+ UIWindowMyWebsites();
131
+ })
132
+
133
+
134
+ export default UIWindowPublishWebsite
src/UI/UIWindowQR.js ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ async function UIWindowQR(options){
23
+ return new Promise(async (resolve) => {
24
+ options = options ?? {};
25
+
26
+ let h = '';
27
+ // close button containing the multiplication sign
28
+ h += `<div class="qr-code-window-close-btn generic-close-window-button"> &times; </div>`;
29
+ h += `<div class="otp-qr-code">`;
30
+ h += `<h1 style="text-align: center; font-size: 16px; padding: 10px; font-weight: 400; margin: -10px 10px 20px 10px; -webkit-font-smoothing: antialiased; color: #5f626d;">Scan the code below to log into this session from other devices</h1>`;
31
+ h += `</div>`;
32
+
33
+ const el_window = await UIWindow({
34
+ title: 'Instant Login!',
35
+ app: 'instant-login',
36
+ single_instance: true,
37
+ icon: null,
38
+ uid: null,
39
+ is_dir: false,
40
+ body_content: h,
41
+ has_head: false,
42
+ selectable_body: false,
43
+ allow_context_menu: false,
44
+ is_resizable: false,
45
+ is_droppable: false,
46
+ init_center: true,
47
+ allow_native_ctxmenu: false,
48
+ allow_user_select: false,
49
+ backdrop: true,
50
+ width: 350,
51
+ height: 'auto',
52
+ dominant: true,
53
+ show_in_taskbar: false,
54
+ draggable_body: true,
55
+ onAppend: function(this_window){
56
+ },
57
+ window_class: 'window-qr',
58
+ body_css: {
59
+ width: 'initial',
60
+ height: '100%',
61
+ 'background-color': 'rgb(245 247 249)',
62
+ 'backdrop-filter': 'blur(3px)',
63
+ }
64
+ })
65
+
66
+ // generate auth token QR code
67
+ new QRCode($(el_window).find('.otp-qr-code').get(0), {
68
+ text: window.gui_origin + '?auth_token=' + window.auth_token,
69
+ width: 155,
70
+ height: 155,
71
+ colorDark : "#000000",
72
+ colorLight : "#ffffff",
73
+ correctLevel : QRCode.CorrectLevel.H
74
+ });
75
+ })
76
+ }
77
+
78
+ export default UIWindowQR
src/UI/UIWindowRecoverPassword.js ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+ import UIAlert from './UIAlert.js'
22
+
23
+ function UIWindowRecoverPassword(options){
24
+ return new Promise(async (resolve) => {
25
+ options = options ?? {};
26
+
27
+ let h = '';
28
+ h += `<div style="-webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; color: #3e5362;">`;
29
+ h += `<h3 style="text-align:center; font-weight: 400; font-size: 20px;">Recover Password</h3>`;
30
+ h += `<form class="pass-recovery-form">`;
31
+ h += `<p style="text-align:center; padding: 0 20px;"></p>`;
32
+ h += `<div class="error"></div>`;
33
+ h += `<label>Email or Username</label>`;
34
+ h += `<input class="pass-recovery-username-or-email" type="text"/>`;
35
+ h += `<button type="submit" class="send-recovery-email button button-block button-primary" style="margin-top:10px;">Send Recovery Email</button>`;
36
+ h += `</form>`;
37
+ h += `</div>`;
38
+
39
+ const el_window = await UIWindow({
40
+ title: null,
41
+ backdrop: options.backdrop ?? false,
42
+ icon: null,
43
+ uid: null,
44
+ is_dir: false,
45
+ body_content: h,
46
+ has_head: options.has_head ?? true,
47
+ selectable_body: false,
48
+ draggable_body: true,
49
+ allow_context_menu: false,
50
+ is_draggable: options.is_draggable ?? true,
51
+ is_droppable: false,
52
+ is_resizable: false,
53
+ stay_on_top: options.stay_on_top ?? false,
54
+ allow_native_ctxmenu: true,
55
+ allow_user_select: true,
56
+ width: 350,
57
+ dominant: true,
58
+ ...options.window_options,
59
+ onAppend: function(el_window){
60
+ $(el_window).find('.pass-recovery-username-or-email').first().focus();
61
+ },
62
+ window_class: 'window-item-properties',
63
+ window_css:{
64
+ height: 'initial',
65
+ },
66
+ body_css: {
67
+ padding: '10px',
68
+ width: 'initial',
69
+ height: 'initial',
70
+ 'background-color': 'rgba(231, 238, 245)',
71
+ 'backdrop-filter': 'blur(3px)',
72
+ }
73
+ })
74
+ $(el_window).find('.pass-recovery-form').on('submit', function(e){
75
+ e.preventDefault();
76
+ e.stopPropagation();
77
+ return false;
78
+ })
79
+
80
+ // Send recovery email
81
+ $(el_window).find('.send-recovery-email').on('click', function(e){
82
+ let email, username;
83
+ let input = $(el_window).find('.pass-recovery-username-or-email').val();
84
+ if(is_email(input))
85
+ email = input;
86
+ else
87
+ username = input;
88
+
89
+ // todo validation before sending
90
+ $.ajax({
91
+ url: api_origin + "/send-pass-recovery-email",
92
+ type: 'POST',
93
+ async: true,
94
+ contentType: "application/json",
95
+ data: JSON.stringify({
96
+ email: email,
97
+ username: username,
98
+ }),
99
+ statusCode: {
100
+ 401: function () {
101
+ logout();
102
+ },
103
+ },
104
+ success: async function (res){
105
+ $(el_window).close();
106
+ await UIAlert({
107
+ message: res.message,
108
+ body_icon: window.icons['c-check.svg'],
109
+ stay_on_top: true,
110
+ backdrop: true,
111
+ window_options: {
112
+ backdrop: true,
113
+ close_on_backdrop_click: false,
114
+ }
115
+ })
116
+ },
117
+ error: function (err){
118
+ $(el_window).find('.error').html(err.responseText);
119
+ $(el_window).find('.error').fadeIn();
120
+ },
121
+ complete: function(){
122
+ }
123
+ })
124
+ })
125
+ })
126
+ }
127
+
128
+ export default UIWindowRecoverPassword
src/UI/UIWindowRefer.js ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+ import UIPopover from './UIPopover.js'
22
+
23
+ async function UIWindowRefer(options){
24
+ let h = '';
25
+ let copy_btn_text = 'Copy Link';
26
+ let copied_btn_text = 'Copied!';
27
+ const url = `${gui_origin}/?r=${user.referral_code}`;
28
+
29
+ h += `<div>`;
30
+ h += `<div class="qr-code-window-close-btn generic-close-window-button disable-user-select"> &times; </div>`;
31
+ h += `<img src="${window.icons['present.svg']}" style="width: 70px; margin: 20px auto 20px; display: block; margin-bottom: 20px;">`;
32
+ h += `<p style="text-align: center; font-size: 16px; padding: 20px; font-weight: 400; margin: -10px 10px 20px 10px; -webkit-font-smoothing: antialiased; color: #5f626d;">Get 1 GB for every friend who creates and confirms an account on Puter. Your friend will get 1 GB too!</p>`;
33
+ h += `<label style="font-weight: bold;">Invite link</label>`;
34
+ h += `<input type="text" style="margin-bottom:10px;" class="downloadable-link" readonly />`;
35
+ h += `<button class="button button-primary copy-downloadable-link" style="width:130px;">${copy_btn_text}</button>`
36
+ h += `<img class="share-copy-link-on-social" src="${window.icons['share-outline.svg']}">`;
37
+ h += `</div>`;
38
+
39
+ const el_window = await UIWindow({
40
+ title: `Refer a friend!`,
41
+ icon: null,
42
+ uid: null,
43
+ is_dir: false,
44
+ body_content: h,
45
+ has_head: false,
46
+ selectable_body: false,
47
+ draggable_body: true,
48
+ allow_context_menu: false,
49
+ is_draggable: true,
50
+ is_resizable: false,
51
+ is_droppable: false,
52
+ init_center: true,
53
+ allow_native_ctxmenu: true,
54
+ allow_user_select: true,
55
+ onAppend: function(el_window){
56
+ },
57
+ width: 500,
58
+ dominant: true,
59
+ window_css: {
60
+ height: 'initial',
61
+ },
62
+ body_css: {
63
+ width: 'initial',
64
+ 'max-height': 'calc(100vh - 200px)',
65
+ 'background-color': 'rgb(241 246 251)',
66
+ 'backdrop-filter': 'blur(3px)',
67
+ 'padding': '10px 20px 20px 20px',
68
+ 'height': 'initial',
69
+ }
70
+ });
71
+
72
+ $(el_window).find('.window-body .downloadable-link').val(url);
73
+
74
+ $(el_window).find('.window-body .share-copy-link-on-social').on('click', function(e){
75
+ const social_links = socialLink({url: url, title: `Get 1 GB of free storage on Puter.com!`, description: `Get 1 GB of free storage on Puter.com!`});
76
+
77
+ let social_links_html = ``;
78
+ social_links_html += `<div style="padding: 10px;">`;
79
+ social_links_html += `<p style="margin: 0; text-align: center; margin-bottom: 6px; color: #484a57; font-weight: bold; font-size: 14px;">Share to</p>`
80
+ social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.twitter}" style=""><svg viewBox="0 0 24 24" aria-hidden="true" style="opacity: 0.7;"><g><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"></path></g></svg></a>`
81
+ social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.whatsapp}" style=""><img src="${window.icons['logo-whatsapp.svg']}"></a>`
82
+ social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.facebook}" style=""><img src="${window.icons['logo-facebook.svg']}"></a>`
83
+ social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.linkedin}" style=""><img src="${window.icons['logo-linkedin.svg']}"></a>`
84
+ social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links.reddit}" style=""><img src="${window.icons['logo-reddit.svg']}"></a>`
85
+ social_links_html += `<a class="copy-link-social-btn" target="_blank" href="${social_links['telegram.me']}" style=""><img src="${window.icons['logo-telegram.svg']}"></a>`
86
+ social_links_html += '</div>';
87
+
88
+ UIPopover({
89
+ content: social_links_html,
90
+ snapToElement: this,
91
+ parent_element: this,
92
+ // width: 300,
93
+ height: 100,
94
+ position: 'bottom',
95
+ });
96
+ })
97
+
98
+ $(el_window).find('.window-body .copy-downloadable-link').on('click', async function(e){
99
+ var copy_btn = this;
100
+ if (navigator.clipboard) {
101
+ // Get link text
102
+ const selected_text = $(el_window).find('.window-body .downloadable-link').val();
103
+ // copy selected text to clipboard
104
+ await navigator.clipboard.writeText(selected_text);
105
+ }
106
+ else{
107
+ // Get the text field
108
+ $(el_window).find('.window-body .downloadable-link').select();
109
+ // Copy the text inside the text field
110
+ document.execCommand('copy');
111
+ }
112
+
113
+ $(this).html(copied_btn_text);
114
+ setTimeout(function(){
115
+ $(copy_btn).html(copy_btn_text);
116
+ }, 1000);
117
+ });
118
+ }
119
+
120
+ export default UIWindowRefer
src/UI/UIWindowRequestFiles.js ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ async function UIWindowRequestFiles(options){
23
+ let h = '';
24
+ h += `<div>`;
25
+ h += `<h3 style="margin-bottom: 0;">File Request Link:</h3>`;
26
+ h += `<p style="word-break: break-all;" class="filereq-link"></p>`;
27
+ h += `</div>`;
28
+
29
+ const el_window = await UIWindow({
30
+ title: `Request Files`,
31
+ icon: null,
32
+ uid: null,
33
+ is_dir: false,
34
+ body_content: h,
35
+ has_head: true,
36
+ selectable_body: false,
37
+ draggable_body: false,
38
+ allow_context_menu: false,
39
+ is_resizable: false,
40
+ is_droppable: false,
41
+ init_center: true,
42
+ allow_native_ctxmenu: true,
43
+ allow_user_select: true,
44
+ width: 400,
45
+ dominant: true,
46
+ onAppend: function(el_window){
47
+ },
48
+ window_class: 'window-item-properties',
49
+ window_css:{
50
+ height: 'initial',
51
+ },
52
+ body_css: {
53
+ padding: '10px',
54
+ width: 'initial',
55
+ 'max-height': 'calc(100vh - 200px)',
56
+ 'background-color': 'rgba(231, 238, 245)',
57
+ 'backdrop-filter': 'blur(3px)',
58
+ 'padding-bottom': 0,
59
+ 'height': 'initial',
60
+ }
61
+ });
62
+
63
+ //check if there is a fr token available
64
+ let stat = await puter.fs.stat(options.dir_path);
65
+ if(stat.file_request_url !== undefined && stat.file_request_url !== null && stat.file_request_url !== ''){
66
+ $(el_window).find('.filereq-link').html(stat.file_request_url);
67
+ }
68
+ // generate new fr url
69
+ else{
70
+ $.ajax({
71
+ url: api_origin + "/filereq",
72
+ type: 'POST',
73
+ data: JSON.stringify({
74
+ dir_path: options.dir_path
75
+ }),
76
+ async: true,
77
+ contentType: "application/json",
78
+ headers: {
79
+ "Authorization": "Bearer "+auth_token
80
+ },
81
+ statusCode: {
82
+ 401: function (){
83
+ logout();
84
+ },
85
+ },
86
+ success: function (filereq){
87
+ $(el_window).find('.filereq-link').html(filereq.url);
88
+ }
89
+ });
90
+ }
91
+ }
92
+
93
+ export default UIWindowRequestFiles
src/UI/UIWindowRequestPermission.js ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Copyright (C) 2024 Puter Technologies Inc.
3
+ *
4
+ * This file is part of Puter.
5
+ *
6
+ * Puter is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU Affero General Public License as published
8
+ * by the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU Affero General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Affero General Public License
17
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ import UIWindow from './UIWindow.js'
21
+
22
+ async function UIWindowRequestPermission(options){
23
+ options = options ?? {};
24
+ options.reload_on_success = options.reload_on_success ?? false;
25
+ return new Promise(async (resolve) => {
26
+ let drivers = [
27
+ {
28
+ name: 'puter-chat-completion',
29
+ human_name: 'AI Chat Completion',
30
+ description: 'This app wants to generate text using AI. This may incur costs on your behalf.',
31
+ },
32
+ {
33
+ name: 'puter-image-generation',
34
+ human_name: 'AI Image Generation',
35
+ description: 'This app wants to generate images using AI. This may incur costs on your behalf.',
36
+ },
37
+ {
38
+ name: 'puter-kvstore',
39
+ human_name: 'Puter Storage',
40
+ description: 'This app wants to securely store data in your Puter account. This app will not be able to access your personal data or data stored by other apps.',
41
+ }
42
+
43
+ ]
44
+
45
+ let parts = options.permission.split(":");
46
+ let driver_name = parts[1];
47
+ let action_name = parts[2];
48
+
49
+ function findDriverByName(driverName) {
50
+ return drivers.find(driver => driver.name === driverName);
51
+ }
52
+
53
+ let driver = findDriverByName(driver_name);
54
+
55
+ if(driver === undefined){
56
+ resolve(false);
57
+ return;
58
+ }
59
+
60
+ let h = ``;
61
+ h += `<div>`;
62
+ h += `<div style="padding: 20px; width: 100%; box-sizing: border-box;">`;
63
+ // title
64
+ h += `<h1 class="perm-title">"<span style="word-break: break-word;">${html_encode(options.app_uid ?? options.origin)}</span>" would Like to use ${html_encode(driver.human_name)}</h1>`;
65
+ // todo show the real description of action
66
+ h += `<p class="perm-description">${html_encode(driver.description)}</p>`;
67
+ // Allow/Don't Allow
68
+ h += `<button type="button" class="app-auth-allow button button-primary button-block" style="margin-top: 10px;">Allow</button>`;
69
+ h += `<button type="button" class="app-auth-dont-allow button button-default button-block" style="margin-top: 10px;">Don't Allow</button>`;
70
+ h += `</div>`;
71
+ h += `</div>`;
72
+
73
+ const el_window = await UIWindow({
74
+ title: null,
75
+ app: 'request-authorization',
76
+ single_instance: true,
77
+ icon: null,
78
+ uid: null,
79
+ is_dir: false,
80
+ body_content: h,
81
+ has_head: true,
82
+ selectable_body: false,
83
+ draggable_body: true,
84
+ allow_context_menu: false,
85
+ is_draggable: true,
86
+ is_droppable: false,
87
+ is_resizable: false,
88
+ stay_on_top: false,
89
+ allow_native_ctxmenu: true,
90
+ allow_user_select: true,
91
+ ...options.window_options,
92
+ width: 350,
93
+ dominant: true,
94
+ on_close: ()=>{
95
+ resolve(false)
96
+ },
97
+ onAppend: function(this_window){
98
+ },
99
+ window_class: 'window-login',
100
+ window_css:{
101
+ height: 'initial',
102
+ },
103
+ body_css: {
104
+ width: 'initial',
105
+ padding: '0',
106
+ 'background-color': 'rgba(231, 238, 245, .95)',
107
+ 'backdrop-filter': 'blur(3px)',
108
+ }
109
+ })
110
+
111
+ $(el_window).find('.app-auth-allow').on('click', async function(e){
112
+ $(this).addClass('disabled');
113
+
114
+ try{
115
+ const res = await fetch( window.api_origin + "/auth/grant-user-app", {
116
+ "headers": {
117
+ "Content-Type": "application/json",
118
+ "Authorization": "Bearer " + window.auth_token,
119
+ },
120
+ "body": JSON.stringify({
121
+ app_uid: options.app_uid,
122
+ origin: options.origin,
123
+ permission: options.permission
124
+ }),
125
+ "method": "POST",
126
+ });
127
+ }catch(err){
128
+ console.error(err);
129
+ resolve(err);
130
+ }
131
+
132
+ resolve(true);
133
+ })
134
+
135
+ $(el_window).find('.app-auth-dont-allow').on('click', function(e){
136
+ $(this).addClass('disabled');
137
+ $(el_window).close();
138
+ resolve(false);
139
+ })
140
+ })
141
+ }
142
+
143
+ export default UIWindowRequestPermission