Initial commit; does not yet work.

This commit is contained in:
Simon Brooke 2020-02-25 09:45:17 +00:00
commit bca0f8492d
600 changed files with 171999 additions and 0 deletions

277
LICENSE.md Normal file
View file

@ -0,0 +1,277 @@
GNU General Public License
==========================
_Version 2, June 1991_
_Copyright © 1989, 1991 Free Software Foundation, Inc.,_
_51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA_
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
### Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: **(1)** copyright the software, and
**(2)** offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
**0.** This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The “Program”, below,
refers to any such program or work, and a “work based on the Program”
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term “modification”.) Each licensee is addressed as “you”.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
**1.** You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
**2.** You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
* **a)** You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
* **b)** You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
* **c)** If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
**3.** You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
* **a)** Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
* **b)** Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
* **c)** Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
**4.** You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
**5.** You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
**6.** Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
**7.** If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
**8.** If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
**9.** The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and “any
later version”, you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
**10.** If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
### NO WARRANTY
**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
**12.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS

38
README.md Normal file
View file

@ -0,0 +1,38 @@
# geocsv-js
An even more ultra-lightweight tool to show comma-separated value data on a map.
## WARNING
Doesn't work yet.
## Overview
This is a third iteration of GeoCSV. The [original](https://github.com/simon-brooke/geocsv) was written quickly in Clojure and ClojureScript, with CSV parsing done server side and React (via [re-frame](https://github.com/day8/re-frame)) driving the client side. That's my comfort zone; but it had the benefit that my customer wanted to pull data from Google Sheets, which you can't do from client side (or at least I don't know how to) because of cross-site scripting protections.
But it's also ludicroously heavyweight for what seemed such a simple requirement. The second iteration, [geocsv-lite](https://simon-brooke.github.io/geocsv-lite/), was written in ClojureScript without heavyweight libraries, and is client-side only. It works, as you can see; but it still results in a much heavier page than I think is justified.
So this project is well out of my comfort zone: it's an attempt to build as lightweight as possible in raw JavaScript, without frameworks or big libraries. Of course, this version also cannot pull data from remote sites because of cross-site scripting rules, and I haven't found a workaround for that.
However, if all you want to do is pull data from the same server you're serving the page from, this will work for you.
The CSV file must have
* column names in the first row;
* data in all other rows;
* a column whose name is `name`, which always contains data;
* a column whose name is `latitude`, whose value is always a number between -90.0 and 90.0;
* a column whose name is `longitude`, whose value is always a number between -180.0 and 180.90
Additionally, the value of the column `category`, if present, will be used to select map pins from the map pins folder, if a suitable pin is present. Thus is the value of `category` is `foo`, a map pin image with the name `Foo-pin.png` will be selected.
Note that, unlike in **geocsv**, *THERE IS NO DEFAULT PIN*, as there is no server side intelligence so we cannot query the server for pin names. So a default pin will be shown only if either
1. There is no `category` column, or
2. If the `category` column is empty
## License
Copyright © 2020 Simon Brooke
Licensed under the GNU General Public License, version 2.0 or (at your option) any later version.

42
dev/user.clj Normal file
View file

@ -0,0 +1,42 @@
(ns user
(:require
[figwheel-sidecar.repl-api :as f]))
;; user is a namespace that the Clojure runtime looks for and
;; loads if its available
;; You can place helper functions in here. This is great for starting
;; and stopping your webserver and other development services
;; The definitions in here will be available if you run "lein repl" or launch a
;; Clojure repl some other way
;; You have to ensure that the libraries you :require are listed in your dependencies
;; Once you start down this path
;; you will probably want to look at
;; tools.namespace https://github.com/clojure/tools.namespace
;; and Component https://github.com/stuartsierra/component
(defn fig-start
"This starts the figwheel server and watch based auto-compiler."
[]
;; this call will only work as long as your :cljsbuild and
;; :figwheel configurations are at the top level of your project.clj
;; and are not spread across different lein profiles
;; otherwise you can pass a configuration into start-figwheel! manually
(f/start-figwheel!))
(defn fig-stop
"Stop the figwheel server and watch based auto-compiler."
[]
(f/stop-figwheel!))
;; if you are in an nREPL environment you will need to make sure you
;; have setup piggieback for this to work
(defn cljs-repl
"Launch a ClojureScript REPL that is connected to your build and host environment."
[]
(f/cljs-repl))

75
docs/css/style.css Normal file
View file

@ -0,0 +1,75 @@
/* some style */
body {
font-family: Helvetica, Ariel, sans-serif;
padding-bottom: 4em;
}
footer {
clear: both;
font-size: smaller;
text-align: center;
color:white;
background-color: #3298dc;
width: 100%;
margin: 0;
padding: 0.25em 0;
bottom:0;
position:fixed;
vertical-align: top;
z-index:150;
_position:absolute;
_top:expression(eval(document.documentElement.scrollTop+
(document.documentElement.clientHeight-this.offsetHeight)));
}
footer a {
color: #ddd;
}
h1, h2, h3, h4, h5, h6 {
margin: 0;
padding: 0.5em 10%;
text-align: left;
background-color: #3298dc;
color: white;
}
samp {
background-color: #b0b0ff;
}
#app {
margin-left: 10%;
}
#app h2 {
width: 60%;
}
#error
{
background-color: maroon;
color: white;
margin: 0px;
padding-left: 10%;
}
#message
{
background-color: darkgreen;
color: white;
margin: 0px;
padding-left: 10%;
}
.geocsv {
height: 600px;
width: 80%;
border: thin solid gray;
}
.leaflet-popup-content h5 {
width: 80%;
}

View file

@ -0,0 +1,59 @@
Country,Name,Latitude,Longitude,CountryCode,Continent
Somaliland,Hargeisa,9.55,44.050000,NULL,Africa
Western Sahara,El-Aaiún,27.153611,-13.203333,EH,Africa
Algeria,Algiers,36.75,3.050000,DZ,Africa
Angola,Luanda,-8.833333333333334,13.216667,AO,Africa
Benin,Porto-Novo,6.483333333333333,2.616667,BJ,Africa
Botswana,Gaborone,-24.633333333333333,25.900000,BW,Africa
Burkina Faso,Ouagadougou,12.366666666666667,-1.516667,BF,Africa
Burundi,Bujumbura,-3.3666666666666667,29.350000,BI,Africa
Cameroon,Yaounde,3.8666666666666667,11.516667,CM,Africa
Cape Verde,Praia,14.916666666666666,-23.516667,CV,Africa
Central African Republic,Bangui,4.366666666666666,18.583333,CF,Africa
Chad,N'Djamena,12.1,15.033333,TD,Africa
Comoros,Moroni,-11.7,43.233333,KM,Africa
Democratic Republic of the Congo,Kinshasa,-4.316666666666666,15.300000,CD,Africa
Republic of Congo,Brazzaville,-4.25,15.283333,CG,Africa
Cote d'Ivoire,Yamoussoukro,6.816666666666666,-5.266667,CI,Africa
Djibouti,Djibouti,11.583333333333334,43.150000,DJ,Africa
Egypt,Cairo,30.05,31.250000,EG,Africa
Equatorial Guinea,Malabo,3.75,8.783333,GQ,Africa
Eritrea,Asmara,15.333333333333334,38.933333,ER,Africa
Ethiopia,Addis Ababa,9.033333333333333,38.700000,ET,Africa
Gabon,Libreville,0.38333333333333336,9.450000,GA,Africa
The Gambia,Banjul,13.45,-16.566667,GM,Africa
Ghana,Accra,5.55,-0.216667,GH,Africa
Guinea,Conakry,9.5,-13.700000,GN,Africa
Guinea-Bissau,Bissau,11.85,-15.583333,GW,Africa
Kenya,Nairobi,-1.2833333333333332,36.816667,KE,Africa
Lesotho,Maseru,-29.316666666666666,27.483333,LS,Africa
Liberia,Monrovia,6.3,-10.800000,LR,Africa
Libya,Tripoli,32.88333333333333,13.166667,LY,Africa
Madagascar,Antananarivo,-18.916666666666668,47.516667,MG,Africa
Malawi,Lilongwe,-13.966666666666667,33.783333,MW,Africa
Mali,Bamako,12.65,-8.000000,ML,Africa
Mauritania,Nouakchott,18.066666666666666,-15.966667,MR,Africa
Mauritius,Port Louis,-20.15,57.483333,MU,Africa
Morocco,Rabat,34.016666666666666,-6.816667,MA,Africa
Mozambique,Maputo,-25.95,32.583333,MZ,Africa
Namibia,Windhoek,-22.566666666666666,17.083333,NA,Africa
Niger,Niamey,13.516666666666667,2.116667,NE,Africa
Nigeria,Abuja,9.083333333333334,7.533333,NG,Africa
Rwanda,Kigali,-1.95,30.050000,RW,Africa
Saint Helena,Jamestown,-15.933333333333334,-5.716667,SH,Africa
Sao Tome and Principe,Sao Tome,0.3333333333333333,6.733333,ST,Africa
Senegal,Dakar,14.733333333333333,-17.633333,SN,Africa
Seychelles,Victoria,-4.616666666666667,55.450000,SC,Africa
Sierra Leone,Freetown,8.483333333333333,-13.233333,SL,Africa
Somalia,Mogadishu,2.066666666666667,45.333333,SO,Africa
South Africa,Pretoria,-25.7,28.216667,ZA,Africa
South Sudan,Juba,4.85,31.616667,SS,Africa
Sudan,Khartoum,15.6,32.533333,SD,Africa
Swaziland,Mbabane,-26.316666666666666,31.133333,SZ,Africa
Tanzania,Dar es Salaam,-6.8,39.283333,TZ,Africa
Togo,Lome,6.116666666666666,1.216667,TG,Africa
Tunisia,Tunis,36.8,10.183333,TN,Africa
Uganda,Kampala,0.31666666666666665,32.550000,UG,Africa
Zambia,Lusaka,-15.416666666666666,28.283333,ZM,Africa
Zimbabwe,Harare,-17.816666666666666,31.033333,ZW,Africa
British Indian Ocean Territory,Diego Garcia,-7.3,72.400000,IO,Africa
1 Country Name Latitude Longitude CountryCode Continent
2 Somaliland Hargeisa 9.55 44.050000 NULL Africa
3 Western Sahara El-Aaiún 27.153611 -13.203333 EH Africa
4 Algeria Algiers 36.75 3.050000 DZ Africa
5 Angola Luanda -8.833333333333334 13.216667 AO Africa
6 Benin Porto-Novo 6.483333333333333 2.616667 BJ Africa
7 Botswana Gaborone -24.633333333333333 25.900000 BW Africa
8 Burkina Faso Ouagadougou 12.366666666666667 -1.516667 BF Africa
9 Burundi Bujumbura -3.3666666666666667 29.350000 BI Africa
10 Cameroon Yaounde 3.8666666666666667 11.516667 CM Africa
11 Cape Verde Praia 14.916666666666666 -23.516667 CV Africa
12 Central African Republic Bangui 4.366666666666666 18.583333 CF Africa
13 Chad N'Djamena 12.1 15.033333 TD Africa
14 Comoros Moroni -11.7 43.233333 KM Africa
15 Democratic Republic of the Congo Kinshasa -4.316666666666666 15.300000 CD Africa
16 Republic of Congo Brazzaville -4.25 15.283333 CG Africa
17 Cote d'Ivoire Yamoussoukro 6.816666666666666 -5.266667 CI Africa
18 Djibouti Djibouti 11.583333333333334 43.150000 DJ Africa
19 Egypt Cairo 30.05 31.250000 EG Africa
20 Equatorial Guinea Malabo 3.75 8.783333 GQ Africa
21 Eritrea Asmara 15.333333333333334 38.933333 ER Africa
22 Ethiopia Addis Ababa 9.033333333333333 38.700000 ET Africa
23 Gabon Libreville 0.38333333333333336 9.450000 GA Africa
24 The Gambia Banjul 13.45 -16.566667 GM Africa
25 Ghana Accra 5.55 -0.216667 GH Africa
26 Guinea Conakry 9.5 -13.700000 GN Africa
27 Guinea-Bissau Bissau 11.85 -15.583333 GW Africa
28 Kenya Nairobi -1.2833333333333332 36.816667 KE Africa
29 Lesotho Maseru -29.316666666666666 27.483333 LS Africa
30 Liberia Monrovia 6.3 -10.800000 LR Africa
31 Libya Tripoli 32.88333333333333 13.166667 LY Africa
32 Madagascar Antananarivo -18.916666666666668 47.516667 MG Africa
33 Malawi Lilongwe -13.966666666666667 33.783333 MW Africa
34 Mali Bamako 12.65 -8.000000 ML Africa
35 Mauritania Nouakchott 18.066666666666666 -15.966667 MR Africa
36 Mauritius Port Louis -20.15 57.483333 MU Africa
37 Morocco Rabat 34.016666666666666 -6.816667 MA Africa
38 Mozambique Maputo -25.95 32.583333 MZ Africa
39 Namibia Windhoek -22.566666666666666 17.083333 NA Africa
40 Niger Niamey 13.516666666666667 2.116667 NE Africa
41 Nigeria Abuja 9.083333333333334 7.533333 NG Africa
42 Rwanda Kigali -1.95 30.050000 RW Africa
43 Saint Helena Jamestown -15.933333333333334 -5.716667 SH Africa
44 Sao Tome and Principe Sao Tome 0.3333333333333333 6.733333 ST Africa
45 Senegal Dakar 14.733333333333333 -17.633333 SN Africa
46 Seychelles Victoria -4.616666666666667 55.450000 SC Africa
47 Sierra Leone Freetown 8.483333333333333 -13.233333 SL Africa
48 Somalia Mogadishu 2.066666666666667 45.333333 SO Africa
49 South Africa Pretoria -25.7 28.216667 ZA Africa
50 South Sudan Juba 4.85 31.616667 SS Africa
51 Sudan Khartoum 15.6 32.533333 SD Africa
52 Swaziland Mbabane -26.316666666666666 31.133333 SZ Africa
53 Tanzania Dar es Salaam -6.8 39.283333 TZ Africa
54 Togo Lome 6.116666666666666 1.216667 TG Africa
55 Tunisia Tunis 36.8 10.183333 TN Africa
56 Uganda Kampala 0.31666666666666665 32.550000 UG Africa
57 Zambia Lusaka -15.416666666666666 28.283333 ZM Africa
58 Zimbabwe Harare -17.816666666666666 31.033333 ZW Africa
59 British Indian Ocean Territory Diego Garcia -7.3 72.400000 IO Africa

View file

@ -0,0 +1,53 @@
Country,Name,Latitude,Longitude,CountryCode,Continent
Saint Martin,Marigot,18.0731,-63.082200,MF,North America
American Samoa,Pago Pago,-14.266666666666667,-170.700000,AS,Australia
Anguilla,The Valley,18.216666666666665,-63.050000,AI,North America
Antigua and Barbuda,Saint John's,17.116666666666667,-61.850000,AG,North America
Argentina,Buenos Aires,-34.583333333333336,-58.666667,AR,South America
Aruba,Oranjestad,12.516666666666667,-70.033333,AW,North America
Bahamas,Nassau,25.083333333333332,-77.350000,BS,North America
Barbados,Bridgetown,13.1,-59.616667,BB,North America
Belize,Belmopan,17.25,-88.766667,BZ,Central America
Bermuda,Hamilton,32.28333333333333,-64.783333,BM,North America
Bolivia,La Paz,-16.5,-68.150000,BO,South America
Brazil,Brasilia,-15.783333333333333,-47.916667,BR,South America
British Virgin Islands,Road Town,18.416666666666668,-64.616667,VG,North America
Canada,Ottawa,45.416666666666664,-75.700000,CA,Central America
Cayman Islands,George Town,19.3,-81.383333,KY,North America
Chile,Santiago,-33.45,-70.666667,CL,South America
Colombia,Bogota,4.6,-74.083333,CO,South America
Costa Rica,San Jose,9.933333333333334,-84.083333,CR,Central America
Cuba,Havana,23.116666666666667,-82.350000,CU,North America
Curaçao,Willemstad,12.1,-68.916667,CW,North America
Dominica,Roseau,15.3,-61.400000,DM,North America
Dominican Republic,Santo Domingo,18.466666666666665,-69.900000,DO,North America
Ecuador,Quito,-0.21666666666666667,-78.500000,EC,South America
El Salvador,San Salvador,13.7,-89.200000,SV,Central America
Falkland Islands,Stanley,-51.7,-57.850000,FK,South America
Greenland,Nuuk,64.18333333333334,-51.750000,GL,Central America
Grenada,Saint George's,12.05,-61.750000,GD,North America
Guatemala,Guatemala City,14.616666666666667,-90.516667,GT,Central America
Guyana,Georgetown,6.8,-58.150000,GY,South America
Haiti,Port-au-Prince,18.533333333333335,-72.333333,HT,North America
Honduras,Tegucigalpa,14.1,-87.216667,HN,Central America
Jamaica,Kingston,18,-76.800000,JM,North America
Mexico,Mexico City,19.433333333333334,-99.133333,MX,Central America
Montserrat,Plymouth,16.7,-62.216667,MS,North America
Nicaragua,Managua,12.133333333333333,-86.250000,NI,Central America
Panama,Panama City,8.966666666666667,-79.533333,PA,Central America
Paraguay,Asuncion,-25.266666666666666,-57.666667,PY,South America
Peru,Lima,-12.05,-77.050000,PE,South America
Puerto Rico,San Juan,18.466666666666665,-66.116667,PR,North America
Saint Barthelemy,Gustavia,17.883333333333333,-62.850000,BL,North America
Saint Kitts and Nevis,Basseterre,17.3,-62.716667,KN,North America
Saint Lucia,Castries,14,-61.000000,LC,North America
Saint Pierre and Miquelon,Saint-Pierre,46.766666666666666,-56.183333,PM,Central America
Saint Vincent and the Grenadines,Kingstown,13.133333333333333,-61.216667,VC,Central America
Sint Maarten,Philipsburg,18.016666666666666,-63.033333,SX,North America
Suriname,Paramaribo,5.833333333333333,-55.166667,SR,South America
Trinidad and Tobago,Port of Spain,10.65,-61.516667,TT,North America
Turks and Caicos Islands,Grand Turk,21.466666666666665,-71.133333,TC,North America
United States,Washington, D.C.,38.883333,-77.000000,US,Central America
Uruguay,Montevideo,-34.85,-56.166667,UY,South America
Venezuela,Caracas,10.483333333333333,-66.866667,VE,South America
US Virgin Islands,Charlotte Amalie,18.35,-64.933333,VI,North America
Can't render this file because it has a wrong number of fields in line 50.

View file

@ -0,0 +1,246 @@
Country,Name,Latitude,Longitude,CountryCode,Continent
Somaliland,Hargeisa,9.55,44.050000,NULL,Africa
South Georgia and South Sandwich Islands,King Edward Point,-54.283333,-36.500000,GS,Antarctica
French Southern and Antarctic Lands,Port-aux-Français,-49.35,70.216667,TF,Antarctica
Palestine,Jerusalem,31.766666666666666,35.233333,PS,Asia
Aland Islands,Mariehamn,60.116667,19.900000,AX,Europe
Nauru,Yaren,-0.5477,166.920867,NR,Australia
Saint Martin,Marigot,18.0731,-63.082200,MF,North America
Tokelau,Atafu,-9.166667,-171.833333,TK,Australia
Western Sahara,El-Aaiún,27.153611,-13.203333,EH,Africa
Afghanistan,Kabul,34.516666666666666,69.183333,AF,Asia
Albania,Tirana,41.31666666666667,19.816667,AL,Europe
Algeria,Algiers,36.75,3.050000,DZ,Africa
American Samoa,Pago Pago,-14.266666666666667,-170.700000,AS,Australia
Andorra,Andorra la Vella,42.5,1.516667,AD,Europe
Angola,Luanda,-8.833333333333334,13.216667,AO,Africa
Anguilla,The Valley,18.216666666666665,-63.050000,AI,North America
Antigua and Barbuda,Saint John's,17.116666666666667,-61.850000,AG,North America
Argentina,Buenos Aires,-34.583333333333336,-58.666667,AR,South America
Armenia,Yerevan,40.166666666666664,44.500000,AM,Europe
Aruba,Oranjestad,12.516666666666667,-70.033333,AW,North America
Australia,Canberra,-35.266666666666666,149.133333,AU,Australia
Austria,Vienna,48.2,16.366667,AT,Europe
Azerbaijan,Baku,40.38333333333333,49.866667,AZ,Europe
Bahamas,Nassau,25.083333333333332,-77.350000,BS,North America
Bahrain,Manama,26.233333333333334,50.566667,BH,Asia
Bangladesh,Dhaka,23.716666666666665,90.400000,BD,Asia
Barbados,Bridgetown,13.1,-59.616667,BB,North America
Belarus,Minsk,53.9,27.566667,BY,Europe
Belgium,Brussels,50.833333333333336,4.333333,BE,Europe
Belize,Belmopan,17.25,-88.766667,BZ,Central America
Benin,Porto-Novo,6.483333333333333,2.616667,BJ,Africa
Bermuda,Hamilton,32.28333333333333,-64.783333,BM,North America
Bhutan,Thimphu,27.466666666666665,89.633333,BT,Asia
Bolivia,La Paz,-16.5,-68.150000,BO,South America
Bosnia and Herzegovina,Sarajevo,43.86666666666667,18.416667,BA,Europe
Botswana,Gaborone,-24.633333333333333,25.900000,BW,Africa
Brazil,Brasilia,-15.783333333333333,-47.916667,BR,South America
British Virgin Islands,Road Town,18.416666666666668,-64.616667,VG,North America
Brunei Darussalam,Bandar Seri Begawan,4.883333333333333,114.933333,BN,Asia
Bulgaria,Sofia,42.68333333333333,23.316667,BG,Europe
Burkina Faso,Ouagadougou,12.366666666666667,-1.516667,BF,Africa
Myanmar,Rangoon,16.8,96.150000,MM,Asia
Burundi,Bujumbura,-3.3666666666666667,29.350000,BI,Africa
Cambodia,Phnom Penh,11.55,104.916667,KH,Asia
Cameroon,Yaounde,3.8666666666666667,11.516667,CM,Africa
Canada,Ottawa,45.416666666666664,-75.700000,CA,Central America
Cape Verde,Praia,14.916666666666666,-23.516667,CV,Africa
Cayman Islands,George Town,19.3,-81.383333,KY,North America
Central African Republic,Bangui,4.366666666666666,18.583333,CF,Africa
Chad,N'Djamena,12.1,15.033333,TD,Africa
Chile,Santiago,-33.45,-70.666667,CL,South America
China,Beijing,39.916666666666664,116.383333,CN,Asia
Christmas Island,The Settlement,-10.416666666666666,105.716667,CX,Australia
Cocos Islands,West Island,-12.166666666666666,96.833333,CC,Australia
Colombia,Bogota,4.6,-74.083333,CO,South America
Comoros,Moroni,-11.7,43.233333,KM,Africa
Democratic Republic of the Congo,Kinshasa,-4.316666666666666,15.300000,CD,Africa
Republic of Congo,Brazzaville,-4.25,15.283333,CG,Africa
Cook Islands,Avarua,-21.2,-159.766667,CK,Australia
Costa Rica,San Jose,9.933333333333334,-84.083333,CR,Central America
Cote d'Ivoire,Yamoussoukro,6.816666666666666,-5.266667,CI,Africa
Croatia,Zagreb,45.8,16.000000,HR,Europe
Cuba,Havana,23.116666666666667,-82.350000,CU,North America
Curaçao,Willemstad,12.1,-68.916667,CW,North America
Cyprus,Nicosia,35.166666666666664,33.366667,CY,Europe
Czech Republic,Prague,50.083333333333336,14.466667,CZ,Europe
Denmark,Copenhagen,55.666666666666664,12.583333,DK,Europe
Djibouti,Djibouti,11.583333333333334,43.150000,DJ,Africa
Dominica,Roseau,15.3,-61.400000,DM,North America
Dominican Republic,Santo Domingo,18.466666666666665,-69.900000,DO,North America
Ecuador,Quito,-0.21666666666666667,-78.500000,EC,South America
Egypt,Cairo,30.05,31.250000,EG,Africa
El Salvador,San Salvador,13.7,-89.200000,SV,Central America
Equatorial Guinea,Malabo,3.75,8.783333,GQ,Africa
Eritrea,Asmara,15.333333333333334,38.933333,ER,Africa
Estonia,Tallinn,59.43333333333333,24.716667,EE,Europe
Ethiopia,Addis Ababa,9.033333333333333,38.700000,ET,Africa
Falkland Islands,Stanley,-51.7,-57.850000,FK,South America
Faroe Islands,Torshavn,62,-6.766667,FO,Europe
Fiji,Suva,-18.133333333333333,178.416667,FJ,Australia
Finland,Helsinki,60.166666666666664,24.933333,FI,Europe
France,Paris,48.86666666666667,2.333333,FR,Europe
French Polynesia,Papeete,-17.533333333333335,-149.566667,PF,Australia
Gabon,Libreville,0.38333333333333336,9.450000,GA,Africa
The Gambia,Banjul,13.45,-16.566667,GM,Africa
Georgia,Tbilisi,41.68333333333333,44.833333,GE,Europe
Germany,Berlin,52.516666666666666,13.400000,DE,Europe
Ghana,Accra,5.55,-0.216667,GH,Africa
Gibraltar,Gibraltar,36.13333333333333,-5.350000,GI,Europe
Greece,Athens,37.983333333333334,23.733333,GR,Europe
Greenland,Nuuk,64.18333333333334,-51.750000,GL,Central America
Grenada,Saint George's,12.05,-61.750000,GD,North America
Guam,Hagatna,13.466666666666667,144.733333,GU,Australia
Guatemala,Guatemala City,14.616666666666667,-90.516667,GT,Central America
Guernsey,Saint Peter Port,49.45,-2.533333,GG,Europe
Guinea,Conakry,9.5,-13.700000,GN,Africa
Guinea-Bissau,Bissau,11.85,-15.583333,GW,Africa
Guyana,Georgetown,6.8,-58.150000,GY,South America
Haiti,Port-au-Prince,18.533333333333335,-72.333333,HT,North America
Vatican City,Vatican City,41.9,12.450000,VA,Europe
Honduras,Tegucigalpa,14.1,-87.216667,HN,Central America
Hungary,Budapest,47.5,19.083333,HU,Europe
Iceland,Reykjavik,64.15,-21.950000,IS,Europe
India,New Delhi,28.6,77.200000,IN,Asia
Indonesia,Jakarta,-6.166666666666667,106.816667,ID,Asia
Iran,Tehran,35.7,51.416667,IR,Asia
Iraq,Baghdad,33.333333333333336,44.400000,IQ,Asia
Ireland,Dublin,53.31666666666667,-6.233333,IE,Europe
Isle of Man,Douglas,54.15,-4.483333,IM,Europe
Israel,Jerusalem,31.766666666666666,35.233333,IL,Asia
Italy,Rome,41.9,12.483333,IT,Europe
Jamaica,Kingston,18,-76.800000,JM,North America
Japan,Tokyo,35.68333333333333,139.750000,JP,Asia
Jersey,Saint Helier,49.18333333333333,-2.100000,JE,Europe
Jordan,Amman,31.95,35.933333,JO,Asia
Kazakhstan,Astana,51.166666666666664,71.416667,KZ,Asia
Kenya,Nairobi,-1.2833333333333332,36.816667,KE,Africa
Kiribati,Tarawa,-0.8833333333333333,169.533333,KI,Australia
North Korea,Pyongyang,39.016666666666666,125.750000,KP,Asia
South Korea,Seoul,37.55,126.983333,KR,Asia
Kosovo,Pristina,42.666666666666664,21.166667,KO,Europe
Kuwait,Kuwait City,29.366666666666667,47.966667,KW,Asia
Kyrgyzstan,Bishkek,42.86666666666667,74.600000,KG,Asia
Laos,Vientiane,17.966666666666665,102.600000,LA,Asia
Latvia,Riga,56.95,24.100000,LV,Europe
Lebanon,Beirut,33.86666666666667,35.500000,LB,Asia
Lesotho,Maseru,-29.316666666666666,27.483333,LS,Africa
Liberia,Monrovia,6.3,-10.800000,LR,Africa
Libya,Tripoli,32.88333333333333,13.166667,LY,Africa
Liechtenstein,Vaduz,47.13333333333333,9.516667,LI,Europe
Lithuania,Vilnius,54.68333333333333,25.316667,LT,Europe
Luxembourg,Luxembourg,49.6,6.116667,LU,Europe
Macedonia,Skopje,42,21.433333,MK,Europe
Madagascar,Antananarivo,-18.916666666666668,47.516667,MG,Africa
Malawi,Lilongwe,-13.966666666666667,33.783333,MW,Africa
Malaysia,Kuala Lumpur,3.1666666666666665,101.700000,MY,Asia
Maldives,Male,4.166666666666667,73.500000,MV,Asia
Mali,Bamako,12.65,-8.000000,ML,Africa
Malta,Valletta,35.88333333333333,14.500000,MT,Europe
Marshall Islands,Majuro,7.1,171.383333,MH,Australia
Mauritania,Nouakchott,18.066666666666666,-15.966667,MR,Africa
Mauritius,Port Louis,-20.15,57.483333,MU,Africa
Mexico,Mexico City,19.433333333333334,-99.133333,MX,Central America
Federated States of Micronesia,Palikir,6.916666666666667,158.150000,FM,Australia
Moldova,Chisinau,47,28.850000,MD,Europe
Monaco,Monaco,43.733333333333334,7.416667,MC,Europe
Mongolia,Ulaanbaatar,47.916666666666664,106.916667,MN,Asia
Montenegro,Podgorica,42.43333333333333,19.266667,ME,Europe
Montserrat,Plymouth,16.7,-62.216667,MS,North America
Morocco,Rabat,34.016666666666666,-6.816667,MA,Africa
Mozambique,Maputo,-25.95,32.583333,MZ,Africa
Namibia,Windhoek,-22.566666666666666,17.083333,NA,Africa
Nepal,Kathmandu,27.716666666666665,85.316667,NP,Asia
Netherlands,Amsterdam,52.35,4.916667,NL,Europe
New Caledonia,Noumea,-22.266666666666666,166.450000,NC,Australia
New Zealand,Wellington,-41.3,174.783333,NZ,Australia
Nicaragua,Managua,12.133333333333333,-86.250000,NI,Central America
Niger,Niamey,13.516666666666667,2.116667,NE,Africa
Nigeria,Abuja,9.083333333333334,7.533333,NG,Africa
Niue,Alofi,-19.016666666666666,-169.916667,NU,Australia
Norfolk Island,Kingston,-29.05,167.966667,NF,Australia
Northern Mariana Islands,Saipan,15.2,145.750000,MP,Australia
Norway,Oslo,59.916666666666664,10.750000,NO,Europe
Oman,Muscat,23.616666666666667,58.583333,OM,Asia
Pakistan,Islamabad,33.68333333333333,73.050000,PK,Asia
Palau,Melekeok,7.483333333333333,134.633333,PW,Australia
Panama,Panama City,8.966666666666667,-79.533333,PA,Central America
Papua New Guinea,Port Moresby,-9.45,147.183333,PG,Australia
Paraguay,Asuncion,-25.266666666666666,-57.666667,PY,South America
Peru,Lima,-12.05,-77.050000,PE,South America
Philippines,Manila,14.6,120.966667,PH,Asia
Pitcairn Islands,Adamstown,-25.066666666666666,-130.083333,PN,Australia
Poland,Warsaw,52.25,21.000000,PL,Europe
Portugal,Lisbon,38.71666666666667,-9.133333,PT,Europe
Puerto Rico,San Juan,18.466666666666665,-66.116667,PR,North America
Qatar,Doha,25.283333333333335,51.533333,QA,Asia
Romania,Bucharest,44.43333333333333,26.100000,RO,Europe
Russia,Moscow,55.75,37.600000,RU,Europe
Rwanda,Kigali,-1.95,30.050000,RW,Africa
Saint Barthelemy,Gustavia,17.883333333333333,-62.850000,BL,North America
Saint Helena,Jamestown,-15.933333333333334,-5.716667,SH,Africa
Saint Kitts and Nevis,Basseterre,17.3,-62.716667,KN,North America
Saint Lucia,Castries,14,-61.000000,LC,North America
Saint Pierre and Miquelon,Saint-Pierre,46.766666666666666,-56.183333,PM,Central America
Saint Vincent and the Grenadines,Kingstown,13.133333333333333,-61.216667,VC,Central America
Samoa,Apia,-13.816666666666666,-171.766667,WS,Australia
San Marino,San Marino,43.93333333333333,12.416667,SM,Europe
Sao Tome and Principe,Sao Tome,0.3333333333333333,6.733333,ST,Africa
Saudi Arabia,Riyadh,24.65,46.700000,SA,Asia
Senegal,Dakar,14.733333333333333,-17.633333,SN,Africa
Serbia,Belgrade,44.833333333333336,20.500000,RS,Europe
Seychelles,Victoria,-4.616666666666667,55.450000,SC,Africa
Sierra Leone,Freetown,8.483333333333333,-13.233333,SL,Africa
Singapore,Singapore,1.2833333333333332,103.850000,SG,Asia
Sint Maarten,Philipsburg,18.016666666666666,-63.033333,SX,North America
Slovakia,Bratislava,48.15,17.116667,SK,Europe
Slovenia,Ljubljana,46.05,14.516667,SI,Europe
Solomon Islands,Honiara,-9.433333333333334,159.950000,SB,Australia
Somalia,Mogadishu,2.066666666666667,45.333333,SO,Africa
South Africa,Pretoria,-25.7,28.216667,ZA,Africa
South Sudan,Juba,4.85,31.616667,SS,Africa
Spain,Madrid,40.4,-3.683333,ES,Europe
Sri Lanka,Colombo,6.916666666666667,79.833333,LK,Asia
Sudan,Khartoum,15.6,32.533333,SD,Africa
Suriname,Paramaribo,5.833333333333333,-55.166667,SR,South America
Svalbard,Longyearbyen,78.21666666666667,15.633333,SJ,Europe
Swaziland,Mbabane,-26.316666666666666,31.133333,SZ,Africa
Sweden,Stockholm,59.333333333333336,18.050000,SE,Europe
Switzerland,Bern,46.916666666666664,7.466667,CH,Europe
Syria,Damascus,33.5,36.300000,SY,Asia
Taiwan,Taipei,25.033333333333335,121.516667,TW,Asia
Tajikistan,Dushanbe,38.55,68.766667,TJ,Asia
Tanzania,Dar es Salaam,-6.8,39.283333,TZ,Africa
Thailand,Bangkok,13.75,100.516667,TH,Asia
Timor-Leste,Dili,-8.583333333333334,125.600000,TL,Asia
Togo,Lome,6.116666666666666,1.216667,TG,Africa
Tonga,Nuku'alofa,-21.133333333333333,-175.200000,TO,Australia
Trinidad and Tobago,Port of Spain,10.65,-61.516667,TT,North America
Tunisia,Tunis,36.8,10.183333,TN,Africa
Turkey,Ankara,39.93333333333333,32.866667,TR,Europe
Turkmenistan,Ashgabat,37.95,58.383333,TM,Asia
Turks and Caicos Islands,Grand Turk,21.466666666666665,-71.133333,TC,North America
Tuvalu,Funafuti,-8.516666666666667,179.216667,TV,Australia
Uganda,Kampala,0.31666666666666665,32.550000,UG,Africa
Ukraine,Kyiv,50.43333333333333,30.516667,UA,Europe
United Arab Emirates,Abu Dhabi,24.466666666666665,54.366667,AE,Asia
United Kingdom,London,51.5,-0.083333,GB,Europe
United States,Washington, D.C.,38.883333,-77.000000,US,Central America
Uruguay,Montevideo,-34.85,-56.166667,UY,South America
Uzbekistan,Tashkent,41.31666666666667,69.250000,UZ,Asia
Vanuatu,Port-Vila,-17.733333333333334,168.316667,VU,Australia
Venezuela,Caracas,10.483333333333333,-66.866667,VE,South America
Vietnam,Hanoi,21.033333333333335,105.850000,VN,Asia
US Virgin Islands,Charlotte Amalie,18.35,-64.933333,VI,North America
Wallis and Futuna,Mata-Utu,-13.95,-171.933333,WF,Australia
Yemen,Sanaa,15.35,44.200000,YE,Asia
Zambia,Lusaka,-15.416666666666666,28.283333,ZM,Africa
Zimbabwe,Harare,-17.816666666666666,31.033333,ZW,Africa
US Minor Outlying Islands,Washington, D.C.,38.883333,-77.000000,UM,Australia
Antarctica,N/A,0,0.000000,AQ,Antarctica
Northern Cyprus,North Nicosia,35.183333,33.366667,NULL,Europe
Hong Kong,N/A,0,0.000000,HK,Asia
Heard Island and McDonald Islands,N/A,0,0.000000,HM,Antarctica
British Indian Ocean Territory,Diego Garcia,-7.3,72.400000,IO,Africa
Macau,N/A,0,0.000000,MO,Asia
Can't render this file because it has a wrong number of fields in line 229.

126
docs/data/data.csv Normal file
View file

@ -0,0 +1,126 @@
Councils by Population Size,Name,Organisation ,Category,Population,,Latitude,Longitude,Co-ordinates,Demand - local (tonnes),Demand - wider (tonnes),,,
1,Glasgow,Glasgow City Council,Planning authority - engaged,626,,55.86,-4.25,"55.86, -4.25",14398,48070,,,http://goldsmith.journeyman.cc:4444/?docid=1k5SAiQc1Llzal1x4WaR10SovEZaaKb19M1dvIeG-t1s#/map
2,Edinburgh,City of Edinburgh Council ,Planning authority not engaged,518,,55.96,-3.18,"55.96, -3.18",11914,20631,,,
3,Fife,Fife Council,Planning authority not engaged,372,,56.2,-3.16,"56.20, -3.16",8556,11983,,,
4,North Lanarkshire,North Lanarkshire Council,Planning authority not engaged,340,,55.95,-3.99,"55.95, -3.99",7820,,,,
5,South Lanarkshire,South Lanarkshire Council,Planning authority not engaged,319,,55.78,-4.05,"55.78, -4.05",7337,,,,
6,Aberdeenshire,Aberdeenshire Council,Planning authority - engaged,261,,57.28,-2.37,"57.28, -2.37",6003,,,,
7,Highland,Highland Council,Planning authority not engaged,235,,57.48,-4.22,"57.48, -4.22",5405,,,,
8,Aberdeen,Aberdeen City Council.,Planning authority not engaged,228,,57.155,-2.264,"57.155, -2.264",5244,,,,
9,West Lothian,West Lothian Council,Planning authority not engaged,182,,55.93,-3.46,"55.93, -3.46",4186,,,,
10,Renfrewshire,Renfrewshire Council,Planning authority not engaged,178,3259,55.84,-4.42,"55.84, -4.42",4094,,,,
11,Falkirk,Falkirk Council,Planning authority not engaged,160,,55.99,-3.78,"55.99,-3.78",3680,,,,
12,Perth and Kinross,Perth and Kinross Council,Planning authority not engaged,151,,56.39,-3.43,"56.39, -3.43",3473,,,,
13,Dumfries and Galloway,Dumfries and Galloway Council.,Planning authority not engaged,149,,55.07,-3.603,"55.07,-3.603",3427,,,,
14,Dundee,Dundee City Council.,Planning authority not engaged,149,,56.28,-2.58,"56.28, -2.58",3427,,,,
15,North Ayrshire,North Ayrshire Council,Planning authority not engaged,135,,55.61,-4.67,"55.61, -4.67",3105,,,,
16,East Ayrshire,East Ayrshire Council,Planning authority not engaged,122,,55.61,-4.5,"55.61, -4.5",2806,,,,
17,Angus,Angus Council.,Planning authority not engaged,116,,56.65,-2.88,"56.65, -2.88",2668,,,,
18,Scottish Borders,Scottish Borders Council,Planning authority not engaged,115,,55.61,-2.8,"55.61, -2.80",2645,,,,
19,South Ayrshire,South Ayrshire Council,Planning authority not engaged,113,,55.46,-4.62,"55.46, -4.62",2599,,,,
20,East Dunbartonshire,East Dunbartonshire Council,Planning authority not engaged,108,,55.94,-5.15,"55.95, -5.15",2484,,,,
21,East Lothian,East Lothian Council,Planning authority not engaged,106,,55.95,-2.78,"55.95, -2.78",2438,,,,
22,Moray,Moray Council,Planning authority not engaged,96,,57.65,-3.31,"57.65, -3.31",2208,,,,
23,East Renfrewshire,East Renfrewshire Council,Planning authority not engaged,95,,55.79,-4.31,"55.79, -4.31",2185,,,,
24,Stirling,Stirling Council,Planning authority not engaged,94,,56.11,-3.94,"56.11, -3.94",2162,,,,
25,Midlothian,Midlothian Council,Planning authority not engaged,91,,55.89,-3.07,"55.89, -3.07",2093,,,,
26,West Dunbartonshire,West Dunbartonshire Council,Planning authority not engaged,89,,55.94,-4.56,"55.94, -4.56",2047,,,,
27,Argyll and Bute,Argyll and Bute Council.,Planning authority not engaged,86,,56.03,-5.45,"56.03, -5.45",1978,,,,
28,Inverclyde,Inverclyde Council,Planning authority not engaged,78,,55.95,-4.76,"55.95, -4.76",1794,,,,
29,Clackmannanshire,Clackmannanshire Council.,Planning authority not engaged,51,,56.11,-3.789,"56.11, -3.789",1173,,,,
30,Na h-Eileanan Siar,Comhairle nan Eilean Siar (Western Isles) Council,Planning authority not engaged,26,,58.209,-6.378,"58.209, -6.378",598,,,,
31,Shetland,Shetland Islands Council,Planning authority not engaged,23,,60.25,-1.146,"60.25, -1.146",529,,,,
32,Orkney,Orkney Islands Council,Planning authority - engaged,22,,58.97,-2.97,"58.97, -2.97",506,,,,
,,,Total,5434,,,,,,,,,
Orkney ,"Orkney Power
",,Power supplier,,,59,-3,"59, -3",,,,,
,Orkney Estates,,Landowner,,,58.98,-2.95,"58.98, -2.95",,,,,
,Orkney College,,Operator,,,58.97,-2.96,,,,,,
,UHI,,Higher education,,,58.986,-2.947,,,,,,
,Orkney Council,,Champion,,,58.99,-2.93,,,,,,
,,,,,,,,,,,,,
,,,,,,,,,,,,,
Glasgow,Glasgow Markets,,Landowner,,,55.869,-4.212,,,,,,
,SEC,,Anchor Customer,,,55.86,-4.287,,,,,,
,Regent Capital,,Developer,,,55.86,-4.26,,,,,,
,Scottish Power,,Power supplier,,,55.866,-4.2,,,,,,
,"
",,Operator,,,,,,,,,,
,City of Glasgow Council,,Champion,,,55.85,-4.25,,,,,,
,City Fibre,,Broadband-supplier,,,55.87,-4.22,,,,,,
,,,,,,,,,,,,,
Fife ,,,Landowner,,,,,,,,,,
,,,Anchor Customer,,,,,,,,,,
,,,Developer,,,,,,,,,,
,SSE,,Power supplier,,,56.33,-2.98,,,,,,
,East of Scotland Growers ,,Operator,,,56.33,-2.97,,,,,,
,BT,,Broadband-supplier,,,56.32,-2.97,,,,,,
,Fife Council,,Champion,,,56.32,-2.975,,,,,,
Gleneagles,Gleneagles Hotel,"
",Landowner,,,56.28,-3.75,,,,,,
,Gleneagles Hotel,,Anchor Customer,,,56.285,-3.74,,,,,,
,Ennismore,,Developer,,,56.29,-3.73,,,,,,
,SSE,,Power supplier,,,56.28,-3.73,,,,,,
,,,Operator,,,,,,,,,,
,BT,,Broadband-supplier,,,56.286,-3.745,,,,,,
,Perth & Kinross Council,,Champion,,,56.285,-3.73,,,,,,
,,,,,,,,,,,,,
Edinburgh ,Forth Ports,,Landowner,,,55.979,-3.159,,,,,,
,Edinburgh Restaurants Alliance,,Anchor Customer,,,55.976,-3.172,,,,,,
,Regent Capital,,Developer,,,55.977,-3.166,,,,,,
,Scottish Power,,Power supplier,,,55.976,-3.164,,,,,,
,,,Operator,,,,,,,,,,
,City Fibre,,Broadband-supplier,,,55.974,-3.169,,,,,,
,"Scottish Government
",,Champion,,,55.977,-3.174,,,,,,
,,,,,,,,,,,,,
Moray,Baxters Foods ,,Landowner,,,57.625,-3.099,,,,,,
,Baxter Foods,,Anchor Customer,,,57.62,-3.105,,,,,,
,Regent Capital,,Developer,,,57.62,-3.12,,,,,,
,SSE,,Power supplier,,,57.63,-3.108,,,,,,
,,,Operator,,,,,,,,,,
,BT,,Broadband-supplier,,,57.63,-3.15,,,,,,
,Moray Council,,Champion,,,57.62,-3.14,,,,,,
,,,,,,,,,,,,,
Falkirk ,Scottish Canals,,Landowner,,,55.999,-3.839,,,,,,
,Scottish Co-ops,,Anchor Customer,,,56.002,-3.836,,,,,,
,Regent Capital,,Developer,,,56,-3.846,,,,,,
,Scottish Power,,Power supplier,,,56,-3.854,,,,,,
,,,Operator,,,,,,,,,,
,Vodaphone,,Broadband-supplier,,,56,-3.82,,,,,,
,Falkirk Council,,Champion,,,55.99,-3.839,,,,,,
,,,,,,,,,,,,,
,,,,,,,,,,,,,
Fort William,Liberty Steel/GFG,,Landowner,,,56.829,-5.072,,,,,,
,Multiples,,Anchor Customer,,,56.828,-5.081,,,,,,
,GFG,,Developer,,,56.829,-5.076,,,,,,
,GFG,,Power supplier,,,56.84,-5.069,,,,,,
,,,Operator,,,,,,,,,,
,Vodaphone,,Broadband-supplier,,,56.827,-5.084,,,,,,
,Highland Council,,Champion,,,56.822,-5.087,,,,,,
,,,,,,,,,,,,,
,,,,,,,,,,,,,
Aberdeen,Wood Group,,Landowner,,,57.187,-2.083,,,,,,
,,,Anchor Customer,,,,,,,,,,
,Regent Capital,,Developer,,,57.17,-2.113,,,,,,
,SSE,,Power supplier,,,57.188,-2.127,,,,,,
,ONE,,Operator,,,57.125,-2.097,,,,,,
,IFB,,Broadband-supplier,,,57.138,-2.074,,,,,,
,Opportunity North East,,Champion,,,57.148,-2.105,,,,,,
,,,,,,,,,,,,,
,,,,,,,,,,,,,
Western Isles,Western Isles Council,,Landowner,,,58.208,-6.425,,,,,,
,,,Anchor Customer,,,,,,,,,,
,,,Developer,,,,,,,,,,
,Point & Sandwick Trust,,Power supplier,,,58.201,-6.272,,,,,,
,,,Operator,,,,,,,,,,
,Vodaphone,,Broadband-supplier,,,58.209,-6.397,,,,,,
,Western Isles Council,,Champion,,,58.21,-6.377,,,,,,
,,,,,,,,,,,,,
Galloway,,,Landowner,,,54.849,-3.869,,,,,,
,,,Anchor Customer,,,,,,,,,,
,,,Developer,,,,,,,,,,
,SSE,,Power supplier,,,54.847,-3.881,,,,,,
,,,Operator,,,,,,,,,,
,Vodaphone,,Broadband-supplier,,,,,,,,,,
,South of Scotland Enterprise Partnership,,Champion,,,54.834,-3.877,,,,,,
1 Councils by Population Size Name Organisation Category Population Latitude Longitude Co-ordinates Demand - local (tonnes) Demand - wider (tonnes)
2 1 Glasgow Glasgow City Council Planning authority - engaged 626 55.86 -4.25 55.86, -4.25 14398 48070 http://goldsmith.journeyman.cc:4444/?docid=1k5SAiQc1Llzal1x4WaR10SovEZaaKb19M1dvIeG-t1s#/map
3 2 Edinburgh City of Edinburgh Council Planning authority not engaged 518 55.96 -3.18 55.96, -3.18 11914 20631
4 3 Fife Fife Council Planning authority not engaged 372 56.2 -3.16 56.20, -3.16 8556 11983
5 4 North Lanarkshire North Lanarkshire Council Planning authority not engaged 340 55.95 -3.99 55.95, -3.99 7820
6 5 South Lanarkshire South Lanarkshire Council Planning authority not engaged 319 55.78 -4.05 55.78, -4.05 7337
7 6 Aberdeenshire Aberdeenshire Council Planning authority - engaged 261 57.28 -2.37 57.28, -2.37 6003
8 7 Highland Highland Council Planning authority not engaged 235 57.48 -4.22 57.48, -4.22 5405
9 8 Aberdeen Aberdeen City Council. Planning authority not engaged 228 57.155 -2.264 57.155, -2.264 5244
10 9 West Lothian West Lothian Council Planning authority not engaged 182 55.93 -3.46 55.93, -3.46 4186
11 10 Renfrewshire Renfrewshire Council Planning authority not engaged 178 3259 55.84 -4.42 55.84, -4.42 4094
12 11 Falkirk Falkirk Council Planning authority not engaged 160 55.99 -3.78 55.99,-3.78 3680
13 12 Perth and Kinross Perth and Kinross Council Planning authority not engaged 151 56.39 -3.43 56.39, -3.43 3473
14 13 Dumfries and Galloway Dumfries and Galloway Council. Planning authority not engaged 149 55.07 -3.603 55.07,-3.603 3427
15 14 Dundee Dundee City Council. Planning authority not engaged 149 56.28 -2.58 56.28, -2.58 3427
16 15 North Ayrshire North Ayrshire Council Planning authority not engaged 135 55.61 -4.67 55.61, -4.67 3105
17 16 East Ayrshire East Ayrshire Council Planning authority not engaged 122 55.61 -4.5 55.61, -4.5 2806
18 17 Angus Angus Council. Planning authority not engaged 116 56.65 -2.88 56.65, -2.88 2668
19 18 Scottish Borders Scottish Borders Council Planning authority not engaged 115 55.61 -2.8 55.61, -2.80 2645
20 19 South Ayrshire South Ayrshire Council Planning authority not engaged 113 55.46 -4.62 55.46, -4.62 2599
21 20 East Dunbartonshire East Dunbartonshire Council Planning authority not engaged 108 55.94 -5.15 55.95, -5.15 2484
22 21 East Lothian East Lothian Council Planning authority not engaged 106 55.95 -2.78 55.95, -2.78 2438
23 22 Moray Moray Council Planning authority not engaged 96 57.65 -3.31 57.65, -3.31 2208
24 23 East Renfrewshire East Renfrewshire Council Planning authority not engaged 95 55.79 -4.31 55.79, -4.31 2185
25 24 Stirling Stirling Council Planning authority not engaged 94 56.11 -3.94 56.11, -3.94 2162
26 25 Midlothian Midlothian Council Planning authority not engaged 91 55.89 -3.07 55.89, -3.07 2093
27 26 West Dunbartonshire West Dunbartonshire Council Planning authority not engaged 89 55.94 -4.56 55.94, -4.56 2047
28 27 Argyll and Bute Argyll and Bute Council. Planning authority not engaged 86 56.03 -5.45 56.03, -5.45 1978
29 28 Inverclyde Inverclyde Council Planning authority not engaged 78 55.95 -4.76 55.95, -4.76 1794
30 29 Clackmannanshire Clackmannanshire Council. Planning authority not engaged 51 56.11 -3.789 56.11, -3.789 1173
31 30 Na h-Eileanan Siar Comhairle nan Eilean Siar (Western Isles) Council Planning authority not engaged 26 58.209 -6.378 58.209, -6.378 598
32 31 Shetland Shetland Islands Council Planning authority not engaged 23 60.25 -1.146 60.25, -1.146 529
33 32 Orkney Orkney Islands Council Planning authority - engaged 22 58.97 -2.97 58.97, -2.97 506
34 Total 5434
35 Orkney Orkney Power Power supplier 59 -3 59, -3
36 Orkney Estates Landowner 58.98 -2.95 58.98, -2.95
37 Orkney College Operator 58.97 -2.96
38 UHI Higher education 58.986 -2.947
39 Orkney Council Champion 58.99 -2.93
40
41
42 Glasgow Glasgow Markets Landowner 55.869 -4.212
43 SEC Anchor Customer 55.86 -4.287
44 Regent Capital Developer 55.86 -4.26
45 Scottish Power Power supplier 55.866 -4.2
46 Operator
47 City of Glasgow Council Champion 55.85 -4.25
48 City Fibre Broadband-supplier 55.87 -4.22
49
50 Fife Landowner
51 Anchor Customer
52 Developer
53 SSE Power supplier 56.33 -2.98
54 East of Scotland Growers Operator 56.33 -2.97
55 BT Broadband-supplier 56.32 -2.97
56 Fife Council Champion 56.32 -2.975
57 Gleneagles Gleneagles Hotel Landowner 56.28 -3.75
58 Gleneagles Hotel Anchor Customer 56.285 -3.74
59 Ennismore Developer 56.29 -3.73
60 SSE Power supplier 56.28 -3.73
61 Operator
62 BT Broadband-supplier 56.286 -3.745
63 Perth & Kinross Council Champion 56.285 -3.73
64
65 Edinburgh Forth Ports Landowner 55.979 -3.159
66 Edinburgh Restaurants Alliance Anchor Customer 55.976 -3.172
67 Regent Capital Developer 55.977 -3.166
68 Scottish Power Power supplier 55.976 -3.164
69 Operator
70 City Fibre Broadband-supplier 55.974 -3.169
71 Scottish Government Champion 55.977 -3.174
72
73 Moray Baxters Foods Landowner 57.625 -3.099
74 Baxter Foods Anchor Customer 57.62 -3.105
75 Regent Capital Developer 57.62 -3.12
76 SSE Power supplier 57.63 -3.108
77 Operator
78 BT Broadband-supplier 57.63 -3.15
79 Moray Council Champion 57.62 -3.14
80
81 Falkirk Scottish Canals Landowner 55.999 -3.839
82 Scottish Co-ops Anchor Customer 56.002 -3.836
83 Regent Capital Developer 56 -3.846
84 Scottish Power Power supplier 56 -3.854
85 Operator
86 Vodaphone Broadband-supplier 56 -3.82
87 Falkirk Council Champion 55.99 -3.839
88
89
90 Fort William Liberty Steel/GFG Landowner 56.829 -5.072
91 Multiples Anchor Customer 56.828 -5.081
92 GFG Developer 56.829 -5.076
93 GFG Power supplier 56.84 -5.069
94 Operator
95 Vodaphone Broadband-supplier 56.827 -5.084
96 Highland Council Champion 56.822 -5.087
97
98
99 Aberdeen Wood Group Landowner 57.187 -2.083
100 Anchor Customer
101 Regent Capital Developer 57.17 -2.113
102 SSE Power supplier 57.188 -2.127
103 ONE Operator 57.125 -2.097
104 IFB Broadband-supplier 57.138 -2.074
105 Opportunity North East Champion 57.148 -2.105
106
107
108 Western Isles Western Isles Council Landowner 58.208 -6.425
109 Anchor Customer
110 Developer
111 Point & Sandwick Trust Power supplier 58.201 -6.272
112 Operator
113 Vodaphone Broadband-supplier 58.209 -6.397
114 Western Isles Council Champion 58.21 -6.377
115
116 Galloway Landowner 54.849 -3.869
117 Anchor Customer
118 Developer
119 SSE Power supplier 54.847 -3.881
120 Operator
121 Vodaphone Broadband-supplier
122 South of Scotland Enterprise Partnership Champion 54.834 -3.877

View file

@ -0,0 +1,59 @@
Country,Name,Latitude,Longitude,CountryCode,Continent
Aland Islands,Mariehamn,60.116667,19.900000,AX,Europe
Albania,Tirana,41.31666666666667,19.816667,AL,Europe
Andorra,Andorra la Vella,42.5,1.516667,AD,Europe
Armenia,Yerevan,40.166666666666664,44.500000,AM,Europe
Austria,Vienna,48.2,16.366667,AT,Europe
Azerbaijan,Baku,40.38333333333333,49.866667,AZ,Europe
Belarus,Minsk,53.9,27.566667,BY,Europe
Belgium,Brussels,50.833333333333336,4.333333,BE,Europe
Bosnia and Herzegovina,Sarajevo,43.86666666666667,18.416667,BA,Europe
Bulgaria,Sofia,42.68333333333333,23.316667,BG,Europe
Croatia,Zagreb,45.8,16.000000,HR,Europe
Cyprus,Nicosia,35.166666666666664,33.366667,CY,Europe
Czech Republic,Prague,50.083333333333336,14.466667,CZ,Europe
Denmark,Copenhagen,55.666666666666664,12.583333,DK,Europe
Estonia,Tallinn,59.43333333333333,24.716667,EE,Europe
Faroe Islands,Torshavn,62,-6.766667,FO,Europe
Finland,Helsinki,60.166666666666664,24.933333,FI,Europe
France,Paris,48.86666666666667,2.333333,FR,Europe
Georgia,Tbilisi,41.68333333333333,44.833333,GE,Europe
Germany,Berlin,52.516666666666666,13.400000,DE,Europe
Gibraltar,Gibraltar,36.13333333333333,-5.350000,GI,Europe
Greece,Athens,37.983333333333334,23.733333,GR,Europe
Guernsey,Saint Peter Port,49.45,-2.533333,GG,Europe
Vatican City,Vatican City,41.9,12.450000,VA,Europe
Hungary,Budapest,47.5,19.083333,HU,Europe
Iceland,Reykjavik,64.15,-21.950000,IS,Europe
Ireland,Dublin,53.31666666666667,-6.233333,IE,Europe
Isle of Man,Douglas,54.15,-4.483333,IM,Europe
Italy,Rome,41.9,12.483333,IT,Europe
Jersey,Saint Helier,49.18333333333333,-2.100000,JE,Europe
Kosovo,Pristina,42.666666666666664,21.166667,KO,Europe
Latvia,Riga,56.95,24.100000,LV,Europe
Liechtenstein,Vaduz,47.13333333333333,9.516667,LI,Europe
Lithuania,Vilnius,54.68333333333333,25.316667,LT,Europe
Luxembourg,Luxembourg,49.6,6.116667,LU,Europe
Macedonia,Skopje,42,21.433333,MK,Europe
Malta,Valletta,35.88333333333333,14.500000,MT,Europe
Moldova,Chisinau,47,28.850000,MD,Europe
Monaco,Monaco,43.733333333333334,7.416667,MC,Europe
Montenegro,Podgorica,42.43333333333333,19.266667,ME,Europe
Netherlands,Amsterdam,52.35,4.916667,NL,Europe
Norway,Oslo,59.916666666666664,10.750000,NO,Europe
Poland,Warsaw,52.25,21.000000,PL,Europe
Portugal,Lisbon,38.71666666666667,-9.133333,PT,Europe
Romania,Bucharest,44.43333333333333,26.100000,RO,Europe
Russia,Moscow,55.75,37.600000,RU,Europe
San Marino,San Marino,43.93333333333333,12.416667,SM,Europe
Serbia,Belgrade,44.833333333333336,20.500000,RS,Europe
Slovakia,Bratislava,48.15,17.116667,SK,Europe
Slovenia,Ljubljana,46.05,14.516667,SI,Europe
Spain,Madrid,40.4,-3.683333,ES,Europe
Svalbard,Longyearbyen,78.21666666666667,15.633333,SJ,Europe
Sweden,Stockholm,59.333333333333336,18.050000,SE,Europe
Switzerland,Bern,46.916666666666664,7.466667,CH,Europe
Turkey,Ankara,39.93333333333333,32.866667,TR,Europe
Ukraine,Kyiv,50.43333333333333,30.516667,UA,Europe
United Kingdom,London,51.5,-0.083333,GB,Europe
Northern Cyprus,North Nicosia,35.183333,33.366667,NULL,Europe
1 Country Name Latitude Longitude CountryCode Continent
2 Aland Islands Mariehamn 60.116667 19.900000 AX Europe
3 Albania Tirana 41.31666666666667 19.816667 AL Europe
4 Andorra Andorra la Vella 42.5 1.516667 AD Europe
5 Armenia Yerevan 40.166666666666664 44.500000 AM Europe
6 Austria Vienna 48.2 16.366667 AT Europe
7 Azerbaijan Baku 40.38333333333333 49.866667 AZ Europe
8 Belarus Minsk 53.9 27.566667 BY Europe
9 Belgium Brussels 50.833333333333336 4.333333 BE Europe
10 Bosnia and Herzegovina Sarajevo 43.86666666666667 18.416667 BA Europe
11 Bulgaria Sofia 42.68333333333333 23.316667 BG Europe
12 Croatia Zagreb 45.8 16.000000 HR Europe
13 Cyprus Nicosia 35.166666666666664 33.366667 CY Europe
14 Czech Republic Prague 50.083333333333336 14.466667 CZ Europe
15 Denmark Copenhagen 55.666666666666664 12.583333 DK Europe
16 Estonia Tallinn 59.43333333333333 24.716667 EE Europe
17 Faroe Islands Torshavn 62 -6.766667 FO Europe
18 Finland Helsinki 60.166666666666664 24.933333 FI Europe
19 France Paris 48.86666666666667 2.333333 FR Europe
20 Georgia Tbilisi 41.68333333333333 44.833333 GE Europe
21 Germany Berlin 52.516666666666666 13.400000 DE Europe
22 Gibraltar Gibraltar 36.13333333333333 -5.350000 GI Europe
23 Greece Athens 37.983333333333334 23.733333 GR Europe
24 Guernsey Saint Peter Port 49.45 -2.533333 GG Europe
25 Vatican City Vatican City 41.9 12.450000 VA Europe
26 Hungary Budapest 47.5 19.083333 HU Europe
27 Iceland Reykjavik 64.15 -21.950000 IS Europe
28 Ireland Dublin 53.31666666666667 -6.233333 IE Europe
29 Isle of Man Douglas 54.15 -4.483333 IM Europe
30 Italy Rome 41.9 12.483333 IT Europe
31 Jersey Saint Helier 49.18333333333333 -2.100000 JE Europe
32 Kosovo Pristina 42.666666666666664 21.166667 KO Europe
33 Latvia Riga 56.95 24.100000 LV Europe
34 Liechtenstein Vaduz 47.13333333333333 9.516667 LI Europe
35 Lithuania Vilnius 54.68333333333333 25.316667 LT Europe
36 Luxembourg Luxembourg 49.6 6.116667 LU Europe
37 Macedonia Skopje 42 21.433333 MK Europe
38 Malta Valletta 35.88333333333333 14.500000 MT Europe
39 Moldova Chisinau 47 28.850000 MD Europe
40 Monaco Monaco 43.733333333333334 7.416667 MC Europe
41 Montenegro Podgorica 42.43333333333333 19.266667 ME Europe
42 Netherlands Amsterdam 52.35 4.916667 NL Europe
43 Norway Oslo 59.916666666666664 10.750000 NO Europe
44 Poland Warsaw 52.25 21.000000 PL Europe
45 Portugal Lisbon 38.71666666666667 -9.133333 PT Europe
46 Romania Bucharest 44.43333333333333 26.100000 RO Europe
47 Russia Moscow 55.75 37.600000 RU Europe
48 San Marino San Marino 43.93333333333333 12.416667 SM Europe
49 Serbia Belgrade 44.833333333333336 20.500000 RS Europe
50 Slovakia Bratislava 48.15 17.116667 SK Europe
51 Slovenia Ljubljana 46.05 14.516667 SI Europe
52 Spain Madrid 40.4 -3.683333 ES Europe
53 Svalbard Longyearbyen 78.21666666666667 15.633333 SJ Europe
54 Sweden Stockholm 59.333333333333336 18.050000 SE Europe
55 Switzerland Bern 46.916666666666664 7.466667 CH Europe
56 Turkey Ankara 39.93333333333333 32.866667 TR Europe
57 Ukraine Kyiv 50.43333333333333 30.516667 UA Europe
58 United Kingdom London 51.5 -0.083333 GB Europe
59 Northern Cyprus North Nicosia 35.183333 33.366667 NULL Europe

BIN
docs/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

263
docs/index.html Normal file
View file

@ -0,0 +1,263 @@
<!DOCTYPE html>
<html>
<head>
<title>GeoCSV Lite</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="css/style.css" rel="stylesheet" type="text/css">
<link rel="icon" href="favicon.ico">
<if you prefer loading libraries from standard hosts, uncomment this and
comment out the local source -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css"
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
crossorigin=""/ -->
<!-- link rel="stylesheet" href="vendor/node_modules/leaflet/dist/leaflet.css" type="text/css" -->
<!-- if you prefer loading libraries from standard hosts, un comment this and
comment out the local source -->
<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"
integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew=="
crossorigin=""></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.1.0/papaparse.min.js"></script>
<!-- script src="vendor/node_modules/leaflet/dist/leaflet.js"></script -->
<!-- script src="vendor/node_modules/papaparse/papaparse.min.js"></script -->
</head>
<body>
<h1>GeoCSV Lite</h1>
<h4>
An ultra-lightweight tool to show comma-separated value data on a map
</h4>
<p id="message"></p>
<p id="error"></p>
<div id="app">
<p>
</p>
<h2>
Map using data from element content
</h2>
<p>
To make this work, you need a <samp>&lt;pre&gt;</samp> tag wrapping
the data. View source of this page to see this work.</samp>
</p>
<div id="element-content-map"
style="height: 600px; width: 80%; border: thin solid gray;">
<pre>
Country,Name,Latitude,Longitude,CountryCode,Continent
Saint Martin,Marigot,18.0731,-63.082200,MF,North America
American Samoa,Pago Pago,-14.266666666666667,-170.700000,AS,Australia
Anguilla,The Valley,18.216666666666665,-63.050000,AI,North America
Antigua and Barbuda,Saint John's,17.116666666666667,-61.850000,AG,North America
Argentina,Buenos Aires,-34.583333333333336,-58.666667,AR,South America
Aruba,Oranjestad,12.516666666666667,-70.033333,AW,North America
Bahamas,Nassau,25.083333333333332,-77.350000,BS,North America
Barbados,Bridgetown,13.1,-59.616667,BB,North America
Belize,Belmopan,17.25,-88.766667,BZ,Central America
Bermuda,Hamilton,32.28333333333333,-64.783333,BM,North America
Bolivia,La Paz,-16.5,-68.150000,BO,South America
Brazil,Brasilia,-15.783333333333333,-47.916667,BR,South America
British Virgin Islands,Road Town,18.416666666666668,-64.616667,VG,North America
Canada,Ottawa,45.416666666666664,-75.700000,CA,Central America
Cayman Islands,George Town,19.3,-81.383333,KY,North America
Chile,Santiago,-33.45,-70.666667,CL,South America
Colombia,Bogota,4.6,-74.083333,CO,South America
Costa Rica,San Jose,9.933333333333334,-84.083333,CR,Central America
Cuba,Havana,23.116666666666667,-82.350000,CU,North America
Curaçao,Willemstad,12.1,-68.916667,CW,North America
Dominica,Roseau,15.3,-61.400000,DM,North America
Dominican Republic,Santo Domingo,18.466666666666665,-69.900000,DO,North America
Ecuador,Quito,-0.21666666666666667,-78.500000,EC,South America
El Salvador,San Salvador,13.7,-89.200000,SV,Central America
Falkland Islands,Stanley,-51.7,-57.850000,FK,South America
Greenland,Nuuk,64.18333333333334,-51.750000,GL,Central America
Grenada,Saint George's,12.05,-61.750000,GD,North America
Guatemala,Guatemala City,14.616666666666667,-90.516667,GT,Central America
Guyana,Georgetown,6.8,-58.150000,GY,South America
Haiti,Port-au-Prince,18.533333333333335,-72.333333,HT,North America
Honduras,Tegucigalpa,14.1,-87.216667,HN,Central America
Jamaica,Kingston,18,-76.800000,JM,North America
Mexico,Mexico City,19.433333333333334,-99.133333,MX,Central America
Montserrat,Plymouth,16.7,-62.216667,MS,North America
Nicaragua,Managua,12.133333333333333,-86.250000,NI,Central America
Panama,Panama City,8.966666666666667,-79.533333,PA,Central America
Paraguay,Asuncion,-25.266666666666666,-57.666667,PY,South America
Peru,Lima,-12.05,-77.050000,PE,South America
Puerto Rico,San Juan,18.466666666666665,-66.116667,PR,North America
Saint Barthelemy,Gustavia,17.883333333333333,-62.850000,BL,North America
Saint Kitts and Nevis,Basseterre,17.3,-62.716667,KN,North America
Saint Lucia,Castries,14,-61.000000,LC,North America
Saint Pierre and Miquelon,Saint-Pierre,46.766666666666666,-56.183333,PM,Central America
Saint Vincent and the Grenadines,Kingstown,13.133333333333333,-61.216667,VC,Central America
Sint Maarten,Philipsburg,18.016666666666666,-63.033333,SX,North America
Suriname,Paramaribo,5.833333333333333,-55.166667,SR,South America
Trinidad and Tobago,Port of Spain,10.65,-61.516667,TT,North America
Turks and Caicos Islands,Grand Turk,21.466666,-71.133333,TC,North America
United States,Washington D.C.,38.883333,-77.000000,US,Central America
Uruguay,Montevideo,-34.85,-56.166667,UY,South America
Venezuela,Caracas,10.483333333333333,-66.866667,VE,South America
US Virgin Islands,Charlotte Amalie,18.35,-64.933333,VI,North America
</pre>
</div>
<h2>
Map using inline CSV
</h2>
<div id="inline-csv-map"
style="height: 600px; width: 80%; border: thin solid gray;"></div>
<h2>
Map using CSV from URL
</h2>
<p>
This is more limited than I would like, because of cross-site scripting
blocks; the URL <b>must</b> be sourced from the same host as the page.
</p>
<div id="url-map"
style="height: 600px; width: 80%; border: thin solid gray;"></div>
<div id="doc">
<p>
Use this page as a crib for how to use <b>GeoCSV Lite</b> in your projects. In order
for it to work, you need:
</p>
<ol>
<li>Javascript dependencies:
<ol>
<li><a href="">Leaflet</a> (provides mapping);</li>
<li><a href="">PapaParse</a> (provides CSV parsing);</li>
</ol>
</li>
<li>
A line which includes the geocsv_lite library, which should be
<em>after</em> those including the dependencies: <br/>
<samp>&lt;script src="js/compiled/geocsv_lite.js"
type="text/javascript"&gt;&lt;/script&gt;</samp>
</li>
<li>One (or more) <code>div</code> elements to contain your maps. It
is a requirement of Leaflet that these must have a fixed pixel height.
Each must have a distinct <code>id</code>;</li>
<li>
For each <code>div</code> which you wish to contain a map view,
an invocation of the function
<code>geocsv_lite.core.initialise_map_element(id, data-source)</code>: <br/>
<samp>&lt;script&gt;geocsv_lite.core.initialise_map_element("map", "data/data.csv");&lt;/script&gt;</samp>
</li>
</ol>
<p>
The value passed as <var>data-source</var> may be CSV text, or it
may be a URL from which CSV text can be sourced.
</p>
<h2>
Custom map pins
</h2>
<p>
<img src="img/map-pins/Anchor-customer-pin.png"/>
<img src="img/map-pins/Broadband-supplier-pin.png"/>
<img src="img/map-pins/Champion-pin.png"/>
<img src="img/map-pins/Developer-pin.png"/>
<img src="img/map-pins/Further-education-pin.png"/>
<img src="img/map-pins/Higher-education-pin.png"/>
<img src="img/map-pins/Investor-pin.png"/>
<img src="img/map-pins/Landowner-pin.png"/>
<img src="img/map-pins/Operator-pin.png"/>
<img src="img/map-pins/Unknown-pin.png"/>
</p>
<p>
If your CSV document has a column called <samp>category</samp> (case insensitive),
then, as with the full-fat GeoCSV, if there is an image file in the
<samp>img/map-pins</samp> subdirectory whose name is the value of that
column with <samp>-pin.png</samp> appended, then that image will be
used as the image for the map pin. The image should be 40 pixels high
and 30 wide. It will be anchored centre bottom. You are advised to use
<samp>Unknown-pin.png</samp> as the basis for your design.
</p>
<p>
<strong>WARNING:</strong> if you have a column called <samp>category</samp>,
and you don't have an appropriate pin image for each value present,
then you will get 'broken' pin images appearing on your map.
</p>
</div>
</div>
<footer>
<div id="credits">
<div>
<img height="16" width="16" alt="Clojure"
src="img/credits/clojure-icon.gif"/> Powered by
<a href="http://clojure.org">Clojure</a> ||
<img height="16" width="16" alt="GitHub"
src="img/credits/github-logo-transparent.png"/>Find me/fork me on
<a href="https://github.com/simon-brooke/geocsv-lite">Github</a> ||
<img height="16" width="16"
alt="Free Software Foundation"
src="img/credits/gnu.small.png"/>Licensed under the
<a href="http://www.gnu.org/licenses/gpl-2.0.html">GNU General Public License version 2.0</a>
</div>
</div>
</footer>
<script src="js/compiled/geocsv_lite.js" type="text/javascript"></script>
<script>
/* Map using data from element content */
geocsv_lite.core.initialise_map_element("element-content-map",
document.getElementById("element-content-map").innerText);
/* Map using inline CSV passed to the function */
geocsv_lite.core.initialise_map_element("inline-csv-map",
"Country,Name,Latitude,Longitude,CountryCode,Continent\n" +
"Somaliland,Hargeisa,9.55,44.050000,NULL,Africa\n" +
"Western Sahara,El-Aaiún,27.153611,-13.203333,EH,Africa\n" +
"Algeria,Algiers,36.75,3.050000,DZ,Africa\n" +
"Angola,Luanda,-8.833333333333334,13.216667,AO,Africa\n" +
"Benin,Porto-Novo,6.483333333333333,2.616667,BJ,Africa\n" +
"Botswana,Gaborone,-24.633333333333333,25.900000,BW,Africa\n" +
"Burkina Faso,Ouagadougou,12.366666666666667,-1.516667,BF,Africa\n" +
"Burundi,Bujumbura,-3.3666666666666667,29.350000,BI,Africa\n" +
"Cameroon,Yaounde,3.8666666666666667,11.516667,CM,Africa\n" +
"Cape Verde,Praia,14.916666666666666,-23.516667,CV,Africa\n" +
"Central African Republic,Bangui,4.366666666666666,18.583333,CF,Africa\n" +
"Chad,N'Djamena,12.1,15.033333,TD,Africa\n" +
"Comoros,Moroni,-11.7,43.233333,KM,Africa\n" +
"Democratic Republic of the Congo,Kinshasa,-4.316666666666666,15.300000,CD,Africa\n" +
"Republic of Congo,Brazzaville,-4.25,15.283333,CG,Africa\n" +
"Cote d'Ivoire,Yamoussoukro,6.816666666666666,-5.266667,CI,Africa\n" +
"Djibouti,Djibouti,11.583333333333334,43.150000,DJ,Africa\n" +
"Egypt,Cairo,30.05,31.250000,EG,Africa\n" +
"Equatorial Guinea,Malabo,3.75,8.783333,GQ,Africa\n" +
"Eritrea,Asmara,15.333333333333334,38.933333,ER,Africa\n" +
"Ethiopia,Addis Ababa,9.033333333333333,38.700000,ET,Africa\n" +
"Gabon,Libreville,0.38333333333333336,9.450000,GA,Africa\n" +
"The Gambia,Banjul,13.45,-16.566667,GM,Africa\n" +
"Ghana,Accra,5.55,-0.216667,GH,Africa\n" +
"Guinea,Conakry,9.5,-13.700000,GN,Africa\n" +
"Guinea-Bissau,Bissau,11.85,-15.583333,GW,Africa\n" +
"Kenya,Nairobi,-1.2833333333333332,36.816667,KE,Africa\n" +
"Lesotho,Maseru,-29.316666666666666,27.483333,LS,Africa\n" +
"Liberia,Monrovia,6.3,-10.800000,LR,Africa\n" +
"Libya,Tripoli,32.88333333333333,13.166667,LY,Africa\n" +
"Madagascar,Antananarivo,-18.916666666666668,47.516667,MG,Africa\n" +
"Malawi,Lilongwe,-13.966666666666667,33.783333,MW,Africa\n" +
"Mali,Bamako,12.65,-8.000000,ML,Africa\n" +
"Mauritania,Nouakchott,18.066666666666666,-15.966667,MR,Africa\n" +
"Mauritius,Port Louis,-20.15,57.483333,MU,Africa\n" +
"Morocco,Rabat,34.016666666666666,-6.816667,MA,Africa\n" +
"Mozambique,Maputo,-25.95,32.583333,MZ,Africa\n" +
"Namibia,Windhoek,-22.566666666666666,17.083333,NA,Africa\n" +
"Niger,Niamey,13.516666666666667,2.116667,NE,Africa\n" +
"Nigeria,Abuja,9.083333333333334,7.533333,NG,Africa\n" +
"Rwanda,Kigali,-1.95,30.050000,RW,Africa\n" +
"Saint Helena,Jamestown,-15.933333333333334,-5.716667,SH,Africa\n" +
"Sao Tome and Principe,Sao Tome,0.3333333333333333,6.733333,ST,Africa\n" +
"Senegal,Dakar,14.733333333333333,-17.633333,SN,Africa\n" +
"Seychelles,Victoria,-4.616666666666667,55.450000,SC,Africa\n" +
"Sierra Leone,Freetown,8.483333333333333,-13.233333,SL,Africa\n" +
"Somalia,Mogadishu,2.066666666666667,45.333333,SO,Africa\n" +
"South Africa,Pretoria,-25.7,28.216667,ZA,Africa\n" +
"South Sudan,Juba,4.85,31.616667,SS,Africa\n" +
"Sudan,Khartoum,15.6,32.533333,SD,Africa\n" +
"Swaziland,Mbabane,-26.316666666666666,31.133333,SZ,Africa\n" +
"Tanzania,Dar es Salaam,-6.8,39.283333,TZ,Africa\n" +
"Togo,Lome,6.116666666666666,1.216667,TG,Africa\n" +
"Tunisia,Tunis,36.8,10.183333,TN,Africa\n" +
"Uganda,Kampala,0.31666666666666665,32.550000,UG,Africa\n" +
"Zambia,Lusaka,-15.416666666666666,28.283333,ZM,Africa\n" +
"Zimbabwe,Harare,-17.816666666666666,31.033333,ZW,Africa\n" +
"British Indian Ocean Territory,Diego Garcia,-7.3,72.400000,IO,Africa\n" );
/* Map using CSV from URL */
var url = window.location.href.substring(0, window.location.href.lastIndexOf('/')) + "/data/europe-capitals.csv";
geocsv_lite.core.initialise_map_element("url-map", url);
</script>
</body>
</html>

View file

@ -0,0 +1,12 @@
var CLOSURE_UNCOMPILED_DEFINES = {};
var CLOSURE_NO_DEPS = true;
if(typeof goog == "undefined") document.write('<script src="js/compiled/out/goog/base.js"></script>');
document.write('<script src="js/compiled/out/goog/deps.js"></script>');
document.write('<script src="js/compiled/out/cljs_deps.js"></script>');
document.write('<script>if (typeof goog == "undefined") console.warn("ClojureScript could not load :main, did you forget to specify :asset-path?");</script>');
document.write('<script>goog.require("devtools.preload");</script>');
document.write('<script>goog.require("figwheel.connect");</script>');
document.write('<script>goog.require("process.env");</script>');
document.write('<script>goog.require("geocsv_lite.core");</script>');
document.write("<script>figwheel.connect.start();</script>");

View file

@ -0,0 +1 @@
-1623538622

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,925 @@
(ns cljs.core.async
(:refer-clojure :exclude [reduce transduce into merge map take partition partition-by])
(:require [cljs.core.async.impl.protocols :as impl]
[cljs.core.async.impl.channels :as channels]
[cljs.core.async.impl.buffers :as buffers]
[cljs.core.async.impl.timers :as timers]
[cljs.core.async.impl.dispatch :as dispatch]
[cljs.core.async.impl.ioc-helpers :as helpers]
[goog.array :as garray])
(:require-macros [cljs.core.async.impl.ioc-macros :as ioc]
[cljs.core.async :refer [go go-loop]]))
(defn- fn-handler
([f] (fn-handler f true))
([f blockable]
(reify
impl/Handler
(active? [_] true)
(blockable? [_] blockable)
(commit [_] f))))
(defn buffer
"Returns a fixed buffer of size n. When full, puts will block/park."
[n]
(buffers/fixed-buffer n))
(defn dropping-buffer
"Returns a buffer of size n. When full, puts will complete but
val will be dropped (no transfer)."
[n]
(buffers/dropping-buffer n))
(defn sliding-buffer
"Returns a buffer of size n. When full, puts will complete, and be
buffered, but oldest elements in buffer will be dropped (not
transferred)."
[n]
(buffers/sliding-buffer n))
(defn unblocking-buffer?
"Returns true if a channel created with buff will never block. That is to say,
puts into this buffer will never cause the buffer to be full. "
[buff]
(satisfies? impl/UnblockingBuffer buff))
(defn chan
"Creates a channel with an optional buffer, an optional transducer (like (map f),
(filter p) etc or a composition thereof), and an optional exception handler.
If buf-or-n is a number, will create and use a fixed buffer of that size. If a
transducer is supplied a buffer must be specified. ex-handler must be a
fn of one argument - if an exception occurs during transformation it will be called
with the thrown value as an argument, and any non-nil return value will be placed
in the channel."
([] (chan nil))
([buf-or-n] (chan buf-or-n nil nil))
([buf-or-n xform] (chan buf-or-n xform nil))
([buf-or-n xform ex-handler]
(let [buf-or-n (if (= buf-or-n 0)
nil
buf-or-n)]
(when xform (assert buf-or-n "buffer must be supplied when transducer is"))
(channels/chan (if (number? buf-or-n)
(buffer buf-or-n)
buf-or-n)
xform
ex-handler))))
(defn promise-chan
"Creates a promise channel with an optional transducer, and an optional
exception-handler. A promise channel can take exactly one value that consumers
will receive. Once full, puts complete but val is dropped (no transfer).
Consumers will block until either a value is placed in the channel or the
channel is closed. See chan for the semantics of xform and ex-handler."
([] (promise-chan nil))
([xform] (promise-chan xform nil))
([xform ex-handler]
(chan (buffers/promise-buffer) xform ex-handler)))
(defn timeout
"Returns a channel that will close after msecs"
[msecs]
(timers/timeout msecs))
(defn <!
"takes a val from port. Must be called inside a (go ...) block. Will
return nil if closed. Will park if nothing is available.
Returns true unless port is already closed"
[port]
(throw (js/Error. "<! used not in (go ...) block")))
(defn take!
"Asynchronously takes a val from port, passing to fn1. Will pass nil
if closed. If on-caller? (default true) is true, and value is
immediately available, will call fn1 on calling thread.
Returns nil."
([port fn1] (take! port fn1 true))
([port fn1 on-caller?]
(let [ret (impl/take! port (fn-handler fn1))]
(when ret
(let [val @ret]
(if on-caller?
(fn1 val)
(dispatch/run #(fn1 val)))))
nil)))
(defn- nop [_])
(def ^:private fhnop (fn-handler nop))
(defn >!
"puts a val into port. nil values are not allowed. Must be called
inside a (go ...) block. Will park if no buffer space is available.
Returns true unless port is already closed."
[port val]
(throw (js/Error. ">! used not in (go ...) block")))
(defn put!
"Asynchronously puts a val into port, calling fn1 (if supplied) when
complete. nil values are not allowed. Will throw if closed. If
on-caller? (default true) is true, and the put is immediately
accepted, will call fn1 on calling thread. Returns nil."
([port val]
(if-let [ret (impl/put! port val fhnop)]
@ret
true))
([port val fn1] (put! port val fn1 true))
([port val fn1 on-caller?]
(if-let [retb (impl/put! port val (fn-handler fn1))]
(let [ret @retb]
(if on-caller?
(fn1 ret)
(dispatch/run #(fn1 ret)))
ret)
true)))
(defn close!
([port]
(impl/close! port)))
(defn- random-array
[n]
(let [a (make-array n)]
(dotimes [x n]
(aset a x x))
(garray/shuffle a)
a))
(defn- alt-flag []
(let [flag (atom true)]
(reify
impl/Handler
(active? [_] @flag)
(blockable? [_] true)
(commit [_]
(reset! flag nil)
true))))
(defn- alt-handler [flag cb]
(reify
impl/Handler
(active? [_] (impl/active? flag))
(blockable? [_] true)
(commit [_]
(impl/commit flag)
cb)))
(defn do-alts
"returns derefable [val port] if immediate, nil if enqueued"
[fret ports opts]
(assert (pos? (count ports)) "alts must have at least one channel operation")
(let [flag (alt-flag)
n (count ports)
idxs (random-array n)
priority (:priority opts)
ret
(loop [i 0]
(when (< i n)
(let [idx (if priority i (aget idxs i))
port (nth ports idx)
wport (when (vector? port) (port 0))
vbox (if wport
(let [val (port 1)]
(impl/put! wport val (alt-handler flag #(fret [% wport]))))
(impl/take! port (alt-handler flag #(fret [% port]))))]
(if vbox
(channels/box [@vbox (or wport port)])
(recur (inc i))))))]
(or
ret
(when (contains? opts :default)
(when-let [got (and (impl/active? flag) (impl/commit flag))]
(channels/box [(:default opts) :default]))))))
(defn alts!
"Completes at most one of several channel operations. Must be called
inside a (go ...) block. ports is a vector of channel endpoints,
which can be either a channel to take from or a vector of
[channel-to-put-to val-to-put], in any combination. Takes will be
made as if by <!, and puts will be made as if by >!. Unless
the :priority option is true, if more than one port operation is
ready a non-deterministic choice will be made. If no operation is
ready and a :default value is supplied, [default-val :default] will
be returned, otherwise alts! will park until the first operation to
become ready completes. Returns [val port] of the completed
operation, where val is the value taken for takes, and a
boolean (true unless already closed, as per put!) for puts.
opts are passed as :key val ... Supported options:
:default val - the value to use if none of the operations are immediately ready
:priority true - (default nil) when true, the operations will be tried in order.
Note: there is no guarantee that the port exps or val exprs will be
used, nor in what order should they be, so they should not be
depended upon for side effects."
[ports & {:as opts}]
(throw (js/Error. "alts! used not in (go ...) block")))
(defn offer!
"Puts a val into port if it's possible to do so immediately.
nil values are not allowed. Never blocks. Returns true if offer succeeds."
[port val]
(let [ret (impl/put! port val (fn-handler nop false))]
(when ret @ret)))
(defn poll!
"Takes a val from port if it's possible to do so immediately.
Never blocks. Returns value if successful, nil otherwise."
[port]
(let [ret (impl/take! port (fn-handler nop false))]
(when ret @ret)))
;;;;;;; channel ops
(defn pipe
"Takes elements from the from channel and supplies them to the to
channel. By default, the to channel will be closed when the from
channel closes, but can be determined by the close? parameter. Will
stop consuming the from channel if the to channel closes"
([from to] (pipe from to true))
([from to close?]
(go-loop []
(let [v (<! from)]
(if (nil? v)
(when close? (close! to))
(when (>! to v)
(recur)))))
to))
(defn- pipeline*
([n to xf from close? ex-handler type]
(assert (pos? n))
(let [jobs (chan n)
results (chan n)
process (fn [[v p :as job]]
(if (nil? job)
(do (close! results) nil)
(let [res (chan 1 xf ex-handler)]
(go
(>! res v)
(close! res))
(put! p res)
true)))
async (fn [[v p :as job]]
(if (nil? job)
(do (close! results) nil)
(let [res (chan 1)]
(xf v res)
(put! p res)
true)))]
(dotimes [_ n]
(case type
:compute (go-loop []
(let [job (<! jobs)]
(when (process job)
(recur))))
:async (go-loop []
(let [job (<! jobs)]
(when (async job)
(recur))))))
(go-loop []
(let [v (<! from)]
(if (nil? v)
(close! jobs)
(let [p (chan 1)]
(>! jobs [v p])
(>! results p)
(recur)))))
(go-loop []
(let [p (<! results)]
(if (nil? p)
(when close? (close! to))
(let [res (<! p)]
(loop []
(let [v (<! res)]
(when (and (not (nil? v)) (>! to v))
(recur))))
(recur))))))))
(defn pipeline-async
"Takes elements from the from channel and supplies them to the to
channel, subject to the async function af, with parallelism n. af
must be a function of two arguments, the first an input value and
the second a channel on which to place the result(s). af must close!
the channel before returning. The presumption is that af will
return immediately, having launched some asynchronous operation
whose completion/callback will manipulate the result channel. Outputs
will be returned in order relative to the inputs. By default, the to
channel will be closed when the from channel closes, but can be
determined by the close? parameter. Will stop consuming the from
channel if the to channel closes."
([n to af from] (pipeline-async n to af from true))
([n to af from close?] (pipeline* n to af from close? nil :async)))
(defn pipeline
"Takes elements from the from channel and supplies them to the to
channel, subject to the transducer xf, with parallelism n. Because
it is parallel, the transducer will be applied independently to each
element, not across elements, and may produce zero or more outputs
per input. Outputs will be returned in order relative to the
inputs. By default, the to channel will be closed when the from
channel closes, but can be determined by the close? parameter. Will
stop consuming the from channel if the to channel closes.
Note this is supplied for API compatibility with the Clojure version.
Values of N > 1 will not result in actual concurrency in a
single-threaded runtime."
([n to xf from] (pipeline n to xf from true))
([n to xf from close?] (pipeline n to xf from close? nil))
([n to xf from close? ex-handler] (pipeline* n to xf from close? ex-handler :compute)))
(defn split
"Takes a predicate and a source channel and returns a vector of two
channels, the first of which will contain the values for which the
predicate returned true, the second those for which it returned
false.
The out channels will be unbuffered by default, or two buf-or-ns can
be supplied. The channels will close after the source channel has
closed."
([p ch] (split p ch nil nil))
([p ch t-buf-or-n f-buf-or-n]
(let [tc (chan t-buf-or-n)
fc (chan f-buf-or-n)]
(go-loop []
(let [v (<! ch)]
(if (nil? v)
(do (close! tc) (close! fc))
(when (>! (if (p v) tc fc) v)
(recur)))))
[tc fc])))
(defn reduce
"f should be a function of 2 arguments. Returns a channel containing
the single result of applying f to init and the first item from the
channel, then applying f to that result and the 2nd item, etc. If
the channel closes without yielding items, returns init and f is not
called. ch must close before reduce produces a result."
[f init ch]
(go-loop [ret init]
(let [v (<! ch)]
(if (nil? v)
ret
(let [ret' (f ret v)]
(if (reduced? ret')
@ret'
(recur ret')))))))
(defn transduce
"async/reduces a channel with a transformation (xform f).
Returns a channel containing the result. ch must close before
transduce produces a result."
[xform f init ch]
(let [f (xform f)]
(go
(let [ret (<! (reduce f init ch))]
(f ret)))))
(defn onto-chan
"Puts the contents of coll into the supplied channel.
By default the channel will be closed after the items are copied,
but can be determined by the close? parameter.
Returns a channel which will close after the items are copied."
([ch coll] (onto-chan ch coll true))
([ch coll close?]
(go-loop [vs (seq coll)]
(if (and vs (>! ch (first vs)))
(recur (next vs))
(when close?
(close! ch))))))
(defn to-chan
"Creates and returns a channel which contains the contents of coll,
closing when exhausted."
[coll]
(let [ch (chan (bounded-count 100 coll))]
(onto-chan ch coll)
ch))
(defprotocol Mux
(muxch* [_]))
(defprotocol Mult
(tap* [m ch close?])
(untap* [m ch])
(untap-all* [m]))
(defn mult
"Creates and returns a mult(iple) of the supplied channel. Channels
containing copies of the channel can be created with 'tap', and
detached with 'untap'.
Each item is distributed to all taps in parallel and synchronously,
i.e. each tap must accept before the next item is distributed. Use
buffering/windowing to prevent slow taps from holding up the mult.
Items received when there are no taps get dropped.
If a tap puts to a closed channel, it will be removed from the mult."
[ch]
(let [cs (atom {}) ;;ch->close?
m (reify
Mux
(muxch* [_] ch)
Mult
(tap* [_ ch close?] (swap! cs assoc ch close?) nil)
(untap* [_ ch] (swap! cs dissoc ch) nil)
(untap-all* [_] (reset! cs {}) nil))
dchan (chan 1)
dctr (atom nil)
done (fn [_] (when (zero? (swap! dctr dec))
(put! dchan true)))]
(go-loop []
(let [val (<! ch)]
(if (nil? val)
(doseq [[c close?] @cs]
(when close? (close! c)))
(let [chs (keys @cs)]
(reset! dctr (count chs))
(doseq [c chs]
(when-not (put! c val done)
(done nil)
(untap* m c)))
;;wait for all
(when (seq chs)
(<! dchan))
(recur)))))
m))
(defn tap
"Copies the mult source onto the supplied channel.
By default the channel will be closed when the source closes,
but can be determined by the close? parameter."
([mult ch] (tap mult ch true))
([mult ch close?] (tap* mult ch close?) ch))
(defn untap
"Disconnects a target channel from a mult"
[mult ch]
(untap* mult ch))
(defn untap-all
"Disconnects all target channels from a mult"
[mult] (untap-all* mult))
(defprotocol Mix
(admix* [m ch])
(unmix* [m ch])
(unmix-all* [m])
(toggle* [m state-map])
(solo-mode* [m mode]))
(defn ioc-alts! [state cont-block ports & {:as opts}]
(ioc/aset-all! state helpers/STATE-IDX cont-block)
(when-let [cb (cljs.core.async/do-alts
(fn [val]
(ioc/aset-all! state helpers/VALUE-IDX val)
(helpers/run-state-machine-wrapped state))
ports
opts)]
(ioc/aset-all! state helpers/VALUE-IDX @cb)
:recur))
(defn mix
"Creates and returns a mix of one or more input channels which will
be put on the supplied out channel. Input sources can be added to
the mix with 'admix', and removed with 'unmix'. A mix supports
soloing, muting and pausing multiple inputs atomically using
'toggle', and can solo using either muting or pausing as determined
by 'solo-mode'.
Each channel can have zero or more boolean modes set via 'toggle':
:solo - when true, only this (ond other soloed) channel(s) will appear
in the mix output channel. :mute and :pause states of soloed
channels are ignored. If solo-mode is :mute, non-soloed
channels are muted, if :pause, non-soloed channels are
paused.
:mute - muted channels will have their contents consumed but not included in the mix
:pause - paused channels will not have their contents consumed (and thus also not included in the mix)
"
[out]
(let [cs (atom {}) ;;ch->attrs-map
solo-modes #{:mute :pause}
attrs (conj solo-modes :solo)
solo-mode (atom :mute)
change (chan)
changed #(put! change true)
pick (fn [attr chs]
(reduce-kv
(fn [ret c v]
(if (attr v)
(conj ret c)
ret))
#{} chs))
calc-state (fn []
(let [chs @cs
mode @solo-mode
solos (pick :solo chs)
pauses (pick :pause chs)]
{:solos solos
:mutes (pick :mute chs)
:reads (conj
(if (and (= mode :pause) (not (empty? solos)))
(vec solos)
(vec (remove pauses (keys chs))))
change)}))
m (reify
Mux
(muxch* [_] out)
Mix
(admix* [_ ch] (swap! cs assoc ch {}) (changed))
(unmix* [_ ch] (swap! cs dissoc ch) (changed))
(unmix-all* [_] (reset! cs {}) (changed))
(toggle* [_ state-map] (swap! cs (partial merge-with cljs.core/merge) state-map) (changed))
(solo-mode* [_ mode]
(assert (solo-modes mode) (str "mode must be one of: " solo-modes))
(reset! solo-mode mode)
(changed)))]
(go-loop [{:keys [solos mutes reads] :as state} (calc-state)]
(let [[v c] (alts! reads)]
(if (or (nil? v) (= c change))
(do (when (nil? v)
(swap! cs dissoc c))
(recur (calc-state)))
(if (or (solos c)
(and (empty? solos) (not (mutes c))))
(when (>! out v)
(recur state))
(recur state)))))
m))
(defn admix
"Adds ch as an input to the mix"
[mix ch]
(admix* mix ch))
(defn unmix
"Removes ch as an input to the mix"
[mix ch]
(unmix* mix ch))
(defn unmix-all
"removes all inputs from the mix"
[mix]
(unmix-all* mix))
(defn toggle
"Atomically sets the state(s) of one or more channels in a mix. The
state map is a map of channels -> channel-state-map. A
channel-state-map is a map of attrs -> boolean, where attr is one or
more of :mute, :pause or :solo. Any states supplied are merged with
the current state.
Note that channels can be added to a mix via toggle, which can be
used to add channels in a particular (e.g. paused) state."
[mix state-map]
(toggle* mix state-map))
(defn solo-mode
"Sets the solo mode of the mix. mode must be one of :mute or :pause"
[mix mode]
(solo-mode* mix mode))
(defprotocol Pub
(sub* [p v ch close?])
(unsub* [p v ch])
(unsub-all* [p] [p v]))
(defn pub
"Creates and returns a pub(lication) of the supplied channel,
partitioned into topics by the topic-fn. topic-fn will be applied to
each value on the channel and the result will determine the 'topic'
on which that value will be put. Channels can be subscribed to
receive copies of topics using 'sub', and unsubscribed using
'unsub'. Each topic will be handled by an internal mult on a
dedicated channel. By default these internal channels are
unbuffered, but a buf-fn can be supplied which, given a topic,
creates a buffer with desired properties.
Each item is distributed to all subs in parallel and synchronously,
i.e. each sub must accept before the next item is distributed. Use
buffering/windowing to prevent slow subs from holding up the pub.
Items received when there are no matching subs get dropped.
Note that if buf-fns are used then each topic is handled
asynchronously, i.e. if a channel is subscribed to more than one
topic it should not expect them to be interleaved identically with
the source."
([ch topic-fn] (pub ch topic-fn (constantly nil)))
([ch topic-fn buf-fn]
(let [mults (atom {}) ;;topic->mult
ensure-mult (fn [topic]
(or (get @mults topic)
(get (swap! mults
#(if (% topic) % (assoc % topic (mult (chan (buf-fn topic))))))
topic)))
p (reify
Mux
(muxch* [_] ch)
Pub
(sub* [p topic ch close?]
(let [m (ensure-mult topic)]
(tap m ch close?)))
(unsub* [p topic ch]
(when-let [m (get @mults topic)]
(untap m ch)))
(unsub-all* [_] (reset! mults {}))
(unsub-all* [_ topic] (swap! mults dissoc topic)))]
(go-loop []
(let [val (<! ch)]
(if (nil? val)
(doseq [m (vals @mults)]
(close! (muxch* m)))
(let [topic (topic-fn val)
m (get @mults topic)]
(when m
(when-not (>! (muxch* m) val)
(swap! mults dissoc topic)))
(recur)))))
p)))
(defn sub
"Subscribes a channel to a topic of a pub.
By default the channel will be closed when the source closes,
but can be determined by the close? parameter."
([p topic ch] (sub p topic ch true))
([p topic ch close?] (sub* p topic ch close?)))
(defn unsub
"Unsubscribes a channel from a topic of a pub"
[p topic ch]
(unsub* p topic ch))
(defn unsub-all
"Unsubscribes all channels from a pub, or a topic of a pub"
([p] (unsub-all* p))
([p topic] (unsub-all* p topic)))
;;;;
(defn map
"Takes a function and a collection of source channels, and returns a
channel which contains the values produced by applying f to the set
of first items taken from each source channel, followed by applying
f to the set of second items from each channel, until any one of the
channels is closed, at which point the output channel will be
closed. The returned channel will be unbuffered by default, or a
buf-or-n can be supplied"
([f chs] (map f chs nil))
([f chs buf-or-n]
(let [chs (vec chs)
out (chan buf-or-n)
cnt (count chs)
rets (object-array cnt)
dchan (chan 1)
dctr (atom nil)
done (mapv (fn [i]
(fn [ret]
(aset rets i ret)
(when (zero? (swap! dctr dec))
(put! dchan (.slice rets 0)))))
(range cnt))]
(go-loop []
(reset! dctr cnt)
(dotimes [i cnt]
(try
(take! (chs i) (done i))
(catch js/Object e
(swap! dctr dec))))
(let [rets (<! dchan)]
(if (some nil? rets)
(close! out)
(do (>! out (apply f rets))
(recur)))))
out)))
(defn merge
"Takes a collection of source channels and returns a channel which
contains all values taken from them. The returned channel will be
unbuffered by default, or a buf-or-n can be supplied. The channel
will close after all the source channels have closed."
([chs] (merge chs nil))
([chs buf-or-n]
(let [out (chan buf-or-n)]
(go-loop [cs (vec chs)]
(if (pos? (count cs))
(let [[v c] (alts! cs)]
(if (nil? v)
(recur (filterv #(not= c %) cs))
(do (>! out v)
(recur cs))))
(close! out)))
out)))
(defn into
"Returns a channel containing the single (collection) result of the
items taken from the channel conjoined to the supplied
collection. ch must close before into produces a result."
[coll ch]
(reduce conj coll ch))
(defn take
"Returns a channel that will return, at most, n items from ch. After n items
have been returned, or ch has been closed, the return chanel will close.
The output channel is unbuffered by default, unless buf-or-n is given."
([n ch]
(take n ch nil))
([n ch buf-or-n]
(let [out (chan buf-or-n)]
(go (loop [x 0]
(when (< x n)
(let [v (<! ch)]
(when (not (nil? v))
(>! out v)
(recur (inc x))))))
(close! out))
out)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; deprecated - do not use ;;;;;;;;;;;;;;;;;;;;;;;;;
(defn map<
"Deprecated - this function will be removed. Use transducer instead"
[f ch]
(reify
impl/Channel
(close! [_] (impl/close! ch))
(closed? [_] (impl/closed? ch))
impl/ReadPort
(take! [_ fn1]
(let [ret
(impl/take! ch
(reify
impl/Handler
(active? [_] (impl/active? fn1))
(blockable? [_] true)
#_(lock-id [_] (impl/lock-id fn1))
(commit [_]
(let [f1 (impl/commit fn1)]
#(f1 (if (nil? %) nil (f %)))))))]
(if (and ret (not (nil? @ret)))
(channels/box (f @ret))
ret)))
impl/WritePort
(put! [_ val fn1] (impl/put! ch val fn1))))
(defn map>
"Deprecated - this function will be removed. Use transducer instead"
[f ch]
(reify
impl/Channel
(close! [_] (impl/close! ch))
impl/ReadPort
(take! [_ fn1] (impl/take! ch fn1))
impl/WritePort
(put! [_ val fn1]
(impl/put! ch (f val) fn1))))
(defn filter>
"Deprecated - this function will be removed. Use transducer instead"
[p ch]
(reify
impl/Channel
(close! [_] (impl/close! ch))
(closed? [_] (impl/closed? ch))
impl/ReadPort
(take! [_ fn1] (impl/take! ch fn1))
impl/WritePort
(put! [_ val fn1]
(if (p val)
(impl/put! ch val fn1)
(channels/box (not (impl/closed? ch)))))))
(defn remove>
"Deprecated - this function will be removed. Use transducer instead"
[p ch]
(filter> (complement p) ch))
(defn filter<
"Deprecated - this function will be removed. Use transducer instead"
([p ch] (filter< p ch nil))
([p ch buf-or-n]
(let [out (chan buf-or-n)]
(go-loop []
(let [val (<! ch)]
(if (nil? val)
(close! out)
(do (when (p val)
(>! out val))
(recur)))))
out)))
(defn remove<
"Deprecated - this function will be removed. Use transducer instead"
([p ch] (remove< p ch nil))
([p ch buf-or-n] (filter< (complement p) ch buf-or-n)))
(defn- mapcat* [f in out]
(go-loop []
(let [val (<! in)]
(if (nil? val)
(close! out)
(do (doseq [v (f val)]
(>! out v))
(when-not (impl/closed? out)
(recur)))))))
(defn mapcat<
"Deprecated - this function will be removed. Use transducer instead"
([f in] (mapcat< f in nil))
([f in buf-or-n]
(let [out (chan buf-or-n)]
(mapcat* f in out)
out)))
(defn mapcat>
"Deprecated - this function will be removed. Use transducer instead"
([f out] (mapcat> f out nil))
([f out buf-or-n]
(let [in (chan buf-or-n)]
(mapcat* f in out)
in)))
(defn unique
"Deprecated - this function will be removed. Use transducer instead"
([ch]
(unique ch nil))
([ch buf-or-n]
(let [out (chan buf-or-n)]
(go (loop [last nil]
(let [v (<! ch)]
(when (not (nil? v))
(if (= v last)
(recur last)
(do (>! out v)
(recur v))))))
(close! out))
out)))
(defn partition
"Deprecated - this function will be removed. Use transducer instead"
([n ch]
(partition n ch nil))
([n ch buf-or-n]
(let [out (chan buf-or-n)]
(go (loop [arr (make-array n)
idx 0]
(let [v (<! ch)]
(if (not (nil? v))
(do (aset ^objects arr idx v)
(let [new-idx (inc idx)]
(if (< new-idx n)
(recur arr new-idx)
(do (>! out (vec arr))
(recur (make-array n) 0)))))
(do (when (> idx 0)
(>! out (vec arr)))
(close! out))))))
out)))
(defn partition-by
"Deprecated - this function will be removed. Use transducer instead"
([f ch]
(partition-by f ch nil))
([f ch buf-or-n]
(let [out (chan buf-or-n)]
(go (loop [lst (make-array 0)
last ::nothing]
(let [v (<! ch)]
(if (not (nil? v))
(let [new-itm (f v)]
(if (or (= new-itm last)
(keyword-identical? last ::nothing))
(do (.push lst v)
(recur lst new-itm))
(do (>! out (vec lst))
(let [new-lst (make-array 0)]
(.push new-lst v)
(recur new-lst new-itm)))))
(do (when (> (alength lst) 0)
(>! out (vec lst)))
(close! out))))))
out)))

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,159 @@
;; Copyright (c) Rich Hickey and contributors. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns cljs.core.async.impl.buffers
(:require [cljs.core.async.impl.protocols :as impl]))
;; -----------------------------------------------------------------------------
;; DO NOT USE, this is internal buffer representation
(defn acopy [src src-start dest dest-start len]
(loop [cnt 0]
(when (< cnt len)
(aset dest
(+ dest-start cnt)
(aget src (+ src-start cnt)))
(recur (inc cnt)))))
(deftype RingBuffer [^:mutable head ^:mutable tail ^:mutable length ^:mutable arr]
Object
(pop [_]
(when-not (zero? length)
(let [x (aget arr tail)]
(aset arr tail nil)
(set! tail (js-mod (inc tail) (alength arr)))
(set! length (dec length))
x)))
(unshift [_ x]
(aset arr head x)
(set! head (js-mod (inc head) (alength arr)))
(set! length (inc length))
nil)
(unbounded-unshift [this x]
(if (== (inc length) (alength arr))
(.resize this))
(.unshift this x))
;; Doubles the size of the buffer while retaining all the existing values
(resize
[_]
(let [new-arr-size (* (alength arr) 2)
new-arr (make-array new-arr-size)]
(cond
(< tail head)
(do (acopy arr tail new-arr 0 length)
(set! tail 0)
(set! head length)
(set! arr new-arr))
(> tail head)
(do (acopy arr tail new-arr 0 (- (alength arr) tail))
(acopy arr 0 new-arr (- (alength arr) tail) head)
(set! tail 0)
(set! head length)
(set! arr new-arr))
(== tail head)
(do (set! tail 0)
(set! head 0)
(set! arr new-arr)))))
(cleanup [this keep?]
(dotimes [x length]
(let [v (.pop this)]
(when ^boolean (keep? v)
(.unshift this v))))))
(defn ring-buffer [n]
(assert (> n 0) "Can't create a ring buffer of size 0")
(RingBuffer. 0 0 0 (make-array n)))
;; -----------------------------------------------------------------------------
(deftype FixedBuffer [buf n]
impl/Buffer
(full? [this]
(== (.-length buf) n))
(remove! [this]
(.pop buf))
(add!* [this itm]
(.unbounded-unshift buf itm)
this)
(close-buf! [this])
cljs.core/ICounted
(-count [this]
(.-length buf)))
(defn fixed-buffer [n]
(FixedBuffer. (ring-buffer n) n))
(deftype DroppingBuffer [buf n]
impl/UnblockingBuffer
impl/Buffer
(full? [this]
false)
(remove! [this]
(.pop buf))
(add!* [this itm]
(when-not (== (.-length buf) n)
(.unshift buf itm))
this)
(close-buf! [this])
cljs.core/ICounted
(-count [this]
(.-length buf)))
(defn dropping-buffer [n]
(DroppingBuffer. (ring-buffer n) n))
(deftype SlidingBuffer [buf n]
impl/UnblockingBuffer
impl/Buffer
(full? [this]
false)
(remove! [this]
(.pop buf))
(add!* [this itm]
(when (== (.-length buf) n)
(impl/remove! this))
(.unshift buf itm)
this)
(close-buf! [this])
cljs.core/ICounted
(-count [this]
(.-length buf)))
(defn sliding-buffer [n]
(SlidingBuffer. (ring-buffer n) n))
(defonce ^:private NO-VAL (js/Object.))
(defn- undelivered? [val]
(identical? NO-VAL val))
(deftype PromiseBuffer [^:mutable val]
impl/UnblockingBuffer
impl/Buffer
(full? [_]
false)
(remove! [_]
val)
(add!* [this itm]
(when (undelivered? val)
(set! val itm))
this)
(close-buf! [_]
(when (undelivered? val)
(set! val nil)))
cljs.core/ICounted
(-count [_]
(if (undelivered? val) 0 1)))
(defn promise-buffer []
(PromiseBuffer. NO-VAL))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,466 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('cljs.core.async.impl.buffers');
goog.require('cljs.core');
goog.require('cljs.core.async.impl.protocols');
cljs.core.async.impl.buffers.acopy = (function cljs$core$async$impl$buffers$acopy(src,src_start,dest,dest_start,len){
var cnt = (0);
while(true){
if((cnt < len)){
(dest[(dest_start + cnt)] = (src[(src_start + cnt)]));
var G__20837 = (cnt + (1));
cnt = G__20837;
continue;
} else {
return null;
}
break;
}
});
/**
* @constructor
* @implements {cljs.core.async.impl.buffers.Object}
*/
cljs.core.async.impl.buffers.RingBuffer = (function (head,tail,length,arr){
this.head = head;
this.tail = tail;
this.length = length;
this.arr = arr;
});
cljs.core.async.impl.buffers.RingBuffer.prototype.pop = (function (){
var self__ = this;
var _ = this;
if((self__.length === (0))){
return null;
} else {
var x = (self__.arr[self__.tail]);
(self__.arr[self__.tail] = null);
self__.tail = ((self__.tail + (1)) % self__.arr.length);
self__.length = (self__.length - (1));
return x;
}
});
cljs.core.async.impl.buffers.RingBuffer.prototype.unshift = (function (x){
var self__ = this;
var _ = this;
(self__.arr[self__.head] = x);
self__.head = ((self__.head + (1)) % self__.arr.length);
self__.length = (self__.length + (1));
return null;
});
cljs.core.async.impl.buffers.RingBuffer.prototype.unbounded_unshift = (function (x){
var self__ = this;
var this$ = this;
if(((self__.length + (1)) === self__.arr.length)){
this$.resize();
} else {
}
return this$.unshift(x);
});
cljs.core.async.impl.buffers.RingBuffer.prototype.resize = (function (){
var self__ = this;
var _ = this;
var new_arr_size = (self__.arr.length * (2));
var new_arr = (new Array(new_arr_size));
if((self__.tail < self__.head)){
cljs.core.async.impl.buffers.acopy.call(null,self__.arr,self__.tail,new_arr,(0),self__.length);
self__.tail = (0);
self__.head = self__.length;
return self__.arr = new_arr;
} else {
if((self__.tail > self__.head)){
cljs.core.async.impl.buffers.acopy.call(null,self__.arr,self__.tail,new_arr,(0),(self__.arr.length - self__.tail));
cljs.core.async.impl.buffers.acopy.call(null,self__.arr,(0),new_arr,(self__.arr.length - self__.tail),self__.head);
self__.tail = (0);
self__.head = self__.length;
return self__.arr = new_arr;
} else {
if((self__.tail === self__.head)){
self__.tail = (0);
self__.head = (0);
return self__.arr = new_arr;
} else {
return null;
}
}
}
});
cljs.core.async.impl.buffers.RingBuffer.prototype.cleanup = (function (keep_QMARK_){
var self__ = this;
var this$ = this;
var n__4607__auto__ = self__.length;
var x = (0);
while(true){
if((x < n__4607__auto__)){
var v_20838 = this$.pop();
if(keep_QMARK_.call(null,v_20838)){
this$.unshift(v_20838);
} else {
}
var G__20839 = (x + (1));
x = G__20839;
continue;
} else {
return null;
}
break;
}
});
cljs.core.async.impl.buffers.RingBuffer.getBasis = (function (){
return new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"head","head",869147608,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"tail","tail",494507963,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"length","length",-2065447907,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"arr","arr",2115492975,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
});
cljs.core.async.impl.buffers.RingBuffer.cljs$lang$type = true;
cljs.core.async.impl.buffers.RingBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/RingBuffer";
cljs.core.async.impl.buffers.RingBuffer.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.buffers/RingBuffer");
});
/**
* Positional factory function for cljs.core.async.impl.buffers/RingBuffer.
*/
cljs.core.async.impl.buffers.__GT_RingBuffer = (function cljs$core$async$impl$buffers$__GT_RingBuffer(head,tail,length,arr){
return (new cljs.core.async.impl.buffers.RingBuffer(head,tail,length,arr));
});
cljs.core.async.impl.buffers.ring_buffer = (function cljs$core$async$impl$buffers$ring_buffer(n){
if((n > (0))){
} else {
throw (new Error(["Assert failed: ","Can't create a ring buffer of size 0","\n","(> n 0)"].join('')));
}
return (new cljs.core.async.impl.buffers.RingBuffer((0),(0),(0),(new Array(n))));
});
/**
* @constructor
* @implements {cljs.core.ICounted}
* @implements {cljs.core.async.impl.protocols.Buffer}
*/
cljs.core.async.impl.buffers.FixedBuffer = (function (buf,n){
this.buf = buf;
this.n = n;
this.cljs$lang$protocol_mask$partition0$ = 2;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = cljs.core.PROTOCOL_SENTINEL;
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return (self__.buf.length === self__.n);
});
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return self__.buf.pop();
});
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 = (function (this$,itm){
var self__ = this;
var this$__$1 = this;
self__.buf.unbounded_unshift(itm);
return this$__$1;
});
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return null;
});
cljs.core.async.impl.buffers.FixedBuffer.prototype.cljs$core$ICounted$_count$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return self__.buf.length;
});
cljs.core.async.impl.buffers.FixedBuffer.getBasis = (function (){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.Symbol(null,"n","n",-2092305744,null)], null);
});
cljs.core.async.impl.buffers.FixedBuffer.cljs$lang$type = true;
cljs.core.async.impl.buffers.FixedBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/FixedBuffer";
cljs.core.async.impl.buffers.FixedBuffer.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.buffers/FixedBuffer");
});
/**
* Positional factory function for cljs.core.async.impl.buffers/FixedBuffer.
*/
cljs.core.async.impl.buffers.__GT_FixedBuffer = (function cljs$core$async$impl$buffers$__GT_FixedBuffer(buf,n){
return (new cljs.core.async.impl.buffers.FixedBuffer(buf,n));
});
cljs.core.async.impl.buffers.fixed_buffer = (function cljs$core$async$impl$buffers$fixed_buffer(n){
return (new cljs.core.async.impl.buffers.FixedBuffer(cljs.core.async.impl.buffers.ring_buffer.call(null,n),n));
});
/**
* @constructor
* @implements {cljs.core.ICounted}
* @implements {cljs.core.async.impl.protocols.UnblockingBuffer}
* @implements {cljs.core.async.impl.protocols.Buffer}
*/
cljs.core.async.impl.buffers.DroppingBuffer = (function (buf,n){
this.buf = buf;
this.n = n;
this.cljs$lang$protocol_mask$partition0$ = 2;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$UnblockingBuffer$ = cljs.core.PROTOCOL_SENTINEL;
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = cljs.core.PROTOCOL_SENTINEL;
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return false;
});
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return self__.buf.pop();
});
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 = (function (this$,itm){
var self__ = this;
var this$__$1 = this;
if((self__.buf.length === self__.n)){
} else {
self__.buf.unshift(itm);
}
return this$__$1;
});
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return null;
});
cljs.core.async.impl.buffers.DroppingBuffer.prototype.cljs$core$ICounted$_count$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return self__.buf.length;
});
cljs.core.async.impl.buffers.DroppingBuffer.getBasis = (function (){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.Symbol(null,"n","n",-2092305744,null)], null);
});
cljs.core.async.impl.buffers.DroppingBuffer.cljs$lang$type = true;
cljs.core.async.impl.buffers.DroppingBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/DroppingBuffer";
cljs.core.async.impl.buffers.DroppingBuffer.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.buffers/DroppingBuffer");
});
/**
* Positional factory function for cljs.core.async.impl.buffers/DroppingBuffer.
*/
cljs.core.async.impl.buffers.__GT_DroppingBuffer = (function cljs$core$async$impl$buffers$__GT_DroppingBuffer(buf,n){
return (new cljs.core.async.impl.buffers.DroppingBuffer(buf,n));
});
cljs.core.async.impl.buffers.dropping_buffer = (function cljs$core$async$impl$buffers$dropping_buffer(n){
return (new cljs.core.async.impl.buffers.DroppingBuffer(cljs.core.async.impl.buffers.ring_buffer.call(null,n),n));
});
/**
* @constructor
* @implements {cljs.core.ICounted}
* @implements {cljs.core.async.impl.protocols.UnblockingBuffer}
* @implements {cljs.core.async.impl.protocols.Buffer}
*/
cljs.core.async.impl.buffers.SlidingBuffer = (function (buf,n){
this.buf = buf;
this.n = n;
this.cljs$lang$protocol_mask$partition0$ = 2;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$UnblockingBuffer$ = cljs.core.PROTOCOL_SENTINEL;
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = cljs.core.PROTOCOL_SENTINEL;
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return false;
});
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return self__.buf.pop();
});
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 = (function (this$,itm){
var self__ = this;
var this$__$1 = this;
if((self__.buf.length === self__.n)){
cljs.core.async.impl.protocols.remove_BANG_.call(null,this$__$1);
} else {
}
self__.buf.unshift(itm);
return this$__$1;
});
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return null;
});
cljs.core.async.impl.buffers.SlidingBuffer.prototype.cljs$core$ICounted$_count$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
return self__.buf.length;
});
cljs.core.async.impl.buffers.SlidingBuffer.getBasis = (function (){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.Symbol(null,"n","n",-2092305744,null)], null);
});
cljs.core.async.impl.buffers.SlidingBuffer.cljs$lang$type = true;
cljs.core.async.impl.buffers.SlidingBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/SlidingBuffer";
cljs.core.async.impl.buffers.SlidingBuffer.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.buffers/SlidingBuffer");
});
/**
* Positional factory function for cljs.core.async.impl.buffers/SlidingBuffer.
*/
cljs.core.async.impl.buffers.__GT_SlidingBuffer = (function cljs$core$async$impl$buffers$__GT_SlidingBuffer(buf,n){
return (new cljs.core.async.impl.buffers.SlidingBuffer(buf,n));
});
cljs.core.async.impl.buffers.sliding_buffer = (function cljs$core$async$impl$buffers$sliding_buffer(n){
return (new cljs.core.async.impl.buffers.SlidingBuffer(cljs.core.async.impl.buffers.ring_buffer.call(null,n),n));
});
if((typeof cljs !== 'undefined') && (typeof cljs.core !== 'undefined') && (typeof cljs.core.async !== 'undefined') && (typeof cljs.core.async.impl !== 'undefined') && (typeof cljs.core.async.impl.buffers !== 'undefined') && (typeof cljs.core.async.impl.buffers.NO_VAL !== 'undefined')){
} else {
cljs.core.async.impl.buffers.NO_VAL = (new Object());
}
cljs.core.async.impl.buffers.undelivered_QMARK_ = (function cljs$core$async$impl$buffers$undelivered_QMARK_(val){
return (cljs.core.async.impl.buffers.NO_VAL === val);
});
/**
* @constructor
* @implements {cljs.core.ICounted}
* @implements {cljs.core.async.impl.protocols.UnblockingBuffer}
* @implements {cljs.core.async.impl.protocols.Buffer}
*/
cljs.core.async.impl.buffers.PromiseBuffer = (function (val){
this.val = val;
this.cljs$lang$protocol_mask$partition0$ = 2;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$UnblockingBuffer$ = cljs.core.PROTOCOL_SENTINEL;
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$ = cljs.core.PROTOCOL_SENTINEL;
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
return false;
});
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
return self__.val;
});
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 = (function (this$,itm){
var self__ = this;
var this$__$1 = this;
if(cljs.core.async.impl.buffers.undelivered_QMARK_.call(null,self__.val)){
self__.val = itm;
} else {
}
return this$__$1;
});
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
if(cljs.core.async.impl.buffers.undelivered_QMARK_.call(null,self__.val)){
return self__.val = null;
} else {
return null;
}
});
cljs.core.async.impl.buffers.PromiseBuffer.prototype.cljs$core$ICounted$_count$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
if(cljs.core.async.impl.buffers.undelivered_QMARK_.call(null,self__.val)){
return (0);
} else {
return (1);
}
});
cljs.core.async.impl.buffers.PromiseBuffer.getBasis = (function (){
return new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(new cljs.core.Symbol(null,"val","val",1769233139,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
});
cljs.core.async.impl.buffers.PromiseBuffer.cljs$lang$type = true;
cljs.core.async.impl.buffers.PromiseBuffer.cljs$lang$ctorStr = "cljs.core.async.impl.buffers/PromiseBuffer";
cljs.core.async.impl.buffers.PromiseBuffer.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.buffers/PromiseBuffer");
});
/**
* Positional factory function for cljs.core.async.impl.buffers/PromiseBuffer.
*/
cljs.core.async.impl.buffers.__GT_PromiseBuffer = (function cljs$core$async$impl$buffers$__GT_PromiseBuffer(val){
return (new cljs.core.async.impl.buffers.PromiseBuffer(val));
});
cljs.core.async.impl.buffers.promise_buffer = (function cljs$core$async$impl$buffers$promise_buffer(){
return (new cljs.core.async.impl.buffers.PromiseBuffer(cljs.core.async.impl.buffers.NO_VAL));
});
//# sourceMappingURL=buffers.js.map?rel=1582560146496

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,192 @@
;; Copyright (c) Rich Hickey and contributors. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns cljs.core.async.impl.channels
(:require [cljs.core.async.impl.protocols :as impl]
[cljs.core.async.impl.dispatch :as dispatch]
[cljs.core.async.impl.buffers :as buffers]))
(defn box [val]
(reify cljs.core/IDeref
(-deref [_] val)))
(deftype PutBox [handler val])
(defn put-active? [box]
(impl/active? (.-handler box)))
(def ^:const MAX_DIRTY 64)
(defprotocol MMC
(abort [this]))
(deftype ManyToManyChannel [takes ^:mutable dirty-takes puts ^:mutable dirty-puts ^not-native buf ^:mutable closed add!]
MMC
(abort [this]
(loop []
(let [putter (.pop puts)]
(when-not (nil? putter)
(let [^not-native put-handler (.-handler putter)
val (.-val putter)]
(if ^boolean (impl/active? put-handler)
(let [put-cb (impl/commit put-handler)]
(dispatch/run #(put-cb true)))
(recur))))))
(.cleanup puts (constantly false))
(impl/close! this))
impl/WritePort
(put! [this val ^not-native handler]
(assert (not (nil? val)) "Can't put nil on a channel")
;; bug in CLJS compiler boolean inference - David
(let [^boolean closed closed]
(if (or closed (not ^boolean (impl/active? handler)))
(box (not closed))
(if (and buf (not (impl/full? buf)))
(do
(impl/commit handler)
(let [done? (reduced? (add! buf val))
take-cbs (loop [takers []]
(if (and (pos? (.-length takes)) (pos? (count buf)))
(let [^not-native taker (.pop takes)]
(if ^boolean (impl/active? taker)
(let [ret (impl/commit taker)
val (impl/remove! buf)]
(recur (conj takers (fn [] (ret val)))))
(recur takers)))
takers))]
(when done? (abort this))
(when (seq take-cbs)
(doseq [f take-cbs]
(dispatch/run f)))
(box true)))
(let [taker (loop []
(let [^not-native taker (.pop takes)]
(when taker
(if (impl/active? taker)
taker
(recur)))))]
(if taker
(let [take-cb (impl/commit taker)]
(impl/commit handler)
(dispatch/run (fn [] (take-cb val)))
(box true))
(do
(if (> dirty-puts MAX_DIRTY)
(do (set! dirty-puts 0)
(.cleanup puts put-active?))
(set! dirty-puts (inc dirty-puts)))
(when (impl/blockable? handler)
(assert (< (.-length puts) impl/MAX-QUEUE-SIZE)
(str "No more than " impl/MAX-QUEUE-SIZE
" pending puts are allowed on a single channel."
" Consider using a windowed buffer."))
(.unbounded-unshift puts (PutBox. handler val)))
nil)))))))
impl/ReadPort
(take! [this ^not-native handler]
(if (not ^boolean (impl/active? handler))
nil
(if (and (not (nil? buf)) (pos? (count buf)))
(do
(if-let [take-cb (impl/commit handler)]
(let [val (impl/remove! buf)
[done? cbs] (when (pos? (.-length puts))
(loop [cbs []]
(let [putter (.pop puts)
^not-native put-handler (.-handler putter)
val (.-val putter)
cb (and ^boolean (impl/active? put-handler) (impl/commit put-handler))
cbs (if cb (conj cbs cb) cbs)
done? (when cb (reduced? (add! buf val)))]
(if (and (not done?) (not (impl/full? buf)) (pos? (.-length puts)))
(recur cbs)
[done? cbs]))))]
(when done?
(abort this))
(doseq [cb cbs]
(dispatch/run #(cb true)))
(box val))))
(let [putter (loop []
(let [putter (.pop puts)]
(when putter
(if ^boolean (impl/active? (.-handler putter))
putter
(recur)))))]
(if putter
(let [put-cb (impl/commit (.-handler putter))]
(impl/commit handler)
(dispatch/run #(put-cb true))
(box (.-val putter)))
(if closed
(do
(when buf (add! buf))
(if (and (impl/active? handler) (impl/commit handler))
(let [has-val (and buf (pos? (count buf)))]
(let [val (when has-val (impl/remove! buf))]
(box val)))
nil))
(do
(if (> dirty-takes MAX_DIRTY)
(do (set! dirty-takes 0)
(.cleanup takes impl/active?))
(set! dirty-takes (inc dirty-takes)))
(when (impl/blockable? handler)
(assert (< (.-length takes) impl/MAX-QUEUE-SIZE)
(str "No more than " impl/MAX-QUEUE-SIZE
" pending takes are allowed on a single channel."))
(.unbounded-unshift takes handler))
nil)))))))
impl/Channel
(closed? [_] closed)
(close! [this]
(if ^boolean closed
nil
(do (set! closed true)
(when (and buf (zero? (.-length puts)))
(add! buf))
(loop []
(let [^not-native taker (.pop takes)]
(when-not (nil? taker)
(when ^boolean (impl/active? taker)
(let [take-cb (impl/commit taker)
val (when (and buf (pos? (count buf))) (impl/remove! buf))]
(dispatch/run (fn [] (take-cb val)))))
(recur))))
(when buf (impl/close-buf! buf))
nil))))
(defn- ex-handler [ex]
(.log js/console ex)
nil)
(defn- handle [buf exh t]
(let [else ((or exh ex-handler) t)]
(if (nil? else)
buf
(impl/add! buf else))))
(defn chan
([buf] (chan buf nil))
([buf xform] (chan buf xform nil))
([buf xform exh]
(ManyToManyChannel. (buffers/ring-buffer 32) 0 (buffers/ring-buffer 32)
0 buf false
(let [add! (if xform (xform impl/add!) impl/add!)]
(fn
([buf]
(try
(add! buf)
(catch :default t
(handle buf exh t))))
([buf val]
(try
(add! buf val)
(catch :default t
(handle buf exh t)))))))))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,685 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('cljs.core.async.impl.channels');
goog.require('cljs.core');
goog.require('cljs.core.async.impl.protocols');
goog.require('cljs.core.async.impl.dispatch');
goog.require('cljs.core.async.impl.buffers');
cljs.core.async.impl.channels.box = (function cljs$core$async$impl$channels$box(val){
if((typeof cljs !== 'undefined') && (typeof cljs.core !== 'undefined') && (typeof cljs.core.async !== 'undefined') && (typeof cljs.core.async.impl !== 'undefined') && (typeof cljs.core.async.impl.channels !== 'undefined') && (typeof cljs.core.async.impl.channels.t_cljs$core$async$impl$channels20847 !== 'undefined')){
} else {
/**
* @constructor
* @implements {cljs.core.IMeta}
* @implements {cljs.core.IDeref}
* @implements {cljs.core.IWithMeta}
*/
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels20847 = (function (val,meta20848){
this.val = val;
this.meta20848 = meta20848;
this.cljs$lang$protocol_mask$partition0$ = 425984;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels20847.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (_20849,meta20848__$1){
var self__ = this;
var _20849__$1 = this;
return (new cljs.core.async.impl.channels.t_cljs$core$async$impl$channels20847(self__.val,meta20848__$1));
});
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels20847.prototype.cljs$core$IMeta$_meta$arity$1 = (function (_20849){
var self__ = this;
var _20849__$1 = this;
return self__.meta20848;
});
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels20847.prototype.cljs$core$IDeref$_deref$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
return self__.val;
});
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels20847.getBasis = (function (){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"val","val",1769233139,null),new cljs.core.Symbol(null,"meta20848","meta20848",1569359721,null)], null);
});
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels20847.cljs$lang$type = true;
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels20847.cljs$lang$ctorStr = "cljs.core.async.impl.channels/t_cljs$core$async$impl$channels20847";
cljs.core.async.impl.channels.t_cljs$core$async$impl$channels20847.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.channels/t_cljs$core$async$impl$channels20847");
});
/**
* Positional factory function for cljs.core.async.impl.channels/t_cljs$core$async$impl$channels20847.
*/
cljs.core.async.impl.channels.__GT_t_cljs$core$async$impl$channels20847 = (function cljs$core$async$impl$channels$box_$___GT_t_cljs$core$async$impl$channels20847(val__$1,meta20848){
return (new cljs.core.async.impl.channels.t_cljs$core$async$impl$channels20847(val__$1,meta20848));
});
}
return (new cljs.core.async.impl.channels.t_cljs$core$async$impl$channels20847(val,cljs.core.PersistentArrayMap.EMPTY));
});
/**
* @constructor
*/
cljs.core.async.impl.channels.PutBox = (function (handler,val){
this.handler = handler;
this.val = val;
});
cljs.core.async.impl.channels.PutBox.getBasis = (function (){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"handler","handler",1444934915,null),new cljs.core.Symbol(null,"val","val",1769233139,null)], null);
});
cljs.core.async.impl.channels.PutBox.cljs$lang$type = true;
cljs.core.async.impl.channels.PutBox.cljs$lang$ctorStr = "cljs.core.async.impl.channels/PutBox";
cljs.core.async.impl.channels.PutBox.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.channels/PutBox");
});
/**
* Positional factory function for cljs.core.async.impl.channels/PutBox.
*/
cljs.core.async.impl.channels.__GT_PutBox = (function cljs$core$async$impl$channels$__GT_PutBox(handler,val){
return (new cljs.core.async.impl.channels.PutBox(handler,val));
});
cljs.core.async.impl.channels.put_active_QMARK_ = (function cljs$core$async$impl$channels$put_active_QMARK_(box){
return cljs.core.async.impl.protocols.active_QMARK_.call(null,box.handler);
});
cljs.core.async.impl.channels.MAX_DIRTY = (64);
/**
* @interface
*/
cljs.core.async.impl.channels.MMC = function(){};
cljs.core.async.impl.channels.abort = (function cljs$core$async$impl$channels$abort(this$){
if((((!((this$ == null)))) && ((!((this$.cljs$core$async$impl$channels$MMC$abort$arity$1 == null)))))){
return this$.cljs$core$async$impl$channels$MMC$abort$arity$1(this$);
} else {
var x__4433__auto__ = (((this$ == null))?null:this$);
var m__4434__auto__ = (cljs.core.async.impl.channels.abort[goog.typeOf(x__4433__auto__)]);
if((!((m__4434__auto__ == null)))){
return m__4434__auto__.call(null,this$);
} else {
var m__4431__auto__ = (cljs.core.async.impl.channels.abort["_"]);
if((!((m__4431__auto__ == null)))){
return m__4431__auto__.call(null,this$);
} else {
throw cljs.core.missing_protocol.call(null,"MMC.abort",this$);
}
}
}
});
/**
* @constructor
* @implements {cljs.core.async.impl.channels.MMC}
* @implements {cljs.core.async.impl.protocols.Channel}
* @implements {cljs.core.async.impl.protocols.WritePort}
* @implements {cljs.core.async.impl.protocols.ReadPort}
*/
cljs.core.async.impl.channels.ManyToManyChannel = (function (takes,dirty_takes,puts,dirty_puts,buf,closed,add_BANG_){
this.takes = takes;
this.dirty_takes = dirty_takes;
this.puts = puts;
this.dirty_puts = dirty_puts;
this.buf = buf;
this.closed = closed;
this.add_BANG_ = add_BANG_;
});
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$channels$MMC$ = cljs.core.PROTOCOL_SENTINEL;
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$channels$MMC$abort$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
while(true){
var putter_20861 = self__.puts.pop();
if((putter_20861 == null)){
} else {
var put_handler_20862 = putter_20861.handler;
var val_20863 = putter_20861.val;
if(cljs.core.async.impl.protocols.active_QMARK_.call(null,put_handler_20862)){
var put_cb_20864 = cljs.core.async.impl.protocols.commit.call(null,put_handler_20862);
cljs.core.async.impl.dispatch.run.call(null,((function (put_cb_20864,put_handler_20862,val_20863,putter_20861,this$__$1){
return (function (){
return put_cb_20864.call(null,true);
});})(put_cb_20864,put_handler_20862,val_20863,putter_20861,this$__$1))
);
} else {
continue;
}
}
break;
}
self__.puts.cleanup(cljs.core.constantly.call(null,false));
return cljs.core.async.impl.protocols.close_BANG_.call(null,this$__$1);
});
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$WritePort$ = cljs.core.PROTOCOL_SENTINEL;
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3 = (function (this$,val,handler){
var self__ = this;
var this$__$1 = this;
if((!((val == null)))){
} else {
throw (new Error(["Assert failed: ","Can't put nil on a channel","\n","(not (nil? val))"].join('')));
}
var closed__$1 = self__.closed;
if(((closed__$1) || ((!(cljs.core.async.impl.protocols.active_QMARK_.call(null,handler)))))){
return cljs.core.async.impl.channels.box.call(null,(!(closed__$1)));
} else {
if(cljs.core.truth_((function (){var and__4120__auto__ = self__.buf;
if(cljs.core.truth_(and__4120__auto__)){
return cljs.core.not.call(null,cljs.core.async.impl.protocols.full_QMARK_.call(null,self__.buf));
} else {
return and__4120__auto__;
}
})())){
cljs.core.async.impl.protocols.commit.call(null,handler);
var done_QMARK_ = cljs.core.reduced_QMARK_.call(null,self__.add_BANG_.call(null,self__.buf,val));
var take_cbs = (function (){var takers = cljs.core.PersistentVector.EMPTY;
while(true){
if((((self__.takes.length > (0))) && ((cljs.core.count.call(null,self__.buf) > (0))))){
var taker = self__.takes.pop();
if(cljs.core.async.impl.protocols.active_QMARK_.call(null,taker)){
var ret = cljs.core.async.impl.protocols.commit.call(null,taker);
var val__$1 = cljs.core.async.impl.protocols.remove_BANG_.call(null,self__.buf);
var G__20865 = cljs.core.conj.call(null,takers,((function (takers,ret,val__$1,taker,done_QMARK_,closed__$1,this$__$1){
return (function (){
return ret.call(null,val__$1);
});})(takers,ret,val__$1,taker,done_QMARK_,closed__$1,this$__$1))
);
takers = G__20865;
continue;
} else {
var G__20866 = takers;
takers = G__20866;
continue;
}
} else {
return takers;
}
break;
}
})();
if(done_QMARK_){
cljs.core.async.impl.channels.abort.call(null,this$__$1);
} else {
}
if(cljs.core.seq.call(null,take_cbs)){
var seq__20850_20867 = cljs.core.seq.call(null,take_cbs);
var chunk__20851_20868 = null;
var count__20852_20869 = (0);
var i__20853_20870 = (0);
while(true){
if((i__20853_20870 < count__20852_20869)){
var f_20871 = cljs.core._nth.call(null,chunk__20851_20868,i__20853_20870);
cljs.core.async.impl.dispatch.run.call(null,f_20871);
var G__20872 = seq__20850_20867;
var G__20873 = chunk__20851_20868;
var G__20874 = count__20852_20869;
var G__20875 = (i__20853_20870 + (1));
seq__20850_20867 = G__20872;
chunk__20851_20868 = G__20873;
count__20852_20869 = G__20874;
i__20853_20870 = G__20875;
continue;
} else {
var temp__5720__auto___20876 = cljs.core.seq.call(null,seq__20850_20867);
if(temp__5720__auto___20876){
var seq__20850_20877__$1 = temp__5720__auto___20876;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__20850_20877__$1)){
var c__4550__auto___20878 = cljs.core.chunk_first.call(null,seq__20850_20877__$1);
var G__20879 = cljs.core.chunk_rest.call(null,seq__20850_20877__$1);
var G__20880 = c__4550__auto___20878;
var G__20881 = cljs.core.count.call(null,c__4550__auto___20878);
var G__20882 = (0);
seq__20850_20867 = G__20879;
chunk__20851_20868 = G__20880;
count__20852_20869 = G__20881;
i__20853_20870 = G__20882;
continue;
} else {
var f_20883 = cljs.core.first.call(null,seq__20850_20877__$1);
cljs.core.async.impl.dispatch.run.call(null,f_20883);
var G__20884 = cljs.core.next.call(null,seq__20850_20877__$1);
var G__20885 = null;
var G__20886 = (0);
var G__20887 = (0);
seq__20850_20867 = G__20884;
chunk__20851_20868 = G__20885;
count__20852_20869 = G__20886;
i__20853_20870 = G__20887;
continue;
}
} else {
}
}
break;
}
} else {
}
return cljs.core.async.impl.channels.box.call(null,true);
} else {
var taker = (function (){while(true){
var taker = self__.takes.pop();
if(cljs.core.truth_(taker)){
if(cljs.core.truth_(cljs.core.async.impl.protocols.active_QMARK_.call(null,taker))){
return taker;
} else {
continue;
}
} else {
return null;
}
break;
}
})();
if(cljs.core.truth_(taker)){
var take_cb = cljs.core.async.impl.protocols.commit.call(null,taker);
cljs.core.async.impl.protocols.commit.call(null,handler);
cljs.core.async.impl.dispatch.run.call(null,((function (take_cb,taker,closed__$1,this$__$1){
return (function (){
return take_cb.call(null,val);
});})(take_cb,taker,closed__$1,this$__$1))
);
return cljs.core.async.impl.channels.box.call(null,true);
} else {
if((self__.dirty_puts > (64))){
self__.dirty_puts = (0);
self__.puts.cleanup(cljs.core.async.impl.channels.put_active_QMARK_);
} else {
self__.dirty_puts = (self__.dirty_puts + (1));
}
if(cljs.core.truth_(cljs.core.async.impl.protocols.blockable_QMARK_.call(null,handler))){
if((self__.puts.length < (1024))){
} else {
throw (new Error(["Assert failed: ",["No more than ",cljs.core.str.cljs$core$IFn$_invoke$arity$1((1024))," pending puts are allowed on a single channel."," Consider using a windowed buffer."].join(''),"\n","(< (.-length puts) impl/MAX-QUEUE-SIZE)"].join('')));
}
self__.puts.unbounded_unshift((new cljs.core.async.impl.channels.PutBox(handler,val)));
} else {
}
return null;
}
}
}
});
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$ReadPort$ = cljs.core.PROTOCOL_SENTINEL;
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2 = (function (this$,handler){
var self__ = this;
var this$__$1 = this;
if((!(cljs.core.async.impl.protocols.active_QMARK_.call(null,handler)))){
return null;
} else {
if((((!((self__.buf == null)))) && ((cljs.core.count.call(null,self__.buf) > (0))))){
var temp__5718__auto__ = cljs.core.async.impl.protocols.commit.call(null,handler);
if(cljs.core.truth_(temp__5718__auto__)){
var take_cb = temp__5718__auto__;
var val = cljs.core.async.impl.protocols.remove_BANG_.call(null,self__.buf);
var vec__20854 = (((self__.puts.length > (0)))?(function (){var cbs = cljs.core.PersistentVector.EMPTY;
while(true){
var putter = self__.puts.pop();
var put_handler = putter.handler;
var val__$1 = putter.val;
var cb = (function (){var and__4120__auto__ = cljs.core.async.impl.protocols.active_QMARK_.call(null,put_handler);
if(and__4120__auto__){
return cljs.core.async.impl.protocols.commit.call(null,put_handler);
} else {
return and__4120__auto__;
}
})();
var cbs__$1 = (cljs.core.truth_(cb)?cljs.core.conj.call(null,cbs,cb):cbs);
var done_QMARK_ = (cljs.core.truth_(cb)?cljs.core.reduced_QMARK_.call(null,self__.add_BANG_.call(null,self__.buf,val__$1)):null);
if(((cljs.core.not.call(null,done_QMARK_)) && (cljs.core.not.call(null,cljs.core.async.impl.protocols.full_QMARK_.call(null,self__.buf))) && ((self__.puts.length > (0))))){
var G__20888 = cbs__$1;
cbs = G__20888;
continue;
} else {
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [done_QMARK_,cbs__$1], null);
}
break;
}
})():null);
var done_QMARK_ = cljs.core.nth.call(null,vec__20854,(0),null);
var cbs = cljs.core.nth.call(null,vec__20854,(1),null);
if(cljs.core.truth_(done_QMARK_)){
cljs.core.async.impl.channels.abort.call(null,this$__$1);
} else {
}
var seq__20857_20889 = cljs.core.seq.call(null,cbs);
var chunk__20858_20890 = null;
var count__20859_20891 = (0);
var i__20860_20892 = (0);
while(true){
if((i__20860_20892 < count__20859_20891)){
var cb_20893 = cljs.core._nth.call(null,chunk__20858_20890,i__20860_20892);
cljs.core.async.impl.dispatch.run.call(null,((function (seq__20857_20889,chunk__20858_20890,count__20859_20891,i__20860_20892,cb_20893,val,vec__20854,done_QMARK_,cbs,take_cb,temp__5718__auto__,this$__$1){
return (function (){
return cb_20893.call(null,true);
});})(seq__20857_20889,chunk__20858_20890,count__20859_20891,i__20860_20892,cb_20893,val,vec__20854,done_QMARK_,cbs,take_cb,temp__5718__auto__,this$__$1))
);
var G__20894 = seq__20857_20889;
var G__20895 = chunk__20858_20890;
var G__20896 = count__20859_20891;
var G__20897 = (i__20860_20892 + (1));
seq__20857_20889 = G__20894;
chunk__20858_20890 = G__20895;
count__20859_20891 = G__20896;
i__20860_20892 = G__20897;
continue;
} else {
var temp__5720__auto___20898 = cljs.core.seq.call(null,seq__20857_20889);
if(temp__5720__auto___20898){
var seq__20857_20899__$1 = temp__5720__auto___20898;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__20857_20899__$1)){
var c__4550__auto___20900 = cljs.core.chunk_first.call(null,seq__20857_20899__$1);
var G__20901 = cljs.core.chunk_rest.call(null,seq__20857_20899__$1);
var G__20902 = c__4550__auto___20900;
var G__20903 = cljs.core.count.call(null,c__4550__auto___20900);
var G__20904 = (0);
seq__20857_20889 = G__20901;
chunk__20858_20890 = G__20902;
count__20859_20891 = G__20903;
i__20860_20892 = G__20904;
continue;
} else {
var cb_20905 = cljs.core.first.call(null,seq__20857_20899__$1);
cljs.core.async.impl.dispatch.run.call(null,((function (seq__20857_20889,chunk__20858_20890,count__20859_20891,i__20860_20892,cb_20905,seq__20857_20899__$1,temp__5720__auto___20898,val,vec__20854,done_QMARK_,cbs,take_cb,temp__5718__auto__,this$__$1){
return (function (){
return cb_20905.call(null,true);
});})(seq__20857_20889,chunk__20858_20890,count__20859_20891,i__20860_20892,cb_20905,seq__20857_20899__$1,temp__5720__auto___20898,val,vec__20854,done_QMARK_,cbs,take_cb,temp__5718__auto__,this$__$1))
);
var G__20906 = cljs.core.next.call(null,seq__20857_20899__$1);
var G__20907 = null;
var G__20908 = (0);
var G__20909 = (0);
seq__20857_20889 = G__20906;
chunk__20858_20890 = G__20907;
count__20859_20891 = G__20908;
i__20860_20892 = G__20909;
continue;
}
} else {
}
}
break;
}
return cljs.core.async.impl.channels.box.call(null,val);
} else {
return null;
}
} else {
var putter = (function (){while(true){
var putter = self__.puts.pop();
if(cljs.core.truth_(putter)){
if(cljs.core.async.impl.protocols.active_QMARK_.call(null,putter.handler)){
return putter;
} else {
continue;
}
} else {
return null;
}
break;
}
})();
if(cljs.core.truth_(putter)){
var put_cb = cljs.core.async.impl.protocols.commit.call(null,putter.handler);
cljs.core.async.impl.protocols.commit.call(null,handler);
cljs.core.async.impl.dispatch.run.call(null,((function (put_cb,putter,this$__$1){
return (function (){
return put_cb.call(null,true);
});})(put_cb,putter,this$__$1))
);
return cljs.core.async.impl.channels.box.call(null,putter.val);
} else {
if(cljs.core.truth_(self__.closed)){
if(cljs.core.truth_(self__.buf)){
self__.add_BANG_.call(null,self__.buf);
} else {
}
if(cljs.core.truth_((function (){var and__4120__auto__ = cljs.core.async.impl.protocols.active_QMARK_.call(null,handler);
if(cljs.core.truth_(and__4120__auto__)){
return cljs.core.async.impl.protocols.commit.call(null,handler);
} else {
return and__4120__auto__;
}
})())){
var has_val = (function (){var and__4120__auto__ = self__.buf;
if(cljs.core.truth_(and__4120__auto__)){
return (cljs.core.count.call(null,self__.buf) > (0));
} else {
return and__4120__auto__;
}
})();
var val = (cljs.core.truth_(has_val)?cljs.core.async.impl.protocols.remove_BANG_.call(null,self__.buf):null);
return cljs.core.async.impl.channels.box.call(null,val);
} else {
return null;
}
} else {
if((self__.dirty_takes > (64))){
self__.dirty_takes = (0);
self__.takes.cleanup(cljs.core.async.impl.protocols.active_QMARK_);
} else {
self__.dirty_takes = (self__.dirty_takes + (1));
}
if(cljs.core.truth_(cljs.core.async.impl.protocols.blockable_QMARK_.call(null,handler))){
if((self__.takes.length < (1024))){
} else {
throw (new Error(["Assert failed: ",["No more than ",cljs.core.str.cljs$core$IFn$_invoke$arity$1((1024))," pending takes are allowed on a single channel."].join(''),"\n","(< (.-length takes) impl/MAX-QUEUE-SIZE)"].join('')));
}
self__.takes.unbounded_unshift(handler);
} else {
}
return null;
}
}
}
}
});
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$Channel$ = cljs.core.PROTOCOL_SENTINEL;
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$Channel$closed_QMARK_$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
return self__.closed;
});
cljs.core.async.impl.channels.ManyToManyChannel.prototype.cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1 = (function (this$){
var self__ = this;
var this$__$1 = this;
if(self__.closed){
return null;
} else {
self__.closed = true;
if(cljs.core.truth_((function (){var and__4120__auto__ = self__.buf;
if(cljs.core.truth_(and__4120__auto__)){
return (self__.puts.length === (0));
} else {
return and__4120__auto__;
}
})())){
self__.add_BANG_.call(null,self__.buf);
} else {
}
while(true){
var taker_20910 = self__.takes.pop();
if((taker_20910 == null)){
} else {
if(cljs.core.async.impl.protocols.active_QMARK_.call(null,taker_20910)){
var take_cb_20911 = cljs.core.async.impl.protocols.commit.call(null,taker_20910);
var val_20912 = (cljs.core.truth_((function (){var and__4120__auto__ = self__.buf;
if(cljs.core.truth_(and__4120__auto__)){
return (cljs.core.count.call(null,self__.buf) > (0));
} else {
return and__4120__auto__;
}
})())?cljs.core.async.impl.protocols.remove_BANG_.call(null,self__.buf):null);
cljs.core.async.impl.dispatch.run.call(null,((function (take_cb_20911,val_20912,taker_20910,this$__$1){
return (function (){
return take_cb_20911.call(null,val_20912);
});})(take_cb_20911,val_20912,taker_20910,this$__$1))
);
} else {
}
continue;
}
break;
}
if(cljs.core.truth_(self__.buf)){
cljs.core.async.impl.protocols.close_buf_BANG_.call(null,self__.buf);
} else {
}
return null;
}
});
cljs.core.async.impl.channels.ManyToManyChannel.getBasis = (function (){
return new cljs.core.PersistentVector(null, 7, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"takes","takes",298247964,null),cljs.core.with_meta(new cljs.core.Symbol(null,"dirty-takes","dirty-takes",575642138,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"puts","puts",-1883877054,null),cljs.core.with_meta(new cljs.core.Symbol(null,"dirty-puts","dirty-puts",57041148,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"buf","buf",1426618187,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"tag","tag",-1290361223),new cljs.core.Symbol(null,"not-native","not-native",-236392494,null)], null)),cljs.core.with_meta(new cljs.core.Symbol(null,"closed","closed",720856168,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"add!","add!",2046056845,null)], null);
});
cljs.core.async.impl.channels.ManyToManyChannel.cljs$lang$type = true;
cljs.core.async.impl.channels.ManyToManyChannel.cljs$lang$ctorStr = "cljs.core.async.impl.channels/ManyToManyChannel";
cljs.core.async.impl.channels.ManyToManyChannel.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.channels/ManyToManyChannel");
});
/**
* Positional factory function for cljs.core.async.impl.channels/ManyToManyChannel.
*/
cljs.core.async.impl.channels.__GT_ManyToManyChannel = (function cljs$core$async$impl$channels$__GT_ManyToManyChannel(takes,dirty_takes,puts,dirty_puts,buf,closed,add_BANG_){
return (new cljs.core.async.impl.channels.ManyToManyChannel(takes,dirty_takes,puts,dirty_puts,buf,closed,add_BANG_));
});
cljs.core.async.impl.channels.ex_handler = (function cljs$core$async$impl$channels$ex_handler(ex){
console.log(ex);
return null;
});
cljs.core.async.impl.channels.handle = (function cljs$core$async$impl$channels$handle(buf,exh,t){
var else$ = (function (){var or__4131__auto__ = exh;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return cljs.core.async.impl.channels.ex_handler;
}
})().call(null,t);
if((else$ == null)){
return buf;
} else {
return cljs.core.async.impl.protocols.add_BANG_.call(null,buf,else$);
}
});
cljs.core.async.impl.channels.chan = (function cljs$core$async$impl$channels$chan(var_args){
var G__20914 = arguments.length;
switch (G__20914) {
case 1:
return cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 3:
return cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$1 = (function (buf){
return cljs.core.async.impl.channels.chan.call(null,buf,null);
});
cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$2 = (function (buf,xform){
return cljs.core.async.impl.channels.chan.call(null,buf,xform,null);
});
cljs.core.async.impl.channels.chan.cljs$core$IFn$_invoke$arity$3 = (function (buf,xform,exh){
return (new cljs.core.async.impl.channels.ManyToManyChannel(cljs.core.async.impl.buffers.ring_buffer.call(null,(32)),(0),cljs.core.async.impl.buffers.ring_buffer.call(null,(32)),(0),buf,false,(function (){var add_BANG_ = (cljs.core.truth_(xform)?xform.call(null,cljs.core.async.impl.protocols.add_BANG_):cljs.core.async.impl.protocols.add_BANG_);
return ((function (add_BANG_){
return (function() {
var G__20918 = null;
var G__20918__1 = (function (buf__$1){
try{return add_BANG_.call(null,buf__$1);
}catch (e20915){var t = e20915;
return cljs.core.async.impl.channels.handle.call(null,buf__$1,exh,t);
}});
var G__20918__2 = (function (buf__$1,val){
try{return add_BANG_.call(null,buf__$1,val);
}catch (e20916){var t = e20916;
return cljs.core.async.impl.channels.handle.call(null,buf__$1,exh,t);
}});
G__20918 = function(buf__$1,val){
switch(arguments.length){
case 1:
return G__20918__1.call(this,buf__$1);
case 2:
return G__20918__2.call(this,buf__$1,val);
}
throw(new Error('Invalid arity: ' + arguments.length));
};
G__20918.cljs$core$IFn$_invoke$arity$1 = G__20918__1;
G__20918.cljs$core$IFn$_invoke$arity$2 = G__20918__2;
return G__20918;
})()
;})(add_BANG_))
})()));
});
cljs.core.async.impl.channels.chan.cljs$lang$maxFixedArity = 3;
//# sourceMappingURL=channels.js.map?rel=1582560146581

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,37 @@
(ns cljs.core.async.impl.dispatch
(:require [cljs.core.async.impl.buffers :as buffers]
[goog.async.nextTick]))
(def tasks (buffers/ring-buffer 32))
(def running? false)
(def queued? false)
(def TASK_BATCH_SIZE 1024)
(declare queue-dispatcher)
(defn process-messages []
(set! running? true)
(set! queued? false)
(loop [count 0]
(let [m (.pop tasks)]
(when-not (nil? m)
(m)
(when (< count TASK_BATCH_SIZE)
(recur (inc count))))))
(set! running? false)
(when (> (.-length tasks) 0)
(queue-dispatcher)))
(defn queue-dispatcher []
(when-not (and queued? running?)
(set! queued? true)
(goog.async.nextTick process-messages)))
(defn run [f]
(.unbounded-unshift tasks f)
(queue-dispatcher))
(defn queue-delay [f delay]
(js/setTimeout f delay))

View file

@ -0,0 +1 @@
["^ ","~:rename-macros",["^ "],"~:renames",["^ "],"~:externs",["^ ","~$setTimeout",["^ "]],"~:use-macros",["^ "],"~:excludes",["~#set",[]],"~:name","~$cljs.core.async.impl.dispatch","~:imports",null,"~:requires",["^ ","~$buffers","~$cljs.core.async.impl.buffers","^<","^<","~$goog.async.nextTick","^="],"~:cljs.spec/speced-vars",[],"~:uses",null,"~:defs",["^ ","~$tasks",["^ ","^7","~$cljs.core.async.impl.dispatch/tasks","~:file","resources/public/js/compiled/out/cljs/core/async/impl/dispatch.cljs","~:line",5,"~:column",1,"~:end-line",5,"~:end-column",11,"~:meta",["^ ","^C","/home/simon/workspace/geocsv-lite/resources/public/js/compiled/out/cljs/core/async/impl/dispatch.cljs","^D",5,"^E",6,"^F",5,"^G",11],"~:tag","~$cljs.core.async.impl.buffers/RingBuffer"],"~$running?",["^ ","^7","~$cljs.core.async.impl.dispatch/running?","^C","resources/public/js/compiled/out/cljs/core/async/impl/dispatch.cljs","^D",6,"^E",1,"^F",6,"^G",14,"^H",["^ ","^C","/home/simon/workspace/geocsv-lite/resources/public/js/compiled/out/cljs/core/async/impl/dispatch.cljs","^D",6,"^E",6,"^F",6,"^G",14],"^I","~$boolean"],"~$queued?",["^ ","^7","~$cljs.core.async.impl.dispatch/queued?","^C","resources/public/js/compiled/out/cljs/core/async/impl/dispatch.cljs","^D",7,"^E",1,"^F",7,"^G",13,"^H",["^ ","^C","/home/simon/workspace/geocsv-lite/resources/public/js/compiled/out/cljs/core/async/impl/dispatch.cljs","^D",7,"^E",6,"^F",7,"^G",13],"^I","^M"],"~$TASK_BATCH_SIZE",["^ ","^7","~$cljs.core.async.impl.dispatch/TASK_BATCH_SIZE","^C","resources/public/js/compiled/out/cljs/core/async/impl/dispatch.cljs","^D",9,"^E",1,"^F",9,"^G",21,"^H",["^ ","^C","/home/simon/workspace/geocsv-lite/resources/public/js/compiled/out/cljs/core/async/impl/dispatch.cljs","^D",9,"^E",6,"^F",9,"^G",21],"^I","~$number"],"~$queue-dispatcher",["^ ","~:protocol-inline",null,"^H",["^ ","^C","/home/simon/workspace/geocsv-lite/resources/public/js/compiled/out/cljs/core/async/impl/dispatch.cljs","^D",26,"^E",7,"^F",26,"^G",23,"~:arglists",["~#list",["~$quote",["^V",[[]]]]]],"^7","~$cljs.core.async.impl.dispatch/queue-dispatcher","^C","resources/public/js/compiled/out/cljs/core/async/impl/dispatch.cljs","^G",23,"~:method-params",["^V",[[]]],"~:protocol-impl",null,"~:arglists-meta",["^V",[null,null]],"^E",1,"~:variadic?",false,"^D",26,"~:ret-tag",["^6",["~$any","~$clj-nil"]],"^F",26,"~:max-fixed-arity",0,"~:fn-var",true,"^U",["^V",["^W",["^V",[[]]]]]],"~$process-messages",["^ ","^T",null,"^H",["^ ","^C","/home/simon/workspace/geocsv-lite/resources/public/js/compiled/out/cljs/core/async/impl/dispatch.cljs","^D",13,"^E",7,"^F",13,"^G",23,"^U",["^V",["^W",["^V",[[]]]]]],"^7","~$cljs.core.async.impl.dispatch/process-messages","^C","resources/public/js/compiled/out/cljs/core/async/impl/dispatch.cljs","^G",23,"^Y",["^V",[[]]],"^Z",null,"^[",["^V",[null,null]],"^E",1,"^10",false,"^D",13,"^11",["^6",["^12","^13"]],"^F",13,"^14",0,"^15",true,"^U",["^V",["^W",["^V",[[]]]]]],"~$run",["^ ","^T",null,"^H",["^ ","^C","/home/simon/workspace/geocsv-lite/resources/public/js/compiled/out/cljs/core/async/impl/dispatch.cljs","^D",31,"^E",7,"^F",31,"^G",10,"^U",["^V",["^W",["^V",[["~$f"]]]]]],"^7","~$cljs.core.async.impl.dispatch/run","^C","resources/public/js/compiled/out/cljs/core/async/impl/dispatch.cljs","^G",10,"^Y",["^V",[["~$f"]]],"^Z",null,"^[",["^V",[null,null]],"^E",1,"^10",false,"^D",31,"^11",["^6",["^12","^13"]],"^F",31,"^14",1,"^15",true,"^U",["^V",["^W",["^V",[["~$f"]]]]]],"~$queue-delay",["^ ","^T",null,"^H",["^ ","^C","/home/simon/workspace/geocsv-lite/resources/public/js/compiled/out/cljs/core/async/impl/dispatch.cljs","^D",35,"^E",7,"^F",35,"^G",18,"^U",["^V",["^W",["^V",[["~$f","~$delay"]]]]]],"^7","~$cljs.core.async.impl.dispatch/queue-delay","^C","resources/public/js/compiled/out/cljs/core/async/impl/dispatch.cljs","^G",18,"^Y",["^V",[["~$f","^1;"]]],"^Z",null,"^[",["^V",[null,null]],"^E",1,"^10",false,"^D",35,"^11","~$js","^F",35,"^14",2,"^15",true,"^U",["^V",["^W",["^V",[["~$f","^1;"]]]]]]],"~:cljs.spec/registry-ref",[],"~:require-macros",null,"~:doc",null]

View file

@ -0,0 +1,58 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('cljs.core.async.impl.dispatch');
goog.require('cljs.core');
goog.require('cljs.core.async.impl.buffers');
goog.require('goog.async.nextTick');
cljs.core.async.impl.dispatch.tasks = cljs.core.async.impl.buffers.ring_buffer.call(null,(32));
cljs.core.async.impl.dispatch.running_QMARK_ = false;
cljs.core.async.impl.dispatch.queued_QMARK_ = false;
cljs.core.async.impl.dispatch.TASK_BATCH_SIZE = (1024);
cljs.core.async.impl.dispatch.process_messages = (function cljs$core$async$impl$dispatch$process_messages(){
cljs.core.async.impl.dispatch.running_QMARK_ = true;
cljs.core.async.impl.dispatch.queued_QMARK_ = false;
var count_20842 = (0);
while(true){
var m_20843 = cljs.core.async.impl.dispatch.tasks.pop();
if((m_20843 == null)){
} else {
m_20843.call(null);
if((count_20842 < cljs.core.async.impl.dispatch.TASK_BATCH_SIZE)){
var G__20844 = (count_20842 + (1));
count_20842 = G__20844;
continue;
} else {
}
}
break;
}
cljs.core.async.impl.dispatch.running_QMARK_ = false;
if((cljs.core.async.impl.dispatch.tasks.length > (0))){
return cljs.core.async.impl.dispatch.queue_dispatcher.call(null);
} else {
return null;
}
});
cljs.core.async.impl.dispatch.queue_dispatcher = (function cljs$core$async$impl$dispatch$queue_dispatcher(){
if(((cljs.core.async.impl.dispatch.queued_QMARK_) && (cljs.core.async.impl.dispatch.running_QMARK_))){
return null;
} else {
cljs.core.async.impl.dispatch.queued_QMARK_ = true;
return goog.async.nextTick.call(null,cljs.core.async.impl.dispatch.process_messages);
}
});
cljs.core.async.impl.dispatch.run = (function cljs$core$async$impl$dispatch$run(f){
cljs.core.async.impl.dispatch.tasks.unbounded_unshift(f);
return cljs.core.async.impl.dispatch.queue_dispatcher.call(null);
});
cljs.core.async.impl.dispatch.queue_delay = (function cljs$core$async$impl$dispatch$queue_delay(f,delay){
return setTimeout(f,delay);
});
//# sourceMappingURL=dispatch.js.map?rel=1582560146515

View file

@ -0,0 +1 @@
{"version":3,"file":"\/home\/simon\/workspace\/geocsv-lite\/resources\/public\/js\/compiled\/out\/cljs\/core\/async\/impl\/dispatch.js","sources":["dispatch.cljs?rel=1582560146515"],"lineCount":58,"mappings":";AAAA;;;;AAIA,AAAKA,sCAAM,mDAAA,nDAACC;AACZ,+CAAA,\/CAAKC;AACL,8CAAA,9CAAKC;AAEL,gDAAA,hDAAKC;AAEL,AAAA,AAEA,iDAAA,jDAAMC;AAAN,AACE,+CAAA,\/CAAMH;;AACN,8CAAA,9CAAMC;;AACN,kBAAA,dAAOG;;AAAP,AACE,IAAMC,UAAE,AAAMP;AAAd,AACE,GAAU,YAAA,XAAMO;AAAhB;AAAA,AACE,AAACA;;AACD,GAAM,CAAGD,cAAMF;AAAf,AACE,eAAO,eAAA,dAAKE;;;;AADd;;;;;AAEN,+CAAA,\/CAAMJ;;AACN,GAAM,8CAAA,7CAAG,AAAUF;AAAnB,AACE,OAACQ;;AADH;;;AAGF,iDAAA,jDAAMA;AAAN,AACE,GAAU,EAAKL,iDAAQD;AAAvB;;AAAA,AACE,8CAAA,9CAAMC;;AACN,OAAC,AAAAM,8BAAoBJ;;;AAEzB,oCAAA,pCAAMK,gFAAKC;AAAX,AACE,AAAoBX,sDAAMW;;AAC1B,OAACH;;AAEH,4CAAA,5CAAMI,gGAAaD,EAAEE;AAArB,AACE,OAACC,WAAcH,EAAEE","names":["cljs.core.async.impl.dispatch\/tasks","cljs.core.async.impl.buffers\/ring-buffer","cljs.core.async.impl.dispatch\/running?","cljs.core.async.impl.dispatch\/queued?","cljs.core.async.impl.dispatch\/TASK_BATCH_SIZE","cljs.core.async.impl.dispatch\/process-messages","count","m","cljs.core.async.impl.dispatch\/queue-dispatcher","goog\/async","cljs.core.async.impl.dispatch\/run","f","cljs.core.async.impl.dispatch\/queue-delay","delay","js\/setTimeout"]}

View file

@ -0,0 +1,146 @@
(ns cljs.core.async.impl.ioc-helpers
(:require [cljs.core.async.impl.protocols :as impl])
(:require-macros [cljs.core.async.impl.ioc-macros :as ioc]))
(def ^:const FN-IDX 0)
(def ^:const STATE-IDX 1)
(def ^:const VALUE-IDX 2)
(def ^:const BINDINGS-IDX 3)
(def ^:const EXCEPTION-FRAMES 4)
(def ^:const CURRENT-EXCEPTION 5)
(def ^:const USER-START-IDX 6)
(defn aset-object [arr idx o]
(aget arr idx o))
(defn aget-object [arr idx]
(aget arr idx))
(defn finished?
"Returns true if the machine is in a finished state"
[state-array]
(keyword-identical? (aget state-array STATE-IDX) :finished))
(defn- fn-handler
[f]
(reify
impl/Handler
(active? [_] true)
(blockable? [_] true)
(commit [_] f)))
(defn run-state-machine [state]
((aget-object state FN-IDX) state))
(defn run-state-machine-wrapped [state]
(try
(run-state-machine state)
(catch js/Object ex
(impl/close! ^not-native (aget-object state USER-START-IDX))
(throw ex))))
(defn take! [state blk ^not-native c]
(if-let [cb (impl/take! c (fn-handler
(fn [x]
(ioc/aset-all! state VALUE-IDX x STATE-IDX blk)
(run-state-machine-wrapped state))))]
(do (ioc/aset-all! state VALUE-IDX @cb STATE-IDX blk)
:recur)
nil))
(defn put! [state blk ^not-native c val]
(if-let [cb (impl/put! c val (fn-handler (fn [ret-val]
(ioc/aset-all! state VALUE-IDX ret-val STATE-IDX blk)
(run-state-machine-wrapped state))))]
(do (ioc/aset-all! state VALUE-IDX @cb STATE-IDX blk)
:recur)
nil))
(defn return-chan [state value]
(let [^not-native c (aget state USER-START-IDX)]
(when-not (nil? value)
(impl/put! c value (fn-handler (fn [] nil))))
(impl/close! c)
c))
(defrecord ExceptionFrame [catch-block
^Class catch-exception
finally-block
continue-block
prev])
(defn add-exception-frame [state catch-block catch-exception finally-block continue-block]
(ioc/aset-all! state
EXCEPTION-FRAMES
(->ExceptionFrame catch-block
catch-exception
finally-block
continue-block
(aget-object state EXCEPTION-FRAMES))))
(defn process-exception [state]
(let [exception-frame (aget-object state EXCEPTION-FRAMES)
catch-block (:catch-block exception-frame)
catch-exception (:catch-exception exception-frame)
exception (aget-object state CURRENT-EXCEPTION)]
(cond
(and exception
(not exception-frame))
(throw exception)
(and exception
catch-block
(or (= :default catch-exception)
(instance? catch-exception exception)))
(ioc/aset-all! state
STATE-IDX
catch-block
VALUE-IDX
exception
CURRENT-EXCEPTION
nil
EXCEPTION-FRAMES
(assoc exception-frame
:catch-block nil
:catch-exception nil))
(and exception
(not catch-block)
(not (:finally-block exception-frame)))
(do (ioc/aset-all! state
EXCEPTION-FRAMES
(:prev exception-frame))
(recur state))
(and exception
(not catch-block)
(:finally-block exception-frame))
(ioc/aset-all! state
STATE-IDX
(:finally-block exception-frame)
EXCEPTION-FRAMES
(assoc exception-frame
:finally-block nil))
(and (not exception)
(:finally-block exception-frame))
(do (ioc/aset-all! state
STATE-IDX
(:finally-block exception-frame)
EXCEPTION-FRAMES
(assoc exception-frame
:finally-block nil)))
(and (not exception)
(not (:finally-block exception-frame)))
(do (ioc/aset-all! state
STATE-IDX
(:continue-block exception-frame)
EXCEPTION-FRAMES
(:prev exception-frame)))
:else (throw (js/Error. "No matching clause")))))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,519 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('cljs.core.async.impl.ioc_helpers');
goog.require('cljs.core');
goog.require('cljs.core.async.impl.protocols');
cljs.core.async.impl.ioc_helpers.FN_IDX = (0);
cljs.core.async.impl.ioc_helpers.STATE_IDX = (1);
cljs.core.async.impl.ioc_helpers.VALUE_IDX = (2);
cljs.core.async.impl.ioc_helpers.BINDINGS_IDX = (3);
cljs.core.async.impl.ioc_helpers.EXCEPTION_FRAMES = (4);
cljs.core.async.impl.ioc_helpers.CURRENT_EXCEPTION = (5);
cljs.core.async.impl.ioc_helpers.USER_START_IDX = (6);
cljs.core.async.impl.ioc_helpers.aset_object = (function cljs$core$async$impl$ioc_helpers$aset_object(arr,idx,o){
return (arr[idx][o]);
});
cljs.core.async.impl.ioc_helpers.aget_object = (function cljs$core$async$impl$ioc_helpers$aget_object(arr,idx){
return (arr[idx]);
});
/**
* Returns true if the machine is in a finished state
*/
cljs.core.async.impl.ioc_helpers.finished_QMARK_ = (function cljs$core$async$impl$ioc_helpers$finished_QMARK_(state_array){
return cljs.core.keyword_identical_QMARK_.call(null,(state_array[(1)]),new cljs.core.Keyword(null,"finished","finished",-1018867731));
});
cljs.core.async.impl.ioc_helpers.fn_handler = (function cljs$core$async$impl$ioc_helpers$fn_handler(f){
if((typeof cljs !== 'undefined') && (typeof cljs.core !== 'undefined') && (typeof cljs.core.async !== 'undefined') && (typeof cljs.core.async.impl !== 'undefined') && (typeof cljs.core.async.impl.ioc_helpers !== 'undefined') && (typeof cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers22871 !== 'undefined')){
} else {
/**
* @constructor
* @implements {cljs.core.async.impl.protocols.Handler}
* @implements {cljs.core.IMeta}
* @implements {cljs.core.IWithMeta}
*/
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers22871 = (function (f,meta22872){
this.f = f;
this.meta22872 = meta22872;
this.cljs$lang$protocol_mask$partition0$ = 393216;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers22871.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (_22873,meta22872__$1){
var self__ = this;
var _22873__$1 = this;
return (new cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers22871(self__.f,meta22872__$1));
});
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers22871.prototype.cljs$core$IMeta$_meta$arity$1 = (function (_22873){
var self__ = this;
var _22873__$1 = this;
return self__.meta22872;
});
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers22871.prototype.cljs$core$async$impl$protocols$Handler$ = cljs.core.PROTOCOL_SENTINEL;
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers22871.prototype.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
return true;
});
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers22871.prototype.cljs$core$async$impl$protocols$Handler$blockable_QMARK_$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
return true;
});
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers22871.prototype.cljs$core$async$impl$protocols$Handler$commit$arity$1 = (function (_){
var self__ = this;
var ___$1 = this;
return self__.f;
});
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers22871.getBasis = (function (){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"f","f",43394975,null),new cljs.core.Symbol(null,"meta22872","meta22872",-718135857,null)], null);
});
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers22871.cljs$lang$type = true;
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers22871.cljs$lang$ctorStr = "cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers22871";
cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers22871.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers22871");
});
/**
* Positional factory function for cljs.core.async.impl.ioc-helpers/t_cljs$core$async$impl$ioc_helpers22871.
*/
cljs.core.async.impl.ioc_helpers.__GT_t_cljs$core$async$impl$ioc_helpers22871 = (function cljs$core$async$impl$ioc_helpers$fn_handler_$___GT_t_cljs$core$async$impl$ioc_helpers22871(f__$1,meta22872){
return (new cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers22871(f__$1,meta22872));
});
}
return (new cljs.core.async.impl.ioc_helpers.t_cljs$core$async$impl$ioc_helpers22871(f,cljs.core.PersistentArrayMap.EMPTY));
});
cljs.core.async.impl.ioc_helpers.run_state_machine = (function cljs$core$async$impl$ioc_helpers$run_state_machine(state){
return cljs.core.async.impl.ioc_helpers.aget_object.call(null,state,(0)).call(null,state);
});
cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped = (function cljs$core$async$impl$ioc_helpers$run_state_machine_wrapped(state){
try{return cljs.core.async.impl.ioc_helpers.run_state_machine.call(null,state);
}catch (e22874){if((e22874 instanceof Object)){
var ex = e22874;
cljs.core.async.impl.protocols.close_BANG_.call(null,cljs.core.async.impl.ioc_helpers.aget_object.call(null,state,(6)));
throw ex;
} else {
throw e22874;
}
}});
cljs.core.async.impl.ioc_helpers.take_BANG_ = (function cljs$core$async$impl$ioc_helpers$take_BANG_(state,blk,c){
var temp__5718__auto__ = cljs.core.async.impl.protocols.take_BANG_.call(null,c,cljs.core.async.impl.ioc_helpers.fn_handler.call(null,(function (x){
var statearr_22875_22877 = state;
(statearr_22875_22877[(2)] = x);
(statearr_22875_22877[(1)] = blk);
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state);
})));
if(cljs.core.truth_(temp__5718__auto__)){
var cb = temp__5718__auto__;
var statearr_22876_22878 = state;
(statearr_22876_22878[(2)] = cljs.core.deref.call(null,cb));
(statearr_22876_22878[(1)] = blk);
return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
return null;
}
});
cljs.core.async.impl.ioc_helpers.put_BANG_ = (function cljs$core$async$impl$ioc_helpers$put_BANG_(state,blk,c,val){
var temp__5718__auto__ = cljs.core.async.impl.protocols.put_BANG_.call(null,c,val,cljs.core.async.impl.ioc_helpers.fn_handler.call(null,(function (ret_val){
var statearr_22879_22881 = state;
(statearr_22879_22881[(2)] = ret_val);
(statearr_22879_22881[(1)] = blk);
return cljs.core.async.impl.ioc_helpers.run_state_machine_wrapped.call(null,state);
})));
if(cljs.core.truth_(temp__5718__auto__)){
var cb = temp__5718__auto__;
var statearr_22880_22882 = state;
(statearr_22880_22882[(2)] = cljs.core.deref.call(null,cb));
(statearr_22880_22882[(1)] = blk);
return new cljs.core.Keyword(null,"recur","recur",-437573268);
} else {
return null;
}
});
cljs.core.async.impl.ioc_helpers.return_chan = (function cljs$core$async$impl$ioc_helpers$return_chan(state,value){
var c = (state[(6)]);
if((value == null)){
} else {
cljs.core.async.impl.protocols.put_BANG_.call(null,c,value,cljs.core.async.impl.ioc_helpers.fn_handler.call(null,((function (c){
return (function (){
return null;
});})(c))
));
}
cljs.core.async.impl.protocols.close_BANG_.call(null,c);
return c;
});
/**
* @constructor
* @implements {cljs.core.IRecord}
* @implements {cljs.core.IKVReduce}
* @implements {cljs.core.IEquiv}
* @implements {cljs.core.IHash}
* @implements {cljs.core.ICollection}
* @implements {cljs.core.ICounted}
* @implements {cljs.core.ISeqable}
* @implements {cljs.core.IMeta}
* @implements {cljs.core.ICloneable}
* @implements {cljs.core.IPrintWithWriter}
* @implements {cljs.core.IIterable}
* @implements {cljs.core.IWithMeta}
* @implements {cljs.core.IAssociative}
* @implements {cljs.core.IMap}
* @implements {cljs.core.ILookup}
*/
cljs.core.async.impl.ioc_helpers.ExceptionFrame = (function (catch_block,catch_exception,finally_block,continue_block,prev,__meta,__extmap,__hash){
this.catch_block = catch_block;
this.catch_exception = catch_exception;
this.finally_block = finally_block;
this.continue_block = continue_block;
this.prev = prev;
this.__meta = __meta;
this.__extmap = __extmap;
this.__hash = __hash;
this.cljs$lang$protocol_mask$partition0$ = 2230716170;
this.cljs$lang$protocol_mask$partition1$ = 139264;
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ILookup$_lookup$arity$2 = (function (this__4385__auto__,k__4386__auto__){
var self__ = this;
var this__4385__auto____$1 = this;
return this__4385__auto____$1.cljs$core$ILookup$_lookup$arity$3(null,k__4386__auto__,null);
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ILookup$_lookup$arity$3 = (function (this__4387__auto__,k22884,else__4388__auto__){
var self__ = this;
var this__4387__auto____$1 = this;
var G__22888 = k22884;
var G__22888__$1 = (((G__22888 instanceof cljs.core.Keyword))?G__22888.fqn:null);
switch (G__22888__$1) {
case "catch-block":
return self__.catch_block;
break;
case "catch-exception":
return self__.catch_exception;
break;
case "finally-block":
return self__.finally_block;
break;
case "continue-block":
return self__.continue_block;
break;
case "prev":
return self__.prev;
break;
default:
return cljs.core.get.call(null,self__.__extmap,k22884,else__4388__auto__);
}
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IKVReduce$_kv_reduce$arity$3 = (function (this__4404__auto__,f__4405__auto__,init__4406__auto__){
var self__ = this;
var this__4404__auto____$1 = this;
return cljs.core.reduce.call(null,((function (this__4404__auto____$1){
return (function (ret__4407__auto__,p__22889){
var vec__22890 = p__22889;
var k__4408__auto__ = cljs.core.nth.call(null,vec__22890,(0),null);
var v__4409__auto__ = cljs.core.nth.call(null,vec__22890,(1),null);
return f__4405__auto__.call(null,ret__4407__auto__,k__4408__auto__,v__4409__auto__);
});})(this__4404__auto____$1))
,init__4406__auto__,this__4404__auto____$1);
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (this__4399__auto__,writer__4400__auto__,opts__4401__auto__){
var self__ = this;
var this__4399__auto____$1 = this;
var pr_pair__4402__auto__ = ((function (this__4399__auto____$1){
return (function (keyval__4403__auto__){
return cljs.core.pr_sequential_writer.call(null,writer__4400__auto__,cljs.core.pr_writer,""," ","",opts__4401__auto__,keyval__4403__auto__);
});})(this__4399__auto____$1))
;
return cljs.core.pr_sequential_writer.call(null,writer__4400__auto__,pr_pair__4402__auto__,"#cljs.core.async.impl.ioc-helpers.ExceptionFrame{",", ","}",opts__4401__auto__,cljs.core.concat.call(null,new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),self__.catch_block],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),self__.catch_exception],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"finally-block","finally-block",832982472),self__.finally_block],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),self__.continue_block],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[new cljs.core.Keyword(null,"prev","prev",-1597069226),self__.prev],null))], null),self__.__extmap));
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IIterable$_iterator$arity$1 = (function (G__22883){
var self__ = this;
var G__22883__$1 = this;
return (new cljs.core.RecordIter((0),G__22883__$1,5,new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),new cljs.core.Keyword(null,"finally-block","finally-block",832982472),new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),new cljs.core.Keyword(null,"prev","prev",-1597069226)], null),(cljs.core.truth_(self__.__extmap)?cljs.core._iterator.call(null,self__.__extmap):cljs.core.nil_iter.call(null))));
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IMeta$_meta$arity$1 = (function (this__4383__auto__){
var self__ = this;
var this__4383__auto____$1 = this;
return self__.__meta;
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ICloneable$_clone$arity$1 = (function (this__4380__auto__){
var self__ = this;
var this__4380__auto____$1 = this;
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,self__.__extmap,self__.__hash));
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ICounted$_count$arity$1 = (function (this__4389__auto__){
var self__ = this;
var this__4389__auto____$1 = this;
return (5 + cljs.core.count.call(null,self__.__extmap));
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IHash$_hash$arity$1 = (function (this__4381__auto__){
var self__ = this;
var this__4381__auto____$1 = this;
var h__4243__auto__ = self__.__hash;
if((!((h__4243__auto__ == null)))){
return h__4243__auto__;
} else {
var h__4243__auto____$1 = ((function (h__4243__auto__,this__4381__auto____$1){
return (function (coll__4382__auto__){
return (846900531 ^ cljs.core.hash_unordered_coll.call(null,coll__4382__auto__));
});})(h__4243__auto__,this__4381__auto____$1))
.call(null,this__4381__auto____$1);
self__.__hash = h__4243__auto____$1;
return h__4243__auto____$1;
}
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (this22885,other22886){
var self__ = this;
var this22885__$1 = this;
return (((!((other22886 == null)))) && ((this22885__$1.constructor === other22886.constructor)) && (cljs.core._EQ_.call(null,this22885__$1.catch_block,other22886.catch_block)) && (cljs.core._EQ_.call(null,this22885__$1.catch_exception,other22886.catch_exception)) && (cljs.core._EQ_.call(null,this22885__$1.finally_block,other22886.finally_block)) && (cljs.core._EQ_.call(null,this22885__$1.continue_block,other22886.continue_block)) && (cljs.core._EQ_.call(null,this22885__$1.prev,other22886.prev)) && (cljs.core._EQ_.call(null,this22885__$1.__extmap,other22886.__extmap)));
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IMap$_dissoc$arity$2 = (function (this__4394__auto__,k__4395__auto__){
var self__ = this;
var this__4394__auto____$1 = this;
if(cljs.core.contains_QMARK_.call(null,new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"finally-block","finally-block",832982472),null,new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),null,new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),null,new cljs.core.Keyword(null,"prev","prev",-1597069226),null,new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),null], null), null),k__4395__auto__)){
return cljs.core.dissoc.call(null,cljs.core._with_meta.call(null,cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,this__4394__auto____$1),self__.__meta),k__4395__auto__);
} else {
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,cljs.core.not_empty.call(null,cljs.core.dissoc.call(null,self__.__extmap,k__4395__auto__)),null));
}
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IAssociative$_assoc$arity$3 = (function (this__4392__auto__,k__4393__auto__,G__22883){
var self__ = this;
var this__4392__auto____$1 = this;
var pred__22893 = cljs.core.keyword_identical_QMARK_;
var expr__22894 = k__4393__auto__;
if(cljs.core.truth_(pred__22893.call(null,new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),expr__22894))){
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(G__22883,self__.catch_exception,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,self__.__extmap,null));
} else {
if(cljs.core.truth_(pred__22893.call(null,new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),expr__22894))){
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,G__22883,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,self__.__extmap,null));
} else {
if(cljs.core.truth_(pred__22893.call(null,new cljs.core.Keyword(null,"finally-block","finally-block",832982472),expr__22894))){
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,G__22883,self__.continue_block,self__.prev,self__.__meta,self__.__extmap,null));
} else {
if(cljs.core.truth_(pred__22893.call(null,new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),expr__22894))){
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,G__22883,self__.prev,self__.__meta,self__.__extmap,null));
} else {
if(cljs.core.truth_(pred__22893.call(null,new cljs.core.Keyword(null,"prev","prev",-1597069226),expr__22894))){
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,self__.continue_block,G__22883,self__.__meta,self__.__extmap,null));
} else {
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,self__.continue_block,self__.prev,self__.__meta,cljs.core.assoc.call(null,self__.__extmap,k__4393__auto__,G__22883),null));
}
}
}
}
}
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ISeqable$_seq$arity$1 = (function (this__4397__auto__){
var self__ = this;
var this__4397__auto____$1 = this;
return cljs.core.seq.call(null,cljs.core.concat.call(null,new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.MapEntry(new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),self__.catch_block,null)),(new cljs.core.MapEntry(new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),self__.catch_exception,null)),(new cljs.core.MapEntry(new cljs.core.Keyword(null,"finally-block","finally-block",832982472),self__.finally_block,null)),(new cljs.core.MapEntry(new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),self__.continue_block,null)),(new cljs.core.MapEntry(new cljs.core.Keyword(null,"prev","prev",-1597069226),self__.prev,null))], null),self__.__extmap));
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (this__4384__auto__,G__22883){
var self__ = this;
var this__4384__auto____$1 = this;
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(self__.catch_block,self__.catch_exception,self__.finally_block,self__.continue_block,self__.prev,G__22883,self__.__extmap,self__.__hash));
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.prototype.cljs$core$ICollection$_conj$arity$2 = (function (this__4390__auto__,entry__4391__auto__){
var self__ = this;
var this__4390__auto____$1 = this;
if(cljs.core.vector_QMARK_.call(null,entry__4391__auto__)){
return this__4390__auto____$1.cljs$core$IAssociative$_assoc$arity$3(null,cljs.core._nth.call(null,entry__4391__auto__,(0)),cljs.core._nth.call(null,entry__4391__auto__,(1)));
} else {
return cljs.core.reduce.call(null,cljs.core._conj,this__4390__auto____$1,entry__4391__auto__);
}
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.getBasis = (function (){
return new cljs.core.PersistentVector(null, 5, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"catch-block","catch-block",-1479223021,null),cljs.core.with_meta(new cljs.core.Symbol(null,"catch-exception","catch-exception",-356775268,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"tag","tag",-1290361223),new cljs.core.Symbol(null,"Class","Class",2064526977,null)], null)),new cljs.core.Symbol(null,"finally-block","finally-block",-1821453297,null),new cljs.core.Symbol(null,"continue-block","continue-block",-211516323,null),new cljs.core.Symbol(null,"prev","prev",43462301,null)], null);
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.cljs$lang$type = true;
cljs.core.async.impl.ioc_helpers.ExceptionFrame.cljs$lang$ctorPrSeq = (function (this__4428__auto__){
return (new cljs.core.List(null,"cljs.core.async.impl.ioc-helpers/ExceptionFrame",null,(1),null));
});
cljs.core.async.impl.ioc_helpers.ExceptionFrame.cljs$lang$ctorPrWriter = (function (this__4428__auto__,writer__4429__auto__){
return cljs.core._write.call(null,writer__4429__auto__,"cljs.core.async.impl.ioc-helpers/ExceptionFrame");
});
/**
* Positional factory function for cljs.core.async.impl.ioc-helpers/ExceptionFrame.
*/
cljs.core.async.impl.ioc_helpers.__GT_ExceptionFrame = (function cljs$core$async$impl$ioc_helpers$__GT_ExceptionFrame(catch_block,catch_exception,finally_block,continue_block,prev){
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(catch_block,catch_exception,finally_block,continue_block,prev,null,null,null));
});
/**
* Factory function for cljs.core.async.impl.ioc-helpers/ExceptionFrame, taking a map of keywords to field values.
*/
cljs.core.async.impl.ioc_helpers.map__GT_ExceptionFrame = (function cljs$core$async$impl$ioc_helpers$map__GT_ExceptionFrame(G__22887){
var extmap__4424__auto__ = (function (){var G__22896 = cljs.core.dissoc.call(null,G__22887,new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),new cljs.core.Keyword(null,"finally-block","finally-block",832982472),new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850),new cljs.core.Keyword(null,"prev","prev",-1597069226));
if(cljs.core.record_QMARK_.call(null,G__22887)){
return cljs.core.into.call(null,cljs.core.PersistentArrayMap.EMPTY,G__22896);
} else {
return G__22896;
}
})();
return (new cljs.core.async.impl.ioc_helpers.ExceptionFrame(new cljs.core.Keyword(null,"catch-block","catch-block",1175212748).cljs$core$IFn$_invoke$arity$1(G__22887),new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795).cljs$core$IFn$_invoke$arity$1(G__22887),new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(G__22887),new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850).cljs$core$IFn$_invoke$arity$1(G__22887),new cljs.core.Keyword(null,"prev","prev",-1597069226).cljs$core$IFn$_invoke$arity$1(G__22887),null,cljs.core.not_empty.call(null,extmap__4424__auto__),null));
});
cljs.core.async.impl.ioc_helpers.add_exception_frame = (function cljs$core$async$impl$ioc_helpers$add_exception_frame(state,catch_block,catch_exception,finally_block,continue_block){
var statearr_22898 = state;
(statearr_22898[(4)] = cljs.core.async.impl.ioc_helpers.__GT_ExceptionFrame.call(null,catch_block,catch_exception,finally_block,continue_block,cljs.core.async.impl.ioc_helpers.aget_object.call(null,state,(4))));
return statearr_22898;
});
cljs.core.async.impl.ioc_helpers.process_exception = (function cljs$core$async$impl$ioc_helpers$process_exception(state){
while(true){
var exception_frame = cljs.core.async.impl.ioc_helpers.aget_object.call(null,state,(4));
var catch_block = new cljs.core.Keyword(null,"catch-block","catch-block",1175212748).cljs$core$IFn$_invoke$arity$1(exception_frame);
var catch_exception = new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795).cljs$core$IFn$_invoke$arity$1(exception_frame);
var exception = cljs.core.async.impl.ioc_helpers.aget_object.call(null,state,(5));
if(cljs.core.truth_((function (){var and__4120__auto__ = exception;
if(cljs.core.truth_(and__4120__auto__)){
return cljs.core.not.call(null,exception_frame);
} else {
return and__4120__auto__;
}
})())){
throw exception;
} else {
if(cljs.core.truth_((function (){var and__4120__auto__ = exception;
if(cljs.core.truth_(and__4120__auto__)){
var and__4120__auto____$1 = catch_block;
if(cljs.core.truth_(and__4120__auto____$1)){
return ((cljs.core._EQ_.call(null,new cljs.core.Keyword(null,"default","default",-1987822328),catch_exception)) || ((exception instanceof catch_exception)));
} else {
return and__4120__auto____$1;
}
} else {
return and__4120__auto__;
}
})())){
var statearr_22899 = state;
(statearr_22899[(1)] = catch_block);
(statearr_22899[(2)] = exception);
(statearr_22899[(5)] = null);
(statearr_22899[(4)] = cljs.core.assoc.call(null,exception_frame,new cljs.core.Keyword(null,"catch-block","catch-block",1175212748),null,new cljs.core.Keyword(null,"catch-exception","catch-exception",-1997306795),null));
return statearr_22899;
} else {
if(cljs.core.truth_((function (){var and__4120__auto__ = exception;
if(cljs.core.truth_(and__4120__auto__)){
return ((cljs.core.not.call(null,catch_block)) && (cljs.core.not.call(null,new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame))));
} else {
return and__4120__auto__;
}
})())){
var statearr_22900_22904 = state;
(statearr_22900_22904[(4)] = new cljs.core.Keyword(null,"prev","prev",-1597069226).cljs$core$IFn$_invoke$arity$1(exception_frame));
var G__22905 = state;
state = G__22905;
continue;
} else {
if(cljs.core.truth_((function (){var and__4120__auto__ = exception;
if(cljs.core.truth_(and__4120__auto__)){
var and__4120__auto____$1 = cljs.core.not.call(null,catch_block);
if(and__4120__auto____$1){
return new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame);
} else {
return and__4120__auto____$1;
}
} else {
return and__4120__auto__;
}
})())){
var statearr_22901 = state;
(statearr_22901[(1)] = new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame));
(statearr_22901[(4)] = cljs.core.assoc.call(null,exception_frame,new cljs.core.Keyword(null,"finally-block","finally-block",832982472),null));
return statearr_22901;
} else {
if(cljs.core.truth_((function (){var and__4120__auto__ = cljs.core.not.call(null,exception);
if(and__4120__auto__){
return new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame);
} else {
return and__4120__auto__;
}
})())){
var statearr_22902 = state;
(statearr_22902[(1)] = new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame));
(statearr_22902[(4)] = cljs.core.assoc.call(null,exception_frame,new cljs.core.Keyword(null,"finally-block","finally-block",832982472),null));
return statearr_22902;
} else {
if(((cljs.core.not.call(null,exception)) && (cljs.core.not.call(null,new cljs.core.Keyword(null,"finally-block","finally-block",832982472).cljs$core$IFn$_invoke$arity$1(exception_frame))))){
var statearr_22903 = state;
(statearr_22903[(1)] = new cljs.core.Keyword(null,"continue-block","continue-block",-1852047850).cljs$core$IFn$_invoke$arity$1(exception_frame));
(statearr_22903[(4)] = new cljs.core.Keyword(null,"prev","prev",-1597069226).cljs$core$IFn$_invoke$arity$1(exception_frame));
return statearr_22903;
} else {
throw (new Error("No matching clause"));
}
}
}
}
}
}
break;
}
});
//# sourceMappingURL=ioc_helpers.js.map?rel=1582560147675

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,43 @@
;; Copyright (c) Rich Hickey and contributors. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns cljs.core.async.impl.protocols)
(def ^:const MAX-QUEUE-SIZE 1024)
(defprotocol ReadPort
(take! [port fn1-handler] "derefable val if taken, nil if take was enqueued"))
(defprotocol WritePort
(put! [port val fn1-handler] "derefable boolean (false if already closed) if handled, nil if put was enqueued.
Must throw on nil val."))
(defprotocol Channel
(close! [chan])
(closed? [chan]))
(defprotocol Handler
(active? [h] "returns true if has callback. Must work w/o lock")
(blockable? [h] "returns true if this handler may be blocked, otherwise it must not block")
#_(lock-id [h] "a unique id for lock acquisition order, 0 if no lock")
(commit [h] "commit to fulfilling its end of the transfer, returns cb. Must be called within lock"))
(defprotocol Buffer
(full? [b] "returns true if buffer cannot accept put")
(remove! [b] "remove and return next item from buffer, called under chan mutex")
(add!* [b itm] "if room, add item to the buffer, returns b, called under chan mutex")
(close-buf! [b] "called on chan closed under chan mutex, return ignored"))
(defn add!
([b] b)
([b itm]
(assert (not (nil? itm)))
(add!* b itm)))
;; Defines a buffer that will never block (return true to full?)
(defprotocol UnblockingBuffer)

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,311 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('cljs.core.async.impl.protocols');
goog.require('cljs.core');
cljs.core.async.impl.protocols.MAX_QUEUE_SIZE = (1024);
/**
* @interface
*/
cljs.core.async.impl.protocols.ReadPort = function(){};
/**
* derefable val if taken, nil if take was enqueued
*/
cljs.core.async.impl.protocols.take_BANG_ = (function cljs$core$async$impl$protocols$take_BANG_(port,fn1_handler){
if((((!((port == null)))) && ((!((port.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2 == null)))))){
return port.cljs$core$async$impl$protocols$ReadPort$take_BANG_$arity$2(port,fn1_handler);
} else {
var x__4433__auto__ = (((port == null))?null:port);
var m__4434__auto__ = (cljs.core.async.impl.protocols.take_BANG_[goog.typeOf(x__4433__auto__)]);
if((!((m__4434__auto__ == null)))){
return m__4434__auto__.call(null,port,fn1_handler);
} else {
var m__4431__auto__ = (cljs.core.async.impl.protocols.take_BANG_["_"]);
if((!((m__4431__auto__ == null)))){
return m__4431__auto__.call(null,port,fn1_handler);
} else {
throw cljs.core.missing_protocol.call(null,"ReadPort.take!",port);
}
}
}
});
/**
* @interface
*/
cljs.core.async.impl.protocols.WritePort = function(){};
/**
* derefable boolean (false if already closed) if handled, nil if put was enqueued.
* Must throw on nil val.
*/
cljs.core.async.impl.protocols.put_BANG_ = (function cljs$core$async$impl$protocols$put_BANG_(port,val,fn1_handler){
if((((!((port == null)))) && ((!((port.cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3 == null)))))){
return port.cljs$core$async$impl$protocols$WritePort$put_BANG_$arity$3(port,val,fn1_handler);
} else {
var x__4433__auto__ = (((port == null))?null:port);
var m__4434__auto__ = (cljs.core.async.impl.protocols.put_BANG_[goog.typeOf(x__4433__auto__)]);
if((!((m__4434__auto__ == null)))){
return m__4434__auto__.call(null,port,val,fn1_handler);
} else {
var m__4431__auto__ = (cljs.core.async.impl.protocols.put_BANG_["_"]);
if((!((m__4431__auto__ == null)))){
return m__4431__auto__.call(null,port,val,fn1_handler);
} else {
throw cljs.core.missing_protocol.call(null,"WritePort.put!",port);
}
}
}
});
/**
* @interface
*/
cljs.core.async.impl.protocols.Channel = function(){};
cljs.core.async.impl.protocols.close_BANG_ = (function cljs$core$async$impl$protocols$close_BANG_(chan){
if((((!((chan == null)))) && ((!((chan.cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1 == null)))))){
return chan.cljs$core$async$impl$protocols$Channel$close_BANG_$arity$1(chan);
} else {
var x__4433__auto__ = (((chan == null))?null:chan);
var m__4434__auto__ = (cljs.core.async.impl.protocols.close_BANG_[goog.typeOf(x__4433__auto__)]);
if((!((m__4434__auto__ == null)))){
return m__4434__auto__.call(null,chan);
} else {
var m__4431__auto__ = (cljs.core.async.impl.protocols.close_BANG_["_"]);
if((!((m__4431__auto__ == null)))){
return m__4431__auto__.call(null,chan);
} else {
throw cljs.core.missing_protocol.call(null,"Channel.close!",chan);
}
}
}
});
cljs.core.async.impl.protocols.closed_QMARK_ = (function cljs$core$async$impl$protocols$closed_QMARK_(chan){
if((((!((chan == null)))) && ((!((chan.cljs$core$async$impl$protocols$Channel$closed_QMARK_$arity$1 == null)))))){
return chan.cljs$core$async$impl$protocols$Channel$closed_QMARK_$arity$1(chan);
} else {
var x__4433__auto__ = (((chan == null))?null:chan);
var m__4434__auto__ = (cljs.core.async.impl.protocols.closed_QMARK_[goog.typeOf(x__4433__auto__)]);
if((!((m__4434__auto__ == null)))){
return m__4434__auto__.call(null,chan);
} else {
var m__4431__auto__ = (cljs.core.async.impl.protocols.closed_QMARK_["_"]);
if((!((m__4431__auto__ == null)))){
return m__4431__auto__.call(null,chan);
} else {
throw cljs.core.missing_protocol.call(null,"Channel.closed?",chan);
}
}
}
});
/**
* @interface
*/
cljs.core.async.impl.protocols.Handler = function(){};
/**
* returns true if has callback. Must work w/o lock
*/
cljs.core.async.impl.protocols.active_QMARK_ = (function cljs$core$async$impl$protocols$active_QMARK_(h){
if((((!((h == null)))) && ((!((h.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1 == null)))))){
return h.cljs$core$async$impl$protocols$Handler$active_QMARK_$arity$1(h);
} else {
var x__4433__auto__ = (((h == null))?null:h);
var m__4434__auto__ = (cljs.core.async.impl.protocols.active_QMARK_[goog.typeOf(x__4433__auto__)]);
if((!((m__4434__auto__ == null)))){
return m__4434__auto__.call(null,h);
} else {
var m__4431__auto__ = (cljs.core.async.impl.protocols.active_QMARK_["_"]);
if((!((m__4431__auto__ == null)))){
return m__4431__auto__.call(null,h);
} else {
throw cljs.core.missing_protocol.call(null,"Handler.active?",h);
}
}
}
});
/**
* returns true if this handler may be blocked, otherwise it must not block
*/
cljs.core.async.impl.protocols.blockable_QMARK_ = (function cljs$core$async$impl$protocols$blockable_QMARK_(h){
if((((!((h == null)))) && ((!((h.cljs$core$async$impl$protocols$Handler$blockable_QMARK_$arity$1 == null)))))){
return h.cljs$core$async$impl$protocols$Handler$blockable_QMARK_$arity$1(h);
} else {
var x__4433__auto__ = (((h == null))?null:h);
var m__4434__auto__ = (cljs.core.async.impl.protocols.blockable_QMARK_[goog.typeOf(x__4433__auto__)]);
if((!((m__4434__auto__ == null)))){
return m__4434__auto__.call(null,h);
} else {
var m__4431__auto__ = (cljs.core.async.impl.protocols.blockable_QMARK_["_"]);
if((!((m__4431__auto__ == null)))){
return m__4431__auto__.call(null,h);
} else {
throw cljs.core.missing_protocol.call(null,"Handler.blockable?",h);
}
}
}
});
/**
* commit to fulfilling its end of the transfer, returns cb. Must be called within lock
*/
cljs.core.async.impl.protocols.commit = (function cljs$core$async$impl$protocols$commit(h){
if((((!((h == null)))) && ((!((h.cljs$core$async$impl$protocols$Handler$commit$arity$1 == null)))))){
return h.cljs$core$async$impl$protocols$Handler$commit$arity$1(h);
} else {
var x__4433__auto__ = (((h == null))?null:h);
var m__4434__auto__ = (cljs.core.async.impl.protocols.commit[goog.typeOf(x__4433__auto__)]);
if((!((m__4434__auto__ == null)))){
return m__4434__auto__.call(null,h);
} else {
var m__4431__auto__ = (cljs.core.async.impl.protocols.commit["_"]);
if((!((m__4431__auto__ == null)))){
return m__4431__auto__.call(null,h);
} else {
throw cljs.core.missing_protocol.call(null,"Handler.commit",h);
}
}
}
});
/**
* @interface
*/
cljs.core.async.impl.protocols.Buffer = function(){};
/**
* returns true if buffer cannot accept put
*/
cljs.core.async.impl.protocols.full_QMARK_ = (function cljs$core$async$impl$protocols$full_QMARK_(b){
if((((!((b == null)))) && ((!((b.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1 == null)))))){
return b.cljs$core$async$impl$protocols$Buffer$full_QMARK_$arity$1(b);
} else {
var x__4433__auto__ = (((b == null))?null:b);
var m__4434__auto__ = (cljs.core.async.impl.protocols.full_QMARK_[goog.typeOf(x__4433__auto__)]);
if((!((m__4434__auto__ == null)))){
return m__4434__auto__.call(null,b);
} else {
var m__4431__auto__ = (cljs.core.async.impl.protocols.full_QMARK_["_"]);
if((!((m__4431__auto__ == null)))){
return m__4431__auto__.call(null,b);
} else {
throw cljs.core.missing_protocol.call(null,"Buffer.full?",b);
}
}
}
});
/**
* remove and return next item from buffer, called under chan mutex
*/
cljs.core.async.impl.protocols.remove_BANG_ = (function cljs$core$async$impl$protocols$remove_BANG_(b){
if((((!((b == null)))) && ((!((b.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1 == null)))))){
return b.cljs$core$async$impl$protocols$Buffer$remove_BANG_$arity$1(b);
} else {
var x__4433__auto__ = (((b == null))?null:b);
var m__4434__auto__ = (cljs.core.async.impl.protocols.remove_BANG_[goog.typeOf(x__4433__auto__)]);
if((!((m__4434__auto__ == null)))){
return m__4434__auto__.call(null,b);
} else {
var m__4431__auto__ = (cljs.core.async.impl.protocols.remove_BANG_["_"]);
if((!((m__4431__auto__ == null)))){
return m__4431__auto__.call(null,b);
} else {
throw cljs.core.missing_protocol.call(null,"Buffer.remove!",b);
}
}
}
});
/**
* if room, add item to the buffer, returns b, called under chan mutex
*/
cljs.core.async.impl.protocols.add_BANG__STAR_ = (function cljs$core$async$impl$protocols$add_BANG__STAR_(b,itm){
if((((!((b == null)))) && ((!((b.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2 == null)))))){
return b.cljs$core$async$impl$protocols$Buffer$add_BANG__STAR_$arity$2(b,itm);
} else {
var x__4433__auto__ = (((b == null))?null:b);
var m__4434__auto__ = (cljs.core.async.impl.protocols.add_BANG__STAR_[goog.typeOf(x__4433__auto__)]);
if((!((m__4434__auto__ == null)))){
return m__4434__auto__.call(null,b,itm);
} else {
var m__4431__auto__ = (cljs.core.async.impl.protocols.add_BANG__STAR_["_"]);
if((!((m__4431__auto__ == null)))){
return m__4431__auto__.call(null,b,itm);
} else {
throw cljs.core.missing_protocol.call(null,"Buffer.add!*",b);
}
}
}
});
/**
* called on chan closed under chan mutex, return ignored
*/
cljs.core.async.impl.protocols.close_buf_BANG_ = (function cljs$core$async$impl$protocols$close_buf_BANG_(b){
if((((!((b == null)))) && ((!((b.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1 == null)))))){
return b.cljs$core$async$impl$protocols$Buffer$close_buf_BANG_$arity$1(b);
} else {
var x__4433__auto__ = (((b == null))?null:b);
var m__4434__auto__ = (cljs.core.async.impl.protocols.close_buf_BANG_[goog.typeOf(x__4433__auto__)]);
if((!((m__4434__auto__ == null)))){
return m__4434__auto__.call(null,b);
} else {
var m__4431__auto__ = (cljs.core.async.impl.protocols.close_buf_BANG_["_"]);
if((!((m__4431__auto__ == null)))){
return m__4431__auto__.call(null,b);
} else {
throw cljs.core.missing_protocol.call(null,"Buffer.close-buf!",b);
}
}
}
});
cljs.core.async.impl.protocols.add_BANG_ = (function cljs$core$async$impl$protocols$add_BANG_(var_args){
var G__20833 = arguments.length;
switch (G__20833) {
case 1:
return cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$1 = (function (b){
return b;
});
cljs.core.async.impl.protocols.add_BANG_.cljs$core$IFn$_invoke$arity$2 = (function (b,itm){
if((!((itm == null)))){
} else {
throw (new Error("Assert failed: (not (nil? itm))"));
}
return cljs.core.async.impl.protocols.add_BANG__STAR_.call(null,b,itm);
});
cljs.core.async.impl.protocols.add_BANG_.cljs$lang$maxFixedArity = 2;
/**
* @interface
*/
cljs.core.async.impl.protocols.UnblockingBuffer = function(){};
//# sourceMappingURL=protocols.js.map?rel=1582560146422

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,172 @@
;; Copyright (c) Rich Hickey and contributors. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns cljs.core.async.impl.timers
(:require [cljs.core.async.impl.protocols :as impl]
[cljs.core.async.impl.channels :as channels]
[cljs.core.async.impl.dispatch :as dispatch]))
(def MAX_LEVEL 15) ;; 16 levels
(def P (/ 1 2))
(defn random-level
([] (random-level 0))
([level]
(if (and (< (.random js/Math) P)
(< level MAX_LEVEL))
(recur (inc level))
level)))
(deftype SkipListNode [key ^:mutable val forward]
ISeqable
(-seq [coll]
(list key val))
IPrintWithWriter
(-pr-writer [coll writer opts]
(pr-sequential-writer writer pr-writer "[" " " "]" opts coll)))
(defn skip-list-node
([level] (skip-list-node nil nil level))
([k v level]
(let [arr (make-array (inc level))]
(loop [i 0]
(when (< i (alength arr))
(aset arr i nil)
(recur (inc i))))
(SkipListNode. k v arr))))
(defn least-greater-node
([x k level] (least-greater-node x k level nil))
([x k level update]
(if-not (neg? level)
(let [x (loop [x x]
(if-let [x' (when (< level (alength (.-forward x)))
(aget (.-forward x) level))]
(if (< (.-key x') k)
(recur x')
x)
x))]
(when-not (nil? update)
(aset update level x))
(recur x k (dec level) update))
x)))
(deftype SkipList [header ^:mutable level]
Object
(put [coll k v]
(let [update (make-array MAX_LEVEL)
x (least-greater-node header k level update)
x (aget (.-forward x) 0)]
(if (and (not (nil? x)) (== (.-key x) k))
(set! (.-val x) v)
(let [new-level (random-level)]
(when (> new-level level)
(loop [i (inc level)]
(when (<= i (inc new-level))
(aset update i header)
(recur (inc i))))
(set! level new-level))
(let [x (skip-list-node k v (make-array new-level))]
(loop [i 0]
(when (<= i level)
(let [links (.-forward (aget update i))]
(aset (.-forward x) i (aget links i))
(aset links i x)))))))))
(remove [coll k]
(let [update (make-array MAX_LEVEL)
x (least-greater-node header k level update)
x (when-not (zero? (alength (.-forward x)))
(aget (.-forward x) 0))]
(when (and (not (nil? x)) (== (.-key x) k))
(loop [i 0]
(when (<= i level)
(let [links (.-forward (aget update i))]
(if (identical? x (when (< i (alength links))
(aget links i)))
(do
(aset links i (aget (.-forward x) i))
(recur (inc i)))
(recur (inc i))))))
(while (and (< 0 level (alength (.-forward header)))
(nil? (aget (.-forward header) level)))
(set! level (dec level))))))
(ceilingEntry [coll k]
(loop [x header level level]
(if-not (neg? level)
(let [nx (loop [x x]
(let [x' (when (< level (alength (.-forward x)))
(aget (.-forward x) level))]
(when-not (nil? x')
(if (>= (.-key x') k)
x'
(recur x')))))]
(if-not (nil? nx)
(recur nx (dec level))
(recur x (dec level))))
(when-not (identical? x header)
x))))
(floorEntry [coll k]
(loop [x header level level]
(if-not (neg? level)
(let [nx (loop [x x]
(let [x' (when (< level (alength (.-forward x)))
(aget (.-forward x) level))]
(if-not (nil? x')
(if (> (.-key x') k)
x
(recur x'))
(when (zero? level)
x))))]
(if nx
(recur nx (dec level))
(recur x (dec level))))
(when-not (identical? x header)
x))))
ISeqable
(-seq [coll]
(letfn [(iter [node]
(lazy-seq
(when-not (nil? node)
(cons [(.-key node) (.-val node)]
(iter (aget (.-forward node) 0))))))]
(iter (aget (.-forward header) 0))))
IPrintWithWriter
(-pr-writer [coll writer opts]
(let [pr-pair (fn [keyval]
(pr-sequential-writer writer pr-writer "" " " "" opts keyval))]
(pr-sequential-writer writer pr-pair "{" ", " "}" opts coll))))
(defn skip-list []
(SkipList. (skip-list-node 0) 0))
(def timeouts-map (skip-list))
(def TIMEOUT_RESOLUTION_MS 10)
(defn timeout
"returns a channel that will close after msecs"
[msecs]
(let [timeout (+ (.valueOf (js/Date.)) msecs)
me (.ceilingEntry timeouts-map timeout)]
(or (when (and me (< (.-key me) (+ timeout TIMEOUT_RESOLUTION_MS)))
(.-val me))
(let [timeout-channel (channels/chan nil)]
(.put timeouts-map timeout timeout-channel)
(dispatch/queue-delay
(fn []
(.remove timeouts-map timeout)
(impl/close! timeout-channel))
msecs)
timeout-channel))))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,479 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('cljs.core.async.impl.timers');
goog.require('cljs.core');
goog.require('cljs.core.async.impl.protocols');
goog.require('cljs.core.async.impl.channels');
goog.require('cljs.core.async.impl.dispatch');
cljs.core.async.impl.timers.MAX_LEVEL = (15);
cljs.core.async.impl.timers.P = ((1) / (2));
cljs.core.async.impl.timers.random_level = (function cljs$core$async$impl$timers$random_level(var_args){
var G__22909 = arguments.length;
switch (G__22909) {
case 0:
return cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$0();
break;
case 1:
return cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$0 = (function (){
return cljs.core.async.impl.timers.random_level.call(null,(0));
});
cljs.core.async.impl.timers.random_level.cljs$core$IFn$_invoke$arity$1 = (function (level){
while(true){
if((((Math.random() < cljs.core.async.impl.timers.P)) && ((level < cljs.core.async.impl.timers.MAX_LEVEL)))){
var G__22911 = (level + (1));
level = G__22911;
continue;
} else {
return level;
}
break;
}
});
cljs.core.async.impl.timers.random_level.cljs$lang$maxFixedArity = 1;
/**
* @constructor
* @implements {cljs.core.ISeqable}
* @implements {cljs.core.IPrintWithWriter}
*/
cljs.core.async.impl.timers.SkipListNode = (function (key,val,forward){
this.key = key;
this.val = val;
this.forward = forward;
this.cljs$lang$protocol_mask$partition0$ = 2155872256;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
cljs.core.async.impl.timers.SkipListNode.prototype.cljs$core$ISeqable$_seq$arity$1 = (function (coll){
var self__ = this;
var coll__$1 = this;
return (new cljs.core.List(null,self__.key,(new cljs.core.List(null,self__.val,null,(1),null)),(2),null));
});
cljs.core.async.impl.timers.SkipListNode.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (coll,writer,opts){
var self__ = this;
var coll__$1 = this;
return cljs.core.pr_sequential_writer.call(null,writer,cljs.core.pr_writer,"["," ","]",opts,coll__$1);
});
cljs.core.async.impl.timers.SkipListNode.getBasis = (function (){
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"key","key",124488940,null),cljs.core.with_meta(new cljs.core.Symbol(null,"val","val",1769233139,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null)),new cljs.core.Symbol(null,"forward","forward",1083186224,null)], null);
});
cljs.core.async.impl.timers.SkipListNode.cljs$lang$type = true;
cljs.core.async.impl.timers.SkipListNode.cljs$lang$ctorStr = "cljs.core.async.impl.timers/SkipListNode";
cljs.core.async.impl.timers.SkipListNode.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.timers/SkipListNode");
});
/**
* Positional factory function for cljs.core.async.impl.timers/SkipListNode.
*/
cljs.core.async.impl.timers.__GT_SkipListNode = (function cljs$core$async$impl$timers$__GT_SkipListNode(key,val,forward){
return (new cljs.core.async.impl.timers.SkipListNode(key,val,forward));
});
cljs.core.async.impl.timers.skip_list_node = (function cljs$core$async$impl$timers$skip_list_node(var_args){
var G__22913 = arguments.length;
switch (G__22913) {
case 1:
return cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 3:
return cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$1 = (function (level){
return cljs.core.async.impl.timers.skip_list_node.call(null,null,null,level);
});
cljs.core.async.impl.timers.skip_list_node.cljs$core$IFn$_invoke$arity$3 = (function (k,v,level){
var arr = (new Array((level + (1))));
var i_22915 = (0);
while(true){
if((i_22915 < arr.length)){
(arr[i_22915] = null);
var G__22916 = (i_22915 + (1));
i_22915 = G__22916;
continue;
} else {
}
break;
}
return (new cljs.core.async.impl.timers.SkipListNode(k,v,arr));
});
cljs.core.async.impl.timers.skip_list_node.cljs$lang$maxFixedArity = 3;
cljs.core.async.impl.timers.least_greater_node = (function cljs$core$async$impl$timers$least_greater_node(var_args){
var G__22918 = arguments.length;
switch (G__22918) {
case 3:
return cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
case 4:
return cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$3 = (function (x,k,level){
return cljs.core.async.impl.timers.least_greater_node.call(null,x,k,level,null);
});
cljs.core.async.impl.timers.least_greater_node.cljs$core$IFn$_invoke$arity$4 = (function (x,k,level,update){
while(true){
if((!((level < (0))))){
var x__$1 = (function (){var x__$1 = x;
while(true){
var temp__5718__auto__ = (((level < x__$1.forward.length))?(x__$1.forward[level]):null);
if(cljs.core.truth_(temp__5718__auto__)){
var x_SINGLEQUOTE_ = temp__5718__auto__;
if((x_SINGLEQUOTE_.key < k)){
var G__22920 = x_SINGLEQUOTE_;
x__$1 = G__22920;
continue;
} else {
return x__$1;
}
} else {
return x__$1;
}
break;
}
})();
if((update == null)){
} else {
(update[level] = x__$1);
}
var G__22921 = x__$1;
var G__22922 = k;
var G__22923 = (level - (1));
var G__22924 = update;
x = G__22921;
k = G__22922;
level = G__22923;
update = G__22924;
continue;
} else {
return x;
}
break;
}
});
cljs.core.async.impl.timers.least_greater_node.cljs$lang$maxFixedArity = 4;
/**
* @constructor
* @implements {cljs.core.async.impl.timers.Object}
* @implements {cljs.core.ISeqable}
* @implements {cljs.core.IPrintWithWriter}
*/
cljs.core.async.impl.timers.SkipList = (function (header,level){
this.header = header;
this.level = level;
this.cljs$lang$protocol_mask$partition0$ = 2155872256;
this.cljs$lang$protocol_mask$partition1$ = 0;
});
cljs.core.async.impl.timers.SkipList.prototype.put = (function (k,v){
var self__ = this;
var coll = this;
var update = (new Array(cljs.core.async.impl.timers.MAX_LEVEL));
var x = cljs.core.async.impl.timers.least_greater_node.call(null,self__.header,k,self__.level,update);
var x__$1 = (x.forward[(0)]);
if((((!((x__$1 == null)))) && ((x__$1.key === k)))){
return x__$1.val = v;
} else {
var new_level = cljs.core.async.impl.timers.random_level.call(null);
if((new_level > self__.level)){
var i_22925 = (self__.level + (1));
while(true){
if((i_22925 <= (new_level + (1)))){
(update[i_22925] = self__.header);
var G__22926 = (i_22925 + (1));
i_22925 = G__22926;
continue;
} else {
}
break;
}
self__.level = new_level;
} else {
}
var x__$2 = cljs.core.async.impl.timers.skip_list_node.call(null,k,v,(new Array(new_level)));
var i = (0);
while(true){
if((i <= self__.level)){
var links = (update[i]).forward;
(x__$2.forward[i] = (links[i]));
return (links[i] = x__$2);
} else {
return null;
}
break;
}
}
});
cljs.core.async.impl.timers.SkipList.prototype.remove = (function (k){
var self__ = this;
var coll = this;
var update = (new Array(cljs.core.async.impl.timers.MAX_LEVEL));
var x = cljs.core.async.impl.timers.least_greater_node.call(null,self__.header,k,self__.level,update);
var x__$1 = (((x.forward.length === (0)))?null:(x.forward[(0)]));
if((((!((x__$1 == null)))) && ((x__$1.key === k)))){
var i_22927 = (0);
while(true){
if((i_22927 <= self__.level)){
var links_22928 = (update[i_22927]).forward;
if((x__$1 === (((i_22927 < links_22928.length))?(links_22928[i_22927]):null))){
(links_22928[i_22927] = (x__$1.forward[i_22927]));
var G__22929 = (i_22927 + (1));
i_22927 = G__22929;
continue;
} else {
var G__22930 = (i_22927 + (1));
i_22927 = G__22930;
continue;
}
} else {
}
break;
}
while(true){
if(((((((0) < self__.level)) && ((self__.level < self__.header.forward.length)))) && (((self__.header.forward[self__.level]) == null)))){
self__.level = (self__.level - (1));
continue;
} else {
return null;
}
break;
}
} else {
return null;
}
});
cljs.core.async.impl.timers.SkipList.prototype.ceilingEntry = (function (k){
var self__ = this;
var coll = this;
var x = self__.header;
var level__$1 = self__.level;
while(true){
if((!((level__$1 < (0))))){
var nx = (function (){var x__$1 = x;
while(true){
var x_SINGLEQUOTE_ = (((level__$1 < x__$1.forward.length))?(x__$1.forward[level__$1]):null);
if((x_SINGLEQUOTE_ == null)){
return null;
} else {
if((x_SINGLEQUOTE_.key >= k)){
return x_SINGLEQUOTE_;
} else {
var G__22931 = x_SINGLEQUOTE_;
x__$1 = G__22931;
continue;
}
}
break;
}
})();
if((!((nx == null)))){
var G__22932 = nx;
var G__22933 = (level__$1 - (1));
x = G__22932;
level__$1 = G__22933;
continue;
} else {
var G__22934 = x;
var G__22935 = (level__$1 - (1));
x = G__22934;
level__$1 = G__22935;
continue;
}
} else {
if((x === self__.header)){
return null;
} else {
return x;
}
}
break;
}
});
cljs.core.async.impl.timers.SkipList.prototype.floorEntry = (function (k){
var self__ = this;
var coll = this;
var x = self__.header;
var level__$1 = self__.level;
while(true){
if((!((level__$1 < (0))))){
var nx = (function (){var x__$1 = x;
while(true){
var x_SINGLEQUOTE_ = (((level__$1 < x__$1.forward.length))?(x__$1.forward[level__$1]):null);
if((!((x_SINGLEQUOTE_ == null)))){
if((x_SINGLEQUOTE_.key > k)){
return x__$1;
} else {
var G__22936 = x_SINGLEQUOTE_;
x__$1 = G__22936;
continue;
}
} else {
if((level__$1 === (0))){
return x__$1;
} else {
return null;
}
}
break;
}
})();
if(cljs.core.truth_(nx)){
var G__22937 = nx;
var G__22938 = (level__$1 - (1));
x = G__22937;
level__$1 = G__22938;
continue;
} else {
var G__22939 = x;
var G__22940 = (level__$1 - (1));
x = G__22939;
level__$1 = G__22940;
continue;
}
} else {
if((x === self__.header)){
return null;
} else {
return x;
}
}
break;
}
});
cljs.core.async.impl.timers.SkipList.prototype.cljs$core$ISeqable$_seq$arity$1 = (function (coll){
var self__ = this;
var coll__$1 = this;
var iter = ((function (coll__$1){
return (function cljs$core$async$impl$timers$iter(node){
return (new cljs.core.LazySeq(null,((function (coll__$1){
return (function (){
if((node == null)){
return null;
} else {
return cljs.core.cons.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [node.key,node.val], null),cljs$core$async$impl$timers$iter.call(null,(node.forward[(0)])));
}
});})(coll__$1))
,null,null));
});})(coll__$1))
;
return iter.call(null,(self__.header.forward[(0)]));
});
cljs.core.async.impl.timers.SkipList.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (coll,writer,opts){
var self__ = this;
var coll__$1 = this;
var pr_pair = ((function (coll__$1){
return (function (keyval){
return cljs.core.pr_sequential_writer.call(null,writer,cljs.core.pr_writer,""," ","",opts,keyval);
});})(coll__$1))
;
return cljs.core.pr_sequential_writer.call(null,writer,pr_pair,"{",", ","}",opts,coll__$1);
});
cljs.core.async.impl.timers.SkipList.getBasis = (function (){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Symbol(null,"header","header",1759972661,null),cljs.core.with_meta(new cljs.core.Symbol(null,"level","level",-1363938217,null),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"mutable","mutable",875778266),true], null))], null);
});
cljs.core.async.impl.timers.SkipList.cljs$lang$type = true;
cljs.core.async.impl.timers.SkipList.cljs$lang$ctorStr = "cljs.core.async.impl.timers/SkipList";
cljs.core.async.impl.timers.SkipList.cljs$lang$ctorPrWriter = (function (this__4374__auto__,writer__4375__auto__,opt__4376__auto__){
return cljs.core._write.call(null,writer__4375__auto__,"cljs.core.async.impl.timers/SkipList");
});
/**
* Positional factory function for cljs.core.async.impl.timers/SkipList.
*/
cljs.core.async.impl.timers.__GT_SkipList = (function cljs$core$async$impl$timers$__GT_SkipList(header,level){
return (new cljs.core.async.impl.timers.SkipList(header,level));
});
cljs.core.async.impl.timers.skip_list = (function cljs$core$async$impl$timers$skip_list(){
return (new cljs.core.async.impl.timers.SkipList(cljs.core.async.impl.timers.skip_list_node.call(null,(0)),(0)));
});
cljs.core.async.impl.timers.timeouts_map = cljs.core.async.impl.timers.skip_list.call(null);
cljs.core.async.impl.timers.TIMEOUT_RESOLUTION_MS = (10);
/**
* returns a channel that will close after msecs
*/
cljs.core.async.impl.timers.timeout = (function cljs$core$async$impl$timers$timeout(msecs){
var timeout = ((new Date()).valueOf() + msecs);
var me = cljs.core.async.impl.timers.timeouts_map.ceilingEntry(timeout);
var or__4131__auto__ = (cljs.core.truth_((function (){var and__4120__auto__ = me;
if(cljs.core.truth_(and__4120__auto__)){
return (me.key < (timeout + cljs.core.async.impl.timers.TIMEOUT_RESOLUTION_MS));
} else {
return and__4120__auto__;
}
})())?me.val:null);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
var timeout_channel = cljs.core.async.impl.channels.chan.call(null,null);
cljs.core.async.impl.timers.timeouts_map.put(timeout,timeout_channel);
cljs.core.async.impl.dispatch.queue_delay.call(null,((function (timeout_channel,or__4131__auto__,timeout,me){
return (function (){
cljs.core.async.impl.timers.timeouts_map.remove(timeout);
return cljs.core.async.impl.protocols.close_BANG_.call(null,timeout_channel);
});})(timeout_channel,or__4131__auto__,timeout,me))
,msecs);
return timeout_channel;
}
});
//# sourceMappingURL=timers.js.map?rel=1582560147715

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,214 @@
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(ns cljs.reader
(:require-macros [cljs.reader :refer [add-data-readers]])
(:require [goog.object :as gobject]
[cljs.tools.reader :as treader]
[cljs.tools.reader.edn :as edn])
(:import [goog.string StringBuffer]))
(defn ^:private zero-fill-right-and-truncate [s width]
(cond
(= width (count s)) s
(< width (count s)) (subs s 0 width)
:else
(loop [b (StringBuffer. s)]
(if (< (.getLength b) width)
(recur (.append b "0"))
(.toString b)))))
(defn ^:private divisible?
[num div]
(zero? (mod num div)))
(defn ^:private indivisible?
[num div]
(not (divisible? num div)))
(defn ^:private leap-year?
[year]
(and (divisible? year 4)
(or (indivisible? year 100)
(divisible? year 400))))
(def ^:private days-in-month
(let [dim-norm [nil 31 28 31 30 31 30 31 31 30 31 30 31]
dim-leap [nil 31 29 31 30 31 30 31 31 30 31 30 31]]
(fn [month leap-year?]
(get (if leap-year? dim-leap dim-norm) month))))
(def ^:private timestamp-regex #"(\d\d\d\d)(?:-(\d\d)(?:-(\d\d)(?:[T](\d\d)(?::(\d\d)(?::(\d\d)(?:[.](\d+))?)?)?)?)?)?(?:[Z]|([-+])(\d\d):(\d\d))?")
(defn ^:private parse-int [s]
(let [n (js/parseInt s 10)]
(if-not (js/isNaN n)
n)))
(defn ^:private check [low n high msg]
(when-not (<= low n high)
(throw (js/Error. (str msg " Failed: " low "<=" n "<=" high))))
n)
(defn parse-and-validate-timestamp [s]
(let [[_ years months days hours minutes seconds fraction offset-sign offset-hours offset-minutes :as v]
(re-matches timestamp-regex s)]
(if-not v
(throw (js/Error. (str "Unrecognized date/time syntax: " s)))
(let [years (parse-int years)
months (or (parse-int months) 1)
days (or (parse-int days) 1)
hours (or (parse-int hours) 0)
minutes (or (parse-int minutes) 0)
seconds (or (parse-int seconds) 0)
fraction (or (parse-int (zero-fill-right-and-truncate fraction 3)) 0)
offset-sign (if (= offset-sign "-") -1 1)
offset-hours (or (parse-int offset-hours) 0)
offset-minutes (or (parse-int offset-minutes) 0)
offset (* offset-sign (+ (* offset-hours 60) offset-minutes))]
[years
(check 1 months 12 "timestamp month field must be in range 1..12")
(check 1 days (days-in-month months (leap-year? years)) "timestamp day field must be in range 1..last day in month")
(check 0 hours 23 "timestamp hour field must be in range 0..23")
(check 0 minutes 59 "timestamp minute field must be in range 0..59")
(check 0 seconds (if (= minutes 59) 60 59) "timestamp second field must be in range 0..60")
(check 0 fraction 999 "timestamp millisecond field must be in range 0..999")
offset]))))
(defn parse-timestamp
[ts]
(if-let [[years months days hours minutes seconds ms offset]
(parse-and-validate-timestamp ts)]
(js/Date.
(- (.UTC js/Date years (dec months) days hours minutes seconds ms)
(* offset 60 1000)))
(throw (js/Error. (str "Unrecognized date/time syntax: " ts)))))
(defn ^:private read-date
[s]
(if (string? s)
(parse-timestamp s)
(throw (js/Error. "Instance literal expects a string for its timestamp."))))
(defn ^:private read-queue
[elems]
(if (vector? elems)
(into cljs.core/PersistentQueue.EMPTY elems)
(throw (js/Error. "Queue literal expects a vector for its elements."))))
(defn ^:private read-js
[form]
(cond
(vector? form)
(let [arr (array)]
(doseq [x form]
(.push arr x))
arr)
(map? form)
(let [obj (js-obj)]
(doseq [[k v] form]
(gobject/set obj (name k) v))
obj)
:else
(throw
(js/Error.
(str "JS literal expects a vector or map containing "
"only string or unqualified keyword keys")))))
(defn ^:private read-uuid
[uuid]
(if (string? uuid)
(cljs.core/uuid uuid)
(throw (js/Error. "UUID literal expects a string as its representation."))))
(def ^:dynamic *default-data-reader-fn*
(atom nil))
(def ^:dynamic *tag-table*
(atom
(add-data-readers
{'inst read-date
'uuid read-uuid
'queue read-queue
'js read-js})))
(defn read
"Reads the first object from an cljs.tools.reader.reader-types/IPushbackReader.
Returns the object read. If EOF, throws if eof-error? is true otherwise returns eof.
If no reader is provided, *in* will be used.
Reads data in the edn format (subset of Clojure data):
http://edn-format.org
cljs.tools.reader.edn/read doesn't depend on dynamic Vars, all configuration
is done by passing an opt map.
opts is a map that can include the following keys:
:eof - value to return on end-of-file. When not supplied, eof throws an exception.
:readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
When not supplied, only the default-data-readers will be used.
:default - A function of two args, that will, if present and no reader is found for a tag,
be called with the tag and the value."
([reader]
(edn/read
{:readers @*tag-table*
:default @*default-data-reader-fn*
:eof nil}
reader))
([{:keys [eof] :as opts} reader]
(edn/read
(update (merge opts {:default @*default-data-reader-fn*})
:readers (fn [m] (merge @*tag-table* m))) reader))
([reader eof-error? eof opts]
(edn/read reader eof-error? eof
(update (merge opts {:default @*default-data-reader-fn*})
:readers (fn [m] (merge @*tag-table* m))))))
(defn read-string
"Reads one object from the string s.
Returns nil when s is nil or empty.
Reads data in the edn format (subset of Clojure data):
http://edn-format.org
opts is a map as per cljs.tools.reader.edn/read"
([s]
(edn/read-string
{:readers @*tag-table*
:default @*default-data-reader-fn*
:eof nil} s))
([opts s]
(edn/read-string
(update (merge {:default @*default-data-reader-fn*} opts)
:readers (fn [m] (merge @*tag-table* m))) s)))
(defn register-tag-parser!
[tag f]
(let [old-parser (get @*tag-table* tag)]
(swap! *tag-table* assoc tag f)
old-parser))
(defn deregister-tag-parser!
[tag]
(let [old-parser (get @*tag-table* tag)]
(swap! *tag-table* dissoc tag)
old-parser))
(defn register-default-tag-parser!
[f]
(let [old-parser @*default-data-reader-fn*]
(swap! *default-data-reader-fn* (fn [_] f))
old-parser))
(defn deregister-default-tag-parser!
[]
(let [old-parser @*default-data-reader-fn*]
(swap! *default-data-reader-fn* (fn [_] nil))
old-parser))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,445 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('cljs.reader');
goog.require('cljs.core');
goog.require('goog.object');
goog.require('cljs.tools.reader');
goog.require('cljs.tools.reader.edn');
goog.require('goog.string.StringBuffer');
cljs.reader.zero_fill_right_and_truncate = (function cljs$reader$zero_fill_right_and_truncate(s,width){
if(cljs.core._EQ_.call(null,width,cljs.core.count.call(null,s))){
return s;
} else {
if((width < cljs.core.count.call(null,s))){
return cljs.core.subs.call(null,s,(0),width);
} else {
var b = (new goog.string.StringBuffer(s));
while(true){
if((b.getLength() < width)){
var G__21298 = b.append("0");
b = G__21298;
continue;
} else {
return b.toString();
}
break;
}
}
}
});
cljs.reader.divisible_QMARK_ = (function cljs$reader$divisible_QMARK_(num,div){
return (cljs.core.mod.call(null,num,div) === (0));
});
cljs.reader.indivisible_QMARK_ = (function cljs$reader$indivisible_QMARK_(num,div){
return (!(cljs.reader.divisible_QMARK_.call(null,num,div)));
});
cljs.reader.leap_year_QMARK_ = (function cljs$reader$leap_year_QMARK_(year){
return ((cljs.reader.divisible_QMARK_.call(null,year,(4))) && (((cljs.reader.indivisible_QMARK_.call(null,year,(100))) || (cljs.reader.divisible_QMARK_.call(null,year,(400))))));
});
cljs.reader.days_in_month = (function (){var dim_norm = new cljs.core.PersistentVector(null, 13, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,(31),(28),(31),(30),(31),(30),(31),(31),(30),(31),(30),(31)], null);
var dim_leap = new cljs.core.PersistentVector(null, 13, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,(31),(29),(31),(30),(31),(30),(31),(31),(30),(31),(30),(31)], null);
return ((function (dim_norm,dim_leap){
return (function (month,leap_year_QMARK_){
return cljs.core.get.call(null,(cljs.core.truth_(leap_year_QMARK_)?dim_leap:dim_norm),month);
});
;})(dim_norm,dim_leap))
})();
cljs.reader.timestamp_regex = /(\d\d\d\d)(?:-(\d\d)(?:-(\d\d)(?:[T](\d\d)(?::(\d\d)(?::(\d\d)(?:[.](\d+))?)?)?)?)?)?(?:[Z]|([-+])(\d\d):(\d\d))?/;
cljs.reader.parse_int = (function cljs$reader$parse_int(s){
var n = parseInt(s,(10));
if(cljs.core.not.call(null,isNaN(n))){
return n;
} else {
return null;
}
});
cljs.reader.check = (function cljs$reader$check(low,n,high,msg){
if((((low <= n)) && ((n <= high)))){
} else {
throw (new Error([cljs.core.str.cljs$core$IFn$_invoke$arity$1(msg)," Failed: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(low),"<=",cljs.core.str.cljs$core$IFn$_invoke$arity$1(n),"<=",cljs.core.str.cljs$core$IFn$_invoke$arity$1(high)].join('')));
}
return n;
});
cljs.reader.parse_and_validate_timestamp = (function cljs$reader$parse_and_validate_timestamp(s){
var vec__21299 = cljs.core.re_matches.call(null,cljs.reader.timestamp_regex,s);
var _ = cljs.core.nth.call(null,vec__21299,(0),null);
var years = cljs.core.nth.call(null,vec__21299,(1),null);
var months = cljs.core.nth.call(null,vec__21299,(2),null);
var days = cljs.core.nth.call(null,vec__21299,(3),null);
var hours = cljs.core.nth.call(null,vec__21299,(4),null);
var minutes = cljs.core.nth.call(null,vec__21299,(5),null);
var seconds = cljs.core.nth.call(null,vec__21299,(6),null);
var fraction = cljs.core.nth.call(null,vec__21299,(7),null);
var offset_sign = cljs.core.nth.call(null,vec__21299,(8),null);
var offset_hours = cljs.core.nth.call(null,vec__21299,(9),null);
var offset_minutes = cljs.core.nth.call(null,vec__21299,(10),null);
var v = vec__21299;
if(cljs.core.not.call(null,v)){
throw (new Error(["Unrecognized date/time syntax: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(s)].join('')));
} else {
var years__$1 = cljs.reader.parse_int.call(null,years);
var months__$1 = (function (){var or__4131__auto__ = cljs.reader.parse_int.call(null,months);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return (1);
}
})();
var days__$1 = (function (){var or__4131__auto__ = cljs.reader.parse_int.call(null,days);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return (1);
}
})();
var hours__$1 = (function (){var or__4131__auto__ = cljs.reader.parse_int.call(null,hours);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return (0);
}
})();
var minutes__$1 = (function (){var or__4131__auto__ = cljs.reader.parse_int.call(null,minutes);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return (0);
}
})();
var seconds__$1 = (function (){var or__4131__auto__ = cljs.reader.parse_int.call(null,seconds);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return (0);
}
})();
var fraction__$1 = (function (){var or__4131__auto__ = cljs.reader.parse_int.call(null,cljs.reader.zero_fill_right_and_truncate.call(null,fraction,(3)));
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return (0);
}
})();
var offset_sign__$1 = ((cljs.core._EQ_.call(null,offset_sign,"-"))?(-1):(1));
var offset_hours__$1 = (function (){var or__4131__auto__ = cljs.reader.parse_int.call(null,offset_hours);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return (0);
}
})();
var offset_minutes__$1 = (function (){var or__4131__auto__ = cljs.reader.parse_int.call(null,offset_minutes);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return (0);
}
})();
var offset = (offset_sign__$1 * ((offset_hours__$1 * (60)) + offset_minutes__$1));
return new cljs.core.PersistentVector(null, 8, 5, cljs.core.PersistentVector.EMPTY_NODE, [years__$1,cljs.reader.check.call(null,(1),months__$1,(12),"timestamp month field must be in range 1..12"),cljs.reader.check.call(null,(1),days__$1,cljs.reader.days_in_month.call(null,months__$1,cljs.reader.leap_year_QMARK_.call(null,years__$1)),"timestamp day field must be in range 1..last day in month"),cljs.reader.check.call(null,(0),hours__$1,(23),"timestamp hour field must be in range 0..23"),cljs.reader.check.call(null,(0),minutes__$1,(59),"timestamp minute field must be in range 0..59"),cljs.reader.check.call(null,(0),seconds__$1,((cljs.core._EQ_.call(null,minutes__$1,(59)))?(60):(59)),"timestamp second field must be in range 0..60"),cljs.reader.check.call(null,(0),fraction__$1,(999),"timestamp millisecond field must be in range 0..999"),offset], null);
}
});
cljs.reader.parse_timestamp = (function cljs$reader$parse_timestamp(ts){
var temp__5718__auto__ = cljs.reader.parse_and_validate_timestamp.call(null,ts);
if(cljs.core.truth_(temp__5718__auto__)){
var vec__21302 = temp__5718__auto__;
var years = cljs.core.nth.call(null,vec__21302,(0),null);
var months = cljs.core.nth.call(null,vec__21302,(1),null);
var days = cljs.core.nth.call(null,vec__21302,(2),null);
var hours = cljs.core.nth.call(null,vec__21302,(3),null);
var minutes = cljs.core.nth.call(null,vec__21302,(4),null);
var seconds = cljs.core.nth.call(null,vec__21302,(5),null);
var ms = cljs.core.nth.call(null,vec__21302,(6),null);
var offset = cljs.core.nth.call(null,vec__21302,(7),null);
return (new Date((Date.UTC(years,(months - (1)),days,hours,minutes,seconds,ms) - ((offset * (60)) * (1000)))));
} else {
throw (new Error(["Unrecognized date/time syntax: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(ts)].join('')));
}
});
cljs.reader.read_date = (function cljs$reader$read_date(s){
if(typeof s === 'string'){
return cljs.reader.parse_timestamp.call(null,s);
} else {
throw (new Error("Instance literal expects a string for its timestamp."));
}
});
cljs.reader.read_queue = (function cljs$reader$read_queue(elems){
if(cljs.core.vector_QMARK_.call(null,elems)){
return cljs.core.into.call(null,cljs.core.PersistentQueue.EMPTY,elems);
} else {
throw (new Error("Queue literal expects a vector for its elements."));
}
});
cljs.reader.read_js = (function cljs$reader$read_js(form){
if(cljs.core.vector_QMARK_.call(null,form)){
var arr = [];
var seq__21305_21327 = cljs.core.seq.call(null,form);
var chunk__21306_21328 = null;
var count__21307_21329 = (0);
var i__21308_21330 = (0);
while(true){
if((i__21308_21330 < count__21307_21329)){
var x_21331 = cljs.core._nth.call(null,chunk__21306_21328,i__21308_21330);
arr.push(x_21331);
var G__21332 = seq__21305_21327;
var G__21333 = chunk__21306_21328;
var G__21334 = count__21307_21329;
var G__21335 = (i__21308_21330 + (1));
seq__21305_21327 = G__21332;
chunk__21306_21328 = G__21333;
count__21307_21329 = G__21334;
i__21308_21330 = G__21335;
continue;
} else {
var temp__5720__auto___21336 = cljs.core.seq.call(null,seq__21305_21327);
if(temp__5720__auto___21336){
var seq__21305_21337__$1 = temp__5720__auto___21336;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__21305_21337__$1)){
var c__4550__auto___21338 = cljs.core.chunk_first.call(null,seq__21305_21337__$1);
var G__21339 = cljs.core.chunk_rest.call(null,seq__21305_21337__$1);
var G__21340 = c__4550__auto___21338;
var G__21341 = cljs.core.count.call(null,c__4550__auto___21338);
var G__21342 = (0);
seq__21305_21327 = G__21339;
chunk__21306_21328 = G__21340;
count__21307_21329 = G__21341;
i__21308_21330 = G__21342;
continue;
} else {
var x_21343 = cljs.core.first.call(null,seq__21305_21337__$1);
arr.push(x_21343);
var G__21344 = cljs.core.next.call(null,seq__21305_21337__$1);
var G__21345 = null;
var G__21346 = (0);
var G__21347 = (0);
seq__21305_21327 = G__21344;
chunk__21306_21328 = G__21345;
count__21307_21329 = G__21346;
i__21308_21330 = G__21347;
continue;
}
} else {
}
}
break;
}
return arr;
} else {
if(cljs.core.map_QMARK_.call(null,form)){
var obj = ({});
var seq__21311_21348 = cljs.core.seq.call(null,form);
var chunk__21312_21349 = null;
var count__21313_21350 = (0);
var i__21314_21351 = (0);
while(true){
if((i__21314_21351 < count__21313_21350)){
var vec__21321_21352 = cljs.core._nth.call(null,chunk__21312_21349,i__21314_21351);
var k_21353 = cljs.core.nth.call(null,vec__21321_21352,(0),null);
var v_21354 = cljs.core.nth.call(null,vec__21321_21352,(1),null);
goog.object.set(obj,cljs.core.name.call(null,k_21353),v_21354);
var G__21355 = seq__21311_21348;
var G__21356 = chunk__21312_21349;
var G__21357 = count__21313_21350;
var G__21358 = (i__21314_21351 + (1));
seq__21311_21348 = G__21355;
chunk__21312_21349 = G__21356;
count__21313_21350 = G__21357;
i__21314_21351 = G__21358;
continue;
} else {
var temp__5720__auto___21359 = cljs.core.seq.call(null,seq__21311_21348);
if(temp__5720__auto___21359){
var seq__21311_21360__$1 = temp__5720__auto___21359;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__21311_21360__$1)){
var c__4550__auto___21361 = cljs.core.chunk_first.call(null,seq__21311_21360__$1);
var G__21362 = cljs.core.chunk_rest.call(null,seq__21311_21360__$1);
var G__21363 = c__4550__auto___21361;
var G__21364 = cljs.core.count.call(null,c__4550__auto___21361);
var G__21365 = (0);
seq__21311_21348 = G__21362;
chunk__21312_21349 = G__21363;
count__21313_21350 = G__21364;
i__21314_21351 = G__21365;
continue;
} else {
var vec__21324_21366 = cljs.core.first.call(null,seq__21311_21360__$1);
var k_21367 = cljs.core.nth.call(null,vec__21324_21366,(0),null);
var v_21368 = cljs.core.nth.call(null,vec__21324_21366,(1),null);
goog.object.set(obj,cljs.core.name.call(null,k_21367),v_21368);
var G__21369 = cljs.core.next.call(null,seq__21311_21360__$1);
var G__21370 = null;
var G__21371 = (0);
var G__21372 = (0);
seq__21311_21348 = G__21369;
chunk__21312_21349 = G__21370;
count__21313_21350 = G__21371;
i__21314_21351 = G__21372;
continue;
}
} else {
}
}
break;
}
return obj;
} else {
throw (new Error(["JS literal expects a vector or map containing ","only string or unqualified keyword keys"].join('')));
}
}
});
cljs.reader.read_uuid = (function cljs$reader$read_uuid(uuid){
if(typeof uuid === 'string'){
return cljs.core.uuid.call(null,uuid);
} else {
throw (new Error("UUID literal expects a string as its representation."));
}
});
cljs.reader._STAR_default_data_reader_fn_STAR_ = cljs.core.atom.call(null,null);
cljs.reader._STAR_tag_table_STAR_ = cljs.core.atom.call(null,cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Symbol(null,"inst","inst",-2008473268,null),cljs.reader.read_date,new cljs.core.Symbol(null,"uuid","uuid",-504564192,null),cljs.reader.read_uuid,new cljs.core.Symbol(null,"queue","queue",-1198599890,null),cljs.reader.read_queue,new cljs.core.Symbol(null,"js","js",-886355190,null),cljs.reader.read_js], null),cljs.core.PersistentArrayMap.EMPTY));
/**
* Reads the first object from an cljs.tools.reader.reader-types/IPushbackReader.
* Returns the object read. If EOF, throws if eof-error? is true otherwise returns eof.
* If no reader is provided, *in* will be used.
*
* Reads data in the edn format (subset of Clojure data):
* http://edn-format.org
*
* cljs.tools.reader.edn/read doesn't depend on dynamic Vars, all configuration
* is done by passing an opt map.
*
* opts is a map that can include the following keys:
* :eof - value to return on end-of-file. When not supplied, eof throws an exception.
* :readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
* When not supplied, only the default-data-readers will be used.
* :default - A function of two args, that will, if present and no reader is found for a tag,
* be called with the tag and the value.
*/
cljs.reader.read = (function cljs$reader$read(var_args){
var G__21374 = arguments.length;
switch (G__21374) {
case 1:
return cljs.reader.read.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return cljs.reader.read.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 4:
return cljs.reader.read.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
cljs.reader.read.cljs$core$IFn$_invoke$arity$1 = (function (reader){
return cljs.tools.reader.edn.read.call(null,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"readers","readers",-2118263030),cljs.core.deref.call(null,cljs.reader._STAR_tag_table_STAR_),new cljs.core.Keyword(null,"default","default",-1987822328),cljs.core.deref.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_),new cljs.core.Keyword(null,"eof","eof",-489063237),null], null),reader);
});
cljs.reader.read.cljs$core$IFn$_invoke$arity$2 = (function (p__21375,reader){
var map__21376 = p__21375;
var map__21376__$1 = (((((!((map__21376 == null))))?(((((map__21376.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__21376.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__21376):map__21376);
var opts = map__21376__$1;
var eof = cljs.core.get.call(null,map__21376__$1,new cljs.core.Keyword(null,"eof","eof",-489063237));
return cljs.tools.reader.edn.read.call(null,cljs.core.update.call(null,cljs.core.merge.call(null,opts,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"default","default",-1987822328),cljs.core.deref.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_)], null)),new cljs.core.Keyword(null,"readers","readers",-2118263030),((function (map__21376,map__21376__$1,opts,eof){
return (function (m){
return cljs.core.merge.call(null,cljs.core.deref.call(null,cljs.reader._STAR_tag_table_STAR_),m);
});})(map__21376,map__21376__$1,opts,eof))
),reader);
});
cljs.reader.read.cljs$core$IFn$_invoke$arity$4 = (function (reader,eof_error_QMARK_,eof,opts){
return cljs.tools.reader.edn.read.call(null,reader,eof_error_QMARK_,eof,cljs.core.update.call(null,cljs.core.merge.call(null,opts,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"default","default",-1987822328),cljs.core.deref.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_)], null)),new cljs.core.Keyword(null,"readers","readers",-2118263030),(function (m){
return cljs.core.merge.call(null,cljs.core.deref.call(null,cljs.reader._STAR_tag_table_STAR_),m);
})));
});
cljs.reader.read.cljs$lang$maxFixedArity = 4;
/**
* Reads one object from the string s.
* Returns nil when s is nil or empty.
*
* Reads data in the edn format (subset of Clojure data):
* http://edn-format.org
*
* opts is a map as per cljs.tools.reader.edn/read
*/
cljs.reader.read_string = (function cljs$reader$read_string(var_args){
var G__21380 = arguments.length;
switch (G__21380) {
case 1:
return cljs.reader.read_string.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return cljs.reader.read_string.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
cljs.reader.read_string.cljs$core$IFn$_invoke$arity$1 = (function (s){
return cljs.tools.reader.edn.read_string.call(null,new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"readers","readers",-2118263030),cljs.core.deref.call(null,cljs.reader._STAR_tag_table_STAR_),new cljs.core.Keyword(null,"default","default",-1987822328),cljs.core.deref.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_),new cljs.core.Keyword(null,"eof","eof",-489063237),null], null),s);
});
cljs.reader.read_string.cljs$core$IFn$_invoke$arity$2 = (function (opts,s){
return cljs.tools.reader.edn.read_string.call(null,cljs.core.update.call(null,cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"default","default",-1987822328),cljs.core.deref.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_)], null),opts),new cljs.core.Keyword(null,"readers","readers",-2118263030),(function (m){
return cljs.core.merge.call(null,cljs.core.deref.call(null,cljs.reader._STAR_tag_table_STAR_),m);
})),s);
});
cljs.reader.read_string.cljs$lang$maxFixedArity = 2;
cljs.reader.register_tag_parser_BANG_ = (function cljs$reader$register_tag_parser_BANG_(tag,f){
var old_parser = cljs.core.get.call(null,cljs.core.deref.call(null,cljs.reader._STAR_tag_table_STAR_),tag);
cljs.core.swap_BANG_.call(null,cljs.reader._STAR_tag_table_STAR_,cljs.core.assoc,tag,f);
return old_parser;
});
cljs.reader.deregister_tag_parser_BANG_ = (function cljs$reader$deregister_tag_parser_BANG_(tag){
var old_parser = cljs.core.get.call(null,cljs.core.deref.call(null,cljs.reader._STAR_tag_table_STAR_),tag);
cljs.core.swap_BANG_.call(null,cljs.reader._STAR_tag_table_STAR_,cljs.core.dissoc,tag);
return old_parser;
});
cljs.reader.register_default_tag_parser_BANG_ = (function cljs$reader$register_default_tag_parser_BANG_(f){
var old_parser = cljs.core.deref.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_);
cljs.core.swap_BANG_.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_,((function (old_parser){
return (function (_){
return f;
});})(old_parser))
);
return old_parser;
});
cljs.reader.deregister_default_tag_parser_BANG_ = (function cljs$reader$deregister_default_tag_parser_BANG_(){
var old_parser = cljs.core.deref.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_);
cljs.core.swap_BANG_.call(null,cljs.reader._STAR_default_data_reader_fn_STAR_,((function (old_parser){
return (function (_){
return null;
});})(old_parser))
);
return old_parser;
});
//# sourceMappingURL=reader.js.map?rel=1582560147241

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,235 @@
;; Copyright (c) Rich Hickey. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns cljs.repl
(:require-macros cljs.repl)
(:require [cljs.spec.alpha :as spec]
[goog.string :as gstring]
[goog.string.format]))
(defn print-doc [{n :ns nm :name :as m}]
(println "-------------------------")
(println (or (:spec m) (str (when-let [ns (:ns m)] (str ns "/")) (:name m))))
(when (:protocol m)
(println "Protocol"))
(cond
(:forms m) (doseq [f (:forms m)]
(println " " f))
(:arglists m) (let [arglists (:arglists m)]
(if (or (:macro m)
(:repl-special-function m))
(prn arglists)
(prn
(if (= 'quote (first arglists))
(second arglists)
arglists)))))
(if (:special-form m)
(do
(println "Special Form")
(println " " (:doc m))
(if (contains? m :url)
(when (:url m)
(println (str "\n Please see http://clojure.org/" (:url m))))
(println (str "\n Please see http://clojure.org/special_forms#"
(:name m)))))
(do
(when (:macro m)
(println "Macro"))
(when (:spec m)
(println "Spec"))
(when (:repl-special-function m)
(println "REPL Special Function"))
(println " " (:doc m))
(when (:protocol m)
(doseq [[name {:keys [doc arglists]}] (:methods m)]
(println)
(println " " name)
(println " " arglists)
(when doc
(println " " doc))))
(when n
(when-let [fnspec (spec/get-spec (symbol (str (ns-name n)) (name nm)))]
(print "Spec")
(doseq [role [:args :ret :fn]]
(when-let [spec (get fnspec role)]
(print (str "\n " (name role) ":") (spec/describe spec)))))))))
(defn Error->map
"Constructs a data representation for a Error with keys:
:cause - root cause message
:phase - error phase
:via - cause chain, with cause keys:
:type - exception class symbol
:message - exception message
:data - ex-data
:at - top stack element
:trace - root cause stack elements"
[o]
(let [base (fn [t]
(merge {:type (cond
(instance? ExceptionInfo t) 'ExceptionInfo
(instance? js/EvalError t) 'js/EvalError
(instance? js/RangeError t) 'js/RangeError
(instance? js/ReferenceError t) 'js/ReferenceError
(instance? js/SyntaxError t) 'js/SyntaxError
(instance? js/URIError t) 'js/URIError
(instance? js/Error t) 'js/Error
:else nil)}
(when-let [msg (ex-message t)]
{:message msg})
(when-let [ed (ex-data t)]
{:data ed})
#_(let [st (extract-canonical-stacktrace t)]
(when (pos? (count st))
{:at st}))))
via (loop [via [], t o]
(if t
(recur (conj via t) (ex-cause t))
via))
root (peek via)]
(merge {:via (vec (map base via))
:trace nil #_(extract-canonical-stacktrace (or root o))}
(when-let [root-msg (ex-message root)]
{:cause root-msg})
(when-let [data (ex-data root)]
{:data data})
(when-let [phase (-> o ex-data :clojure.error/phase)]
{:phase phase}))))
(defn ex-triage
"Returns an analysis of the phase, error, cause, and location of an error that occurred
based on Throwable data, as returned by Throwable->map. All attributes other than phase
are optional:
:clojure.error/phase - keyword phase indicator, one of:
:read-source :compile-syntax-check :compilation :macro-syntax-check :macroexpansion
:execution :read-eval-result :print-eval-result
:clojure.error/source - file name (no path)
:clojure.error/line - integer line number
:clojure.error/column - integer column number
:clojure.error/symbol - symbol being expanded/compiled/invoked
:clojure.error/class - cause exception class symbol
:clojure.error/cause - cause exception message
:clojure.error/spec - explain-data for spec error"
[datafied-throwable]
(let [{:keys [via trace phase] :or {phase :execution}} datafied-throwable
{:keys [type message data]} (last via)
{:cljs.spec.alpha/keys [problems fn] :cljs.spec.test.alpha/keys [caller]} data
{:keys [:clojure.error/source] :as top-data} (:data (first via))]
(assoc
(case phase
:read-source
(let [{:keys [:clojure.error/line :clojure.error/column]} data]
(cond-> (merge (-> via second :data) top-data)
source (assoc :clojure.error/source source)
(#{"NO_SOURCE_FILE" "NO_SOURCE_PATH"} source) (dissoc :clojure.error/source)
message (assoc :clojure.error/cause message)))
(:compile-syntax-check :compilation :macro-syntax-check :macroexpansion)
(cond-> top-data
source (assoc :clojure.error/source source)
(#{"NO_SOURCE_FILE" "NO_SOURCE_PATH"} source) (dissoc :clojure.error/source)
type (assoc :clojure.error/class type)
message (assoc :clojure.error/cause message)
problems (assoc :clojure.error/spec data))
(:read-eval-result :print-eval-result)
(let [[source method file line] (-> trace first)]
(cond-> top-data
line (assoc :clojure.error/line line)
file (assoc :clojure.error/source file)
(and source method) (assoc :clojure.error/symbol (vector #_java-loc->source source method))
type (assoc :clojure.error/class type)
message (assoc :clojure.error/cause message)))
:execution
(let [[source method file line] (->> trace #_(drop-while #(core-class? (name (first %)))) first)
file (first (remove #(or (nil? %) (#{"NO_SOURCE_FILE" "NO_SOURCE_PATH"} %)) [(:file caller) file]))
err-line (or (:line caller) line)]
(cond-> {:clojure.error/class type}
err-line (assoc :clojure.error/line err-line)
message (assoc :clojure.error/cause message)
(or fn (and source method)) (assoc :clojure.error/symbol (or fn (vector #_java-loc->source source method)))
file (assoc :clojure.error/source file)
problems (assoc :clojure.error/spec data))))
:clojure.error/phase phase)))
(defn ex-str
"Returns a string from exception data, as produced by ex-triage.
The first line summarizes the exception phase and location.
The subsequent lines describe the cause."
[{:clojure.error/keys [phase source line column symbol class cause spec] :as triage-data}]
(let [loc (str (or source "<cljs repl>") ":" (or line 1) (if column (str ":" column) ""))
class-name (name (or class ""))
simple-class class-name
cause-type (if (contains? #{"Exception" "RuntimeException"} simple-class)
"" ;; omit, not useful
(str " (" simple-class ")"))
format gstring/format]
(case phase
:read-source
(format "Syntax error reading source at (%s).\n%s\n" loc cause)
:macro-syntax-check
(format "Syntax error macroexpanding %sat (%s).\n%s"
(if symbol (str symbol " ") "")
loc
(if spec
(with-out-str
(spec/explain-out
(if true #_(= s/*explain-out* s/explain-printer)
(update spec ::spec/problems
(fn [probs] (map #(dissoc % :in) probs)))
spec)))
(format "%s\n" cause)))
:macroexpansion
(format "Unexpected error%s macroexpanding %sat (%s).\n%s\n"
cause-type
(if symbol (str symbol " ") "")
loc
cause)
:compile-syntax-check
(format "Syntax error%s compiling %sat (%s).\n%s\n"
cause-type
(if symbol (str symbol " ") "")
loc
cause)
:compilation
(format "Unexpected error%s compiling %sat (%s).\n%s\n"
cause-type
(if symbol (str symbol " ") "")
loc
cause)
:read-eval-result
(format "Error reading eval result%s at %s (%s).\n%s\n" cause-type symbol loc cause)
:print-eval-result
(format "Error printing return value%s at %s (%s).\n%s\n" cause-type symbol loc cause)
:execution
(if spec
(format "Execution error - invalid arguments to %s at (%s).\n%s"
symbol
loc
(with-out-str
(spec/explain-out
(if true #_(= s/*explain-out* s/explain-printer)
(update spec ::spec/problems
(fn [probs] (map #(dissoc % :in) probs)))
spec))))
(format "Execution error%s at %s(%s).\n%s\n"
cause-type
(if symbol (str symbol " ") "")
loc
cause)))))
(defn error->str [error]
(ex-str (ex-triage (Error->map error))))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,670 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('cljs.repl');
goog.require('cljs.core');
goog.require('cljs.spec.alpha');
goog.require('goog.string');
goog.require('goog.string.format');
cljs.repl.print_doc = (function cljs$repl$print_doc(p__30007){
var map__30008 = p__30007;
var map__30008__$1 = (((((!((map__30008 == null))))?(((((map__30008.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30008.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30008):map__30008);
var m = map__30008__$1;
var n = cljs.core.get.call(null,map__30008__$1,new cljs.core.Keyword(null,"ns","ns",441598760));
var nm = cljs.core.get.call(null,map__30008__$1,new cljs.core.Keyword(null,"name","name",1843675177));
cljs.core.println.call(null,"-------------------------");
cljs.core.println.call(null,(function (){var or__4131__auto__ = new cljs.core.Keyword(null,"spec","spec",347520401).cljs$core$IFn$_invoke$arity$1(m);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return [(function (){var temp__5720__auto__ = new cljs.core.Keyword(null,"ns","ns",441598760).cljs$core$IFn$_invoke$arity$1(m);
if(cljs.core.truth_(temp__5720__auto__)){
var ns = temp__5720__auto__;
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(ns),"/"].join('');
} else {
return null;
}
})(),cljs.core.str.cljs$core$IFn$_invoke$arity$1(new cljs.core.Keyword(null,"name","name",1843675177).cljs$core$IFn$_invoke$arity$1(m))].join('');
}
})());
if(cljs.core.truth_(new cljs.core.Keyword(null,"protocol","protocol",652470118).cljs$core$IFn$_invoke$arity$1(m))){
cljs.core.println.call(null,"Protocol");
} else {
}
if(cljs.core.truth_(new cljs.core.Keyword(null,"forms","forms",2045992350).cljs$core$IFn$_invoke$arity$1(m))){
var seq__30010_30042 = cljs.core.seq.call(null,new cljs.core.Keyword(null,"forms","forms",2045992350).cljs$core$IFn$_invoke$arity$1(m));
var chunk__30011_30043 = null;
var count__30012_30044 = (0);
var i__30013_30045 = (0);
while(true){
if((i__30013_30045 < count__30012_30044)){
var f_30046 = cljs.core._nth.call(null,chunk__30011_30043,i__30013_30045);
cljs.core.println.call(null," ",f_30046);
var G__30047 = seq__30010_30042;
var G__30048 = chunk__30011_30043;
var G__30049 = count__30012_30044;
var G__30050 = (i__30013_30045 + (1));
seq__30010_30042 = G__30047;
chunk__30011_30043 = G__30048;
count__30012_30044 = G__30049;
i__30013_30045 = G__30050;
continue;
} else {
var temp__5720__auto___30051 = cljs.core.seq.call(null,seq__30010_30042);
if(temp__5720__auto___30051){
var seq__30010_30052__$1 = temp__5720__auto___30051;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__30010_30052__$1)){
var c__4550__auto___30053 = cljs.core.chunk_first.call(null,seq__30010_30052__$1);
var G__30054 = cljs.core.chunk_rest.call(null,seq__30010_30052__$1);
var G__30055 = c__4550__auto___30053;
var G__30056 = cljs.core.count.call(null,c__4550__auto___30053);
var G__30057 = (0);
seq__30010_30042 = G__30054;
chunk__30011_30043 = G__30055;
count__30012_30044 = G__30056;
i__30013_30045 = G__30057;
continue;
} else {
var f_30058 = cljs.core.first.call(null,seq__30010_30052__$1);
cljs.core.println.call(null," ",f_30058);
var G__30059 = cljs.core.next.call(null,seq__30010_30052__$1);
var G__30060 = null;
var G__30061 = (0);
var G__30062 = (0);
seq__30010_30042 = G__30059;
chunk__30011_30043 = G__30060;
count__30012_30044 = G__30061;
i__30013_30045 = G__30062;
continue;
}
} else {
}
}
break;
}
} else {
if(cljs.core.truth_(new cljs.core.Keyword(null,"arglists","arglists",1661989754).cljs$core$IFn$_invoke$arity$1(m))){
var arglists_30063 = new cljs.core.Keyword(null,"arglists","arglists",1661989754).cljs$core$IFn$_invoke$arity$1(m);
if(cljs.core.truth_((function (){var or__4131__auto__ = new cljs.core.Keyword(null,"macro","macro",-867863404).cljs$core$IFn$_invoke$arity$1(m);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return new cljs.core.Keyword(null,"repl-special-function","repl-special-function",1262603725).cljs$core$IFn$_invoke$arity$1(m);
}
})())){
cljs.core.prn.call(null,arglists_30063);
} else {
cljs.core.prn.call(null,((cljs.core._EQ_.call(null,new cljs.core.Symbol(null,"quote","quote",1377916282,null),cljs.core.first.call(null,arglists_30063)))?cljs.core.second.call(null,arglists_30063):arglists_30063));
}
} else {
}
}
if(cljs.core.truth_(new cljs.core.Keyword(null,"special-form","special-form",-1326536374).cljs$core$IFn$_invoke$arity$1(m))){
cljs.core.println.call(null,"Special Form");
cljs.core.println.call(null," ",new cljs.core.Keyword(null,"doc","doc",1913296891).cljs$core$IFn$_invoke$arity$1(m));
if(cljs.core.contains_QMARK_.call(null,m,new cljs.core.Keyword(null,"url","url",276297046))){
if(cljs.core.truth_(new cljs.core.Keyword(null,"url","url",276297046).cljs$core$IFn$_invoke$arity$1(m))){
return cljs.core.println.call(null,["\n Please see http://clojure.org/",cljs.core.str.cljs$core$IFn$_invoke$arity$1(new cljs.core.Keyword(null,"url","url",276297046).cljs$core$IFn$_invoke$arity$1(m))].join(''));
} else {
return null;
}
} else {
return cljs.core.println.call(null,["\n Please see http://clojure.org/special_forms#",cljs.core.str.cljs$core$IFn$_invoke$arity$1(new cljs.core.Keyword(null,"name","name",1843675177).cljs$core$IFn$_invoke$arity$1(m))].join(''));
}
} else {
if(cljs.core.truth_(new cljs.core.Keyword(null,"macro","macro",-867863404).cljs$core$IFn$_invoke$arity$1(m))){
cljs.core.println.call(null,"Macro");
} else {
}
if(cljs.core.truth_(new cljs.core.Keyword(null,"spec","spec",347520401).cljs$core$IFn$_invoke$arity$1(m))){
cljs.core.println.call(null,"Spec");
} else {
}
if(cljs.core.truth_(new cljs.core.Keyword(null,"repl-special-function","repl-special-function",1262603725).cljs$core$IFn$_invoke$arity$1(m))){
cljs.core.println.call(null,"REPL Special Function");
} else {
}
cljs.core.println.call(null," ",new cljs.core.Keyword(null,"doc","doc",1913296891).cljs$core$IFn$_invoke$arity$1(m));
if(cljs.core.truth_(new cljs.core.Keyword(null,"protocol","protocol",652470118).cljs$core$IFn$_invoke$arity$1(m))){
var seq__30014_30064 = cljs.core.seq.call(null,new cljs.core.Keyword(null,"methods","methods",453930866).cljs$core$IFn$_invoke$arity$1(m));
var chunk__30015_30065 = null;
var count__30016_30066 = (0);
var i__30017_30067 = (0);
while(true){
if((i__30017_30067 < count__30016_30066)){
var vec__30028_30068 = cljs.core._nth.call(null,chunk__30015_30065,i__30017_30067);
var name_30069 = cljs.core.nth.call(null,vec__30028_30068,(0),null);
var map__30031_30070 = cljs.core.nth.call(null,vec__30028_30068,(1),null);
var map__30031_30071__$1 = (((((!((map__30031_30070 == null))))?(((((map__30031_30070.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30031_30070.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30031_30070):map__30031_30070);
var doc_30072 = cljs.core.get.call(null,map__30031_30071__$1,new cljs.core.Keyword(null,"doc","doc",1913296891));
var arglists_30073 = cljs.core.get.call(null,map__30031_30071__$1,new cljs.core.Keyword(null,"arglists","arglists",1661989754));
cljs.core.println.call(null);
cljs.core.println.call(null," ",name_30069);
cljs.core.println.call(null," ",arglists_30073);
if(cljs.core.truth_(doc_30072)){
cljs.core.println.call(null," ",doc_30072);
} else {
}
var G__30074 = seq__30014_30064;
var G__30075 = chunk__30015_30065;
var G__30076 = count__30016_30066;
var G__30077 = (i__30017_30067 + (1));
seq__30014_30064 = G__30074;
chunk__30015_30065 = G__30075;
count__30016_30066 = G__30076;
i__30017_30067 = G__30077;
continue;
} else {
var temp__5720__auto___30078 = cljs.core.seq.call(null,seq__30014_30064);
if(temp__5720__auto___30078){
var seq__30014_30079__$1 = temp__5720__auto___30078;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__30014_30079__$1)){
var c__4550__auto___30080 = cljs.core.chunk_first.call(null,seq__30014_30079__$1);
var G__30081 = cljs.core.chunk_rest.call(null,seq__30014_30079__$1);
var G__30082 = c__4550__auto___30080;
var G__30083 = cljs.core.count.call(null,c__4550__auto___30080);
var G__30084 = (0);
seq__30014_30064 = G__30081;
chunk__30015_30065 = G__30082;
count__30016_30066 = G__30083;
i__30017_30067 = G__30084;
continue;
} else {
var vec__30033_30085 = cljs.core.first.call(null,seq__30014_30079__$1);
var name_30086 = cljs.core.nth.call(null,vec__30033_30085,(0),null);
var map__30036_30087 = cljs.core.nth.call(null,vec__30033_30085,(1),null);
var map__30036_30088__$1 = (((((!((map__30036_30087 == null))))?(((((map__30036_30087.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30036_30087.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30036_30087):map__30036_30087);
var doc_30089 = cljs.core.get.call(null,map__30036_30088__$1,new cljs.core.Keyword(null,"doc","doc",1913296891));
var arglists_30090 = cljs.core.get.call(null,map__30036_30088__$1,new cljs.core.Keyword(null,"arglists","arglists",1661989754));
cljs.core.println.call(null);
cljs.core.println.call(null," ",name_30086);
cljs.core.println.call(null," ",arglists_30090);
if(cljs.core.truth_(doc_30089)){
cljs.core.println.call(null," ",doc_30089);
} else {
}
var G__30091 = cljs.core.next.call(null,seq__30014_30079__$1);
var G__30092 = null;
var G__30093 = (0);
var G__30094 = (0);
seq__30014_30064 = G__30091;
chunk__30015_30065 = G__30092;
count__30016_30066 = G__30093;
i__30017_30067 = G__30094;
continue;
}
} else {
}
}
break;
}
} else {
}
if(cljs.core.truth_(n)){
var temp__5720__auto__ = cljs.spec.alpha.get_spec.call(null,cljs.core.symbol.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.ns_name.call(null,n)),cljs.core.name.call(null,nm)));
if(cljs.core.truth_(temp__5720__auto__)){
var fnspec = temp__5720__auto__;
cljs.core.print.call(null,"Spec");
var seq__30038 = cljs.core.seq.call(null,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"args","args",1315556576),new cljs.core.Keyword(null,"ret","ret",-468222814),new cljs.core.Keyword(null,"fn","fn",-1175266204)], null));
var chunk__30039 = null;
var count__30040 = (0);
var i__30041 = (0);
while(true){
if((i__30041 < count__30040)){
var role = cljs.core._nth.call(null,chunk__30039,i__30041);
var temp__5720__auto___30095__$1 = cljs.core.get.call(null,fnspec,role);
if(cljs.core.truth_(temp__5720__auto___30095__$1)){
var spec_30096 = temp__5720__auto___30095__$1;
cljs.core.print.call(null,["\n ",cljs.core.name.call(null,role),":"].join(''),cljs.spec.alpha.describe.call(null,spec_30096));
} else {
}
var G__30097 = seq__30038;
var G__30098 = chunk__30039;
var G__30099 = count__30040;
var G__30100 = (i__30041 + (1));
seq__30038 = G__30097;
chunk__30039 = G__30098;
count__30040 = G__30099;
i__30041 = G__30100;
continue;
} else {
var temp__5720__auto____$1 = cljs.core.seq.call(null,seq__30038);
if(temp__5720__auto____$1){
var seq__30038__$1 = temp__5720__auto____$1;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__30038__$1)){
var c__4550__auto__ = cljs.core.chunk_first.call(null,seq__30038__$1);
var G__30101 = cljs.core.chunk_rest.call(null,seq__30038__$1);
var G__30102 = c__4550__auto__;
var G__30103 = cljs.core.count.call(null,c__4550__auto__);
var G__30104 = (0);
seq__30038 = G__30101;
chunk__30039 = G__30102;
count__30040 = G__30103;
i__30041 = G__30104;
continue;
} else {
var role = cljs.core.first.call(null,seq__30038__$1);
var temp__5720__auto___30105__$2 = cljs.core.get.call(null,fnspec,role);
if(cljs.core.truth_(temp__5720__auto___30105__$2)){
var spec_30106 = temp__5720__auto___30105__$2;
cljs.core.print.call(null,["\n ",cljs.core.name.call(null,role),":"].join(''),cljs.spec.alpha.describe.call(null,spec_30106));
} else {
}
var G__30107 = cljs.core.next.call(null,seq__30038__$1);
var G__30108 = null;
var G__30109 = (0);
var G__30110 = (0);
seq__30038 = G__30107;
chunk__30039 = G__30108;
count__30040 = G__30109;
i__30041 = G__30110;
continue;
}
} else {
return null;
}
}
break;
}
} else {
return null;
}
} else {
return null;
}
}
});
/**
* Constructs a data representation for a Error with keys:
* :cause - root cause message
* :phase - error phase
* :via - cause chain, with cause keys:
* :type - exception class symbol
* :message - exception message
* :data - ex-data
* :at - top stack element
* :trace - root cause stack elements
*/
cljs.repl.Error__GT_map = (function cljs$repl$Error__GT_map(o){
var base = (function (t){
return cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"type","type",1174270348),(((t instanceof cljs.core.ExceptionInfo))?new cljs.core.Symbol(null,"ExceptionInfo","ExceptionInfo",294935087,null):(((t instanceof EvalError))?new cljs.core.Symbol("js","EvalError","js/EvalError",1793498501,null):(((t instanceof RangeError))?new cljs.core.Symbol("js","RangeError","js/RangeError",1703848089,null):(((t instanceof ReferenceError))?new cljs.core.Symbol("js","ReferenceError","js/ReferenceError",-198403224,null):(((t instanceof SyntaxError))?new cljs.core.Symbol("js","SyntaxError","js/SyntaxError",-1527651665,null):(((t instanceof URIError))?new cljs.core.Symbol("js","URIError","js/URIError",505061350,null):(((t instanceof Error))?new cljs.core.Symbol("js","Error","js/Error",-1692659266,null):null
)))))))], null),(function (){var temp__5720__auto__ = cljs.core.ex_message.call(null,t);
if(cljs.core.truth_(temp__5720__auto__)){
var msg = temp__5720__auto__;
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"message","message",-406056002),msg], null);
} else {
return null;
}
})(),(function (){var temp__5720__auto__ = cljs.core.ex_data.call(null,t);
if(cljs.core.truth_(temp__5720__auto__)){
var ed = temp__5720__auto__;
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"data","data",-232669377),ed], null);
} else {
return null;
}
})());
});
var via = (function (){var via = cljs.core.PersistentVector.EMPTY;
var t = o;
while(true){
if(cljs.core.truth_(t)){
var G__30111 = cljs.core.conj.call(null,via,t);
var G__30112 = cljs.core.ex_cause.call(null,t);
via = G__30111;
t = G__30112;
continue;
} else {
return via;
}
break;
}
})();
var root = cljs.core.peek.call(null,via);
return cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"via","via",-1904457336),cljs.core.vec.call(null,cljs.core.map.call(null,base,via)),new cljs.core.Keyword(null,"trace","trace",-1082747415),null], null),(function (){var temp__5720__auto__ = cljs.core.ex_message.call(null,root);
if(cljs.core.truth_(temp__5720__auto__)){
var root_msg = temp__5720__auto__;
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"cause","cause",231901252),root_msg], null);
} else {
return null;
}
})(),(function (){var temp__5720__auto__ = cljs.core.ex_data.call(null,root);
if(cljs.core.truth_(temp__5720__auto__)){
var data = temp__5720__auto__;
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"data","data",-232669377),data], null);
} else {
return null;
}
})(),(function (){var temp__5720__auto__ = new cljs.core.Keyword("clojure.error","phase","clojure.error/phase",275140358).cljs$core$IFn$_invoke$arity$1(cljs.core.ex_data.call(null,o));
if(cljs.core.truth_(temp__5720__auto__)){
var phase = temp__5720__auto__;
return new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"phase","phase",575722892),phase], null);
} else {
return null;
}
})());
});
/**
* Returns an analysis of the phase, error, cause, and location of an error that occurred
* based on Throwable data, as returned by Throwable->map. All attributes other than phase
* are optional:
* :clojure.error/phase - keyword phase indicator, one of:
* :read-source :compile-syntax-check :compilation :macro-syntax-check :macroexpansion
* :execution :read-eval-result :print-eval-result
* :clojure.error/source - file name (no path)
* :clojure.error/line - integer line number
* :clojure.error/column - integer column number
* :clojure.error/symbol - symbol being expanded/compiled/invoked
* :clojure.error/class - cause exception class symbol
* :clojure.error/cause - cause exception message
* :clojure.error/spec - explain-data for spec error
*/
cljs.repl.ex_triage = (function cljs$repl$ex_triage(datafied_throwable){
var map__30115 = datafied_throwable;
var map__30115__$1 = (((((!((map__30115 == null))))?(((((map__30115.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30115.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30115):map__30115);
var via = cljs.core.get.call(null,map__30115__$1,new cljs.core.Keyword(null,"via","via",-1904457336));
var trace = cljs.core.get.call(null,map__30115__$1,new cljs.core.Keyword(null,"trace","trace",-1082747415));
var phase = cljs.core.get.call(null,map__30115__$1,new cljs.core.Keyword(null,"phase","phase",575722892),new cljs.core.Keyword(null,"execution","execution",253283524));
var map__30116 = cljs.core.last.call(null,via);
var map__30116__$1 = (((((!((map__30116 == null))))?(((((map__30116.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30116.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30116):map__30116);
var type = cljs.core.get.call(null,map__30116__$1,new cljs.core.Keyword(null,"type","type",1174270348));
var message = cljs.core.get.call(null,map__30116__$1,new cljs.core.Keyword(null,"message","message",-406056002));
var data = cljs.core.get.call(null,map__30116__$1,new cljs.core.Keyword(null,"data","data",-232669377));
var map__30117 = data;
var map__30117__$1 = (((((!((map__30117 == null))))?(((((map__30117.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30117.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30117):map__30117);
var problems = cljs.core.get.call(null,map__30117__$1,new cljs.core.Keyword("cljs.spec.alpha","problems","cljs.spec.alpha/problems",447400814));
var fn = cljs.core.get.call(null,map__30117__$1,new cljs.core.Keyword("cljs.spec.alpha","fn","cljs.spec.alpha/fn",408600443));
var caller = cljs.core.get.call(null,map__30117__$1,new cljs.core.Keyword("cljs.spec.test.alpha","caller","cljs.spec.test.alpha/caller",-398302390));
var map__30118 = new cljs.core.Keyword(null,"data","data",-232669377).cljs$core$IFn$_invoke$arity$1(cljs.core.first.call(null,via));
var map__30118__$1 = (((((!((map__30118 == null))))?(((((map__30118.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30118.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30118):map__30118);
var top_data = map__30118__$1;
var source = cljs.core.get.call(null,map__30118__$1,new cljs.core.Keyword("clojure.error","source","clojure.error/source",-2011936397));
return cljs.core.assoc.call(null,(function (){var G__30123 = phase;
var G__30123__$1 = (((G__30123 instanceof cljs.core.Keyword))?G__30123.fqn:null);
switch (G__30123__$1) {
case "read-source":
var map__30124 = data;
var map__30124__$1 = (((((!((map__30124 == null))))?(((((map__30124.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30124.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30124):map__30124);
var line = cljs.core.get.call(null,map__30124__$1,new cljs.core.Keyword("clojure.error","line","clojure.error/line",-1816287471));
var column = cljs.core.get.call(null,map__30124__$1,new cljs.core.Keyword("clojure.error","column","clojure.error/column",304721553));
var G__30126 = cljs.core.merge.call(null,new cljs.core.Keyword(null,"data","data",-232669377).cljs$core$IFn$_invoke$arity$1(cljs.core.second.call(null,via)),top_data);
var G__30126__$1 = (cljs.core.truth_(source)?cljs.core.assoc.call(null,G__30126,new cljs.core.Keyword("clojure.error","source","clojure.error/source",-2011936397),source):G__30126);
var G__30126__$2 = (cljs.core.truth_(new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 2, ["NO_SOURCE_PATH",null,"NO_SOURCE_FILE",null], null), null).call(null,source))?cljs.core.dissoc.call(null,G__30126__$1,new cljs.core.Keyword("clojure.error","source","clojure.error/source",-2011936397)):G__30126__$1);
if(cljs.core.truth_(message)){
return cljs.core.assoc.call(null,G__30126__$2,new cljs.core.Keyword("clojure.error","cause","clojure.error/cause",-1879175742),message);
} else {
return G__30126__$2;
}
break;
case "compile-syntax-check":
case "compilation":
case "macro-syntax-check":
case "macroexpansion":
var G__30127 = top_data;
var G__30127__$1 = (cljs.core.truth_(source)?cljs.core.assoc.call(null,G__30127,new cljs.core.Keyword("clojure.error","source","clojure.error/source",-2011936397),source):G__30127);
var G__30127__$2 = (cljs.core.truth_(new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 2, ["NO_SOURCE_PATH",null,"NO_SOURCE_FILE",null], null), null).call(null,source))?cljs.core.dissoc.call(null,G__30127__$1,new cljs.core.Keyword("clojure.error","source","clojure.error/source",-2011936397)):G__30127__$1);
var G__30127__$3 = (cljs.core.truth_(type)?cljs.core.assoc.call(null,G__30127__$2,new cljs.core.Keyword("clojure.error","class","clojure.error/class",278435890),type):G__30127__$2);
var G__30127__$4 = (cljs.core.truth_(message)?cljs.core.assoc.call(null,G__30127__$3,new cljs.core.Keyword("clojure.error","cause","clojure.error/cause",-1879175742),message):G__30127__$3);
if(cljs.core.truth_(problems)){
return cljs.core.assoc.call(null,G__30127__$4,new cljs.core.Keyword("clojure.error","spec","clojure.error/spec",2055032595),data);
} else {
return G__30127__$4;
}
break;
case "read-eval-result":
case "print-eval-result":
var vec__30128 = cljs.core.first.call(null,trace);
var source__$1 = cljs.core.nth.call(null,vec__30128,(0),null);
var method = cljs.core.nth.call(null,vec__30128,(1),null);
var file = cljs.core.nth.call(null,vec__30128,(2),null);
var line = cljs.core.nth.call(null,vec__30128,(3),null);
var G__30131 = top_data;
var G__30131__$1 = (cljs.core.truth_(line)?cljs.core.assoc.call(null,G__30131,new cljs.core.Keyword("clojure.error","line","clojure.error/line",-1816287471),line):G__30131);
var G__30131__$2 = (cljs.core.truth_(file)?cljs.core.assoc.call(null,G__30131__$1,new cljs.core.Keyword("clojure.error","source","clojure.error/source",-2011936397),file):G__30131__$1);
var G__30131__$3 = (cljs.core.truth_((function (){var and__4120__auto__ = source__$1;
if(cljs.core.truth_(and__4120__auto__)){
return method;
} else {
return and__4120__auto__;
}
})())?cljs.core.assoc.call(null,G__30131__$2,new cljs.core.Keyword("clojure.error","symbol","clojure.error/symbol",1544821994),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[source__$1,method],null))):G__30131__$2);
var G__30131__$4 = (cljs.core.truth_(type)?cljs.core.assoc.call(null,G__30131__$3,new cljs.core.Keyword("clojure.error","class","clojure.error/class",278435890),type):G__30131__$3);
if(cljs.core.truth_(message)){
return cljs.core.assoc.call(null,G__30131__$4,new cljs.core.Keyword("clojure.error","cause","clojure.error/cause",-1879175742),message);
} else {
return G__30131__$4;
}
break;
case "execution":
var vec__30132 = cljs.core.first.call(null,trace);
var source__$1 = cljs.core.nth.call(null,vec__30132,(0),null);
var method = cljs.core.nth.call(null,vec__30132,(1),null);
var file = cljs.core.nth.call(null,vec__30132,(2),null);
var line = cljs.core.nth.call(null,vec__30132,(3),null);
var file__$1 = cljs.core.first.call(null,cljs.core.remove.call(null,((function (vec__30132,source__$1,method,file,line,G__30123,G__30123__$1,map__30115,map__30115__$1,via,trace,phase,map__30116,map__30116__$1,type,message,data,map__30117,map__30117__$1,problems,fn,caller,map__30118,map__30118__$1,top_data,source){
return (function (p1__30114_SHARP_){
var or__4131__auto__ = (p1__30114_SHARP_ == null);
if(or__4131__auto__){
return or__4131__auto__;
} else {
return new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 2, ["NO_SOURCE_PATH",null,"NO_SOURCE_FILE",null], null), null).call(null,p1__30114_SHARP_);
}
});})(vec__30132,source__$1,method,file,line,G__30123,G__30123__$1,map__30115,map__30115__$1,via,trace,phase,map__30116,map__30116__$1,type,message,data,map__30117,map__30117__$1,problems,fn,caller,map__30118,map__30118__$1,top_data,source))
,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"file","file",-1269645878).cljs$core$IFn$_invoke$arity$1(caller),file], null)));
var err_line = (function (){var or__4131__auto__ = new cljs.core.Keyword(null,"line","line",212345235).cljs$core$IFn$_invoke$arity$1(caller);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return line;
}
})();
var G__30135 = new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword("clojure.error","class","clojure.error/class",278435890),type], null);
var G__30135__$1 = (cljs.core.truth_(err_line)?cljs.core.assoc.call(null,G__30135,new cljs.core.Keyword("clojure.error","line","clojure.error/line",-1816287471),err_line):G__30135);
var G__30135__$2 = (cljs.core.truth_(message)?cljs.core.assoc.call(null,G__30135__$1,new cljs.core.Keyword("clojure.error","cause","clojure.error/cause",-1879175742),message):G__30135__$1);
var G__30135__$3 = (cljs.core.truth_((function (){var or__4131__auto__ = fn;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
var and__4120__auto__ = source__$1;
if(cljs.core.truth_(and__4120__auto__)){
return method;
} else {
return and__4120__auto__;
}
}
})())?cljs.core.assoc.call(null,G__30135__$2,new cljs.core.Keyword("clojure.error","symbol","clojure.error/symbol",1544821994),(function (){var or__4131__auto__ = fn;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return (new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[source__$1,method],null));
}
})()):G__30135__$2);
var G__30135__$4 = (cljs.core.truth_(file__$1)?cljs.core.assoc.call(null,G__30135__$3,new cljs.core.Keyword("clojure.error","source","clojure.error/source",-2011936397),file__$1):G__30135__$3);
if(cljs.core.truth_(problems)){
return cljs.core.assoc.call(null,G__30135__$4,new cljs.core.Keyword("clojure.error","spec","clojure.error/spec",2055032595),data);
} else {
return G__30135__$4;
}
break;
default:
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__30123__$1)].join('')));
}
})(),new cljs.core.Keyword("clojure.error","phase","clojure.error/phase",275140358),phase);
});
/**
* Returns a string from exception data, as produced by ex-triage.
* The first line summarizes the exception phase and location.
* The subsequent lines describe the cause.
*/
cljs.repl.ex_str = (function cljs$repl$ex_str(p__30139){
var map__30140 = p__30139;
var map__30140__$1 = (((((!((map__30140 == null))))?(((((map__30140.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__30140.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__30140):map__30140);
var triage_data = map__30140__$1;
var phase = cljs.core.get.call(null,map__30140__$1,new cljs.core.Keyword("clojure.error","phase","clojure.error/phase",275140358));
var source = cljs.core.get.call(null,map__30140__$1,new cljs.core.Keyword("clojure.error","source","clojure.error/source",-2011936397));
var line = cljs.core.get.call(null,map__30140__$1,new cljs.core.Keyword("clojure.error","line","clojure.error/line",-1816287471));
var column = cljs.core.get.call(null,map__30140__$1,new cljs.core.Keyword("clojure.error","column","clojure.error/column",304721553));
var symbol = cljs.core.get.call(null,map__30140__$1,new cljs.core.Keyword("clojure.error","symbol","clojure.error/symbol",1544821994));
var class$ = cljs.core.get.call(null,map__30140__$1,new cljs.core.Keyword("clojure.error","class","clojure.error/class",278435890));
var cause = cljs.core.get.call(null,map__30140__$1,new cljs.core.Keyword("clojure.error","cause","clojure.error/cause",-1879175742));
var spec = cljs.core.get.call(null,map__30140__$1,new cljs.core.Keyword("clojure.error","spec","clojure.error/spec",2055032595));
var loc = [cljs.core.str.cljs$core$IFn$_invoke$arity$1((function (){var or__4131__auto__ = source;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return "<cljs repl>";
}
})()),":",cljs.core.str.cljs$core$IFn$_invoke$arity$1((function (){var or__4131__auto__ = line;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return (1);
}
})()),(cljs.core.truth_(column)?[":",cljs.core.str.cljs$core$IFn$_invoke$arity$1(column)].join(''):"")].join('');
var class_name = cljs.core.name.call(null,(function (){var or__4131__auto__ = class$;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return "";
}
})());
var simple_class = class_name;
var cause_type = ((cljs.core.contains_QMARK_.call(null,new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 2, ["RuntimeException",null,"Exception",null], null), null),simple_class))?"":[" (",simple_class,")"].join(''));
var format = goog.string.format;
var G__30142 = phase;
var G__30142__$1 = (((G__30142 instanceof cljs.core.Keyword))?G__30142.fqn:null);
switch (G__30142__$1) {
case "read-source":
return format.call(null,"Syntax error reading source at (%s).\n%s\n",loc,cause);
break;
case "macro-syntax-check":
return format.call(null,"Syntax error macroexpanding %sat (%s).\n%s",(cljs.core.truth_(symbol)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(symbol)," "].join(''):""),loc,(cljs.core.truth_(spec)?(function (){var sb__4661__auto__ = (new goog.string.StringBuffer());
var _STAR_print_newline_STAR__orig_val__30143_30152 = cljs.core._STAR_print_newline_STAR_;
var _STAR_print_fn_STAR__orig_val__30144_30153 = cljs.core._STAR_print_fn_STAR_;
var _STAR_print_newline_STAR__temp_val__30145_30154 = true;
var _STAR_print_fn_STAR__temp_val__30146_30155 = ((function (_STAR_print_newline_STAR__orig_val__30143_30152,_STAR_print_fn_STAR__orig_val__30144_30153,_STAR_print_newline_STAR__temp_val__30145_30154,sb__4661__auto__,G__30142,G__30142__$1,loc,class_name,simple_class,cause_type,format,map__30140,map__30140__$1,triage_data,phase,source,line,column,symbol,class$,cause,spec){
return (function (x__4662__auto__){
return sb__4661__auto__.append(x__4662__auto__);
});})(_STAR_print_newline_STAR__orig_val__30143_30152,_STAR_print_fn_STAR__orig_val__30144_30153,_STAR_print_newline_STAR__temp_val__30145_30154,sb__4661__auto__,G__30142,G__30142__$1,loc,class_name,simple_class,cause_type,format,map__30140,map__30140__$1,triage_data,phase,source,line,column,symbol,class$,cause,spec))
;
cljs.core._STAR_print_newline_STAR_ = _STAR_print_newline_STAR__temp_val__30145_30154;
cljs.core._STAR_print_fn_STAR_ = _STAR_print_fn_STAR__temp_val__30146_30155;
try{cljs.spec.alpha.explain_out.call(null,cljs.core.update.call(null,spec,new cljs.core.Keyword("cljs.spec.alpha","problems","cljs.spec.alpha/problems",447400814),((function (_STAR_print_newline_STAR__orig_val__30143_30152,_STAR_print_fn_STAR__orig_val__30144_30153,_STAR_print_newline_STAR__temp_val__30145_30154,_STAR_print_fn_STAR__temp_val__30146_30155,sb__4661__auto__,G__30142,G__30142__$1,loc,class_name,simple_class,cause_type,format,map__30140,map__30140__$1,triage_data,phase,source,line,column,symbol,class$,cause,spec){
return (function (probs){
return cljs.core.map.call(null,((function (_STAR_print_newline_STAR__orig_val__30143_30152,_STAR_print_fn_STAR__orig_val__30144_30153,_STAR_print_newline_STAR__temp_val__30145_30154,_STAR_print_fn_STAR__temp_val__30146_30155,sb__4661__auto__,G__30142,G__30142__$1,loc,class_name,simple_class,cause_type,format,map__30140,map__30140__$1,triage_data,phase,source,line,column,symbol,class$,cause,spec){
return (function (p1__30137_SHARP_){
return cljs.core.dissoc.call(null,p1__30137_SHARP_,new cljs.core.Keyword(null,"in","in",-1531184865));
});})(_STAR_print_newline_STAR__orig_val__30143_30152,_STAR_print_fn_STAR__orig_val__30144_30153,_STAR_print_newline_STAR__temp_val__30145_30154,_STAR_print_fn_STAR__temp_val__30146_30155,sb__4661__auto__,G__30142,G__30142__$1,loc,class_name,simple_class,cause_type,format,map__30140,map__30140__$1,triage_data,phase,source,line,column,symbol,class$,cause,spec))
,probs);
});})(_STAR_print_newline_STAR__orig_val__30143_30152,_STAR_print_fn_STAR__orig_val__30144_30153,_STAR_print_newline_STAR__temp_val__30145_30154,_STAR_print_fn_STAR__temp_val__30146_30155,sb__4661__auto__,G__30142,G__30142__$1,loc,class_name,simple_class,cause_type,format,map__30140,map__30140__$1,triage_data,phase,source,line,column,symbol,class$,cause,spec))
)
);
}finally {cljs.core._STAR_print_fn_STAR_ = _STAR_print_fn_STAR__orig_val__30144_30153;
cljs.core._STAR_print_newline_STAR_ = _STAR_print_newline_STAR__orig_val__30143_30152;
}
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb__4661__auto__);
})():format.call(null,"%s\n",cause)));
break;
case "macroexpansion":
return format.call(null,"Unexpected error%s macroexpanding %sat (%s).\n%s\n",cause_type,(cljs.core.truth_(symbol)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(symbol)," "].join(''):""),loc,cause);
break;
case "compile-syntax-check":
return format.call(null,"Syntax error%s compiling %sat (%s).\n%s\n",cause_type,(cljs.core.truth_(symbol)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(symbol)," "].join(''):""),loc,cause);
break;
case "compilation":
return format.call(null,"Unexpected error%s compiling %sat (%s).\n%s\n",cause_type,(cljs.core.truth_(symbol)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(symbol)," "].join(''):""),loc,cause);
break;
case "read-eval-result":
return format.call(null,"Error reading eval result%s at %s (%s).\n%s\n",cause_type,symbol,loc,cause);
break;
case "print-eval-result":
return format.call(null,"Error printing return value%s at %s (%s).\n%s\n",cause_type,symbol,loc,cause);
break;
case "execution":
if(cljs.core.truth_(spec)){
return format.call(null,"Execution error - invalid arguments to %s at (%s).\n%s",symbol,loc,(function (){var sb__4661__auto__ = (new goog.string.StringBuffer());
var _STAR_print_newline_STAR__orig_val__30147_30156 = cljs.core._STAR_print_newline_STAR_;
var _STAR_print_fn_STAR__orig_val__30148_30157 = cljs.core._STAR_print_fn_STAR_;
var _STAR_print_newline_STAR__temp_val__30149_30158 = true;
var _STAR_print_fn_STAR__temp_val__30150_30159 = ((function (_STAR_print_newline_STAR__orig_val__30147_30156,_STAR_print_fn_STAR__orig_val__30148_30157,_STAR_print_newline_STAR__temp_val__30149_30158,sb__4661__auto__,G__30142,G__30142__$1,loc,class_name,simple_class,cause_type,format,map__30140,map__30140__$1,triage_data,phase,source,line,column,symbol,class$,cause,spec){
return (function (x__4662__auto__){
return sb__4661__auto__.append(x__4662__auto__);
});})(_STAR_print_newline_STAR__orig_val__30147_30156,_STAR_print_fn_STAR__orig_val__30148_30157,_STAR_print_newline_STAR__temp_val__30149_30158,sb__4661__auto__,G__30142,G__30142__$1,loc,class_name,simple_class,cause_type,format,map__30140,map__30140__$1,triage_data,phase,source,line,column,symbol,class$,cause,spec))
;
cljs.core._STAR_print_newline_STAR_ = _STAR_print_newline_STAR__temp_val__30149_30158;
cljs.core._STAR_print_fn_STAR_ = _STAR_print_fn_STAR__temp_val__30150_30159;
try{cljs.spec.alpha.explain_out.call(null,cljs.core.update.call(null,spec,new cljs.core.Keyword("cljs.spec.alpha","problems","cljs.spec.alpha/problems",447400814),((function (_STAR_print_newline_STAR__orig_val__30147_30156,_STAR_print_fn_STAR__orig_val__30148_30157,_STAR_print_newline_STAR__temp_val__30149_30158,_STAR_print_fn_STAR__temp_val__30150_30159,sb__4661__auto__,G__30142,G__30142__$1,loc,class_name,simple_class,cause_type,format,map__30140,map__30140__$1,triage_data,phase,source,line,column,symbol,class$,cause,spec){
return (function (probs){
return cljs.core.map.call(null,((function (_STAR_print_newline_STAR__orig_val__30147_30156,_STAR_print_fn_STAR__orig_val__30148_30157,_STAR_print_newline_STAR__temp_val__30149_30158,_STAR_print_fn_STAR__temp_val__30150_30159,sb__4661__auto__,G__30142,G__30142__$1,loc,class_name,simple_class,cause_type,format,map__30140,map__30140__$1,triage_data,phase,source,line,column,symbol,class$,cause,spec){
return (function (p1__30138_SHARP_){
return cljs.core.dissoc.call(null,p1__30138_SHARP_,new cljs.core.Keyword(null,"in","in",-1531184865));
});})(_STAR_print_newline_STAR__orig_val__30147_30156,_STAR_print_fn_STAR__orig_val__30148_30157,_STAR_print_newline_STAR__temp_val__30149_30158,_STAR_print_fn_STAR__temp_val__30150_30159,sb__4661__auto__,G__30142,G__30142__$1,loc,class_name,simple_class,cause_type,format,map__30140,map__30140__$1,triage_data,phase,source,line,column,symbol,class$,cause,spec))
,probs);
});})(_STAR_print_newline_STAR__orig_val__30147_30156,_STAR_print_fn_STAR__orig_val__30148_30157,_STAR_print_newline_STAR__temp_val__30149_30158,_STAR_print_fn_STAR__temp_val__30150_30159,sb__4661__auto__,G__30142,G__30142__$1,loc,class_name,simple_class,cause_type,format,map__30140,map__30140__$1,triage_data,phase,source,line,column,symbol,class$,cause,spec))
)
);
}finally {cljs.core._STAR_print_fn_STAR_ = _STAR_print_fn_STAR__orig_val__30148_30157;
cljs.core._STAR_print_newline_STAR_ = _STAR_print_newline_STAR__orig_val__30147_30156;
}
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb__4661__auto__);
})());
} else {
return format.call(null,"Execution error%s at %s(%s).\n%s\n",cause_type,(cljs.core.truth_(symbol)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(symbol)," "].join(''):""),loc,cause);
}
break;
default:
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__30142__$1)].join('')));
}
});
cljs.repl.error__GT_str = (function cljs$repl$error__GT_str(error){
return cljs.repl.ex_str.call(null,cljs.repl.ex_triage.call(null,cljs.repl.Error__GT_map.call(null,error)));
});
//# sourceMappingURL=repl.js.map?rel=1582560151693

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,183 @@
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(ns cljs.spec.gen.alpha
(:refer-clojure :exclude [boolean cat hash-map list map not-empty set vector
char double int keyword symbol string uuid delay shuffle])
(:require-macros [cljs.core :as c]
[cljs.spec.gen.alpha :as gen :refer [dynaload lazy-combinators lazy-prims]])
(:require [cljs.core :as c])
(:import (goog Uri)))
(deftype LazyVar [f ^:mutable cached]
IDeref
(-deref [this]
(if-not (nil? cached)
cached
(let [x (f)]
(when-not (nil? x)
(set! cached x))
x))))
(def ^:private quick-check-ref
(dynaload 'clojure.test.check/quick-check))
(defn quick-check
[& args]
(apply @quick-check-ref args))
(def ^:private for-all*-ref
(dynaload 'clojure.test.check.properties/for-all*))
(defn for-all*
"Dynamically loaded clojure.test.check.properties/for-all*."
[& args]
(apply @for-all*-ref args))
(let [g? (dynaload 'clojure.test.check.generators/generator?)
g (dynaload 'clojure.test.check.generators/generate)
mkg (dynaload 'clojure.test.check.generators/->Generator)]
(defn- generator?
[x]
(@g? x))
(defn- generator
[gfn]
(@mkg gfn))
(defn generate
"Generate a single value using generator."
[generator]
(@g generator)))
(defn ^:skip-wiki delay-impl
[gfnd]
;;N.B. depends on test.check impl details
(generator (fn [rnd size]
((:gen @gfnd) rnd size))))
;(defn gen-for-name
; "Dynamically loads test.check generator named s."
; [s]
; (let [g (dynaload s)]
; (if (generator? g)
; g
; (throw (js/Error. (str "Var " s " is not a generator"))))))
(lazy-combinators hash-map list map not-empty set vector vector-distinct fmap elements
bind choose one-of such-that tuple sample return
large-integer* double* frequency shuffle)
(lazy-prims any any-printable boolean char char-alpha char-alphanumeric char-ascii double
int keyword keyword-ns large-integer ratio simple-type simple-type-printable
string string-ascii string-alphanumeric symbol symbol-ns uuid)
(defn cat
"Returns a generator of a sequence catenated from results of
gens, each of which should generate something sequential."
[& gens]
(fmap #(apply concat %)
(apply tuple gens)))
(defn- ^boolean qualified? [ident] (not (nil? (namespace ident))))
(def ^:private
gen-builtins
(c/delay
(let [simple (simple-type-printable)]
{any? (one-of [(return nil) (any-printable)])
some? (such-that some? (any-printable))
number? (one-of [(large-integer) (double)])
integer? (large-integer)
int? (large-integer)
pos-int? (large-integer* {:min 1})
neg-int? (large-integer* {:max -1})
nat-int? (large-integer* {:min 0})
float? (double)
double? (double)
string? (string-alphanumeric)
ident? (one-of [(keyword-ns) (symbol-ns)])
simple-ident? (one-of [(keyword) (symbol)])
qualified-ident? (such-that qualified? (one-of [(keyword-ns) (symbol-ns)]))
keyword? (keyword-ns)
simple-keyword? (keyword)
qualified-keyword? (such-that qualified? (keyword-ns))
symbol? (symbol-ns)
simple-symbol? (symbol)
qualified-symbol? (such-that qualified? (symbol-ns))
uuid? (uuid)
uri? (fmap #(Uri. (str "http://" % ".com")) (uuid))
inst? (fmap #(js/Date. %)
(large-integer))
seqable? (one-of [(return nil)
(list simple)
(vector simple)
(map simple simple)
(set simple)
(string-alphanumeric)])
indexed? (vector simple)
map? (map simple simple)
vector? (vector simple)
list? (list simple)
seq? (list simple)
char? (char)
set? (set simple)
nil? (return nil)
false? (return false)
true? (return true)
boolean? (boolean)
zero? (return 0)
;rational? (one-of [(large-integer) (ratio)])
coll? (one-of [(map simple simple)
(list simple)
(vector simple)
(set simple)])
empty? (elements [nil '() [] {} #{}])
associative? (one-of [(map simple simple) (vector simple)])
sequential? (one-of [(list simple) (vector simple)])
;ratio? (such-that ratio? (ratio))
})))
(defn gen-for-pred
"Given a predicate, returns a built-in generator if one exists."
[pred]
(if (set? pred)
(elements pred)
(get @gen-builtins pred)))
(comment
(require 'clojure.test.check)
(require 'clojure.test.check.properties)
(require 'cljs.spec.gen)
(in-ns 'cljs.spec.gen)
;; combinators, see call to lazy-combinators above for complete list
(generate (one-of [(gen-for-pred integer?) (gen-for-pred string?)]))
(generate (such-that #(< 10000 %) (gen-for-pred integer?)))
(let [reqs {:a (gen-for-pred number?)
:b (gen-for-pred keyword?)}
opts {:c (gen-for-pred string?)}]
(generate (bind (choose 0 (count opts))
#(let [args (concat (seq reqs) (c/shuffle (seq opts)))]
(->> args
(take (+ % (count reqs)))
(mapcat identity)
(apply hash-map))))))
(generate (cat (list (gen-for-pred string?))
(list (gen-for-pred integer?))))
;; load your own generator
;(gen-for-name 'clojure.test.check.generators/int)
;; failure modes
;(gen-for-name 'unqualified)
;(gen-for-name 'clojure.core/+)
;(gen-for-name 'clojure.core/name-does-not-exist)
;(gen-for-name 'ns.does.not.exist/f)
)

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,716 @@
;; Copyright (c) Rich Hickey. All rights reserved.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns cljs.stacktrace
(:require #?@(:clj [[cljs.util :as util]
[clojure.java.io :as io]]
:cljs [[goog.string :as gstring]])
[clojure.string :as string])
#?(:clj (:import [java.util.regex Pattern]
[java.io File])))
(defmulti parse-stacktrace
"Parse a JavaScript stacktrace string into a canonical data form. The
arguments:
repl-env - the repl environment, an optional map with :host and :port keys
if the stacktrace includes url, not file references
st - the original stacktrace string to parse
err - an error map. :ua-product key defines the type of stacktrace parser
to use, for example :chrome
opts - additional options. :output-dir maybe given in this argument if
:host and :port do not apply, for example, a file path
The canonical stacktrace representation can easily be mapped to a
ClojureScript one see mapped-stacktrace and mapped-stacktrace-str"
(fn [repl-env st err opts] (:ua-product err)))
(defn parse-int [s]
#?(:clj (Long/parseLong s)
:cljs (js/parseInt s 10)))
(defn starts-with?
#?(:cljs {:tag boolean})
[^String s0 s1]
#?(:clj (.startsWith s0 s1)
:cljs (gstring/startsWith s0 s1)))
(defn ends-with?
#?(:cljs {:tag boolean})
[^String s0 s1]
#?(:clj (.endsWith s0 s1)
:cljs (gstring/endsWith s0 s1)))
(defn string->regex [s]
#?(:clj (Pattern/compile s)
:cljs (js/RegExp. s)))
(defn output-directory [opts]
#?(:clj (util/output-directory opts)
:cljs (or (:output-dir opts) "out")))
(defmethod parse-stacktrace :default
[repl-env st err opts] st)
(defn parse-file-line-column [flc]
(if-not (re-find #":" flc)
[flc nil nil]
(let [xs (string/split flc #":")
[pre [line column]]
(reduce
(fn [[pre post] [x i]]
(if (<= i 2)
[pre (conj post x)]
[(conj pre x) post]))
[[] []] (map vector xs (range (count xs) 0 -1)))
file (string/join ":" pre)]
[(cond-> file
(starts-with? file "(") (string/replace "(" ""))
(parse-int
(cond-> line
(ends-with? line ")") (string/replace ")" "")))
(parse-int
(cond-> column
(ends-with? column ")") (string/replace ")" "")))])))
(defn parse-file
"Given a browser file url convert it into a relative path that can be used
to locate the original source."
[{:keys [host host-port port] :as repl-env} file {:keys [asset-path] :as opts}]
(let [urlpat (if host
(string->regex
(str "http://" host ":" (or host-port port) "/"))
"")
match (if host
(re-find urlpat file)
(contains? opts :output-dir))]
(if match
(-> file
(string/replace urlpat "")
(string/replace
(string->regex
;; if :asset-path specified drop leading slash
(str "^" (or (and asset-path (string/replace asset-path #"^/" ""))
(output-directory opts)) "/"))
""))
(if-let [asset-root (:asset-root opts)]
(string/replace file asset-root "")
(throw
(ex-info (str "Could not relativize URL " file)
{:type :parse-stacktrace
:reason :relativize-url}))))))
;; -----------------------------------------------------------------------------
;; Chrome Stacktrace
(defn chrome-st-el->frame
[repl-env st-el opts]
(let [xs (-> st-el
(string/replace #"\s+at\s+" "")
(string/split #"\s+"))
[function flc] (if (== 1 (count xs))
[nil (first xs)]
[(first xs) (last xs)])
[file line column] (parse-file-line-column flc)]
(if (and file function line column)
{:file (parse-file repl-env file opts)
:function (string/replace function #"Object\." "")
:line line
:column column}
(when-not (string/blank? function)
{:file nil
:function (string/replace function #"Object\." "")
:line nil
:column nil}))))
(comment
(chrome-st-el->frame {:host "localhost" :port 9000}
"\tat cljs$core$ffirst (http://localhost:9000/out/cljs/core.js:5356:34)" {})
)
(defmethod parse-stacktrace :chrome
[repl-env st err opts]
(->> st
string/split-lines
(drop-while #(starts-with? % "Error"))
(take-while #(not (starts-with? % " at eval")))
(map #(chrome-st-el->frame repl-env % opts))
(remove nil?)
vec))
(comment
(parse-stacktrace {:host "localhost" :port 9000}
"Error: 1 is not ISeqable
at Object.cljs$core$seq [as seq] (http://localhost:9000/out/cljs/core.js:4258:8)
at Object.cljs$core$first [as first] (http://localhost:9000/out/cljs/core.js:4288:19)
at cljs$core$ffirst (http://localhost:9000/out/cljs/core.js:5356:34)
at http://localhost:9000/out/cljs/core.js:16971:89
at cljs.core.map.cljs$core$map__2 (http://localhost:9000/out/cljs/core.js:16972:3)
at http://localhost:9000/out/cljs/core.js:10981:129
at cljs.core.LazySeq.sval (http://localhost:9000/out/cljs/core.js:10982:3)
at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (http://localhost:9000/out/cljs/core.js:11073:10)
at Object.cljs$core$seq [as seq] (http://localhost:9000/out/cljs/core.js:4239:13)
at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (http://localhost:9000/out/cljs/core.js:28706:14)"
{:ua-product :chrome}
nil)
(parse-stacktrace {:host "localhost" :port 9000}
"Error: 1 is not ISeqable
at Object.cljs$core$seq [as seq] (http://localhost:9000/js/cljs/core.js:4258:8)
at Object.cljs$core$first [as first] (http://localhost:9000/js/cljs/core.js:4288:19)
at cljs$core$ffirst (http://localhost:9000/js/cljs/core.js:5356:34)
at http://localhost:9000/js/cljs/core.js:16971:89
at cljs.core.map.cljs$core$map__2 (http://localhost:9000/js/cljs/core.js:16972:3)
at http://localhost:9000/js/cljs/core.js:10981:129
at cljs.core.LazySeq.sval (http://localhost:9000/js/cljs/core.js:10982:3)
at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (http://localhost:9000/js/cljs/core.js:11073:10)
at Object.cljs$core$seq [as seq] (http://localhost:9000/js/cljs/core.js:4239:13)
at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (http://localhost:9000/js/cljs/core.js:28706:14)"
{:ua-product :chrome}
{:asset-path "/js"})
(parse-stacktrace {:host "localhost" :port 9000}
"Error: 1 is not ISeqable
at Object.cljs$core$seq [as seq] (http://localhost:9000/out/cljs/core.js:4259:8)
at Object.cljs$core$first [as first] (http://localhost:9000/out/cljs/core.js:4289:19)
at cljs$core$ffirst (http://localhost:9000/out/cljs/core.js:5357:18)
at eval (eval at <anonymous> (http://localhost:9000/out/clojure/browser/repl.js:23:272), <anonymous>:1:106)
at eval (eval at <anonymous> (http://localhost:9000/out/clojure/browser/repl.js:23:272), <anonymous>:9:3)
at eval (eval at <anonymous> (http://localhost:9000/out/clojure/browser/repl.js:23:272), <anonymous>:14:4)
at http://localhost:9000/out/clojure/browser/repl.js:23:267
at clojure$browser$repl$evaluate_javascript (http://localhost:9000/out/clojure/browser/repl.js:26:4)
at Object.callback (http://localhost:9000/out/clojure/browser/repl.js:121:169)
at goog.messaging.AbstractChannel.deliver (http://localhost:9000/out/goog/messaging/abstractchannel.js:142:13)"
{:ua-product :chrome}
nil)
;; Node.js example
(parse-stacktrace {}
"Error: 1 is not ISeqable
at Object.cljs$core$seq [as seq] (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:3999:8)
at Object.cljs$core$first [as first] (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:4018:19)
at cljs$core$ffirst (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:5161:34)
at /home/my/cool/project/.cljs_bootstrap/cljs/core.js:16006:88
at cljs.core.map.cljs$core$IFn$_invoke$arity$2 (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:16007:3)
at cljs.core.LazySeq.sval (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:10244:109)
at cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:10335:10)
at Object.cljs$core$seq [as seq] (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:3980:13)
at Object.cljs$core$pr_sequential_writer [as pr_sequential_writer] (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:28084:14)
at cljs.core.LazySeq.cljs$core$IPrintWithWriter$_pr_writer$arity$3 (/home/my/cool/project/.cljs_bootstrap/cljs/core.js:28812:18)"
{:ua-product :chrome}
{:output-dir "/home/my/cool/project/.cljs_bootstrap"})
)
;; -----------------------------------------------------------------------------
;; Safari Stacktrace
(defn safari-st-el->frame
[repl-env st-el opts]
(let [[function flc] (if (re-find #"@" st-el)
(string/split st-el #"@")
[nil st-el])
[file line column] (parse-file-line-column flc)]
(if (and file function line column)
{:file (parse-file repl-env file opts)
:function (string/trim function)
:line line
:column column}
(when-not (string/blank? function)
{:file nil
:function (string/trim function)
:line nil
:column nil}))))
(comment
(safari-st-el->frame {:host "localhost" :port 9000}
"cljs$core$seq@http://localhost:9000/out/cljs/core.js:4259:17" {})
(safari-st-el->frame {:host "localhost" :port 9000}
"cljs$core$seq@http://localhost:9000/js/cljs/core.js:4259:17" {:asset-path "js"})
)
(defmethod parse-stacktrace :safari
[repl-env st err opts]
(->> st
string/split-lines
(drop-while #(starts-with? % "Error"))
(take-while #(not (starts-with? % "eval code")))
(remove string/blank?)
(map #(safari-st-el->frame repl-env % opts))
(remove nil?)
vec))
(comment
(parse-stacktrace {}
"cljs$core$seq@out/cljs/core.js:3999:17
cljs$core$first@out/cljs/core.js:4018:22
cljs$core$ffirst@out/cljs/core.js:5161:39
global code"
{:ua-product :safari}
{:output-dir "out"})
(parse-stacktrace {:host "localhost" :port 9000}
"cljs$core$seq@http://localhost:9000/out/cljs/core.js:4259:17
cljs$core$first@http://localhost:9000/out/cljs/core.js:4289:22
cljs$core$ffirst@http://localhost:9000/out/cljs/core.js:5357:39
http://localhost:9000/out/cljs/core.js:16972:92
http://localhost:9000/out/cljs/core.js:16973:3
http://localhost:9000/out/cljs/core.js:10982:133
sval@http://localhost:9000/out/cljs/core.js:10983:3
cljs$core$ISeqable$_seq$arity$1@http://localhost:9000/out/cljs/core.js:11074:14
cljs$core$seq@http://localhost:9000/out/cljs/core.js:4240:44
cljs$core$pr_sequential_writer@http://localhost:9000/out/cljs/core.js:28707:17
cljs$core$IPrintWithWriter$_pr_writer$arity$3@http://localhost:9000/out/cljs/core.js:29386:38
cljs$core$pr_writer_impl@http://localhost:9000/out/cljs/core.js:28912:57
cljs$core$pr_writer@http://localhost:9000/out/cljs/core.js:29011:32
cljs$core$pr_seq_writer@http://localhost:9000/out/cljs/core.js:29015:20
cljs$core$pr_sb_with_opts@http://localhost:9000/out/cljs/core.js:29078:24
cljs$core$pr_str_with_opts@http://localhost:9000/out/cljs/core.js:29092:48
cljs$core$pr_str__delegate@http://localhost:9000/out/cljs/core.js:29130:34
cljs$core$pr_str@http://localhost:9000/out/cljs/core.js:29139:39
eval code
eval@[native code]
http://localhost:9000/out/clojure/browser/repl.js:23:271
clojure$browser$repl$evaluate_javascript@http://localhost:9000/out/clojure/browser/repl.js:26:4
http://localhost:9000/out/clojure/browser/repl.js:121:173
deliver@http://localhost:9000/out/goog/messaging/abstractchannel.js:142:21
xpcDeliver@http://localhost:9000/out/goog/net/xpc/crosspagechannel.js:733:19
messageReceived_@http://localhost:9000/out/goog/net/xpc/nativemessagingtransport.js:321:23
fireListener@http://localhost:9000/out/goog/events/events.js:741:25
handleBrowserEvent_@http://localhost:9000/out/goog/events/events.js:862:34
http://localhost:9000/out/goog/events/events.js:276:42"
{:ua-product :safari}
nil)
)
;; -----------------------------------------------------------------------------
;; Firefox Stacktrace
(defn firefox-clean-function [f]
(as-> f f
(cond
(string/blank? f) nil
(not= (.indexOf f "</") -1)
(let [idx (.indexOf f "</")]
(.substring f (+ idx 2)))
:else f)
(-> f
(string/replace #"<" "")
(string/replace #?(:clj #"\/" :cljs (js/RegExp. "\\/")) ""))))
(defn firefox-st-el->frame
[repl-env st-el opts]
(let [[function flc] (if (re-find #"@" st-el)
(string/split st-el #"@")
[nil st-el])
[file line column] (parse-file-line-column flc)]
(if (and file function line column)
{:file (parse-file repl-env file opts)
:function (firefox-clean-function function)
:line line
:column column}
(when-not (string/blank? function)
{:file nil
:function (firefox-clean-function function)
:line nil
:column nil}))))
(comment
(firefox-st-el->frame {:host "localhost" :port 9000}
"cljs$core$seq@http://localhost:9000/out/cljs/core.js:4258:8" {})
(firefox-st-el->frame {:host "localhost" :port 9000}
"cljs.core.map</cljs$core$map__2/</<@http://localhost:9000/out/cljs/core.js:16971:87" {})
(firefox-st-el->frame {:host "localhost" :port 9000}
"cljs.core.map</cljs$core$map__2/</<@http://localhost:9000/out/cljs/core.js:16971:87" {})
(firefox-st-el->frame {:host "localhost" :port 9000}
"cljs.core.pr_str</cljs$core$pr_str@http://localhost:9000/out/cljs/core.js:29138:8" {})
(firefox-st-el->frame {:host "localhost" :port 9000}
"cljs.core.pr_str</cljs$core$pr_str__delegate@http://localhost:9000/out/cljs/core.js:29129:8" {})
)
(defmethod parse-stacktrace :firefox
[repl-env st err opts]
(->> st
string/split-lines
(drop-while #(starts-with? % "Error"))
(take-while #(= (.indexOf % "> eval") -1))
(remove string/blank?)
(map #(firefox-st-el->frame repl-env % opts))
(remove nil?)
vec))
(comment
(parse-stacktrace {:host "localhost" :port 9000}
"cljs$core$seq@http://localhost:9000/out/cljs/core.js:4258:8
cljs$core$first@http://localhost:9000/out/cljs/core.js:4288:9
cljs$core$ffirst@http://localhost:9000/out/cljs/core.js:5356:24
cljs.core.map</cljs$core$map__2/</<@http://localhost:9000/out/cljs/core.js:16971:87
cljs.core.map</cljs$core$map__2/<@http://localhost:9000/out/cljs/core.js:16970:1
cljs.core.LazySeq.prototype.sval/self__.s<@http://localhost:9000/out/cljs/core.js:10981:119
cljs.core.LazySeq.prototype.sval@http://localhost:9000/out/cljs/core.js:10981:13
cljs.core.LazySeq.prototype.cljs$core$ISeqable$_seq$arity$1@http://localhost:9000/out/cljs/core.js:11073:1
cljs$core$seq@http://localhost:9000/out/cljs/core.js:4239:8
cljs$core$pr_sequential_writer@http://localhost:9000/out/cljs/core.js:28706:4
cljs.core.LazySeq.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3@http://localhost:9000/out/cljs/core.js:29385:8
cljs$core$pr_writer_impl@http://localhost:9000/out/cljs/core.js:28911:8
cljs$core$pr_writer@http://localhost:9000/out/cljs/core.js:29010:8
cljs$core$pr_seq_writer@http://localhost:9000/out/cljs/core.js:29014:1
cljs$core$pr_sb_with_opts@http://localhost:9000/out/cljs/core.js:29077:1
cljs$core$pr_str_with_opts@http://localhost:9000/out/cljs/core.js:29091:23
cljs.core.pr_str</cljs$core$pr_str__delegate@http://localhost:9000/out/cljs/core.js:29129:8
cljs.core.pr_str</cljs$core$pr_str@http://localhost:9000/out/cljs/core.js:29138:8
@http://localhost:9000/out/clojure/browser/repl.js line 23 > eval:1:25
@http://localhost:9000/out/clojure/browser/repl.js line 23 > eval:1:2
clojure$browser$repl$evaluate_javascript/result<@http://localhost:9000/out/clojure/browser/repl.js:23:267
clojure$browser$repl$evaluate_javascript@http://localhost:9000/out/clojure/browser/repl.js:23:15
clojure$browser$repl$connect/</<@http://localhost:9000/out/clojure/browser/repl.js:121:128
goog.messaging.AbstractChannel.prototype.deliver@http://localhost:9000/out/goog/messaging/abstractchannel.js:142:5
goog.net.xpc.CrossPageChannel.prototype.xpcDeliver@http://localhost:9000/out/goog/net/xpc/crosspagechannel.js:733:7
goog.net.xpc.NativeMessagingTransport.messageReceived_@http://localhost:9000/out/goog/net/xpc/nativemessagingtransport.js:321:1
goog.events.fireListener@http://localhost:9000/out/goog/events/events.js:741:10
goog.events.handleBrowserEvent_@http://localhost:9000/out/goog/events/events.js:862:1
goog.events.getProxy/f<@http://localhost:9000/out/goog/events/events.js:276:16"
{:ua-product :firefox}
nil)
)
;; -----------------------------------------------------------------------------
;; Rhino Stacktrace
(defmethod parse-stacktrace :rhino
[repl-env st err {:keys [output-dir] :as opts}]
(letfn [(process-frame [frame-str]
(when-not (or (string/blank? frame-str)
(== -1 (.indexOf frame-str "\tat")))
(let [[file-side line-fn-side] (string/split frame-str #":")
file (string/replace file-side #"\s+at\s+" "")
[line function] (string/split line-fn-side #"\s+")]
{:file (string/replace file
(str output-dir
#?(:clj File/separator :cljs "/"))
"")
:function (when function
(-> function
(string/replace "(" "")
(string/replace ")" "")))
:line (when (and line (not (string/blank? line)))
(parse-int line))
:column 0})))]
(->> (string/split st #"\n")
(map process-frame)
(remove nil?)
vec)))
(comment
(parse-stacktrace {}
"\tat .cljs_rhino_repl/goog/../cljs/core.js:4215 (seq)
\tat .cljs_rhino_repl/goog/../cljs/core.js:4245 (first)
\tat .cljs_rhino_repl/goog/../cljs/core.js:5295 (ffirst)
\tat <cljs repl>:1
\tat <cljs repl>:1"
{:ua-product :rhino}
{:output-dir ".cljs_rhino_repl"})
(parse-stacktrace {}
"org.mozilla.javascript.JavaScriptException: Error: 1 is not ISeqable (.cljs_rhino_repl/goog/../cljs/core.js#3998)
\tat .cljs_rhino_repl/goog/../cljs/core.js:3998 (cljs$core$seq)
\tat .cljs_rhino_repl/goog/../cljs/core.js:4017 (cljs$core$first)
\tat .cljs_rhino_repl/goog/../cljs/core.js:5160 (cljs$core$ffirst)
\tat .cljs_rhino_repl/goog/../cljs/core.js:16005
\tat .cljs_rhino_repl/goog/../cljs/core.js:16004
\tat .cljs_rhino_repl/goog/../cljs/core.js:10243
\tat .cljs_rhino_repl/goog/../cljs/core.js:10334
\tat .cljs_rhino_repl/goog/../cljs/core.js:3979 (cljs$core$seq)
\tat .cljs_rhino_repl/goog/../cljs/core.js:28083 (cljs$core$pr_sequential_writer)
\tat .cljs_rhino_repl/goog/../cljs/core.js:28811
\tat .cljs_rhino_repl/goog/../cljs/core.js:28267 (cljs$core$pr_writer_impl)
\tat .cljs_rhino_repl/goog/../cljs/core.js:28349 (cljs$core$pr_writer)
\tat .cljs_rhino_repl/goog/../cljs/core.js:28353 (cljs$core$pr_seq_writer)
\tat .cljs_rhino_repl/goog/../cljs/core.js:28416 (cljs$core$pr_sb_with_opts)
\tat .cljs_rhino_repl/goog/../cljs/core.js:28430 (cljs$core$pr_str_with_opts)
\tat .cljs_rhino_repl/goog/../cljs/core.js:28524
\tat .cljs_rhino_repl/goog/../cljs/core.js:28520 (cljs$core$pr_str)
at <cljs repl>:1
"
{:ua-product :rhino}
{:output-dir ".cljs_rhino_repl"})
)
;; -----------------------------------------------------------------------------
;; Nashorn Stacktrace
(defmethod parse-stacktrace :nashorn
[repl-env st err {:keys [output-dir] :as opts}]
(letfn [(process-frame [frame-str]
(when-not (or (string/blank? frame-str)
(== -1 (.indexOf frame-str "\tat")))
(let [frame-str (string/replace frame-str #"\s+at\s+" "")
[function file-and-line] (string/split frame-str #"\s+")
[file-part line-part] (string/split file-and-line #":")]
{:file (string/replace (.substring file-part 1)
(str output-dir
#?(:clj File/separator :cljs "/"))
"")
:function function
:line (when (and line-part (not (string/blank? line-part)))
(parse-int
(.substring line-part 0
(dec (count line-part)))))
:column 0})))]
(->> (string/split st #"\n")
(map process-frame)
(remove nil?)
vec)))
;; -----------------------------------------------------------------------------
;; Graal.JS Stacktrace
(defmethod parse-stacktrace :graaljs
[repl-env st err {:keys [output-dir] :as opts}]
(letfn [(process-frame [frame-str]
(when-not (string/blank? frame-str)
(let [[function file-and-line] (string/split frame-str #"\(")
[file-part line-part] (string/split file-and-line #":")]
{:file (string/replace file-part
(str output-dir
#?(:clj File/separator :cljs "/"))
"")
:function function
:line (when (and line-part (not (string/blank? line-part)))
(parse-int
(.substring line-part 0
(dec (count line-part)))))
:column 0})))]
(->> (string/split st #"\n")
(map process-frame)
(remove nil?)
vec)))
(comment
(parse-stacktrace {}
"Error: 1 is not ISeqable
\tat cljs$core$seq (.cljs_nashorn_repl/goog/../cljs/core.js:3998)
\tat cljs$core$first (.cljs_nashorn_repl/goog/../cljs/core.js:4017)
\tat cljs$core$ffirst (.cljs_nashorn_repl/goog/../cljs/core.js:5160)
\tat <anonymous> (.cljs_nashorn_repl/goog/../cljs/core.js:16005)
\tat <anonymous> (.cljs_nashorn_repl/goog/../cljs/core.js:16004)
\tat sval (.cljs_nashorn_repl/goog/../cljs/core.js:10243)
\tat cljs$core$ISeqable$_seq$arity$1-6 (.cljs_nashorn_repl/goog/../cljs/core.js:10334)
\tat cljs$core$seq (.cljs_nashorn_repl/goog/../cljs/core.js:3979)
\tat cljs$core$pr_sequential_writer (.cljs_nashorn_repl/goog/../cljs/core.js:28083)
\tat cljs$core$IPrintWithWriter$_pr_writer$arity$3-5 (.cljs_nashorn_repl/goog/../cljs/core.js:28811)
\tat cljs$core$pr_writer_impl (.cljs_nashorn_repl/goog/../cljs/core.js:28267)
\tat cljs$core$pr_writer (.cljs_nashorn_repl/goog/../cljs/core.js:28349)
\tat cljs$core$pr_seq_writer (.cljs_nashorn_repl/goog/../cljs/core.js:28353)
\tat cljs$core$pr_sb_with_opts (.cljs_nashorn_repl/goog/../cljs/core.js:28416)
\tat cljs$core$pr_str_with_opts (.cljs_nashorn_repl/goog/../cljs/core.js:28430)
\tat cljs$core$IFn$_invoke$arity$variadic-71 (.cljs_nashorn_repl/goog/../cljs/core.js:28524)
\tat cljs$core$pr_str (.cljs_nashorn_repl/goog/../cljs/core.js:28520)
\tat <anonymous> (<eval>:1)
\tat <program> (<eval>:1)\n"
{:ua-product :nashorn}
{:output-dir ".cljs_nashorn_repl"})
)
;; -----------------------------------------------------------------------------
;; Node.js Stacktrace
(defmethod parse-stacktrace :nodejs
[repl-env st err {:keys [output-dir] :as opts}]
(letfn [(parse-source-loc-info [x]
(when (and x (not (string/blank? x)))
(parse-int x)))
(process-frame [frame-str]
(when-not (or (string/blank? frame-str)
(nil? (re-find #"^\s+at" frame-str)))
(let [frame-str (string/replace frame-str #"\s+at\s+" "")]
(when-not (string/starts-with? frame-str "repl:")
(let [parts (string/split frame-str #"\s+")
[function file&line] (if (== 2 (count parts))
[(first parts)
(subs (second parts) 1
(dec (count (second parts))))]
[nil (first parts)])
[file-part line-part col-part] (string/split file&line #":")]
{:file (if function
(cond-> file-part
output-dir
(string/replace
(str output-dir
#?(:clj File/separator :cljs "/"))
""))
file-part)
:function function
:line (parse-source-loc-info line-part)
:column (parse-source-loc-info col-part)})))))]
(->> (string/split st #"\n")
(map process-frame)
(remove nil?)
vec)))
(comment
(parse-stacktrace {}
"Error: 1 is not ISeqable
at cljs$core$seq (.cljs_node_repl/cljs/core.cljs:1118:20)
at repl:1:65
at repl:9:4
at repl:17:3
at repl:22:4
at Object.exports.runInThisContext (vm.js:54:17)
at Domain.<anonymous> ([stdin]:41:34)
at Domain.run (domain.js:228:14)
at Socket.<anonymous> ([stdin]:40:25)
at emitOne (events.js:77:13)"
{:ua-product :nodejs}
{:output-dir ".cljs_node_repl"})
)
;; -----------------------------------------------------------------------------
;; Stacktrace Mapping
(defn remove-ext [file]
(-> file
(string/replace #"\.js$" "")
(string/replace #"\.cljs$" "")
(string/replace #"\.cljc$" "")
(string/replace #"\.clj$" "")))
(defn mapped-line-column-call
"Given a cljs.source-map source map data structure map a generated line
and column back to the original line, column, and function called."
[sms file line column]
(let [source-map (get sms (symbol (string/replace (remove-ext file) "/" ".")))]
;; source maps are 0 indexed for columns
;; multiple segments may exist at column
;; the last segment seems most accurate
(letfn [(get-best-column [columns column]
(last (or (get columns
(last (filter #(<= % (dec column))
(sort (keys columns)))))
(second (first columns)))))
(adjust [mapped]
(vec (map #(%1 %2) [inc inc identity] mapped)))]
(let [default [line column nil]]
;; source maps are 0 indexed for lines
(if-let [columns (get source-map (dec line))]
(adjust (map (get-best-column columns column) [:line :col :name]))
default)))))
(defn mapped-frame
"Given opts and a canonicalized JavaScript stacktrace frame, return the
ClojureScript frame."
[{:keys [function file line column]} sms opts]
(let [no-source-file? (if-not file true (starts-with? file "<"))
[line' column' call] (if no-source-file?
[line column nil]
(mapped-line-column-call sms file line column))
file' (when-not no-source-file?
(if (ends-with? file ".js")
(str (subs file 0 (- (count file) 3)) ".cljs")
file))]
{:function function
:call call
:file (if no-source-file?
(str "NO_SOURCE_FILE" (when file (str " " file)))
file')
:line line'
:column column'}))
(defn mapped-stacktrace
"Given a vector representing the canonicalized JavaScript stacktrace
return the ClojureScript stacktrace. The canonical stacktrace must be
in the form:
[{:file <string>
:function <string>
:line <integer>
:column <integer>}*]
:file must be a URL path (without protocol) relative to :output-dir or a
identifier delimited by angle brackets. The returned mapped stacktrace will
also contain :url entries to the original sources if it can be determined
from the classpath."
([stacktrace sms]
(mapped-stacktrace stacktrace sms nil))
([stacktrace sms opts]
(letfn [(call->function [x]
(if (:call x)
(hash-map :function (:call x))
{}))
(call-merge [function call]
(merge-with
(fn [munged-fn-name unmunged-call-name]
(if (= munged-fn-name
(string/replace (munge unmunged-call-name) "." "$"))
unmunged-call-name
munged-fn-name))
function call))]
(let [mapped-frames (map (memoize #(mapped-frame % sms opts)) stacktrace)]
;; take each non-nil :call and optionally merge it into :function one-level
;; up to avoid replacing with local symbols, we only replace munged name if
;; we can munge call symbol back to it
(vec (map call-merge
(map #(dissoc % :call) mapped-frames)
(concat (rest (map call->function mapped-frames)) [{}])))))))
(defn mapped-stacktrace-str
"Given a vector representing the canonicalized JavaScript stacktrace and a map
of library names to decoded source maps, print the ClojureScript stacktrace .
See mapped-stacktrace."
([stacktrace sms]
(mapped-stacktrace-str stacktrace sms nil))
([stacktrace sms opts]
(with-out-str
(doseq [{:keys [function file line column]}
(mapped-stacktrace stacktrace sms opts)]
(println "\t"
(str (when function (str function " "))
"(" file (when line (str ":" line))
(when column (str ":" column)) ")"))))))
(comment
(require '[cljs.closure :as cljsc]
'[clojure.data.json :as json]
'[cljs.source-map :as sm]
'[clojure.pprint :as pp])
(cljsc/build "samples/hello/src"
{:optimizations :none
:output-dir "samples/hello/out"
:output-to "samples/hello/out/hello.js"
:source-map true})
(def sms
{'hello.core
(sm/decode
(json/read-str
(slurp "samples/hello/out/hello/core.js.map")
:key-fn keyword))})
(pp/pprint sms)
;; maps to :line 5 :column 24
(mapped-stacktrace
[{:file "hello/core.js"
:function "first"
:line 6
:column 0}]
sms {:output-dir "samples/hello/out"})
(mapped-stacktrace-str
[{:file "hello/core.js"
:function "first"
:line 6
:column 0}]
sms {:output-dir "samples/hello/out"})
)

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,665 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('cljs.stacktrace');
goog.require('cljs.core');
goog.require('goog.string');
goog.require('clojure.string');
if((typeof cljs !== 'undefined') && (typeof cljs.stacktrace !== 'undefined') && (typeof cljs.stacktrace.parse_stacktrace !== 'undefined')){
} else {
/**
* Parse a JavaScript stacktrace string into a canonical data form. The
* arguments:
*
* repl-env - the repl environment, an optional map with :host and :port keys
* if the stacktrace includes url, not file references
* st - the original stacktrace string to parse
* err - an error map. :ua-product key defines the type of stacktrace parser
* to use, for example :chrome
* opts - additional options. :output-dir maybe given in this argument if
* :host and :port do not apply, for example, a file path
*
* The canonical stacktrace representation can easily be mapped to a
* ClojureScript one see mapped-stacktrace and mapped-stacktrace-str
*/
cljs.stacktrace.parse_stacktrace = (function (){var method_table__4613__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var prefer_table__4614__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var method_cache__4615__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var cached_hierarchy__4616__auto__ = cljs.core.atom.call(null,cljs.core.PersistentArrayMap.EMPTY);
var hierarchy__4617__auto__ = cljs.core.get.call(null,cljs.core.PersistentArrayMap.EMPTY,new cljs.core.Keyword(null,"hierarchy","hierarchy",-1053470341),cljs.core.get_global_hierarchy.call(null));
return (new cljs.core.MultiFn(cljs.core.symbol.call(null,"cljs.stacktrace","parse-stacktrace"),((function (method_table__4613__auto__,prefer_table__4614__auto__,method_cache__4615__auto__,cached_hierarchy__4616__auto__,hierarchy__4617__auto__){
return (function (repl_env,st,err,opts){
return new cljs.core.Keyword(null,"ua-product","ua-product",938384227).cljs$core$IFn$_invoke$arity$1(err);
});})(method_table__4613__auto__,prefer_table__4614__auto__,method_cache__4615__auto__,cached_hierarchy__4616__auto__,hierarchy__4617__auto__))
,new cljs.core.Keyword(null,"default","default",-1987822328),hierarchy__4617__auto__,method_table__4613__auto__,prefer_table__4614__auto__,method_cache__4615__auto__,cached_hierarchy__4616__auto__));
})();
}
cljs.stacktrace.parse_int = (function cljs$stacktrace$parse_int(s){
return parseInt(s,(10));
});
cljs.stacktrace.starts_with_QMARK_ = (function cljs$stacktrace$starts_with_QMARK_(s0,s1){
return goog.string.startsWith(s0,s1);
});
cljs.stacktrace.ends_with_QMARK_ = (function cljs$stacktrace$ends_with_QMARK_(s0,s1){
return goog.string.endsWith(s0,s1);
});
cljs.stacktrace.string__GT_regex = (function cljs$stacktrace$string__GT_regex(s){
return (new RegExp(s));
});
cljs.stacktrace.output_directory = (function cljs$stacktrace$output_directory(opts){
var or__4131__auto__ = new cljs.core.Keyword(null,"output-dir","output-dir",-290956991).cljs$core$IFn$_invoke$arity$1(opts);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return "out";
}
});
cljs.core._add_method.call(null,cljs.stacktrace.parse_stacktrace,new cljs.core.Keyword(null,"default","default",-1987822328),(function (repl_env,st,err,opts){
return st;
}));
cljs.stacktrace.parse_file_line_column = (function cljs$stacktrace$parse_file_line_column(flc){
if(cljs.core.not.call(null,cljs.core.re_find.call(null,/:/,flc))){
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [flc,null,null], null);
} else {
var xs = clojure.string.split.call(null,flc,/:/);
var vec__28172 = cljs.core.reduce.call(null,((function (xs){
return (function (p__28178,p__28179){
var vec__28180 = p__28178;
var pre = cljs.core.nth.call(null,vec__28180,(0),null);
var post = cljs.core.nth.call(null,vec__28180,(1),null);
var vec__28183 = p__28179;
var x = cljs.core.nth.call(null,vec__28183,(0),null);
var i = cljs.core.nth.call(null,vec__28183,(1),null);
if((i <= (2))){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [pre,cljs.core.conj.call(null,post,x)], null);
} else {
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.conj.call(null,pre,x),post], null);
}
});})(xs))
,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.PersistentVector.EMPTY,cljs.core.PersistentVector.EMPTY], null),cljs.core.map.call(null,cljs.core.vector,xs,cljs.core.range.call(null,cljs.core.count.call(null,xs),(0),(-1))));
var pre = cljs.core.nth.call(null,vec__28172,(0),null);
var vec__28175 = cljs.core.nth.call(null,vec__28172,(1),null);
var line = cljs.core.nth.call(null,vec__28175,(0),null);
var column = cljs.core.nth.call(null,vec__28175,(1),null);
var file = clojure.string.join.call(null,":",pre);
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [(function (){var G__28186 = file;
if(cljs.stacktrace.starts_with_QMARK_.call(null,file,"(")){
return clojure.string.replace.call(null,G__28186,"(","");
} else {
return G__28186;
}
})(),cljs.stacktrace.parse_int.call(null,(function (){var G__28187 = line;
if(cljs.stacktrace.ends_with_QMARK_.call(null,line,")")){
return clojure.string.replace.call(null,G__28187,")","");
} else {
return G__28187;
}
})()),cljs.stacktrace.parse_int.call(null,(function (){var G__28188 = column;
if(cljs.stacktrace.ends_with_QMARK_.call(null,column,")")){
return clojure.string.replace.call(null,G__28188,")","");
} else {
return G__28188;
}
})())], null);
}
});
/**
* Given a browser file url convert it into a relative path that can be used
* to locate the original source.
*/
cljs.stacktrace.parse_file = (function cljs$stacktrace$parse_file(p__28189,file,p__28190){
var map__28191 = p__28189;
var map__28191__$1 = (((((!((map__28191 == null))))?(((((map__28191.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__28191.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__28191):map__28191);
var repl_env = map__28191__$1;
var host = cljs.core.get.call(null,map__28191__$1,new cljs.core.Keyword(null,"host","host",-1558485167));
var host_port = cljs.core.get.call(null,map__28191__$1,new cljs.core.Keyword(null,"host-port","host-port",1956551772));
var port = cljs.core.get.call(null,map__28191__$1,new cljs.core.Keyword(null,"port","port",1534937262));
var map__28192 = p__28190;
var map__28192__$1 = (((((!((map__28192 == null))))?(((((map__28192.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__28192.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__28192):map__28192);
var opts = map__28192__$1;
var asset_path = cljs.core.get.call(null,map__28192__$1,new cljs.core.Keyword(null,"asset-path","asset-path",1500889617));
var urlpat = (cljs.core.truth_(host)?cljs.stacktrace.string__GT_regex.call(null,["http://",cljs.core.str.cljs$core$IFn$_invoke$arity$1(host),":",cljs.core.str.cljs$core$IFn$_invoke$arity$1((function (){var or__4131__auto__ = host_port;
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return port;
}
})()),"/"].join('')):"");
var match = (cljs.core.truth_(host)?cljs.core.re_find.call(null,urlpat,file):cljs.core.contains_QMARK_.call(null,opts,new cljs.core.Keyword(null,"output-dir","output-dir",-290956991)));
if(cljs.core.truth_(match)){
return clojure.string.replace.call(null,clojure.string.replace.call(null,file,urlpat,""),cljs.stacktrace.string__GT_regex.call(null,["^",cljs.core.str.cljs$core$IFn$_invoke$arity$1((function (){var or__4131__auto__ = (function (){var and__4120__auto__ = asset_path;
if(cljs.core.truth_(and__4120__auto__)){
return clojure.string.replace.call(null,asset_path,/^\//,"");
} else {
return and__4120__auto__;
}
})();
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return cljs.stacktrace.output_directory.call(null,opts);
}
})()),"/"].join('')),"");
} else {
var temp__5718__auto__ = new cljs.core.Keyword(null,"asset-root","asset-root",1771735072).cljs$core$IFn$_invoke$arity$1(opts);
if(cljs.core.truth_(temp__5718__auto__)){
var asset_root = temp__5718__auto__;
return clojure.string.replace.call(null,file,asset_root,"");
} else {
throw cljs.core.ex_info.call(null,["Could not relativize URL ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(file)].join(''),new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"type","type",1174270348),new cljs.core.Keyword(null,"parse-stacktrace","parse-stacktrace",-38208461),new cljs.core.Keyword(null,"reason","reason",-2070751759),new cljs.core.Keyword(null,"relativize-url","relativize-url",621482324)], null));
}
}
});
cljs.stacktrace.chrome_st_el__GT_frame = (function cljs$stacktrace$chrome_st_el__GT_frame(repl_env,st_el,opts){
var xs = clojure.string.split.call(null,clojure.string.replace.call(null,st_el,/\s+at\s+/,""),/\s+/);
var vec__28195 = ((((1) === cljs.core.count.call(null,xs)))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,cljs.core.first.call(null,xs)], null):new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.first.call(null,xs),cljs.core.last.call(null,xs)], null));
var function$ = cljs.core.nth.call(null,vec__28195,(0),null);
var flc = cljs.core.nth.call(null,vec__28195,(1),null);
var vec__28198 = cljs.stacktrace.parse_file_line_column.call(null,flc);
var file = cljs.core.nth.call(null,vec__28198,(0),null);
var line = cljs.core.nth.call(null,vec__28198,(1),null);
var column = cljs.core.nth.call(null,vec__28198,(2),null);
if(cljs.core.truth_((function (){var and__4120__auto__ = file;
if(cljs.core.truth_(and__4120__auto__)){
var and__4120__auto____$1 = function$;
if(cljs.core.truth_(and__4120__auto____$1)){
var and__4120__auto____$2 = line;
if(cljs.core.truth_(and__4120__auto____$2)){
return column;
} else {
return and__4120__auto____$2;
}
} else {
return and__4120__auto____$1;
}
} else {
return and__4120__auto__;
}
})())){
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),cljs.stacktrace.parse_file.call(null,repl_env,file,opts),new cljs.core.Keyword(null,"function","function",-2127255473),clojure.string.replace.call(null,function$,/Object\./,""),new cljs.core.Keyword(null,"line","line",212345235),line,new cljs.core.Keyword(null,"column","column",2078222095),column], null);
} else {
if(clojure.string.blank_QMARK_.call(null,function$)){
return null;
} else {
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),null,new cljs.core.Keyword(null,"function","function",-2127255473),clojure.string.replace.call(null,function$,/Object\./,""),new cljs.core.Keyword(null,"line","line",212345235),null,new cljs.core.Keyword(null,"column","column",2078222095),null], null);
}
}
});
cljs.core._add_method.call(null,cljs.stacktrace.parse_stacktrace,new cljs.core.Keyword(null,"chrome","chrome",1718738387),(function (repl_env,st,err,opts){
return cljs.core.vec.call(null,cljs.core.remove.call(null,cljs.core.nil_QMARK_,cljs.core.map.call(null,(function (p1__28203_SHARP_){
return cljs.stacktrace.chrome_st_el__GT_frame.call(null,repl_env,p1__28203_SHARP_,opts);
}),cljs.core.take_while.call(null,(function (p1__28202_SHARP_){
return (!(cljs.stacktrace.starts_with_QMARK_.call(null,p1__28202_SHARP_," at eval")));
}),cljs.core.drop_while.call(null,(function (p1__28201_SHARP_){
return cljs.stacktrace.starts_with_QMARK_.call(null,p1__28201_SHARP_,"Error");
}),clojure.string.split_lines.call(null,st))))));
}));
cljs.stacktrace.safari_st_el__GT_frame = (function cljs$stacktrace$safari_st_el__GT_frame(repl_env,st_el,opts){
var vec__28204 = (cljs.core.truth_(cljs.core.re_find.call(null,/@/,st_el))?clojure.string.split.call(null,st_el,/@/):new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,st_el], null));
var function$ = cljs.core.nth.call(null,vec__28204,(0),null);
var flc = cljs.core.nth.call(null,vec__28204,(1),null);
var vec__28207 = cljs.stacktrace.parse_file_line_column.call(null,flc);
var file = cljs.core.nth.call(null,vec__28207,(0),null);
var line = cljs.core.nth.call(null,vec__28207,(1),null);
var column = cljs.core.nth.call(null,vec__28207,(2),null);
if(cljs.core.truth_((function (){var and__4120__auto__ = file;
if(cljs.core.truth_(and__4120__auto__)){
var and__4120__auto____$1 = function$;
if(cljs.core.truth_(and__4120__auto____$1)){
var and__4120__auto____$2 = line;
if(cljs.core.truth_(and__4120__auto____$2)){
return column;
} else {
return and__4120__auto____$2;
}
} else {
return and__4120__auto____$1;
}
} else {
return and__4120__auto__;
}
})())){
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),cljs.stacktrace.parse_file.call(null,repl_env,file,opts),new cljs.core.Keyword(null,"function","function",-2127255473),clojure.string.trim.call(null,function$),new cljs.core.Keyword(null,"line","line",212345235),line,new cljs.core.Keyword(null,"column","column",2078222095),column], null);
} else {
if(clojure.string.blank_QMARK_.call(null,function$)){
return null;
} else {
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),null,new cljs.core.Keyword(null,"function","function",-2127255473),clojure.string.trim.call(null,function$),new cljs.core.Keyword(null,"line","line",212345235),null,new cljs.core.Keyword(null,"column","column",2078222095),null], null);
}
}
});
cljs.core._add_method.call(null,cljs.stacktrace.parse_stacktrace,new cljs.core.Keyword(null,"safari","safari",497115653),(function (repl_env,st,err,opts){
return cljs.core.vec.call(null,cljs.core.remove.call(null,cljs.core.nil_QMARK_,cljs.core.map.call(null,(function (p1__28212_SHARP_){
return cljs.stacktrace.safari_st_el__GT_frame.call(null,repl_env,p1__28212_SHARP_,opts);
}),cljs.core.remove.call(null,clojure.string.blank_QMARK_,cljs.core.take_while.call(null,(function (p1__28211_SHARP_){
return (!(cljs.stacktrace.starts_with_QMARK_.call(null,p1__28211_SHARP_,"eval code")));
}),cljs.core.drop_while.call(null,(function (p1__28210_SHARP_){
return cljs.stacktrace.starts_with_QMARK_.call(null,p1__28210_SHARP_,"Error");
}),clojure.string.split_lines.call(null,st)))))));
}));
cljs.stacktrace.firefox_clean_function = (function cljs$stacktrace$firefox_clean_function(f){
var f__$1 = f;
var f__$2 = ((clojure.string.blank_QMARK_.call(null,f__$1))?null:((cljs.core.not_EQ_.call(null,f__$1.indexOf("</"),(-1)))?(function (){var idx = f__$1.indexOf("</");
return f__$1.substring((idx + (2)));
})():f__$1
));
return clojure.string.replace.call(null,clojure.string.replace.call(null,f__$2,/</,""),(new RegExp("\\/")),"");
});
cljs.stacktrace.firefox_st_el__GT_frame = (function cljs$stacktrace$firefox_st_el__GT_frame(repl_env,st_el,opts){
var vec__28213 = (cljs.core.truth_(cljs.core.re_find.call(null,/@/,st_el))?clojure.string.split.call(null,st_el,/@/):new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,st_el], null));
var function$ = cljs.core.nth.call(null,vec__28213,(0),null);
var flc = cljs.core.nth.call(null,vec__28213,(1),null);
var vec__28216 = cljs.stacktrace.parse_file_line_column.call(null,flc);
var file = cljs.core.nth.call(null,vec__28216,(0),null);
var line = cljs.core.nth.call(null,vec__28216,(1),null);
var column = cljs.core.nth.call(null,vec__28216,(2),null);
if(cljs.core.truth_((function (){var and__4120__auto__ = file;
if(cljs.core.truth_(and__4120__auto__)){
var and__4120__auto____$1 = function$;
if(cljs.core.truth_(and__4120__auto____$1)){
var and__4120__auto____$2 = line;
if(cljs.core.truth_(and__4120__auto____$2)){
return column;
} else {
return and__4120__auto____$2;
}
} else {
return and__4120__auto____$1;
}
} else {
return and__4120__auto__;
}
})())){
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),cljs.stacktrace.parse_file.call(null,repl_env,file,opts),new cljs.core.Keyword(null,"function","function",-2127255473),cljs.stacktrace.firefox_clean_function.call(null,function$),new cljs.core.Keyword(null,"line","line",212345235),line,new cljs.core.Keyword(null,"column","column",2078222095),column], null);
} else {
if(clojure.string.blank_QMARK_.call(null,function$)){
return null;
} else {
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),null,new cljs.core.Keyword(null,"function","function",-2127255473),cljs.stacktrace.firefox_clean_function.call(null,function$),new cljs.core.Keyword(null,"line","line",212345235),null,new cljs.core.Keyword(null,"column","column",2078222095),null], null);
}
}
});
cljs.core._add_method.call(null,cljs.stacktrace.parse_stacktrace,new cljs.core.Keyword(null,"firefox","firefox",1283768880),(function (repl_env,st,err,opts){
return cljs.core.vec.call(null,cljs.core.remove.call(null,cljs.core.nil_QMARK_,cljs.core.map.call(null,(function (p1__28221_SHARP_){
return cljs.stacktrace.firefox_st_el__GT_frame.call(null,repl_env,p1__28221_SHARP_,opts);
}),cljs.core.remove.call(null,clojure.string.blank_QMARK_,cljs.core.take_while.call(null,(function (p1__28220_SHARP_){
return cljs.core._EQ_.call(null,p1__28220_SHARP_.indexOf("> eval"),(-1));
}),cljs.core.drop_while.call(null,(function (p1__28219_SHARP_){
return cljs.stacktrace.starts_with_QMARK_.call(null,p1__28219_SHARP_,"Error");
}),clojure.string.split_lines.call(null,st)))))));
}));
cljs.core._add_method.call(null,cljs.stacktrace.parse_stacktrace,new cljs.core.Keyword(null,"rhino","rhino",1962118035),(function (repl_env,st,err,p__28222){
var map__28223 = p__28222;
var map__28223__$1 = (((((!((map__28223 == null))))?(((((map__28223.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__28223.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__28223):map__28223);
var opts = map__28223__$1;
var output_dir = cljs.core.get.call(null,map__28223__$1,new cljs.core.Keyword(null,"output-dir","output-dir",-290956991));
var process_frame = ((function (map__28223,map__28223__$1,opts,output_dir){
return (function cljs$stacktrace$process_frame(frame_str){
if(((clojure.string.blank_QMARK_.call(null,frame_str)) || (((-1) === frame_str.indexOf("\tat"))))){
return null;
} else {
var vec__28231 = clojure.string.split.call(null,frame_str,/:/);
var file_side = cljs.core.nth.call(null,vec__28231,(0),null);
var line_fn_side = cljs.core.nth.call(null,vec__28231,(1),null);
var file = clojure.string.replace.call(null,file_side,/\s+at\s+/,"");
var vec__28234 = clojure.string.split.call(null,line_fn_side,/\s+/);
var line = cljs.core.nth.call(null,vec__28234,(0),null);
var function$ = cljs.core.nth.call(null,vec__28234,(1),null);
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),clojure.string.replace.call(null,file,[cljs.core.str.cljs$core$IFn$_invoke$arity$1(output_dir),"/"].join(''),""),new cljs.core.Keyword(null,"function","function",-2127255473),(cljs.core.truth_(function$)?clojure.string.replace.call(null,clojure.string.replace.call(null,function$,"(",""),")",""):null),new cljs.core.Keyword(null,"line","line",212345235),(cljs.core.truth_((function (){var and__4120__auto__ = line;
if(cljs.core.truth_(and__4120__auto__)){
return (!(clojure.string.blank_QMARK_.call(null,line)));
} else {
return and__4120__auto__;
}
})())?cljs.stacktrace.parse_int.call(null,line):null),new cljs.core.Keyword(null,"column","column",2078222095),(0)], null);
}
});})(map__28223,map__28223__$1,opts,output_dir))
;
return cljs.core.vec.call(null,cljs.core.remove.call(null,cljs.core.nil_QMARK_,cljs.core.map.call(null,process_frame,clojure.string.split.call(null,st,/\n/))));
}));
cljs.core._add_method.call(null,cljs.stacktrace.parse_stacktrace,new cljs.core.Keyword(null,"nashorn","nashorn",988299963),(function (repl_env,st,err,p__28237){
var map__28238 = p__28237;
var map__28238__$1 = (((((!((map__28238 == null))))?(((((map__28238.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__28238.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__28238):map__28238);
var opts = map__28238__$1;
var output_dir = cljs.core.get.call(null,map__28238__$1,new cljs.core.Keyword(null,"output-dir","output-dir",-290956991));
var process_frame = ((function (map__28238,map__28238__$1,opts,output_dir){
return (function cljs$stacktrace$process_frame(frame_str){
if(((clojure.string.blank_QMARK_.call(null,frame_str)) || (((-1) === frame_str.indexOf("\tat"))))){
return null;
} else {
var frame_str__$1 = clojure.string.replace.call(null,frame_str,/\s+at\s+/,"");
var vec__28246 = clojure.string.split.call(null,frame_str__$1,/\s+/);
var function$ = cljs.core.nth.call(null,vec__28246,(0),null);
var file_and_line = cljs.core.nth.call(null,vec__28246,(1),null);
var vec__28249 = clojure.string.split.call(null,file_and_line,/:/);
var file_part = cljs.core.nth.call(null,vec__28249,(0),null);
var line_part = cljs.core.nth.call(null,vec__28249,(1),null);
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),clojure.string.replace.call(null,file_part.substring((1)),[cljs.core.str.cljs$core$IFn$_invoke$arity$1(output_dir),"/"].join(''),""),new cljs.core.Keyword(null,"function","function",-2127255473),function$,new cljs.core.Keyword(null,"line","line",212345235),(cljs.core.truth_((function (){var and__4120__auto__ = line_part;
if(cljs.core.truth_(and__4120__auto__)){
return (!(clojure.string.blank_QMARK_.call(null,line_part)));
} else {
return and__4120__auto__;
}
})())?cljs.stacktrace.parse_int.call(null,line_part.substring((0),(cljs.core.count.call(null,line_part) - (1)))):null),new cljs.core.Keyword(null,"column","column",2078222095),(0)], null);
}
});})(map__28238,map__28238__$1,opts,output_dir))
;
return cljs.core.vec.call(null,cljs.core.remove.call(null,cljs.core.nil_QMARK_,cljs.core.map.call(null,process_frame,clojure.string.split.call(null,st,/\n/))));
}));
cljs.core._add_method.call(null,cljs.stacktrace.parse_stacktrace,new cljs.core.Keyword(null,"graaljs","graaljs",1880468686),(function (repl_env,st,err,p__28252){
var map__28253 = p__28252;
var map__28253__$1 = (((((!((map__28253 == null))))?(((((map__28253.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__28253.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__28253):map__28253);
var opts = map__28253__$1;
var output_dir = cljs.core.get.call(null,map__28253__$1,new cljs.core.Keyword(null,"output-dir","output-dir",-290956991));
var process_frame = ((function (map__28253,map__28253__$1,opts,output_dir){
return (function cljs$stacktrace$process_frame(frame_str){
if(clojure.string.blank_QMARK_.call(null,frame_str)){
return null;
} else {
var vec__28261 = clojure.string.split.call(null,frame_str,/\(/);
var function$ = cljs.core.nth.call(null,vec__28261,(0),null);
var file_and_line = cljs.core.nth.call(null,vec__28261,(1),null);
var vec__28264 = clojure.string.split.call(null,file_and_line,/:/);
var file_part = cljs.core.nth.call(null,vec__28264,(0),null);
var line_part = cljs.core.nth.call(null,vec__28264,(1),null);
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),clojure.string.replace.call(null,file_part,[cljs.core.str.cljs$core$IFn$_invoke$arity$1(output_dir),"/"].join(''),""),new cljs.core.Keyword(null,"function","function",-2127255473),function$,new cljs.core.Keyword(null,"line","line",212345235),(cljs.core.truth_((function (){var and__4120__auto__ = line_part;
if(cljs.core.truth_(and__4120__auto__)){
return (!(clojure.string.blank_QMARK_.call(null,line_part)));
} else {
return and__4120__auto__;
}
})())?cljs.stacktrace.parse_int.call(null,line_part.substring((0),(cljs.core.count.call(null,line_part) - (1)))):null),new cljs.core.Keyword(null,"column","column",2078222095),(0)], null);
}
});})(map__28253,map__28253__$1,opts,output_dir))
;
return cljs.core.vec.call(null,cljs.core.remove.call(null,cljs.core.nil_QMARK_,cljs.core.map.call(null,process_frame,clojure.string.split.call(null,st,/\n/))));
}));
cljs.core._add_method.call(null,cljs.stacktrace.parse_stacktrace,new cljs.core.Keyword(null,"nodejs","nodejs",321212524),(function (repl_env,st,err,p__28267){
var map__28268 = p__28267;
var map__28268__$1 = (((((!((map__28268 == null))))?(((((map__28268.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__28268.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__28268):map__28268);
var opts = map__28268__$1;
var output_dir = cljs.core.get.call(null,map__28268__$1,new cljs.core.Keyword(null,"output-dir","output-dir",-290956991));
var parse_source_loc_info = ((function (map__28268,map__28268__$1,opts,output_dir){
return (function cljs$stacktrace$parse_source_loc_info(x){
if(cljs.core.truth_((function (){var and__4120__auto__ = x;
if(cljs.core.truth_(and__4120__auto__)){
return (!(clojure.string.blank_QMARK_.call(null,x)));
} else {
return and__4120__auto__;
}
})())){
return cljs.stacktrace.parse_int.call(null,x);
} else {
return null;
}
});})(map__28268,map__28268__$1,opts,output_dir))
;
var process_frame = ((function (map__28268,map__28268__$1,opts,output_dir){
return (function cljs$stacktrace$process_frame(frame_str){
if(((clojure.string.blank_QMARK_.call(null,frame_str)) || ((cljs.core.re_find.call(null,/^\s+at/,frame_str) == null)))){
return null;
} else {
var frame_str__$1 = clojure.string.replace.call(null,frame_str,/\s+at\s+/,"");
if(clojure.string.starts_with_QMARK_.call(null,frame_str__$1,"repl:")){
return null;
} else {
var parts = clojure.string.split.call(null,frame_str__$1,/\s+/);
var vec__28277 = ((((2) === cljs.core.count.call(null,parts)))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.first.call(null,parts),cljs.core.subs.call(null,cljs.core.second.call(null,parts),(1),(cljs.core.count.call(null,cljs.core.second.call(null,parts)) - (1)))], null):new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,cljs.core.first.call(null,parts)], null));
var function$ = cljs.core.nth.call(null,vec__28277,(0),null);
var file_AMPERSAND_line = cljs.core.nth.call(null,vec__28277,(1),null);
var vec__28280 = clojure.string.split.call(null,file_AMPERSAND_line,/:/);
var file_part = cljs.core.nth.call(null,vec__28280,(0),null);
var line_part = cljs.core.nth.call(null,vec__28280,(1),null);
var col_part = cljs.core.nth.call(null,vec__28280,(2),null);
return new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"file","file",-1269645878),(cljs.core.truth_(function$)?(function (){var G__28283 = file_part;
if(cljs.core.truth_(output_dir)){
return clojure.string.replace.call(null,G__28283,[cljs.core.str.cljs$core$IFn$_invoke$arity$1(output_dir),"/"].join(''),"");
} else {
return G__28283;
}
})():file_part),new cljs.core.Keyword(null,"function","function",-2127255473),function$,new cljs.core.Keyword(null,"line","line",212345235),parse_source_loc_info.call(null,line_part),new cljs.core.Keyword(null,"column","column",2078222095),parse_source_loc_info.call(null,col_part)], null);
}
}
});})(map__28268,map__28268__$1,opts,output_dir))
;
return cljs.core.vec.call(null,cljs.core.remove.call(null,cljs.core.nil_QMARK_,cljs.core.map.call(null,process_frame,clojure.string.split.call(null,st,/\n/))));
}));
cljs.stacktrace.remove_ext = (function cljs$stacktrace$remove_ext(file){
return clojure.string.replace.call(null,clojure.string.replace.call(null,clojure.string.replace.call(null,clojure.string.replace.call(null,file,/\.js$/,""),/\.cljs$/,""),/\.cljc$/,""),/\.clj$/,"");
});
/**
* Given a cljs.source-map source map data structure map a generated line
* and column back to the original line, column, and function called.
*/
cljs.stacktrace.mapped_line_column_call = (function cljs$stacktrace$mapped_line_column_call(sms,file,line,column){
var source_map = cljs.core.get.call(null,sms,cljs.core.symbol.call(null,clojure.string.replace.call(null,cljs.stacktrace.remove_ext.call(null,file),"/",".")));
var get_best_column = ((function (source_map){
return (function cljs$stacktrace$mapped_line_column_call_$_get_best_column(columns,column__$1){
return cljs.core.last.call(null,(function (){var or__4131__auto__ = cljs.core.get.call(null,columns,cljs.core.last.call(null,cljs.core.filter.call(null,((function (source_map){
return (function (p1__28284_SHARP_){
return (p1__28284_SHARP_ <= (column__$1 - (1)));
});})(source_map))
,cljs.core.sort.call(null,cljs.core.keys.call(null,columns)))));
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return cljs.core.second.call(null,cljs.core.first.call(null,columns));
}
})());
});})(source_map))
;
var adjust = ((function (source_map){
return (function cljs$stacktrace$mapped_line_column_call_$_adjust(mapped){
return cljs.core.vec.call(null,cljs.core.map.call(null,((function (source_map){
return (function (p1__28285_SHARP_,p2__28286_SHARP_){
return p1__28285_SHARP_.call(null,p2__28286_SHARP_);
});})(source_map))
,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.inc,cljs.core.inc,cljs.core.identity], null),mapped));
});})(source_map))
;
var default$ = new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [line,column,null], null);
var temp__5718__auto__ = cljs.core.get.call(null,source_map,(line - (1)));
if(cljs.core.truth_(temp__5718__auto__)){
var columns = temp__5718__auto__;
return adjust.call(null,cljs.core.map.call(null,get_best_column.call(null,columns,column),new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"line","line",212345235),new cljs.core.Keyword(null,"col","col",-1959363084),new cljs.core.Keyword(null,"name","name",1843675177)], null)));
} else {
return default$;
}
});
/**
* Given opts and a canonicalized JavaScript stacktrace frame, return the
* ClojureScript frame.
*/
cljs.stacktrace.mapped_frame = (function cljs$stacktrace$mapped_frame(p__28287,sms,opts){
var map__28288 = p__28287;
var map__28288__$1 = (((((!((map__28288 == null))))?(((((map__28288.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__28288.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__28288):map__28288);
var function$ = cljs.core.get.call(null,map__28288__$1,new cljs.core.Keyword(null,"function","function",-2127255473));
var file = cljs.core.get.call(null,map__28288__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line = cljs.core.get.call(null,map__28288__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column = cljs.core.get.call(null,map__28288__$1,new cljs.core.Keyword(null,"column","column",2078222095));
var no_source_file_QMARK_ = ((cljs.core.not.call(null,file))?true:cljs.stacktrace.starts_with_QMARK_.call(null,file,"<"));
var vec__28290 = ((no_source_file_QMARK_)?new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [line,column,null], null):cljs.stacktrace.mapped_line_column_call.call(null,sms,file,line,column));
var line_SINGLEQUOTE_ = cljs.core.nth.call(null,vec__28290,(0),null);
var column_SINGLEQUOTE_ = cljs.core.nth.call(null,vec__28290,(1),null);
var call = cljs.core.nth.call(null,vec__28290,(2),null);
var file_SINGLEQUOTE_ = ((no_source_file_QMARK_)?null:((cljs.stacktrace.ends_with_QMARK_.call(null,file,".js"))?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.subs.call(null,file,(0),(cljs.core.count.call(null,file) - (3)))),".cljs"].join(''):file));
return new cljs.core.PersistentArrayMap(null, 5, [new cljs.core.Keyword(null,"function","function",-2127255473),function$,new cljs.core.Keyword(null,"call","call",-519999866),call,new cljs.core.Keyword(null,"file","file",-1269645878),((no_source_file_QMARK_)?["NO_SOURCE_FILE",(cljs.core.truth_(file)?[" ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(file)].join(''):null)].join(''):file_SINGLEQUOTE_),new cljs.core.Keyword(null,"line","line",212345235),line_SINGLEQUOTE_,new cljs.core.Keyword(null,"column","column",2078222095),column_SINGLEQUOTE_], null);
});
/**
* Given a vector representing the canonicalized JavaScript stacktrace
* return the ClojureScript stacktrace. The canonical stacktrace must be
* in the form:
*
* [{:file <string>
* :function <string>
* :line <integer>
* :column <integer>}*]
*
* :file must be a URL path (without protocol) relative to :output-dir or a
* identifier delimited by angle brackets. The returned mapped stacktrace will
* also contain :url entries to the original sources if it can be determined
* from the classpath.
*/
cljs.stacktrace.mapped_stacktrace = (function cljs$stacktrace$mapped_stacktrace(var_args){
var G__28296 = arguments.length;
switch (G__28296) {
case 2:
return cljs.stacktrace.mapped_stacktrace.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 3:
return cljs.stacktrace.mapped_stacktrace.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
cljs.stacktrace.mapped_stacktrace.cljs$core$IFn$_invoke$arity$2 = (function (stacktrace,sms){
return cljs.stacktrace.mapped_stacktrace.call(null,stacktrace,sms,null);
});
cljs.stacktrace.mapped_stacktrace.cljs$core$IFn$_invoke$arity$3 = (function (stacktrace,sms,opts){
var call__GT_function = (function cljs$stacktrace$call__GT_function(x){
if(cljs.core.truth_(new cljs.core.Keyword(null,"call","call",-519999866).cljs$core$IFn$_invoke$arity$1(x))){
return cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null,"function","function",-2127255473)],[new cljs.core.Keyword(null,"call","call",-519999866).cljs$core$IFn$_invoke$arity$1(x)]);
} else {
return cljs.core.PersistentArrayMap.EMPTY;
}
});
var call_merge = (function cljs$stacktrace$call_merge(function$,call){
return cljs.core.merge_with.call(null,(function (munged_fn_name,unmunged_call_name){
if(cljs.core._EQ_.call(null,munged_fn_name,clojure.string.replace.call(null,cljs.core.munge.call(null,unmunged_call_name),".","$"))){
return unmunged_call_name;
} else {
return munged_fn_name;
}
}),function$,call);
});
var mapped_frames = cljs.core.map.call(null,cljs.core.memoize.call(null,(function (p1__28293_SHARP_){
return cljs.stacktrace.mapped_frame.call(null,p1__28293_SHARP_,sms,opts);
})),stacktrace);
return cljs.core.vec.call(null,cljs.core.map.call(null,call_merge,cljs.core.map.call(null,((function (mapped_frames){
return (function (p1__28294_SHARP_){
return cljs.core.dissoc.call(null,p1__28294_SHARP_,new cljs.core.Keyword(null,"call","call",-519999866));
});})(mapped_frames))
,mapped_frames),cljs.core.concat.call(null,cljs.core.rest.call(null,cljs.core.map.call(null,call__GT_function,mapped_frames)),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.PersistentArrayMap.EMPTY], null))));
});
cljs.stacktrace.mapped_stacktrace.cljs$lang$maxFixedArity = 3;
/**
* Given a vector representing the canonicalized JavaScript stacktrace and a map
* of library names to decoded source maps, print the ClojureScript stacktrace .
* See mapped-stacktrace.
*/
cljs.stacktrace.mapped_stacktrace_str = (function cljs$stacktrace$mapped_stacktrace_str(var_args){
var G__28299 = arguments.length;
switch (G__28299) {
case 2:
return cljs.stacktrace.mapped_stacktrace_str.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 3:
return cljs.stacktrace.mapped_stacktrace_str.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
cljs.stacktrace.mapped_stacktrace_str.cljs$core$IFn$_invoke$arity$2 = (function (stacktrace,sms){
return cljs.stacktrace.mapped_stacktrace_str.call(null,stacktrace,sms,null);
});
cljs.stacktrace.mapped_stacktrace_str.cljs$core$IFn$_invoke$arity$3 = (function (stacktrace,sms,opts){
var sb__4661__auto__ = (new goog.string.StringBuffer());
var _STAR_print_newline_STAR__orig_val__28300_28317 = cljs.core._STAR_print_newline_STAR_;
var _STAR_print_fn_STAR__orig_val__28301_28318 = cljs.core._STAR_print_fn_STAR_;
var _STAR_print_newline_STAR__temp_val__28302_28319 = true;
var _STAR_print_fn_STAR__temp_val__28303_28320 = ((function (_STAR_print_newline_STAR__orig_val__28300_28317,_STAR_print_fn_STAR__orig_val__28301_28318,_STAR_print_newline_STAR__temp_val__28302_28319,sb__4661__auto__){
return (function (x__4662__auto__){
return sb__4661__auto__.append(x__4662__auto__);
});})(_STAR_print_newline_STAR__orig_val__28300_28317,_STAR_print_fn_STAR__orig_val__28301_28318,_STAR_print_newline_STAR__temp_val__28302_28319,sb__4661__auto__))
;
cljs.core._STAR_print_newline_STAR_ = _STAR_print_newline_STAR__temp_val__28302_28319;
cljs.core._STAR_print_fn_STAR_ = _STAR_print_fn_STAR__temp_val__28303_28320;
try{var seq__28304_28321 = cljs.core.seq.call(null,cljs.stacktrace.mapped_stacktrace.call(null,stacktrace,sms,opts));
var chunk__28305_28322 = null;
var count__28306_28323 = (0);
var i__28307_28324 = (0);
while(true){
if((i__28307_28324 < count__28306_28323)){
var map__28312_28325 = cljs.core._nth.call(null,chunk__28305_28322,i__28307_28324);
var map__28312_28326__$1 = (((((!((map__28312_28325 == null))))?(((((map__28312_28325.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__28312_28325.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__28312_28325):map__28312_28325);
var function_28327 = cljs.core.get.call(null,map__28312_28326__$1,new cljs.core.Keyword(null,"function","function",-2127255473));
var file_28328 = cljs.core.get.call(null,map__28312_28326__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line_28329 = cljs.core.get.call(null,map__28312_28326__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column_28330 = cljs.core.get.call(null,map__28312_28326__$1,new cljs.core.Keyword(null,"column","column",2078222095));
cljs.core.println.call(null,"\t",[(cljs.core.truth_(function_28327)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(function_28327)," "].join(''):null),"(",cljs.core.str.cljs$core$IFn$_invoke$arity$1(file_28328),(cljs.core.truth_(line_28329)?[":",cljs.core.str.cljs$core$IFn$_invoke$arity$1(line_28329)].join(''):null),(cljs.core.truth_(column_28330)?[":",cljs.core.str.cljs$core$IFn$_invoke$arity$1(column_28330)].join(''):null),")"].join(''));
var G__28331 = seq__28304_28321;
var G__28332 = chunk__28305_28322;
var G__28333 = count__28306_28323;
var G__28334 = (i__28307_28324 + (1));
seq__28304_28321 = G__28331;
chunk__28305_28322 = G__28332;
count__28306_28323 = G__28333;
i__28307_28324 = G__28334;
continue;
} else {
var temp__5720__auto___28335 = cljs.core.seq.call(null,seq__28304_28321);
if(temp__5720__auto___28335){
var seq__28304_28336__$1 = temp__5720__auto___28335;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__28304_28336__$1)){
var c__4550__auto___28337 = cljs.core.chunk_first.call(null,seq__28304_28336__$1);
var G__28338 = cljs.core.chunk_rest.call(null,seq__28304_28336__$1);
var G__28339 = c__4550__auto___28337;
var G__28340 = cljs.core.count.call(null,c__4550__auto___28337);
var G__28341 = (0);
seq__28304_28321 = G__28338;
chunk__28305_28322 = G__28339;
count__28306_28323 = G__28340;
i__28307_28324 = G__28341;
continue;
} else {
var map__28314_28342 = cljs.core.first.call(null,seq__28304_28336__$1);
var map__28314_28343__$1 = (((((!((map__28314_28342 == null))))?(((((map__28314_28342.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__28314_28342.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__28314_28342):map__28314_28342);
var function_28344 = cljs.core.get.call(null,map__28314_28343__$1,new cljs.core.Keyword(null,"function","function",-2127255473));
var file_28345 = cljs.core.get.call(null,map__28314_28343__$1,new cljs.core.Keyword(null,"file","file",-1269645878));
var line_28346 = cljs.core.get.call(null,map__28314_28343__$1,new cljs.core.Keyword(null,"line","line",212345235));
var column_28347 = cljs.core.get.call(null,map__28314_28343__$1,new cljs.core.Keyword(null,"column","column",2078222095));
cljs.core.println.call(null,"\t",[(cljs.core.truth_(function_28344)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(function_28344)," "].join(''):null),"(",cljs.core.str.cljs$core$IFn$_invoke$arity$1(file_28345),(cljs.core.truth_(line_28346)?[":",cljs.core.str.cljs$core$IFn$_invoke$arity$1(line_28346)].join(''):null),(cljs.core.truth_(column_28347)?[":",cljs.core.str.cljs$core$IFn$_invoke$arity$1(column_28347)].join(''):null),")"].join(''));
var G__28348 = cljs.core.next.call(null,seq__28304_28336__$1);
var G__28349 = null;
var G__28350 = (0);
var G__28351 = (0);
seq__28304_28321 = G__28348;
chunk__28305_28322 = G__28349;
count__28306_28323 = G__28350;
i__28307_28324 = G__28351;
continue;
}
} else {
}
}
break;
}
}finally {cljs.core._STAR_print_fn_STAR_ = _STAR_print_fn_STAR__orig_val__28301_28318;
cljs.core._STAR_print_newline_STAR_ = _STAR_print_newline_STAR__orig_val__28300_28317;
}
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb__4661__auto__);
});
cljs.stacktrace.mapped_stacktrace_str.cljs$lang$maxFixedArity = 3;
//# sourceMappingURL=stacktrace.js.map?rel=1582560150591

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,950 @@
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns ^{:doc "A clojure reader in clojure"
:author "Bronsa"}
cljs.tools.reader
(:refer-clojure :exclude [read read-line read-string char read+string
default-data-readers *default-data-reader-fn*
*data-readers* *suppress-read*])
(:require-macros [cljs.tools.reader.reader-types :refer [log-source]])
(:require [cljs.tools.reader.reader-types :refer
[read-char unread peek-char indexing-reader?
get-line-number get-column-number get-file-name
string-push-back-reader]]
[cljs.tools.reader.impl.utils :refer
[char ex-info? whitespace? numeric? desugar-meta next-id namespace-keys second'
ReaderConditional reader-conditional reader-conditional? char-code]]
[cljs.tools.reader.impl.commons :refer
[number-literal? read-past match-number parse-symbol read-comment throwing-reader]]
[cljs.tools.reader.impl.errors :as err]
[goog.array :as garray]
[goog.string :as gstring])
(:import goog.string.StringBuffer))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; helpers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(declare ^:private read*
macros dispatch-macros
^:dynamic *data-readers*
^:dynamic *default-data-reader-fn*
^:dynamic *suppress-read*
default-data-readers)
(defn- ^boolean macro-terminating? [ch]
(case ch
(\" \; \@ \^ \` \~ \( \) \[ \] \{ \} \\) true
false))
(def sb (StringBuffer.))
(defn- read-token
"Read in a single logical token from the reader"
[^not-native rdr kind initch]
(if (nil? initch)
(err/throw-eof-at-start rdr kind)
(do
(.clear sb)
(loop [ch initch]
(if (or (whitespace? ch)
(macro-terminating? ch)
(nil? ch))
(do
(when-not (nil? ch)
(unread rdr ch))
(.toString sb))
(do
(.append sb ch)
(recur (read-char rdr))))))))
(declare read-tagged)
(defn- read-dispatch
[^not-native rdr _ opts pending-forms]
(if-let [ch (read-char rdr)]
(if-let [dm (dispatch-macros ch)]
(dm rdr ch opts pending-forms)
(read-tagged (doto rdr (unread ch)) ch opts pending-forms)) ;; ctor reader is implemented as a tagged literal
(err/throw-eof-at-dispatch rdr)))
(defn- read-unmatched-delimiter
[rdr ch opts pending-forms]
(err/throw-unmatch-delimiter rdr ch))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; readers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn read-regex
[^not-native rdr ch opts pending-forms]
(let [sb (StringBuffer.)]
(loop [ch (read-char rdr)]
(if (identical? \" ch)
(re-pattern (str sb))
(if (nil? ch)
(err/throw-eof-reading rdr :regex sb)
(do
(.append sb ch )
(when (identical? \\ ch)
(let [ch (read-char rdr)]
(if (nil? ch)
(err/throw-eof-reading rdr :regex sb))
(.append sb ch)))
(recur (read-char rdr))))))))
(defn- read-unicode-char
([token offset length base]
(let [l (+ offset length)]
(when-not (== (count token) l)
(err/throw-invalid-unicode-literal nil token))
(loop [i offset uc 0]
(if (== i l)
(js/String.fromCharCode uc)
(let [d (char-code (nth token i) base)]
(if (== d -1)
(err/throw-invalid-unicode-digit-in-token nil (nth token i) token)
(recur (inc i) (+ d (* uc base)))))))))
([^not-native rdr initch base length exact?]
(loop [i 1 uc (char-code initch base)]
(if (== uc -1)
(err/throw-invalid-unicode-digit rdr initch)
(if-not (== i length)
(let [ch (peek-char rdr)]
(if (or (whitespace? ch)
(macros ch)
(nil? ch))
(if exact?
(err/throw-invalid-unicode-len rdr i length)
(js/String.fromCharCode uc))
(let [d (char-code ch base)]
(read-char rdr)
(if (== d -1)
(err/throw-invalid-unicode-digit rdr ch)
(recur (inc i) (+ d (* uc base)))))))
(js/String.fromCharCode uc))))))
(def ^:private ^:const upper-limit (.charCodeAt \uD7ff 0))
(def ^:private ^:const lower-limit (.charCodeAt \uE000 0))
(defn- valid-octal? [token base]
(<= (js/parseInt token base) 0377))
(defn- read-char*
"Read in a character literal"
[^not-native rdr backslash opts pending-forms]
(let [ch (read-char rdr)]
(if-not (nil? ch)
(let [token (if (or (macro-terminating? ch)
(whitespace? ch))
(str ch)
(read-token rdr :character ch))
token-len (. token -length)]
(cond
(== 1 token-len) (.charAt token 0) ;;; no char type - so can't ensure/cache char
(= token "newline") \newline
(= token "space") \space
(= token "tab") \tab
(= token "backspace") \backspace
(= token "formfeed") \formfeed
(= token "return") \return
(gstring/startsWith token "u")
(let [c (read-unicode-char token 1 4 16)
ic (.charCodeAt c 0)]
(if (and (> ic upper-limit)
(< ic lower-limit))
(err/throw-invalid-character-literal rdr (.toString ic 16))
c))
(gstring/startsWith token "o")
(let [len (dec token-len)]
(if (> len 3)
(err/throw-invalid-octal-len rdr token)
(let [offset 1
base 8
uc (read-unicode-char token offset len base)]
(if-not (valid-octal? (subs token offset) base)
(err/throw-bad-octal-number rdr)
uc))))
:else (err/throw-unsupported-character rdr token)))
(err/throw-eof-in-character rdr))))
(defn- starting-line-col-info [^not-native rdr]
(when (indexing-reader? rdr)
[(get-line-number rdr) (int (dec (get-column-number rdr)))]))
(defn- ending-line-col-info [^not-native rdr]
(when (indexing-reader? rdr)
[(get-line-number rdr) (get-column-number rdr)]))
(defonce ^:private READ_EOF (js/Object.))
(defonce ^:private READ_FINISHED (js/Object.))
(def ^:dynamic *read-delim* false)
(defn- read-delimited-internal [kind delim rdr opts pending-forms]
(let [[start-line start-column] (starting-line-col-info rdr)
delim (char delim)]
(loop [a (transient [])]
(let [form (read* rdr false READ_EOF delim opts pending-forms)]
(if (identical? form READ_FINISHED)
(persistent! a)
(if (identical? form READ_EOF)
(err/throw-eof-delimited rdr kind start-line start-column (count a))
(recur (conj! a form))))))))
(defn- read-delimited
"Reads and returns a collection ended with delim"
[kind delim rdr opts pending-forms]
(binding [*read-delim* true]
(read-delimited-internal kind delim rdr opts pending-forms)))
(defn- read-list
"Read in a list, including its location if the reader is an indexing reader"
[rdr _ opts pending-forms]
(let [[start-line start-column] (starting-line-col-info rdr)
the-list (read-delimited :list \) rdr opts pending-forms)
[end-line end-column] (ending-line-col-info rdr)]
(with-meta (if (empty? the-list)
'()
(apply list the-list))
(when start-line
(merge
(when-let [file (get-file-name rdr)]
{:file file})
{:line start-line
:column start-column
:end-line end-line
:end-column end-column})))))
(defn- read-vector
"Read in a vector, including its location if the reader is an indexing reader"
[rdr _ opts pending-forms]
(let [[start-line start-column] (starting-line-col-info rdr)
the-vector (read-delimited :vector \] rdr opts pending-forms)
[end-line end-column] (ending-line-col-info rdr)]
(with-meta the-vector
(when start-line
(merge
(when-let [file (get-file-name rdr)]
{:file file})
{:line start-line
:column start-column
:end-line end-line
:end-column end-column})))))
(defn- read-map
"Read in a map, including its location if the reader is an indexing reader"
[rdr _ opts pending-forms]
(let [[start-line start-column] (starting-line-col-info rdr)
the-map (read-delimited :map \} rdr opts pending-forms)
map-count (count the-map)
ks (take-nth 2 the-map)
key-set (set ks)
[end-line end-column] (ending-line-col-info rdr)]
(when (odd? map-count)
(err/throw-odd-map rdr start-line start-column the-map))
(when-not (= (count key-set) (count ks))
(err/throw-dup-keys rdr :map ks))
(with-meta
(if (<= map-count (* 2 (.-HASHMAP-THRESHOLD cljs.core/PersistentArrayMap)))
(.fromArray cljs.core/PersistentArrayMap (to-array the-map) true true)
(.fromArray cljs.core/PersistentHashMap (to-array the-map) true))
(when start-line
(merge
(when-let [file (get-file-name rdr)]
{:file file})
{:line start-line
:column start-column
:end-line end-line
:end-column end-column})))))
(defn- read-number
[^not-native rdr initch]
(loop [sb (doto (StringBuffer.) (.append initch))
ch (read-char rdr)]
(if (or (whitespace? ch) (macros ch) (nil? ch))
(let [s (str sb)]
(unread rdr ch)
(or (match-number s)
(err/throw-invalid-number rdr s)))
(recur (doto sb (.append ch)) (read-char rdr)))))
(defn- escape-char [sb ^not-native rdr]
(let [ch (read-char rdr)]
(case ch
\t "\t"
\r "\r"
\n "\n"
\\ "\\"
\" "\""
\b "\b"
\f "\f"
\u (let [ch (read-char rdr)]
(if (== -1 (js/parseInt (int ch) 16))
(err/throw-invalid-unicode-escape rdr ch)
(read-unicode-char rdr ch 16 4 true)))
(if (numeric? ch)
(let [ch (read-unicode-char rdr ch 8 3 false)]
(if (> (int ch) 0377)
(err/throw-bad-octal-number rdr)
ch))
(err/throw-bad-escape-char rdr ch)))))
(defn- read-string*
[^not-native reader _ opts pending-forms]
(loop [sb (StringBuffer.)
ch (read-char reader)]
(if (nil? ch)
(err/throw-eof-reading reader :string \" sb)
(case ch
\\ (recur (doto sb (.append (escape-char sb reader)))
(read-char reader))
\" (str sb)
(recur (doto sb (.append ch)) (read-char reader))))))
(defn- loc-info [rdr line column]
(when-not (nil? line)
(let [file (get-file-name rdr)
filem (when-not (nil? file) {:file file})
[end-line end-column] (ending-line-col-info rdr)
lcm {:line line
:column column
:end-line end-line
:end-column end-column}]
(merge filem lcm))))
(defn- read-symbol
[rdr initch]
(let [[line column] (starting-line-col-info rdr)
token (read-token rdr :symbol initch)]
(when-not (nil? token)
(case token
;; special symbols
"nil" nil
"true" true
"false" false
"/" '/
(let [^not-native p (parse-symbol token)]
(if-not (nil? p)
(let [^not-native sym (symbol (-nth p 0) (-nth p 1))]
(-with-meta sym (loc-info rdr line column)))
(err/throw-invalid rdr :symbol token)))))))
(def ^:dynamic *alias-map*
"Map from ns alias to ns, if non-nil, it will be used to resolve read-time
ns aliases.
Defaults to nil"
nil)
(defn- resolve-alias [sym]
(get *alias-map* sym))
(defn- resolve-ns [sym]
(or (resolve-alias sym)
(when-let [ns (find-ns sym)]
(symbol (ns-name ns)))))
(defn- read-keyword
[^not-native reader initch opts pending-forms]
(let [ch (read-char reader)]
(if-not (whitespace? ch)
(let [token (read-token reader :keyword ch)
^not-native s (parse-symbol token)]
(if-not (nil? s)
(let [ns (-nth s 0)
name (-nth s 1)]
(if (identical? \: (.charAt token 0))
(if-not (nil? ns)
(if-let [ns (resolve-alias (symbol (subs ns 1)))]
(keyword (str ns) name)
(err/throw-invalid reader :keyword (str \: token)))
(if-let [ns *ns*]
(keyword (str ns) (subs name 1))
(err/reader-error reader "Invalid token: :" token)))
(keyword ns name)))
(err/throw-invalid reader :keyword (str \: token))))
(err/throw-single-colon reader))))
(defn- wrapping-reader
"Returns a function which wraps a reader in a call to sym"
[sym]
(fn [rdr _ opts pending-forms]
(list sym (read* rdr true nil opts pending-forms))))
(defn- read-meta
"Read metadata and return the following object with the metadata applied"
[rdr _ opts pending-forms]
(log-source rdr
(let [[line column] (starting-line-col-info rdr)
m (desugar-meta (read* rdr true nil opts pending-forms))]
(when-not (map? m)
(err/throw-bad-metadata rdr m))
(let [o (read* rdr true nil opts pending-forms)]
(if (implements? IMeta o)
(let [m (if (and line (seq? o))
(assoc m :line line :column column)
m)]
(if (implements? IWithMeta o)
(with-meta o (merge (meta o) m))
(reset-meta! o m)))
(err/throw-bad-metadata-target rdr o))))))
(defn- read-set
[rdr _ opts pending-forms]
(let [[start-line start-column] (starting-line-col-info rdr)
;; subtract 1 from start-column so it includes the # in the leading #{
start-column (if start-column (int (dec start-column)))
coll (read-delimited :set \} rdr opts pending-forms)
the-set (set coll)
[end-line end-column] (ending-line-col-info rdr)]
(when-not (= (count coll) (count the-set))
(err/reader-error rdr (err/throw-dup-keys rdr :set coll)))
(with-meta the-set
(when start-line
(merge
(when-let [file (get-file-name rdr)]
{:file file})
{:line start-line
:column start-column
:end-line end-line
:end-column end-column})))))
(defn- read-discard
"Read and discard the first object from rdr"
[rdr _ opts pending-forms]
(doto rdr
(read* true nil opts pending-forms)))
(defn- read-symbolic-value
[rdr _ opts pending-forms]
(let [sym (read* rdr true nil opts pending-forms)]
(case sym
NaN js/Number.NaN
-Inf js/Number.NEGATIVE_INFINITY
Inf js/Number.POSITIVE_INFINITY
(err/reader-error rdr (str "Invalid token: ##" sym)))))
(def ^:private RESERVED_FEATURES #{:else :none})
(defn- has-feature?
[rdr feature opts]
(if (keyword? feature)
(or (= :default feature) (contains? (get opts :features) feature))
(err/reader-error rdr "Feature should be a keyword: " feature)))
(defn- check-eof-error
[form rdr first-line]
(when (identical? form READ_EOF)
(err/throw-eof-error rdr (and (< first-line 0) first-line))))
(defn- check-reserved-features
[rdr form]
(when (get RESERVED_FEATURES form)
(err/reader-error rdr "Feature name " form " is reserved")))
(defn- check-invalid-read-cond
[form rdr first-line]
(when (identical? form READ_FINISHED)
(if (< first-line 0)
(err/reader-error rdr "read-cond requires an even number of forms")
(err/reader-error rdr "read-cond starting on line " first-line " requires an even number of forms"))))
(defn- read-suppress
"Read next form and suppress. Return nil or READ_FINISHED."
[first-line rdr opts pending-forms]
(binding [*suppress-read* true]
(let [form (read* rdr false READ_EOF \) opts pending-forms)]
(check-eof-error form rdr first-line)
(when (identical? form READ_FINISHED)
READ_FINISHED))))
(defonce ^:private NO_MATCH (js/Object.))
(defn- match-feature
"Read next feature. If matched, read next form and return.
Otherwise, read and skip next form, returning READ_FINISHED or nil."
[first-line rdr opts pending-forms]
(let [feature (read* rdr false READ_EOF \) opts pending-forms)]
(check-eof-error feature rdr first-line)
(if (= feature READ_FINISHED)
READ_FINISHED
(do
(check-reserved-features rdr feature)
(if (has-feature? rdr feature opts)
;; feature matched, read selected form
(doto (read* rdr false READ_EOF \) opts pending-forms)
(check-eof-error rdr first-line)
(check-invalid-read-cond rdr first-line))
;; feature not matched, ignore next form
(or (read-suppress first-line rdr opts pending-forms)
NO_MATCH))))))
(defn- read-cond-delimited
[rdr splicing opts pending-forms]
(let [first-line (if (indexing-reader? rdr) (get-line-number rdr) -1)
result (loop [matched NO_MATCH
finished nil]
(cond
;; still looking for match, read feature+form
(identical? matched NO_MATCH)
(let [match (match-feature first-line rdr opts pending-forms)]
(if (identical? match READ_FINISHED)
READ_FINISHED
(recur match nil)))
;; found match, just read and ignore the rest
(not (identical? finished READ_FINISHED))
(recur matched (read-suppress first-line rdr opts pending-forms))
:else
matched))]
(if (identical? result READ_FINISHED)
rdr
(if splicing
(do
(if (implements? ISequential result)
(do
(garray/insertArrayAt pending-forms (to-array result) 0)
rdr)
(err/reader-error rdr "Spliced form list in read-cond-splicing must implement ISequential")))
result))))
(defn- read-cond
[^not-native rdr _ opts pending-forms]
(when (not (and opts (#{:allow :preserve} (:read-cond opts))))
(throw (ex-info "Conditional read not allowed"
{:type :runtime-exception})))
(if-let [ch (read-char rdr)]
(let [splicing (= ch \@)
ch (if splicing (read-char rdr) ch)]
(when splicing
(when-not *read-delim*
(err/reader-error rdr "cond-splice not in list")))
(if-let [ch (if (whitespace? ch) (read-past whitespace? rdr) ch)]
(if (not= ch \()
(throw (ex-info "read-cond body must be a list"
{:type :runtime-exception}))
(binding [*suppress-read* (or *suppress-read* (= :preserve (:read-cond opts)))]
(if *suppress-read*
(reader-conditional (read-list rdr ch opts pending-forms) splicing)
(read-cond-delimited rdr splicing opts pending-forms))))
(err/throw-eof-in-character rdr)))
(err/throw-eof-in-character rdr)))
(def ^:private ^:dynamic arg-env nil)
(defn- garg
"Get a symbol for an anonymous ?argument?"
[n]
(symbol (str (if (== -1 n) "rest" (str "p" n))
"__" (next-id) "#")))
(defn- read-fn
[rdr _ opts pending-forms]
(if arg-env
(throw (ex-info "Nested #()s are not allowed" {:type :illegal-state})))
(binding [arg-env (sorted-map)]
(let [form (read* (doto rdr (unread \()) true nil opts pending-forms) ;; this sets bindings
rargs (rseq arg-env)
args (if rargs
(let [higharg (key (first rargs))]
(let [args (loop [i 1 args (transient [])]
(if (> i higharg)
(persistent! args)
(recur (inc i) (conj! args (or (get arg-env i)
(garg i))))))
args (if (arg-env -1)
(conj args '& (arg-env -1))
args)]
args))
[])]
(list 'fn* args form))))
(defn- register-arg
"Registers an argument to the arg-env"
[n]
(if arg-env
(if-let [ret (arg-env n)]
ret
(let [g (garg n)]
(set! arg-env (assoc arg-env n g))
g))
(throw (ex-info "Arg literal not in #()"
{:type :illegal-state})))) ;; should never hit this
(declare read-symbol)
(defn- read-arg
[^not-native rdr pct opts pending-forms]
(if (nil? arg-env)
(read-symbol rdr pct)
(let [ch (peek-char rdr)]
(cond
(or (whitespace? ch)
(macro-terminating? ch)
(nil? ch))
(register-arg 1)
(= ch \&)
(do (read-char rdr)
(register-arg -1))
:else
(let [n (read* rdr true nil opts pending-forms)]
(if-not (integer? n)
(throw (ex-info "Arg literal must be %, %& or %integer"
{:type :illegal-state}))
(register-arg n)))))))
(def ^:private ^:dynamic gensym-env nil)
(defn- read-unquote
[^not-native rdr comma opts pending-forms]
(if-let [ch (peek-char rdr)]
(if (= \@ ch)
((wrapping-reader 'clojure.core/unquote-splicing) (doto rdr read-char) \@ opts pending-forms)
((wrapping-reader 'clojure.core/unquote) rdr \~ opts pending-forms))))
(declare syntax-quote*)
(defn- unquote-splicing? [form]
(and (seq? form)
(= (first form) 'clojure.core/unquote-splicing)))
(defn- unquote? [form]
(and (seq? form)
(= (first form) 'clojure.core/unquote)))
(defn- expand-list
"Expand a list by resolving its syntax quotes and unquotes"
[s]
(loop [s (seq s) r (transient [])]
(if s
(let [item (first s)
ret (conj! r
(cond
(unquote? item) (list 'clojure.core/list (second item))
(unquote-splicing? item) (second item)
:else (list 'clojure.core/list (syntax-quote* item))))]
(recur (next s) ret))
(seq (persistent! r)))))
(defn- flatten-map
"Flatten a map into a seq of alternate keys and values"
[form]
(loop [s (seq form) key-vals (transient [])]
(if s
(let [e (first s)]
(recur (next s) (-> key-vals
(conj! (key e))
(conj! (val e)))))
(seq (persistent! key-vals)))))
(defn- register-gensym [sym]
(if-not gensym-env
(throw (ex-info "Gensym literal not in syntax-quote"
{:type :illegal-state})))
(or (get gensym-env sym)
(let [gs (symbol (str (subs (name sym)
0 (dec (count (name sym))))
"__" (next-id) "__auto__"))]
(set! gensym-env (assoc gensym-env sym gs))
gs)))
(defn- add-meta [form ret]
(if (and (implements? IWithMeta form)
(seq (dissoc (meta form) :line :column :end-line :end-column :file :source)))
(list 'cljs.core/with-meta ret (syntax-quote* (meta form)))
ret))
(defn- syntax-quote-coll [type coll]
(let [res (list 'cljs.core/sequence
(cons 'cljs.core/concat
(expand-list coll)))]
(if type
(list 'cljs.core/apply type res)
res)))
(defn map-func
"Decide which map type to use, array-map if less than 16 elements"
[coll]
(if (>= (count coll) 16)
'cljs.core/hash-map
'cljs.core/array-map))
(defn bool? [x]
(or (instance? js/Boolean x)
(true? x)
(false? x)))
(defn ^:dynamic resolve-symbol
"Resolve a symbol s into its fully qualified namespace version"
[s]
(throw (ex-info "resolve-symbol is not implemented" {:sym s})))
(defn- syntax-quote* [form]
(->>
(cond
(special-symbol? form) (list 'quote form)
(symbol? form)
(list 'quote
(if (and (not (namespace form))
(gstring/endsWith (name form) "#"))
(register-gensym form)
(let [sym (str form)]
(if (gstring/endsWith sym ".")
(let [csym (symbol (subs sym 0 (dec (count sym))))]
(symbol (str (resolve-symbol csym) ".")))
(resolve-symbol form)))))
(unquote? form) (second form)
(unquote-splicing? form) (throw (ex-info "unquote-splice not in list"
{:type :illegal-state}))
(coll? form)
(cond
(implements? IRecord form) form
(map? form) (syntax-quote-coll (map-func form) (flatten-map form))
(vector? form) (list 'cljs.core/vec (syntax-quote-coll nil form))
(set? form) (syntax-quote-coll 'cljs.core/hash-set form)
(or (seq? form) (list? form))
(let [seq (seq form)]
(if seq
(syntax-quote-coll nil seq)
'(cljs.core/list)))
:else (throw (ex-info "Unknown Collection type"
{:type :unsupported-operation})))
(or (keyword? form)
(number? form)
(string? form)
(nil? form)
(bool? form)
(instance? js/RegExp form))
form
:else (list 'quote form))
(add-meta form)))
(defn- read-syntax-quote
[rdr backquote opts pending-forms]
(binding [gensym-env {}]
(-> (read* rdr true nil opts pending-forms)
syntax-quote*)))
(defn- read-namespaced-map
[rdr _ opts pending-forms]
(let [token (read-token rdr :namespaced-map (read-char rdr))]
(if-let [ns (cond
(= token ":")
(ns-name *ns*)
(= \: (first token))
(some-> token (subs 1) parse-symbol second' symbol resolve-ns)
:else
(some-> token parse-symbol second'))]
(let [ch (read-past whitespace? rdr)]
(if (identical? ch \{)
(let [items (read-delimited :namespaced-map \} rdr opts pending-forms)]
(when (odd? (count items))
(err/throw-odd-map rdr nil nil items))
(let [keys (namespace-keys (str ns) (take-nth 2 items))
vals (take-nth 2 (rest items))]
(when-not (= (count (set keys)) (count keys))
(err/throw-dup-keys rdr :namespaced-map keys))
(zipmap keys vals)))
(err/throw-ns-map-no-map rdr token)))
(err/throw-bad-ns rdr token))))
(defn- macros [ch]
(case ch
\" read-string*
\: read-keyword
\; read-comment
\' (wrapping-reader 'quote)
\@ (wrapping-reader 'clojure.core/deref)
\^ read-meta
\` read-syntax-quote
\~ read-unquote
\( read-list
\) read-unmatched-delimiter
\[ read-vector
\] read-unmatched-delimiter
\{ read-map
\} read-unmatched-delimiter
\\ read-char*
\% read-arg
\# read-dispatch
nil))
(defn- dispatch-macros [ch]
(case ch
\^ read-meta ;; deprecated
\' (wrapping-reader 'var)
\( read-fn
\{ read-set
\< (throwing-reader "Unreadable form")
\= (throwing-reader "read-eval not supported")
\" read-regex
\! read-comment
\_ read-discard
\? read-cond
\: read-namespaced-map
\# read-symbolic-value
nil))
(defn- read-tagged [^not-native rdr initch opts pending-forms]
(let [tag (read* rdr true nil opts pending-forms)]
(if-not (symbol? tag)
(err/throw-bad-reader-tag rdr tag))
(if *suppress-read*
(tagged-literal tag (read* rdr true nil opts pending-forms))
(if-let [f (or (*data-readers* tag)
(default-data-readers tag))]
(f (read* rdr true nil opts pending-forms))
(if-let [f *default-data-reader-fn*]
(f tag (read* rdr true nil opts pending-forms))
(err/throw-unknown-reader-tag rdr tag))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Public API
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def ^:dynamic *data-readers*
"Map from reader tag symbols to data reader Vars.
Reader tags without namespace qualifiers are reserved for Clojure.
This light version of tools.reader has no implementation for default
reader tags such as #inst and #uuid."
{})
(def ^:dynamic *default-data-reader-fn*
"When no data reader is found for a tag and *default-data-reader-fn*
is non-nil, it will be called with two arguments, the tag and the value.
If *default-data-reader-fn* is nil (the default value), an exception
will be thrown for the unknown tag."
nil)
(def ^:dynamic *suppress-read* false)
(def default-data-readers
"Default map of data reader functions provided by Clojure.
May be overridden by binding *data-readers*"
{})
(defn- read*-internal
[^not-native reader ^boolean eof-error? sentinel return-on opts pending-forms]
(loop []
(log-source reader
(if-not ^boolean (garray/isEmpty pending-forms)
(let [form (aget pending-forms 0)]
(garray/removeAt pending-forms 0)
form)
(let [ch (read-char reader)]
(cond
(whitespace? ch) (recur)
(nil? ch) (if eof-error? (err/throw-eof-error reader nil) sentinel)
(identical? ch return-on) READ_FINISHED
(number-literal? reader ch) (read-number reader ch)
:else (let [f (macros ch)]
(if-not (nil? f)
(let [res (f reader ch opts pending-forms)]
(if (identical? res reader)
(recur)
res))
(read-symbol reader ch)))))))))
(defn- read*
([reader eof-error? sentinel opts pending-forms]
(read* reader eof-error? sentinel nil opts pending-forms))
([^not-native reader eof-error? sentinel return-on opts pending-forms]
(try
(read*-internal reader eof-error? sentinel return-on opts pending-forms)
(catch js/Error e
(if (ex-info? e)
(let [d (ex-data e)]
(if (= :reader-exception (:type d))
(throw e)
(throw (ex-info (.-message e)
(merge {:type :reader-exception}
d
(if (indexing-reader? reader)
{:line (get-line-number reader)
:column (get-column-number reader)
:file (get-file-name reader)}))
e))))
(throw (ex-info (.-message e)
(merge {:type :reader-exception}
(if (indexing-reader? reader)
{:line (get-line-number reader)
:column (get-column-number reader)
:file (get-file-name reader)}))
e)))))))
(defn read
"Reads the first object from an IPushbackReader.
Returns the object read. If EOF, throws if eof-error? is true.
Otherwise returns sentinel. If no stream is providen, *in* will be used.
Opts is a persistent map with valid keys:
:read-cond - :allow to process reader conditionals, or
:preserve to keep all branches
:features - persistent set of feature keywords for reader conditionals
:eof - on eof, return value unless :eofthrow, then throw.
if not specified, will throw
To read data structures only, use clojure.tools.reader.edn/read
Note that the function signature of clojure.tools.reader/read and
clojure.tools.reader.edn/read is not the same for eof-handling"
{:arglists '([reader] [opts reader] [reader eof-error? eof-value])}
([reader] (read reader true nil))
([{eof :eof :as opts :or {eof :eofthrow}} reader] (read* reader (= eof :eofthrow) eof nil opts (to-array [])))
([reader eof-error? sentinel] (read* reader eof-error? sentinel nil {} (to-array []))))
(defn read-string
"Reads one object from the string s.
Returns nil when s is nil or empty.
To read data structures only, use clojure.tools.reader.edn/read-string
Note that the function signature of clojure.tools.reader/read-string and
clojure.tools.reader.edn/read-string is not the same for eof-handling"
([s]
(read-string {} s))
([opts s]
(when (and s (not (identical? s "")))
(read opts (string-push-back-reader s)))))
(defn read+string
"Like read, and taking the same args. reader must be a SourceLoggingPushbackReader.
Returns a vector containing the object read and the (whitespace-trimmed) string read."
([reader & args]
(let [buf (fn [reader] (str (:buffer @(.-frames reader))))
offset (count (buf reader))
o (log-source reader (if (= 1 (count args))
(read (first args) reader)
(apply read reader args)))
s (.trim (subs (buf reader) offset))]
[o s])))

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,448 @@
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns ^{:doc "An EDN reader in clojure"
:author "Bronsa"}
cljs.tools.reader.edn
(:refer-clojure :exclude [read read-string char default-data-readers])
(:require [cljs.tools.reader.impl.errors :as err]
[cljs.tools.reader.reader-types :refer
[read-char unread peek-char indexing-reader?
get-line-number get-column-number get-file-name string-push-back-reader]]
[cljs.tools.reader.impl.utils :refer
[char ex-info? whitespace? numeric? desugar-meta namespace-keys second' char-code]]
[cljs.tools.reader.impl.commons :refer
[number-literal? read-past match-number parse-symbol read-comment throwing-reader]]
[cljs.tools.reader :refer [default-data-readers]]
[goog.string :as gstring])
(:import goog.string.StringBuffer))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; helpers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(declare read macros dispatch-macros)
(defn- ^boolean macro-terminating? [ch]
(and (not (identical? \# ch))
(not (identical? \' ch))
(not (identical? \: ch))
(macros ch)))
(defn- ^boolean not-constituent? [ch]
(or (identical? \@ ch)
(identical? \` ch)
(identical? \~ ch)))
(defn- read-token
([rdr kind initch]
(read-token rdr kind initch true))
([rdr kind initch validate-leading?]
(cond
(not initch)
(err/throw-eof-at-start rdr kind)
(and validate-leading?
(not-constituent? initch))
(err/throw-bad-char rdr kind initch)
:else
(loop [sb (StringBuffer.)
ch (do (unread rdr initch) initch)]
(if (or (whitespace? ch)
(macro-terminating? ch)
(nil? ch))
(str sb)
(if (not-constituent? ch)
(err/throw-bad-char rdr kind ch)
(recur (doto sb (.append (read-char rdr))) (peek-char rdr))))))))
(declare read-tagged)
(defn- read-dispatch
[rdr _ opts]
(if-let [ch (read-char rdr)]
(if-let [dm (dispatch-macros ch)]
(dm rdr ch opts)
(if-let [obj (read-tagged (doto rdr (unread ch)) ch opts)]
obj
(err/throw-no-dispatch rdr ch)))
(err/throw-eof-at-dispatch rdr)))
(defn- read-unmatched-delimiter
[rdr ch opts]
(err/throw-unmatch-delimiter rdr ch))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; readers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn- read-unicode-char
([token offset length base]
(let [l (+ offset length)]
(when-not (== (count token) l)
(err/throw-invalid-unicode-literal nil token))
(loop [i offset uc 0]
(if (== i l)
(js/String.fromCharCode uc)
(let [d (char-code (nth token i) base)]
(if (== d -1)
(err/throw-invalid-unicode-digit-in-token nil (nth token i) token)
(recur (inc i) (+ d (* uc base)))))))))
([rdr initch base length exact?]
(loop [i 1 uc (char-code initch base)]
(if (== uc -1)
(err/throw-invalid-unicode-digit rdr initch)
(if-not (== i length)
(let [ch (peek-char rdr)]
(if (or (whitespace? ch)
(macros ch)
(nil? ch))
(if exact?
(err/throw-invalid-unicode-len rdr i length)
(js/String.fromCharCode uc))
(let [d (char-code ch base)]
(read-char rdr)
(if (== d -1)
(err/throw-invalid-unicode-digit rdr ch)
(recur (inc i) (+ d (* uc base)))))))
(js/String.fromCharCode uc))))))
(def ^:private ^:const upper-limit (.charCodeAt \uD7ff 0))
(def ^:private ^:const lower-limit (.charCodeAt \uE000 0))
(defn- read-char*
[rdr backslash opts]
(let [ch (read-char rdr)]
(if-not (nil? ch)
(let [token (if (or (macro-terminating? ch)
(not-constituent? ch)
(whitespace? ch))
(str ch)
(read-token rdr :character ch false))
token-len (count token)]
(cond
(== 1 token-len) (nth token 0)
(identical? token "newline") \newline
(identical? token "space") \space
(identical? token "tab") \tab
(identical? token "backspace") \backspace
(identical? token "formfeed") \formfeed
(identical? token "return") \return
(gstring/startsWith token "u")
(let [c (read-unicode-char token 1 4 16)
ic (.charCodeAt c)]
(if (and (> ic upper-limit)
(< ic lower-limit))
(err/throw-invalid-character-literal rdr (.toString ic 16))
c))
(gstring/startsWith token "o")
(let [len (dec token-len)]
(if (> len 3)
(err/throw-invalid-octal-len rdr token)
(let [uc (read-unicode-char token 1 len 8)]
(if (> (int uc) 0377)
(err/throw-bad-octal-number rdr)
uc))))
:else (err/throw-unsupported-character rdr token)))
(err/throw-eof-in-character rdr))))
(defn ^:private starting-line-col-info [rdr]
(when (indexing-reader? rdr)
[(get-line-number rdr) (int (dec (int (get-column-number rdr))))]))
(defn- read-delimited
[kind delim rdr opts]
(let [[start-line start-column] (starting-line-col-info rdr)
delim (char delim)]
(loop [a (transient [])]
(let [ch (read-past whitespace? rdr)]
(when-not ch
(err/throw-eof-delimited rdr kind start-line start-column (count a)))
(if (= delim (char ch))
(persistent! a)
(if-let [macrofn (macros ch)]
(let [mret (macrofn rdr ch opts)]
(recur (if-not (identical? mret rdr) (conj! a mret) a)))
(let [o (read (doto rdr (unread ch)) true nil opts)]
(recur (if-not (identical? o rdr) (conj! a o) a)))))))))
(defn- read-list
[rdr _ opts]
(let [the-list (read-delimited :list \) rdr opts)]
(if (empty? the-list)
'()
(apply list the-list))))
(defn- read-vector
[rdr _ opts]
(read-delimited :vector \] rdr opts))
(defn- read-map
[rdr _ opts]
(let [[start-line start-column] (starting-line-col-info rdr)
the-map (read-delimited :map \} rdr opts)
map-count (count the-map)
ks (take-nth 2 the-map)
key-set (set ks)]
(when (odd? map-count)
(err/throw-odd-map rdr start-line start-column the-map))
(when-not (= (count key-set) (count ks))
(err/throw-dup-keys rdr :map ks))
(if (<= map-count (* 2 (.-HASHMAP-THRESHOLD cljs.core/PersistentArrayMap)))
(.fromArray cljs.core/PersistentArrayMap (to-array the-map) true true)
(.fromArray cljs.core/PersistentHashMap (to-array the-map) true))))
(defn- read-number
[rdr initch opts]
(loop [sb (doto (StringBuffer.) (.append initch))
ch (read-char rdr)]
(if (or (whitespace? ch) (macros ch) (nil? ch))
(let [s (str sb)]
(unread rdr ch)
(or (match-number s)
(err/throw-invalid-number rdr s)))
(recur (doto sb (.append ch)) (read-char rdr)))))
(defn- escape-char [sb rdr]
(let [ch (read-char rdr)]
(case ch
\t "\t"
\r "\r"
\n "\n"
\\ "\\"
\" "\""
\b "\b"
\f "\f"
\u (let [ch (read-char rdr)]
(if (== -1 (js/parseInt (int ch) 16))
(err/throw-invalid-unicode-escape rdr ch)
(read-unicode-char rdr ch 16 4 true)))
(if (numeric? ch)
(let [ch (read-unicode-char rdr ch 8 3 false)]
(if (> (int ch) 0377)
(err/throw-bad-octal-number rdr)
ch))
(err/throw-bad-escape-char rdr ch)))))
(defn- read-string*
[rdr _ opts]
(loop [sb (StringBuffer.)
ch (read-char rdr)]
(case ch
nil (err/throw-eof-reading rdr :string \" sb)
\\ (recur (doto sb (.append (escape-char sb rdr)))
(read-char rdr))
\" (str sb)
(recur (doto sb (.append ch)) (read-char rdr)))))
(defn- read-symbol
[rdr initch]
(when-let [token (read-token rdr :symbol initch)]
(case token
;; special symbols
"nil" nil
"true" true
"false" false
"/" '/
(or (when-let [p (parse-symbol token)]
(symbol (p 0) (p 1)))
(err/throw-invalid rdr :symbol token)))))
(defn- read-keyword
[reader initch opts]
(let [ch (read-char reader)]
(if-not (whitespace? ch)
(let [token (read-token reader :keyword ch)
s (parse-symbol token)]
(if (and s (== -1 (.indexOf token "::")))
(let [ns (s 0)
name (s 1)]
(if (identical? \: (nth token 0))
(err/throw-invalid reader :keyword token) ;; no ::keyword in edn
(keyword ns name)))
(err/throw-invalid reader :keyword token)))
(err/throw-single-colon reader))))
(defn- wrapping-reader
[sym]
(fn [rdr _ opts]
(list sym (read rdr true nil opts))))
(defn- read-meta
[rdr _ opts]
(let [m (desugar-meta (read rdr true nil opts))]
(when-not (map? m)
(err/throw-bad-metadata rdr m))
(let [o (read rdr true nil opts)]
(if (implements? IMeta o)
(with-meta o (merge (meta o) m))
(err/throw-bad-metadata-target rdr o)))))
(defn- read-set
[rdr _ opts]
(let [coll (read-delimited :set \} rdr opts)
the-set (set coll)]
(when-not (= (count coll) (count the-set))
(err/throw-dup-keys rdr :set coll))
the-set))
(defn- read-discard
[rdr _ opts]
(doto rdr
(read true nil true)))
(defn- read-namespaced-map
[rdr _ opts]
(let [token (read-token rdr :namespaced-map (read-char rdr))]
(if-let [ns (some-> token parse-symbol second')]
(let [ch (read-past whitespace? rdr)]
(if (identical? ch \{)
(let [items (read-delimited :namespaced-map \} rdr opts)]
(when (odd? (count items))
(err/throw-odd-map rdr nil nil items))
(let [keys (namespace-keys (str ns) (take-nth 2 items))
vals (take-nth 2 (rest items))]
(when-not (= (count (set keys)) (count keys))
(err/throw-dup-keys rdr :namespaced-map keys))
(zipmap keys vals)))
(err/throw-ns-map-no-map rdr token)))
(err/throw-bad-ns rdr token))))
(defn- read-symbolic-value
[rdr _ opts]
(let [sym (read rdr true nil opts)]
(case sym
NaN js/Number.NaN
-Inf js/Number.NEGATIVE_INFINITY
Inf js/Number.POSITIVE_INFINITY
(err/reader-error rdr (str "Invalid token: ##" sym)))))
(defn- macros [ch]
(case ch
\" read-string*
\: read-keyword
\; read-comment
\^ read-meta
\( read-list
\) read-unmatched-delimiter
\[ read-vector
\] read-unmatched-delimiter
\{ read-map
\} read-unmatched-delimiter
\\ read-char*
\# read-dispatch
nil))
(defn- dispatch-macros [ch]
(case ch
\^ read-meta ;deprecated
\{ read-set
\< (throwing-reader "Unreadable form")
\! read-comment
\_ read-discard
\: read-namespaced-map
\# read-symbolic-value
nil))
(defn- read-tagged [rdr initch opts]
(let [tag (read rdr true nil opts)
object (read rdr true nil opts)]
(if-not (symbol? tag)
(err/throw-bad-reader-tag rdr "Reader tag must be a symbol"))
(if-let [f (or (get (:readers opts) tag)
(default-data-readers tag))]
(f object)
(if-let [d (:default opts)]
(d tag object)
(err/throw-unknown-reader-tag rdr tag)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Public API
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn read
"Reads the first object from an IPushbackReader.
Returns the object read. If EOF, throws if eof-error? is true otherwise returns eof.
If no reader is provided, *in* will be used.
Reads data in the edn format (subset of Clojure data):
http://edn-format.org
clojure.tools.reader.edn/read doesn't depend on dynamic Vars, all configuration
is done by passing an opt map.
opts is a map that can include the following keys:
:eof - value to return on end-of-file. When not supplied, eof throws an exception.
:readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
When not supplied, only the default-data-readers will be used.
:default - A function of two args, that will, if present and no reader is found for a tag,
be called with the tag and the value."
([reader] (read {} reader))
([{:keys [eof] :as opts} reader]
(let [eof-error? (not (contains? opts :eof))]
(read reader eof-error? eof opts)))
([reader eof-error? eof opts]
(try
(loop []
(let [ch (read-char reader)]
(cond
(whitespace? ch) (recur)
(nil? ch) (if eof-error? (err/throw-eof-error reader nil) eof)
(number-literal? reader ch) (read-number reader ch opts)
:else (let [f (macros ch)]
(if f
(let [res (f reader ch opts)]
(if (identical? res reader)
(recur)
res))
(read-symbol reader ch))))))
(catch js/Error e
(if (ex-info? e)
(let [d (ex-data e)]
(if (= :reader-exception (:type d))
(throw e)
(throw (ex-info (.-message e)
(merge {:type :reader-exception}
d
(if (indexing-reader? reader)
{:line (get-line-number reader)
:column (get-column-number reader)
:file (get-file-name reader)}))
e))))
(throw (ex-info (.-message e)
(merge {:type :reader-exception}
(if (indexing-reader? reader)
{:line (get-line-number reader)
:column (get-column-number reader)
:file (get-file-name reader)}))
e)))))))
(defn read-string
"Reads one object from the string s.
Returns nil when s is nil or empty.
Reads data in the edn format (subset of Clojure data):
http://edn-format.org
opts is a map as per clojure.tools.reader.edn/read"
([s] (read-string {:eof nil} s))
([opts s]
(when (and s (not= s ""))
(read opts (string-push-back-reader s)))))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,933 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('cljs.tools.reader.edn');
goog.require('cljs.core');
goog.require('cljs.tools.reader.impl.errors');
goog.require('cljs.tools.reader.reader_types');
goog.require('cljs.tools.reader.impl.utils');
goog.require('cljs.tools.reader.impl.commons');
goog.require('cljs.tools.reader');
goog.require('goog.string');
goog.require('goog.string.StringBuffer');
cljs.tools.reader.edn.macro_terminating_QMARK_ = (function cljs$tools$reader$edn$macro_terminating_QMARK_(ch){
var and__4120__auto__ = (!(("#" === ch)));
if(and__4120__auto__){
var and__4120__auto____$1 = (!(("'" === ch)));
if(and__4120__auto____$1){
var and__4120__auto____$2 = (!((":" === ch)));
if(and__4120__auto____$2){
return cljs.tools.reader.edn.macros.call(null,ch);
} else {
return and__4120__auto____$2;
}
} else {
return and__4120__auto____$1;
}
} else {
return and__4120__auto__;
}
});
cljs.tools.reader.edn.not_constituent_QMARK_ = (function cljs$tools$reader$edn$not_constituent_QMARK_(ch){
return ((("@" === ch)) || (("`" === ch)) || (("~" === ch)));
});
cljs.tools.reader.edn.read_token = (function cljs$tools$reader$edn$read_token(var_args){
var G__21219 = arguments.length;
switch (G__21219) {
case 3:
return cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
break;
case 4:
return cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$3 = (function (rdr,kind,initch){
return cljs.tools.reader.edn.read_token.call(null,rdr,kind,initch,true);
});
cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$4 = (function (rdr,kind,initch,validate_leading_QMARK_){
if(cljs.core.not.call(null,initch)){
return cljs.tools.reader.impl.errors.throw_eof_at_start.call(null,rdr,kind);
} else {
if(cljs.core.truth_((function (){var and__4120__auto__ = validate_leading_QMARK_;
if(cljs.core.truth_(and__4120__auto__)){
return cljs.tools.reader.edn.not_constituent_QMARK_.call(null,initch);
} else {
return and__4120__auto__;
}
})())){
return cljs.tools.reader.impl.errors.throw_bad_char.call(null,rdr,kind,initch);
} else {
var sb = (new goog.string.StringBuffer());
var ch = (function (){
cljs.tools.reader.reader_types.unread.call(null,rdr,initch);
return initch;
})()
;
while(true){
if(((cljs.tools.reader.impl.utils.whitespace_QMARK_.call(null,ch)) || (cljs.tools.reader.edn.macro_terminating_QMARK_.call(null,ch)) || ((ch == null)))){
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb);
} else {
if(cljs.tools.reader.edn.not_constituent_QMARK_.call(null,ch)){
return cljs.tools.reader.impl.errors.throw_bad_char.call(null,rdr,kind,ch);
} else {
var G__21222 = (function (){var G__21220 = sb;
G__21220.append(cljs.tools.reader.reader_types.read_char.call(null,rdr));
return G__21220;
})();
var G__21223 = cljs.tools.reader.reader_types.peek_char.call(null,rdr);
sb = G__21222;
ch = G__21223;
continue;
}
}
break;
}
}
}
});
cljs.tools.reader.edn.read_token.cljs$lang$maxFixedArity = 4;
cljs.tools.reader.edn.read_dispatch = (function cljs$tools$reader$edn$read_dispatch(rdr,_,opts){
var temp__5718__auto__ = cljs.tools.reader.reader_types.read_char.call(null,rdr);
if(cljs.core.truth_(temp__5718__auto__)){
var ch = temp__5718__auto__;
var temp__5718__auto____$1 = cljs.tools.reader.edn.dispatch_macros.call(null,ch);
if(cljs.core.truth_(temp__5718__auto____$1)){
var dm = temp__5718__auto____$1;
return dm.call(null,rdr,ch,opts);
} else {
var temp__5718__auto____$2 = cljs.tools.reader.edn.read_tagged.call(null,(function (){var G__21224 = rdr;
cljs.tools.reader.reader_types.unread.call(null,G__21224,ch);
return G__21224;
})(),ch,opts);
if(cljs.core.truth_(temp__5718__auto____$2)){
var obj = temp__5718__auto____$2;
return obj;
} else {
return cljs.tools.reader.impl.errors.throw_no_dispatch.call(null,rdr,ch);
}
}
} else {
return cljs.tools.reader.impl.errors.throw_eof_at_dispatch.call(null,rdr);
}
});
cljs.tools.reader.edn.read_unmatched_delimiter = (function cljs$tools$reader$edn$read_unmatched_delimiter(rdr,ch,opts){
return cljs.tools.reader.impl.errors.throw_unmatch_delimiter.call(null,rdr,ch);
});
cljs.tools.reader.edn.read_unicode_char = (function cljs$tools$reader$edn$read_unicode_char(var_args){
var G__21226 = arguments.length;
switch (G__21226) {
case 4:
return cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
break;
case 5:
return cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$5((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$4 = (function (token,offset,length,base){
var l = (offset + length);
if((cljs.core.count.call(null,token) === l)){
} else {
cljs.tools.reader.impl.errors.throw_invalid_unicode_literal.call(null,null,token);
}
var i = offset;
var uc = (0);
while(true){
if((i === l)){
return String.fromCharCode(uc);
} else {
var d = cljs.tools.reader.impl.utils.char_code.call(null,cljs.core.nth.call(null,token,i),base);
if((d === (-1))){
return cljs.tools.reader.impl.errors.throw_invalid_unicode_digit_in_token.call(null,null,cljs.core.nth.call(null,token,i),token);
} else {
var G__21228 = (i + (1));
var G__21229 = (d + (uc * base));
i = G__21228;
uc = G__21229;
continue;
}
}
break;
}
});
cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$5 = (function (rdr,initch,base,length,exact_QMARK_){
var i = (1);
var uc = cljs.tools.reader.impl.utils.char_code.call(null,initch,base);
while(true){
if((uc === (-1))){
return cljs.tools.reader.impl.errors.throw_invalid_unicode_digit.call(null,rdr,initch);
} else {
if((!((i === length)))){
var ch = cljs.tools.reader.reader_types.peek_char.call(null,rdr);
if(cljs.core.truth_((function (){var or__4131__auto__ = cljs.tools.reader.impl.utils.whitespace_QMARK_.call(null,ch);
if(or__4131__auto__){
return or__4131__auto__;
} else {
var or__4131__auto____$1 = cljs.tools.reader.edn.macros.call(null,ch);
if(cljs.core.truth_(or__4131__auto____$1)){
return or__4131__auto____$1;
} else {
return (ch == null);
}
}
})())){
if(cljs.core.truth_(exact_QMARK_)){
return cljs.tools.reader.impl.errors.throw_invalid_unicode_len.call(null,rdr,i,length);
} else {
return String.fromCharCode(uc);
}
} else {
var d = cljs.tools.reader.impl.utils.char_code.call(null,ch,base);
cljs.tools.reader.reader_types.read_char.call(null,rdr);
if((d === (-1))){
return cljs.tools.reader.impl.errors.throw_invalid_unicode_digit.call(null,rdr,ch);
} else {
var G__21230 = (i + (1));
var G__21231 = (d + (uc * base));
i = G__21230;
uc = G__21231;
continue;
}
}
} else {
return String.fromCharCode(uc);
}
}
break;
}
});
cljs.tools.reader.edn.read_unicode_char.cljs$lang$maxFixedArity = 5;
cljs.tools.reader.edn.upper_limit = "\uD7FF".charCodeAt((0));
cljs.tools.reader.edn.lower_limit = "\uE000".charCodeAt((0));
cljs.tools.reader.edn.read_char_STAR_ = (function cljs$tools$reader$edn$read_char_STAR_(rdr,backslash,opts){
var ch = cljs.tools.reader.reader_types.read_char.call(null,rdr);
if((!((ch == null)))){
var token = ((((cljs.tools.reader.edn.macro_terminating_QMARK_.call(null,ch)) || (cljs.tools.reader.edn.not_constituent_QMARK_.call(null,ch)) || (cljs.tools.reader.impl.utils.whitespace_QMARK_.call(null,ch))))?cljs.core.str.cljs$core$IFn$_invoke$arity$1(ch):cljs.tools.reader.edn.read_token.call(null,rdr,new cljs.core.Keyword(null,"character","character",380652989),ch,false));
var token_len = cljs.core.count.call(null,token);
if(((1) === token_len)){
return cljs.core.nth.call(null,token,(0));
} else {
if((token === "newline")){
return "\n";
} else {
if((token === "space")){
return " ";
} else {
if((token === "tab")){
return "\t";
} else {
if((token === "backspace")){
return "\b";
} else {
if((token === "formfeed")){
return "\f";
} else {
if((token === "return")){
return "\r";
} else {
if(cljs.core.truth_(goog.string.startsWith(token,"u"))){
var c = cljs.tools.reader.edn.read_unicode_char.call(null,token,(1),(4),(16));
var ic = c.charCodeAt();
if((((ic > cljs.tools.reader.edn.upper_limit)) && ((ic < cljs.tools.reader.edn.lower_limit)))){
return cljs.tools.reader.impl.errors.throw_invalid_character_literal.call(null,rdr,ic.toString((16)));
} else {
return c;
}
} else {
if(cljs.core.truth_(goog.string.startsWith(token,"o"))){
var len = (token_len - (1));
if((len > (3))){
return cljs.tools.reader.impl.errors.throw_invalid_octal_len.call(null,rdr,token);
} else {
var uc = cljs.tools.reader.edn.read_unicode_char.call(null,token,(1),len,(8));
if(((uc | (0)) > (255))){
return cljs.tools.reader.impl.errors.throw_bad_octal_number.call(null,rdr);
} else {
return uc;
}
}
} else {
return cljs.tools.reader.impl.errors.throw_unsupported_character.call(null,rdr,token);
}
}
}
}
}
}
}
}
}
} else {
return cljs.tools.reader.impl.errors.throw_eof_in_character.call(null,rdr);
}
});
cljs.tools.reader.edn.starting_line_col_info = (function cljs$tools$reader$edn$starting_line_col_info(rdr){
if(cljs.tools.reader.reader_types.indexing_reader_QMARK_.call(null,rdr)){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.tools.reader.reader_types.get_line_number.call(null,rdr),(((cljs.tools.reader.reader_types.get_column_number.call(null,rdr) | (0)) - (1)) | (0))], null);
} else {
return null;
}
});
cljs.tools.reader.edn.read_delimited = (function cljs$tools$reader$edn$read_delimited(kind,delim,rdr,opts){
var vec__21232 = cljs.tools.reader.edn.starting_line_col_info.call(null,rdr);
var start_line = cljs.core.nth.call(null,vec__21232,(0),null);
var start_column = cljs.core.nth.call(null,vec__21232,(1),null);
var delim__$1 = cljs.tools.reader.impl.utils.char$.call(null,delim);
var a = cljs.core.transient$.call(null,cljs.core.PersistentVector.EMPTY);
while(true){
var ch = cljs.tools.reader.impl.commons.read_past.call(null,cljs.tools.reader.impl.utils.whitespace_QMARK_,rdr);
if(cljs.core.truth_(ch)){
} else {
cljs.tools.reader.impl.errors.throw_eof_delimited.call(null,rdr,kind,start_line,start_column,cljs.core.count.call(null,a));
}
if(cljs.core._EQ_.call(null,delim__$1,cljs.tools.reader.impl.utils.char$.call(null,ch))){
return cljs.core.persistent_BANG_.call(null,a);
} else {
var temp__5718__auto__ = cljs.tools.reader.edn.macros.call(null,ch);
if(cljs.core.truth_(temp__5718__auto__)){
var macrofn = temp__5718__auto__;
var mret = macrofn.call(null,rdr,ch,opts);
var G__21236 = (((!((mret === rdr))))?cljs.core.conj_BANG_.call(null,a,mret):a);
a = G__21236;
continue;
} else {
var o = cljs.tools.reader.edn.read.call(null,(function (){var G__21235 = rdr;
cljs.tools.reader.reader_types.unread.call(null,G__21235,ch);
return G__21235;
})(),true,null,opts);
var G__21237 = (((!((o === rdr))))?cljs.core.conj_BANG_.call(null,a,o):a);
a = G__21237;
continue;
}
}
break;
}
});
cljs.tools.reader.edn.read_list = (function cljs$tools$reader$edn$read_list(rdr,_,opts){
var the_list = cljs.tools.reader.edn.read_delimited.call(null,new cljs.core.Keyword(null,"list","list",765357683),")",rdr,opts);
if(cljs.core.empty_QMARK_.call(null,the_list)){
return cljs.core.List.EMPTY;
} else {
return cljs.core.apply.call(null,cljs.core.list,the_list);
}
});
cljs.tools.reader.edn.read_vector = (function cljs$tools$reader$edn$read_vector(rdr,_,opts){
return cljs.tools.reader.edn.read_delimited.call(null,new cljs.core.Keyword(null,"vector","vector",1902966158),"]",rdr,opts);
});
cljs.tools.reader.edn.read_map = (function cljs$tools$reader$edn$read_map(rdr,_,opts){
var vec__21238 = cljs.tools.reader.edn.starting_line_col_info.call(null,rdr);
var start_line = cljs.core.nth.call(null,vec__21238,(0),null);
var start_column = cljs.core.nth.call(null,vec__21238,(1),null);
var the_map = cljs.tools.reader.edn.read_delimited.call(null,new cljs.core.Keyword(null,"map","map",1371690461),"}",rdr,opts);
var map_count = cljs.core.count.call(null,the_map);
var ks = cljs.core.take_nth.call(null,(2),the_map);
var key_set = cljs.core.set.call(null,ks);
if(cljs.core.odd_QMARK_.call(null,map_count)){
cljs.tools.reader.impl.errors.throw_odd_map.call(null,rdr,start_line,start_column,the_map);
} else {
}
if(cljs.core._EQ_.call(null,cljs.core.count.call(null,key_set),cljs.core.count.call(null,ks))){
} else {
cljs.tools.reader.impl.errors.throw_dup_keys.call(null,rdr,new cljs.core.Keyword(null,"map","map",1371690461),ks);
}
if((map_count <= ((2) * cljs.core.PersistentArrayMap.HASHMAP_THRESHOLD))){
return cljs.core.PersistentArrayMap.fromArray(cljs.core.to_array.call(null,the_map),true,true);
} else {
return cljs.core.PersistentHashMap.fromArray(cljs.core.to_array.call(null,the_map),true);
}
});
cljs.tools.reader.edn.read_number = (function cljs$tools$reader$edn$read_number(rdr,initch,opts){
var sb = (function (){var G__21241 = (new goog.string.StringBuffer());
G__21241.append(initch);
return G__21241;
})();
var ch = cljs.tools.reader.reader_types.read_char.call(null,rdr);
while(true){
if(cljs.core.truth_((function (){var or__4131__auto__ = cljs.tools.reader.impl.utils.whitespace_QMARK_.call(null,ch);
if(or__4131__auto__){
return or__4131__auto__;
} else {
var or__4131__auto____$1 = cljs.tools.reader.edn.macros.call(null,ch);
if(cljs.core.truth_(or__4131__auto____$1)){
return or__4131__auto____$1;
} else {
return (ch == null);
}
}
})())){
var s = cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb);
cljs.tools.reader.reader_types.unread.call(null,rdr,ch);
var or__4131__auto__ = cljs.tools.reader.impl.commons.match_number.call(null,s);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return cljs.tools.reader.impl.errors.throw_invalid_number.call(null,rdr,s);
}
} else {
var G__21243 = (function (){var G__21242 = sb;
G__21242.append(ch);
return G__21242;
})();
var G__21244 = cljs.tools.reader.reader_types.read_char.call(null,rdr);
sb = G__21243;
ch = G__21244;
continue;
}
break;
}
});
cljs.tools.reader.edn.escape_char = (function cljs$tools$reader$edn$escape_char(sb,rdr){
var ch = cljs.tools.reader.reader_types.read_char.call(null,rdr);
var G__21245 = ch;
switch (G__21245) {
case "t":
return "\t";
break;
case "r":
return "\r";
break;
case "n":
return "\n";
break;
case "\\":
return "\\";
break;
case "\"":
return "\"";
break;
case "b":
return "\b";
break;
case "f":
return "\f";
break;
case "u":
var ch__$1 = cljs.tools.reader.reader_types.read_char.call(null,rdr);
if(((-1) === parseInt((ch__$1 | (0)),(16)))){
return cljs.tools.reader.impl.errors.throw_invalid_unicode_escape.call(null,rdr,ch__$1);
} else {
return cljs.tools.reader.edn.read_unicode_char.call(null,rdr,ch__$1,(16),(4),true);
}
break;
default:
if(cljs.tools.reader.impl.utils.numeric_QMARK_.call(null,ch)){
var ch__$1 = cljs.tools.reader.edn.read_unicode_char.call(null,rdr,ch,(8),(3),false);
if(((ch__$1 | (0)) > (255))){
return cljs.tools.reader.impl.errors.throw_bad_octal_number.call(null,rdr);
} else {
return ch__$1;
}
} else {
return cljs.tools.reader.impl.errors.throw_bad_escape_char.call(null,rdr,ch);
}
}
});
cljs.tools.reader.edn.read_string_STAR_ = (function cljs$tools$reader$edn$read_string_STAR_(rdr,_,opts){
var sb = (new goog.string.StringBuffer());
var ch = cljs.tools.reader.reader_types.read_char.call(null,rdr);
while(true){
var G__21247 = ch;
if(cljs.core._EQ_.call(null,null,G__21247)){
return cljs.tools.reader.impl.errors.throw_eof_reading.call(null,rdr,new cljs.core.Keyword(null,"string","string",-1989541586),"\"",sb);
} else {
if(cljs.core._EQ_.call(null,"\\",G__21247)){
var G__21250 = (function (){var G__21248 = sb;
G__21248.append(cljs.tools.reader.edn.escape_char.call(null,sb,rdr));
return G__21248;
})();
var G__21251 = cljs.tools.reader.reader_types.read_char.call(null,rdr);
sb = G__21250;
ch = G__21251;
continue;
} else {
if(cljs.core._EQ_.call(null,"\"",G__21247)){
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb);
} else {
var G__21252 = (function (){var G__21249 = sb;
G__21249.append(ch);
return G__21249;
})();
var G__21253 = cljs.tools.reader.reader_types.read_char.call(null,rdr);
sb = G__21252;
ch = G__21253;
continue;
}
}
}
break;
}
});
cljs.tools.reader.edn.read_symbol = (function cljs$tools$reader$edn$read_symbol(rdr,initch){
var temp__5720__auto__ = cljs.tools.reader.edn.read_token.call(null,rdr,new cljs.core.Keyword(null,"symbol","symbol",-1038572696),initch);
if(cljs.core.truth_(temp__5720__auto__)){
var token = temp__5720__auto__;
var G__21254 = token;
switch (G__21254) {
case "nil":
return null;
break;
case "true":
return true;
break;
case "false":
return false;
break;
case "/":
return new cljs.core.Symbol(null,"/","/",-1371932971,null);
break;
default:
var or__4131__auto__ = (function (){var temp__5720__auto____$1 = cljs.tools.reader.impl.commons.parse_symbol.call(null,token);
if(cljs.core.truth_(temp__5720__auto____$1)){
var p = temp__5720__auto____$1;
return cljs.core.symbol.call(null,p.call(null,(0)),p.call(null,(1)));
} else {
return null;
}
})();
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return cljs.tools.reader.impl.errors.throw_invalid.call(null,rdr,new cljs.core.Keyword(null,"symbol","symbol",-1038572696),token);
}
}
} else {
return null;
}
});
cljs.tools.reader.edn.read_keyword = (function cljs$tools$reader$edn$read_keyword(reader,initch,opts){
var ch = cljs.tools.reader.reader_types.read_char.call(null,reader);
if((!(cljs.tools.reader.impl.utils.whitespace_QMARK_.call(null,ch)))){
var token = cljs.tools.reader.edn.read_token.call(null,reader,new cljs.core.Keyword(null,"keyword","keyword",811389747),ch);
var s = cljs.tools.reader.impl.commons.parse_symbol.call(null,token);
if(cljs.core.truth_((function (){var and__4120__auto__ = s;
if(cljs.core.truth_(and__4120__auto__)){
return ((-1) === token.indexOf("::"));
} else {
return and__4120__auto__;
}
})())){
var ns = s.call(null,(0));
var name = s.call(null,(1));
if((":" === cljs.core.nth.call(null,token,(0)))){
return cljs.tools.reader.impl.errors.throw_invalid.call(null,reader,new cljs.core.Keyword(null,"keyword","keyword",811389747),token);
} else {
return cljs.core.keyword.call(null,ns,name);
}
} else {
return cljs.tools.reader.impl.errors.throw_invalid.call(null,reader,new cljs.core.Keyword(null,"keyword","keyword",811389747),token);
}
} else {
return cljs.tools.reader.impl.errors.throw_single_colon.call(null,reader);
}
});
cljs.tools.reader.edn.wrapping_reader = (function cljs$tools$reader$edn$wrapping_reader(sym){
return (function (rdr,_,opts){
return (new cljs.core.List(null,sym,(new cljs.core.List(null,cljs.tools.reader.edn.read.call(null,rdr,true,null,opts),null,(1),null)),(2),null));
});
});
cljs.tools.reader.edn.read_meta = (function cljs$tools$reader$edn$read_meta(rdr,_,opts){
var m = cljs.tools.reader.impl.utils.desugar_meta.call(null,cljs.tools.reader.edn.read.call(null,rdr,true,null,opts));
if(cljs.core.map_QMARK_.call(null,m)){
} else {
cljs.tools.reader.impl.errors.throw_bad_metadata.call(null,rdr,m);
}
var o = cljs.tools.reader.edn.read.call(null,rdr,true,null,opts);
if((((!((o == null))))?(((((o.cljs$lang$protocol_mask$partition0$ & (131072))) || ((cljs.core.PROTOCOL_SENTINEL === o.cljs$core$IMeta$))))?true:false):false)){
return cljs.core.with_meta.call(null,o,cljs.core.merge.call(null,cljs.core.meta.call(null,o),m));
} else {
return cljs.tools.reader.impl.errors.throw_bad_metadata_target.call(null,rdr,o);
}
});
cljs.tools.reader.edn.read_set = (function cljs$tools$reader$edn$read_set(rdr,_,opts){
var coll = cljs.tools.reader.edn.read_delimited.call(null,new cljs.core.Keyword(null,"set","set",304602554),"}",rdr,opts);
var the_set = cljs.core.set.call(null,coll);
if(cljs.core._EQ_.call(null,cljs.core.count.call(null,coll),cljs.core.count.call(null,the_set))){
} else {
cljs.tools.reader.impl.errors.throw_dup_keys.call(null,rdr,new cljs.core.Keyword(null,"set","set",304602554),coll);
}
return the_set;
});
cljs.tools.reader.edn.read_discard = (function cljs$tools$reader$edn$read_discard(rdr,_,opts){
var G__21257 = rdr;
cljs.tools.reader.edn.read.call(null,G__21257,true,null,true);
return G__21257;
});
cljs.tools.reader.edn.read_namespaced_map = (function cljs$tools$reader$edn$read_namespaced_map(rdr,_,opts){
var token = cljs.tools.reader.edn.read_token.call(null,rdr,new cljs.core.Keyword(null,"namespaced-map","namespaced-map",1235665380),cljs.tools.reader.reader_types.read_char.call(null,rdr));
var temp__5718__auto__ = (function (){var G__21258 = token;
var G__21258__$1 = (((G__21258 == null))?null:cljs.tools.reader.impl.commons.parse_symbol.call(null,G__21258));
if((G__21258__$1 == null)){
return null;
} else {
return cljs.tools.reader.impl.utils.second_SINGLEQUOTE_.call(null,G__21258__$1);
}
})();
if(cljs.core.truth_(temp__5718__auto__)){
var ns = temp__5718__auto__;
var ch = cljs.tools.reader.impl.commons.read_past.call(null,cljs.tools.reader.impl.utils.whitespace_QMARK_,rdr);
if((ch === "{")){
var items = cljs.tools.reader.edn.read_delimited.call(null,new cljs.core.Keyword(null,"namespaced-map","namespaced-map",1235665380),"}",rdr,opts);
if(cljs.core.odd_QMARK_.call(null,cljs.core.count.call(null,items))){
cljs.tools.reader.impl.errors.throw_odd_map.call(null,rdr,null,null,items);
} else {
}
var keys = cljs.tools.reader.impl.utils.namespace_keys.call(null,cljs.core.str.cljs$core$IFn$_invoke$arity$1(ns),cljs.core.take_nth.call(null,(2),items));
var vals = cljs.core.take_nth.call(null,(2),cljs.core.rest.call(null,items));
if(cljs.core._EQ_.call(null,cljs.core.count.call(null,cljs.core.set.call(null,keys)),cljs.core.count.call(null,keys))){
} else {
cljs.tools.reader.impl.errors.throw_dup_keys.call(null,rdr,new cljs.core.Keyword(null,"namespaced-map","namespaced-map",1235665380),keys);
}
return cljs.core.zipmap.call(null,keys,vals);
} else {
return cljs.tools.reader.impl.errors.throw_ns_map_no_map.call(null,rdr,token);
}
} else {
return cljs.tools.reader.impl.errors.throw_bad_ns.call(null,rdr,token);
}
});
cljs.tools.reader.edn.read_symbolic_value = (function cljs$tools$reader$edn$read_symbolic_value(rdr,_,opts){
var sym = cljs.tools.reader.edn.read.call(null,rdr,true,null,opts);
var G__21259 = sym;
if(cljs.core._EQ_.call(null,new cljs.core.Symbol(null,"NaN","NaN",666918153,null),G__21259)){
return Number.NaN;
} else {
if(cljs.core._EQ_.call(null,new cljs.core.Symbol(null,"-Inf","-Inf",-2123243689,null),G__21259)){
return Number.NEGATIVE_INFINITY;
} else {
if(cljs.core._EQ_.call(null,new cljs.core.Symbol(null,"Inf","Inf",647172781,null),G__21259)){
return Number.POSITIVE_INFINITY;
} else {
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,["Invalid token: ##",cljs.core.str.cljs$core$IFn$_invoke$arity$1(sym)].join(''));
}
}
}
});
cljs.tools.reader.edn.macros = (function cljs$tools$reader$edn$macros(ch){
var G__21260 = ch;
switch (G__21260) {
case "\"":
return cljs.tools.reader.edn.read_string_STAR_;
break;
case ":":
return cljs.tools.reader.edn.read_keyword;
break;
case ";":
return cljs.tools.reader.impl.commons.read_comment;
break;
case "^":
return cljs.tools.reader.edn.read_meta;
break;
case "(":
return cljs.tools.reader.edn.read_list;
break;
case ")":
return cljs.tools.reader.edn.read_unmatched_delimiter;
break;
case "[":
return cljs.tools.reader.edn.read_vector;
break;
case "]":
return cljs.tools.reader.edn.read_unmatched_delimiter;
break;
case "{":
return cljs.tools.reader.edn.read_map;
break;
case "}":
return cljs.tools.reader.edn.read_unmatched_delimiter;
break;
case "\\":
return cljs.tools.reader.edn.read_char_STAR_;
break;
case "#":
return cljs.tools.reader.edn.read_dispatch;
break;
default:
return null;
}
});
cljs.tools.reader.edn.dispatch_macros = (function cljs$tools$reader$edn$dispatch_macros(ch){
var G__21262 = ch;
switch (G__21262) {
case "^":
return cljs.tools.reader.edn.read_meta;
break;
case "{":
return cljs.tools.reader.edn.read_set;
break;
case "<":
return cljs.tools.reader.impl.commons.throwing_reader.call(null,"Unreadable form");
break;
case "!":
return cljs.tools.reader.impl.commons.read_comment;
break;
case "_":
return cljs.tools.reader.edn.read_discard;
break;
case ":":
return cljs.tools.reader.edn.read_namespaced_map;
break;
case "#":
return cljs.tools.reader.edn.read_symbolic_value;
break;
default:
return null;
}
});
cljs.tools.reader.edn.read_tagged = (function cljs$tools$reader$edn$read_tagged(rdr,initch,opts){
var tag = cljs.tools.reader.edn.read.call(null,rdr,true,null,opts);
var object = cljs.tools.reader.edn.read.call(null,rdr,true,null,opts);
if((!((tag instanceof cljs.core.Symbol)))){
cljs.tools.reader.impl.errors.throw_bad_reader_tag.call(null,rdr,"Reader tag must be a symbol");
} else {
}
var temp__5718__auto__ = (function (){var or__4131__auto__ = cljs.core.get.call(null,new cljs.core.Keyword(null,"readers","readers",-2118263030).cljs$core$IFn$_invoke$arity$1(opts),tag);
if(cljs.core.truth_(or__4131__auto__)){
return or__4131__auto__;
} else {
return cljs.tools.reader.default_data_readers.call(null,tag);
}
})();
if(cljs.core.truth_(temp__5718__auto__)){
var f = temp__5718__auto__;
return f.call(null,object);
} else {
var temp__5718__auto____$1 = new cljs.core.Keyword(null,"default","default",-1987822328).cljs$core$IFn$_invoke$arity$1(opts);
if(cljs.core.truth_(temp__5718__auto____$1)){
var d = temp__5718__auto____$1;
return d.call(null,tag,object);
} else {
return cljs.tools.reader.impl.errors.throw_unknown_reader_tag.call(null,rdr,tag);
}
}
});
/**
* Reads the first object from an IPushbackReader.
* Returns the object read. If EOF, throws if eof-error? is true otherwise returns eof.
* If no reader is provided, *in* will be used.
*
* Reads data in the edn format (subset of Clojure data):
* http://edn-format.org
*
* clojure.tools.reader.edn/read doesn't depend on dynamic Vars, all configuration
* is done by passing an opt map.
*
* opts is a map that can include the following keys:
* :eof - value to return on end-of-file. When not supplied, eof throws an exception.
* :readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
* When not supplied, only the default-data-readers will be used.
* :default - A function of two args, that will, if present and no reader is found for a tag,
* be called with the tag and the value.
*/
cljs.tools.reader.edn.read = (function cljs$tools$reader$edn$read(var_args){
var G__21265 = arguments.length;
switch (G__21265) {
case 1:
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
case 4:
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$1 = (function (reader){
return cljs.tools.reader.edn.read.call(null,cljs.core.PersistentArrayMap.EMPTY,reader);
});
cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$2 = (function (p__21266,reader){
var map__21267 = p__21266;
var map__21267__$1 = (((((!((map__21267 == null))))?(((((map__21267.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__21267.cljs$core$ISeq$))))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__21267):map__21267);
var opts = map__21267__$1;
var eof = cljs.core.get.call(null,map__21267__$1,new cljs.core.Keyword(null,"eof","eof",-489063237));
var eof_error_QMARK_ = (!(cljs.core.contains_QMARK_.call(null,opts,new cljs.core.Keyword(null,"eof","eof",-489063237))));
return cljs.tools.reader.edn.read.call(null,reader,eof_error_QMARK_,eof,opts);
});
cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 = (function (reader,eof_error_QMARK_,eof,opts){
try{while(true){
var ch = cljs.tools.reader.reader_types.read_char.call(null,reader);
if(cljs.tools.reader.impl.utils.whitespace_QMARK_.call(null,ch)){
continue;
} else {
if((ch == null)){
if(cljs.core.truth_(eof_error_QMARK_)){
return cljs.tools.reader.impl.errors.throw_eof_error.call(null,reader,null);
} else {
return eof;
}
} else {
if(cljs.tools.reader.impl.commons.number_literal_QMARK_.call(null,reader,ch)){
return cljs.tools.reader.edn.read_number.call(null,reader,ch,opts);
} else {
var f = cljs.tools.reader.edn.macros.call(null,ch);
if(cljs.core.truth_(f)){
var res = f.call(null,reader,ch,opts);
if((res === reader)){
continue;
} else {
return res;
}
} else {
return cljs.tools.reader.edn.read_symbol.call(null,reader,ch);
}
}
}
}
break;
}
}catch (e21269){if((e21269 instanceof Error)){
var e = e21269;
if(cljs.tools.reader.impl.utils.ex_info_QMARK_.call(null,e)){
var d = cljs.core.ex_data.call(null,e);
if(cljs.core._EQ_.call(null,new cljs.core.Keyword(null,"reader-exception","reader-exception",-1938323098),new cljs.core.Keyword(null,"type","type",1174270348).cljs$core$IFn$_invoke$arity$1(d))){
throw e;
} else {
throw cljs.core.ex_info.call(null,e.message,cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"type","type",1174270348),new cljs.core.Keyword(null,"reader-exception","reader-exception",-1938323098)], null),d,((cljs.tools.reader.reader_types.indexing_reader_QMARK_.call(null,reader))?new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"line","line",212345235),cljs.tools.reader.reader_types.get_line_number.call(null,reader),new cljs.core.Keyword(null,"column","column",2078222095),cljs.tools.reader.reader_types.get_column_number.call(null,reader),new cljs.core.Keyword(null,"file","file",-1269645878),cljs.tools.reader.reader_types.get_file_name.call(null,reader)], null):null)),e);
}
} else {
throw cljs.core.ex_info.call(null,e.message,cljs.core.merge.call(null,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"type","type",1174270348),new cljs.core.Keyword(null,"reader-exception","reader-exception",-1938323098)], null),((cljs.tools.reader.reader_types.indexing_reader_QMARK_.call(null,reader))?new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"line","line",212345235),cljs.tools.reader.reader_types.get_line_number.call(null,reader),new cljs.core.Keyword(null,"column","column",2078222095),cljs.tools.reader.reader_types.get_column_number.call(null,reader),new cljs.core.Keyword(null,"file","file",-1269645878),cljs.tools.reader.reader_types.get_file_name.call(null,reader)], null):null)),e);
}
} else {
throw e21269;
}
}});
cljs.tools.reader.edn.read.cljs$lang$maxFixedArity = 4;
/**
* Reads one object from the string s.
* Returns nil when s is nil or empty.
*
* Reads data in the edn format (subset of Clojure data):
* http://edn-format.org
*
* opts is a map as per clojure.tools.reader.edn/read
*/
cljs.tools.reader.edn.read_string = (function cljs$tools$reader$edn$read_string(var_args){
var G__21272 = arguments.length;
switch (G__21272) {
case 1:
return cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
break;
case 2:
return cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
break;
default:
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
}
});
cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$1 = (function (s){
return cljs.tools.reader.edn.read_string.call(null,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"eof","eof",-489063237),null], null),s);
});
cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$2 = (function (opts,s){
if(cljs.core.truth_((function (){var and__4120__auto__ = s;
if(cljs.core.truth_(and__4120__auto__)){
return cljs.core.not_EQ_.call(null,s,"");
} else {
return and__4120__auto__;
}
})())){
return cljs.tools.reader.edn.read.call(null,opts,cljs.tools.reader.reader_types.string_push_back_reader.call(null,s));
} else {
return null;
}
});
cljs.tools.reader.edn.read_string.cljs$lang$maxFixedArity = 2;
//# sourceMappingURL=edn.js.map?rel=1582560147180

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,131 @@
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
;; The use and distribution terms for this software are covered by the
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;; which can be found in the file epl-v10.html at the root of this distribution.
;; By using this software in any fashion, you are agreeing to be bound by
;; the terms of this license.
;; You must not remove this notice, or any other, from this software.
(ns cljs.tools.reader.impl.commons
(:refer-clojure :exclude [char])
(:require
[cljs.tools.reader.impl.errors :refer [reader-error]]
[cljs.tools.reader.reader-types :refer [peek-char read-char]]
[cljs.tools.reader.impl.utils :refer [numeric? newline? char]]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; helpers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn ^boolean number-literal?
"Checks whether the reader is at the start of a number literal"
[^not-native reader initch]
(or (numeric? initch)
(and (or (identical? \+ initch) (identical? \- initch))
(numeric? (peek-char reader)))))
(defn read-past
"Read until first character that doesn't match pred, returning
char."
[pred ^not-native rdr]
(loop [ch (read-char rdr)]
(if ^boolean (pred ch)
(recur (read-char rdr))
ch)))
(defn skip-line
"Advances the reader to the end of a line. Returns the reader"
[^not-native reader]
(loop []
(when-not (newline? (read-char reader))
(recur)))
reader)
(def int-pattern #"^([-+]?)(?:(0)|([1-9][0-9]*)|0[xX]([0-9A-Fa-f]+)|0([0-7]+)|([1-9][0-9]?)[rR]([0-9A-Za-z]+)|0[0-9]+)(N)?$")
(def ratio-pattern #"([-+]?[0-9]+)/([0-9]+)")
(def float-pattern #"([-+]?[0-9]+(\.[0-9]*)?([eE][-+]?[0-9]+)?)(M)?")
(defn- match-int
[s]
(let [m (vec (re-find int-pattern s))]
(if-not (nil? (m 2))
0
(let [^boolean negate? (identical? "-" (m 1))
a (cond
(not (nil? (m 3))) [(m 3) 10]
(not (nil? (m 4))) [(m 4) 16]
(not (nil? (m 5))) [(m 5) 8]
(not (nil? (m 7))) [(m 7) (js/parseInt (m 6))]
:else [nil nil])
n (a 0)]
(when-not (nil? n)
(let [bn (js/parseInt n (a 1))
bn (if negate? (* -1 bn) bn)]
(when-not (js/isNaN bn)
bn)))))))
(defn- match-ratio
[s]
(let [m (vec (re-find ratio-pattern s))
numerator (m 1)
denominator (m 2)
numerator (if (re-find #"^\+" numerator)
(subs numerator 1)
numerator)]
(/ (-> numerator js/parseInt) ;;; No ratio type in cljs
(-> denominator js/parseInt)))); So will convert to js/Number
(defn- match-float
[s]
(let [m (vec (re-find float-pattern s))]
(if-not (nil? (m 4)) ;; for BigDecimal "10.03M", as all parsed to js/Number
(js/parseFloat (m 1))
(js/parseFloat s))))
(defn ^boolean matches? [pattern s]
(let [[match] (re-find pattern s)]
(identical? match s)))
(defn match-number [s]
(if (matches? int-pattern s)
(match-int s)
(if (matches? float-pattern s)
(match-float s)
(when (matches? ratio-pattern s)
(match-ratio s)))))
(defn parse-symbol
"Parses a string into a vector of the namespace and symbol"
[token]
(when-not (or (identical? "" token)
(true? (.test #":$" token))
(true? (.test #"^::" token)))
(let [ns-idx (.indexOf token "/")
ns (when (pos? ns-idx)
(subs token 0 ns-idx))]
(if-not (nil? ns)
(let [ns-idx (inc ns-idx)]
(when-not (== ns-idx (count token))
(let [sym (subs token ns-idx)]
(when (and (not (numeric? (nth sym 0)))
(not (identical? "" sym))
(false? (.test #":$" ns))
(or (identical? sym "/")
(== -1 (.indexOf sym "/"))))
[ns sym]))))
(when (or (identical? token "/")
(== -1 (.indexOf token "/")))
[nil token])))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; readers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn read-comment
[rdr & _]
(skip-line rdr))
(defn throwing-reader
[msg]
(fn [rdr & _]
(reader-error rdr msg)))

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,193 @@
// Compiled by ClojureScript 1.10.520 {}
goog.provide('cljs.tools.reader.impl.commons');
goog.require('cljs.core');
goog.require('cljs.tools.reader.impl.errors');
goog.require('cljs.tools.reader.reader_types');
goog.require('cljs.tools.reader.impl.utils');
/**
* Checks whether the reader is at the start of a number literal
*/
cljs.tools.reader.impl.commons.number_literal_QMARK_ = (function cljs$tools$reader$impl$commons$number_literal_QMARK_(reader,initch){
return ((cljs.tools.reader.impl.utils.numeric_QMARK_.call(null,initch)) || (((((("+" === initch)) || (("-" === initch)))) && (cljs.tools.reader.impl.utils.numeric_QMARK_.call(null,cljs.tools.reader.reader_types.peek_char.call(null,reader))))));
});
/**
* Read until first character that doesn't match pred, returning
* char.
*/
cljs.tools.reader.impl.commons.read_past = (function cljs$tools$reader$impl$commons$read_past(pred,rdr){
var ch = cljs.tools.reader.reader_types.read_char.call(null,rdr);
while(true){
if(pred.call(null,ch)){
var G__21061 = cljs.tools.reader.reader_types.read_char.call(null,rdr);
ch = G__21061;
continue;
} else {
return ch;
}
break;
}
});
/**
* Advances the reader to the end of a line. Returns the reader
*/
cljs.tools.reader.impl.commons.skip_line = (function cljs$tools$reader$impl$commons$skip_line(reader){
while(true){
if(cljs.tools.reader.impl.utils.newline_QMARK_.call(null,cljs.tools.reader.reader_types.read_char.call(null,reader))){
} else {
continue;
}
break;
}
return reader;
});
cljs.tools.reader.impl.commons.int_pattern = /^([-+]?)(?:(0)|([1-9][0-9]*)|0[xX]([0-9A-Fa-f]+)|0([0-7]+)|([1-9][0-9]?)[rR]([0-9A-Za-z]+)|0[0-9]+)(N)?$/;
cljs.tools.reader.impl.commons.ratio_pattern = /([-+]?[0-9]+)\/([0-9]+)/;
cljs.tools.reader.impl.commons.float_pattern = /([-+]?[0-9]+(\.[0-9]*)?([eE][-+]?[0-9]+)?)(M)?/;
cljs.tools.reader.impl.commons.match_int = (function cljs$tools$reader$impl$commons$match_int(s){
var m = cljs.core.vec.call(null,cljs.core.re_find.call(null,cljs.tools.reader.impl.commons.int_pattern,s));
if((!((m.call(null,(2)) == null)))){
return (0);
} else {
var negate_QMARK_ = ("-" === m.call(null,(1)));
var a = (((!((m.call(null,(3)) == null))))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [m.call(null,(3)),(10)], null):(((!((m.call(null,(4)) == null))))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [m.call(null,(4)),(16)], null):(((!((m.call(null,(5)) == null))))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [m.call(null,(5)),(8)], null):(((!((m.call(null,(7)) == null))))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [m.call(null,(7)),parseInt(m.call(null,(6)))], null):new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,null], null)
))));
var n = a.call(null,(0));
if((n == null)){
return null;
} else {
var bn = parseInt(n,a.call(null,(1)));
var bn__$1 = ((negate_QMARK_)?((-1) * bn):bn);
if(cljs.core.truth_(isNaN(bn__$1))){
return null;
} else {
return bn__$1;
}
}
}
});
cljs.tools.reader.impl.commons.match_ratio = (function cljs$tools$reader$impl$commons$match_ratio(s){
var m = cljs.core.vec.call(null,cljs.core.re_find.call(null,cljs.tools.reader.impl.commons.ratio_pattern,s));
var numerator = m.call(null,(1));
var denominator = m.call(null,(2));
var numerator__$1 = (cljs.core.truth_(cljs.core.re_find.call(null,/^\+/,numerator))?cljs.core.subs.call(null,numerator,(1)):numerator);
return (parseInt(numerator__$1) / parseInt(denominator));
});
cljs.tools.reader.impl.commons.match_float = (function cljs$tools$reader$impl$commons$match_float(s){
var m = cljs.core.vec.call(null,cljs.core.re_find.call(null,cljs.tools.reader.impl.commons.float_pattern,s));
if((!((m.call(null,(4)) == null)))){
return parseFloat(m.call(null,(1)));
} else {
return parseFloat(s);
}
});
cljs.tools.reader.impl.commons.matches_QMARK_ = (function cljs$tools$reader$impl$commons$matches_QMARK_(pattern,s){
var vec__21062 = cljs.core.re_find.call(null,pattern,s);
var match = cljs.core.nth.call(null,vec__21062,(0),null);
return (match === s);
});
cljs.tools.reader.impl.commons.match_number = (function cljs$tools$reader$impl$commons$match_number(s){
if(cljs.tools.reader.impl.commons.matches_QMARK_.call(null,cljs.tools.reader.impl.commons.int_pattern,s)){
return cljs.tools.reader.impl.commons.match_int.call(null,s);
} else {
if(cljs.tools.reader.impl.commons.matches_QMARK_.call(null,cljs.tools.reader.impl.commons.float_pattern,s)){
return cljs.tools.reader.impl.commons.match_float.call(null,s);
} else {
if(cljs.tools.reader.impl.commons.matches_QMARK_.call(null,cljs.tools.reader.impl.commons.ratio_pattern,s)){
return cljs.tools.reader.impl.commons.match_ratio.call(null,s);
} else {
return null;
}
}
}
});
/**
* Parses a string into a vector of the namespace and symbol
*/
cljs.tools.reader.impl.commons.parse_symbol = (function cljs$tools$reader$impl$commons$parse_symbol(token){
if(((("" === token)) || (/:$/.test(token) === true) || (/^::/.test(token) === true))){
return null;
} else {
var ns_idx = token.indexOf("/");
var ns = (((ns_idx > (0)))?cljs.core.subs.call(null,token,(0),ns_idx):null);
if((!((ns == null)))){
var ns_idx__$1 = (ns_idx + (1));
if((ns_idx__$1 === cljs.core.count.call(null,token))){
return null;
} else {
var sym = cljs.core.subs.call(null,token,ns_idx__$1);
if((((!(cljs.tools.reader.impl.utils.numeric_QMARK_.call(null,cljs.core.nth.call(null,sym,(0)))))) && ((!(("" === sym)))) && (/:$/.test(ns) === false) && ((((sym === "/")) || (((-1) === sym.indexOf("/"))))))){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [ns,sym], null);
} else {
return null;
}
}
} else {
if((((token === "/")) || (((-1) === token.indexOf("/"))))){
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,token], null);
} else {
return null;
}
}
}
});
cljs.tools.reader.impl.commons.read_comment = (function cljs$tools$reader$impl$commons$read_comment(var_args){
var args__4736__auto__ = [];
var len__4730__auto___21067 = arguments.length;
var i__4731__auto___21068 = (0);
while(true){
if((i__4731__auto___21068 < len__4730__auto___21067)){
args__4736__auto__.push((arguments[i__4731__auto___21068]));
var G__21069 = (i__4731__auto___21068 + (1));
i__4731__auto___21068 = G__21069;
continue;
} else {
}
break;
}
var argseq__4737__auto__ = ((((1) < args__4736__auto__.length))?(new cljs.core.IndexedSeq(args__4736__auto__.slice((1)),(0),null)):null);
return cljs.tools.reader.impl.commons.read_comment.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__4737__auto__);
});
cljs.tools.reader.impl.commons.read_comment.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,_){
return cljs.tools.reader.impl.commons.skip_line.call(null,rdr);
});
cljs.tools.reader.impl.commons.read_comment.cljs$lang$maxFixedArity = (1);
/** @this {Function} */
cljs.tools.reader.impl.commons.read_comment.cljs$lang$applyTo = (function (seq21065){
var G__21066 = cljs.core.first.call(null,seq21065);
var seq21065__$1 = cljs.core.next.call(null,seq21065);
var self__4717__auto__ = this;
return self__4717__auto__.cljs$core$IFn$_invoke$arity$variadic(G__21066,seq21065__$1);
});
cljs.tools.reader.impl.commons.throwing_reader = (function cljs$tools$reader$impl$commons$throwing_reader(msg){
return (function() {
var G__21070__delegate = function (rdr,_){
return cljs.tools.reader.impl.errors.reader_error.call(null,rdr,msg);
};
var G__21070 = function (rdr,var_args){
var _ = null;
if (arguments.length > 1) {
var G__21071__i = 0, G__21071__a = new Array(arguments.length - 1);
while (G__21071__i < G__21071__a.length) {G__21071__a[G__21071__i] = arguments[G__21071__i + 1]; ++G__21071__i;}
_ = new cljs.core.IndexedSeq(G__21071__a,0,null);
}
return G__21070__delegate.call(this,rdr,_);};
G__21070.cljs$lang$maxFixedArity = 1;
G__21070.cljs$lang$applyTo = (function (arglist__21072){
var rdr = cljs.core.first(arglist__21072);
var _ = cljs.core.rest(arglist__21072);
return G__21070__delegate(rdr,_);
});
G__21070.cljs$core$IFn$_invoke$arity$variadic = G__21070__delegate;
return G__21070;
})()
;
});
//# sourceMappingURL=commons.js.map?rel=1582560146886

Some files were not shown because too many files have changed in this diff Show more