This commit is contained in:
Ruben Müller 2014-12-07 20:57:49 +01:00
parent 4ecfaad8e5
commit 760c1838ed
3983 changed files with 554828 additions and 378 deletions

954
app.js Normal file

File diff suppressed because one or more lines are too long

BIN
font/Minecraftia-Regular.ttf Executable file

Binary file not shown.

BIN
images/Thumbs.db Normal file

Binary file not shown.

BIN
images/actions.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 662 B

BIN
images/active.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

BIN
images/buildinfo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
images/cursor.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 953 B

BIN
images/deadtiles.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
images/end.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
images/entities.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 915 B

BIN
images/entitydetails.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

BIN
images/hud.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
images/info.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

BIN
images/intro1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
images/intro2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

BIN
images/intro3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
images/intro4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
images/layerdetails.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
images/layers.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
images/progress.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 136 B

BIN
images/selected.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
images/speechbubbles.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
images/speechbubbles.psd Normal file

Binary file not shown.

BIN
images/titlescreen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

View file

@ -1,42 +1,14 @@
<!doctype html>
<html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>Ld31 by arg-games</title>
<link rel="stylesheet" href="stylesheets/styles.css">
<link rel="stylesheet" href="stylesheets/pygment_trac.css">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<title>LD31</title>
<link rel="stylesheet" href="styles.css">
<script src="vendors/jquery-1.11.1.min.js"></script>
<script src="vendors/canvasquery.js"></script>
<script src="vendors/playground.js"></script>
</head>
<body>
<div class="wrapper">
<header>
<h1>Ld31</h1>
<p>ARG Games rocking Ludum Dare 31</p>
<p class="view"><a href="https://github.com/arg-games/ld31">View the Project on GitHub <small>arg-games/ld31</small></a></p>
<ul>
<li><a href="https://github.com/arg-games/ld31/zipball/master">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/arg-games/ld31/tarball/master">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/arg-games/ld31">View On <strong>GitHub</strong></a></li>
</ul>
</header>
<section>
<h1>
<a id="test" class="anchor" href="#test" aria-hidden="true"><span class="octicon octicon-link"></span></a>Test</h1>
</section>
<footer>
<p>This project is maintained by <a href="https://github.com/arg-games">arg-games</a></p>
<p><small>Hosted on GitHub Pages &mdash; Theme by <a href="https://github.com/orderedlist">orderedlist</a></small></p>
</footer>
</div>
<script src="javascripts/scale.fix.js"></script>
<script src="app.js"></script>
</body>
</html>
</html>

View file

@ -1,17 +0,0 @@
var metas = document.getElementsByTagName('meta');
var i;
if (navigator.userAgent.match(/iPhone/i)) {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
}
}
document.addEventListener("gesturestart", gestureStart, false);
}
function gestureStart() {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=0.25, maximum-scale=1.6";
}
}
}

1
node_modules/.bin/browser-sync generated vendored Symbolic link
View file

@ -0,0 +1 @@
../browser-sync/bin/browser-sync

1
node_modules/.bin/gulp generated vendored Symbolic link
View file

@ -0,0 +1 @@
../gulp/bin/gulp.js

596
node_modules/browser-sync/LICENSE-GPL generated vendored Normal file
View file

@ -0,0 +1,596 @@
GNU GENERAL PUBLIC LICENSE
==========================
Version 3, 29 June 2007
Copyright &copy; 2007 Free Software Foundation, Inc. &lt;<http://fsf.org/>&gt;
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
## Preamble
The GNU General Public License is a free, copyleft license for software and other
kinds of works.
The licenses for most software and other practical works are designed to take away
your freedom to share and change the works. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change all versions of a
program--to make sure it remains free software for all its users. We, the Free
Software Foundation, use the GNU General Public License for most of our software; it
applies also to any other work released this way by its authors. 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 them 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 prevent others from denying you these rights or
asking you to surrender the rights. Therefore, you have certain responsibilities if
you distribute copies of the software, or if you modify it: responsibilities to
respect the freedom of others.
For example, if you distribute copies of such a program, whether gratis or for a fee,
you must pass on to the recipients the same freedoms that you received. 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.
Developers that use the GNU GPL protect your rights with two steps: (1) assert
copyright on the software, and (2) offer you this License giving you legal permission
to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains that there is
no warranty for this free software. For both users' and authors' sake, the GPL
requires that modified versions be marked as changed, so that their problems will not
be attributed erroneously to authors of previous versions.
Some devices are designed to deny users access to install or run modified versions of
the software inside them, although the manufacturer can do so. This is fundamentally
incompatible with the aim of protecting users' freedom to change the software. The
systematic pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we have designed
this version of the GPL to prohibit the practice for those products. If such problems
arise substantially in other domains, we stand ready to extend this provision to
those domains in future versions of the GPL, as needed to protect the freedom of
users.
Finally, every program is threatened constantly by software patents. States should
not allow patents to restrict development and use of software on general-purpose
computers, but in those that do, we wish to avoid the special danger that patents
applied to a free program could make it effectively proprietary. To prevent this, the
GPL assures that patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and modification follow.
## TERMS AND CONDITIONS
### 0. Definitions.
&ldquo;This License&rdquo; refers to version 3 of the GNU General Public License.
&ldquo;Copyright&rdquo; also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
&ldquo;The Program&rdquo; refers to any copyrightable work licensed under this
License. Each licensee is addressed as &ldquo;you&rdquo;. &ldquo;Licensees&rdquo; and
&ldquo;recipients&rdquo; may be individuals or organizations.
To &ldquo;modify&rdquo; a work means to copy from or adapt all or part of the work in
a fashion requiring copyright permission, other than the making of an exact copy. The
resulting work is called a &ldquo;modified version&rdquo; of the earlier work or a
work &ldquo;based on&rdquo; the earlier work.
A &ldquo;covered work&rdquo; means either the unmodified Program or a work based on
the Program.
To &ldquo;propagate&rdquo; a work means to do anything with it that, without
permission, would make you directly or secondarily liable for infringement under
applicable copyright law, except executing it on a computer or modifying a private
copy. Propagation includes copying, distribution (with or without modification),
making available to the public, and in some countries other activities as well.
To &ldquo;convey&rdquo; a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through a computer
network, with no transfer of a copy, is not conveying.
An interactive user interface displays &ldquo;Appropriate Legal Notices&rdquo; to the
extent that it includes a convenient and prominently visible feature that (1)
displays an appropriate copyright notice, and (2) tells the user that there is no
warranty for the work (except to the extent that warranties are provided), that
licensees may convey the work under this License, and how to view a copy of this
License. If the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
### 1. Source Code.
The &ldquo;source code&rdquo; for a work means the preferred form of the work for
making modifications to it. &ldquo;Object code&rdquo; means any non-source form of a
work.
A &ldquo;Standard Interface&rdquo; means an interface that either is an official
standard defined by a recognized standards body, or, in the case of interfaces
specified for a particular programming language, one that is widely used among
developers working in that language.
The &ldquo;System Libraries&rdquo; of an executable work include anything, other than
the work as a whole, that (a) is included in the normal form of packaging a Major
Component, but which is not part of that Major Component, and (b) serves only to
enable use of the work with that Major Component, or to implement a Standard
Interface for which an implementation is available to the public in source code form.
A &ldquo;Major Component&rdquo;, in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system (if any) on which
the executable work runs, or a compiler used to produce the work, or an object code
interpreter used to run it.
The &ldquo;Corresponding Source&rdquo; for a work in object code form means all the
source code needed to generate, install, and (for an executable work) run the object
code and to modify the work, including scripts to control those activities. However,
it does not include the work's System Libraries, or general-purpose tools or
generally available free programs which are used unmodified in performing those
activities but which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for the work, and
the source code for shared libraries and dynamically linked subprograms that the work
is specifically designed to require, such as by intimate data communication or
control flow between those subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate
automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
### 2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the
Program, and are irrevocable provided the stated conditions are met. This License
explicitly affirms your unlimited permission to run the unmodified Program. The
output from running a covered work is covered by this License only if the output,
given its content, constitutes a covered work. This License acknowledges your rights
of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without
conditions so long as your license otherwise remains in force. You may convey covered
works to others for the sole purpose of having them make modifications exclusively
for you, or provide you with facilities for running those works, provided that you
comply with the terms of this License in conveying all material for which you do not
control copyright. Those thus making or running the covered works for you must do so
exclusively on your behalf, under your direction and control, on terms that prohibit
them from making any copies of your copyrighted material outside their relationship
with you.
Conveying under any other circumstances is permitted solely under the conditions
stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any
applicable law fulfilling obligations under article 11 of the WIPO copyright treaty
adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention
of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of
technological measures to the extent such circumvention is effected by exercising
rights under this License with respect to the covered work, and you disclaim any
intention to limit operation or modification of the work as a means of enforcing,
against the work's users, your or third parties' legal rights to forbid circumvention
of technological measures.
### 4. Conveying Verbatim Copies.
You may convey 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; keep intact all notices stating that this License and
any non-permissive terms added in accord with section 7 apply to the code; keep
intact all notices of the absence of any warranty; and give all recipients a copy of
this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer
support or warranty protection for a fee.
### 5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from
the Program, in the form of source code under the terms of section 4, provided that
you also meet all of these conditions:
* **a)** The work must carry prominent notices stating that you modified it, and giving a
relevant date.
* **b)** The work must carry prominent notices stating that it is released under this
License and any conditions added under section 7. This requirement modifies the
requirement in section 4 to &ldquo;keep intact all notices&rdquo;.
* **c)** You must license the entire work, as a whole, under this License to anyone who
comes into possession of a copy. This License will therefore apply, along with any
applicable section 7 additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no permission to license the
work in any other way, but it does not invalidate such permission if you have
separately received it.
* **d)** If the work has interactive user interfaces, each must display Appropriate Legal
Notices; however, if the Program has interactive interfaces that do not display
Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are
not by their nature extensions of the covered work, and which are not combined with
it such as to form a larger program, in or on a volume of a storage or distribution
medium, is called an &ldquo;aggregate&rdquo; if the compilation and its resulting
copyright are not used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work in an aggregate
does not cause this License to apply to the other parts of the aggregate.
### 6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and
5, provided that you also convey the machine-readable Corresponding Source under the
terms of this License, in one of these ways:
* **a)** Convey the object code in, or embodied in, a physical product (including a
physical distribution medium), accompanied by the Corresponding Source fixed on a
durable physical medium customarily used for software interchange.
* **b)** Convey the object code in, or embodied in, a physical product (including a
physical distribution medium), accompanied by a written offer, valid for at least
three years and valid for as long as you offer spare parts or customer support for
that product model, to give anyone who possesses the object code either (1) a copy of
the Corresponding Source for all the software in the product that is covered by this
License, on a durable physical medium customarily used for software interchange, for
a price no more than your reasonable cost of physically performing this conveying of
source, or (2) access to copy the Corresponding Source from a network server at no
charge.
* **c)** Convey individual copies of the object code with a copy of the written offer to
provide the Corresponding Source. This alternative is allowed only occasionally and
noncommercially, and only if you received the object code with such an offer, in
accord with subsection 6b.
* **d)** Convey the object code by offering access from a designated place (gratis or for
a charge), and offer equivalent access to the Corresponding Source in the same way
through the same place at no further charge. You need not require recipients to copy
the Corresponding Source along with the object code. If the place to copy the object
code is a network server, the Corresponding Source may be on a different server
(operated by you or a third party) that supports equivalent copying facilities,
provided you maintain clear directions next to the object code saying where to find
the Corresponding Source. Regardless of what server hosts the Corresponding Source,
you remain obligated to ensure that it is available for as long as needed to satisfy
these requirements.
* **e)** Convey the object code using peer-to-peer transmission, provided you inform
other peers where the object code and Corresponding Source of the work are being
offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the
Corresponding Source as a System Library, need not be included in conveying the
object code work.
A &ldquo;User Product&rdquo; is either (1) a &ldquo;consumer product&rdquo;, which
means any tangible personal property which is normally used for personal, family, or
household purposes, or (2) anything designed or sold for incorporation into a
dwelling. In determining whether a product is a consumer product, doubtful cases
shall be resolved in favor of coverage. For a particular product received by a
particular user, &ldquo;normally used&rdquo; refers to a typical or common use of
that class of product, regardless of the status of the particular user or of the way
in which the particular user actually uses, or expects or is expected to use, the
product. A product is a consumer product regardless of whether the product has
substantial commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
&ldquo;Installation Information&rdquo; for a User Product means any methods,
procedures, authorization keys, or other information required to install and execute
modified versions of a covered work in that User Product from a modified version of
its Corresponding Source. The information must suffice to ensure that the continued
functioning of the modified object code is in no case prevented or interfered with
solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for
use in, a User Product, and the conveying occurs as part of a transaction in which
the right of possession and use of the User Product is transferred to the recipient
in perpetuity or for a fixed term (regardless of how the transaction is
characterized), the Corresponding Source conveyed under this section must be
accompanied by the Installation Information. But this requirement does not apply if
neither you nor any third party retains the ability to install modified object code
on the User Product (for example, the work has been installed in ROM).
The requirement to provide Installation Information does not include a requirement to
continue to provide support service, warranty, or updates for a work that has been
modified or installed by the recipient, or for the User Product in which it has been
modified or installed. Access to a network may be denied when the modification itself
materially and adversely affects the operation of the network or violates the rules
and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with
this section must be in a format that is publicly documented (and with an
implementation available to the public in source code form), and must require no
special password or key for unpacking, reading or copying.
### 7. Additional Terms.
&ldquo;Additional permissions&rdquo; are terms that supplement the terms of this
License by making exceptions from one or more of its conditions. Additional
permissions that are applicable to the entire Program shall be treated as though they
were included in this License, to the extent that they are valid under applicable
law. If additional permissions apply only to part of the Program, that part may be
used separately under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any
additional permissions from that copy, or from any part of it. (Additional
permissions may be written to require their own removal in certain cases when you
modify the work.) You may place additional permissions on material, added by you to a
covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a
covered work, you may (if authorized by the copyright holders of that material)
supplement the terms of this License with terms:
* **a)** Disclaiming warranty or limiting liability differently from the terms of
sections 15 and 16 of this License; or
* **b)** Requiring preservation of specified reasonable legal notices or author
attributions in that material or in the Appropriate Legal Notices displayed by works
containing it; or
* **c)** Prohibiting misrepresentation of the origin of that material, or requiring that
modified versions of such material be marked in reasonable ways as different from the
original version; or
* **d)** Limiting the use for publicity purposes of names of licensors or authors of the
material; or
* **e)** Declining to grant rights under trademark law for use of some trade names,
trademarks, or service marks; or
* **f)** Requiring indemnification of licensors and authors of that material by anyone
who conveys the material (or modified versions of it) with contractual assumptions of
liability to the recipient, for any liability that these contractual assumptions
directly impose on those licensors and authors.
All other non-permissive additional terms are considered &ldquo;further
restrictions&rdquo; within the meaning of section 10. If the Program as you received
it, or any part of it, contains a notice stating that it is governed by this License
along with a term that is a further restriction, you may remove that term. If a
license document contains a further restriction but permits relicensing or conveying
under this License, you may add to a covered work material governed by the terms of
that license document, provided that the further restriction does not survive such
relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in
the relevant source files, a statement of the additional terms that apply to those
files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a
separately written license, or stated as exceptions; the above requirements apply
either way.
### 8. Termination.
You may not propagate or modify a covered work except as expressly provided under
this License. Any attempt otherwise to propagate or modify it is void, and will
automatically terminate your rights under this License (including any patent licenses
granted under the third paragraph of section 11).
However, if you cease all violation of this License, then your license from a
particular copyright holder is reinstated (a) provisionally, unless and until the
copyright holder explicitly and finally terminates your license, and (b) permanently,
if the copyright holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently
if the copyright holder notifies you of the violation by some reasonable means, this
is the first time you have received notice of violation of this License (for any
work) from that copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of
parties who have received copies or rights from you under this License. If your
rights have been terminated and not permanently reinstated, you do not qualify to
receive new licenses for the same material under section 10.
### 9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the
Program. Ancillary propagation of a covered work occurring solely as a consequence of
using peer-to-peer transmission to receive a copy likewise does not require
acceptance. However, nothing other than this License grants you permission to
propagate or modify any covered work. These actions infringe copyright if you do not
accept this License. Therefore, by modifying or propagating a covered work, you
indicate your acceptance of this License to do so.
### 10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license
from the original licensors, to run, modify and propagate that work, subject to this
License. You are not responsible for enforcing compliance by third parties with this
License.
An &ldquo;entity transaction&rdquo; is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an organization, or
merging organizations. If propagation of a covered work results from an entity
transaction, each party to that transaction who receives a copy of the work also
receives whatever licenses to the work the party's predecessor in interest had or
could give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if the predecessor
has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or
affirmed under this License. For example, you may not impose a license fee, royalty,
or other charge for exercise of rights granted under this License, and you may not
initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging
that any patent claim is infringed by making, using, selling, offering for sale, or
importing the Program or any portion of it.
### 11. Patents.
A &ldquo;contributor&rdquo; is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The work thus
licensed is called the contributor's &ldquo;contributor version&rdquo;.
A contributor's &ldquo;essential patent claims&rdquo; are all patent claims owned or
controlled by the contributor, whether already acquired or hereafter acquired, that
would be infringed by some manner, permitted by this License, of making, using, or
selling its contributor version, but do not include claims that would be infringed
only as a consequence of further modification of the contributor version. For
purposes of this definition, &ldquo;control&rdquo; includes the right to grant patent
sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license
under the contributor's essential patent claims, to make, use, sell, offer for sale,
import and otherwise run, modify and propagate the contents of its contributor
version.
In the following three paragraphs, a &ldquo;patent license&rdquo; is any express
agreement or commitment, however denominated, not to enforce a patent (such as an
express permission to practice a patent or covenant not to sue for patent
infringement). To &ldquo;grant&rdquo; such a patent license to a party means to make
such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the
Corresponding Source of the work is not available for anyone to copy, free of charge
and under the terms of this License, through a publicly available network server or
other readily accessible means, then you must either (1) cause the Corresponding
Source to be so available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner consistent with
the requirements of this License, to extend the patent license to downstream
recipients. &ldquo;Knowingly relying&rdquo; means you have actual knowledge that, but
for the patent license, your conveying the covered work in a country, or your
recipient's use of the covered work in a country, would infringe one or more
identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you
convey, or propagate by procuring conveyance of, a covered work, and grant a patent
license to some of the parties receiving the covered work authorizing them to use,
propagate, modify or convey a specific copy of the covered work, then the patent
license you grant is automatically extended to all recipients of the covered work and
works based on it.
A patent license is &ldquo;discriminatory&rdquo; if it does not include within the
scope of its coverage, prohibits the exercise of, or is conditioned on the
non-exercise of one or more of the rights that are specifically granted under this
License. You may not convey a covered work if you are a party to an arrangement with
a third party that is in the business of distributing software, under which you make
payment to the third party based on the extent of your activity of conveying the
work, and under which the third party grants, to any of the parties who would receive
the covered work from you, a discriminatory patent license (a) in connection with
copies of the covered work conveyed by you (or copies made from those copies), or (b)
primarily for and in connection with specific products or compilations that contain
the covered work, unless you entered into that arrangement, or that patent license
was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied
license or other defenses to infringement that may otherwise be available to you
under applicable patent law.
### 12. No Surrender of Others' Freedom.
If 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 convey a covered work so as to satisfy
simultaneously your obligations under this License and any other pertinent
obligations, then as a consequence you may not convey it at all. For example, if you
agree to terms that obligate you to collect a royalty for further conveying from
those to whom you convey the Program, the only way you could satisfy both those terms
and this License would be to refrain entirely from conveying the Program.
### 13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have permission to link or
combine any covered work with a work licensed under version 3 of the GNU Affero
General Public License into a single combined work, and to convey the resulting work.
The terms of this License will continue to apply to the part which is the covered
work, but the special requirements of the GNU Affero General Public License, section
13, concerning interaction through a network will apply to the combination as such.
### 14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU
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 that
a certain numbered version of the GNU General Public License &ldquo;or any later
version&rdquo; applies to it, you have the option of following the terms and
conditions either of that numbered version or of any later version published by the
Free Software Foundation. If the Program does not specify a version number of the GNU
General Public License, you may choose any version ever published by the Free
Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU
General Public License can be used, that proxy's public statement of acceptance of a
version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no
additional obligations are imposed on any author or copyright holder as a result of
your choosing to follow a later version.
### 15. Disclaimer of Warranty.
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 &ldquo;AS IS&rdquo; 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.
### 16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY
COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 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.
### 17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be
given local legal effect according to their terms, reviewing courts shall apply local
law that most closely approximates an absolute waiver of all civil liability in
connection with the Program, unless a warranty or assumption of liability accompanies
a copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
## How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible use to
the public, the best way to achieve this is to make it free software which everyone
can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them
to the start of each source file to most effectively state the exclusion of warranty;
and each file should have at least the &ldquo;copyright&rdquo; line and a pointer to
where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like this
when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type 'show c' for details.
The hypothetical commands 'show w' and 'show c' should show the appropriate parts of
the General Public License. Of course, your program's commands might be different;
for a GUI interface, you would use an &ldquo;about box&rdquo;.
You should also get your employer (if you work as a programmer) or school, if any, to
sign a &ldquo;copyright disclaimer&rdquo; for the program, if necessary. For more
information on this, and how to apply and follow the GNU GPL, see
&lt;<http://www.gnu.org/licenses/>&gt;.
The GNU General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may consider it
more useful to permit linking proprietary applications with the library. If this is
what you want to do, use the GNU Lesser General Public License instead of this
License. But first, please read
&lt;<http://www.gnu.org/philosophy/why-not-lgpl.html>&gt;.

97
node_modules/browser-sync/README.md generated vendored Normal file
View file

@ -0,0 +1,97 @@
# BrowserSync [![Build status] (https://ci.appveyor.com/api/projects/status/r5vung2ipn9uj4sy)](https://ci.appveyor.com/project/shakyShane/browser-sync) [![Build Status](http://img.shields.io/travis/shakyShane/browser-sync/master.svg?style=flat)] (https://travis-ci.org/shakyShane/browser-sync) [![Coverage Status](https://img.shields.io/coveralls/shakyShane/browser-sync.svg?style=flat)](https://coveralls.io/r/shakyShane/browser-sync?branch=master) [![NPM version](https://img.shields.io/npm/v/browser-sync.svg?style=flat)](http://npmjs.org/package/browser-sync)
> Keep multiple browsers & devices in sync when building websites.
<a href="http://www.wearejh.com"><img src="http://cl.ly/image/3Y3O0M2z310j/jh-100-red.png" /></a>
BrowserSync is developed and maintained internally at <a href="http://www.wearejh.com">JH</a>, follow <a href="http://www.twitter.com/browsersync">@BrowserSync</a> on twitter for news & updates.
##Features
1. **Scroll** - I can keep your pages in sync when scrolling.
2. **Forms** - You fill out a form in one browser, I'll copy the data to all the others.
3. **Links** - I'll watch your clicks and make all the other browsers follow you.
4. **CSS injecting** - I can even watch your CSS files & inject them when they change.
5. **Live Reload** - I can also watch files like HTML and PHP & when they change I can reload all browsers for you.
6. **Built-in Server** - Yep, I can serve static files too if you need me to (uses Connect).
7. **Use with any back-end setup** - I even have a proxy option so that I can be used with existing PHP, Rails, Python, Node or ASP.net setup.
8. **Public URL** - View your website via a URL that any internet connected device can access & maintain all BrowserSync features.
9. **Browser Stack support** - Use the all of my features when viewing your site through Browser Stack.
##When is it useful?
It's pretty useful when used with a single browser, watching a CSS file for changes & injecting it. But the real power comes when you're building responsive sites and using multiple devices/monitors because it can keep all browsers in sync & make your workflow much faster.
##Requirements
BrowserSync works by injecting an asynchronous script tag (`<script async>...</script>`) right after the `<body>` tag
during initial request. In order for this to work properly the `<body>` tag must be present. Alternatively you
can provide a custom rule for the snippet using [snippetOptions](http://www.browsersync.io/docs/options/#option-snippetOptions)
##Install
```
npm install -g browser-sync
```
##How to use it
1. [Command line](http://www.browsersync.io/docs/command-line/)
2. [API](http://www.browsersync.io/docs/api/)
## Using Grunt?
There's a [separate plugin](https://github.com/shakyShane/grunt-browser-sync) for that
## Using Gulp?
No problem, here's a [setup guide](http://www.browsersync.io/docs/gulp)
## Using Brunch?
Enjoy the [browser-sync-brunch plugin](https://github.com/ocombe/browser-sync-brunch)
## Screencasts
[Some listed here](https://github.com/shakyShane/browser-sync/wiki/Screencasts)
Want any more? Something specific? ask me nicely [@shaneOsbourne](http://www.twitter.com/shaneOsbourne)
##Support
If you've found Browser-sync useful and would like to contribute to its continued development & support, please feel free to send a donation of any size - it would be greatly appreciated!
[![Support via Gittip](https://rawgithub.com/chris---/Donation-Badges/master/gittip.jpeg)](https://www.gittip.com/shakyshane)
[![Support via PayPal](https://rawgithub.com/chris---/Donation-Badges/master/paypal.jpeg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=shakyshane%40gmail%2ecom&lc=US&item_name=browser%2dsync)
## Contributors
```
778 Shane Osbourne
29 Shinnosuke Watanabe
19 Shane Daniel
13 Hugo Bessa
11 Paul Kinlan
8 shinnn
3 Marek 'saji' Augustynowicz
3 Werner van Deventer
3 Adam Lynch
2 Paul Robertson
2 Dan Tello
2 Hugo Dias
2 Michael Branch
2 Olivier Combe
2 Piotr Kaleta
2 brutaldev
2 chase_chou
1 Dave Hall
1 mericson
1 Robert Vock
1 Craig Morris
1 Cedric Kastner
1 Carl Henderson
1 Sylvain Emery
1 Tony Holdstock-Brown
1 Victor Fernandez de Alba
1 Cameron Spear
1 Yazhong Liu
1 Jory Graham
1 Benjamín Eidelman
1 viktor hesselbom
1 Guillaume Lambert
1 Peter Blazejewicz
```
## License
Copyright (c) 2014 Shane Osbourne
Licensed under the GPL license.

28
node_modules/browser-sync/bin/browser-sync generated vendored Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env node
"use strict";
var cli = require("../lib/cli/index");
var pjson = require("../package.json");
var utils = require("../lib/utils");
var init = cli.init;
var info = cli.info;
var BrowserSync = require("../lib/browser-sync");
var browserSync = new BrowserSync();
var argv = process.argv;
var args = require("minimist")(argv.slice(2));
init.parse(pjson.version, args, argv, function (err, data) {
if (err) {
utils.fail(err, {}, true);
}
if (data.config) {
browserSync.init(data.files || [], data.config, pjson.version);
}
if (data.configFile) {
info.makeConfig(browserSync.cwd);
}
});

80
node_modules/browser-sync/index.js generated vendored Executable file
View file

@ -0,0 +1,80 @@
#! /usr/bin/env node
"use strict";
/**
* @module BrowserSync
*/
var pjson = require("./package.json");
var BrowserSync = require("./lib/browser-sync");
var browserSync = new BrowserSync();
/**
* @method browserSync
* @param {Object} [config] This is the main configuration for your BrowserSync instance and can contain any of the [available options]({{site.links.options}})
* If you do not pass a config an argument for configuration, BrowserSync will still run; but it will be in the `snippet` mode
* @param {Function} [cb] If you pass a callback function, it will be called when BrowserSync has completed all setup tasks and is ready to use. This
* is useful when you need to wait for information (for example: urls, port etc) or perform other tasks synchronously.
* @returns {BrowserSync}
*/
var publicInit = require("./lib/public/init")(browserSync, pjson);
module.exports = publicInit;
module.exports.init = publicInit;
/**
* The `reload` method will inform all browsers about changed files and will either cause the browser to refresh, or inject the files where possible.
*
* @method reload
* @param {String|Array|Object} [arg] The file or files to be reloaded. For
* details and examples of Streams support, please see the [GulpJS]({{site.links.gulp}}) examples
* @returns {*}
*/
module.exports.reload = require("./lib/public/reload")(browserSync);
/**
* Helper method for browser notifications
*
* @method notify
* @param {String|HTML} msg Can be a simple message such as 'Connected' or HTML
* @param {Number} [timeout] How long the message will remain in the browser. @since 1.3.0
*/
module.exports.notify = require("./lib/public/notify")(browserSync);
/**
* Register a plugin. Must implement at least a 'plugin' method that returns a
* callable function.
*
* @method use
* @param {String} name The name of the plugin
* @param {Object} module The object to be `required`.
* @param {Function} [cb] A callback function that will return any errors.
*/
module.exports.use = browserSync.registerPlugin.bind(browserSync);
/**
* The internal Event Emitter used by the running BrowserSync instance (if there is one).
* You can use this to emit your own events, such as changed files, logging etc.
*
* @property emitter
* @type Events.EventEmitter
*/
module.exports.emitter = browserSync.events;
/**
* This method will close any running server, stop file watching & exit the current process.
*
* @method exit
*/
module.exports.exit = require("./lib/public/exit")(browserSync);
/**
* A simple true/false flag that you can use to determine if there's a currently-running BrowserSync instance.
*
* @property active
*/
Object.defineProperty(module.exports, "active", {
get: function () {
return browserSync.active;
}
});

71
node_modules/browser-sync/lib/args.js generated vendored Normal file
View file

@ -0,0 +1,71 @@
"use strict";
function isFilesArg (arg) {
return Array.isArray(arg) || typeof arg === "string";
}
/**
* Handle arguments for backwards compatibility
* @param {Object} args
* @returns {{config: {}, cb: *}}
*/
module.exports = function (args) {
var config = {};
var cb;
switch (args.length) {
case 1 :
if (isFilesArg(args[0])) {
config.files = args[0];
} else if (typeof args[0] === "function") {
cb = args[0];
} else {
config = args[0];
}
break;
case 2 :
// if second is a function, first MUST be config
if (typeof args[1] === "function") {
config = args[0] || {};
cb = args[1];
} else {
config = args[1] || {};
if (!config.files) {
config.files = args[0];
}
}
break;
case 3 :
config = args[1] || {};
if (!config.files) {
config.files = args[0];
}
cb = args[2];
}
return {
config: config,
cb: cb
};
};

436
node_modules/browser-sync/lib/browser-sync.js generated vendored Normal file
View file

@ -0,0 +1,436 @@
"use strict";
var services = require("./services");
var hooks = require("./hooks");
var config = require("./config");
var messages = require("./messages");
var utils = require("./utils");
var logger = require("./logger");
var _ = require("lodash");
var EE = require("easy-extender");
var filePath = require("path");
var events = require("events");
var objectPath = require("object-path");
/**
* Required internal plugin, all can be overridden.
*/
var defaultPlugins = {
"logger": logger,
"socket": require("./sockets"),
"file:watcher": require("./file-watcher"),
"server": require("./server"),
"tunnel": require("./tunnel"),
"client:script": require("browser-sync-client")
};
/**
* @constructor
*/
var BrowserSync = function () {
this.cwd = process.cwd();
this.active = false;
this.config = config;
// Events
this.events = new events.EventEmitter();
this.events.setMaxListeners(20);
this._reloadQueue = [];
this._browserReload = false;
// Plugin management
this.pluginManager = new EE(defaultPlugins, hooks);
this._userPlugins = [];
this.clientEvents = [
"scroll",
"input:text",
"input:toggles",
"form:submit",
"form:reset",
"click"
];
};
/**
* @param module
* @param opts
* @param cb
*/
BrowserSync.prototype.registerPlugin = function (module, opts, cb) {
this.pluginManager.registerPlugin(module, opts, cb);
if (module["plugin:name"]) {
this._userPlugins.push(module);
}
};
/**
* @param {Function} [filter]
*/
BrowserSync.prototype.getUserPlugins = function (filter) {
filter = filter || function () {
return true;
};
/**
* Transform Plugins option
*/
this.userPlugins = this._userPlugins.filter(filter).map(function (plugin) {
return {
name: plugin["plugin:name"],
active: plugin._enabled
};
});
return this.userPlugins;
};
/**
* Get middleware
* @returns {*}
*/
BrowserSync.prototype.getMiddleware = function (type) {
var types = {
"connector": messages.socketConnector(this.options.port, this.options, true),
"socket-js": require("./snippet").utils.getSocketScript()
};
if (type in types) {
return function (req, res) {
res.setHeader("Content-Type", "text/javascript");
res.end(types[type]);
};
}
};
/**
* @param {Array} files
* @param {Object} options
* @param {String} version
* @param {Function} cb
* @returns {BrowserSync}
*/
BrowserSync.prototype.init = function (files, options, version, cb) {
var err;
this.version = options.version = version;
this.cb = cb;
this.pluginManager.init();
this.pluginManager.wrap(require("localtunnel"), "tunnel:runner");
this.logger = this.pluginManager.get("logger")(this.events, options);
this.debugger = this.logger.clone({useLevelPrefixes: true});
this.debug = this.debugger.debug;
// Die if both server & proxy options provided
if (options.server && options.proxy) {
err = "Invalid config. You cannot specify both a server & proxy option.";
this.events.emit("config:error", {msg: err});
return utils.fail(true, err, this.cb);
}
this.debug("Looking for an empty port...");
utils.getPorts(options)
.then(this.handleSuccess.bind(this, options))
.catch(this.handleError.bind(this, options));
return this;
};
/**
* @param options
* @param err
*/
BrowserSync.prototype.handleError = function (options, err) {
this.logger.mute(false).error(err);
utils.fail(true, err, this.cb);
};
/**
* @param options
* @param ports
*/
BrowserSync.prototype.handleSuccess = function (options, ports) {
var debug = this.debug;
debug("Using port {magenta:%s", ports[0]);
options.port = ports[0];
var init = function () {
services.init(this)(options);
}.bind(this);
if (_.isUndefined(options.online) && _.isUndefined(process.env.TESTING)) {
debug("Checking if you're online");
require("dns").resolve("www.google.com", function (err) {
if (err) {
debug("Could not resolve www.google.com, setting {magenta:online: false}");
options.online = false;
} else {
debug("Resolved www.google.com, setting {magenta:online: true}");
options.online = true;
}
init();
});
} else {
init();
}
};
/**
* Callback helper
* @param err
* @param [data]
*/
BrowserSync.prototype.callback = function (err, data) {
if (_.isFunction(this.cb)) {
this.cb(err, data, this);
}
this.events.emit("service:ready");
};
/**
* Callback helper
* @param name
* @param [defaultValue]
*/
BrowserSync.prototype.getOption = function (name, defaultValue) {
this.debug("Getting option: {magenta:%s", name);
return objectPath.get(this.options, name, defaultValue);
};
/**
* @returns {BrowserSync.options}
*/
BrowserSync.prototype.getOptions = function () {
return this.options;
};
/**
* @returns {BrowserSync.options}
*/
BrowserSync.prototype.getLogger = logger.getLogger;
/**
* @param {String} name
* @param {*} value
* @returns {BrowserSync.options|*}
*/
BrowserSync.prototype.setOption = function (name, value) {
var objectPath = require("object-path");
if (!_.isUndefined(objectPath.get(this.options, name))) {
this.debug("Setting option: {magenta:%s", name);
objectPath.set(this.options, name, value);
this.events.emit("options:set", {name: name, value: value, options: this.options});
}
return this.options;
};
/**
* Internal Events
* @param {Object} options
*/
BrowserSync.prototype.registerInternalEvents = function (options) {
var events = {
"file:changed": function (data) {
if (data.namespace === "core") {
if (_.isUndefined(data.log)) {
data.log = this.getOption("logFileChanges");
}
this.changeFile(data, options);
}
},
"file:reload": function (data) {
this.doFileReload(data);
},
"browser:reload": function () {
this.doBrowserReload();
},
"browser:notify": function (data) {
this.io.sockets.emit("browser:notify", data);
},
/**
* Things that happened after the service is running
* @param data
*/
"service:running": function (data) {
if (data.type !== "snippet") {
utils.openBrowser(data.url, options);
}
// log about any file watching
if (this.watchers) {
this.events.emit("file:watching", this.watchers);
}
},
"options:set": function (data) {
this.io.sockets.emit("options:set", data);
},
"init": function () {
this.active = true;
},
"plugins:configure": function (data) {
if (data.active) {
this.pluginManager.enablePlugin(data.name);
} else {
this.pluginManager.disablePlugin(data.name);
}
this.options.userPlugins = this.getUserPlugins();
}
};
_.each(events, function (func, event) {
this.events.on(event, func.bind(this));
}, this);
};
/**
* Handle Browser Reloads
*/
BrowserSync.prototype.doBrowserReload = function () {
var bs = this;
if (bs._browserReload) {
return;
}
bs._browserReload = setTimeout(function () {
bs.io.sockets.emit("browser:reload");
clearTimeout(bs._browserReload);
bs._browserReload = false;
}, this.getOption("reloadDelay"));
};
/**
* Handle a queue of reloads
* @param {Object} data
*/
BrowserSync.prototype.doFileReload = function (data) {
var bs = this;
bs._reloadQueue = bs._reloadQueue || [];
bs._reloadQueue.push(data);
if (bs._reloadTimer) {
return;
}
bs._reloadTimer = setTimeout(function () {
if (utils.willCauseReload(bs._reloadQueue.map(function (item) { return item.path; }), bs.getOption("injectFileTypes"))) {
bs.io.sockets.emit("browser:reload");
} else {
bs._reloadQueue.forEach(function (item) {
bs.io.sockets.emit("file:reload", item);
});
}
clearTimeout(bs._reloadTimer);
bs._reloadTimer = undefined;
bs._reloadQueue = [];
}, bs.getOption("reloadDelay"));
};
/**
* Instance Cleanup
*/
BrowserSync.prototype.cleanup = function (cb) {
if (!this.active) {
return;
}
// Close any servers
if (this.server) {
this.debug("Closing server...");
this.server.close();
}
// Stop any file watching
if (this.watchers) {
this.debug("Stopping watchers...");
_.each(this.watchers, function (item) {
item.watcher.end();
});
}
// Remove all event listeners
if (this.events) {
this.debug("Removing event listeners...");
this.events.removeAllListeners();
}
// Reset the flag
this.debug("Setting {magenta:active: false");
this.active = false;
this.pluginManager.plugins = {};
this.pluginManager.pluginOptions = {};
this._userPlugins = [];
this._reloadTimer = undefined;
this._reloadQueue = undefined;
if (_.isFunction(cb)) {
cb(null);
}
};
/**
* @param {Object} data
* @param {Object} options
* @returns {{assetFileName: String}}
*/
BrowserSync.prototype.changeFile = function (data, options) {
var path = data.path;
var fileName = filePath.basename(path);
var fileExtension = utils.getFileExtension(path);
var obj = {
assetFileName: fileName,
fileExtension: fileExtension
};
var message = "inject";
// RELOAD page
if (!_.contains(options.injectFileTypes, fileExtension)) {
obj.url = path;
message = "reload";
}
obj.cwd = this.cwd;
obj.path = path;
obj.type = message;
obj.log = data.log;
// emit the event through socket
this.events.emit("file:reload", obj);
return obj;
};
module.exports = BrowserSync;

66
node_modules/browser-sync/lib/cli/cli-info.js generated vendored Normal file
View file

@ -0,0 +1,66 @@
"use strict";
var config = require("./../config");
var utils = require("./../utils");
var logger = require("./../logger").logger;
var fs = require("fs");
var _ = require("lodash");
var path = require("path");
var info = {
/**
* Version info
* @param {Object} pjson
* @returns {String}
*/
getVersion: function (pjson) {
console.log(pjson.version);
return pjson.version;
},
/**
* Retrieve the config file
* @returns {*}
* @private
* @param filePath
*/
_getConfigFile: function (filePath) {
var relPath = path.resolve(process.cwd() + "/" + filePath);
if (fs.existsSync(relPath)) {
return require(relPath);
}
return false;
},
/**
* Generate an example Config file.
*/
makeConfig: function (cwd) {
var opts = require(__dirname + "/../" + config.configFile);
var userOpts = {};
var ignore = ["excludedFileTypes", "injectFileTypes"];
Object.keys(opts).forEach(function (key) {
if (!_.contains(ignore, key)) {
userOpts[key] = opts[key];
}
});
var file = fs.readFileSync(__dirname + config.template);
file = file.toString().replace("//OPTS", JSON.stringify(userOpts, null, 4));
var path = cwd + config.userFile;
fs.writeFile(path, file, function () {
logger.info("Config file created {magenta:%s}", utils.resolveRelativeFilePath(path, cwd));
logger.info(
"To use it, in the same directory run: " +
"{cyan:browser-sync start --config bs-config.js}"
);
});
}
};
module.exports = info;

91
node_modules/browser-sync/lib/cli/cli-init.js generated vendored Normal file
View file

@ -0,0 +1,91 @@
"use strict";
var defaultConfig = require("./../default-config");
var cliOptions = require("./cli-options");
var info = require("./cli-info");
var opts = require("./opts.json");
var tfunk = require("tfunk");
var program = require("commander");
var merge = require("opt-merger").merge;
module.exports.allowedOptions = ["host", "server", "proxy"];
/**
* Handle command-line usage with 'start'
* @param args
* @param cb
*/
module.exports.startFromCommandLine = function (args, cb) {
var userConfig;
// First look for provided --config option
if (args.config) {
userConfig = info._getConfigFile(args.config);
}
var options = merge(defaultConfig, userConfig || {}, cliOptions.callbacks);
cb(null, {
files: options.files || [],
config: options
});
};
/**
* @param {String} version
* @param {Object} args - minimist object
* @param {Object} argv
* @param {Function} cb
*/
module.exports.parse = function (version, args, argv, cb) {
program
.version(version)
.usage("<command> [options]");
Object.keys(opts).forEach(function (key) {
program.option(key, opts[key]);
});
program
.on("--help", exports.help);
program
.command("init")
.description("Creates a default config file")
.action(function () {
cb(null, {configFile: true});
});
program
.command("start")
.description("Start Browser Sync")
.action(exports.startFromCommandLine.bind(null, args, cb));
program.parse(argv);
if (!args._.length) {
program.help();
}
};
/**
* Help screen
*/
module.exports.help = function () {
console.log(tfunk(" {bold:Server Example:"));
console.log(" ---------------");
console.log(" Use current directory as root & watch CSS files");
console.log("");
console.log(tfunk(" {magenta:$}{cyan: browser-sync start --server --files=\"css/*.css\""));
console.log("");
console.log(tfunk(" {bold:Proxy Example:"));
console.log(" --------------");
console.log(" Proxy `localhost:8080` & watch CSS files");
console.log("");
console.log(tfunk(" {magenta:$}{cyan: browser-sync start --proxy=\"localhost:8080\" --files=\"css/*.css\""));
console.log("");
};

266
node_modules/browser-sync/lib/cli/cli-options.js generated vendored Normal file
View file

@ -0,0 +1,266 @@
"use strict";
var path = require("path");
var _ = require("lodash");
var utils = {
/**
* @param pattern
* @returns {*|string}
* @private
*/
wrapPattern: function (pattern) {
var prefix = "!";
var suffix = "/**";
var lastChar = pattern.charAt(pattern.length - 1);
var extName = path.extname(pattern);
// If there's a file ext, don't append any suffix
if (extName.length) {
suffix = "";
} else {
if (lastChar === "/") {
suffix = "**";
}
if (lastChar === "*") {
suffix = "";
}
}
return [prefix, pattern, suffix].join("");
}
};
module.exports.utils = utils;
module.exports.callbacks = {
/**
* Merge server options
* @param defaultValue
* @param merged
* @param newValue
* @param args
* @returns {*}
*/
server: function (defaultValue, merged, newValue, args) {
// Return if object or array given
if (typeof merged === "undefined" || merged === false) {
return defaultValue;
}
if (newValue.baseDir) {
return newValue;
}
var obj = {
baseDir: "./"
};
if (newValue !== true) {
obj.baseDir = newValue;
}
if (args) {
if (args.index) {
obj.index = args.index;
}
if (args.directory) {
obj.directory = true;
}
}
return obj;
},
/**
* @param defaultValue
* @param newValue
* @returns {*}
*/
proxy: function (defaultValue, newValue) {
var protocol = "http";
var host = "localhost";
var port = 80;
var segs;
var startPath = false;
var returnObj;
if (typeof newValue !== "string") {
return false;
}
var url = newValue.replace(/^(https?):\/\//, function (match, solo) {
protocol = solo;
return "";
});
if (~url.indexOf(":")) {
segs = url.split(":");
host = segs[0];
port = parseInt(segs[1], 10);
} else {
host = url;
}
if (~host.indexOf("/")) {
segs = host.split("/");
host = segs.shift();
startPath = segs.join("/");
}
returnObj = {
protocol: protocol,
host: host,
port: port,
target: protocol + "://" + host + (port > 80 ? ":" + port : "")
};
if (startPath) {
returnObj.startPath = startPath;
}
return returnObj;
},
/**
* @param {Object} defaultValue
* @param {String} newValue
* @returns {String}
* @private
*/
host: function (defaultValue, newValue) {
if (newValue && typeof newValue === "string") {
return newValue;
}
return null;
},
/**
* @param defaultValue
* @param newValue
* @private
*/
ports: function (defaultValue, newValue) {
var segs;
var obj = {};
if (typeof newValue === "string") {
if (~newValue.indexOf(",")) {
segs = newValue.split(",");
obj.min = parseInt(segs[0], 10);
obj.max = parseInt(segs[1], 10);
} else {
obj.min = parseInt(newValue, 10);
obj.max = null;
}
return obj;
} else {
return {
min: newValue.min,
max: newValue.max || null
};
}
},
/**
* @param defaultValue
* @returns {*}
*/
ghostMode: function (defaultValue, merged, newValue, args) {
var def = _.cloneDeep(merged);
var trueAll = {
clicks: true,
scroll: true,
location: false,
forms: {
submit: true,
inputs: true,
toggles: true
}
};
var falseAll = {
clicks: false,
scroll: false,
location: false,
forms: {
submit: false,
inputs: false,
toggles: false
}
};
if (merged === false || merged === "false" || args && args.ghost === false) {
return falseAll;
}
if (merged === true || merged === "true" || args && args.ghost === true) {
return trueAll;
}
if (merged.forms === false || newValue === false || newValue === "false") {
def.forms = {
submit: false,
inputs: false,
toggles: false
};
}
if (merged.forms === true || newValue === true || newValue === "true") {
def.forms = {
submit: true,
inputs: true,
toggles: true
};
}
return def;
},
/**
* @param defaultValue
* @param newValue
* @param args
* @param config
* @returns {*}
*/
files: function (defaultValue, newValue, args, config) {
var merged = [];
var exclude = config && config.exclude ? config.exclude : false;
if (newValue) {
if (typeof newValue === "string") {
if (~newValue.indexOf(",")) {
merged = merged.concat(newValue.split(",").map(function (item) {
return item.trim();
}));
} else {
merged.push(newValue);
}
} else {
merged = newValue;
}
if (typeof exclude === "string") {
merged.push(utils.wrapPattern(exclude));
} else {
if (Array.isArray(exclude)) {
exclude.forEach(function (pattern) {
merged.push(utils.wrapPattern(pattern));
}, this);
}
}
}
return merged;
}
};

15
node_modules/browser-sync/lib/cli/cli-template.js generated vendored Normal file
View file

@ -0,0 +1,15 @@
/*
|--------------------------------------------------------------------------
| Browser-sync config file
|--------------------------------------------------------------------------
|
| For up-to-date information about the options:
| http://www.browsersync.io/docs/options/
|
| There are more options than you see here, these are just the ones that are
| set internally. See the website for more info.
|
|
*/
module.exports = //OPTS;

7
node_modules/browser-sync/lib/cli/index.js generated vendored Normal file
View file

@ -0,0 +1,7 @@
"use strict";
module.exports = {
init: require("./cli-init"),
options: require("./cli-options"),
info: require("./cli-info")
};

21
node_modules/browser-sync/lib/cli/opts.json generated vendored Normal file
View file

@ -0,0 +1,21 @@
{
"--files": "File paths to watch",
"--exclude": "File patterns to ignore",
"--server": "Run a Local server (uses your cwd as the web root)",
"--index": "Specify which file should be used as the index page",
"--startPath": "Specify the start path for the opened browser",
"--https": "Enable SSL for local development",
"--directory": "Show a directory listing for the server",
"--proxy": "Proxy an existing server",
"--xip": "Use xip.io domain routing",
"--tunnel": "Use a public URL",
"--open": "Choose which URL is auto-opened (local, external or tunnel)",
"--config": "Specify a path to a bs-config.js file",
"--host": "Specify a hostname to use",
"--logLevel": "Set the logger output level (silent, info or debug)",
"--port": "Specify a port to use",
"--no-notify": "Disable the notify element in browsers",
"--no-open": "Don't open a new browser window",
"--no-ghost": "Disable Ghost Mode",
"--no-online": "Force offline usage"
}

23
node_modules/browser-sync/lib/config.js generated vendored Normal file
View file

@ -0,0 +1,23 @@
"use strict";
var path = require("path");
/**
* @type {{controlPanel: {jsFile: string, baseDir: *}, socketIoScript: string, configFile: string, client: {shims: string}}}
*/
module.exports = {
controlPanel: {
jsFile: "/js/app.js",
baseDir: path.resolve(__dirname + "/control-panel")
},
templates: {
scriptTag: path.resolve(__dirname + "/templates/script-tags.tmpl"),
connector: path.resolve(__dirname + "/templates/connector.tmpl")
},
socketIoScript: "/public/socket.io.js",
configFile: "/default-config.js",
userFile: "/bs-config.js",
template: "/cli-template.js",
client: {
shims: "/client/client-shims.js"
}
};

310
node_modules/browser-sync/lib/default-config.js generated vendored Normal file
View file

@ -0,0 +1,310 @@
"use strict";
/**
* @module BrowserSync.options
*/
module.exports = {
/**
* BrowserSync can watch your files as you work. Changes you make will either
* be injected into the page (CSS & images) or will cause all browsers to do
* a full-page refresh. See [isaacs's minimatch](https://github.com/isaacs/minimatch) for more information on glob patterns.
* @property files
* @type Array|String
* @default false
*/
files: false,
/**
* File watching options that get passed along to [Gaze](https://github.com/shama/gaze). Check out the [properties](https://github.com/shama/gaze#properties)
* section of their docs to see which options they support.
* for availbable options
* @property watchOptions
* @type Object
* @default undefined
* @since 1.3.0
*/
/**
* Use the built-in static server for basic HTML/JS/CSS websites.
* @property server
* @type Object|Boolean
* @default false
*/
server: false,
/**
* Proxy an EXISTING vhost. BrowserSync will wrap your existing url and provide a different one to use.
* @property proxy
* @type String|Boolean
* @default false
*/
proxy: false,
/**
* @property port
* @type Number
* @default 3000
*/
port: 3000,
/**
* Enable https for localhost development. **Note:** Proxy and Tunnel not currently supported.
* @property https
* @type Boolean
* @default undefined
* @since 1.3.0
*/
/**
* @property ghostMode
* @param {Boolean} [clicks=true]
* @param {Boolean} [scroll=true]
* @param {Boolean} [location=false]
* @param {Boolean} [forms=true]
* @param {Boolean} [forms.submit=true]
* @param {Boolean} [forms.inputs=true]
* @param {Boolean} [forms.toggles=true]
* @type Object
*/
ghostMode: {
clicks: true,
scroll: true,
location: false,
forms: {
submit: true,
inputs: true,
toggles: true
}
},
/**
* Can be either "info", "debug", "warn", or "silent"
* @property logLevel
* @type String
* @default info
*/
logLevel: "info",
/**
* Change the console logging prefix. Useful if you're creating your
* own project based on BrowserSync
* @property logPrefix
* @type String
* @default BS
* @since 1.5.1
*/
logPrefix: "BS",
/**
* @property logConnections
* @type Boolean
* @default false
*/
logConnections: false,
/**
* @property logFileChanges
* @type Boolean
* @default true
*/
logFileChanges: true,
/**
* Log the snippet to the console when you're in snippet mode (no proxy/server)
* @property logSnippet
* @type: Boolean
* @default true
* @since 1.5.2
*/
logSnippet: true,
/**
* SINCE 1.7.0! You can control how the snippet is injected
* onto each page via a custom regex + function.
* You can also provide patterns for certain urls
* that should be ignored from the snippet injection.
* @property snippetOptions
* @since 1.7.0
* @param {String|Array} [ignorePaths=undefined]
* @param {RegExp} [rule.match=/&lt;body&#91;^&gt;&#93;*&gt;/i]
* @param {Function} [rule.fn=Function]
* @type Object
*/
snippetOptions: {
rule: {
match: /<body[^>]*>/i,
fn: function (snippet, match) {
return match + snippet;
}
}
},
/**
* @property tunnel
* @type String|Boolean
* @default null
*/
/**
* Some features of BrowserSync (such as `xip` & `tunnel`) require an internet connection, but if you're
* working offline, you can reduce start-up time by setting this option to `false`
* @property online
* @type Boolean
* @default undefined
*/
/**
* Decide which URL to open automatically when BrowserSync starts. Defaults to "local" if none set.
* Can be true, "local", "external" or "tunnel"
* @property open
* @type Boolean|String
* @default true
*/
open: "local",
/**
* @property browser
* @type String|Array
* @default default
*/
browser: "default",
/**
* Requires an internet connection - useful for services such as [Typekit](https://typekit.com/)
* as it allows you to configure domains such as `*.xip.io` in your kit settings
* @property xip
* @type Boolean
* @default false
*/
xip: false,
hostnameSuffix: false,
/**
* The small pop-over notifications in the browser are not always needed/wanted.
* @property notify
* @type Boolean
* @default true
*/
notify: true,
/**
* @property scrollProportionally
* @type Boolean
* @default true
*/
scrollProportionally: true,
/**
* @property scrollThrottle
* @type Number
* @default 0
*/
scrollThrottle: 0,
/**
* @property reloadDelay
* @type Number
* @default 0
*/
reloadDelay: 0,
/**
* @property injectChanges
* @type Boolean
* @default true
*/
injectChanges: true,
/**
* @property startPath
* @type String|Null
* @default null
*/
startPath: null,
/**
* Whether to minify client script, or not.
* @property minify
* @type Boolean
* @default true
*/
minify: true,
/**
* @property host
* @type String
* @default null
*/
host: null,
/**
* @property codeSync
* @type Boolean
* @default true
*/
codeSync: true,
/**
* @property timestamps
* @type Boolean
* @default true
*/
timestamps: true,
/**
* Alter the script path for complete control over where the BrowserSync
* Javascript is served from. Whatever you return from this function
* will be used as the script path.
* @property scriptPath
* @default undefined
* @since 1.5.0
* @type Function
*/
/**
* Configure the Socket.IO path and namespace to avoid collisions. Note: `namespace` can also be a function
* @property socket
* @param {String} [path="/browser-sync/socket.io"]
* @param {String} [clientPath="/browser-sync"]
* @param {String|Function} [namespace="/browser-sync"]
* @since 1.6.2
* @type Object
*/
socket: {
path: "/browser-sync/socket.io",
clientPath: "/browser-sync",
namespace: "/browser-sync"
},
injectFileTypes: ["css", "png", "jpg", "jpeg", "svg", "gif", "webp"],
excludedFileTypes: [
"js",
"css",
"pdf",
"map",
"svg",
"ico",
"woff",
"json",
"eot",
"ttf",
"png",
"jpg",
"jpeg",
"webp",
"gif",
"mp4",
"mp3",
"3gp",
"ogg",
"ogv",
"webm",
"m4a",
"flv",
"wmv",
"avi",
"swf",
"scss"
],
debugInfo: true
};

34
node_modules/browser-sync/lib/file-watcher.js generated vendored Normal file
View file

@ -0,0 +1,34 @@
"use strict";
var globWatcher = require("glob-watcher");
var _ = require("lodash");
/**
* Plugin interface
* @returns {*|function(this:exports)}
*/
module.exports.plugin = function (globs, options, emitter) {
// Options to pass along to Gaze
var watchOptions = options.watchOptions || options.watchoptions || {};
var tempWatcher;
var watchers = {};
_.each(globs, function (glob, namespace) {
tempWatcher = globWatcher(glob, watchOptions, function (data) {
data.namespace = namespace;
emitter.emit("file:changed", data);
});
// Ignore dir-related errors from gaze
tempWatcher.on("error", function () {/*noop*/});
watchers[namespace] = {
glob: glob,
watcher: tempWatcher
};
});
return watchers;
};

102
node_modules/browser-sync/lib/hooks.js generated vendored Normal file
View file

@ -0,0 +1,102 @@
"use strict";
var _ = require("lodash");
var snippetUtils = require("./snippet").utils;
module.exports = {
/**
*
* @this {BrowserSync}
* @returns {String}
*/
"client:js": function (hooks, data) {
var js = snippetUtils.getClientJs(data.port, data.options);
return hooks.reduce(function (joined, hook) {
return joined += hook;
}, js);
},
/**
* @this {BrowserSync}
* @returns {Array}
*/
"client:events": function (hooks, clientEvents) {
hooks.forEach(function (hook) {
var result = hook(this);
if (Array.isArray(result)) {
clientEvents = _.union(clientEvents, result);
} else {
clientEvents.push(result);
}
}, this);
return clientEvents;
},
/**
* @returns {Array}
*/
"server:middleware": function (hooks, initial) {
initial = initial || [];
_.each(hooks, function (hook) {
var result = hook(this);
if (Array.isArray(result)) {
result.forEach(function (res) {
if (_.isFunction(res)) {
initial.push(res);
}
});
} else {
if (_.isFunction(result)) {
initial.push(result);
}
}
}, this);
return initial;
},
/**
* Allow plugins to have their own watchers
* @param hooks
* @param bs
* @param obj
* @returns {{core: *}}
*/
"files:watch": function (hooks, bs, obj) {
var added = false;
var namespaces = {};
if (Array.isArray(obj)) {
if (obj.length) {
namespaces["core"] = obj;
if (obj.length === 1) {
added = true;
}
}
}
if (!added && Object.keys(obj).length) {
_.each(obj, function (val, key) {
namespaces[key] = val;
});
}
if (bs.pluginManager.pluginOptions) {
_.each(bs.pluginManager.pluginOptions, function (value, key) {
if (value && value.files) {
namespaces[key] = value.files;
}
}, this);
}
return namespaces;
}
};

194
node_modules/browser-sync/lib/logger.js generated vendored Normal file
View file

@ -0,0 +1,194 @@
"use strict";
var messages = require("./messages");
var utils = require("./utils");
var _ = require("lodash");
var template = "[{blue:%s}] ";
var logger = require("eazy-logger").Logger({
prefix: template.replace("%s", "BS"),
useLevelPrefixes: false
});
module.exports.logger = logger;
/**
* @param name
* @returns {*}
*/
module.exports.getLogger = function (name) {
return logger.clone(function (config) {
config.prefix = config.prefix + template.replace("%s", name);
return config;
});
};
/**
* Logging Callbacks
*/
module.exports.callbacks = {
/**
* Log when file-watching has started
* @param options
* @param data
*/
"file:watching": function (options, data) {
if (Object.keys(data).length) {
logger.info("Watching files...");
}
},
/**
* Log when a file changes
* @param options
* @param data
*/
"file:reload": function (options, data) {
if (data.log) {
var path = utils.resolveRelativeFilePath(data.path, data.cwd);
logger.info("{cyan:File changed: {magenta:%s", path);
}
},
/**
*
*/
"service:exit": function () {
logger.debug("Exiting...");
},
/**
*
*/
"browser:reload": function () {
logger.info("{cyan:Reloading Browsers...");
},
/**
* @param options
* @param data
*/
"config:error": function (options, data) {
logger.setOnce("useLevelPrefixes", true).error(data.msg);
},
/**
* @param options
* @param data
*/
"config:warn": function (options, data) {
logger.setOnce("useLevelPrefixes", true).warn(data.msg);
},
/**
* @param options
* @param data
*/
"stream:changed": function (options, data) {
var changed = data.changed;
logger.info("{cyan:%s %s changed} ({magenta:%s})",
changed.length,
changed.length > 1 ? "files" : "file",
changed.join(", ")
);
},
/**
* Client connected logging
* @param options
* @param data
*/
"client:connected": function (options, data) {
var uaString = utils.getUaString(data.ua);
var msg = "{cyan:Browser Connected: {magenta:%s, version: %s}";
var method = "info";
if (!options.logConnections) {
method = "debug";
}
logger.log(method, msg,
uaString.name,
uaString.version
);
},
/**
* Main logging when the service is running
* @param options
* @param data
*/
"service:running": function (options, data) {
var type = data.type;
var baseDir = options.server.baseDir;
var proxy = options.proxy;
if (type === "server") {
logUrls(options.urls);
if (baseDir) {
if (Array.isArray(baseDir)) {
_.each(baseDir, serveFiles);
} else {
serveFiles(baseDir);
}
}
}
if (type === "proxy") {
logger.info("Proxying: {cyan:%s}", proxy.target);
logger.info("Now you can access your site through the following addresses:");
logUrls(options.urls);
}
if (type === "snippet" && options.logSnippet) {
logger.info(
"Copy the following snippet into your website, " +
"just before the closing {cyan:</body>} tag"
);
logger.unprefixed("info",
messages.scriptTags(options.port, options)
);
}
function serveFiles (base) {
logger.info("Serving files from: {magenta:%s}", base);
}
function logUrls (urls) {
_.each(urls, function (value, key) {
logger.info("%s URL: {magenta:%s}",
utils.ucfirst(key),
value);
});
}
}
};
/**
* Plugin interface - only to be called once to register all events
*/
module.exports.plugin = function (emitter, options) {
// Should set logger level here!
if (options.logLevel === "silent") {
logger.mute(true);
} else {
logger.setLevel(options.logLevel);
}
if (options.logPrefix) {
if (_.isFunction(options.logPrefix)) {
logger.setPrefix(options.logPrefix);
} else {
logger.setPrefix(template.replace("%s", options.logPrefix));
}
}
_.each(exports.callbacks, function (func, event) {
emitter.on(event, func.bind(this, options));
});
return logger;
};

99
node_modules/browser-sync/lib/messages.js generated vendored Normal file
View file

@ -0,0 +1,99 @@
"use strict";
var objectPath = require("object-path");
var _ = require("lodash");
var fs = require("fs");
var config = require("./config");
var messages = {
/**
* @param {Number} port
* @param {Object} options
* @returns {String}
*/
scriptTags: function (port, options) {
function getPath(relative, port) {
return "//HOST:" + port + relative;
}
var template = fs.readFileSync(config.templates.scriptTag, "utf-8");
var scriptPath = this.clientScript(options);
var script;
var override = false;
if (options.scriptPath && _.isFunction(options.scriptPath)) {
script = options.scriptPath(scriptPath, port, options);
override = true;
} else {
script = getPath(scriptPath, port);
}
if (!override && (options.server || options.proxy)) {
script = scriptPath;
}
template = template
.replace("%script%", script);
return template;
},
/**
* @param {String|Number} port
* @param {Object} options
* @returns {String}
*/
socketConnector: function (port, options, external) {
var path = objectPath.get(options, "socket.path");
var namespace = objectPath.get(options, "socket.namespace");
var override = false;
var withPort = "location.hostname + ':%port+ns%'".replace("%port+ns%", port + namespace);
if (_.isFunction(namespace)) {
namespace = "'" + namespace(path, port, options) + "'";
override = true;
}
if (!override) {
// Ensure snippet mode always has PORT
if (!options.server && !options.proxy || external) {
namespace = withPort;
} else {
namespace = "'%ns'".replace("%ns", namespace);
}
}
var template = fs.readFileSync(config.templates.connector, "utf-8");
template = template
.replace("%path%", path)
.replace("%url%", namespace);
return template;
},
/**
* @param {Object} [options]
* @param {Boolean} [both]
*/
clientScript: function (options, both) {
var prefix = options.socket && options.socket.clientPath || "/browser-sync";
var script = prefix + "/browser-sync-client.js";
var template = prefix + "/browser-sync-client.%s.js";
var compiled = template.replace("%s", options.version);
if (both) {
return {
path: script,
versioned: compiled
};
}
return compiled;
}
};
module.exports = messages;

20
node_modules/browser-sync/lib/public/exit.js generated vendored Normal file
View file

@ -0,0 +1,20 @@
"use strict";
/**
* @param {BrowserSync} browserSync
* @returns {Function}
*/
module.exports = function (browserSync) {
function exit() {
if (browserSync.active) {
browserSync.events.emit("service:exit");
browserSync.cleanup();
}
process.exit();
}
process.on("SIGINT", exit);
return exit;
};

28
node_modules/browser-sync/lib/public/init.js generated vendored Normal file
View file

@ -0,0 +1,28 @@
"use strict";
var defaultConfig = require("../default-config");
var cliOptions = require("../cli/cli-options");
var merger = require("opt-merger");
/**
* @param {BrowserSync} browserSync
* @param {Object} pjson
* @returns {Function}
*/
module.exports = function (browserSync, pjson) {
return function () {
var args = Array.prototype.slice.call(arguments);
args = require("../args")(args);
var config = merger.set({ignoreCli: true}).merge(defaultConfig, args.config || {}, cliOptions.callbacks);
if (!config.server && !config.proxy) {
config.open = false;
}
return browserSync.init(config.files || [], config, pjson.version, args.cb);
};
};

18
node_modules/browser-sync/lib/public/notify.js generated vendored Normal file
View file

@ -0,0 +1,18 @@
"use strict";
/**
* @param {BrowserSync} browserSync
* @returns {Function}
*/
module.exports = function (browserSync) {
return function (msg, timeout) {
if (msg) {
browserSync.events.emit("browser:notify", {
message: msg,
timeout: timeout || 2000
});
}
};
};

98
node_modules/browser-sync/lib/public/reload.js generated vendored Normal file
View file

@ -0,0 +1,98 @@
"use strict";
var path = require("path");
var utils = require("../utils");
var defaultConfig = require("../default-config");
/**
* @param {BrowserSync} browserSync
* @returns {Function}
*/
module.exports = function (browserSync) {
var events = browserSync.events;
function emitReload(path, log) {
events.emit("file:changed", {
path: path,
log: log,
namespace: "core"
});
}
function emitBrowserReload() {
events.emit("browser:reload");
}
function emitInfo(changed) {
events.emit("stream:changed", {changed: changed});
}
return function (arg) {
if (typeof arg === "string") {
return emitReload(arg, true);
}
if (Array.isArray(arg)) {
if (utils.willCauseReload(arg, defaultConfig.injectFileTypes)) {
return emitBrowserReload();
}
return arg.forEach(function (filepath) {
emitReload(filepath, true);
});
}
if (arg && arg.stream === true) {
// Handle Streams here...
var emitted = false;
var once = arg.once || false;
var Transform = require("stream").Transform;
var reload = new Transform({objectMode:true});
var changed = [];
reload._transform = function (file, encoding, next) {
if (once === true && !emitted) {
emitBrowserReload();
emitted = true;
} else { // handle multiple
if (once === true && emitted) {
} else {
if (file.path) {
emitted = true;
emitReload(file.path, false);
changed.push(path.basename(file.path));
}
}
}
this.push(file); // always send the file down-stream
next();
};
reload._flush = function (next) {
emitInfo(changed);
next();
};
return reload;
}
return emitBrowserReload();
};
};

3
node_modules/browser-sync/lib/public/socket.io.js generated vendored Normal file

File diff suppressed because one or more lines are too long

18
node_modules/browser-sync/lib/server/certs/server.crt generated vendored Normal file
View file

@ -0,0 +1,18 @@
-----BEGIN CERTIFICATE-----
MIIC7zCCAligAwIBAgIJAOku4vmM434TMA0GCSqGSIb3DQEBBQUAMFkxCzAJBgNV
BAYTAkdCMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
aWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMTCWxvY2FsaG9zdDAeFw0xNDA3MDgyMDE3
NDZaFw0xNTA3MDgyMDE3NDZaMFkxCzAJBgNVBAYTAkdCMRMwEQYDVQQIEwpTb21l
LVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNV
BAMTCWxvY2FsaG9zdDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAuCoY7Qeo
NtkrLHcXtqIUzfyJIiVthoxtjq58pIFv6es8XWS+gTEUy496TLcuLuAzdRykrPVX
F/UyLPHOfX4AR4LQyopw08vyKoLFLYXq70qH1wcJHe/6a+qjTfVMR6uGNfFGa7Id
ZRVtJUD/mBmR6FQ04YJHiTt2vb30DMWtyW8CAwEAAaOBvjCBuzAdBgNVHQ4EFgQU
5rLnWXk1j1xVQi3iIs+Z7xfuQPcwgYsGA1UdIwSBgzCBgIAU5rLnWXk1j1xVQi3i
Is+Z7xfuQPehXaRbMFkxCzAJBgNVBAYTAkdCMRMwEQYDVQQIEwpTb21lLVN0YXRl
MSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxEjAQBgNVBAMTCWxv
Y2FsaG9zdIIJAOku4vmM434TMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQAD
gYEAOBOI+IWCzL5MB+0AxB6lQz1wa41aQQKkqSN8FrSJ+45yQADEW3IqieTOXgdD
R5/w+EAD+L9BSq9RiVCXq6ACmnBnQUMld3clCEKQfv1T5r4KzvpZF7KDuspVLidu
CUpLCuc3+x0bm45z/cmg2Iy6eYjDLBQksrDTrgXdWU/4X1U=
-----END CERTIFICATE-----

15
node_modules/browser-sync/lib/server/certs/server.key generated vendored Normal file
View file

@ -0,0 +1,15 @@
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQC4KhjtB6g22Sssdxe2ohTN/IkiJW2GjG2OrnykgW/p6zxdZL6B
MRTLj3pMty4u4DN1HKSs9VcX9TIs8c59fgBHgtDKinDTy/IqgsUthervSofXBwkd
7/pr6qNN9UxHq4Y18UZrsh1lFW0lQP+YGZHoVDThgkeJO3a9vfQMxa3JbwIDAQAB
AoGAOaeMOCBujAU+2+PIu7dQNhB6SgNXn4i0/7cmdEXFaIDpW/+fGEjqTrPzQLMU
NT6hPWejMjZ4dpqfg6yLzYO1yCTigBZv1n2BzJ2qxb4gILIO2olAI0rb5QOWW07a
2BOgeA/ovwYuUMSIs+Oxaz128vSJjrtBUDVn1U8iHZMYTxkCQQDucj+Bd0xovNap
Ut1emL/uQfHEbheLDO2tY8W1cxdX2Ppu4SmU+Z2u9826DdGCrYQhSHnP+DTVHTjj
SQTE8hLLAkEAxbja9DaRyhgENmLixwi7gUMH4kI6hm1msDLIFNljpzs+BmwCZ6Nv
uRc4Gpx+Px+UR+3ZXlYGODUgMu2m7PU7bQJBAJQjjqjUgTgg+gxAWx/GLpfLiHTN
IPtWkONENTTByCLfvtbcNIVFf12QvtN0elGBk7FJ4cP/JHOysAElAD2LV3kCQHXB
NS2SvlsE2KVnWTY+fiVqvWxEE0TyLOEtLTo1igMT5km+0+PTU3uBV5mJsCp57T61
aeqkAwpAoY+TOAIRvzUCQCUC70C+SHT19mS4L093CsDDows0ww7KOG4IY4d2ZpzD
OgjvCBULqwM1rHdl9oRRI/Utp0vc8ynENRTnTrTqSdU=
-----END RSA PRIVATE KEY-----

235
node_modules/browser-sync/lib/server/index.js generated vendored Normal file
View file

@ -0,0 +1,235 @@
"use strict";
var messages = require("./../messages");
var snippetUtils = require("./../snippet").utils;
var utils = require("./utils.js");
var mainUtils = require("./../utils");
var connect = require("connect");
var _ = require("lodash");
var http = require("http");
var https = require("https");
var foxy = require("foxy");
var fs = require("fs");
/**
*
*/
module.exports.plugin = function (bs, scripts) {
var options = bs.options;
var debug = bs.debug;
var proxy = options.proxy || false;
var server = options.server || false;
var snippet = (!server && !proxy);
var baseDir = mainUtils.getBaseDir(server.baseDir || "./");
var type = "snippet";
var events = bs.events;
if (options.server) {
options.server.middleware = bs.pluginManager.hook("server:middleware", server.middleware || null);
}
var bsServer = exports.createServer(options, scripts, bs);
if (server || snippet) {
debug("Static Server running ({magenta:%s}) ...", options.https ? "https" : "http");
type = server ? "server" : "snippet";
}
if (proxy) {
debug("Proxy running, proxing: {magenta:%s}", options.proxy.target);
type = "proxy";
}
if (bsServer) {
bs.server = bsServer.listen(options.port);
}
debug("Running mode: %s", type.toUpperCase());
if (type && (server || proxy)) {
if (options.tunnel && options.online) {
try {
var tunnel = bs.pluginManager.get("tunnel:runner");
if (tunnel) {
bs.pluginManager.get("tunnel")(bs, tunnel(), finished);
}
} catch (e) {
console.log("ERRRRRRRRRRRRR: " + e);
}
} else {
finished(options.urls.local);
}
} else {
finished("n/a");
}
function finished (url, tunnel) {
if (tunnel) {
bs.options.urls.tunnel = url;
}
events.emit("service:running", {
type: type,
options: bs.options,
baseDir: baseDir || null,
port: options.port,
url: url,
tunnel: tunnel ? url : false
});
}
return bsServer;
};
/**
* Launch the server for serving the client JS plus static files
* @param {Object} options
* @param {String} scripts
* @param {BrowserSync} bs
* @returns {{staticServer: (http.Server), proxyServer: (http.Server)}}
*/
module.exports.createServer = function (options, scripts, bs) {
var proxy = options.proxy || false;
var server = options.server || false;
options.snippet = messages.scriptTags(options.port, options);
options.scriptPaths = messages.clientScript(options, true);
if (!proxy && !server) {
return createSnippetServer(options, scripts, bs);
}
if (options.proxy) {
return exports.createProxy(options, scripts, bs);
}
if (options.server) {
return createServer(options, scripts, bs);
}
};
/**
* @param options
* @param scripts
* @param context
* @returns {*}
*/
function createServer (options, scripts, context) {
var server = options.server;
var middleware = server.middleware;
var secure = (options.https !== undefined && options.https !== false);
var secureKey, secureCert;
var index, app;
index = server.index || "index.html";
app = context.app = connect();
context.connect = connect;
utils.addMiddleware(app, middleware);
app.use(function (req, res, next) {
snippetUtils.isOldIe(req);
return next();
})
.use(options.scriptPaths.versioned, scripts)
.use(options.scriptPaths.path, scripts);
if (server.directory) {
utils.addDirectory(app, server.baseDir);
}
app.use(snippetUtils.getSnippetMiddleware(options.snippet, options.snippetOptions));
utils.addBaseDir(app, server.baseDir, index);
if (server.routes) {
utils.addRoutes(app, server.routes);
}
if (secure) {
secureKey = fs.readFileSync(secure.key || __dirname + "/certs/server.key");
secureCert = fs.readFileSync(secure.cert || __dirname + "/certs/server.crt");
return https.createServer({key: secureKey, cert: secureCert}, app);
} else {
return http.createServer(app);
}
}
/**
* @param options
* @param scripts
* @param context
* @returns {*}
*/
function createSnippetServer (options, scripts, context) {
var app = context.app = connect();
context.connect = connect;
app.use(options.scriptPaths.versioned, scripts)
.use(options.scriptPaths.path, scripts);
return http.createServer(app);
}
/**
* @param options
* @param scripts
* @returns {*}
* @param {BrowserSync} bs
*/
module.exports.createProxy = function (options, scripts, bs) {
exports.checkProxyTarget(options.proxy, function (err) {
if (err) {
bs.events.emit("config:warn", {msg: err});
}
});
return foxy(options.proxy.target, {
rules: snippetUtils.getRegex(options.snippet, options.snippetOptions),
ignorePaths: options.snippetOptions.ignorePaths,
middleware: snippetUtils.getProxyMiddleware(scripts, options.scriptPaths.versioned),
errHandler: function () {}
}
);
};
/**
* @param {Object} proxy
* @param {Function} cb
*/
module.exports.checkProxyTarget = function (proxy, cb) {
var chunks = [];
var errored = false;
function logError() {
if (!errored) {
cb("Proxy address not reachable - is your server running?");
errored = true;
}
}
require("http").get(proxy.target, function (res) {
res.on("data", function (data) {
chunks.push(data);
});
}).on("error", function (err) {
if (_.contains(["ENOTFOUND", "ECONNREFUSED"], err.code)) {
logError();
}
}).on("close", function () {
if (!chunks.length) {
logError();
}
});
};

134
node_modules/browser-sync/lib/server/utils.js generated vendored Normal file
View file

@ -0,0 +1,134 @@
"use strict";
var filePath = require("path");
var serveIndex = require("serve-index");
var serveStatic = require("serve-static");
var _ = require("lodash");
var snippetUtils = require("./../snippet").utils;
module.exports = {
/**
* The middleware that can emit location change events.
* @param {Object} io
* @param {Object} options
* @returns {Function}
*/
navigateCallback: function (io, options) {
var disabled = false;
var navigating = false;
var canNavigate = this.canNavigate;
return function (req, res, next) {
if (canNavigate(req, options, io)) {
var clients = io.sockets.clients();
if (clients.length && !disabled && !navigating) {
navigating = true;
disabled = true;
io.sockets.emit("location", {
url: req.url
});
var timer = setTimeout(function () {
disabled = false;
navigating = false;
clearInterval(timer);
}, 300);
}
}
if (typeof next === "function") {
next();
}
};
},
/**
* All the conditions that determine if we should emit
* a location:change event
* @param {Object} req
* @param {Object} options
* @returns {Boolean}
*/
canNavigate: function (req, options) {
var headers = req.headers || {};
if (req.method !== "GET") {
return false;
}
if (headers["x-requested-with"] !== undefined && headers["x-requested-with"] === "XMLHttpRequest") {
return false;
}
if (!options || !options.ghostMode || !options.ghostMode.location) {
return false;
}
if (snippetUtils.isExcluded(req.url, options.excludedFileTypes)) {
return false;
}
return true;
},
/**
* @param app
* @param middleware
* @returns {*}
*/
addMiddleware: function (app, middleware) {
if (Array.isArray(middleware)) {
middleware.forEach(function (item) {
app.use(item);
});
} else if (typeof middleware === "function") {
app.use(middleware);
}
return app;
},
/**
* @param app
* @param base
* @param index
*/
addBaseDir: function (app, base, index) {
if (Array.isArray(base)) {
base.forEach(function (item) {
app.use(serveStatic(filePath.resolve(item), {index: index}));
});
} else {
if ("string" === typeof base) {
app.use(serveStatic(filePath.resolve(base), {index: index}));
}
}
},
/**
* @param app
* @param base
*/
addDirectory: function (app, base) {
if (Array.isArray(base)) {
base = base[0];
}
app.use(serveIndex(filePath.resolve(base), {icons:true}));
},
/**
* @param app
* @param {Object} routes
*/
addRoutes: function (app, routes) {
Object.keys(routes).forEach(function (key) {
if (_.isString(key) && _.isString(routes[key])) {
app.use(key, serveStatic(filePath.resolve(routes[key])));
}
});
}
};

59
node_modules/browser-sync/lib/services.js generated vendored Normal file
View file

@ -0,0 +1,59 @@
"use strict";
var utils = require("./utils");
/**
* @param context
* @returns {function(this:*)}
*/
module.exports.init = function (context) {
/**
* @this {BrowserSync}
*/
return function (options) {
this.options = options;
// register internal events
this.registerInternalEvents(options);
// Set global URL options
options.urls = utils.setUrlOptions(options.port, options);
var files = this.pluginManager.hook("files:watch", this, options.files);
// Start file watcher
this.watchers = this.pluginManager.get("file:watcher")(files, options, this.events);
// Get the Client JS + any user-defined
var clientJs = this.clientJs = this.pluginManager.hook("client:js", {
port: options.port,
options: options
});
// Start the server
var server = this.server = this.pluginManager.get("server")(
this,
this.pluginManager.get("client:script")(options, clientJs, options.proxy ? "file" : "middleware")
);
this.clientEvents = this.pluginManager.hook("client:events", this.clientEvents);
// Start the socket, needs an existing server.
this.io = this.pluginManager.get("socket")(
server,
this.clientEvents,
this
);
this.events.emit("init", this);
this.pluginManager.initUserPlugins(this);
this.options.userPlugins = this.getUserPlugins();
this.callback(null, this);
}.bind(context);
};

115
node_modules/browser-sync/lib/snippet.js generated vendored Normal file
View file

@ -0,0 +1,115 @@
"use strict";
var messages = require("./messages");
var config = require("./config");
var lrSnippet = require("resp-modifier");
var path = require("path");
var _ = require("lodash");
var fs = require("fs");
/**
* Utils for snippet injection
*/
var utils = {
/**
* @param {String} url
* @param {Array} excludeList
* @returns {boolean}
*/
isExcluded: function (url, excludeList) {
var extension = path.extname(url);
if (extension) {
if (~url.indexOf("?")) {
return true;
}
extension = extension.slice(1);
return _.contains(excludeList, extension);
}
return false;
},
/**
* @param {String} snippet
* @param {Object} options
* @returns {{match: RegExp, fn: Function}}
*/
getRegex: function (snippet, options) {
var fn = options.rule.fn.bind(null, snippet);
return {
match: options.rule.match,
fn: fn
};
},
/**
* @param {String} snippet
* @param {Object} [options]
* @returns {Function}
*/
getSnippetMiddleware: function (snippet, options) {
options = options || {};
return lrSnippet({
rules: [utils.getRegex(snippet, options)],
ignorePaths: options.ignorePaths
});
},
/**
* @param {String} scripts - the client side JS
* @param {String} scriptPath - the URL to match
* @returns {Function}
*/
getProxyMiddleware: function (scripts, scriptPath) {
return function (req, res, next) {
if (req.url.indexOf(scriptPath) > -1) {
res.writeHead(200, {"Content-Type": "text/javascript"});
res.write(scripts);
res.end();
return next(true);
} else {
return next(false);
}
};
},
/**
* @param {Object} req
* @param {Array} [excludeList]
* @returns {Object}
*/
isOldIe: function (req, excludeList) {
var ua = req.headers["user-agent"];
var match = /MSIE (\d)\.\d/.exec(ua);
if (match) {
if (parseInt(match[1], 10) < 9) {
if (!utils.isExcluded(req.url, excludeList)) {
req.headers["accept"] = "text/html";
}
}
}
return req;
},
getNoConflictJs: function () {
return "window.___browserSync___oldSocketIo = window.io;";
},
/**
* @param {Number} port
* @param {BrowserSync.options} options
* @returns {String}
*/
getClientJs: function (port, options) {
var socket = utils.getSocketScript();
return utils.getNoConflictJs() + socket + ";" + messages.socketConnector(port, options);
},
/**
* @returns {String}
*/
getSocketScript: function () {
return fs.readFileSync(path.resolve(__dirname + config.socketIoScript), "utf-8");
}
};
module.exports.utils = utils;

81
node_modules/browser-sync/lib/sockets.js generated vendored Normal file
View file

@ -0,0 +1,81 @@
"use strict";
var socket = require("socket.io");
var Steward = require("emitter-steward");
/**
* Plugin interface
* @returns {*|function(this:exports)}
*/
module.exports.plugin = function (server, clientEvents, bs) {
return exports.init(server, clientEvents, bs);
};
/**
* @param {http.Server} server
* @param clientEvents
* @param {BrowserSync} bs
*/
module.exports.init = function (server, clientEvents, bs) {
var emitter = bs.events;
var io = socket.listen(server, {log: false, path: bs.getOption("socket.path")});
// Override default namespace.
io.sockets = io.of(bs.getOption("socket.namespace", "/browser-sync"));
var steward = new Steward(emitter);
/**
* Listen for new connections
*/
io.sockets.on("connection", handleConnection);
/**
* Handle each new connection
* @param {Object} client
*/
function handleConnection (client) {
// set ghostmode callbacks
if (bs.getOption("ghostMode")) {
addGhostMode(client);
}
client.emit("connection", bs.getOptions());
emitter.emit("client:connected", {
ua: client.handshake.headers["user-agent"]
});
}
/**
* @param {string} event
* @param {Socket.client} client
* @param {Object} data
*/
function handleClientEvent(event, client, data) {
if (steward.valid(client.id)) {
client.broadcast.emit(event, data);
}
}
/**
* @param client
*/
function addGhostMode (client) {
clientEvents.forEach(addEvent);
function addEvent(event) {
client.on(event, handleClientEvent.bind(null, event, client));
}
}
return io;
};

View file

@ -0,0 +1,6 @@
window.___browserSync___ = {};
___browserSync___.io = window.io;
window.io = window.___browserSync___oldSocketIo;
window.___browserSync___oldSocketIo=undefined;
___browserSync___.socketConfig = {}; ___browserSync___.socketConfig.path = '%path%';
___browserSync___.socket = ___browserSync___.io(%url%, ___browserSync___.socketConfig);

View file

@ -0,0 +1,3 @@
<script type='text/javascript' id="__bs_script__">//<![CDATA[
document.write("<script async src='%script%'><\/script>".replace(/HOST/g, location.hostname).replace(/PORT/g, location.port));
//]]></script>

30
node_modules/browser-sync/lib/tunnel.js generated vendored Normal file
View file

@ -0,0 +1,30 @@
"use strict";
var _ = require("lodash");
/**
* @param {BrowserSync} bs
* @param {Function} tunnelRunner
* @param {Function} cb
*/
module.exports.plugin = function (bs, tunnelRunner, cb) {
var opts = {};
var options = bs.options;
var port = bs.options.port;
//var debug = bs.debug;
if (_.isString(options.tunnel)) {
opts.subdomain = options.tunnel;
}
//debug("Trying tunnel connection with: %s ", options.tunnel || "no subdomain specified");
tunnelRunner(port, opts, function (err, tunnel) {
if (err) {
throw err;
}
cb(tunnel.url, true);
});
};

271
node_modules/browser-sync/lib/utils.js generated vendored Normal file
View file

@ -0,0 +1,271 @@
"use strict";
var devIp = require("dev-ip");
var open = require("opn");
var filePath = require("path");
var portScanner = require("portscanner-plus");
var _ = require("lodash");
var UAParser = require("ua-parser-js");
var parser = new UAParser();
var utils = {
/**
* @param {Object} options
* @returns {String|boolean} - the IP address
*/
getHostIp: function (options) {
var returnValue = devIp.getIp(null);
if (options) {
if (options.host && options.host !== "localhost") {
return options.host;
}
if (options.detect === false || !devIp) {
return false;
}
}
if (Array.isArray(returnValue)) {
returnValue = returnValue[0];
}
return returnValue || false;
},
/**
* Take the path provided in options & transform into CWD for serving files
* @param {String} [baseDir]
* @returns {String}
*/
getBaseDir: function (baseDir) {
if (Array.isArray(baseDir)) {
return baseDir;
}
var suffix = "";
var validRoots = ["./", "/", "."];
if (!baseDir || _.contains(validRoots, baseDir)) {
return process.cwd();
}
if (baseDir.charAt(0) === "/") {
suffix = baseDir;
} else {
if (/^.\//.test(baseDir)) {
suffix = baseDir.replace(".", "");
} else {
suffix = "/" + baseDir;
}
}
return process.cwd() + suffix;
},
/**
* Set URL Options
*/
setUrlOptions: function (port, options) {
var urls = {};
var scheme = (options.https && !options.proxy && !options.tunnel) ? "https" : "http";
if (!options.online) {
urls.local = utils.getUrl(scheme + "://localhost:" + port, options);
return urls;
}
var external = utils.xip(utils.getHostIp(options), options);
var localhost = "localhost";
if (options.xip) {
localhost = "127.0.0.1";
}
var local = utils.xip(localhost, options);
options.external = options.host = external;
return utils.getUrls(external, local, scheme, port, options);
},
/**
* Append a start path if given in options
* @param {String} url
* @param {Object} options
* @returns {String}
*/
getUrl: function (url, options) {
var prefix = "/";
var startPath = options.startPath;
if (options.proxy && options.proxy.startPath) {
startPath = options.proxy.startPath;
}
if (startPath) {
if (startPath.charAt(0) === "/") {
prefix = "";
}
url = url + prefix + startPath;
}
return url;
},
/**
* @param {String} external
* @param {String} local
* @param {String} scheme
* @param {number|string} port
* @param {Object} options
* @returns {{local: string, external: string}}
*/
getUrls: function (external, local, scheme, port, options) {
var urls = {
local: utils.getUrl(utils._makeUrl(scheme, local, port), options)
};
if (external !== local) {
urls.external = utils.getUrl(utils._makeUrl(scheme, external, port), options);
}
return urls;
},
/**
* @param {String} scheme
* @param {String} host
* @param {Number} port
* @returns {String}
* @private
*/
_makeUrl: function (scheme, host, port) {
return scheme + "://" + host + ":" + port;
},
/**
* Get ports
* @param {Object} options
* @returns {Q.promise}
*/
getPorts: function (options) {
var port = options.port;
var ports = options.ports; // backwards compatibility
var max;
if (ports) {
port = ports.min;
max = ports.max;
}
return portScanner.getPorts(1, port, max);
},
/**
* @param {String} ua
* @returns {Object}
*/
getUaString: function (ua) {
return parser.setUA(ua).getBrowser();
},
/**
* @param {String} filepath
* @param {String} cwd
* @returns {String}
*/
resolveRelativeFilePath: function (filepath, cwd) {
return filepath.replace(cwd + "/", "");
},
/**
* @param {String} path
* @returns {String}
*/
getFileExtension: function (path) {
return filePath.extname(path).replace(".", "");
},
/**
* Open the page in browser
* @param {String} url
* @param {Object} options
*/
openBrowser: function (url, options) {
if (_.isString(options.open)) {
if (options.urls[options.open]) {
url = options.urls[options.open];
}
}
if (options.open) {
if (options.browser !== "default") {
if (Array.isArray(options.browser)) {
options.browser.forEach(function (browser) {
utils.open(url, browser);
});
} else {
utils.open(url, options.browser); // single
}
} else {
utils.open(url);
}
}
},
/**
* Wrapper for open module - for easier stubbin'
* @param url
* @param name
*/
open: function (url, name) {
open(url, name || null);
},
/**
* @param {Boolean} kill
* @param err
* @param cb
*/
fail: function (kill, err, cb) {
if (kill) {
if (cb && _.isFunction(cb)) {
cb(err);
}
process.exit(1);
}
},
/**
* Add support for xip.io urls
* @param {String} host
* @param {Object} options
* @returns {String}
*/
xip: function (host, options) {
if (options.xip) {
return host + ".xip.io";
}
if (options.hostnameSuffix) {
return host + options.hostnameSuffix;
}
return host;
},
/**
* @param {String} string
* @returns {string}
*/
ucfirst: function (string) {
return string.charAt(0).toUpperCase() + string.slice(1);
},
/**
* Determine if an array of file paths will cause a full page reload.
* @param {Array} needles - filepath such as ["core.css", "index.html"]
* @param {Array} haystack
* @returns {Boolean}
*/
willCauseReload: function (needles, haystack) {
return needles.some(function (needle) {
return !_.contains(haystack, filePath.extname(needle).replace(".", ""));
});
}
};
module.exports = utils;

1
node_modules/browser-sync/node_modules/.bin/dev-ip generated vendored Symbolic link
View file

@ -0,0 +1 @@
../dev-ip/lib/dev-ip.js

1
node_modules/browser-sync/node_modules/.bin/lt generated vendored Symbolic link
View file

@ -0,0 +1 @@
../localtunnel/bin/client

1
node_modules/browser-sync/node_modules/.bin/opn generated vendored Symbolic link
View file

@ -0,0 +1 @@
../opn/cli.js

View file

@ -0,0 +1 @@
browser-sync-client

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="chai-DefinitelyTyped" level="application" />
<orderEntry type="library" name="lodash-DefinitelyTyped" level="application" />
<orderEntry type="library" name="mocha-DefinitelyTyped" level="application" />
<orderEntry type="library" name="sinon-chai-DefinitelyTyped" level="application" />
<orderEntry type="library" name="browser-sync-client node_modules" level="project" />
<orderEntry type="library" name="browserify-DefinitelyTyped" level="application" />
<orderEntry type="library" name="Node.js v0.10.26 Core Modules" level="application" />
<orderEntry type="library" name="sass-stdlib" level="application" />
</component>
</module>

View file

@ -0,0 +1,10 @@
<component name="ProjectDictionaryState">
<dictionary name="shakyshane">
<words>
<w>browserify</w>
<w>fucntion</w>
<w>minified</w>
<w>minify</w>
</words>
</dictionary>
</component>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>

View file

@ -0,0 +1,7 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0" is_locked="false">
<option name="myName" value="Project Default" />
<option name="myLocal" value="false" />
<inspection_tool class="JSValidateTypes" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
</profile>
</component>

View file

@ -0,0 +1,7 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Project Default" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
</settings>
</component>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptLibraryMappings">
<file url="file://$PROJECT_DIR$" libraries="{browser-sync-client node_modules}" />
<includedPredefinedLibrary name="Node.js Globals" />
</component>
</project>

View file

@ -0,0 +1,14 @@
<component name="libraryTable">
<library name="browser-sync-client node_modules" type="javaScript">
<properties>
<option name="frameworkName" value="node_modules" />
<sourceFilesUrls>
<item url="file://$PROJECT_DIR$/node_modules" />
</sourceFilesUrls>
</properties>
<CLASSES>
<root url="file://$PROJECT_DIR$/node_modules" />
</CLASSES>
<SOURCES />
</library>
</component>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" />
</project>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/browser-sync-client.iml" filepath="$PROJECT_DIR$/.idea/browser-sync-client.iml" />
</modules>
</component>
</project>

View file

@ -0,0 +1,5 @@
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1 @@
test/

View file

@ -0,0 +1,7 @@
language: node_js
node_js:
- '0.10'
before_script:
- "npm install -g gulp"
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"

View file

@ -0,0 +1,22 @@
Copyright (c) 2013 Shane Osbourne
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

View file

@ -0,0 +1,15 @@
# browser-sync-client [![Build Status](https://travis-ci.org/shakyShane/browser-sync-client.png?branch=master)](https://travis-ci.org/shakyShane/browser-sync-client)
Client-side script for BrowserSync
## Contributors
```
68 Shane Osbourne
1 Hugo Dias
1 Sergey Slipchenko
```
## License
Copyright (c) 2014 Shane Osbourne
Licensed under the MIT license.

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

View file

View file

@ -0,0 +1,89 @@
var gulp = require("gulp");
var karma = require('gulp-karma');
var jshint = require('gulp-jshint');
var uglify = require('gulp-uglify');
var contribs = require('gulp-contribs');
var browserify = require('gulp-browserify');
var through2 = require('through2');
var rename = require('gulp-rename');
var testFiles = [
'test/todo.js'
];
gulp.task('test', function() {
// Be sure to return the stream
return gulp.src(testFiles)
.pipe(karma({
configFile: 'test/karma.conf.ci.js',
action: 'run'
}));
});
gulp.task('test:watch', function() {
gulp.src(testFiles)
.pipe(karma({
configFile: 'test/karma.conf.js',
action: 'watch'
}));
});
gulp.task('lint-test', function () {
gulp.src(['test/client-new/*.js', 'test/middleware/*.js'])
.pipe(jshint('test/.jshintrc'))
.pipe(jshint.reporter("default"))
.pipe(jshint.reporter("fail"))
});
gulp.task('lint-lib', function () {
return gulp.src(['lib/*', '!lib/browser-sync-client.js', '!lib/events.js'])
.pipe(jshint('lib/.jshintrc'))
.pipe(jshint.reporter("default"))
.pipe(jshint.reporter("fail"))
});
gulp.task('contribs', function () {
gulp.src('README.md')
.pipe(contribs())
.pipe(gulp.dest("./"))
});
/**
* Strip debug statements
* @returns {*}
*/
var stripDebug = function () {
return through2.obj(function (file, enc, cb) {
var string = file.contents.toString();
var regex = /\/\*\*debug:start\*\*\/[\s\S]*\/\*\*debug:end\*\*\//g;
var stripped = string.replace(regex, "");
file.contents = new Buffer(stripped);
this.push(file);
cb();
});
};
// Basic usage
gulp.task('build-dist', function() {
// Single entry point to browserify
gulp.src('lib/index.js')
.pipe(browserify())
.pipe(gulp.dest('./dist'))
.pipe(stripDebug())
.pipe(uglify())
.pipe(rename("index.min.js"))
.pipe(gulp.dest('./dist'));
});
gulp.task('build-dev', function() {
// Single entry point to browserify
gulp.src('lib/index.js')
.pipe(browserify())
.pipe(gulp.dest('./dist'))
});
gulp.task("dev", ['build-dist'], function () {
gulp.watch(["lib/*.js", "test/client-new/**/*.js"], ['build-dist']);
});
gulp.task('default', ["lint-lib", "lint-test", "build-dist", "test"]);

View file

@ -0,0 +1,30 @@
"use strict";
var fs = require("fs");
var path = require("path");
var script = path.resolve(__dirname + "/dist/index.min.js");
function init(options, connector, type) {
var result;
if (options && options.minify) {
result = fs.readFileSync(script);
} else {
script = path.resolve(__dirname + "/dist/index.js");
result = fs.readFileSync(script);
}
if (type && type === "file") {
return connector + result;
}
return function (req, res) {
res.setHeader("Content-Type", "text/javascript");
res.end(connector + result);
};
}
module.exports.middleware = init;
module.exports.plugin = init;

View file

@ -0,0 +1,19 @@
{
"curly": true,
"eqeqeq": true,
"immed": true,
"latedef": "nofunc",
"newcap": true,
"noarg": true,
"sub": true,
"undef": false,
"unused": false,
"quotmark": "double",
"boss": true,
"eqnull": true,
"node": true,
"globals": {
"window" : false,
"document" : false
}
}

View file

@ -0,0 +1,102 @@
"use strict";
var socket = require("./socket");
var emitter = require("./emitter");
var notify = require("./notify");
var utils = require("./browser.utils");
/**
* @constructor
*/
var BrowserSync = function (options) {
this.options = options;
this.socket = socket;
this.emitter = emitter;
this.utils = utils.utils;
var _this = this;
/**
* Options set
*/
socket.on("options:set", function (data) {
emitter.emit("notify", "Setting options...");
_this.options = data.options;
});
};
/**
* Helper to check if syncing is allowed
* @param data
* @param optPath
* @returns {boolean}
*/
BrowserSync.prototype.canSync = function (data, optPath) {
data = data || {};
var canSync = true;
if (optPath) {
canSync = this.getOption(optPath);
}
return canSync && data.url === window.location.pathname;
};
/**
* Helper to check if syncing is allowed
* @returns {boolean}
*/
BrowserSync.prototype.getOption = function (path) {
if (path && path.match(/\./)) {
return getByPath(this.options, path);
} else {
var opt = this.options[path];
if (isUndefined(opt)) {
return false;
} else {
return opt;
}
}
};
/**
* @type {Function}
*/
module.exports = BrowserSync;
/**
* @param {String} val
* @returns {boolean}
*/
function isUndefined(val) {
return "undefined" === typeof val;
}
/**
* @param obj
* @param path
*/
function getByPath(obj, path) {
for(var i = 0, tempPath = path.split("."), len = tempPath.length; i < len; i++){
if(!obj || typeof obj !== "object") {
return false;
}
obj = obj[tempPath[i]];
}
if(typeof obj === "undefined") {
return false;
}
return obj;
}

View file

@ -0,0 +1,132 @@
"use strict";
/**
* @returns {window}
*/
exports.getWindow = function () {
return window;
};
/**
*
* @returns {HTMLDocument}
*/
exports.getDocument = function () {
return document;
};
/**
* @type {{getScrollPosition: getScrollPosition, getScrollSpace: getScrollSpace}}
*/
exports.utils = {
/**
* Cross-browser scroll position
* @returns {{x: number, y: number}}
*/
getBrowserScrollPosition: function () {
var $window = exports.getWindow();
var $document = exports.getDocument();
var scrollX;
var scrollY;
var dElement = $document.documentElement;
var dBody = $document.body;
if ($window.pageYOffset !== undefined) {
scrollX = $window.pageXOffset;
scrollY = $window.pageYOffset;
} else {
scrollX = dElement.scrollLeft || dBody.scrollLeft || 0;
scrollY = dElement.scrollTop || dBody.scrollTop || 0;
}
return {
x: scrollX,
y: scrollY
};
},
/**
* @returns {{x: number, y: number}}
*/
getScrollSpace: function () {
var $document = exports.getDocument();
var dElement = $document.documentElement;
var dBody = $document.body;
return {
x: dBody.scrollHeight - dElement.clientWidth,
y: dBody.scrollHeight - dElement.clientHeight
};
},
/**
* Saves scroll position into cookies
*/
saveScrollPosition: function () {
var pos = exports.utils.getBrowserScrollPosition();
pos = [pos.x, pos.y];
document.cookie = "bs_scroll_pos=" + pos.join(",");
},
/**
* Restores scroll position from cookies
*/
restoreScrollPosition: function () {
var pos = document.cookie.replace(/(?:(?:^|.*;\s*)bs_scroll_pos\s*\=\s*([^;]*).*$)|^.*$/, "$1").split(",");
window.scrollTo(pos[0], pos[1]);
},
/**
* @param tagName
* @param elem
* @returns {*|number}
*/
getElementIndex: function (tagName, elem) {
var allElems = document.getElementsByTagName(tagName);
return Array.prototype.indexOf.call(allElems, elem);
},
/**
* Force Change event on radio & checkboxes (IE)
*/
forceChange: function (elem) {
elem.blur();
elem.focus();
},
/**
* @param elem
* @returns {{tagName: (elem.tagName|*), index: *}}
*/
getElementData: function (elem) {
var tagName = elem.tagName;
var index = exports.utils.getElementIndex(tagName, elem);
return {
tagName: tagName,
index: index
};
},
/**
* @param {string} tagName
* @param {number} index
*/
getSingleElement: function (tagName, index) {
var elems = document.getElementsByTagName(tagName);
return elems[index];
},
/**
*
*/
getBody: function () {
return document.getElementsByTagName("body")[0];
},
/**
*
*/
reloadBrowser: function () {
exports.getWindow().location.reload(true);
},
getWindow: exports.getWindow,
getDocument: exports.getDocument,
/**
* Are we dealing with old IE?
* @returns {boolean}
*/
isOldIe: function () {
return typeof window.attachEvent !== "undefined";
}
};

View file

@ -0,0 +1,20 @@
if (!("indexOf" in Array.prototype)) {
Array.prototype.indexOf= function(find, i) {
if (i === undefined) {
i = 0;
}
if (i < 0) {
i += this.length;
}
if (i < 0) {
i= 0;
}
for (var n = this.length; i < n; i += 1) {
if (i in this && this[i]===find) {
return i;
}
}
return -1;
};
}

View file

@ -0,0 +1,218 @@
"use strict";
var events = require("./events");
var utils = require("./browser.utils").utils;
var options = {
tagNames: {
"css": "link",
"jpg": "img",
"jpeg": "img",
"png": "img",
"svg": "img",
"gif": "img",
"js": "script"
},
attrs: {
"link": "href",
"img": "src",
"script": "src"
}
};
var hiddenElem;
var OPT_PATH = "codeSync";
var current = function () {
return window.location.pathname;
};
/**
* @param {BrowserSync} bs
*/
exports.init = function (bs) {
exports.saveScroll(utils.getWindow(), utils.getDocument());
bs.socket.on("file:reload", exports.reload(bs));
bs.socket.on("browser:reload", function () {
if (bs.canSync({url: current()}, OPT_PATH)) {
exports.reloadBrowser(true);
}
});
};
/**
* Use a cookie-drop to save scroll position of
* @param $window
* @param $document
*/
exports.saveScroll = function ($window, $document) {
if (!utils.isOldIe()) {
return;
}
if ($document.readyState === "complete") {
utils.restoreScrollPosition();
} else {
events.manager.addEvent($document, "readystatechange", function() {
if ($document.readyState === "complete") {
utils.restoreScrollPosition();
}
});
}
events.manager.addEvent(window, "beforeunload", utils.saveScrollPosition);
};
/**
* @param elem
* @param attr
* @param options
* @returns {{elem: HTMLElement, timeStamp: number}}
*/
exports.swapFile = function (elem, attr, options) {
var currentValue = elem[attr];
var timeStamp = new Date().getTime();
var suffix = "?rel=" + timeStamp;
var justUrl = /^[^\?]+(?=\?)/.exec(currentValue);
if (justUrl) {
currentValue = justUrl[0];
}
if (options) {
if (!options.timestamps) {
suffix = "";
}
}
elem[attr] = currentValue + suffix;
var body = document.body;
setTimeout(function () {
if (!hiddenElem) {
hiddenElem = document.createElement("DIV");
body.appendChild(hiddenElem);
} else {
hiddenElem.style.display = "none";
hiddenElem.style.display = "block";
}
}, 200);
return {
elem: elem,
timeStamp: timeStamp
};
};
/**
* @param {BrowserSync} bs
* @returns {*}
*/
exports.reload = function (bs) {
/**
* @param data - from socket
*/
return function (data) {
if (!bs.canSync({url: current()}, OPT_PATH)) {
return;
}
var transformedElem;
var options = bs.options;
var emitter = bs.emitter;
if (data.url || !options.injectChanges) {
exports.reloadBrowser(true);
}
if (data.assetFileName && data.fileExtension) {
var domData = exports.getElems(data.fileExtension);
var elems = exports.getMatches(domData.elems, data.assetFileName, domData.attr);
if (elems.length && options.notify) {
emitter.emit("notify", {message: "Injected: " + data.assetFileName});
}
for (var i = 0, n = elems.length; i < n; i += 1) {
transformedElem = exports.swapFile(elems[i], domData.attr, options);
}
}
return transformedElem;
};
};
/**
* @param fileExtension
* @returns {*}
*/
exports.getTagName = function (fileExtension) {
return options.tagNames[fileExtension];
};
/**
* @param tagName
* @returns {*}
*/
exports.getAttr = function (tagName) {
return options.attrs[tagName];
};
/**
* @param elems
* @param url
* @param attr
* @returns {Array}
*/
exports.getMatches = function (elems, url, attr) {
var matches = [];
for (var i = 0, len = elems.length; i < len; i += 1) {
if (elems[i][attr].indexOf(url) !== -1) {
matches.push(elems[i]);
}
}
return matches;
};
/**
* @param fileExtension
* @returns {{elems: NodeList, attr: *}}
*/
exports.getElems = function(fileExtension) {
var tagName = exports.getTagName(fileExtension);
var attr = exports.getAttr(tagName);
return {
elems: document.getElementsByTagName(tagName),
attr: attr
};
};
/**
* @returns {window}
*/
exports.getWindow = function () {
return window;
};
/**
* @param confirm
*/
exports.reloadBrowser = function (confirm) {
var $window = exports.getWindow();
if (confirm) {
$window.location.reload(true);
}
};

View file

@ -0,0 +1,33 @@
"use strict";
exports.events = {};
/**
* @param name
* @param data
*/
exports.emit = function (name, data) {
var event = exports.events[name];
var listeners;
if (event && event.listeners) {
listeners = event.listeners;
for (var i = 0, n = listeners.length; i < n; i += 1) {
listeners[i](data);
}
}
};
/**
* @param name
* @param func
*/
exports.on = function (name, func) {
var events = exports.events;
if (!events[name]) {
events[name] = {
listeners: [func]
};
} else {
events[name].listeners.push(func);
}
};

View file

@ -0,0 +1,279 @@
exports._ElementCache = function () {
var cache = {},
guidCounter = 1,
expando = "data" + (new Date).getTime();
this.getData = function (elem) {
var guid = elem[expando];
if (!guid) {
guid = elem[expando] = guidCounter++;
cache[guid] = {};
}
return cache[guid];
};
this.removeData = function (elem) {
var guid = elem[expando];
if (!guid) return;
delete cache[guid];
try {
delete elem[expando];
}
catch (e) {
if (elem.removeAttribute) {
elem.removeAttribute(expando);
}
}
};
};
/**
* Fix an event
* @param event
* @returns {*}
*/
exports._fixEvent = function (event) {
function returnTrue() {
return true;
}
function returnFalse() {
return false;
}
if (!event || !event.stopPropagation) {
var old = event || window.event;
// Clone the old object so that we can modify the values
event = {};
for (var prop in old) {
event[prop] = old[prop];
}
// The event occurred on this element
if (!event.target) {
event.target = event.srcElement || document;
}
// Handle which other element the event is related to
event.relatedTarget = event.fromElement === event.target ?
event.toElement :
event.fromElement;
// Stop the default browser action
event.preventDefault = function () {
event.returnValue = false;
event.isDefaultPrevented = returnTrue;
};
event.isDefaultPrevented = returnFalse;
// Stop the event from bubbling
event.stopPropagation = function () {
event.cancelBubble = true;
event.isPropagationStopped = returnTrue;
};
event.isPropagationStopped = returnFalse;
// Stop the event from bubbling and executing other handlers
event.stopImmediatePropagation = function () {
this.isImmediatePropagationStopped = returnTrue;
this.stopPropagation();
};
event.isImmediatePropagationStopped = returnFalse;
// Handle mouse position
if (event.clientX != null) {
var doc = document.documentElement, body = document.body;
event.pageX = event.clientX +
(doc && doc.scrollLeft || body && body.scrollLeft || 0) -
(doc && doc.clientLeft || body && body.clientLeft || 0);
event.pageY = event.clientY +
(doc && doc.scrollTop || body && body.scrollTop || 0) -
(doc && doc.clientTop || body && body.clientTop || 0);
}
// Handle key presses
event.which = event.charCode || event.keyCode;
// Fix button for mouse clicks:
// 0 == left; 1 == middle; 2 == right
if (event.button != null) {
event.button = (event.button & 1 ? 0 :
(event.button & 4 ? 1 :
(event.button & 2 ? 2 : 0)));
}
}
return event;
};
/**
* @constructor
*/
exports._EventManager = function (cache) {
var nextGuid = 1;
this.addEvent = function (elem, type, fn) {
var data = cache.getData(elem);
if (!data.handlers) data.handlers = {};
if (!data.handlers[type])
data.handlers[type] = [];
if (!fn.guid) fn.guid = nextGuid++;
data.handlers[type].push(fn);
if (!data.dispatcher) {
data.disabled = false;
data.dispatcher = function (event) {
if (data.disabled) return;
event = exports._fixEvent(event);
var handlers = data.handlers[event.type];
if (handlers) {
for (var n = 0; n < handlers.length; n++) {
handlers[n].call(elem, event);
}
}
};
}
if (data.handlers[type].length == 1) {
if (document.addEventListener) {
elem.addEventListener(type, data.dispatcher, false);
}
else if (document.attachEvent) {
elem.attachEvent("on" + type, data.dispatcher);
}
}
};
function tidyUp(elem, type) {
function isEmpty(object) {
for (var prop in object) {
return false;
}
return true;
}
var data = cache.getData(elem);
if (data.handlers[type].length === 0) {
delete data.handlers[type];
if (document.removeEventListener) {
elem.removeEventListener(type, data.dispatcher, false);
}
else if (document.detachEvent) {
elem.detachEvent("on" + type, data.dispatcher);
}
}
if (isEmpty(data.handlers)) {
delete data.handlers;
delete data.dispatcher;
}
if (isEmpty(data)) {
cache.removeData(elem);
}
}
this.removeEvent = function (elem, type, fn) {
var data = cache.getData(elem);
if (!data.handlers) return;
var removeType = function (t) {
data.handlers[t] = [];
tidyUp(elem, t);
};
if (!type) {
for (var t in data.handlers) removeType(t);
return;
}
var handlers = data.handlers[type];
if (!handlers) return;
if (!fn) {
removeType(type);
return;
}
if (fn.guid) {
for (var n = 0; n < handlers.length; n++) {
if (handlers[n].guid === fn.guid) {
handlers.splice(n--, 1);
}
}
}
tidyUp(elem, type);
};
this.proxy = function (context, fn) {
if (!fn.guid) {
fn.guid = nextGuid++;
}
var ret = function () {
return fn.apply(context, arguments);
};
ret.guid = fn.guid;
return ret;
};
};
/**
* Trigger a click on an element
* @param elem
*/
exports.triggerClick = function (elem) {
var evObj;
if (document.createEvent) {
window.setTimeout(function () {
evObj = document.createEvent("MouseEvents");
evObj.initEvent("click", true, true);
elem.dispatchEvent(evObj);
}, 0);
} else {
window.setTimeout(function () {
if (document.createEventObject) {
evObj = document.createEventObject();
evObj.cancelBubble = true;
elem.fireEvent("on" + "click", evObj);
}
}, 0);
}
};
var cache = new exports._ElementCache();
var eventManager = new exports._EventManager(cache);
eventManager.triggerClick = exports.triggerClick;
exports.manager = eventManager;

View file

@ -0,0 +1,65 @@
"use strict";
/**
* This is the plugin for syncing clicks between browsers
* @type {string}
*/
var EVENT_NAME = "click";
var OPT_PATH = "ghostMode.clicks";
exports.canEmitEvents = true;
/**
* @param {BrowserSync} bs
* @param eventManager
*/
exports.init = function (bs, eventManager) {
eventManager.addEvent(document.body, EVENT_NAME, exports.browserEvent(bs));
bs.socket.on(EVENT_NAME, exports.socketEvent(bs, eventManager));
};
/**
* Uses event delegation to determine the clicked element
* @param {BrowserSync} bs
* @returns {Function}
*/
exports.browserEvent = function (bs) {
return function (event) {
if (exports.canEmitEvents) {
var elem = event.target || event.srcElement;
if (elem.type === "checkbox" || elem.type === "radio") {
bs.utils.forceChange(elem);
return;
}
bs.socket.emit(EVENT_NAME, bs.utils.getElementData(elem));
} else {
exports.canEmitEvents = true;
}
};
};
/**
* @param {BrowserSync} bs
* @param {manager} eventManager
* @returns {Function}
*/
exports.socketEvent = function (bs, eventManager) {
return function (data) {
if (bs.canSync(data, OPT_PATH)) {
var elem = bs.utils.getSingleElement(data.tagName, data.index);
if (elem) {
exports.canEmitEvents = false;
eventManager.triggerClick(elem);
}
}
};
};

View file

@ -0,0 +1,67 @@
"use strict";
/**
* This is the plugin for syncing clicks between browsers
* @type {string}
*/
var EVENT_NAME = "input:text";
var OPT_PATH = "ghostMode.forms.inputs";
exports.canEmitEvents = true;
/**
* @param {BrowserSync} bs
* @param eventManager
*/
exports.init = function (bs, eventManager) {
eventManager.addEvent(document.body, "keyup", exports.browserEvent(bs));
bs.socket.on(EVENT_NAME, exports.socketEvent(bs, eventManager));
};
/**
* @param {BrowserSync} bs
* @returns {Function}
*/
exports.browserEvent = function (bs) {
return function (event) {
var elem = event.target || event.srcElement;
var data;
if (exports.canEmitEvents) {
if (elem.tagName === "INPUT" || elem.tagName === "TEXTAREA") {
data = bs.utils.getElementData(elem);
data.value = elem.value;
bs.socket.emit(EVENT_NAME, data);
}
} else {
exports.canEmitEvents = true;
}
};
};
/**
* @param {BrowserSync} bs
* @returns {Function}
*/
exports.socketEvent = function (bs) {
return function (data) {
if (bs.canSync(data, OPT_PATH)) {
var elem = bs.utils.getSingleElement(data.tagName, data.index);
if (elem) {
elem.value = data.value;
return elem;
}
}
return false;
};
};

View file

@ -0,0 +1,35 @@
"use strict";
exports.plugins = {
"inputs": require("./ghostmode.forms.input"),
"toggles": require("./ghostmode.forms.toggles"),
"submit": require("./ghostmode.forms.submit")
};
/**
* Load plugins for enabled options
* @param bs
*/
exports.init = function (bs, eventManager) {
var checkOpt = true;
var options = bs.options.ghostMode.forms;
if (options === true) {
checkOpt = false;
}
function init(name) {
exports.plugins[name].init(bs, eventManager);
}
for (var name in exports.plugins) {
if (!checkOpt) {
init(name);
} else {
if (options[name]) {
init(name);
}
}
}
};

View file

@ -0,0 +1,60 @@
"use strict";
/**
* This is the plugin for syncing clicks between browsers
* @type {string}
*/
var EVENT_NAME = "form:submit";
var OPT_PATH = "ghostMode.forms.submit";
exports.canEmitEvents = true;
/**
* @param {BrowserSync} bs
* @param eventManager
*/
exports.init = function (bs, eventManager) {
var browserEvent = exports.browserEvent(bs);
eventManager.addEvent(document.body, "submit", browserEvent);
eventManager.addEvent(document.body, "reset", browserEvent);
bs.socket.on(EVENT_NAME, exports.socketEvent(bs, eventManager));
};
/**
* @param {BrowserSync} bs
* @returns {Function}
*/
exports.browserEvent = function (bs) {
return function (event) {
if (exports.canEmitEvents) {
var elem = event.target || event.srcElement;
var data = bs.utils.getElementData(elem);
data.type = event.type;
bs.socket.emit(EVENT_NAME, data);
} else {
exports.canEmitEvents = true;
}
};
};
/**
* @param {BrowserSync} bs
* @returns {Function}
*/
exports.socketEvent = function (bs) {
return function (data) {
if (bs.canSync(data, OPT_PATH)) {
var elem = bs.utils.getSingleElement(data.tagName, data.index);
exports.canEmitEvents = false;
if (elem && data.type === "submit") {
elem.submit();
}
if (elem && data.type === "reset") {
elem.reset();
}
return false;
}
return false;
};
};

View file

@ -0,0 +1,96 @@
"use strict";
/**
* This is the plugin for syncing clicks between browsers
* @type {string}
*/
var EVENT_NAME = "input:toggles";
var OPT_PATH = "ghostMode.forms.toggles";
exports.canEmitEvents = true;
/**
* @param {BrowserSync} bs
* @param eventManager
*/
exports.init = function (bs, eventManager) {
var browserEvent = exports.browserEvent(bs);
exports.addEvents(eventManager, browserEvent);
bs.socket.on(EVENT_NAME, exports.socketEvent(bs, eventManager));
};
/**
* @param eventManager
* @param event
*/
exports.addEvents = function (eventManager, event) {
var elems = document.getElementsByTagName("select");
var inputs = document.getElementsByTagName("input");
addEvents(elems);
addEvents(inputs);
function addEvents(domElems) {
for (var i = 0, n = domElems.length; i < n; i += 1) {
eventManager.addEvent(domElems[i], "change", event);
}
}
};
/**
* @param {BrowserSync} bs
* @returns {Function}
*/
exports.browserEvent = function (bs) {
return function (event) {
if (exports.canEmitEvents) {
var elem = event.target || event.srcElement;
var data;
if (elem.type === "radio" || elem.type === "checkbox" || elem.tagName === "SELECT") {
data = bs.utils.getElementData(elem);
data.type = elem.type;
data.value = elem.value;
data.checked = elem.checked;
bs.socket.emit(EVENT_NAME, data);
}
} else {
exports.canEmitEvents = true;
}
};
};
/**
* @param {BrowserSync} bs
* @returns {Function}
*/
exports.socketEvent = function (bs) {
return function (data) {
if (bs.canSync(data, OPT_PATH)) {
exports.canEmitEvents = false;
var elem = bs.utils.getSingleElement(data.tagName, data.index);
if (elem) {
if (data.type === "radio") {
elem.checked = true;
}
if (data.type === "checkbox") {
elem.checked = data.checked;
}
if (data.tagName === "SELECT") {
elem.value = data.value;
}
return elem;
}
return false;
}
return false;
};
};

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