@nativescript/core 8.2.0-custom.1 → 8.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/accessibility/accessibility-service.android.js +11 -9
  2. package/accessibility/accessibility-service.android.js.map +1 -1
  3. package/accessibility/index.android.js +16 -15
  4. package/accessibility/index.android.js.map +1 -1
  5. package/application/application-common.d.ts +2 -0
  6. package/application/application-common.js +2 -0
  7. package/application/application-common.js.map +1 -1
  8. package/application/index.android.d.ts +14 -1
  9. package/application/index.android.js +36 -2
  10. package/application/index.android.js.map +1 -1
  11. package/application/index.d.ts +37 -0
  12. package/application/index.ios.d.ts +7 -1
  13. package/application/index.ios.js +63 -14
  14. package/application/index.ios.js.map +1 -1
  15. package/color/color-common.js +4 -2
  16. package/color/color-common.js.map +1 -1
  17. package/config/config.interface.d.ts +9 -1
  18. package/connectivity/index.ios.js +1 -0
  19. package/connectivity/index.ios.js.map +1 -1
  20. package/css/parser.js +0 -1
  21. package/css/parser.js.map +1 -1
  22. package/debugger/webinspector-network.ios.js.map +1 -1
  23. package/file-system/file-system-access.android.d.ts +57 -1
  24. package/file-system/file-system-access.android.js +293 -0
  25. package/file-system/file-system-access.android.js.map +1 -1
  26. package/file-system/file-system-access.d.ts +73 -1
  27. package/file-system/index.js +18 -16
  28. package/file-system/index.js.map +1 -1
  29. package/global-types.d.ts +1 -0
  30. package/image-asset/index.ios.js +7 -12
  31. package/image-asset/index.ios.js.map +1 -1
  32. package/image-source/index.ios.js +20 -17
  33. package/image-source/index.ios.js.map +1 -1
  34. package/index.d.ts +8 -4
  35. package/index.js +14 -4
  36. package/index.js.map +1 -1
  37. package/module-name-resolver/qualifier-matcher/index.js +6 -4
  38. package/module-name-resolver/qualifier-matcher/index.js.map +1 -1
  39. package/package.json +44 -29
  40. package/platforms/android/res/values/ids.xml +4 -0
  41. package/platforms/android/widgets-release.aar +0 -0
  42. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/Info.plist +0 -0
  43. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/TNSWidgets.framework/TNSWidgets +0 -0
  44. package/platforms/ios/TNSWidgets.xcframework/ios-arm64/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  45. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/Info.plist +0 -0
  46. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/TNSWidgets +0 -0
  47. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/TNSWidgets.framework/_CodeSignature/CodeResources +1 -1
  48. package/platforms/ios/TNSWidgets.xcframework/ios-arm64_x86_64-simulator/dSYMs/TNSWidgets.framework.dSYM/Contents/Resources/DWARF/TNSWidgets +0 -0
  49. package/platforms/ios/src/NativeScriptUtils.h +16 -0
  50. package/platforms/ios/src/NativeScriptUtils.m +134 -0
  51. package/platforms/ios/src/UIView+NativeScript.h +13 -0
  52. package/platforms/ios/src/UIView+NativeScript.m +127 -0
  53. package/platforms/ios/src/module.modulemap +10 -0
  54. package/platforms/ios/typings/objc!NativeScriptUtils.d.ts +19 -0
  55. package/references.d.ts +5 -1
  56. package/ui/action-bar/index.android.d.ts +2 -0
  57. package/ui/action-bar/index.android.js +30 -1
  58. package/ui/action-bar/index.android.js.map +1 -1
  59. package/ui/animation/index.android.js +40 -62
  60. package/ui/animation/index.android.js.map +1 -1
  61. package/ui/animation/index.ios.js +10 -1
  62. package/ui/animation/index.ios.js.map +1 -1
  63. package/ui/animation/keyframe-animation.js +1 -2
  64. package/ui/animation/keyframe-animation.js.map +1 -1
  65. package/ui/builder/binding-builder.js +1 -1
  66. package/ui/builder/binding-builder.js.map +1 -1
  67. package/ui/button/button-common.js.map +1 -1
  68. package/ui/button/index.android.d.ts +2 -0
  69. package/ui/button/index.android.js +26 -0
  70. package/ui/button/index.android.js.map +1 -1
  71. package/ui/core/bindable/bindable-expressions.d.ts +7 -0
  72. package/ui/core/bindable/bindable-expressions.js +257 -0
  73. package/ui/core/bindable/bindable-expressions.js.map +1 -0
  74. package/ui/core/bindable/index.js +41 -33
  75. package/ui/core/bindable/index.js.map +1 -1
  76. package/ui/core/view/index.android.d.ts +5 -0
  77. package/ui/core/view/index.android.js +112 -9
  78. package/ui/core/view/index.android.js.map +1 -1
  79. package/ui/core/view/index.d.ts +10 -2
  80. package/ui/core/view/index.ios.d.ts +1 -0
  81. package/ui/core/view/index.ios.js +17 -3
  82. package/ui/core/view/index.ios.js.map +1 -1
  83. package/ui/core/view/view-common.d.ts +9 -2
  84. package/ui/core/view/view-common.js +47 -1
  85. package/ui/core/view/view-common.js.map +1 -1
  86. package/ui/core/view-base/index.d.ts +10 -0
  87. package/ui/core/view-base/index.js +5 -1
  88. package/ui/core/view-base/index.js.map +1 -1
  89. package/ui/date-picker/date-picker-common.d.ts +8 -0
  90. package/ui/date-picker/date-picker-common.js +25 -0
  91. package/ui/date-picker/date-picker-common.js.map +1 -1
  92. package/ui/date-picker/index.android.d.ts +2 -0
  93. package/ui/date-picker/index.android.js +30 -3
  94. package/ui/date-picker/index.android.js.map +1 -1
  95. package/ui/date-picker/index.ios.js +49 -8
  96. package/ui/date-picker/index.ios.js.map +1 -1
  97. package/ui/frame/fragment.android.js +3 -0
  98. package/ui/frame/fragment.android.js.map +1 -1
  99. package/ui/frame/fragment.transitions.android.d.ts +1 -0
  100. package/ui/frame/fragment.transitions.android.js +25 -28
  101. package/ui/frame/fragment.transitions.android.js.map +1 -1
  102. package/ui/frame/fragment.transitions.ios.js +3 -3
  103. package/ui/frame/frame-common.js.map +1 -1
  104. package/ui/frame/index.android.d.ts +1 -0
  105. package/ui/frame/index.android.js +45 -5
  106. package/ui/frame/index.android.js.map +1 -1
  107. package/ui/frame/index.d.ts +1 -0
  108. package/ui/frame/index.ios.js +8 -8
  109. package/ui/gestures/gestures-common.d.ts +6 -0
  110. package/ui/gestures/gestures-common.js +7 -0
  111. package/ui/gestures/gestures-common.js.map +1 -1
  112. package/ui/gestures/index.android.js +16 -6
  113. package/ui/gestures/index.android.js.map +1 -1
  114. package/ui/gestures/index.d.ts +21 -0
  115. package/ui/gestures/index.ios.js +9 -2
  116. package/ui/gestures/index.ios.js.map +1 -1
  117. package/ui/gestures/touch-manager.d.ts +53 -0
  118. package/ui/gestures/touch-manager.js +205 -0
  119. package/ui/gestures/touch-manager.js.map +1 -0
  120. package/ui/image/image-common.d.ts +1 -0
  121. package/ui/image/image-common.js +4 -0
  122. package/ui/image/image-common.js.map +1 -1
  123. package/ui/image/index.ios.d.ts +2 -0
  124. package/ui/image/index.ios.js +64 -27
  125. package/ui/image/index.ios.js.map +1 -1
  126. package/ui/index.d.ts +2 -2
  127. package/ui/index.js +1 -1
  128. package/ui/index.js.map +1 -1
  129. package/ui/layouts/root-layout/index.android.js +17 -2
  130. package/ui/layouts/root-layout/index.android.js.map +1 -1
  131. package/ui/layouts/root-layout/index.d.ts +2 -0
  132. package/ui/layouts/root-layout/index.ios.d.ts +3 -0
  133. package/ui/layouts/root-layout/index.ios.js +30 -9
  134. package/ui/layouts/root-layout/index.ios.js.map +1 -1
  135. package/ui/layouts/root-layout/root-layout-common.d.ts +5 -2
  136. package/ui/layouts/root-layout/root-layout-common.js +76 -62
  137. package/ui/layouts/root-layout/root-layout-common.js.map +1 -1
  138. package/ui/list-view/list-view-common.js.map +1 -1
  139. package/ui/page/page-common.js.map +1 -1
  140. package/ui/placeholder/index.android.js.map +1 -1
  141. package/ui/repeater/index.js.map +1 -1
  142. package/ui/scroll-view/index.android.js +2 -1
  143. package/ui/scroll-view/index.android.js.map +1 -1
  144. package/ui/scroll-view/scroll-view-common.js.map +1 -1
  145. package/ui/search-bar/search-bar-common.js.map +1 -1
  146. package/ui/segmented-bar/segmented-bar-common.js.map +1 -1
  147. package/ui/slider/slider-common.js.map +1 -1
  148. package/ui/styling/background-common.d.ts +1 -2
  149. package/ui/styling/background-common.js.map +1 -1
  150. package/ui/styling/background.android.d.ts +1 -3
  151. package/ui/styling/background.android.js +2 -124
  152. package/ui/styling/background.android.js.map +1 -1
  153. package/ui/styling/background.d.ts +60 -56
  154. package/ui/styling/background.ios.js +3 -34
  155. package/ui/styling/background.ios.js.map +1 -1
  156. package/ui/styling/css-animation-parser.js +1 -1
  157. package/ui/styling/css-animation-parser.js.map +1 -1
  158. package/ui/styling/css-selector/index.js +2 -2
  159. package/ui/styling/css-selector/index.js.map +1 -1
  160. package/ui/styling/font-common.js +5 -10
  161. package/ui/styling/font-common.js.map +1 -1
  162. package/ui/styling/font.ios.js +9 -91
  163. package/ui/styling/font.ios.js.map +1 -1
  164. package/ui/styling/linear-gradient.d.ts +7 -2
  165. package/ui/styling/linear-gradient.js.map +1 -1
  166. package/ui/styling/style-properties.js +3 -3
  167. package/ui/styling/style-properties.js.map +1 -1
  168. package/ui/switch/index.android.js +5 -2
  169. package/ui/switch/index.android.js.map +1 -1
  170. package/ui/switch/index.ios.d.ts +2 -0
  171. package/ui/switch/index.ios.js +61 -7
  172. package/ui/switch/index.ios.js.map +1 -1
  173. package/ui/switch/switch-common.js +6 -1
  174. package/ui/switch/switch-common.js.map +1 -1
  175. package/ui/tab-view/index.android.d.ts +1 -0
  176. package/ui/tab-view/index.android.js +23 -3
  177. package/ui/tab-view/index.android.js.map +1 -1
  178. package/ui/tab-view/index.d.ts +9 -0
  179. package/ui/tab-view/index.ios.d.ts +13 -3
  180. package/ui/tab-view/index.ios.js +47 -40
  181. package/ui/tab-view/index.ios.js.map +1 -1
  182. package/ui/tab-view/tab-view-common.d.ts +2 -0
  183. package/ui/tab-view/tab-view-common.js +2 -0
  184. package/ui/tab-view/tab-view-common.js.map +1 -1
  185. package/ui/text-base/index.android.js +19 -13
  186. package/ui/text-base/index.android.js.map +1 -1
  187. package/ui/text-base/index.ios.d.ts +7 -6
  188. package/ui/text-base/index.ios.js +69 -193
  189. package/ui/text-base/index.ios.js.map +1 -1
  190. package/ui/text-field/index.android.js +1 -1
  191. package/ui/text-field/index.android.js.map +1 -1
  192. package/ui/text-field/text-field-common.js.map +1 -1
  193. package/ui/time-picker/index.ios.js +1 -1
  194. package/ui/time-picker/index.ios.js.map +1 -1
  195. package/ui/utils.d.ts +31 -1
  196. package/ui/utils.ios.d.ts +16 -0
  197. package/ui/utils.ios.js +41 -0
  198. package/ui/utils.ios.js.map +1 -1
  199. package/ui/web-view/web-view-common.js.map +1 -1
  200. package/utils/index.d.ts +21 -0
  201. package/utils/native-helper.android.js +7 -1
  202. package/utils/native-helper.android.js.map +1 -1
  203. package/utils/utils-common.d.ts +3 -0
  204. package/utils/utils-common.js +30 -0
  205. package/utils/utils-common.js.map +1 -1
  206. package/js-libs/esprima/esprima.d.ts +0 -266
  207. package/js-libs/esprima/esprima.js +0 -1042
  208. package/js-libs/esprima/package.json +0 -75
  209. package/js-libs/polymer-expressions/package.json +0 -6
  210. package/js-libs/polymer-expressions/path-parser.js +0 -393
  211. package/js-libs/polymer-expressions/polymer-expressions.d.ts +0 -14
  212. package/js-libs/polymer-expressions/polymer-expressions.js +0 -541
  213. package/ui/styling/gradient.d.ts +0 -17
@@ -1,1042 +0,0 @@
1
- /*
2
- Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
3
- Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
4
- Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
5
- Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>
6
- Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
7
- Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>
8
- Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
9
- Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
10
- Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>
11
-
12
- Redistribution and use in source and binary forms, with or without
13
- modification, are permitted provided that the following conditions are met:
14
-
15
- * Redistributions of source code must retain the above copyright
16
- notice, this list of conditions and the following disclaimer.
17
- * Redistributions in binary form must reproduce the above copyright
18
- notice, this list of conditions and the following disclaimer in the
19
- documentation and/or other materials provided with the distribution.
20
-
21
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
- ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
25
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
- */
32
-
33
- (function (global) {
34
- 'use strict';
35
-
36
- var Token,
37
- TokenName,
38
- Syntax,
39
- Messages,
40
- source,
41
- index,
42
- length,
43
- delegate,
44
- lookahead,
45
- state;
46
-
47
- Token = {
48
- BooleanLiteral: 1,
49
- EOF: 2,
50
- Identifier: 3,
51
- Keyword: 4,
52
- NullLiteral: 5,
53
- NumericLiteral: 6,
54
- Punctuator: 7,
55
- StringLiteral: 8
56
- };
57
-
58
- TokenName = {};
59
- TokenName[Token.BooleanLiteral] = 'Boolean';
60
- TokenName[Token.EOF] = '<end>';
61
- TokenName[Token.Identifier] = 'Identifier';
62
- TokenName[Token.Keyword] = 'Keyword';
63
- TokenName[Token.NullLiteral] = 'Null';
64
- TokenName[Token.NumericLiteral] = 'Numeric';
65
- TokenName[Token.Punctuator] = 'Punctuator';
66
- TokenName[Token.StringLiteral] = 'String';
67
-
68
- Syntax = {
69
- ArrayExpression: 'ArrayExpression',
70
- BinaryExpression: 'BinaryExpression',
71
- CallExpression: 'CallExpression',
72
- ConditionalExpression: 'ConditionalExpression',
73
- EmptyStatement: 'EmptyStatement',
74
- ExpressionStatement: 'ExpressionStatement',
75
- Identifier: 'Identifier',
76
- Literal: 'Literal',
77
- LabeledStatement: 'LabeledStatement',
78
- LogicalExpression: 'LogicalExpression',
79
- MemberExpression: 'MemberExpression',
80
- ObjectExpression: 'ObjectExpression',
81
- Program: 'Program',
82
- Property: 'Property',
83
- ThisExpression: 'ThisExpression',
84
- UnaryExpression: 'UnaryExpression'
85
- };
86
-
87
- // Error messages should be identical to V8.
88
- Messages = {
89
- UnexpectedToken: 'Unexpected token %0',
90
- UnknownLabel: 'Undefined label \'%0\'',
91
- Redeclaration: '%0 \'%1\' has already been declared'
92
- };
93
-
94
- // Ensure the condition is true, otherwise throw an error.
95
- // This is only to have a better contract semantic, i.e. another safety net
96
- // to catch a logic error. The condition shall be fulfilled in normal case.
97
- // Do NOT use this to enforce a certain condition on any user input.
98
-
99
- function assert(condition, message) {
100
- if (!condition) {
101
- throw new Error('ASSERT: ' + message);
102
- }
103
- }
104
-
105
- function isDecimalDigit(ch) {
106
- return (ch >= 48 && ch <= 57); // 0..9
107
- }
108
-
109
-
110
- // 7.2 White Space
111
-
112
- function isWhiteSpace(ch) {
113
- return (ch === 32) || // space
114
- (ch === 9) || // tab
115
- (ch === 0xB) ||
116
- (ch === 0xC) ||
117
- (ch === 0xA0) ||
118
- (ch >= 0x1680 && '\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\uFEFF'.indexOf(String.fromCharCode(ch)) > 0);
119
- }
120
-
121
- // 7.3 Line Terminators
122
-
123
- function isLineTerminator(ch) {
124
- return (ch === 10) || (ch === 13) || (ch === 0x2028) || (ch === 0x2029);
125
- }
126
-
127
- // 7.6 Identifier Names and Identifiers
128
-
129
- function isIdentifierStart(ch) {
130
- return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
131
- (ch >= 65 && ch <= 90) || // A..Z
132
- (ch >= 97 && ch <= 122); // a..z
133
- }
134
-
135
- function isIdentifierPart(ch) {
136
- return (ch === 36) || (ch === 95) || // $ (dollar) and _ (underscore)
137
- (ch >= 65 && ch <= 90) || // A..Z
138
- (ch >= 97 && ch <= 122) || // a..z
139
- (ch >= 48 && ch <= 57); // 0..9
140
- }
141
-
142
- // 7.6.1.1 Keywords
143
-
144
- function isKeyword(id) {
145
- return (id === 'this')
146
- }
147
-
148
- // 7.4 Comments
149
-
150
- function skipWhitespace() {
151
- while (index < length && isWhiteSpace(source.charCodeAt(index))) {
152
- ++index;
153
- }
154
- }
155
-
156
- function getIdentifier() {
157
- var start, ch;
158
-
159
- start = index++;
160
- while (index < length) {
161
- ch = source.charCodeAt(index);
162
- if (isIdentifierPart(ch)) {
163
- ++index;
164
- } else {
165
- break;
166
- }
167
- }
168
-
169
- return source.slice(start, index);
170
- }
171
-
172
- function scanIdentifier() {
173
- var start, id, type;
174
-
175
- start = index;
176
-
177
- id = getIdentifier();
178
-
179
- // There is no keyword or literal with only one character.
180
- // Thus, it must be an identifier.
181
- if (id.length === 1) {
182
- type = Token.Identifier;
183
- } else if (isKeyword(id)) {
184
- type = Token.Keyword;
185
- } else if (id === 'null') {
186
- type = Token.NullLiteral;
187
- } else if (id === 'true' || id === 'false') {
188
- type = Token.BooleanLiteral;
189
- } else {
190
- type = Token.Identifier;
191
- }
192
-
193
- return {
194
- type: type,
195
- value: id,
196
- range: [start, index]
197
- };
198
- }
199
-
200
-
201
- // 7.7 Punctuators
202
-
203
- function scanPunctuator() {
204
- var start = index,
205
- code = source.charCodeAt(index),
206
- code2,
207
- ch1 = source[index],
208
- ch2;
209
-
210
- switch (code) {
211
-
212
- // Check for most common single-character punctuators.
213
- case 46: // . dot
214
- case 40: // ( open bracket
215
- case 41: // ) close bracket
216
- case 59: // ; semicolon
217
- case 44: // , comma
218
- case 123: // { open curly brace
219
- case 125: // } close curly brace
220
- case 91: // [
221
- case 93: // ]
222
- case 58: // :
223
- case 63: // ?
224
- ++index;
225
- return {
226
- type: Token.Punctuator,
227
- value: String.fromCharCode(code),
228
- range: [start, index]
229
- };
230
-
231
- default:
232
- code2 = source.charCodeAt(index + 1);
233
-
234
- // '=' (char #61) marks an assignment or comparison operator.
235
- if (code2 === 61) {
236
- switch (code) {
237
- case 37: // %
238
- case 38: // &
239
- case 42: // *:
240
- case 43: // +
241
- case 45: // -
242
- case 47: // /
243
- case 60: // <
244
- case 62: // >
245
- case 124: // |
246
- index += 2;
247
- return {
248
- type: Token.Punctuator,
249
- value: String.fromCharCode(code) + String.fromCharCode(code2),
250
- range: [start, index]
251
- };
252
-
253
- case 33: // !
254
- case 61: // =
255
- index += 2;
256
-
257
- // !== and ===
258
- if (source.charCodeAt(index) === 61) {
259
- ++index;
260
- }
261
- return {
262
- type: Token.Punctuator,
263
- value: source.slice(start, index),
264
- range: [start, index]
265
- };
266
- default:
267
- break;
268
- }
269
- }
270
- break;
271
- }
272
-
273
- // Peek more characters.
274
-
275
- ch2 = source[index + 1];
276
-
277
- // Other 2-character punctuators: && ||
278
-
279
- if (ch1 === ch2 && ('&|'.indexOf(ch1) >= 0)) {
280
- index += 2;
281
- return {
282
- type: Token.Punctuator,
283
- value: ch1 + ch2,
284
- range: [start, index]
285
- };
286
- }
287
-
288
- if ('<>=!+-*%&|^/'.indexOf(ch1) >= 0) {
289
- ++index;
290
- return {
291
- type: Token.Punctuator,
292
- value: ch1,
293
- range: [start, index]
294
- };
295
- }
296
-
297
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
298
- }
299
-
300
- // 7.8.3 Numeric Literals
301
- function scanNumericLiteral() {
302
- var number, start, ch;
303
-
304
- ch = source[index];
305
- assert(isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'),
306
- 'Numeric literal must start with a decimal digit or a decimal point');
307
-
308
- start = index;
309
- number = '';
310
- if (ch !== '.') {
311
- number = source[index++];
312
- ch = source[index];
313
-
314
- // Hex number starts with '0x'.
315
- // Octal number starts with '0'.
316
- if (number === '0') {
317
- // decimal number starts with '0' such as '09' is illegal.
318
- if (ch && isDecimalDigit(ch.charCodeAt(0))) {
319
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
320
- }
321
- }
322
-
323
- while (isDecimalDigit(source.charCodeAt(index))) {
324
- number += source[index++];
325
- }
326
- ch = source[index];
327
- }
328
-
329
- if (ch === '.') {
330
- number += source[index++];
331
- while (isDecimalDigit(source.charCodeAt(index))) {
332
- number += source[index++];
333
- }
334
- ch = source[index];
335
- }
336
-
337
- if (ch === 'e' || ch === 'E') {
338
- number += source[index++];
339
-
340
- ch = source[index];
341
- if (ch === '+' || ch === '-') {
342
- number += source[index++];
343
- }
344
- if (isDecimalDigit(source.charCodeAt(index))) {
345
- while (isDecimalDigit(source.charCodeAt(index))) {
346
- number += source[index++];
347
- }
348
- } else {
349
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
350
- }
351
- }
352
-
353
- if (isIdentifierStart(source.charCodeAt(index))) {
354
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
355
- }
356
-
357
- return {
358
- type: Token.NumericLiteral,
359
- value: parseFloat(number),
360
- range: [start, index]
361
- };
362
- }
363
-
364
- // 7.8.4 String Literals
365
-
366
- function scanStringLiteral() {
367
- var str = '', quote, start, ch, octal = false;
368
-
369
- quote = source[index];
370
- assert((quote === '\'' || quote === '"'),
371
- 'String literal must starts with a quote');
372
-
373
- start = index;
374
- ++index;
375
-
376
- while (index < length) {
377
- ch = source[index++];
378
-
379
- if (ch === quote) {
380
- quote = '';
381
- break;
382
- } else if (ch === '\\') {
383
- ch = source[index++];
384
- if (!ch || !isLineTerminator(ch.charCodeAt(0))) {
385
- switch (ch) {
386
- case 'n':
387
- str += '\n';
388
- break;
389
- case 'r':
390
- str += '\r';
391
- break;
392
- case 't':
393
- str += '\t';
394
- break;
395
- case 'b':
396
- str += '\b';
397
- break;
398
- case 'f':
399
- str += '\f';
400
- break;
401
- case 'v':
402
- str += '\x0B';
403
- break;
404
-
405
- default:
406
- str += ch;
407
- break;
408
- }
409
- } else {
410
- if (ch === '\r' && source[index] === '\n') {
411
- ++index;
412
- }
413
- }
414
- } else if (isLineTerminator(ch.charCodeAt(0))) {
415
- break;
416
- } else {
417
- str += ch;
418
- }
419
- }
420
-
421
- if (quote !== '') {
422
- throwError({}, Messages.UnexpectedToken, 'ILLEGAL');
423
- }
424
-
425
- return {
426
- type: Token.StringLiteral,
427
- value: str,
428
- octal: octal,
429
- range: [start, index]
430
- };
431
- }
432
-
433
- function isIdentifierName(token) {
434
- return token.type === Token.Identifier ||
435
- token.type === Token.Keyword ||
436
- token.type === Token.BooleanLiteral ||
437
- token.type === Token.NullLiteral;
438
- }
439
-
440
- function advance() {
441
- var ch;
442
-
443
- skipWhitespace();
444
-
445
- if (index >= length) {
446
- return {
447
- type: Token.EOF,
448
- range: [index, index]
449
- };
450
- }
451
-
452
- ch = source.charCodeAt(index);
453
-
454
- // Very common: ( and ) and ;
455
- if (ch === 40 || ch === 41 || ch === 58) {
456
- return scanPunctuator();
457
- }
458
-
459
- // String literal starts with single quote (#39) or double quote (#34).
460
- if (ch === 39 || ch === 34) {
461
- return scanStringLiteral();
462
- }
463
-
464
- if (isIdentifierStart(ch)) {
465
- return scanIdentifier();
466
- }
467
-
468
- // Dot (.) char #46 can also start a floating-point number, hence the need
469
- // to check the next character.
470
- if (ch === 46) {
471
- if (isDecimalDigit(source.charCodeAt(index + 1))) {
472
- return scanNumericLiteral();
473
- }
474
- return scanPunctuator();
475
- }
476
-
477
- if (isDecimalDigit(ch)) {
478
- return scanNumericLiteral();
479
- }
480
-
481
- return scanPunctuator();
482
- }
483
-
484
- function lex() {
485
- var token;
486
-
487
- token = lookahead;
488
- index = token.range[1];
489
-
490
- lookahead = advance();
491
-
492
- index = token.range[1];
493
-
494
- return token;
495
- }
496
-
497
- function peek() {
498
- var pos;
499
-
500
- pos = index;
501
- lookahead = advance();
502
- index = pos;
503
- }
504
-
505
- // Throw an exception
506
-
507
- function throwError(token, messageFormat) {
508
- var error,
509
- args = Array.prototype.slice.call(arguments, 2),
510
- msg = messageFormat.replace(
511
- /%(\d)/g,
512
- function (whole, index) {
513
- assert(index < args.length, 'Message reference must be in range');
514
- return args[index];
515
- }
516
- );
517
-
518
- error = new Error(msg);
519
- error.index = index;
520
- error.description = msg;
521
- throw error;
522
- }
523
-
524
- // Throw an exception because of the token.
525
-
526
- function throwUnexpected(token) {
527
- throwError(token, Messages.UnexpectedToken, token.value);
528
- }
529
-
530
- // Expect the next token to match the specified punctuator.
531
- // If not, an exception will be thrown.
532
-
533
- function expect(value) {
534
- var token = lex();
535
- if (token.type !== Token.Punctuator || token.value !== value) {
536
- throwUnexpected(token);
537
- }
538
- }
539
-
540
- // Return true if the next token matches the specified punctuator.
541
-
542
- function match(value) {
543
- return lookahead.type === Token.Punctuator && lookahead.value === value;
544
- }
545
-
546
- // Return true if the next token matches the specified keyword
547
-
548
- function matchKeyword(keyword) {
549
- return lookahead.type === Token.Keyword && lookahead.value === keyword;
550
- }
551
-
552
- function consumeSemicolon() {
553
- // Catch the very common case first: immediately a semicolon (char #59).
554
- if (source.charCodeAt(index) === 59) {
555
- lex();
556
- return;
557
- }
558
-
559
- skipWhitespace();
560
-
561
- if (match(';')) {
562
- lex();
563
- return;
564
- }
565
-
566
- if (lookahead.type !== Token.EOF && !match('}')) {
567
- throwUnexpected(lookahead);
568
- }
569
- }
570
-
571
- // 11.1.4 Array Initialiser
572
-
573
- function parseArrayInitialiser() {
574
- var elements = [];
575
-
576
- expect('[');
577
-
578
- while (!match(']')) {
579
- if (match(',')) {
580
- lex();
581
- elements.push(null);
582
- } else {
583
- elements.push(parseExpression());
584
-
585
- if (!match(']')) {
586
- expect(',');
587
- }
588
- }
589
- }
590
-
591
- expect(']');
592
-
593
- return delegate.createArrayExpression(elements);
594
- }
595
-
596
- // 11.1.5 Object Initialiser
597
-
598
- function parseObjectPropertyKey() {
599
- var token;
600
-
601
- skipWhitespace();
602
- token = lex();
603
-
604
- // Note: This function is called only from parseObjectProperty(), where
605
- // EOF and Punctuator tokens are already filtered out.
606
- if (token.type === Token.StringLiteral || token.type === Token.NumericLiteral) {
607
- return delegate.createLiteral(token);
608
- }
609
-
610
- return delegate.createIdentifier(token.value);
611
- }
612
-
613
- function parseObjectProperty() {
614
- var token, key;
615
-
616
- token = lookahead;
617
- skipWhitespace();
618
-
619
- if (token.type === Token.EOF || token.type === Token.Punctuator) {
620
- throwUnexpected(token);
621
- }
622
-
623
- key = parseObjectPropertyKey();
624
- expect(':');
625
- return delegate.createProperty('init', key, parseExpression());
626
- }
627
-
628
- function parseObjectInitialiser() {
629
- var properties = [];
630
-
631
- expect('{');
632
-
633
- while (!match('}')) {
634
- properties.push(parseObjectProperty());
635
-
636
- if (!match('}')) {
637
- expect(',');
638
- }
639
- }
640
-
641
- expect('}');
642
-
643
- return delegate.createObjectExpression(properties);
644
- }
645
-
646
- // 11.1.6 The Grouping Operator
647
-
648
- function parseGroupExpression() {
649
- var expr;
650
-
651
- expect('(');
652
-
653
- expr = parseExpression();
654
-
655
- expect(')');
656
-
657
- return expr;
658
- }
659
-
660
-
661
- // 11.1 Primary Expressions
662
-
663
- function parsePrimaryExpression() {
664
- var type, token, expr;
665
-
666
- if (match('(')) {
667
- return parseGroupExpression();
668
- }
669
-
670
- type = lookahead.type;
671
-
672
- if (type === Token.Identifier) {
673
- expr = delegate.createIdentifier(lex().value);
674
- } else if (type === Token.StringLiteral || type === Token.NumericLiteral) {
675
- expr = delegate.createLiteral(lex());
676
- } else if (type === Token.Keyword) {
677
- if (matchKeyword('this')) {
678
- lex();
679
- expr = delegate.createThisExpression();
680
- }
681
- } else if (type === Token.BooleanLiteral) {
682
- token = lex();
683
- token.value = (token.value === 'true');
684
- expr = delegate.createLiteral(token);
685
- } else if (type === Token.NullLiteral) {
686
- token = lex();
687
- token.value = null;
688
- expr = delegate.createLiteral(token);
689
- } else if (match('[')) {
690
- expr = parseArrayInitialiser();
691
- } else if (match('{')) {
692
- expr = parseObjectInitialiser();
693
- }
694
-
695
- if (expr) {
696
- return expr;
697
- }
698
-
699
- throwUnexpected(lex());
700
- }
701
-
702
- // 11.2 Left-Hand-Side Expressions
703
-
704
- function parseArguments() {
705
- var args = [];
706
-
707
- expect('(');
708
-
709
- if (!match(')')) {
710
- while (index < length) {
711
- args.push(parseExpression());
712
- if (match(')')) {
713
- break;
714
- }
715
- expect(',');
716
- }
717
- }
718
-
719
- expect(')');
720
-
721
- return args;
722
- }
723
-
724
- function parseNonComputedProperty() {
725
- var token;
726
-
727
- token = lex();
728
-
729
- if (!isIdentifierName(token)) {
730
- throwUnexpected(token);
731
- }
732
-
733
- return delegate.createIdentifier(token.value);
734
- }
735
-
736
- function parseNonComputedMember() {
737
- expect('.');
738
-
739
- return parseNonComputedProperty();
740
- }
741
-
742
- function parseComputedMember() {
743
- var expr;
744
-
745
- expect('[');
746
-
747
- expr = parseExpression();
748
-
749
- expect(']');
750
-
751
- return expr;
752
- }
753
-
754
- function parseLeftHandSideExpression() {
755
- var expr, args, property;
756
-
757
- expr = parsePrimaryExpression();
758
-
759
- while (true) {
760
- if (match('[')) {
761
- property = parseComputedMember();
762
- expr = delegate.createMemberExpression('[', expr, property);
763
- } else if (match('.')) {
764
- property = parseNonComputedMember();
765
- expr = delegate.createMemberExpression('.', expr, property);
766
- } else if (match('(')) {
767
- args = parseArguments();
768
- expr = delegate.createCallExpression(expr, args);
769
- } else {
770
- break;
771
- }
772
- }
773
-
774
- return expr;
775
- }
776
-
777
- // 11.3 Postfix Expressions
778
-
779
- var parsePostfixExpression = parseLeftHandSideExpression;
780
-
781
- // 11.4 Unary Operators
782
-
783
- function parseUnaryExpression() {
784
- var token, expr;
785
-
786
- if (lookahead.type !== Token.Punctuator && lookahead.type !== Token.Keyword) {
787
- expr = parsePostfixExpression();
788
- } else if (match('+') || match('-') || match('!')) {
789
- token = lex();
790
- expr = parseUnaryExpression();
791
- expr = delegate.createUnaryExpression(token.value, expr);
792
- } else if (matchKeyword('delete') || matchKeyword('void') || matchKeyword('typeof')) {
793
- throwError({}, Messages.UnexpectedToken);
794
- } else {
795
- expr = parsePostfixExpression();
796
- }
797
-
798
- return expr;
799
- }
800
-
801
- function binaryPrecedence(token) {
802
- var prec = 0;
803
-
804
- if (token.type !== Token.Punctuator && token.type !== Token.Keyword) {
805
- return 0;
806
- }
807
-
808
- switch (token.value) {
809
- case '||':
810
- prec = 1;
811
- break;
812
-
813
- case '&&':
814
- prec = 2;
815
- break;
816
-
817
- case '==':
818
- case '!=':
819
- case '===':
820
- case '!==':
821
- prec = 6;
822
- break;
823
-
824
- case '<':
825
- case '>':
826
- case '<=':
827
- case '>=':
828
- case 'instanceof':
829
- prec = 7;
830
- break;
831
-
832
- case 'in':
833
- prec = 7;
834
- break;
835
-
836
- case '+':
837
- case '-':
838
- prec = 9;
839
- break;
840
-
841
- case '*':
842
- case '/':
843
- case '%':
844
- prec = 11;
845
- break;
846
-
847
- default:
848
- break;
849
- }
850
-
851
- return prec;
852
- }
853
-
854
- // 11.5 Multiplicative Operators
855
- // 11.6 Additive Operators
856
- // 11.7 Bitwise Shift Operators
857
- // 11.8 Relational Operators
858
- // 11.9 Equality Operators
859
- // 11.10 Binary Bitwise Operators
860
- // 11.11 Binary Logical Operators
861
-
862
- function parseBinaryExpression() {
863
- var expr, token, prec, stack, right, operator, left, i;
864
-
865
- left = parseUnaryExpression();
866
-
867
- token = lookahead;
868
- prec = binaryPrecedence(token);
869
- if (prec === 0) {
870
- return left;
871
- }
872
- token.prec = prec;
873
- lex();
874
-
875
- right = parseUnaryExpression();
876
-
877
- stack = [left, token, right];
878
-
879
- while ((prec = binaryPrecedence(lookahead)) > 0) {
880
-
881
- // Reduce: make a binary expression from the three topmost entries.
882
- while ((stack.length > 2) && (prec <= stack[stack.length - 2].prec)) {
883
- right = stack.pop();
884
- operator = stack.pop().value;
885
- left = stack.pop();
886
- expr = delegate.createBinaryExpression(operator, left, right);
887
- stack.push(expr);
888
- }
889
-
890
- // Shift.
891
- token = lex();
892
- token.prec = prec;
893
- stack.push(token);
894
- expr = parseUnaryExpression();
895
- stack.push(expr);
896
- }
897
-
898
- // Final reduce to clean-up the stack.
899
- i = stack.length - 1;
900
- expr = stack[i];
901
- while (i > 1) {
902
- expr = delegate.createBinaryExpression(stack[i - 1].value, stack[i - 2], expr);
903
- i -= 2;
904
- }
905
-
906
- return expr;
907
- }
908
-
909
-
910
- // 11.12 Conditional Operator
911
-
912
- function parseConditionalExpression() {
913
- var expr, consequent, alternate;
914
-
915
- expr = parseBinaryExpression();
916
-
917
- if (match('?')) {
918
- lex();
919
- consequent = parseConditionalExpression();
920
- expect(':');
921
- alternate = parseConditionalExpression();
922
-
923
- expr = delegate.createConditionalExpression(expr, consequent, alternate);
924
- }
925
-
926
- return expr;
927
- }
928
-
929
- // Simplification since we do not support AssignmentExpression.
930
- var parseExpression = parseConditionalExpression;
931
-
932
- // Polymer Syntax extensions
933
-
934
- // Filter ::
935
- // Identifier
936
- // Identifier "(" ")"
937
- // Identifier "(" FilterArguments ")"
938
-
939
- function parseFilter() {
940
- var identifier, args;
941
-
942
- identifier = lex();
943
-
944
- if (identifier.type !== Token.Identifier) {
945
- throwUnexpected(identifier);
946
- }
947
-
948
- args = match('(') ? parseArguments() : [];
949
-
950
- return delegate.createFilter(identifier.value, args);
951
- }
952
-
953
- // Filters ::
954
- // "|" Filter
955
- // Filters "|" Filter
956
-
957
- function parseFilters() {
958
- while (match('|')) {
959
- lex();
960
- parseFilter();
961
- }
962
- }
963
-
964
- // TopLevel ::
965
- // LabelledExpressions
966
- // AsExpression
967
- // InExpression
968
- // FilterExpression
969
-
970
- // AsExpression ::
971
- // FilterExpression as Identifier
972
-
973
- // InExpression ::
974
- // Identifier, Identifier in FilterExpression
975
- // Identifier in FilterExpression
976
-
977
- // FilterExpression ::
978
- // Expression
979
- // Expression Filters
980
-
981
- function parseTopLevel() {
982
- skipWhitespace();
983
- peek();
984
-
985
- var expr = parseExpression();
986
- if (expr) {
987
- if (lookahead.value === ',' || lookahead.value == 'in' &&
988
- expr.type === Syntax.Identifier) {
989
- parseInExpression(expr);
990
- } else {
991
- parseFilters();
992
- if (lookahead.value === 'as') {
993
- parseAsExpression(expr);
994
- } else {
995
- delegate.createTopLevel(expr);
996
- }
997
- }
998
- }
999
-
1000
- if (lookahead.type !== Token.EOF) {
1001
- throwUnexpected(lookahead);
1002
- }
1003
- }
1004
-
1005
- function parseAsExpression(expr) {
1006
- lex(); // as
1007
- var identifier = lex().value;
1008
- delegate.createAsExpression(expr, identifier);
1009
- }
1010
-
1011
- function parseInExpression(identifier) {
1012
- var indexName;
1013
- if (lookahead.value === ',') {
1014
- lex();
1015
- if (lookahead.type !== Token.Identifier)
1016
- throwUnexpected(lookahead);
1017
- indexName = lex().value;
1018
- }
1019
-
1020
- lex(); // in
1021
- var expr = parseExpression();
1022
- parseFilters();
1023
- delegate.createInExpression(identifier.name, indexName, expr);
1024
- }
1025
-
1026
- function parse(code, inDelegate) {
1027
- delegate = inDelegate;
1028
- source = code;
1029
- index = 0;
1030
- length = source.length;
1031
- lookahead = null;
1032
- state = {
1033
- labelSet: {}
1034
- };
1035
-
1036
- return parseTopLevel();
1037
- }
1038
-
1039
- global.esprima = {
1040
- parse: parse
1041
- };
1042
- })(module.exports);