mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
checking in jsdoc dir so people can generate docs themselves
This commit is contained in:
470
jsdoc-master/rhino/MPL_1.1.txt
Normal file
470
jsdoc-master/rhino/MPL_1.1.txt
Normal file
@@ -0,0 +1,470 @@
|
||||
MOZILLA PUBLIC LICENSE
|
||||
Version 1.1
|
||||
|
||||
---------------
|
||||
|
||||
1. Definitions.
|
||||
|
||||
1.0.1. "Commercial Use" means distribution or otherwise making the
|
||||
Covered Code available to a third party.
|
||||
|
||||
1.1. "Contributor" means each entity that creates or contributes to
|
||||
the creation of Modifications.
|
||||
|
||||
1.2. "Contributor Version" means the combination of the Original
|
||||
Code, prior Modifications used by a Contributor, and the Modifications
|
||||
made by that particular Contributor.
|
||||
|
||||
1.3. "Covered Code" means the Original Code or Modifications or the
|
||||
combination of the Original Code and Modifications, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.4. "Electronic Distribution Mechanism" means a mechanism generally
|
||||
accepted in the software development community for the electronic
|
||||
transfer of data.
|
||||
|
||||
1.5. "Executable" means Covered Code in any form other than Source
|
||||
Code.
|
||||
|
||||
1.6. "Initial Developer" means the individual or entity identified
|
||||
as the Initial Developer in the Source Code notice required by Exhibit
|
||||
A.
|
||||
|
||||
1.7. "Larger Work" means a work which combines Covered Code or
|
||||
portions thereof with code not governed by the terms of this License.
|
||||
|
||||
1.8. "License" means this document.
|
||||
|
||||
1.8.1. "Licensable" means having the right to grant, to the maximum
|
||||
extent possible, whether at the time of the initial grant or
|
||||
subsequently acquired, any and all of the rights conveyed herein.
|
||||
|
||||
1.9. "Modifications" means any addition to or deletion from the
|
||||
substance or structure of either the Original Code or any previous
|
||||
Modifications. When Covered Code is released as a series of files, a
|
||||
Modification is:
|
||||
A. Any addition to or deletion from the contents of a file
|
||||
containing Original Code or previous Modifications.
|
||||
|
||||
B. Any new file that contains any part of the Original Code or
|
||||
previous Modifications.
|
||||
|
||||
1.10. "Original Code" means Source Code of computer software code
|
||||
which is described in the Source Code notice required by Exhibit A as
|
||||
Original Code, and which, at the time of its release under this
|
||||
License is not already Covered Code governed by this License.
|
||||
|
||||
1.10.1. "Patent Claims" means any patent claim(s), now owned or
|
||||
hereafter acquired, including without limitation, method, process,
|
||||
and apparatus claims, in any patent Licensable by grantor.
|
||||
|
||||
1.11. "Source Code" means the preferred form of the Covered Code for
|
||||
making modifications to it, including all modules it contains, plus
|
||||
any associated interface definition files, scripts used to control
|
||||
compilation and installation of an Executable, or source code
|
||||
differential comparisons against either the Original Code or another
|
||||
well known, available Covered Code of the Contributor's choice. The
|
||||
Source Code can be in a compressed or archival form, provided the
|
||||
appropriate decompression or de-archiving software is widely available
|
||||
for no charge.
|
||||
|
||||
1.12. "You" (or "Your") means an individual or a legal entity
|
||||
exercising rights under, and complying with all of the terms of, this
|
||||
License or a future version of this License issued under Section 6.1.
|
||||
For legal entities, "You" includes any entity which controls, is
|
||||
controlled by, or is under common control with You. For purposes of
|
||||
this definition, "control" means (a) the power, direct or indirect,
|
||||
to cause the direction or management of such entity, whether by
|
||||
contract or otherwise, or (b) ownership of more than fifty percent
|
||||
(50%) of the outstanding shares or beneficial ownership of such
|
||||
entity.
|
||||
|
||||
2. Source Code License.
|
||||
|
||||
2.1. The Initial Developer Grant.
|
||||
The Initial Developer hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license, subject to third party intellectual property
|
||||
claims:
|
||||
(a) under intellectual property rights (other than patent or
|
||||
trademark) Licensable by Initial Developer to use, reproduce,
|
||||
modify, display, perform, sublicense and distribute the Original
|
||||
Code (or portions thereof) with or without Modifications, and/or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patents Claims infringed by the making, using or
|
||||
selling of Original Code, to make, have made, use, practice,
|
||||
sell, and offer for sale, and/or otherwise dispose of the
|
||||
Original Code (or portions thereof).
|
||||
|
||||
(c) the licenses granted in this Section 2.1(a) and (b) are
|
||||
effective on the date Initial Developer first distributes
|
||||
Original Code under the terms of this License.
|
||||
|
||||
(d) Notwithstanding Section 2.1(b) above, no patent license is
|
||||
granted: 1) for code that You delete from the Original Code; 2)
|
||||
separate from the Original Code; or 3) for infringements caused
|
||||
by: i) the modification of the Original Code or ii) the
|
||||
combination of the Original Code with other software or devices.
|
||||
|
||||
2.2. Contributor Grant.
|
||||
Subject to third party intellectual property claims, each Contributor
|
||||
hereby grants You a world-wide, royalty-free, non-exclusive license
|
||||
|
||||
(a) under intellectual property rights (other than patent or
|
||||
trademark) Licensable by Contributor, to use, reproduce, modify,
|
||||
display, perform, sublicense and distribute the Modifications
|
||||
created by such Contributor (or portions thereof) either on an
|
||||
unmodified basis, with other Modifications, as Covered Code
|
||||
and/or as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims infringed by the making, using, or
|
||||
selling of Modifications made by that Contributor either alone
|
||||
and/or in combination with its Contributor Version (or portions
|
||||
of such combination), to make, use, sell, offer for sale, have
|
||||
made, and/or otherwise dispose of: 1) Modifications made by that
|
||||
Contributor (or portions thereof); and 2) the combination of
|
||||
Modifications made by that Contributor with its Contributor
|
||||
Version (or portions of such combination).
|
||||
|
||||
(c) the licenses granted in Sections 2.2(a) and 2.2(b) are
|
||||
effective on the date Contributor first makes Commercial Use of
|
||||
the Covered Code.
|
||||
|
||||
(d) Notwithstanding Section 2.2(b) above, no patent license is
|
||||
granted: 1) for any code that Contributor has deleted from the
|
||||
Contributor Version; 2) separate from the Contributor Version;
|
||||
3) for infringements caused by: i) third party modifications of
|
||||
Contributor Version or ii) the combination of Modifications made
|
||||
by that Contributor with other software (except as part of the
|
||||
Contributor Version) or other devices; or 4) under Patent Claims
|
||||
infringed by Covered Code in the absence of Modifications made by
|
||||
that Contributor.
|
||||
|
||||
3. Distribution Obligations.
|
||||
|
||||
3.1. Application of License.
|
||||
The Modifications which You create or to which You contribute are
|
||||
governed by the terms of this License, including without limitation
|
||||
Section 2.2. The Source Code version of Covered Code may be
|
||||
distributed only under the terms of this License or a future version
|
||||
of this License released under Section 6.1, and You must include a
|
||||
copy of this License with every copy of the Source Code You
|
||||
distribute. You may not offer or impose any terms on any Source Code
|
||||
version that alters or restricts the applicable version of this
|
||||
License or the recipients' rights hereunder. However, You may include
|
||||
an additional document offering the additional rights described in
|
||||
Section 3.5.
|
||||
|
||||
3.2. Availability of Source Code.
|
||||
Any Modification which You create or to which You contribute must be
|
||||
made available in Source Code form under the terms of this License
|
||||
either on the same media as an Executable version or via an accepted
|
||||
Electronic Distribution Mechanism to anyone to whom you made an
|
||||
Executable version available; and if made available via Electronic
|
||||
Distribution Mechanism, must remain available for at least twelve (12)
|
||||
months after the date it initially became available, or at least six
|
||||
(6) months after a subsequent version of that particular Modification
|
||||
has been made available to such recipients. You are responsible for
|
||||
ensuring that the Source Code version remains available even if the
|
||||
Electronic Distribution Mechanism is maintained by a third party.
|
||||
|
||||
3.3. Description of Modifications.
|
||||
You must cause all Covered Code to which You contribute to contain a
|
||||
file documenting the changes You made to create that Covered Code and
|
||||
the date of any change. You must include a prominent statement that
|
||||
the Modification is derived, directly or indirectly, from Original
|
||||
Code provided by the Initial Developer and including the name of the
|
||||
Initial Developer in (a) the Source Code, and (b) in any notice in an
|
||||
Executable version or related documentation in which You describe the
|
||||
origin or ownership of the Covered Code.
|
||||
|
||||
3.4. Intellectual Property Matters
|
||||
(a) Third Party Claims.
|
||||
If Contributor has knowledge that a license under a third party's
|
||||
intellectual property rights is required to exercise the rights
|
||||
granted by such Contributor under Sections 2.1 or 2.2,
|
||||
Contributor must include a text file with the Source Code
|
||||
distribution titled "LEGAL" which describes the claim and the
|
||||
party making the claim in sufficient detail that a recipient will
|
||||
know whom to contact. If Contributor obtains such knowledge after
|
||||
the Modification is made available as described in Section 3.2,
|
||||
Contributor shall promptly modify the LEGAL file in all copies
|
||||
Contributor makes available thereafter and shall take other steps
|
||||
(such as notifying appropriate mailing lists or newsgroups)
|
||||
reasonably calculated to inform those who received the Covered
|
||||
Code that new knowledge has been obtained.
|
||||
|
||||
(b) Contributor APIs.
|
||||
If Contributor's Modifications include an application programming
|
||||
interface and Contributor has knowledge of patent licenses which
|
||||
are reasonably necessary to implement that API, Contributor must
|
||||
also include this information in the LEGAL file.
|
||||
|
||||
(c) Representations.
|
||||
Contributor represents that, except as disclosed pursuant to
|
||||
Section 3.4(a) above, Contributor believes that Contributor's
|
||||
Modifications are Contributor's original creation(s) and/or
|
||||
Contributor has sufficient rights to grant the rights conveyed by
|
||||
this License.
|
||||
|
||||
3.5. Required Notices.
|
||||
You must duplicate the notice in Exhibit A in each file of the Source
|
||||
Code. If it is not possible to put such notice in a particular Source
|
||||
Code file due to its structure, then You must include such notice in a
|
||||
location (such as a relevant directory) where a user would be likely
|
||||
to look for such a notice. If You created one or more Modification(s)
|
||||
You may add your name as a Contributor to the notice described in
|
||||
Exhibit A. You must also duplicate this License in any documentation
|
||||
for the Source Code where You describe recipients' rights or ownership
|
||||
rights relating to Covered Code. You may choose to offer, and to
|
||||
charge a fee for, warranty, support, indemnity or liability
|
||||
obligations to one or more recipients of Covered Code. However, You
|
||||
may do so only on Your own behalf, and not on behalf of the Initial
|
||||
Developer or any Contributor. You must make it absolutely clear than
|
||||
any such warranty, support, indemnity or liability obligation is
|
||||
offered by You alone, and You hereby agree to indemnify the Initial
|
||||
Developer and every Contributor for any liability incurred by the
|
||||
Initial Developer or such Contributor as a result of warranty,
|
||||
support, indemnity or liability terms You offer.
|
||||
|
||||
3.6. Distribution of Executable Versions.
|
||||
You may distribute Covered Code in Executable form only if the
|
||||
requirements of Section 3.1-3.5 have been met for that Covered Code,
|
||||
and if You include a notice stating that the Source Code version of
|
||||
the Covered Code is available under the terms of this License,
|
||||
including a description of how and where You have fulfilled the
|
||||
obligations of Section 3.2. The notice must be conspicuously included
|
||||
in any notice in an Executable version, related documentation or
|
||||
collateral in which You describe recipients' rights relating to the
|
||||
Covered Code. You may distribute the Executable version of Covered
|
||||
Code or ownership rights under a license of Your choice, which may
|
||||
contain terms different from this License, provided that You are in
|
||||
compliance with the terms of this License and that the license for the
|
||||
Executable version does not attempt to limit or alter the recipient's
|
||||
rights in the Source Code version from the rights set forth in this
|
||||
License. If You distribute the Executable version under a different
|
||||
license You must make it absolutely clear that any terms which differ
|
||||
from this License are offered by You alone, not by the Initial
|
||||
Developer or any Contributor. You hereby agree to indemnify the
|
||||
Initial Developer and every Contributor for any liability incurred by
|
||||
the Initial Developer or such Contributor as a result of any such
|
||||
terms You offer.
|
||||
|
||||
3.7. Larger Works.
|
||||
You may create a Larger Work by combining Covered Code with other code
|
||||
not governed by the terms of this License and distribute the Larger
|
||||
Work as a single product. In such a case, You must make sure the
|
||||
requirements of this License are fulfilled for the Covered Code.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation.
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Code due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description
|
||||
must be included in the LEGAL file described in Section 3.4 and must
|
||||
be included with all distributions of the Source Code. Except to the
|
||||
extent prohibited by statute or regulation, such description must be
|
||||
sufficiently detailed for a recipient of ordinary skill to be able to
|
||||
understand it.
|
||||
|
||||
5. Application of this License.
|
||||
|
||||
This License applies to code to which the Initial Developer has
|
||||
attached the notice in Exhibit A and to related Covered Code.
|
||||
|
||||
6. Versions of the License.
|
||||
|
||||
6.1. New Versions.
|
||||
Netscape Communications Corporation ("Netscape") may publish revised
|
||||
and/or new versions of the License from time to time. Each version
|
||||
will be given a distinguishing version number.
|
||||
|
||||
6.2. Effect of New Versions.
|
||||
Once Covered Code has been published under a particular version of the
|
||||
License, You may always continue to use it under the terms of that
|
||||
version. You may also choose to use such Covered Code under the terms
|
||||
of any subsequent version of the License published by Netscape. No one
|
||||
other than Netscape has the right to modify the terms applicable to
|
||||
Covered Code created under this License.
|
||||
|
||||
6.3. Derivative Works.
|
||||
If You create or use a modified version of this License (which you may
|
||||
only do in order to apply it to code which is not already Covered Code
|
||||
governed by this License), You must (a) rename Your license so that
|
||||
the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
|
||||
"MPL", "NPL" or any confusingly similar phrase do not appear in your
|
||||
license (except to note that your license differs from this License)
|
||||
and (b) otherwise make it clear that Your version of the license
|
||||
contains terms which differ from the Mozilla Public License and
|
||||
Netscape Public License. (Filling in the name of the Initial
|
||||
Developer, Original Code or Contributor in the notice described in
|
||||
Exhibit A shall not of themselves be deemed to be modifications of
|
||||
this License.)
|
||||
|
||||
7. DISCLAIMER OF WARRANTY.
|
||||
|
||||
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
||||
WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
|
||||
DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
|
||||
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
|
||||
IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
|
||||
YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
|
||||
COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
|
||||
OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
|
||||
ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
|
||||
|
||||
8. TERMINATION.
|
||||
|
||||
8.1. This License and the rights granted hereunder will terminate
|
||||
automatically if You fail to comply with terms herein and fail to cure
|
||||
such breach within 30 days of becoming aware of the breach. All
|
||||
sublicenses to the Covered Code which are properly granted shall
|
||||
survive any termination of this License. Provisions which, by their
|
||||
nature, must remain in effect beyond the termination of this License
|
||||
shall survive.
|
||||
|
||||
8.2. If You initiate litigation by asserting a patent infringement
|
||||
claim (excluding declatory judgment actions) against Initial Developer
|
||||
or a Contributor (the Initial Developer or Contributor against whom
|
||||
You file such action is referred to as "Participant") alleging that:
|
||||
|
||||
(a) such Participant's Contributor Version directly or indirectly
|
||||
infringes any patent, then any and all rights granted by such
|
||||
Participant to You under Sections 2.1 and/or 2.2 of this License
|
||||
shall, upon 60 days notice from Participant terminate prospectively,
|
||||
unless if within 60 days after receipt of notice You either: (i)
|
||||
agree in writing to pay Participant a mutually agreeable reasonable
|
||||
royalty for Your past and future use of Modifications made by such
|
||||
Participant, or (ii) withdraw Your litigation claim with respect to
|
||||
the Contributor Version against such Participant. If within 60 days
|
||||
of notice, a reasonable royalty and payment arrangement are not
|
||||
mutually agreed upon in writing by the parties or the litigation claim
|
||||
is not withdrawn, the rights granted by Participant to You under
|
||||
Sections 2.1 and/or 2.2 automatically terminate at the expiration of
|
||||
the 60 day notice period specified above.
|
||||
|
||||
(b) any software, hardware, or device, other than such Participant's
|
||||
Contributor Version, directly or indirectly infringes any patent, then
|
||||
any rights granted to You by such Participant under Sections 2.1(b)
|
||||
and 2.2(b) are revoked effective as of the date You first made, used,
|
||||
sold, distributed, or had made, Modifications made by that
|
||||
Participant.
|
||||
|
||||
8.3. If You assert a patent infringement claim against Participant
|
||||
alleging that such Participant's Contributor Version directly or
|
||||
indirectly infringes any patent where such claim is resolved (such as
|
||||
by license or settlement) prior to the initiation of patent
|
||||
infringement litigation, then the reasonable value of the licenses
|
||||
granted by such Participant under Sections 2.1 or 2.2 shall be taken
|
||||
into account in determining the amount or value of any payment or
|
||||
license.
|
||||
|
||||
8.4. In the event of termination under Sections 8.1 or 8.2 above,
|
||||
all end user license agreements (excluding distributors and resellers)
|
||||
which have been validly granted by You or any distributor hereunder
|
||||
prior to termination shall survive termination.
|
||||
|
||||
9. LIMITATION OF LIABILITY.
|
||||
|
||||
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
|
||||
(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
|
||||
DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
|
||||
OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
|
||||
ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
|
||||
CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
|
||||
WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
|
||||
COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
|
||||
INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
|
||||
LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
|
||||
RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
|
||||
PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
|
||||
EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
|
||||
THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
10. U.S. GOVERNMENT END USERS.
|
||||
|
||||
The Covered Code is a "commercial item," as that term is defined in
|
||||
48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
|
||||
software" and "commercial computer software documentation," as such
|
||||
terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
|
||||
C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
|
||||
all U.S. Government End Users acquire Covered Code with only those
|
||||
rights set forth herein.
|
||||
|
||||
11. MISCELLANEOUS.
|
||||
|
||||
This License represents the complete agreement concerning subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. This License shall be governed by
|
||||
California law provisions (except to the extent applicable law, if
|
||||
any, provides otherwise), excluding its conflict-of-law provisions.
|
||||
With respect to disputes in which at least one party is a citizen of,
|
||||
or an entity chartered or registered to do business in the United
|
||||
States of America, any litigation relating to this License shall be
|
||||
subject to the jurisdiction of the Federal Courts of the Northern
|
||||
District of California, with venue lying in Santa Clara County,
|
||||
California, with the losing party responsible for costs, including
|
||||
without limitation, court costs and reasonable attorneys' fees and
|
||||
expenses. The application of the United Nations Convention on
|
||||
Contracts for the International Sale of Goods is expressly excluded.
|
||||
Any law or regulation which provides that the language of a contract
|
||||
shall be construed against the drafter shall not apply to this
|
||||
License.
|
||||
|
||||
12. RESPONSIBILITY FOR CLAIMS.
|
||||
|
||||
As between Initial Developer and the Contributors, each party is
|
||||
responsible for claims and damages arising, directly or indirectly,
|
||||
out of its utilization of rights under this License and You agree to
|
||||
work with Initial Developer and Contributors to distribute such
|
||||
responsibility on an equitable basis. Nothing herein is intended or
|
||||
shall be deemed to constitute any admission of liability.
|
||||
|
||||
13. MULTIPLE-LICENSED CODE.
|
||||
|
||||
Initial Developer may designate portions of the Covered Code as
|
||||
"Multiple-Licensed". "Multiple-Licensed" means that the Initial
|
||||
Developer permits you to utilize portions of the Covered Code under
|
||||
Your choice of the NPL or the alternative licenses, if any, specified
|
||||
by the Initial Developer in the file described in Exhibit A.
|
||||
|
||||
EXHIBIT A -Mozilla Public License.
|
||||
|
||||
``The contents of this file are subject to the Mozilla Public License
|
||||
Version 1.1 (the "License"); you may not use this file except in
|
||||
compliance with the License. You may obtain a copy of the License at
|
||||
http://www.mozilla.org/MPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS IS"
|
||||
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
License for the specific language governing rights and limitations
|
||||
under the License.
|
||||
|
||||
The Original Code is ______________________________________.
|
||||
|
||||
The Initial Developer of the Original Code is ________________________.
|
||||
Portions created by ______________________ are Copyright (C) ______
|
||||
_______________________. All Rights Reserved.
|
||||
|
||||
Contributor(s): ______________________________________.
|
||||
|
||||
Alternatively, the contents of this file may be used under the terms
|
||||
of the _____ license (the "[___] License"), in which case the
|
||||
provisions of [______] License are applicable instead of those
|
||||
above. If you wish to allow use of your version of this file only
|
||||
under the terms of the [____] License and not to allow others to use
|
||||
your version of this file under the MPL, indicate your decision by
|
||||
deleting the provisions above and replace them with the notice and
|
||||
other provisions required by the [___] License. If you do not delete
|
||||
the provisions above, a recipient may use your version of this file
|
||||
under either the MPL or the [___] License."
|
||||
|
||||
[NOTE: The text of this Exhibit A may differ slightly from the text of
|
||||
the notices in the Source Code files of the Original Code. You should
|
||||
use the text of this Exhibit A rather than the text found in the
|
||||
Original Code Source Code for Your Modifications.]
|
||||
|
1
jsdoc-master/rhino/crypto.js
Normal file
1
jsdoc-master/rhino/crypto.js
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require('crypto-browserify');
|
200
jsdoc-master/rhino/events.js
Normal file
200
jsdoc-master/rhino/events.js
Normal file
@@ -0,0 +1,200 @@
|
||||
/**
|
||||
* Shim for Node.js `events` module. Adapted from `node-browserify`.
|
||||
* @see https://github.com/substack/node-browserify
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
if (!process.EventEmitter) {
|
||||
process.EventEmitter = function () {};
|
||||
}
|
||||
|
||||
var EventEmitter = exports.EventEmitter = process.EventEmitter;
|
||||
var isArray = typeof Array.isArray === 'function' ?
|
||||
Array.isArray :
|
||||
function (xs) {
|
||||
return Object.prototype.toString.call(xs) === '[object Array]';
|
||||
}
|
||||
;
|
||||
|
||||
// By default EventEmitters will print a warning if more than
|
||||
// 10 listeners are added to it. This is a useful default which
|
||||
// helps finding memory leaks.
|
||||
//
|
||||
// Obviously not all Emitters should be limited to 10. This function allows
|
||||
// that to be increased. Set to zero for unlimited.
|
||||
var defaultMaxListeners = 10;
|
||||
EventEmitter.prototype.setMaxListeners = function(n) {
|
||||
if (!this._events) {
|
||||
this._events = {};
|
||||
}
|
||||
this._events.maxListeners = n;
|
||||
};
|
||||
|
||||
|
||||
EventEmitter.prototype.emit = function(type) {
|
||||
var args;
|
||||
|
||||
// If there is no 'error' event listener then throw.
|
||||
if (type === 'error') {
|
||||
if (!this._events || !this._events.error ||
|
||||
(isArray(this._events.error) && !this._events.error.length))
|
||||
{
|
||||
if (arguments[1] instanceof Error) {
|
||||
throw arguments[1]; // Unhandled 'error' event
|
||||
} else {
|
||||
throw new Error("Uncaught, unspecified 'error' event.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this._events) {
|
||||
return false;
|
||||
}
|
||||
var handler = this._events[type];
|
||||
if (!handler) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof handler == 'function') {
|
||||
switch (arguments.length) {
|
||||
// fast cases
|
||||
case 1:
|
||||
handler.call(this);
|
||||
break;
|
||||
case 2:
|
||||
handler.call(this, arguments[1]);
|
||||
break;
|
||||
case 3:
|
||||
handler.call(this, arguments[1], arguments[2]);
|
||||
break;
|
||||
// slower
|
||||
default:
|
||||
args = Array.prototype.slice.call(arguments, 1);
|
||||
handler.apply(this, args);
|
||||
}
|
||||
return true;
|
||||
|
||||
} else if (isArray(handler)) {
|
||||
args = Array.prototype.slice.call(arguments, 1);
|
||||
|
||||
var listeners = handler.slice();
|
||||
for (var i = 0, l = listeners.length; i < l; i++) {
|
||||
listeners[i].apply(this, args);
|
||||
}
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// EventEmitter is defined in src/node_events.cc
|
||||
// EventEmitter.prototype.emit() is also defined there.
|
||||
EventEmitter.prototype.addListener = function(type, listener) {
|
||||
if ('function' !== typeof listener) {
|
||||
throw new Error('addListener only takes instances of Function');
|
||||
}
|
||||
|
||||
if (!this._events) {
|
||||
this._events = {};
|
||||
}
|
||||
|
||||
// To avoid recursion in the case that type == "newListeners"! Before
|
||||
// adding it to the listeners, first emit "newListeners".
|
||||
this.emit('newListener', type, listener);
|
||||
|
||||
if (!this._events[type]) {
|
||||
// Optimize the case of one listener. Don't need the extra array object.
|
||||
this._events[type] = listener;
|
||||
} else if (isArray(this._events[type])) {
|
||||
|
||||
// Check for listener leak
|
||||
if (!this._events[type].warned) {
|
||||
var m;
|
||||
if (this._events.maxListeners !== undefined) {
|
||||
m = this._events.maxListeners;
|
||||
} else {
|
||||
m = defaultMaxListeners;
|
||||
}
|
||||
|
||||
if (m && m > 0 && this._events[type].length > m) {
|
||||
this._events[type].warned = true;
|
||||
console.error('(node) warning: possible EventEmitter memory ' +
|
||||
'leak detected. %d listeners added. ' +
|
||||
'Use emitter.setMaxListeners() to increase limit.',
|
||||
this._events[type].length);
|
||||
console.trace();
|
||||
}
|
||||
}
|
||||
|
||||
// If we've already got an array, just append.
|
||||
this._events[type].push(listener);
|
||||
} else {
|
||||
// Adding the second element, need to change to array.
|
||||
this._events[type] = [this._events[type], listener];
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
||||
|
||||
EventEmitter.prototype.once = function(type, listener) {
|
||||
var self = this;
|
||||
self.on(type, function g() {
|
||||
self.removeListener(type, g);
|
||||
listener.apply(this, arguments);
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
EventEmitter.prototype.removeListener = function(type, listener) {
|
||||
if ('function' !== typeof listener) {
|
||||
throw new Error('removeListener only takes instances of Function');
|
||||
}
|
||||
|
||||
// does not use listeners(), so no side effect of creating _events[type]
|
||||
if (!this._events || !this._events[type]) {
|
||||
return this;
|
||||
}
|
||||
|
||||
var list = this._events[type];
|
||||
|
||||
if (isArray(list)) {
|
||||
var i = list.indexOf(listener);
|
||||
if (i < 0) {
|
||||
return this;
|
||||
}
|
||||
list.splice(i, 1);
|
||||
if (list.length === 0) {
|
||||
delete this._events[type];
|
||||
}
|
||||
} else if (this._events[type] === listener) {
|
||||
delete this._events[type];
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
EventEmitter.prototype.removeAllListeners = function(type) {
|
||||
// does not use listeners(), so no side effect of creating _events[type]
|
||||
if (type && this._events && this._events[type]) {
|
||||
this._events[type] = null;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
EventEmitter.prototype.listeners = function(type) {
|
||||
if (!this._events) {
|
||||
this._events = {};
|
||||
}
|
||||
if (!this._events[type]) {
|
||||
this._events[type] = [];
|
||||
}
|
||||
if (!isArray(this._events[type])) {
|
||||
this._events[type] = [this._events[type]];
|
||||
}
|
||||
return this._events[type];
|
||||
};
|
176
jsdoc-master/rhino/fs.js
Normal file
176
jsdoc-master/rhino/fs.js
Normal file
@@ -0,0 +1,176 @@
|
||||
/*global Packages: true */
|
||||
|
||||
/**
|
||||
* Partial Rhino shim for Node.js' `fs` module.
|
||||
* @see http://nodejs.org/api/fs.html
|
||||
*/
|
||||
|
||||
var path = require('path');
|
||||
|
||||
var asyncify = path._asyncify;
|
||||
|
||||
function checkEncoding(enc, name) {
|
||||
// we require the `encoding` parameter for Node.js compatibility; on Node.js, if you omit the
|
||||
// encoding, you get a stream instead of a string
|
||||
if (!enc || typeof enc === 'function') {
|
||||
throw new Error(name + ' requires an encoding on Rhino!');
|
||||
}
|
||||
|
||||
// Node.js wants 'utf8', but Java wants 'utf-8'
|
||||
if (enc === 'utf8') {
|
||||
enc = 'utf-8';
|
||||
}
|
||||
|
||||
return enc;
|
||||
}
|
||||
|
||||
exports.readFileSync = function(filename, encoding) {
|
||||
encoding = checkEncoding(encoding, 'fs.readFile[Sync]');
|
||||
|
||||
return readFile(filename, encoding);
|
||||
};
|
||||
exports.readFile = asyncify(exports.readFileSync);
|
||||
|
||||
// in node 0.8, path.exists() and path.existsSync() moved to the "fs" module
|
||||
exports.existsSync = path.existsSync;
|
||||
exports.exists = path.exists;
|
||||
|
||||
var statSync = exports.statSync = function(_path) {
|
||||
var f = new java.io.File(_path);
|
||||
return {
|
||||
isFile: function() {
|
||||
return f.isFile();
|
||||
},
|
||||
isDirectory: function() {
|
||||
return f.isDirectory();
|
||||
}
|
||||
};
|
||||
};
|
||||
exports.stat = asyncify(statSync);
|
||||
|
||||
var readdirSync = exports.readdirSync = function(_path) {
|
||||
var dir;
|
||||
var files;
|
||||
|
||||
dir = new java.io.File(_path);
|
||||
if (!dir.directory) {
|
||||
throw new Error("ENOENT, no such file or directory '" + _path + "'");
|
||||
}
|
||||
|
||||
files = dir.list();
|
||||
|
||||
// Convert files to Javascript strings so they play nice with node modules
|
||||
files = files.map(function(fileName) {
|
||||
return String(fileName);
|
||||
});
|
||||
|
||||
return files;
|
||||
};
|
||||
exports.readdir = asyncify(readdirSync);
|
||||
|
||||
// JSDoc extension to `fs` module
|
||||
var ls = exports.ls = function(dir, recurse, _allFiles, _path) {
|
||||
var files,
|
||||
file;
|
||||
|
||||
if (typeof _path === 'undefined') { // initially
|
||||
_allFiles = [];
|
||||
_path = [dir];
|
||||
}
|
||||
|
||||
if (_path.length === 0) { return _allFiles; }
|
||||
if (typeof recurse === 'undefined') { recurse = 1; }
|
||||
|
||||
if ( statSync(dir).isFile(dir) ) {
|
||||
files = [dir];
|
||||
}
|
||||
else {
|
||||
files = readdirSync(dir);
|
||||
}
|
||||
|
||||
for (var f = 0, lenf = files.length; f < lenf; f++) {
|
||||
file = String(files[f]);
|
||||
|
||||
if (file.match(/^\.[^\.\/\\]/)) { continue; } // skip dot files
|
||||
|
||||
if ((new java.io.File(_path.join('/') + '/' + file)).list()) { // it's a directory
|
||||
_path.push(file);
|
||||
|
||||
if (_path.length - 1 < recurse) {
|
||||
ls(_path.join('/'), recurse, _allFiles, _path);
|
||||
}
|
||||
_path.pop();
|
||||
}
|
||||
else { // it's a file
|
||||
_allFiles.push(
|
||||
path.normalize(_path.join('/') + '/' + file)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return _allFiles;
|
||||
};
|
||||
|
||||
// JSDoc extension to `fs` module
|
||||
var toDir = exports.toDir = function(_path) {
|
||||
var f = new java.io.File(_path);
|
||||
|
||||
if (f.isDirectory()){
|
||||
return _path;
|
||||
} else {
|
||||
return path.dirname(_path);
|
||||
}
|
||||
};
|
||||
|
||||
var mkdirSync = exports.mkdirSync = function(_path) {
|
||||
var dir_path = toDir(_path);
|
||||
(new java.io.File(dir_path)).mkdir();
|
||||
};
|
||||
exports.mkdir = asyncify(mkdirSync);
|
||||
|
||||
// JSDoc extension to `fs` module
|
||||
exports.mkPath = function(/**Array*/ _path) {
|
||||
if (_path.constructor == Array) { _path = _path.join(''); }
|
||||
|
||||
(new java.io.File(_path)).mkdirs();
|
||||
};
|
||||
|
||||
// JSDoc extension to `fs` module
|
||||
exports.copyFileSync = function(inFile, outDir, fileName) {
|
||||
if (fileName == null){fileName = path.basename(inFile);}
|
||||
|
||||
outDir = toDir(outDir);
|
||||
|
||||
inFile = new java.io.File(inFile);
|
||||
var outFile = new java.io.File(outDir+'/'+fileName);
|
||||
|
||||
var bis = new Packages.java.io.BufferedInputStream(new Packages.java.io.FileInputStream(inFile), 4096);
|
||||
var bos = new Packages.java.io.BufferedOutputStream(new Packages.java.io.FileOutputStream(outFile), 4096);
|
||||
var theChar;
|
||||
while ((theChar = bis.read()) != -1) {
|
||||
bos.write(theChar);
|
||||
}
|
||||
bos.close();
|
||||
bis.close();
|
||||
};
|
||||
exports.copyFile = asyncify(exports.copyFileSync);
|
||||
|
||||
exports.writeFileSync = function(filename, data, encoding) {
|
||||
encoding = checkEncoding(encoding, 'fs.writeFile[Sync]');
|
||||
|
||||
var out = new Packages.java.io.PrintWriter(
|
||||
new Packages.java.io.OutputStreamWriter(
|
||||
new Packages.java.io.FileOutputStream(filename),
|
||||
encoding
|
||||
)
|
||||
);
|
||||
|
||||
try {
|
||||
out.write(data);
|
||||
}
|
||||
finally {
|
||||
out.flush();
|
||||
out.close();
|
||||
}
|
||||
};
|
||||
exports.writeFile = asyncify(exports.writeFileSync);
|
BIN
jsdoc-master/rhino/js.jar
Normal file
BIN
jsdoc-master/rhino/js.jar
Normal file
Binary file not shown.
9
jsdoc-master/rhino/jsdoc.js
Normal file
9
jsdoc-master/rhino/jsdoc.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// Platform-specific functions to support jsdoc.js
|
||||
|
||||
exports.pathToUri = function(_path) {
|
||||
return String( new java.io.File(_path).toURI() );
|
||||
};
|
||||
|
||||
exports.uriToPath = function(uri) {
|
||||
return String( new java.io.File(new java.net.URI(uri)) );
|
||||
};
|
7
jsdoc-master/rhino/jsdoc/util/include.js
Normal file
7
jsdoc-master/rhino/jsdoc/util/include.js
Normal file
@@ -0,0 +1,7 @@
|
||||
/*global Packages: true */
|
||||
module.exports = function(filepath) {
|
||||
var myGlobal = require('jsdoc/util/global');
|
||||
|
||||
var cx = Packages.org.mozilla.javascript.Context.getCurrentContext();
|
||||
Packages.org.mozilla.javascript.tools.shell.Main.processFile(cx, myGlobal, filepath);
|
||||
};
|
18
jsdoc-master/rhino/os.js
Normal file
18
jsdoc-master/rhino/os.js
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Partial Rhino implementation of Node.js' `os` module.
|
||||
* @module os
|
||||
* @author Jeff Williams <jeffrey.l.williams@gmail.com>
|
||||
* @see http://nodejs.org/api/os.html
|
||||
*/
|
||||
|
||||
exports.EOL = String( java.lang.System.getProperty('line.separator') );
|
||||
|
||||
// clearly not accurate, but probably good enough
|
||||
exports.platform = function() {
|
||||
if ( String(java.lang.System.getProperty('os.name')).match(/^[Ww]in/) ) {
|
||||
return 'win32';
|
||||
}
|
||||
else {
|
||||
return 'linux';
|
||||
}
|
||||
};
|
399
jsdoc-master/rhino/path.js
Normal file
399
jsdoc-master/rhino/path.js
Normal file
@@ -0,0 +1,399 @@
|
||||
var isWindows = java.lang.System.getProperty("os.name").toLowerCase().contains("windows");
|
||||
var fileSeparator = exports.sep = String( java.lang.System.getProperty("file.separator") );
|
||||
|
||||
function noOp() {}
|
||||
|
||||
// exported for the benefit of our `fs` shim
|
||||
var asyncify = exports._asyncify = function(func) {
|
||||
return function() {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var callback = args.pop();
|
||||
var data;
|
||||
|
||||
callback = typeof callback === 'function' ? callback : noOp;
|
||||
|
||||
try {
|
||||
data = func.apply(this, args);
|
||||
process.nextTick(function() {
|
||||
callback(null, data);
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
process.nextTick(function() {
|
||||
callback(e);
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns everything on a path except for the last item
|
||||
* e.g. if the path was 'path/to/something', the return value would be 'path/to'
|
||||
*/
|
||||
exports.dirname = function(_path) {
|
||||
var f = new java.io.File(_path);
|
||||
return String(f.getParent());
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the last item on a path
|
||||
*/
|
||||
exports.basename = function(_path, ext) {
|
||||
var f = new java.io.File(_path);
|
||||
var p = f.getParentFile();
|
||||
var base = String(f.getName());
|
||||
if (p != null) {
|
||||
var idx = ext ? base.indexOf(ext) : -1;
|
||||
if (idx !== -1) {
|
||||
base = base.substring(0, base.length - ext.length);
|
||||
}
|
||||
}
|
||||
return base;
|
||||
};
|
||||
|
||||
exports.existsSync = function(_path) {
|
||||
var f = new java.io.File(_path);
|
||||
|
||||
if (f.isDirectory()){
|
||||
return true;
|
||||
}
|
||||
if (!f.exists()){
|
||||
return false;
|
||||
}
|
||||
if (!f.canRead()){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
exports.exists = asyncify(exports.existsSync);
|
||||
|
||||
//Code below taken from node
|
||||
|
||||
//resolves . and .. elements in a path array with directory names there
|
||||
//must be no slashes, empty elements, or device names (c:\) in the array
|
||||
//(so also no leading and trailing slashes - it does not distinguish
|
||||
//relative and absolute paths)
|
||||
function normalizeArray(parts, allowAboveRoot) {
|
||||
// if the path tries to go above the root, `up` ends up > 0
|
||||
var up = 0;
|
||||
for ( var i = parts.length - 1; i >= 0; i--) {
|
||||
var last = parts[i];
|
||||
if (last == '.') {
|
||||
parts.splice(i, 1);
|
||||
} else if (last === '..') {
|
||||
parts.splice(i, 1);
|
||||
up++;
|
||||
} else if (up) {
|
||||
parts.splice(i, 1);
|
||||
up--;
|
||||
}
|
||||
}
|
||||
|
||||
// if the path is allowed to go above the root, restore leading ..s
|
||||
if (allowAboveRoot) {
|
||||
for (; up--; up) {
|
||||
parts.unshift('..');
|
||||
}
|
||||
}
|
||||
|
||||
return parts;
|
||||
}
|
||||
|
||||
if (isWindows) {
|
||||
// Regex to split a windows path into three parts: [*, device, slash,
|
||||
// tail] windows-only
|
||||
var splitDeviceRe =
|
||||
/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?([\\\/])?([\s\S]*?)$/;
|
||||
|
||||
// path.resolve([from ...], to)
|
||||
// windows version
|
||||
exports.resolve = function() {
|
||||
var resolvedDevice = '',
|
||||
resolvedTail = '',
|
||||
resolvedAbsolute = false;
|
||||
|
||||
for (var i = arguments.length - 1; i >= -1; i--) {
|
||||
var path;
|
||||
if (i >= 0) {
|
||||
path = arguments[i];
|
||||
} else if (!resolvedDevice) {
|
||||
path = process.cwd();
|
||||
} else {
|
||||
// Windows has the concept of drive-specific current working
|
||||
// directories. If we've resolved a drive letter but not yet an
|
||||
// absolute path, get cwd for that drive. We're sure the device is not
|
||||
// an unc path at this points, because unc paths are always absolute.
|
||||
path = process.env['=' + resolvedDevice];
|
||||
// Verify that a drive-local cwd was found and that it actually points
|
||||
// to our drive. If not, default to the drive's root.
|
||||
if (!path || path.substr(0, 3).toLowerCase() !==
|
||||
resolvedDevice.toLowerCase() + '\\') {
|
||||
path = resolvedDevice + '\\';
|
||||
}
|
||||
}
|
||||
|
||||
// Skip empty and invalid entries
|
||||
if (typeof path !== 'string' || !path) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var result = splitDeviceRe.exec(path),
|
||||
device = result[1] || '',
|
||||
isUnc = device && device.charAt(1) !== ':',
|
||||
isAbsolute = !!result[2] || isUnc, // UNC paths are always absolute
|
||||
tail = result[3];
|
||||
|
||||
if (device &&
|
||||
resolvedDevice &&
|
||||
device.toLowerCase() !== resolvedDevice.toLowerCase()) {
|
||||
// This path points to another device so it is not applicable
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!resolvedDevice) {
|
||||
resolvedDevice = device;
|
||||
}
|
||||
if (!resolvedAbsolute) {
|
||||
resolvedTail = tail + '\\' + resolvedTail;
|
||||
resolvedAbsolute = isAbsolute;
|
||||
}
|
||||
|
||||
if (resolvedDevice && resolvedAbsolute) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Replace slashes (in UNC share name) by backslashes
|
||||
resolvedDevice = resolvedDevice.replace(/\//g, '\\');
|
||||
|
||||
// At this point the path should be resolved to a full absolute path,
|
||||
// but handle relative paths to be safe (might happen when process.cwd()
|
||||
// fails)
|
||||
|
||||
// Normalize the tail path
|
||||
|
||||
function f(p) {
|
||||
return !!p;
|
||||
}
|
||||
|
||||
resolvedTail = normalizeArray(resolvedTail.split(/[\\\/]+/).filter(f),
|
||||
!resolvedAbsolute).join('\\');
|
||||
|
||||
return (resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail) ||
|
||||
'.';
|
||||
};
|
||||
|
||||
// windows version
|
||||
exports.normalize = function(_path) {
|
||||
var result = splitDeviceRe.exec(_path),
|
||||
device = result[1] || '',
|
||||
isUnc = device && device.charAt(1) !== ':',
|
||||
isAbsolute = !!result[2] || isUnc, // UNC paths are always absolute
|
||||
tail = result[3],
|
||||
trailingSlash = /[\\\/]$/.test(tail);
|
||||
|
||||
// Normalize the tail path
|
||||
tail = normalizeArray(tail.split(/[\\\/]+/).filter(function(p) {
|
||||
return !!p;
|
||||
}), !isAbsolute).join('\\');
|
||||
|
||||
if (!tail && !isAbsolute) {
|
||||
tail = '.';
|
||||
}
|
||||
if (tail && trailingSlash) {
|
||||
tail += '\\';
|
||||
}
|
||||
|
||||
return device + (isAbsolute ? '\\' : '') + tail;
|
||||
};
|
||||
|
||||
//windows version
|
||||
exports.join = function() {
|
||||
function f(p) {
|
||||
return p && typeof p === 'string';
|
||||
}
|
||||
|
||||
var _paths = Array.prototype.slice.call(arguments, 0).filter(f);
|
||||
var joined = _paths.join('\\');
|
||||
|
||||
// Make sure that the joined path doesn't start with two slashes
|
||||
// - it will be mistaken for an unc path by normalize() -
|
||||
// unless the _paths[0] also starts with two slashes
|
||||
if (/^[\\\/]{2}/.test(joined) && !/^[\\\/]{2}/.test(_paths[0])) {
|
||||
joined = joined.slice(1);
|
||||
}
|
||||
|
||||
return exports.normalize(joined);
|
||||
};
|
||||
|
||||
// path.relative(from, to)
|
||||
// it will solve the relative path from 'from' to 'to', for instance:
|
||||
// from = 'C:\\orandea\\test\\aaa'
|
||||
// to = 'C:\\orandea\\impl\\bbb'
|
||||
// The output of the function should be: '..\\..\\impl\\bbb'
|
||||
// windows version
|
||||
exports.relative = function(from, to) {
|
||||
from = exports.resolve(from);
|
||||
to = exports.resolve(to);
|
||||
|
||||
// windows is not case sensitive
|
||||
var lowerFrom = from.toLowerCase();
|
||||
var lowerTo = to.toLowerCase();
|
||||
|
||||
function trim(arr) {
|
||||
var start = 0;
|
||||
for (; start < arr.length; start++) {
|
||||
if (arr[start] !== '') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var end = arr.length - 1;
|
||||
for (; end >= 0; end--) {
|
||||
if (arr[end] !== '') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (start > end) {
|
||||
return [];
|
||||
}
|
||||
return arr.slice(start, end - start + 1);
|
||||
}
|
||||
|
||||
var toParts = trim(to.split('\\'));
|
||||
|
||||
var lowerFromParts = trim(lowerFrom.split('\\'));
|
||||
var lowerToParts = trim(lowerTo.split('\\'));
|
||||
|
||||
var length = Math.min(lowerFromParts.length, lowerToParts.length);
|
||||
var samePartsLength = length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (lowerFromParts[i] !== lowerToParts[i]) {
|
||||
samePartsLength = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (samePartsLength === 0) {
|
||||
return to;
|
||||
}
|
||||
|
||||
var outputParts = [];
|
||||
for (i = samePartsLength; i < lowerFromParts.length; i++) {
|
||||
outputParts.push('..');
|
||||
}
|
||||
|
||||
outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
||||
|
||||
return outputParts.join('\\');
|
||||
};
|
||||
} else {
|
||||
// path.resolve([from ...], to)
|
||||
// posix version
|
||||
exports.resolve = function() {
|
||||
var resolvedPath = '',
|
||||
resolvedAbsolute = false;
|
||||
|
||||
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
||||
var path = (i >= 0) ? arguments[i] : process.cwd();
|
||||
|
||||
// Skip empty and invalid entries
|
||||
if (typeof path !== 'string' || !path) {
|
||||
continue;
|
||||
}
|
||||
|
||||
resolvedPath = path + '/' + resolvedPath;
|
||||
resolvedAbsolute = path.charAt(0) === '/';
|
||||
}
|
||||
|
||||
// At this point the path should be resolved to a full absolute path, but
|
||||
// handle relative paths to be safe (might happen when process.cwd() fails)
|
||||
|
||||
// Normalize the path
|
||||
resolvedPath = normalizeArray(resolvedPath.split('/').filter(function(p) {
|
||||
return !!p;
|
||||
}), !resolvedAbsolute).join('/');
|
||||
|
||||
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
||||
};
|
||||
|
||||
// path.normalize(_path)
|
||||
// posix version
|
||||
exports.normalize = function(_path) {
|
||||
var isAbsolute = _path.charAt(0) === '/',
|
||||
trailingSlash = _path.slice(-1) === '/';
|
||||
|
||||
// Normalize the path
|
||||
_path = normalizeArray(_path.split('/').filter(function(p) {
|
||||
return !!p;
|
||||
}), !isAbsolute).join('/');
|
||||
|
||||
if (!_path && !isAbsolute) {
|
||||
_path = '.';
|
||||
}
|
||||
if (_path && trailingSlash) {
|
||||
_path += '/';
|
||||
}
|
||||
|
||||
return (isAbsolute ? '/' : '') + _path;
|
||||
};
|
||||
|
||||
// posix version
|
||||
exports.join = function() {
|
||||
var _paths = Array.prototype.slice.call(arguments, 0);
|
||||
return exports.normalize(_paths.filter(function(p, index) {
|
||||
return p && typeof p === 'string';
|
||||
}).join('/'));
|
||||
};
|
||||
|
||||
// path.relative(from, to)
|
||||
// posix version
|
||||
exports.relative = function(from, to) {
|
||||
from = exports.resolve(from).substr(1);
|
||||
to = exports.resolve(to).substr(1);
|
||||
|
||||
function trim(arr) {
|
||||
var start = 0;
|
||||
for (; start < arr.length; start++) {
|
||||
if (arr[start] !== '') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var end = arr.length - 1;
|
||||
for (; end >= 0; end--) {
|
||||
if (arr[end] !== '') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (start > end) {
|
||||
return [];
|
||||
}
|
||||
return arr.slice(start, end - start + 1);
|
||||
}
|
||||
|
||||
var fromParts = trim(from.split('/'));
|
||||
var toParts = trim(to.split('/'));
|
||||
|
||||
var length = Math.min(fromParts.length, toParts.length);
|
||||
var samePartsLength = length;
|
||||
for (var i = 0; i < length; i++) {
|
||||
if (fromParts[i] !== toParts[i]) {
|
||||
samePartsLength = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var outputParts = [];
|
||||
for (i = samePartsLength; i < fromParts.length; i++) {
|
||||
outputParts.push('..');
|
||||
}
|
||||
|
||||
outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
||||
|
||||
return outputParts.join('/');
|
||||
};
|
||||
}
|
122
jsdoc-master/rhino/querystring.js
Normal file
122
jsdoc-master/rhino/querystring.js
Normal file
@@ -0,0 +1,122 @@
|
||||
/**
|
||||
* Adapted version of Node.js' `querystring` module.
|
||||
* @module querystring
|
||||
* @see http://nodejs.org/api/querystring.html
|
||||
* @see https://github.com/joyent/node/blob/f105f2f2/lib/querystring.js
|
||||
* @license MIT
|
||||
*/
|
||||
var QueryString = exports;
|
||||
|
||||
// If obj.hasOwnProperty has been overridden, then calling
|
||||
// obj.hasOwnProperty(prop) will break.
|
||||
// See: https://github.com/joyent/node/issues/1707
|
||||
function hasOwnProp(obj, prop) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, prop);
|
||||
}
|
||||
|
||||
|
||||
QueryString.unescape = function(s) {
|
||||
return decodeURIComponent(s);
|
||||
};
|
||||
|
||||
|
||||
QueryString.escape = function(str) {
|
||||
return encodeURIComponent(str);
|
||||
};
|
||||
|
||||
var stringifyPrimitive = function(v) {
|
||||
switch (typeof v) {
|
||||
case 'string':
|
||||
return v;
|
||||
|
||||
case 'boolean':
|
||||
return v ? 'true' : 'false';
|
||||
|
||||
case 'number':
|
||||
return isFinite(v) ? v : '';
|
||||
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
QueryString.stringify = QueryString.encode = function(obj, sep, eq, name) {
|
||||
sep = sep || '&';
|
||||
eq = eq || '=';
|
||||
if (obj === null) {
|
||||
obj = undefined;
|
||||
}
|
||||
|
||||
if (typeof obj === 'object') {
|
||||
return Object.keys(obj).map(function(k) {
|
||||
var ks = QueryString.escape(stringifyPrimitive(k)) + eq;
|
||||
if (Array.isArray(obj[k])) {
|
||||
return obj[k].map(function(v) {
|
||||
return ks + QueryString.escape(stringifyPrimitive(v));
|
||||
}).join(sep);
|
||||
} else {
|
||||
return ks + QueryString.escape(stringifyPrimitive(obj[k]));
|
||||
}
|
||||
}).join(sep);
|
||||
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
return '';
|
||||
}
|
||||
return QueryString.escape(stringifyPrimitive(name)) + eq +
|
||||
QueryString.escape(stringifyPrimitive(obj));
|
||||
};
|
||||
|
||||
// Parse a key=val string.
|
||||
QueryString.parse = QueryString.decode = function(qs, sep, eq, options) {
|
||||
sep = sep || '&';
|
||||
eq = eq || '=';
|
||||
var obj = {};
|
||||
|
||||
if (typeof qs !== 'string' || qs.length === 0) {
|
||||
return obj;
|
||||
}
|
||||
|
||||
var regexp = /\+/g;
|
||||
qs = qs.split(sep);
|
||||
|
||||
var maxKeys = 1000;
|
||||
if (options && typeof options.maxKeys === 'number') {
|
||||
maxKeys = options.maxKeys;
|
||||
}
|
||||
|
||||
var len = qs.length;
|
||||
// maxKeys <= 0 means that we should not limit keys count
|
||||
if (maxKeys > 0 && len > maxKeys) {
|
||||
len = maxKeys;
|
||||
}
|
||||
|
||||
for (var i = 0; i < len; ++i) {
|
||||
var x = qs[i].replace(regexp, '%20'),
|
||||
idx = x.indexOf(eq),
|
||||
kstr, vstr, k, v;
|
||||
|
||||
if (idx >= 0) {
|
||||
kstr = x.substr(0, idx);
|
||||
vstr = x.substr(idx + 1);
|
||||
} else {
|
||||
kstr = x;
|
||||
vstr = '';
|
||||
}
|
||||
|
||||
k = QueryString.unescape(kstr);
|
||||
v = QueryString.unescape(vstr);
|
||||
|
||||
if (!hasOwnProp(obj, k)) {
|
||||
obj[k] = v;
|
||||
} else if (Array.isArray(obj[k])) {
|
||||
obj[k].push(v);
|
||||
} else {
|
||||
obj[k] = [obj[k], v];
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
123
jsdoc-master/rhino/rhino-shim.js
Normal file
123
jsdoc-master/rhino/rhino-shim.js
Normal file
@@ -0,0 +1,123 @@
|
||||
/*global env: true, Packages: true */
|
||||
/**
|
||||
* @overview A minimal emulation of the standard features of Node.js necessary
|
||||
* to get JSDoc to run.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Emulate DOM timeout/interval functions.
|
||||
* @see https://developer.mozilla.org/en-US/docs/DOM/window#Methods
|
||||
*/
|
||||
|
||||
setTimeout = null,
|
||||
clearTimeout = null,
|
||||
setInterval = null,
|
||||
clearInterval = null;
|
||||
|
||||
(function() {
|
||||
// TODO: tune number of threads if necessary
|
||||
var timerPool = new java.util.concurrent.ScheduledThreadPoolExecutor(10);
|
||||
var timers = {};
|
||||
var timerCount = 1;
|
||||
var timerUnits = java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
|
||||
function getCallback(fn) {
|
||||
return new java.lang.Runnable({
|
||||
run: Packages.org.mozilla.javascript.Context.call(fn)
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout = function(fn, delay) {
|
||||
var timerId = timerCount++;
|
||||
var callback = getCallback(fn);
|
||||
timers[timerId] = timerPool.schedule(callback, delay, timerUnits);
|
||||
return timerId;
|
||||
};
|
||||
|
||||
clearTimeout = function(timerId) {
|
||||
if (timers[timerId]) {
|
||||
timerPool.remove(timers[timerId]);
|
||||
delete timers[timerId];
|
||||
}
|
||||
};
|
||||
|
||||
setInterval = function(fn, delay) {
|
||||
var timerId = timerCount++;
|
||||
var callback = getCallback(fn);
|
||||
timers[timerId] = timerPool.scheduleAtFixedRate(callback, delay, delay, timerUnits);
|
||||
return timerId;
|
||||
};
|
||||
|
||||
clearInterval = clearTimeout;
|
||||
})();
|
||||
|
||||
/**
|
||||
* Emulate Node.js console functions.
|
||||
* @see http://nodejs.org/api/stdio.html
|
||||
*/
|
||||
console = (function() {
|
||||
function println(stream, args) {
|
||||
java.lang.System[stream].println( require('util').format.apply(this, args) );
|
||||
}
|
||||
|
||||
return {
|
||||
error: function() {
|
||||
println('err', arguments);
|
||||
},
|
||||
info: function() {
|
||||
println('out', arguments);
|
||||
},
|
||||
log: function() {
|
||||
println('out', arguments);
|
||||
},
|
||||
trace: function(label) {
|
||||
// this puts some extra junk at the top of the stack trace, but it's close enough
|
||||
var e = new java.lang.Exception(label || 'Trace');
|
||||
e.printStackTrace();
|
||||
},
|
||||
warn: function() {
|
||||
println('err', arguments);
|
||||
}
|
||||
};
|
||||
})();
|
||||
|
||||
/**
|
||||
* Emulate Node.js process functions.
|
||||
* @see http://nodejs.org/api/process.html
|
||||
*/
|
||||
process = {
|
||||
argv: [__dirname + '/jsdoc.js'].concat(Array.prototype.slice.call(arguments, 0)),
|
||||
cwd: function() {
|
||||
return new Packages.java.io.File('.').getCanonicalPath() + '';
|
||||
},
|
||||
env: (function() {
|
||||
var result = {};
|
||||
|
||||
var env = java.lang.System.getenv();
|
||||
var keys = env.keySet().toArray();
|
||||
var key;
|
||||
for (var i = 0, l = keys.length; i < l; i++) {
|
||||
key = keys[i];
|
||||
result[key + ''] = env.get(key) + '';
|
||||
}
|
||||
|
||||
return result;
|
||||
})(),
|
||||
exit: function(n) {
|
||||
n = n || 0;
|
||||
java.lang.System.exit(n);
|
||||
},
|
||||
nextTick: function(callback) {
|
||||
setTimeout(callback, 0);
|
||||
},
|
||||
stderr: {
|
||||
write: function(str) {
|
||||
java.lang.System.err.print(str);
|
||||
}
|
||||
},
|
||||
stdout: {
|
||||
write: function(str) {
|
||||
java.lang.System.out.print(str);
|
||||
}
|
||||
}
|
||||
};
|
561
jsdoc-master/rhino/util.js
Normal file
561
jsdoc-master/rhino/util.js
Normal file
@@ -0,0 +1,561 @@
|
||||
/**
|
||||
* Adapted version of Node.js' `util` module.
|
||||
* @module util
|
||||
* @see http://nodejs.org/api/util.html
|
||||
* @see https://github.com/joyent/node/blob/85090734/lib/util.js
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
function hasOwnProp(obj, prop) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, prop);
|
||||
}
|
||||
|
||||
|
||||
// placate JSHint
|
||||
var stylizeNoColor, stylizeWithColor, formatValue, formatPrimitive;
|
||||
|
||||
/**
|
||||
* Echoes the value of a value. Trys to print the value out
|
||||
* in the best way possible given the different types.
|
||||
*
|
||||
* @param {Object} obj The object to print out.
|
||||
* @param {Object} opts Optional options object that alters the output.
|
||||
*/
|
||||
/* legacy: obj, showHidden, depth, colors*/
|
||||
function inspect(obj, opts) {
|
||||
// default options
|
||||
var ctx = {
|
||||
seen: [],
|
||||
stylize: stylizeNoColor
|
||||
};
|
||||
// legacy...
|
||||
if (arguments.length >= 3) {
|
||||
ctx.depth = arguments[2];
|
||||
}
|
||||
if (arguments.length >= 4) {
|
||||
ctx.colors = arguments[3];
|
||||
}
|
||||
if (typeof opts === 'boolean') {
|
||||
// legacy...
|
||||
ctx.showHidden = opts;
|
||||
} else if (opts) {
|
||||
// got an "options" object
|
||||
exports._extend(ctx, opts);
|
||||
}
|
||||
// set default options
|
||||
if (typeof ctx.showHidden === 'undefined') {
|
||||
ctx.showHidden = false;
|
||||
}
|
||||
if (typeof ctx.depth === 'undefined') {
|
||||
ctx.depth = 2;
|
||||
}
|
||||
if (typeof ctx.colors === 'undefined') {
|
||||
ctx.colors = false;
|
||||
}
|
||||
if (typeof ctx.customInspect === 'undefined') {
|
||||
ctx.customInspect = true;
|
||||
}
|
||||
if (ctx.colors) {
|
||||
ctx.stylize = stylizeWithColor;
|
||||
}
|
||||
return formatValue(ctx, obj, ctx.depth);
|
||||
}
|
||||
exports.inspect = inspect;
|
||||
|
||||
|
||||
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
|
||||
inspect.colors = {
|
||||
'bold' : [1, 22],
|
||||
'italic' : [3, 23],
|
||||
'underline' : [4, 24],
|
||||
'inverse' : [7, 27],
|
||||
'white' : [37, 39],
|
||||
'grey' : [90, 39],
|
||||
'black' : [30, 39],
|
||||
'blue' : [34, 39],
|
||||
'cyan' : [36, 39],
|
||||
'green' : [32, 39],
|
||||
'magenta' : [35, 39],
|
||||
'red' : [31, 39],
|
||||
'yellow' : [33, 39]
|
||||
};
|
||||
|
||||
// Don't use 'blue' not visible on cmd.exe
|
||||
inspect.styles = {
|
||||
'special': 'cyan',
|
||||
'number': 'yellow',
|
||||
'boolean': 'yellow',
|
||||
'undefined': 'grey',
|
||||
'null': 'bold',
|
||||
'string': 'green',
|
||||
'date': 'magenta',
|
||||
// "name": intentionally not styling
|
||||
'regexp': 'red'
|
||||
};
|
||||
|
||||
|
||||
stylizeWithColor = function(str, styleType) {
|
||||
var style = inspect.styles[styleType];
|
||||
|
||||
if (style) {
|
||||
return '\u001b[' + inspect.colors[style][0] + 'm' + str +
|
||||
'\u001b[' + inspect.colors[style][1] + 'm';
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
stylizeNoColor = function(str, styleType) {
|
||||
return str;
|
||||
};
|
||||
|
||||
|
||||
var formatRegExp = /%[sdj%]/g;
|
||||
exports.format = function(f) {
|
||||
var i, len;
|
||||
|
||||
if (typeof f !== 'string') {
|
||||
var objects = [];
|
||||
for (i = 0, len = arguments.length; i < len; i++) {
|
||||
objects.push(inspect(arguments[i]));
|
||||
}
|
||||
return objects.join(' ');
|
||||
}
|
||||
|
||||
i = 1;
|
||||
var args = arguments;
|
||||
len = args.length;
|
||||
var str = String(f).replace(formatRegExp, function(x) {
|
||||
if (x === '%%') {
|
||||
return '%';
|
||||
}
|
||||
if (i >= len) {
|
||||
return x;
|
||||
}
|
||||
switch (x) {
|
||||
case '%s': return String(args[i++]);
|
||||
case '%d': return Number(args[i++]);
|
||||
case '%j': return require('jsdoc/util/dumper').dump(args[i++]);
|
||||
default:
|
||||
return x;
|
||||
}
|
||||
});
|
||||
for (var x = args[i]; i < len; x = args[++i]) {
|
||||
if (x === null || typeof x !== 'object') {
|
||||
str += ' ' + x;
|
||||
} else {
|
||||
str += ' ' + inspect(x);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
};
|
||||
|
||||
|
||||
// Mark that a method should not be used.
|
||||
// Returns a modified function which warns once by default.
|
||||
// If --no-deprecation is set, then it is a no-op.
|
||||
exports.deprecate = function(fn, msg) {
|
||||
if (process.noDeprecation === true) {
|
||||
return fn;
|
||||
}
|
||||
|
||||
var warned = false;
|
||||
function deprecated() {
|
||||
if (!warned) {
|
||||
if (process.traceDeprecation) {
|
||||
console.trace(msg);
|
||||
} else {
|
||||
console.error(msg);
|
||||
}
|
||||
warned = true;
|
||||
}
|
||||
return fn.apply(this, arguments);
|
||||
}
|
||||
|
||||
return deprecated;
|
||||
};
|
||||
|
||||
|
||||
exports.print = function() {
|
||||
var args = Array.prototype.slice.call(arguments, 0);
|
||||
for (var i = 0, len = args.length; i < len; ++i) {
|
||||
process.stdout.write(String(args[i]));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
exports.puts = function() {
|
||||
var args = Array.prototype.slice.call(arguments, 0);
|
||||
for (var i = 0, len = args.length; i < len; ++i) {
|
||||
process.stdout.write(args[i] + '\n');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
exports.debug = function(x) {
|
||||
process.stderr.write('DEBUG: ' + x + '\n');
|
||||
};
|
||||
|
||||
|
||||
var error = exports.error = function(x) {
|
||||
var args = Array.prototype.slice.call(arguments, 0);
|
||||
for (var i = 0, len = args.length; i < len; ++i) {
|
||||
process.stderr.write(args[i] + '\n');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function arrayToHash(array) {
|
||||
var hash = {};
|
||||
|
||||
array.forEach(function(val, idx) {
|
||||
hash[val] = true;
|
||||
});
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
||||
function formatError(value) {
|
||||
return '[' + Error.prototype.toString.call(value) + ']';
|
||||
}
|
||||
|
||||
|
||||
function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
|
||||
var name, str, desc;
|
||||
desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
|
||||
if (desc.get) {
|
||||
if (desc.set) {
|
||||
str = ctx.stylize('[Getter/Setter]', 'special');
|
||||
} else {
|
||||
str = ctx.stylize('[Getter]', 'special');
|
||||
}
|
||||
} else {
|
||||
if (desc.set) {
|
||||
str = ctx.stylize('[Setter]', 'special');
|
||||
}
|
||||
}
|
||||
if (!hasOwnProp(visibleKeys, key)) {
|
||||
name = '[' + key + ']';
|
||||
}
|
||||
if (!str) {
|
||||
if (ctx.seen.indexOf(desc.value) < 0) {
|
||||
if (recurseTimes === null) {
|
||||
str = formatValue(ctx, desc.value, null);
|
||||
} else {
|
||||
str = formatValue(ctx, desc.value, recurseTimes - 1);
|
||||
}
|
||||
if (str.indexOf('\n') > -1) {
|
||||
if (array) {
|
||||
str = str.split('\n').map(function(line) {
|
||||
return ' ' + line;
|
||||
}).join('\n').substr(2);
|
||||
} else {
|
||||
str = '\n' + str.split('\n').map(function(line) {
|
||||
return ' ' + line;
|
||||
}).join('\n');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
str = ctx.stylize('[Circular]', 'special');
|
||||
}
|
||||
}
|
||||
if (typeof name === 'undefined') {
|
||||
if (array && key.match(/^\d+$/)) {
|
||||
return str;
|
||||
}
|
||||
name = JSON.stringify('' + key);
|
||||
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
||||
name = name.substr(1, name.length - 2);
|
||||
name = ctx.stylize(name, 'name');
|
||||
} else {
|
||||
name = name.replace(/'/g, "\\'")
|
||||
.replace(/\\"/g, '"')
|
||||
.replace(/(^"|"$)/g, "'");
|
||||
name = ctx.stylize(name, 'string');
|
||||
}
|
||||
}
|
||||
|
||||
return name + ': ' + str;
|
||||
}
|
||||
|
||||
|
||||
function formatArray(ctx, value, recurseTimes, visibleKeys, keys) {
|
||||
var output = [];
|
||||
for (var i = 0, l = value.length; i < l; ++i) {
|
||||
if (hasOwnProp(value, String(i))) {
|
||||
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
||||
String(i), true));
|
||||
} else {
|
||||
output.push('');
|
||||
}
|
||||
}
|
||||
keys.forEach(function(key) {
|
||||
if (!key.match(/^\d+$/)) {
|
||||
output.push(formatProperty(ctx, value, recurseTimes, visibleKeys,
|
||||
key, true));
|
||||
}
|
||||
});
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
function reduceToSingleString(output, base, braces) {
|
||||
var numLinesEst = 0;
|
||||
var length = output.reduce(function(prev, cur) {
|
||||
numLinesEst++;
|
||||
if (cur.indexOf('\n') >= 0) {
|
||||
numLinesEst++;
|
||||
}
|
||||
return prev + cur.length + 1;
|
||||
}, 0);
|
||||
|
||||
if (length > 60) {
|
||||
return braces[0] +
|
||||
(base === '' ? '' : base + '\n ') +
|
||||
' ' +
|
||||
output.join(',\n ') +
|
||||
' ' +
|
||||
braces[1];
|
||||
}
|
||||
|
||||
return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
||||
}
|
||||
|
||||
|
||||
function objectToString(o) {
|
||||
return Object.prototype.toString.call(o);
|
||||
}
|
||||
|
||||
|
||||
// NOTE: These type checking functions intentionally don't use `instanceof`
|
||||
// because it is fragile and can be easily faked with `Object.create()`.
|
||||
function isArray(ar) {
|
||||
return Array.isArray(ar) ||
|
||||
(typeof ar === 'object' && objectToString(ar) === '[object Array]');
|
||||
}
|
||||
exports.isArray = isArray;
|
||||
|
||||
|
||||
function isRegExp(re) {
|
||||
return typeof re === 'object' && objectToString(re) === '[object RegExp]';
|
||||
}
|
||||
exports.isRegExp = isRegExp;
|
||||
|
||||
|
||||
function isDate(d) {
|
||||
return typeof d === 'object' && objectToString(d) === '[object Date]';
|
||||
}
|
||||
exports.isDate = isDate;
|
||||
|
||||
|
||||
function isError(e) {
|
||||
return typeof e === 'object' && objectToString(e) === '[object Error]';
|
||||
}
|
||||
exports.isError = isError;
|
||||
|
||||
|
||||
formatValue = function(ctx, value, recurseTimes) {
|
||||
// Provide a hook for user-specified inspect functions.
|
||||
// Check that value is an object with an inspect function on it
|
||||
if (ctx.customInspect && value && typeof value.inspect === 'function' &&
|
||||
// Filter out the util module, it's inspect function is special
|
||||
value.inspect !== exports.inspect &&
|
||||
// Also filter out any prototype objects using the circular check.
|
||||
!(value.constructor && value.constructor.prototype === value)) {
|
||||
return String(value.inspect(recurseTimes));
|
||||
}
|
||||
|
||||
// Primitive types cannot have properties
|
||||
var primitive = formatPrimitive(ctx, value);
|
||||
if (primitive) {
|
||||
return primitive;
|
||||
}
|
||||
|
||||
// Look up the keys of the object.
|
||||
var keys = Object.keys(value);
|
||||
var visibleKeys = arrayToHash(keys);
|
||||
|
||||
if (ctx.showHidden) {
|
||||
keys = Object.getOwnPropertyNames(value);
|
||||
}
|
||||
|
||||
// Some type of object without properties can be shortcutted.
|
||||
if (keys.length === 0) {
|
||||
if (typeof value === 'function') {
|
||||
var name = value.name ? ': ' + value.name : '';
|
||||
return ctx.stylize('[Function' + name + ']', 'special');
|
||||
}
|
||||
if (isRegExp(value)) {
|
||||
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
||||
}
|
||||
if (isDate(value)) {
|
||||
return ctx.stylize(Date.prototype.toString.call(value), 'date');
|
||||
}
|
||||
if (isError(value)) {
|
||||
return formatError(value);
|
||||
}
|
||||
}
|
||||
|
||||
var base = '', array = false, braces = ['{', '}'];
|
||||
|
||||
// Make Array say that they are Array
|
||||
if (isArray(value)) {
|
||||
array = true;
|
||||
braces = ['[', ']'];
|
||||
}
|
||||
|
||||
// Make functions say that they are functions
|
||||
if (typeof value === 'function') {
|
||||
var n = value.name ? ': ' + value.name : '';
|
||||
base = ' [Function' + n + ']';
|
||||
}
|
||||
|
||||
// Make RegExps say that they are RegExps
|
||||
if (isRegExp(value)) {
|
||||
base = ' ' + RegExp.prototype.toString.call(value);
|
||||
}
|
||||
|
||||
// Make dates with properties first say the date
|
||||
if (isDate(value)) {
|
||||
base = ' ' + Date.prototype.toUTCString.call(value);
|
||||
}
|
||||
|
||||
// Make error with message first say the error
|
||||
if (isError(value)) {
|
||||
base = ' ' + formatError(value);
|
||||
}
|
||||
|
||||
if (keys.length === 0 && (!array || value.length === 0)) {
|
||||
return braces[0] + base + braces[1];
|
||||
}
|
||||
|
||||
if (recurseTimes < 0) {
|
||||
if (isRegExp(value)) {
|
||||
return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp');
|
||||
} else {
|
||||
return ctx.stylize('[Object]', 'special');
|
||||
}
|
||||
}
|
||||
|
||||
ctx.seen.push(value);
|
||||
|
||||
var output;
|
||||
if (array) {
|
||||
output = formatArray(ctx, value, recurseTimes, visibleKeys, keys);
|
||||
} else {
|
||||
output = keys.map(function(key) {
|
||||
return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array);
|
||||
});
|
||||
}
|
||||
|
||||
ctx.seen.pop();
|
||||
|
||||
return reduceToSingleString(output, base, braces);
|
||||
};
|
||||
|
||||
|
||||
formatPrimitive = function(ctx, value) {
|
||||
switch (typeof value) {
|
||||
case 'undefined':
|
||||
return ctx.stylize('undefined', 'undefined');
|
||||
|
||||
case 'string':
|
||||
var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '')
|
||||
.replace(/'/g, "\\'")
|
||||
.replace(/\\"/g, '"') + '\'';
|
||||
return ctx.stylize(simple, 'string');
|
||||
|
||||
case 'number':
|
||||
return ctx.stylize('' + value, 'number');
|
||||
|
||||
case 'boolean':
|
||||
return ctx.stylize('' + value, 'boolean');
|
||||
}
|
||||
// For some reason typeof null is "object", so special case here.
|
||||
if (value === null) {
|
||||
return ctx.stylize('null', 'null');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
exports.p = exports.deprecate(function() {
|
||||
var args = Array.prototype.slice.call(arguments, 0);
|
||||
for (var i = 0, len = args.length; i < len; ++i) {
|
||||
error(exports.inspect(args[i]));
|
||||
}
|
||||
}, 'util.p: Use console.error() instead.');
|
||||
|
||||
|
||||
function pad(n) {
|
||||
return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
||||
}
|
||||
|
||||
|
||||
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
||||
'Oct', 'Nov', 'Dec'];
|
||||
|
||||
// 26 Feb 16:19:34
|
||||
function timestamp() {
|
||||
var d = new Date();
|
||||
var time = [pad(d.getHours()),
|
||||
pad(d.getMinutes()),
|
||||
pad(d.getSeconds())].join(':');
|
||||
return [d.getDate(), months[d.getMonth()], time].join(' ');
|
||||
}
|
||||
|
||||
|
||||
exports.log = function(msg) {
|
||||
exports.puts(timestamp() + ' - ' + msg.toString());
|
||||
};
|
||||
|
||||
|
||||
exports.exec = function() {
|
||||
throw new Error('util.exec() is not implemented on Rhino (and was deprecated in Node.js 0.2)');
|
||||
};
|
||||
|
||||
|
||||
exports.pump = function() {
|
||||
throw new Error('util.pump() is not implemented on Rhino (and was deprecated in Node.js 0.8');
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Inherit the prototype methods from one constructor into another.
|
||||
*
|
||||
* The Function.prototype.inherits from lang.js rewritten as a standalone
|
||||
* function (not on Function.prototype). NOTE: If this file is to be loaded
|
||||
* during bootstrapping this function needs to be rewritten using some native
|
||||
* functions as prototype setup using normal JavaScript does not work as
|
||||
* expected during bootstrapping (see mirror.js in r114903).
|
||||
*
|
||||
* @param {function} ctor Constructor function which needs to inherit the
|
||||
* prototype.
|
||||
* @param {function} superCtor Constructor function to inherit prototype from.
|
||||
*/
|
||||
exports.inherits = function(ctor, superCtor) {
|
||||
ctor.super_ = superCtor;
|
||||
ctor.prototype = Object.create(superCtor.prototype, {
|
||||
constructor: {
|
||||
value: ctor,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exports._extend = function(origin, add) {
|
||||
// Don't do anything if add isn't an object
|
||||
if (!add || typeof add !== 'object') {
|
||||
return origin;
|
||||
}
|
||||
|
||||
var keys = Object.keys(add);
|
||||
var i = keys.length;
|
||||
while (i--) {
|
||||
origin[keys[i]] = add[keys[i]];
|
||||
}
|
||||
return origin;
|
||||
};
|
Reference in New Issue
Block a user