Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C2ECD18526 for ; Sat, 20 Jun 2015 19:33:29 +0000 (UTC) Received: (qmail 36984 invoked by uid 500); 20 Jun 2015 19:33:29 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 36896 invoked by uid 500); 20 Jun 2015 19:33:29 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 36591 invoked by uid 99); 20 Jun 2015 19:33:29 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 20 Jun 2015 19:33:29 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 0EA7EE3626; Sat, 20 Jun 2015 19:33:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: timb@apache.org To: commits@cordova.apache.org Date: Sat, 20 Jun 2015 19:33:37 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [10/16] cordova-browser git commit: Update 'cordova run browser' command to use cordova-serve module. http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/0044fe33/node_modules/cordova-serve/node_modules/d8/package.json ---------------------------------------------------------------------- diff --git a/node_modules/cordova-serve/node_modules/d8/package.json b/node_modules/cordova-serve/node_modules/d8/package.json new file mode 100644 index 0000000..8ac1f3d --- /dev/null +++ b/node_modules/cordova-serve/node_modules/d8/package.json @@ -0,0 +1,64 @@ +{ + "author": { + "name": "constantology", + "email": "christos@muigui.com", + "url": "http://muigui.com" + }, + "description": "d8 is a date parsing and formatting micro-framework for modern JavaScript engines.", + "dependencies": { + "m8": ">= 0.4.3" + }, + "devDependencies": { + "catn8": ">= 0.0.2", + "chai": ">= 1.2.0", + "mocha": ">= 1.4.2" + }, + "engines": { + "node": ">= 0.8.x" + }, + "keywords": [ + "date" + ], + "licenses": [ + { + "type": "MIT", + "url": "https://raw.github.com/constantology/d8/master/LICENSE" + } + ], + "main": "./d8", + "name": "d8", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/constantology/d8.git" + }, + "scripts": { + "test": "mocha -c --ignore-leaks -R spec -u tdd ./test/*.test.js" + }, + "version": "0.4.4", + "readme": "# d8.js [![build status](https://secure.travis-ci.org/constantology/d8.png)](http://travis-ci.org/constantology/d8)\n\nd8 is a date parsing and formatting micro-framework for modern JavaScript engines.\n\nd8 formats Dates into Strings and conversley turns Strings into Dates based on [php formatting options](http://php.net/manual/en/function.date.php).\n\nAs d8 extends JavaScript's native `Date` & `Date.prototype` – the CORRECT way – there is no actual global called d8. Instead all static and instance methods are available on the native `Date` & `Date.prototype` respectively.\n\ncurrently the only locales available are:\n\n- en-GB (0.9kb gzipped)\n- en-US (0.9kb gzipped)\n- GR (1.1kb gzipped) **this still needs some work as my Greek is — how you say — \"hella-rusty\"**\n\nbut feel free to create a locale for your specific nationality and submit a pull request! :D\n\n## File size\n\n- d8.js ≅ 8.8kb (gzipped)\n- d8.min.js ≅ 5.2kb (minzipped)\n\n## Dependenc ies\n\nd8.js only has one dependency [m8.js](/constantology/m8).\n\n**NOTE:**\nIf you are using d8 within a commonjs module, you don't need to require m8 before requiring d8 as this is done internally.\n\nAlso, since d8.js simply extends the Native Date Class, a reference to **m8 IS NOT** stored.\n\n## browser usage\n\n```html\n\n \n\n \n\n \n\n```\n\n## nodejs usage\n\n```javascript\n\n require( 'd8' );\n require( 'd8/locale/en-GB' ); // NOTE: This should now come after the actual library, since it is now possible to have use locales at once\n\n // if running in a sandboxed environment remember to:\n require( 'm8' ).x( Date/*[, Object, Array, Bool ean Function]*/ ); // and/ or any other Types that require extending.\n\n```\n\nAs mentioned above d8 extends JavaScript's native `Date` & `Date.prototype`, so when requiring d8, you don't need to assign it to a variable to use d8's features.\n\n## Support\n\nTested to work with nodejs, FF4+, Safari 5+, Chrome 7+, IE9+ and Opera — with one exception: `( new Date( [] ) ).valid() )` returns `true` in Opera and false in every other browser — technically **d8** should work in any JavaScript parser that supports [ecma 5]( http://kangax.github.com/es5-compat-table/) without throwing any JavaScript errors.\n\n## API\n\n### Static methods\n\n#### isLeapYear( year:String ):Boolean\nReturns true if the passed **4 digit** year is a leap year.\n\n**NOTE:** This method is located in the locale file. If your calendar system does not contain leap years, you can simply change the method to only `return false`.\n\n#### getOrdinal( date:Number ):String\nReturns the ordinal for a given date.\n\n## ### Example:\n\n```javascript\n\n Date.getOrdinal( 1 ); // returns => \"st\"\n Date.getOrdinal( 10 ); // returns => \"th\"\n Date.getOrdinal( 22 ); // returns => \"nd\"\n Date.getOrdinal( 33 ); // returns => \"rd\"\n\n```\n\n**NOTE:** Ordinals and the `getOrdinal` This method is located in the locale file. You can simply change the `ordinal` Array to your specific language; overwrite the `getOrdinal` method or both.\n\n#### setLeapYear( date:Date ):Void\nSets the inlcuded locale's February day count to the correct number of days, based on whether or not the date is a leap year or not.\n\n**NOTE:** This method is located in the locale file. If your calendar system does not contain leap years, you can simply change the method to do nothing.\n\n#### toDate( date:String, format:String ):Date\nTakes a date String and a format String based on the **Date formatting and parsing options** described below and returns a – hopefully – correct and valid Date.\n\n```javascrip t\n\n Date.toDate( 'Sunday, the 1st of January 2012', 'l, jS F Y' ); // returns => Date { Sun Jan 01 2012 00:00:00 GMT+0000 (GMT) }\n Date.toDate( '2012-01-01T00:00:00+00:00', Date.formats.ISO_8601 ); // returns => Date { Sun Jan 01 2012 00:00:00 GMT+0000 (GMT) }\n\n```\n\n### Static properties\n\n#### filters\nAn Object of all the available filters for formatting a Date.\n\n**IMPORTANT: Don't change these unless you know what you are doing!**\n\n#### formats\nAn Object containing some default date formats:\n\n\t\n\t\n\t\n\t\n\t\n
ISO_8601Y-m-dH:i:sP
ISO_8601_SHORTY-m-d
RFC_850l, d-M-y H:i:s T
RFC_2822D, d M Y H:i:s O
sortableY-m-d H:i:sO
\n\n### Instance methods\n\n#### adjust( interval:Object|String[, value:Num ber] ):Date\nYour one stop shop for all Date arithmetic. Adjusts the Date based on the passed `interval`, by the passed numeric `value`.\n\n**Note:** The method also accepts a single Object param where each key is the interval and each value is the number to adjust the Date by.\n\n**Valid intervals are:** year, month, week, day, hr, min, sec, ms.\n\n##### Example:\n\n```javascript\n\n var date = new Date( 2012, 0, 1 ); // Date {Sun Jan 01 2012 00:00:00 GMT+0000 (GMT)}\n\n date.adjust( Date.DAY, 1 ); // Date {Mon Jan 02 2012 00:00:00 GMT+0000 (GMT)}\n date.adjust( Date.HOUR, -1 ); // Date {Sun Jan 01 2012 23:00:00 GMT+0000 (GMT)}\n date.adjust( {\n year : -1, month : -1, day : 24,\n hr : 1, sec : -1\n } ); // Date {Sat Dec 25 2010 23:59:59 GMT+0000 (GMT)}\n\n```\n\n#### between( date_lower:Date, date_higher:Date ):Boolean\nChecks to see if the Date instance is in between the two passed Dates.\n\n##### Example:\ n\n```javascript\n\n var date = new Date( 2012, 0, 1 );\n\n date.between( new Date( 2011, 0, 1 ), new Date( 2013, 0, 1 ) ); // returns => true;\n\n date.between( new Date( 2013, 0, 1 ), new Date( 2011, 0, 1 ) ); // returns => false;\n\n```\n\n#### clearTime():Date\nClears the time from the Date instance.\n\n#### clone():Date\nReturns a clone of the current Date.\n\n#### diff( [date:Date, exclude:String] ):Object\nReturns an Object describing the difference between the Date instance and now — or the optionally passed Date.\n\nThe Object will contain any or all of the following properties:\n\n\n\t\n\t\t\n\t\n\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t\n\t\n
PropTypeDescription
tenseNumberThis will either be:\n\t\t\t
\n\t\t\t\t
-1
The Date instance is less than now or the pa ssed Date, i.e. in the past
\n\t\t\t\t
0
The Date instance is equal to now or the passed Date, i.e. in the present.
NOTE: If tense is 0 then the Object will most probably have no other properties, except value, which will be zero.
\n\t\t\t\t
1
The Date instance is greater than now or the passed Date, i.e. in the future
\n\t\t\t
\n\t\t\tNOTE: To make the diff Object's values easier to work with all other properties will be positive Numbers. You should use the tense property as your reference for the diff being in the past, present or future.\n\t\t
valueNumberThe — absolute — number of milliseconds difference between the two Dates.
yearsNumberTh e number of years the Date instance is ahead or behind the passed Date.
monthsNumberThe months of years the Date instance is ahead or behind the passed Date.
weeksNumberThe weeks of years the Date instance is ahead or behind the passed Date.
daysNumberThe days of years the Date instance is ahead or behind the passed Date.
hoursNumberThe hours of years the Date instance is ahead or behind the passed Date.
minutesNumberThe minutes of years the Date instance is ahead or behind the passed Date.
secondsNumberThe seco nds of years the Date instance is ahead or behind the passed Date.
millisecondsNumberThe milliseconds of years the Date instance is ahead or behind the passed Date.
\n\n**NOTE:** If any property — other than `tense` & `value` — is zero it will be omitted from the `diff` Object.\n\n\n##### Example:\n\n```javascript\n\n ( new Date( 2012, 0, 1 ) ).diff( new Date( 2012, 0, 1 ) ) // returns => { tense : 0 }\n\n ( new Date( 2012, 0, 1 ) ).diff( new Date( 2012, 0, 2 ) ) // returns => { tense : -1, value : 86400000, days : 1 }\n\n ( new Date( 2012, 0, 2 ) ).diff( new Date( 2012, 0, 1 ) ) // returns => { tense : 1, value : 86400000, days : 1 }\n\n ( new Date( 2012, 0, 1 ) ).diff( new Date( 2010, 9, 8, 7, 6, 5, 4 ) ) // returns => { tense : 1, value : 38858034996, years : 1, months : 2, weeks : 3, days : 3, hours : 17 , minutes : 53, seconds : 54, ms : 995 }\n\n```\n\n**NOTE:** You can supply a **space delimited** String defining which properties you want to exclude from the result and `diff` will either pass the current calculation to the next time unit or, if there are none will round off — up if over .5 or down if less, uses `Math.round` to figure this out — to the previous time unit.\n\nExclusion codes:\n- `-` will exclude the time unit from the `diff` Object.\n- `+` will include the time unit in the `diff` Object. **Note:** this is the same as not including the time unit in the `exclusions` String.\n- `>` will exclude all time units from this time unit down from the `diff` Object.\n\n##### Example with exclusions:\n\n```javascript\n\n ( new Date( 2012, 0, 1 ) ).diff( new Date( 2012, 0, 2 ), '-days' ) // returns => { tense : -1, value : 86400000, hours : 24 }\n\n ( new Date( 2012, 0, 2 ) ).diff( new Date( 2012, 0, 1 ), '-days' ) // returns => { tense : 1, value : 86400000, hours : 24 }\n\n ( new Date( 2012, 0, 1 ) ).diff( new Date( 2010, 9, 8, 7, 6, 5, 4 ), '-years -weeks >minutes' ) // returns => { tense : 1, value : 38858034996, months : 14, days : 29, hours : 18 }\n\n```\n\n#### format( format:String ):String\nReturns a string representation of the Date instance, based on the passed format. See the [Date formatting and parsing options](#date-formatting-and-parsing-options) below.\n\n##### Example:\n\n```javascript\n\n ( new Date( 2012, 0, 1 ) ).format( 'c' ); // returns => \"2012-01-01T00:00:00.000Z\"\n // which is a short hand format for:\n ( new Date( 2012, 0, 1 ) ).format( 'Y-m-dH:i:s.u' ); // returns => \"2012-01-01T00:00:00.000Z\"\n\n ( new Date( 2012, 0, 1 ) ).format( 'l, nS F Y' ) // returns => \"Sunday, the 1st of January 2012\"\n\n```\n\nYou can use predefined formats found in `Date.formats`. **Hint:** You can do:\n\n```javascript\ n\n console.dir( Date.formats );\n\n```\n\nwithin your browser's JavaScript console to see a list of available formats.\n\nPreviously used formats are also cached to save the overhead of having to create a `new Function` everytime you want to format a date.\n\n#### getDayOfYear():Number\nReturns the zero based day of the year.\n\n#### getFirstOfTheMonth():Date\nReturns a Date instance of the first day of this Date instance's month.\n\n#### getGMTOffset( [colon:Boolean] ):String\nReturns the Date instances offset from GMT.\n\n#### getISODay():Number\nReturns the ISO day of the week.\n\n#### getISODaysInYear():Number\nReturns the ISO number of days in the year.\n\n#### getISOFirstMondayOfYear():Date\nReturns the ISO first Monday of the year.\n\n#### getISOWeek():Number\nReturns the ISO week of the year\n\n#### getISOWeeksInYear():Number\nReturns the number of weeks in the ISO year.\n\n#### getLastOfTheMonth():Date\nReturns a Date instance of the last day of this Date instance's mon th.\n\n#### getWeek():Number\nReturns the week of the year, based on the `dayOfYear` divided by 7.\n\n##### Example:\n\n```javascript\n\n ( new Date( 2012, 0, 1 ) ).getWeek(); // returns => 0\n ( new Date( 2012, 2, 13 ) ).getWeek(); // returns => 10\n ( new Date( 2012, 11, 31 ) ).getWeek(); // returns => 52\n\n```\n\n#### isDST():Boolean\nReturns true if the Date instance is within daylight savings time.\n\n#### isLeapYear():Boolean\nReturns true if the Date instance is a leap year.\n\n#### lexicalize( [now:Date, format:String] ):String\nReturns a String representation of the difference between the date instance and now, or the passed `Date`.\n\n#### Available formats\nThe default format is `approx`, however this can be over-written by changing the **locale** file and/ or by passing in the desired format to the method.\n\n\n\t\n\t\n
approxWill return an approximate difference. e .g. about 2 days ago; almost 1 and a half years from now.
exactWill return the exact difference, e.g. 2 days 3 hours and 5 minutes ago; 1 year, 4 months, 2 weeks, 1 day, 5 hours, 3 minutes and 7 seconds from now.
\n\n##### Example:\n\n```javascript\n\n\tvar date = new Date( 2012, 0, 1 );\n\n\tdate.clone().adjust( { hr : -3, day : -2 } ).lexicalize( date, 'approx' ); // returns => \"just over 2 days ago\"\n\tdate.clone().adjust( { hr : -3, day : -2 } ).lexicalize( date, 'exact' ); // returns => \"2 days and 3 hours ago\"\n\n\tdate.lexicalize( date.clone().adjust( { hr : -6, day : -2 } ), 'approx' ); // returns => \"almost 2 and a half days from now\"\n\tdate.lexicalize( date.clone().adjust( { hr : -6, day : -2 } ), 'exact' ); // returns => \"2 days and 6 hours from now\"\n\n```\n\n#### setWeek():Number(UnixTimeStamp)\nSets the week of the year from the 1st January.\n\n##### Example:\n\n```javascript\n\n new Date( ( new Date( 20 12, 0, 1 ) ).setWeek( 17 ) ); // returns => Date {Sun Apr 29 2012 00:00:00 GMT+0100 (BST)}\n\n ( new Date( 2012, 2, 13 ) ).setWeek( 17 ); // returns => 1335654000000 same as above\n\n ( new Date( 2012, 11, 31 ) ).setWeek( 17 ); // returns => 1335654000000\n\n```\n\n#### timezone():String\nReturns the JavaScript engine's Date.prototype.toString() timezone abbreviation.\n\n## Date formatting and parsing options\n\n### escaping characters\n\nIf you want to escape characters that are used by the Date parser you can wrap them between <>.\n\n#### Example:\n\n```javascript\n\n ( new Date( 2012, 0, 1 ) ).format( 'l, jS F Y' ); // returns => \"Sunday, the 1st of January 2012\"\n\n```\n\n### day\n\n\t\n\t \n\t\n\t\n\t\n\t\n\t\n\t\n
dDay of the month, 2 digits with leading zeros
DA textual representation of a day, three letters
jDay of the month without leading zeros
lA full textual representation of the day of the week
NISO-8601 numeric representation of the day of the week
SEnglish ordinal suffix for the day of the month, 2 characters
wNumeric representation of the day of the week
zThe day of the year (starting from 0)
\n### week\n\n\t\n
WISO-8601 week number of year, weeks starting on Monday
\n### month\n\n\t\n\t\n\t\n\t\n\t\n
FA full textual representation of a month
mNumeric representation of a month, with leading zeros
MA short textual representation of a month, three letters
nNumeric representation of a month, without leading zeros
tNumber of days in the given month
\n### year\n\n\t\n\t\n\t\n\t\n
LWhether it's a leap year
oISO-8601 year number. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead.
YA full numeric representation of a year, 4 digits
yA two digit representation of a year
\n### time\n\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n\t\n
aLowercase Ante meridiem and Post meridiem
AUppercase Ante meridiem and Post meridiem
g12-hour format of an hour without leading zeros
G24-hour format of an hour without leading zeros
h12-hour format of an hour with leading zeros
H24-hour format of an hour with leading zeros
iMinutes with leading zeros
sSeconds, with leading zeros
uMilliseconds
\n### timezone\n\n\t\n\t\n\t\n\t\n
ODifference to Greenwich time (GMT) in hours
PDifference to Greenwich time (GMT) with colon between hours and minutes
TTimezone abbreviation
ZTimezone offset in seconds. The offset for timezones west of UTC is always negative, and for those east of UTC is always positive.
\n### full date/time\n\n\t\n\t\n\t\n
cISO 8601 date
rRFC 2822 formatted date
USeconds since the Unix Epoch January 1 1970 00:00:00 GMT
\n### custom\n\n\t\n\t\n
ethis is a convenience for `date.lexicalize( 'exact' );`
xthis is a convenience for `date.lexicalize( 'approx' );`
\n\n## License\n\n(The MIT License)\n\nCopyright © 2012 christos \"constantology\" constandinou http://muigui.com\n\nPermission is here by 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:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE 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 TH E SOFTWARE.\n", + "readmeFilename": "README.md", + "bugs": { + "url": "https://github.com/constantology/d8/issues" + }, + "_id": "d8@0.4.4", + "dist": { + "shasum": "5989dd62b90bdd853d3978f1261a4bc76bcf6485", + "tarball": "http://registry.npmjs.org/d8/-/d8-0.4.4.tgz" + }, + "_from": "d8@>=0.4.4 <0.5.0", + "_npmVersion": "1.2.25", + "_npmUser": { + "name": "constantology", + "email": "constantology@gmail.com" + }, + "maintainers": [ + { + "name": "constantology", + "email": "constantology@gmail.com" + } + ], + "directories": {}, + "_shasum": "5989dd62b90bdd853d3978f1261a4bc76bcf6485", + "_resolved": "https://registry.npmjs.org/d8/-/d8-0.4.4.tgz", + "homepage": "https://github.com/constantology/d8#readme" +} http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/0044fe33/node_modules/cordova-serve/node_modules/d8/src/_begin.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-serve/node_modules/d8/src/_begin.js b/node_modules/cordova-serve/node_modules/d8/src/_begin.js new file mode 100644 index 0000000..3cd310a --- /dev/null +++ b/node_modules/cordova-serve/node_modules/d8/src/_begin.js @@ -0,0 +1,3 @@ +;!function( util ) { + "use strict"; + util.x.cache( 'Date', function( Type ) { http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/0044fe33/node_modules/cordova-serve/node_modules/d8/src/_end.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-serve/node_modules/d8/src/_end.js b/node_modules/cordova-serve/node_modules/d8/src/_end.js new file mode 100644 index 0000000..11ffe79 --- /dev/null +++ b/node_modules/cordova-serve/node_modules/d8/src/_end.js @@ -0,0 +1,4 @@ + } ).x( Date ); +// at this point we don't know if util is available or not, and as such do not know what environment we are in. +// so, we check and do what is required. +}( typeof m8 != 'undefined' ? m8 : typeof require != 'undefined' ? require( 'm8' ) : null ); http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/0044fe33/node_modules/cordova-serve/node_modules/d8/src/coerce.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-serve/node_modules/d8/src/coerce.js b/node_modules/cordova-serve/node_modules/d8/src/coerce.js new file mode 100644 index 0000000..0c70010 --- /dev/null +++ b/node_modules/cordova-serve/node_modules/d8/src/coerce.js @@ -0,0 +1,103 @@ + function coerce( date_str, date_format ) { + return buildParser( date_format )( date_str ); + } + + function buildParser( date_format ) { + var LID = Type.locale.id, i, keys, l, parsers, part, parts, re; + + if ( cache_parse[LID][date_format] ) return cache_parse[LID][date_format]; + + parts = date_format.replace( re_add_nr, NOREPLACE_RB ).replace( re_add_enr, NOREPLACE_RE ).split( re_split ); + keys = []; i = -1; l = parts.length; parsers = {}; re = []; + + while ( ++i < l ) { + part = parts[i]; + if ( part == NOREPLACE ) { + re.push( parts[++i] ); ++i; + continue; + } + part.replace( re_compile, function( m, p1, p2, p3 ) { + var _fn, _k, _p; + if ( !( _p = parser[p2] ) ) return; + if ( _p.k ) { + keys.push( _p.k ); + if ( _p.fn ) parsers[_p.k] = _p.fn; + } + if ( _p.combo ) { + _k = _p.combo.pluck( 'k' ); + _fn = associate( _p.combo.pluck( 'fn' ), _k ); + keys.push.apply( keys, _k ); + util.copy( parsers, _fn, true ); + } + if ( _p.re ) re.push( p1, _p.re, p3 ); + } ); + } + return cache_parse[LID][date_format] = parse.bind( null, new RegExp( re.join( '' ) ), keys, parsers ); + } + + function parse( re, keys, fn, s ) { + var date = new Type( 0, 0, 1, 0, 0, 0, 0 ), parts = s.match( re ), + parsers = associate( parts.slice( 1 ), keys ); + + Object.reduce( parsers, function( n, v, k ) { + if ( typeof v == 'string' && fn[k] ) + parsers[k] = fn[k]( v, parsers ); + return n; + }, null ); + + if ( !isNaN( parsers[UNIX] ) ) date.setTime( parsers[UNIX] ); + else { + parse_setTime( date, parsers[HOUR], parsers[MINUTE], parsers[SECOND], parsers[MILLISECOND] ); + parse_setDate( date, parsers ); + parse_setTimezoneOffset( date, parsers[TIMEZONE] ); + } + + return date; + } + + function parse_setDate( date, parsers ) { + var L = Type.locale, dayweek, i = -1, l, leapyr, ordinal; + + if ( date_members.every( util.has.bind( null, parsers ) ) ) return; // only set the date if there's one to set (i.e. the format is not just for time) + + if ( isNaN( parsers[YEAR] ) ) parsers[YEAR] = date.getFullYear(); + + if ( isNaN( parsers[MONTH] ) ) { + leapyr = L.isLeapYear( parsers[YEAR] ) ? 1 : 0; + ordinal = L.ordinal_day_count[leapyr]; + l = ordinal.length; + parsers[MONTH] = 0; + + if ( parsers[WEEK] && !parsers[DAYYEAR] ) { // give precedence to the day of the year + dayweek = parsers[DAYWEEK]; + dayweek = isNaN( dayweek ) ? 0 : !dayweek ? 7 : dayweek; + parsers[DAYYEAR] = ( parsers[WEEK] * 7 ) - ( 4 - dayweek ); + } + + if ( !isNaN( parsers[DAYYEAR] ) ) { + if ( parsers[DAYYEAR] > ordinal[ordinal.length - 1] ) { + parsers[DAYYEAR] -= ordinal[ordinal.length - 1]; + ++parsers[YEAR]; + } + while( ++i < l ) { + if ( between_equalto( parsers[DAYYEAR], ordinal[i], ordinal[i+1] ) ) { + parsers[MONTH] = i; + parsers[DAY] = ordinal[i] == 0 ? parsers[DAYYEAR] : ( parsers[DAYYEAR] - ordinal[i] ); + break; + } + } + } + } + + if ( isNaN( parsers[DAY] ) ) parsers[DAY] = 1; + + date.setYear( parsers[YEAR] ); date.setMonth( parsers[MONTH] ); date.setDate( parsers[DAY] ); + + } + function parse_setTime( date, hr, min, sec, ms ) { + date.setHours( hr || 0 ); date.setMinutes( min || 0 ); + date.setSeconds( sec || 0 ); date.setMilliseconds( ms || 0 ); + } + function parse_setTimezoneOffset( date, tzoffset ) { + !between_equalto( tzoffset, -43200, 50400 ) || date.adjust( Type.SECOND, ( -date.getTimezoneOffset() * 60 ) - tzoffset ); + } http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/0044fe33/node_modules/cordova-serve/node_modules/d8/src/diff.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-serve/node_modules/d8/src/diff.js b/node_modules/cordova-serve/node_modules/d8/src/diff.js new file mode 100644 index 0000000..09f7595 --- /dev/null +++ b/node_modules/cordova-serve/node_modules/d8/src/diff.js @@ -0,0 +1,137 @@ + function diff( now, props ) { //noinspection FallthroughInSwitchStatementJS + switch ( util.ntype( now ) ) { + case 'number' : case 'string' : + if ( valid( new Type( now ) ) ) + now = new Type( now ); + else { + if ( !props ) props = now; + + now = Type.now(); + + break; + } // allow [specific] fall-through + case 'array' : case 'object' : + props = now; + now = Type.now(); + break; + case 'date' : if ( valid( new Type( +now ) ) ) break; // allow [conditional] fall-through if not a valid date + default : now = Type.now(); + + } + + var diff, + ms = +now - +this, + tense = ms < 0 ? 1 : ms > 0 ? -1 : 0; + + if ( !tense ) { + diff = util.obj(); + diff.value = 0; + } + else + diff = diff_get( Math.abs( ms ), diff_get_exclusions( props ) ); + + diff.tense = tense; + + return diff; + } + + function diff_eval( diff, calc, i, calcs ) { + var time; + if ( diff.__ms__ ) { + if ( !diff.excl[calc[0]] ) { + if ( diff.__ms__ >= calc[1] ) { + + time = diff.__ms__ / calc[1]; + + if ( !( calc[0] in diff.val ) ) { + diff.__ms__ = ( time % 1 ) * calc[1]; + diff.val[calc[0]] = Math.floor( time ); + } + else { + time = Math.floor( time ); + diff.__ms__ -= time * calc[1]; + diff.val[calc[0]] += time; + } + + } + return diff; + } +// round up or down depending on what's available + if ( ( !calcs[i + 1] || diff.excl[calcs[i + 1][0]] ) && ( calc = calcs[i - 1] ) ) { + time = diff.__ms__ / calc[1]; + diff.__ms__ = ( Math.round( time ) * calc[1] ) + ( ( ( diff.__ms__ / calcs[i][1] ) % 1 ) * calcs[i][1] ); + return diff_eval( diff, calc, i - 1, [] ); + } + return diff; + } + return diff; + } + + function diff_get( ms, excl ) { + var diff = time_map.reduce( diff_eval, { + __ms__ : ms, excl : excl, val : util.obj() + } ).val; + + diff.value = ms; + + return diff; + } + + function diff_get_exclusions( props ) { + var excl = util.obj(), incl_remaining = true; + + if ( props ) { //noinspection FallthroughInSwitchStatementJS + switch ( util.ntype( props ) ) { + case 'object' : incl_remaining = false; break; + case 'string' : props = props.split( ' ' ); // allow fall-through + case 'array' : props = props.reduce( diff_excl, excl ); + incl_remaining = !!util.len( excl ); + } + } + + time_props.map( function( prop ) { + if ( !( prop in this ) ) + this[prop] = !incl_remaining; + }, excl ); + + return excl; + } + + function diff_excl( excl, val ) { + var prop = ( val = String( val ).toLowerCase() ).substring( 1 ); + + switch ( val.charAt( 0 ) ) { + case '-' : excl[prop] = true; break; + case '+' : excl[prop] = false; break; + case '>' : + time_map.map( diff_excl_iter, { excl : excl, prop : prop, val : true } ); + break; + case '<' : + time_map.slice().reverse().map( diff_excl_iter, { excl : excl, prop : prop, val : false } ); + break; + default : excl[val] = false; + } + + return excl; + } + + function diff_excl_iter( calc ) { + if ( calc[0] === this.prop ) + this.SET_VALID = true; + if ( this.SET_VALID ) + this.excl[calc[0]] = this.val; + } + +// this ensures a diff's keys are always in descending order of +// number of milliseconds per unit of time, i.e. year, ..., millisecond + function diff_keys( diff ) { + diff = util.copy( diff ); util.remove( diff, 'tense', 'value' ); +// while this may seem like overkill, only having to run `indexOf` once for each sort item means that +// the overall performance is dramatically improved + return Object.keys( diff ).map( function( k ) { + return [time_props.indexOf( k ), k]; + } ).sort( function( a, b ) { + a = a[0]; b = b[0]; + return a > b ? 1 : -1; // skipping `===` check as we know all indexes are unique + } ).pluck( 1 ); + } http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/0044fe33/node_modules/cordova-serve/node_modules/d8/src/expose.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-serve/node_modules/d8/src/expose.js b/node_modules/cordova-serve/node_modules/d8/src/expose.js new file mode 100644 index 0000000..9eb9152 --- /dev/null +++ b/node_modules/cordova-serve/node_modules/d8/src/expose.js @@ -0,0 +1,27 @@ +// instance methods + util.defs( Type.prototype, { + adjust : adjust, between : between, clearTime : clearTime, + clone : clone, diff : diff, format : format, + getDayOfYear : getDayOfYear, getFirstOfTheMonth : getFirstOfTheMonth, getGMTOffset : getGMTOffset, + getISODay : getISODay, getISODaysInYear : getISODaysInYear, getISOFirstMondayOfYear : getISOFirstMondayOfYear, + getISOWeek : getISOWeek, getISOWeeksInYear : getISOWeeksInYear, getLastOfTheMonth : getLastOfTheMonth, + getWeek : getWeek, isDST : isDST, isLeapYear : isLeapYear, + lexicalize : lexicalize, setWeek : setWeek, timezone : timezone, + valid : function() { return Type.valid( this ); } + }, 'r' ); + +// static methods & properties + util.defs( Type, { +// constants used by Date.prototype.adjust + DAY : DAY, HOUR : 'hr', MINUTE : MINUTE.substring( 0, 3 ), + MILLISECOND : MILLISECOND, MONTH : MONTH, SECOND : SECOND.substring( 0, 3 ), + WEEK : WEEK, YEAR : YEAR, +// constants defining milliseconds for different times + MS_DAY : MS_DAY, MS_HOUR : MS_HOUR, MS_MINUTE : MS_MINUTE, MS_MONTH : MS_MONTH, + MS_SECOND : MS_SECOND, MS_WEEK : MS_WEEK, MS_YEAR : MS_YEAR, +// filters and formats + lexicon : { value : lexicon }, time_map : { value : time_map }, time_props : { value : time_props }, +// static methods + coerce : coerce, diffKeys : diff_keys, localize : localize, + toDate : coerce, valid : valid + }, 'r' ); http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/0044fe33/node_modules/cordova-serve/node_modules/d8/src/filters.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-serve/node_modules/d8/src/filters.js b/node_modules/cordova-serve/node_modules/d8/src/filters.js new file mode 100644 index 0000000..e9ecf7c --- /dev/null +++ b/node_modules/cordova-serve/node_modules/d8/src/filters.js @@ -0,0 +1,64 @@ + function localize_filters( L ) { + var F = { +// day + d : function( d ) { return pad( d.getDate(), 2 ); }, // Day of the month, 2 digits with leading zeros + D : function( d ) { return L.days[d.getDay()].substring( 0, 3 ); }, // A textual representation of a day, three letters + j : function( d ) { return d.getDate(); }, // Day of the month without leading zeros + l : function( d ) { return L.days[d.getDay()]; }, // A full textual representation of the day of the week + N : function( d ) { return getISODay.call( d ); }, // ISO-8601 numeric representation of the day of the week + S : function( d ) { return L.getOrdinal( d.getDate() ); }, // English ordinal suffix for the day of the month, 2 characters + w : function( d ) { return d.getDay(); }, // Numeric representation of the day of the week + z : function( d ) { return d.getDayOfYear(); }, // The day of the year (starting from 0) +// week + W : function( d ) { return getISOWeek.call( d ); }, // ISO-8601 week number of year, weeks starting on Monday +// month + F : function( d ) { return L.months[d.getMonth()]; }, // A full textual representation of a month + m : function( d ) { return pad( ( d.getMonth() + 1 ), 2 ); }, // Numeric representation of a month, with leading zeros + M : function( d ) { return L.months[d.getMonth()].substring( 0, 3 ); }, // A short textual representation of a month, three letters + n : function( d ) { return d.getMonth() + 1; }, // Numeric representation of a month, without leading zeros + t : function( d ) { // Number of days in the given month + L.setLeapYear( d ); + return L.day_count[d.getMonth()]; + }, +// year + L : function( d ) { return d.isLeapYear() ? 1 : 0; }, // Whether it's a leap year + o : function( d ) { // ISO-8601 year number. This has the same value as Y, except that if the ISO + var m = d.getMonth(), w = getISOWeek.call( d ); // week number (W) belongs to the previous or next year, that year is used instead. + return ( d.getFullYear() + ( w == 1 && m > 0 ? 1 : ( w >= 52 && m < 11 ? -1 : 0 ) ) ); + }, + Y : function( d ) { return d.getFullYear(); }, // A full numeric representation of a year, 4 digits + y : function( d ) { return String( d.getFullYear() ).substring( 2, 4 ); }, // A two digit representation of a year +// time + a : function( d ) { return _lc( d.getHours() < 12 ? L.AM : L.PM ); }, // Lowercase Ante meridiem and Post meridiem + A : function( d ) { return _uc( d.getHours() < 12 ? L.AM : L.PM ); }, // Uppercase Ante meridiem and Post meridiem + g : function( d ) { return d.getHours() % 12 || 12; }, // 12-hour format of an hour without leading zeros + G : function( d ) { return d.getHours(); }, // 24-hour format of an hour without leading zeros + h : function( d ) { return pad( filter.g( d ), 2 ); }, // 12-hour format of an hour with leading zeros + H : function( d ) { return pad( filter.G( d ), 2 ); }, // 24-hour format of an hour with leading zeros + i : function( d ) { return pad( d.getMinutes(), 2 ); }, // Minutes with leading zeros + s : function( d ) { return pad( d.getSeconds(), 2 ); }, // Seconds, with leading zeros + u : function( d ) { return pad( d.getMilliseconds(), 3 ); }, // Milliseconds +// timezone + O : function( d ) { return getGMTOffset.call( d ); }, // Difference to Greenwich time (GMT) in hours + P : function( d ) { return getGMTOffset.call( d, true ); }, // Difference to Greenwich time (GMT) with colon between hours and minutes + T : function( d ) { return timezone.call( d ); }, // Timezone abbreviation + Z : function( d ) { return d.getTimezoneOffset() * -60; }, // Timezone offset in seconds. The offset for timezones west of UTC + // is always negative, and for those east of UTC is always positive. +// full date/time + c : function( d ) { return format.call( d, formats.ISO_8601 ); }, // ISO 8601 date + r : function( d ) { return format.call( d, formats.RFC_2822 ); }, // RFC 2822 formatted date + U : function( d ) { return d.getTime(); }, // Seconds since the Unix Epoch January 1 1970 00:00:00 GMT + +// custom + e : function( d ) { return d.lexicalize( 'exact' ); }, // these are either self explanatory or you need serious help! + x : function( d ) { return d.lexicalize( 'approx' ); } // t(om )hanks you. + }; + + filter_chars = Object.keys( F ).sort().join( '' ); + + re_compile = new RegExp( '([^' + filter_chars + ']*)([' + filter_chars + '])([^' + filter_chars + ']*)', 'g' ); + + util.def( Type, 'filters', { value : filter = F }, 'w', true ); + + return F; + } http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/0044fe33/node_modules/cordova-serve/node_modules/d8/src/fns.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-serve/node_modules/d8/src/fns.js b/node_modules/cordova-serve/node_modules/d8/src/fns.js new file mode 100644 index 0000000..52f18f4 --- /dev/null +++ b/node_modules/cordova-serve/node_modules/d8/src/fns.js @@ -0,0 +1,111 @@ +// private methods + function _24hrTime( o, res ) { return ( o = Number( o ) ) < 12 && _lc( res.ampm ) == _lc( Type.locale.PM ) ? o += 12 : o; } + function _adjust( d, v, k ) { return d.adjust( k, v ); } + function _adjust_toobj( a ) { + return adjust_order.reduce( function( v, k, i ) { + var delta = parseFloat( a[i] ); + + if ( !isNaN( delta ) && delta !== 0 ) + v[k] = delta; + + return v; + }, util.obj() ); + } + function _dayOffset( d ) { return Math.floor( ( d - getISOFirstMondayOfYear.call( d ) ) / MS_DAY ); } + function _hours( d ) { return d.getHours() + ( d.isDST() ? 1 : 0 ); } + function _timezoneOffset( o ) { + if ( o == 'Z' ) { + o = '0000'; + } + var t = !!o.indexOf( '-' ), + m = o.match( re_tz_off ), + v = ( Number( m[1] ) + ( m[2] / 60 ) ) * 3600; + return t ? v : -v; + } + function _weekOffset( d ) { return Math.floor( Math.abs( _dayOffset( d ) / 7 ) ); } + function _zeroIndexedInt( o, k ) { return !isNaN( k ) ? k == o ? 0 : Number( k ) : Number( o ) - 1; } + +// public methods + + function adjust( o, v ) { + var date = this, day, fn, weekday; // noinspection FallthroughInSwitchStatementJS + switch ( util.ntype( o ) ) { + case 'number' : o = arguments; // allow fall-through + case 'array' : o = _adjust_toobj( o ); // allow fall-through + case 'object' : Object.reduce( o, _adjust, date ); break; + case 'string' : + fn = adjust_by[o.toLowerCase()]; + if ( fn && v !== 0 ) { + Type.locale.setLeapYear( date ); + + if ( fn == adjust_by.month ) { + day = date.getDate(); + day < 28 || date.setDate( Math.min( day, getLastOfTheMonth.call( getFirstOfTheMonth.call( date ).adjust( Type.MONTH, v ) ).getDate() ) ); + } + + fn != adjust_by.week || ( weekday = date.getDay() ); + + date[fn[1]]( date[fn[0]]() + v ); + + !weekday || date.setDate( date.getDate() + weekday ); + } + } + + return date; + } + + function between( l, h ) { return +this >= +l && +this <= +h; } + + function clearTime() { + this.setHours( 0 ); this.setMinutes( 0 ); this.setSeconds( 0 ); this.setMilliseconds( 0 ); + return this; + } + + function clone() { return new Type( this.getTime() ); } + + function getDayOfYear() { + var L = Type.locale; + L.setLeapYear( this ); + return L.day_count.slice( 0, this.getMonth() ).reduce( sum, 0 ) + this.getDate() - 1; + } + + function getFirstOfTheMonth() { return new Type( this.getFullYear(), this.getMonth(), 1 ); } + + function getGMTOffset( colon ) { + var tz = this.getTimezoneOffset(); + return [( tz > 0 ? '-' : '+' ), pad( Math.floor( Math.abs( tz ) / 60 ), 2 ), ( colon ? ':' : '' ), pad( Math.abs( tz % 60 ), 2 )].join( '' ); + } + + function getISODay() { return this.getDay() || 7; } + function getISODaysInYear() { return Math.ceil( ( getISOFirstMondayOfYear.call( new Type( this.getFullYear() + 1, 0, 1 ) ) - getISOFirstMondayOfYear.call( this ) ) / MS_DAY ); } + function getISOFirstMondayOfYear() { + var y = this.getFullYear(); + return new Type( y, 0, DAY_OFFSETS[new Type( y, 0, 1 ).getDay()] ); + } + function getISOWeek() { + var w, y = this.getFullYear(); + if ( this >= getISOFirstMondayOfYear.call( new Type( y + 1, 0, 1 ) ) ) return 1; + w = Math.floor( ( getDayOfYear.call( this ) - getISODay.call( this ) + 10 ) / 7 ); + return w == 0 ? getISOWeeksInYear.call( new Type( y - 1, 0, 1 ) ) - _weekOffset( this ) : w; + } + function getISOWeeksInYear() { return Math.round( ( getISOFirstMondayOfYear.call( new Type( this.getFullYear() + 1, 0, 1 ) ) - getISOFirstMondayOfYear.call( this ) ) / MS_WEEK ); } + + function getLastOfTheMonth() { + var L = Type.locale, m = this.getMonth(); L.setLeapYear( this ); + return new Type( this.getFullYear(), m, L.day_count[m] ); + } + + function getWeek() { return Math.floor( getDayOfYear.call( this ) / 7 ); } + + function isDST() { return new Type( this.getFullYear(), 0, 1 ).getTimezoneOffset() != this.getTimezoneOffset(); } + + function isLeapYear() { return Type.locale.isLeapYear( this.getFullYear() ); } + + function setWeek( v ) { this.setMonth( 0 ); this.setDate( 1 ); return ( this.adjust( Type.DAY, v * 7 ) ).getTime(); } + + function timezone() { + var s = this.toString().split( ' ' ); + return s.splice( 4, s.length ).join( ' ' ).replace( re_tz, '$1' ).replace( re_tz_abbr, '' ); + } + + function valid( date ) { return util.ntype( date ) == 'date' && !isNaN( +date ); } http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/0044fe33/node_modules/cordova-serve/node_modules/d8/src/format.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-serve/node_modules/d8/src/format.js b/node_modules/cordova-serve/node_modules/d8/src/format.js new file mode 100644 index 0000000..3ef3b79 --- /dev/null +++ b/node_modules/cordova-serve/node_modules/d8/src/format.js @@ -0,0 +1,28 @@ + function buildTemplate( date_format ) { + var LID = Type.locale.id, fn, i, l, part, parts, re_invalid; + + if ( cache_format[LID][date_format] ) return cache_format[LID][date_format]; + + fn = ['\tvar out=[];']; + parts = date_format.replace( re_add_nr, NOREPLACE_RB ).replace( re_add_enr, NOREPLACE_RE ).split( re_split ), + re_invalid = /^[^A-Za-z]*$/g; + i = -1; l = parts.length; + + while( ++i < l ) { + part = parts[i]; + part == NOREPLACE ? ( fn.push( tplOut( parts[++i] ) ), ++i ) + : re_invalid.test( part ) + ? fn.push( tplOut( part ) ) + : fn.push( compileTplStr( part ) ); + } + + fn.push( 'return out.join( "" );\n\t//@ sourceURL=d8/format/' + LID + '/' + date_format ); + + return cache_format[LID][date_format] = new Function( 'filter', 'date', fn.join( '\n\n\t' ) ); + } + + function format( f ) { return buildTemplate( f )( filter, this ); } + + function compileTplStr( o ) { return o.replace( re_compile, function( m, p0, p1, p2 ) { return tplOut( p0 + '\', filter.' + p1 + '( date ), \'' + p2 ); } ); } + + function tplOut( s ) { return 'out.push( \'' + s + '\' );'; } http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/0044fe33/node_modules/cordova-serve/node_modules/d8/src/formats.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-serve/node_modules/d8/src/formats.js b/node_modules/cordova-serve/node_modules/d8/src/formats.js new file mode 100644 index 0000000..70ffd46 --- /dev/null +++ b/node_modules/cordova-serve/node_modules/d8/src/formats.js @@ -0,0 +1,13 @@ + function localize_formats( L ) { + var F = util.copy( { + ISO_8601 : 'Y-m-dH:i:s.u', ISO_8601_SHORT : 'Y-m-d', + RFC_850 : 'l, d-M-y H:i:s T', RFC_2822 : 'D, d M Y H:i:s O', + sortable : 'Y-m-d H:i:sO' + }, L.formats ); + + F.atom = F.ISO_8601; F.cookie = F.RFC_850; F.rss = F.RFC_2822; + + util.def( Type, 'formats', { value : formats = F }, 'w', true ); + + return F; + } http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/0044fe33/node_modules/cordova-serve/node_modules/d8/src/lexicalize.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-serve/node_modules/d8/src/lexicalize.js b/node_modules/cordova-serve/node_modules/d8/src/lexicalize.js new file mode 100644 index 0000000..5bebea0 --- /dev/null +++ b/node_modules/cordova-serve/node_modules/d8/src/lexicalize.js @@ -0,0 +1,110 @@ + function lexicalize( now, precision ) { + if ( !valid( now ) ) { + if ( valid( new Type( now ) ) ) + now = new Type( now ); + else { + precision = now; + now = Type.now(); + } + } + + var LEX = Type.locale.lexicon; + + if ( typeof lexicon[precision = String( precision ).toLowerCase()] != 'function' ) + precision = LEX.DEFAULT; + + return !( +now - +this ) ? LEX.just_now : lexicon[precision].call( LEX, this, now ).replace( re_space, ' ' ); + } + + function lexicalize_approx( parts, diff ) { + return parts.join( ' ' ); + } + + function lexicalize_exact( parts, diff ) { + var last = parts.pop(); + + return ( parts.length ? parts.join( this.delim ) + ' ' + this.and + ' ' + last : last ) + ' ' + this[diff.tense < 1 ? 'ago' : 'from_now']; + } + + lexicon.approx = function( date, now ) { + var adverb, bal, determiner = this.a, + diff = date.diff( now ), + dkeys = Type.diffKeys( diff ), index, parts, tense, + tm = Type.time_map, tu = this.time_units, today, use_noun; + + if ( diff.value < Type.MS_MINUTE ) + return this.just_now; + + switch ( dkeys[0] ) { + case 'years' : index = 0; break; + case 'months' : index = 1; break; + case 'weeks' : index = 2; break; + case 'days' : if ( diff.days < 2 ) { + today = date.format( 'l' ) === now.format( 'l' ); + use_noun = today || dkeys[1] != 'hours' || diff.hours < 25; + } + index = 3; break; + case 'hours' : today = date.format( 'l' ) === now.format( 'l' ); + use_noun = diff.hours / 24 >= .75; + determiner = this.an; + index = 4; break; + case 'minutes' : index = 5; break; + } + + bal = ( diff.value - tm[index][1] * diff[dkeys[0]] ) / tm[index][1]; + + if ( use_noun ) + return today ? this.today : diff.tense > 0 ? this.tomorrow : this.yesterday; + + parts = []; + tense = diff.tense > 0 ? this.from_now : this.ago; + + if ( bal < .1 ) { //noinspection FallthroughInSwitchStatementJS + switch ( dkeys[0] ) { + case 'years' : case 'months' : case 'weeks' : + if ( diff[dkeys[0]] === 1 ) { + parts.push( ( diff.tense < 1 ? this.last : this.next ), tu[index][0] ); + break; + } // allow [conditional] fall-through + default : + !bal || parts.push( this.about ); + parts.push( diff[dkeys[0]], tu[index][diff[dkeys[0]] > 1 ? 1 : 0], tense ); + } + } + else { + if ( bal < .74 ) { + if ( bal < .24 ) + adverb = this.just_over; + else { + adverb = ( bal > .24 && bal < .4 ) ? this.almost : this.about; + parts.push( this.and, this.a, this.half ); + } + } + else + parts.push( this.almost, ( diff[dkeys[0]] + 1 ), tu[index][1], tense ); + } + + if ( adverb ) { + parts.push( tu[index][diff[dkeys[0]] > 1 || parts.length ? 1 : 0], tense ); + parts.unshift( adverb, diff[dkeys[0]] ); + } + + return typeof this.approx == 'function' ? this.approx.call( this, parts, diff ) : lexicalize_approx.call( this, parts, diff ); + }; + + lexicon.exact = function( date, now ) { + var diff = date.diff( now ), parts, tu = this.time_units; + + parts = Type.time_map.reduce( function( val, unit, i ) { + var v = diff[unit[0]]; + + !v || !tu[i] || val.push( v + ' ' + tu[i][v > 1 ? 1 : 0] ); + + return val; + }, [] ); + + if ( !parts.length ) + return this.just_now; + + return typeof this.exact == 'function' ? this.exact.call( this, parts, diff ) : lexicalize_exact.call( this, parts, diff ); + }; http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/0044fe33/node_modules/cordova-serve/node_modules/d8/src/localize.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-serve/node_modules/d8/src/localize.js b/node_modules/cordova-serve/node_modules/d8/src/localize.js new file mode 100644 index 0000000..65bcb36 --- /dev/null +++ b/node_modules/cordova-serve/node_modules/d8/src/localize.js @@ -0,0 +1,35 @@ + function localize( locale ) { //noinspection FallthroughInSwitchStatementJS + switch ( util.ntype( locale ) ) { + case 'object' : + if ( locale.id ) { + locales[locale.id] = locale; + break; + } // allow [conditional] fall-through + case 'string' : + if ( locale in locales ) { + locale = locales[locale]; + break; + } // allow [conditional] fall-through + default : locale = null; + } + + if ( util.ntype( locale ) == 'object' ) { + util.defs( Type, { + locale : { value : locale }, + getOrdinal : locale.getOrdinal, + isLeapYear : locale.isLeapYear, + setLeapYear : locale.setLeapYear + }, 'w', true ); + + if ( !( locale.id in cache_format ) ) + cache_format[locale.id] = util.obj(); + if ( !( locale.id in cache_parse ) ) + cache_parse[locale.id] = util.obj(); + + filter = localize_filters( locale ); + formats = localize_formats( locale ); + parser = localize_parsers( locale ); + } + + return Type; + } http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/0044fe33/node_modules/cordova-serve/node_modules/d8/src/parsers.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-serve/node_modules/d8/src/parsers.js b/node_modules/cordova-serve/node_modules/d8/src/parsers.js new file mode 100644 index 0000000..9759205 --- /dev/null +++ b/node_modules/cordova-serve/node_modules/d8/src/parsers.js @@ -0,0 +1,59 @@ + function localize_parsers( L ) { + var P = { + // day + d : { k : DAY, fn : Number, re : re_d2 }, + D : { k : DAYWEEK, fn : _indexOf.bind( null, L.days_short ), re : '(' + L.days_short.join( '|' ) + ')' }, + j : { k : DAY, fn : Number, re : re_d1_2 }, + l : { k : DAYWEEK, fn : _indexOf.bind( null, L.days ), re : '(' + L.days.join( '|' ) + ')' }, + N : { k : DAYWEEK, fn : _zeroIndexedInt.bind( null, 7 ), re : '([1-7])' }, + S : { re : '(?:' + L.ordinal.join( '|' ) + ')' }, + w : { k : DAYWEEK, fn : Number, re : '([0-6])' }, + z : { k : DAYYEAR, fn : Number, re : '([0-9]{1,3})' }, + // week + W : { k : WEEK, fn : Number, re : re_d2 }, + // month + F : { k : MONTH, fn : _indexOf.bind( null, L.months ), re : '(' + L.months.join( '|' ) + ')' }, + m : { k : MONTH, fn : _zeroIndexedInt, re : re_d2 }, + M : { k : MONTH, fn : _indexOf.bind( null, L.months_short ), re : '(' + L.months_short.join( '|' ) + ')' }, + n : { k : MONTH, fn : _zeroIndexedInt, re : re_d1_2 }, + t : { re : '[0-9]{2}' }, + // year + L : { re : '(?:0|1)' }, + o : { k : YEAR, fn : Number, re : re_d4 }, + Y : { k : YEAR, fn : Number, re : re_d4 }, + y : { k : YEAR, fn : function( o ) { + o = Number( o ); + return o += ( o < 30 ? 2000 : 1900 ); + }, re : re_d2 }, + // time + a : { k : AMPM, fn : util, re : re_ampm }, + A : { k : AMPM, fn : _lc, re : _uc( re_ampm ) }, + g : { k : HOUR, fn : _24hrTime, re : re_d1_2 }, + G : { k : HOUR, fn : Number, re : re_d1_2 }, + h : { k : HOUR, fn : _24hrTime, re : re_d2 }, + H : { k : HOUR, fn : Number, re : re_d2 }, + i : { k : MINUTE, fn : Number, re : re_d2 }, + s : { k : SECOND, fn : Number, re : re_d2 }, + u : { k : MILLISECOND, fn : Number, re : '([0-9]{1,})' }, + // timezone + O : { k : TIMEZONE, fn : _timezoneOffset, re : '([\\+-][0-9]{4})' }, + P : { k : TIMEZONE, fn : _timezoneOffset, re : '([\\+-][0-9]{2}:[0-9]{2})' }, + T : { re : '[A-Z]{1,4}' }, + Z : { k : TIMEZONE, fn : _timezoneOffset, re : '(Z|[\\+-]?[0-9]{2}:?[0-9]{2})' }, + // full date/time + U : { k : UNIX, fn : Number, re : '(-?[0-9]{1,})' } + }; + + P.c = { + combo : [P.Y, P.m, P.d, P.H, P.i, P.s, P.u, P.P], + re : [P.Y.re, '-', P.m.re, '-', P.d.re, 'T', P.H.re, ':', P.i.re, ':', P.s.re, '(?:\\.', P.u.re, '){0,1}', P.Z.re, '{0,1}'].join( '' ) + }; + P.r = { + combo : [P.D, P.d, P.M, P.Y, P.H, P.i, P.s, P.O], + re : [P.D.re, ', ', P.d.re, ' ', P.M.re, ' ', P.Y.re, ' ', P.H.re, ':', P.i.re, ':', P.s.re, ' ', P.O.re].join( '' ) + }; + + util.def( Type, 'parsers', { value : parser = P }, 'w', true ); + + return P; + } http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/0044fe33/node_modules/cordova-serve/node_modules/d8/src/utils.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-serve/node_modules/d8/src/utils.js b/node_modules/cordova-serve/node_modules/d8/src/utils.js new file mode 100644 index 0000000..6c56bd7 --- /dev/null +++ b/node_modules/cordova-serve/node_modules/d8/src/utils.js @@ -0,0 +1,13 @@ +// utility methods + function _indexOf( o, k ) { var i = o.indexOf( k ); return i == -1 ? null : i; } + function _lc( o ) { return o.toLocaleLowerCase(); } + function _uc( o ) { return o.toLocaleUpperCase(); } + function associate( o, k ) { return o.reduce( function( res, v, i ) { res[k[i]] = v; return res; }, {} ); } + function between_equalto( v, l, h ) { return l <= v && v <= h; } + function pad( o, len, radix ) { + var i = -1, s = o.toString( radix || 10 ); + len -= s.length; + while ( ++i < len ) s = '0' + s; + return s; + } + function sum( v, i ) { return v + i; } http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/0044fe33/node_modules/cordova-serve/node_modules/d8/src/vars.js ---------------------------------------------------------------------- diff --git a/node_modules/cordova-serve/node_modules/d8/src/vars.js b/node_modules/cordova-serve/node_modules/d8/src/vars.js new file mode 100644 index 0000000..cc6f052 --- /dev/null +++ b/node_modules/cordova-serve/node_modules/d8/src/vars.js @@ -0,0 +1,30 @@ + var U, +// DAY_OFFSETS is the amount of days from the current day to the Monday of the week it belongs to + DAY_OFFSETS = [9, 1, 0, -1, -2, 4, 3], MS_DAY = 864e5, MS_HOUR = 3600000, MS_MINUTE = 60000, + MS_MONTH = 2592e6, MS_SECOND = 1000, MS_WEEK = 6048e5, MS_YEAR = 31536e6, +// parser keys + AMPM = 'ampm', DAY = 'day', DAYWEEK = 'dayweek', DAYYEAR = 'dayyear', HOUR = 'hour', + MILLISECOND = 'ms', MINUTE = 'minute', MONTH = 'month', SECOND = 'second', TIMEZONE = 'timezone', + UNIX = 'unix', WEEK = 'week', YEAR = 'year', +// used by Date.prototype.format && Date.toDate to replace escaped chars + NOREPLACE = 'NOREPLACE', NOREPLACE_RB = '<' + NOREPLACE + '<', NOREPLACE_RE = '>END' + NOREPLACE + '>', + adjust_by = { day : ['getDate', 'setDate'], hr : ['getHours', 'setHours'], min : ['getMinutes', 'setMinutes'], month : ['getMonth', 'setMonth'], ms : ['getMilliseconds', 'setMilliseconds'], sec : ['getSeconds', 'setSeconds'], week : ['getWeek', 'setWeek'], year : ['getFullYear', 'setFullYear'] }, + adjust_order = [YEAR, MONTH, WEEK, DAY, 'hr', MINUTE.substring( 0, 3 ), SECOND.substring( 0, 3 ), MILLISECOND], +// cache objects + cache_format = util.obj(), cache_parse = util.obj(), date_members = [DAY, DAYWEEK, DAYYEAR, MONTH, WEEK, YEAR], + filter, filter_chars, formats, lexicon = util.obj(), locales = util.obj(), m, parser, + re_ampm = '(am|pm)', re_add_enr = />/g, re_add_nr = /]/, re_tz = /[^\(]*\(([^\)]+)\)/g, + re_tz_abbr = /[^A-Z]+/g, re_tz_off = /[\+-]?([0-9]{2}):?([0-9]{2})/, + time_map = [ // the order of this Array is important as it is the remainder of the larger + [YEAR + 's', MS_YEAR], // time unit that gets passed to the following time unit — as such we want + [MONTH + 's', MS_MONTH], // to keep the order in case we want to exclude time units from the diff + [WEEK + 's', MS_WEEK], + [DAY + 's', MS_DAY], + [HOUR + 's', MS_HOUR], + [MINUTE + 's', MS_MINUTE], + [SECOND + 's', MS_SECOND], + [MILLISECOND, 1] + ], + time_props = time_map.pluck( 0 ); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org