ice" spec="2.0.2" /> 100
+    <plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
101
+    <plugin name="cordova-plugin-ionic-webview" spec="^5.0.0" />
102
+    <plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
103
+</widget>

+ 4 - 1
ionic.config.json

@@ -1,7 +1,10 @@
1 1
 {
2 2
   "name": "farmr3",
3 3
   "integrations": {
4
-    "capacitor": {}
4
+    "capacitor": {
5
+      "enabled": false
6
+    },
7
+    "cordova": {}
5 8
   },
6 9
   "type": "angular"
7 10
 }

File diff suppressed because it is too large
+ 1698 - 17353
package-lock.json


+ 97 - 2
package.json

@@ -19,13 +19,43 @@
19 19
     "@angular/platform-browser": "~13.2.2",
20 20
     "@angular/platform-browser-dynamic": "~13.2.2",
21 21
     "@angular/router": "~13.2.2",
22
+    "@awesome-cordova-plugins/barcode-scanner": "^5.37.1",
23
+    "@awesome-cordova-plugins/core": "^5.37.1",
24
+    "@awesome-cordova-plugins/file-transfer": "^5.37.1",
25
+    "@awesome-cordova-plugins/native-geocoder": "^5.41.0",
26
+    "@awesome-cordova-plugins/push": "^5.37.1",
27
+    "@awesome-cordova-plugins/status-bar": "^5.37.2",
28
+    "@awesome-cordova-plugins/stripe": "^5.37.1",
22 29
     "@capacitor/app": "1.1.1",
23 30
     "@capacitor/core": "3.5.0",
24 31
     "@capacitor/haptics": "1.1.4",
32
+    "@capacitor/ios": "3.5.0",
25 33
     "@capacitor/keyboard": "1.2.2",
26 34
     "@capacitor/status-bar": "1.0.8",
35
+    "@fortawesome/angular-fontawesome": "^0.10.1",
36
+    "@fortawesome/fontawesome-free": "^5.15.4",
37
+    "@fortawesome/fontawesome-svg-core": "^1.2.36",
38
+    "@fortawesome/free-brands-svg-icons": "^5.15.4",
39
+    "@fortawesome/free-regular-svg-icons": "^5.15.4",
40
+    "@fortawesome/free-solid-svg-icons": "^5.15.4",
41
+    "@ionic-native/android-permissions": "^5.30.0",
42
+    "@ionic-native/call-number": "^5.36.0",
43
+    "@ionic-native/core": "^5.36.0",
44
+    "@ionic-native/device": "^5.30.0",
45
+    "@ionic-native/email-composer": "^5.36.0",
46
+    "@ionic-native/facebook": "^5.36.0",
47
+    "@ionic-native/geolocation": "^5.36.0",
48
+    "@ionic-native/http": "^5.36.0",
49
+    "@ionic-native/in-app-browser": "^5.36.0",
50
+    "@ionic-native/native-geocoder": "^5.36.0",
51
+    "@ionic-native/paypal": "^5.30.0",
52
+    "@ionic-native/push": "^5.36.0",
53
+    "@ionic-native/sign-in-with-apple": "^5.36.0",
54
+    "@ionic-native/uid": "^5.30.0",
27 55
     "@ionic/angular": "^6.0.0",
56
+    "@ionic/cordova-builders": "^6.1.0",
28 57
     "rxjs": "~6.6.0",
58
+    "sharp": "^0.30.4",
29 59
     "tslib": "^2.2.0",
30 60
     "zone.js": "~0.11.4"
31 61
   },
@@ -41,11 +71,36 @@
41 71
     "@angular/language-service": "~13.2.2",
42 72
     "@capacitor/cli": "3.5.0",
43 73
     "@ionic/angular-toolkit": "^6.0.0",
74
+    "@ionic/storage-angular": "^3.0.6",
44 75
     "@types/jasmine": "~3.6.0",
45 76
     "@types/jasminewd2": "~2.0.3",
46 77
     "@types/node": "^12.11.1",
47 78
     "@typescript-eslint/eslint-plugin": "5.3.0",
48 79
     "@typescript-eslint/parser": "5.3.0",
80
+    "cordova-ios": "^6.2.0",
81
+    "cordova-plugin-add-swift-support": "^2.0.2",
82
+    "cordova-plugin-advanced-http": "^3.2.2",
83
+    "cordova-plugin-android-permissions": "^1.1.2",
84
+    "cordova-plugin-androidx": "^3.0.0",
85
+    "cordova-plugin-androidx-adapter": "^1.1.3",
86
+    "cordova-plugin-device": "2.0.2",
87
+    "cordova-plugin-email-composer": "^0.10.0",
88
+    "cordova-plugin-facebook-connect": "^3.2.0",
89
+    "cordova-plugin-file": "^6.0.2",
90
+    "cordova-plugin-file-transfer": "^1.7.1",
91
+    "cordova-plugin-geolocation": "^4.1.0",
92
+    "cordova-plugin-googlemaps": "^2.7.1",
93
+    "cordova-plugin-googlemaps-sdk": "github:mapsplugin/cordova-plugin-googlemaps-sdk",
94
+    "cordova-plugin-inappbrowser": "^5.0.0",
95
+    "cordova-plugin-ionic-keyboard": "^2.2.0",
96
+    "cordova-plugin-ionic-webview": "^5.0.0",
97
+    "cordova-plugin-nativegeocoder": "^3.4.1",
98
+    "cordova-plugin-sign-in-with-apple": "^0.1.2",
99
+    "cordova-plugin-splashscreen": "5.0.2",
100
+    "cordova-plugin-statusbar": "2.4.2",
101
+    "cordova-plugin-stripe": "^1.5.3",
102
+    "cordova-plugin-uid": "^1.3.0",
103
+    "cordova-support-google-services": "^1.4.1",
49 104
     "eslint": "^7.6.0",
50 105
     "eslint-plugin-import": "2.22.1",
51 106
     "eslint-plugin-jsdoc": "30.7.6",
@@ -58,9 +113,49 @@
58 113
     "karma-coverage-istanbul-reporter": "~3.0.2",
59 114
     "karma-jasmine": "~4.0.0",
60 115
     "karma-jasmine-html-reporter": "^1.5.0",
116
+    "mx.ferreyra.callnumber": "0.0.2",
61 117
     "protractor": "~7.0.0",
62 118
     "ts-node": "~8.3.0",
63 119
     "typescript": "~4.4.4"
64 120
   },
65
-  "description": "An Ionic project"
66
-}
121
+  "description": "An Ionic project",
122
+  "cordova": {
123
+    "plugins": {
124
+      "cordova-plugin-statusbar": {},
125
+      "cordova-plugin-device": {},
126
+      "cordova-plugin-splashscreen": {},
127
+      "cordova-plugin-ionic-webview": {},
128
+      "cordova-plugin-ionic-keyboard": {},
129
+      "cordova-plugin-geolocation": {},
130
+      "cordova-plugin-nativegeocoder": {
131
+        "LOCATION_WHEN_IN_USE_DESCRIPTION": "Use geocoder service"
132
+      },
133
+      "mx.ferreyra.callnumber": {},
134
+      "cordova-plugin-email-composer": {},
135
+      "call-number": {},
136
+      "cordova-plugin-inappbrowser": {},
137
+      "cordova-plugin-sign-in-with-apple": {},
138
+      "cordova-plugin-androidx": {},
139
+      "cordova-plugin-androidx-adapter": {},
140
+      "phonegap-plugin-push": {},
141
+      "cordova-plugin-file-transfer": {},
142
+      "cordova-plugin-stripe": {},
143
+      "com.paypal.cordova.mobilesdk": {},
144
+      "cordova-plugin-facebook-connect": {
145
+        "APP_ID": "4746807965342529",
146
+        "APP_NAME": "FarmSter",
147
+        "FACEBOOK_URL_SCHEME_SUFFIX": " ",
148
+        "OTHER_APP_SCHEMES": " ",
149
+        "FACEBOOK_AUTO_LOG_APP_EVENTS": "true",
150
+        "FACEBOOK_HYBRID_APP_EVENTS": "false",
151
+        "FACEBOOK_ADVERTISER_ID_COLLECTION": "true",
152
+        "FACEBOOK_ANDROID_SDK_VERSION": "11.3.0",
153
+        "FACEBOOK_IOS_SDK_VERSION": "11.1.0",
154
+        "FACEBOOK_BROWSER_SDK_VERSION": "v11.0"
155
+      }
156
+    },
157
+    "platforms": [
158
+      "ios"
159
+    ]
160
+  }
161
+}

+ 8 - 0
resources/README.md

@@ -0,0 +1,8 @@
1
+These are Cordova resources. You can replace icon.png and splash.png and run
2
+`ionic cordova resources` to generate custom icons and splash screens for your
3
+app. See `ionic cordova resources --help` for details.
4
+
5
+Cordova reference documentation:
6
+
7
+- Icons: https://cordova.apache.org/docs/en/latest/config_ref/images.html
8
+- Splash Screens: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-splashscreen/

BIN
resources/android/icon/drawable-hdpi-icon.png


BIN
resources/android/icon/drawable-ldpi-icon.png


BIN
resources/android/icon/drawable-mdpi-icon.png


BIN
resources/android/icon/drawable-xhdpi-icon.png


BIN
resources/android/icon/drawable-xxhdpi-icon.png


BIN
resources/android/icon/drawable-xxxhdpi-icon.png


BIN
resources/android/splash/drawable-land-hdpi-screen.png


BIN
resources/android/splash/drawable-land-ldpi-screen.png


BIN
resources/android/splash/drawable-land-mdpi-screen.png


BIN
resources/android/splash/drawable-land-xhdpi-screen.png


BIN
resources/android/splash/drawable-land-xxhdpi-screen.png


BIN
resources/android/splash/drawable-land-xxxhdpi-screen.png


BIN
resources/android/splash/drawable-port-hdpi-screen.png


BIN
resources/android/splash/drawable-port-ldpi-screen.png


BIN
resources/android/splash/drawable-port-mdpi-screen.png


BIN
resources/android/splash/drawable-port-xhdpi-screen.png


BIN
resources/android/splash/drawable-port-xxhdpi-screen.png


BIN
resources/android/splash/drawable-port-xxxhdpi-screen.png


+ 7 - 0
resources/android/xml/network_security_config.xml

@@ -0,0 +1,7 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<network-security-config>
3
+    <domain-config cleartextTrafficPermitted="true">
4
+        <domain includeSubdomains="true">localhost</domain>
5
+        <domain includeSubdomains="true">tamtime.iamarray.xyz</domain>
6
+    </domain-config>
7
+</network-security-config>

BIN
resources/icon.png


BIN
resources/ios/icon/icon-1024.png


BIN
resources/ios/icon/icon-108@2x.png


BIN
resources/ios/icon/icon-20.png


BIN
resources/ios/icon/icon-20@2x.png


BIN
resources/ios/icon/icon-20@3x.png


BIN
resources/ios/icon/icon-24@2x.png


BIN
resources/ios/icon/icon-27.5@2x.png


BIN
resources/ios/icon/icon-29.png


BIN
resources/ios/icon/icon-29@2x.png


BIN
resources/ios/icon/icon-29@3x.png


BIN
resources/ios/icon/icon-40.png


BIN
resources/ios/icon/icon-40@2x.png


BIN
resources/ios/icon/icon-40@3x.png


BIN
resources/ios/icon/icon-44@2x.png


BIN
resources/ios/icon/icon-50.png


BIN
resources/ios/icon/icon-50@2x.png


BIN
resources/ios/icon/icon-60.png


BIN
resources/ios/icon/icon-60@2x.png


BIN
resources/ios/icon/icon-60@3x.png


BIN
resources/ios/icon/icon-72.png


BIN
resources/ios/icon/icon-72@2x.png


BIN
resources/ios/icon/icon-76.png


BIN
resources/ios/icon/icon-76@2x.png


BIN
resources/ios/icon/icon-83.5@2x.png


BIN
resources/ios/icon/icon-86@2x.png


BIN
resources/ios/icon/icon-98@2x.png


BIN
resources/ios/icon/icon.png


BIN
resources/ios/icon/icon@2x.png


BIN
resources/ios/splash/Default-1792h~iphone.png


BIN
resources/ios/splash/Default-2436h.png


BIN
resources/ios/splash/Default-2688h~iphone.png


BIN
resources/ios/splash/Default-568h@2x~iphone.png


BIN
resources/ios/splash/Default-667h.png


BIN
resources/ios/splash/Default-736h.png


BIN
resources/ios/splash/Default-Landscape-1792h~iphone.png


BIN
resources/ios/splash/Default-Landscape-2436h.png


BIN
resources/ios/splash/Default-Landscape-2688h~iphone.png


BIN
resources/ios/splash/Default-Landscape-736h.png


BIN
resources/ios/splash/Default-Landscape@2x~ipad.png


BIN
resources/ios/splash/Default-Landscape@~ipadpro.png


BIN
resources/ios/splash/Default-Landscape~ipad.png


BIN
resources/ios/splash/Default-Portrait@2x~ipad.png


BIN
resources/ios/splash/Default-Portrait@~ipadpro.png


BIN
resources/ios/splash/Default-Portrait~ipad.png


BIN
resources/ios/splash/Default@2x~iphone.png


BIN
resources/ios/splash/Default@2x~universal~anyany.png


BIN
resources/ios/splash/Default~iphone.png


BIN
resources/splash.png


+ 76 - 0
src/app/app-routing.module.ts

@@ -5,6 +5,82 @@ const routes: Routes = [
5 5
   {
6 6
     path: '',
7 7
     loadChildren: () => import('./tabs/tabs.module').then(m => m.TabsPageModule)
8
+  },
9
+  {
10
+    path: 'home',
11
+    loadChildren: () => import('./home/home.module').then( m => m.HomePageModule)
12
+  },
13
+  {
14
+    path: 'register',
15
+    loadChildren: () => import('./register/register.module').then( m => m.RegisterPageModule)
16
+  },
17
+  {
18
+    path: 'login',
19
+    loadChildren: () => import('./login/login.module').then( m => m.LoginPageModule)
20
+  },
21
+  {
22
+    path: 'forgot-password',
23
+    loadChildren: () => import('./forgot-password/forgot-password.module').then( m => m.ForgotPasswordPageModule)
24
+  },
25
+  {
26
+    path: 'register-form',
27
+    loadChildren: () => import('./register-form/register-form.module').then( m => m.RegisterFormPageModule)
28
+  },
29
+  {
30
+    path: 'profile',
31
+    loadChildren: () => import('./profile/profile.module').then( m => m.ProfilePageModule)
32
+  },
33
+  {
34
+    path: 'reset-password',
35
+    loadChildren: () => import('./reset-password/reset-password.module').then( m => m.ResetPasswordPageModule)
36
+  },
37
+  {
38
+    path: 'placedetail',
39
+    loadChildren: () => import('./placedetail/placedetail.module').then( m => m.PlacedetailPageModule)
40
+  },
41
+  {
42
+    path: 'place',
43
+    loadChildren: () => import('./place/place.module').then( m => m.PlacePageModule)
44
+  },
45
+  {
46
+    path: 'province',
47
+    loadChildren: () => import('./province/province.module').then( m => m.ProvincePageModule)
48
+  },
49
+  {
50
+    path: 'gmap',
51
+    loadChildren: () => import('./gmap/gmap.module').then( m => m.GmapPageModule)
52
+  },
53
+  {
54
+    path: 'nearme',
55
+    loadChildren: () => import('./nearme/nearme.module').then( m => m.NearmePageModule)
56
+  },
57
+  {
58
+    path: 'sample',
59
+    loadChildren: () => import('./sample/sample.module').then( m => m.SamplePageModule)
60
+  },
61
+  {
62
+    path: 'product',
63
+    loadChildren: () => import('./product/product.module').then( m => m.ProductPageModule)
64
+  },
65
+  {
66
+    path: 'product-detail',
67
+    loadChildren: () => import('./product-detail/product-detail.module').then( m => m.ProductDetailPageModule)
68
+  },
69
+  {
70
+    path: 'tracking',
71
+    loadChildren: () => import('./tracking/tracking.module').then( m => m.TrackingPageModule)
72
+  },
73
+  {
74
+    path: 'news',
75
+    loadChildren: () => import('./news/news.module').then( m => m.NewsPageModule)
76
+  },
77
+  {
78
+    path: 'checkout',
79
+    loadChildren: () => import('./checkout/checkout.module').then( m => m.CheckoutPageModule)
80
+  },
81
+  {
82
+    path: 'pay',
83
+    loadChildren: () => import('./pay/pay.module').then( m => m.PayPageModule)
8 84
   }
9 85
 ];
10 86
 @NgModule({

+ 4 - 0
src/app/app.component.scss

@@ -0,0 +1,4 @@
1
+.product-title {
2
+    font-weight:bold;
3
+    font-size:20px;
4
+}

+ 43 - 1
src/app/app.component.ts

@@ -1,4 +1,9 @@
1 1
 import { Component } from '@angular/core';
2
+import { Storage } from '@ionic/storage-angular';
3
+import { StatusBar } from '@awesome-cordova-plugins/status-bar/ngx';
4
+import { Uid } from '@ionic-native/uid/ngx';
5
+import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';
6
+
2 7
 
3 8
 @Component({
4 9
   selector: 'app-root',
@@ -6,5 +11,42 @@ import { Component } from '@angular/core';
6 11
   styleUrls: ['app.component.scss'],
7 12
 })
8 13
 export class AppComponent {
9
-  constructor() {}
14
+    constructor(private storage: Storage, private statusBar:StatusBar, private uid: Uid, private androidPermissions: AndroidPermissions) {
15
+
16
+        this.statusBar.overlaysWebView(true);
17
+
18
+
19
+    }
20
+    openQRCode() {
21
+        console.log("open QR Code");
22
+    }
23
+    async ngOnInit() {
24
+        // If using a custom driver:
25
+        // await this.storage.defineDriver(MyCustomDriver)
26
+        await this.storage.create();
27
+        //await this.getImei();
28
+    }
29
+    async getImei() {
30
+        const { hasPermission } = await this.androidPermissions.checkPermission(
31
+            this.androidPermissions.PERMISSION.READ_PHONE_STATE
32
+        );
33
+        console.log(hasPermission);
34
+
35
+        if (!hasPermission) {
36
+            const result = await this.androidPermissions.requestPermission(
37
+                this.androidPermissions.PERMISSION.READ_PHONE_STATE
38
+            );
39
+
40
+            if (!result.hasPermission) {
41
+                throw new Error('Permissions required');
42
+            }
43
+
44
+            // ok, a user gave us permission, we can get him identifiers after restart app
45
+            return;
46
+        }
47
+        console.log("UUID");
48
+        console.log(this.uid.UUID);
49
+        await this.storage.set('uid', this.uid.UUID);
50
+        return this.uid.IMEI
51
+    }
10 52
 }

+ 66 - 6
src/app/app.module.ts

@@ -7,11 +7,71 @@ import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
7 7
 import { AppRoutingModule } from './app-routing.module';
8 8
 import { AppComponent } from './app.component';
9 9
 
10
+import { HttpClientModule, HttpClient} from '@angular/common/http';
11
+
12
+// import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
13
+// import { library } from '@fortawesome/fontawesome-svg-core';
14
+import { FontAwesomeModule, FaIconLibrary } from '@fortawesome/angular-fontawesome';
15
+import { fas } from '@fortawesome/free-solid-svg-icons';
16
+import { far } from '@fortawesome/free-regular-svg-icons';
17
+import { fab } from '@fortawesome/free-brands-svg-icons';
18
+
19
+import { Geolocation } from '@ionic-native/geolocation/ngx';
20
+import { NativeGeocoder } from '@ionic-native/native-geocoder/ngx';
21
+
22
+import { CallNumber } from '@ionic-native/call-number/ngx';
23
+import { EmailComposer } from '@ionic-native/email-composer/ngx';
24
+import { HTTP } from '@ionic-native/http/ngx';
25
+import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
26
+
27
+import { IonicStorageModule } from '@ionic/storage-angular';
28
+import { SignInWithApple } from '@ionic-native/sign-in-with-apple/ngx';
29
+
30
+import { PipeModule } from './pipe/pipe.module';
31
+import { Facebook } from '@ionic-native/facebook/ngx';
32
+
33
+import { BarcodeScanner } from '@awesome-cordova-plugins/barcode-scanner/ngx';
34
+import { PayPal } from '@ionic-native/paypal/ngx';
35
+import { StatusBar } from '@awesome-cordova-plugins/status-bar/ngx';
36
+import { Uid } from '@ionic-native/uid/ngx';
37
+import { AndroidPermissions } from '@ionic-native/android-permissions/ngx';
38
+import { Device } from '@ionic-native/device/ngx';
39
+
40
+//import { Stripe } from '@awesome-cordova-plugins/stripe/ngx';
41
+
42
+
43
+// import { IonicImageViewerModule } from 'ionic-img-viewer';
44
+
45
+
46
+// library.add(fas,far,fab);
47
+
10 48
 @NgModule({
11
-  declarations: [AppComponent],
12
-  entryComponents: [],
13
-  imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
14
-  providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
15
-  bootstrap: [AppComponent],
49
+    declarations: [AppComponent],
50
+    entryComponents: [],
51
+    imports: [HttpClientModule, BrowserModule, PipeModule,IonicModule.forRoot({_forceStatusbarPadding: true}), AppRoutingModule, FontAwesomeModule,   IonicStorageModule.forRoot()],
52
+    providers: [
53
+        Geolocation,
54
+        NativeGeocoder,
55
+        CallNumber,
56
+        EmailComposer,
57
+        InAppBrowser,
58
+        HTTP,
59
+        Facebook, 
60
+        StatusBar,
61
+        BarcodeScanner,
62
+        SignInWithApple,
63
+        PayPal,
64
+        AndroidPermissions,
65
+        Uid,
66
+        Device,
67
+        //Stripe,
68
+        { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }
69
+    ],
70
+    bootstrap: [AppComponent],
16 71
 })
17
-export class AppModule {}
72
+export class AppModule {
73
+    constructor(library: FaIconLibrary) {
74
+        library.addIconPacks(fas, fab, far);
75
+    }
76
+
77
+}

+ 17 - 0
src/app/checkout/checkout-routing.module.ts

@@ -0,0 +1,17 @@
1
+import { NgModule } from '@angular/core';
2
+import { Routes, RouterModule } from '@angular/router';
3
+
4
+import { CheckoutPage } from './checkout.page';
5
+
6
+const routes: Routes = [
7
+  {
8
+    path: '',
9
+    component: CheckoutPage
10
+  }
11
+];
12
+
13
+@NgModule({
14
+  imports: [RouterModule.forChild(routes)],
15
+  exports: [RouterModule],
16
+})
17
+export class CheckoutPageRoutingModule {}

+ 20 - 0
src/app/checkout/checkout.module.ts

@@ -0,0 +1,20 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+import { FormsModule } from '@angular/forms';
4
+
5
+import { IonicModule } from '@ionic/angular';
6
+
7
+import { CheckoutPageRoutingModule } from './checkout-routing.module';
8
+
9
+import { CheckoutPage } from './checkout.page';
10
+
11
+@NgModule({
12
+  imports: [
13
+    CommonModule,
14
+    FormsModule,
15
+    IonicModule,
16
+    CheckoutPageRoutingModule
17
+  ],
18
+  declarations: [CheckoutPage]
19
+})
20
+export class CheckoutPageModule {}

+ 81 - 0
src/app/checkout/checkout.page.html

@@ -0,0 +1,81 @@
1
+<ion-header>
2
+  <ion-toolbar class='new-background-color'>
3
+    <ion-title>Checkout</ion-title>
4
+      <ion-buttons slot="end">
5
+          <ion-button (click)="dismiss()" color="light">
6
+            <ion-icon name="close-circle-outline"></ion-icon>
7
+          </ion-button>
8
+      </ion-buttons>
9
+  </ion-toolbar>
10
+</ion-header>
11
+
12
+<ion-content>
13
+    <ion-list>
14
+        <ion-list-header>
15
+            Recent Items
16
+        </ion-list-header>
17
+
18
+        <ion-item-sliding>
19
+            <ion-item>
20
+            <ion-avatar slot="start">
21
+                <img src="assets/images/fresh-durian.jpeg">
22
+            </ion-avatar>
23
+            <ion-label>
24
+                <h2>Durian</h2>
25
+                <p>Size M</p>
26
+            </ion-label>
27
+            <ion-label slot='end'>
28
+                3 * 100.00 = 
29
+            </ion-label>
30
+            <ion-label slot='end'>
31
+                300.00 THB
32
+            </ion-label>
33
+            </ion-item>
34
+            <ion-item-options side="end">
35
+                <ion-item-option (click)="unread(item)" color='danger'>Remove</ion-item-option>
36
+            </ion-item-options>
37
+        </ion-item-sliding>
38
+        <ion-item>
39
+            <ion-avatar slot="start">
40
+                <img src="assets/images/fresh-durian.jpeg">
41
+            </ion-avatar>
42
+            <ion-label>
43
+                <h2>Durian</h2>
44
+                <p>Size M</p>
45
+            </ion-label>
46
+            <ion-label slot='end'>
47
+                3 * 100 = 
48
+            </ion-label>
49
+            <ion-label slot='end'>
50
+                300.00 THB
51
+            </ion-label>
52
+        </ion-item>
53
+        <ion-item>
54
+            <ion-label slot="end">
55
+                <h2>Sub Total = </h2>
56
+            </ion-label>
57
+            <ion-label slot='end'>
58
+               600.00 THB
59
+            </ion-label>
60
+        </ion-item>
61
+        <ion-item>
62
+            <ion-label slot="end">
63
+                <h2>Vat 7%  = </h2>
64
+            </ion-label>
65
+            <ion-label slot='end'>
66
+               42.00 THB
67
+            </ion-label>
68
+        </ion-item>
69
+        <ion-item>
70
+            <ion-label slot="end">
71
+                <h2>Total = </h2>
72
+            </ion-label>
73
+            <ion-label slot='end'>
74
+               642.00 THB
75
+            </ion-label>
76
+        </ion-item>
77
+    </ion-list>
78
+    <ion-button expand="full" color="success" (click)="payWithPaypal()">Pay with PayPal</ion-button>
79
+
80
+
81
+</ion-content>

+ 0 - 0
src/app/checkout/checkout.page.scss


+ 24 - 0
src/app/checkout/checkout.page.spec.ts

@@ -0,0 +1,24 @@
1
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2
+import { IonicModule } from '@ionic/angular';
3
+
4
+import { CheckoutPage } from './checkout.page';
5
+
6
+describe('CheckoutPage', () => {
7
+  let component: CheckoutPage;
8
+  let fixture: ComponentFixture<CheckoutPage>;
9
+
10
+  beforeEach(waitForAsync(() => {
11
+    TestBed.configureTestingModule({
12
+      declarations: [ CheckoutPage ],
13
+      imports: [IonicModule.forRoot()]
14
+    }).compileComponents();
15
+
16
+    fixture = TestBed.createComponent(CheckoutPage);
17
+    component = fixture.componentInstance;
18
+    fixture.detectChanges();
19
+  }));
20
+
21
+  it('should create', () => {
22
+    expect(component).toBeTruthy();
23
+  });
24
+});

+ 56 - 0
src/app/checkout/checkout.page.ts

@@ -0,0 +1,56 @@
1
+import { Component, OnInit } from '@angular/core';
2
+import { ModalController, Platform } from '@ionic/angular';
3
+import { PayPal, PayPalPayment, PayPalConfiguration } from '@ionic-native/paypal/ngx';
4
+
5
+@Component({
6
+    selector: 'app-checkout',
7
+    templateUrl: './checkout.page.html',
8
+    styleUrls: ['./checkout.page.scss'],
9
+})
10
+export class CheckoutPage implements OnInit {
11
+
12
+    constructor(public modalController: ModalController, private payPal: PayPal) { }
13
+
14
+    ngOnInit() {
15
+    }
16
+
17
+    dismiss() {
18
+        // using the injected ModalController this page
19
+        // can "dismiss" itself and optionally pass back data
20
+        this.modalController.dismiss({
21
+            'dismissed': true
22
+        });
23
+    }
24
+
25
+    paymentAmount: string = '640';
26
+    currency: string = 'USD';
27
+    currencyIcon: string = 'USD';
28
+
29
+    payWithPaypal() {
30
+        this.payPal.init({
31
+            PayPalEnvironmentProduction: 'YOUR_PRODUCTION_CLIENT_ID',
32
+            PayPalEnvironmentSandbox: 'AVszPxWCuK3FGXKlgOCFu3gVXr8lFkKj9z1wUo9BYdestZbGRg5vDqWm_pqlLkhEu8KHsjP8NmfPhc_o'
33
+        }).then(() => {
34
+            // Environments: PayPalEnvironmentNoNetwork, PayPalEnvironmentSandbox, PayPalEnvironmentProduction
35
+            this.payPal.prepareToRender('PayPalEnvironmentSandbox', new PayPalConfiguration({
36
+                // Only needed if you get an "Internal Service Error" after PayPal login!
37
+                //payPalShippingAddressOption: 2 // PayPalShippingAddressOptionPayPal
38
+            })).then(() => {
39
+                let payment = new PayPalPayment(this.paymentAmount, this.currency, 'Description', 'sale');
40
+                this.payPal.renderSinglePaymentUI(payment).then((res) => {
41
+                    console.log(res);
42
+                    // Successfully paid
43
+                }, (error) => {
44
+                    console.log(error);
45
+                    // Error or render dialog closed without being successful
46
+                });
47
+            }, (error) => {
48
+                console.log(error);
49
+                // Error in configuration
50
+            });
51
+        }, (error) => {
52
+            console.log(error);
53
+            // Error in initialization, maybe PayPal isn't supported or something else
54
+        });
55
+    }
56
+}

+ 3 - 1
src/app/explore-container/explore-container.component.html

@@ -1,4 +1,6 @@
1 1
 <div id="container">
2 2
   <strong>{{ name }}</strong>
3 3
   <p>Explore <a target="_blank" rel="noopener noreferrer" href="https://ionicframework.com/docs/components">UI Components</a></p>
4
-</div>
4
+</div>
5
+<ion-title size="large">wellnessroute.info</ion-title>
6
+  <ion-title size="large">แผนที่สุขภาพ</ion-title>

+ 17 - 0
src/app/forgot-password/forgot-password-routing.module.ts

@@ -0,0 +1,17 @@
1
+import { NgModule } from '@angular/core';
2
+import { Routes, RouterModule } from '@angular/router';
3
+
4
+import { ForgotPasswordPage } from './forgot-password.page';
5
+
6
+const routes: Routes = [
7
+  {
8
+    path: '',
9
+    component: ForgotPasswordPage
10
+  }
11
+];
12
+
13
+@NgModule({
14
+  imports: [RouterModule.forChild(routes)],
15
+  exports: [RouterModule],
16
+})
17
+export class ForgotPasswordPageRoutingModule {}

+ 20 - 0
src/app/forgot-password/forgot-password.module.ts

@@ -0,0 +1,20 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+import { FormsModule } from '@angular/forms';
4
+
5
+import { IonicModule } from '@ionic/angular';
6
+
7
+import { ForgotPasswordPageRoutingModule } from './forgot-password-routing.module';
8
+
9
+import { ForgotPasswordPage } from './forgot-password.page';
10
+
11
+@NgModule({
12
+  imports: [
13
+    CommonModule,
14
+    FormsModule,
15
+    IonicModule,
16
+    ForgotPasswordPageRoutingModule
17
+  ],
18
+  declarations: [ForgotPasswordPage]
19
+})
20
+export class ForgotPasswordPageModule {}

+ 37 - 0
src/app/forgot-password/forgot-password.page.html

@@ -0,0 +1,37 @@
1
+<ion-header>
2
+  <ion-toolbar class="new-background-color">
3
+    <ion-buttons slot="end">
4
+      <ion-button (click)="dismiss()" color="light">ปิด</ion-button>
5
+    </ion-buttons>
6
+    <div class="hcs">
7
+      <img src="/assets/images/wellnessbar.svg" height="50" />    
8
+    </div>
9
+  </ion-toolbar>
10
+</ion-header>
11
+<ion-content>
12
+  <div><img src="/assets/images/image-006.jpg"></div>
13
+  <ion-grid>
14
+    <ion-row>
15
+      <ion-col>
16
+        <div class="ion-text-center">
17
+          <h1>ลืมรหัสผ่าน</h1>
18
+        </div>
19
+      </ion-col>
20
+    </ion-row>
21
+    <form>
22
+      <ion-row>
23
+        <ion-col>
24
+          <ion-item lines="full">
25
+            <ion-label position="floating">อีเมล์</ion-label>
26
+            <ion-input type="email" name="email" [(ngModel)]="email" inputmode="email"></ion-input>
27
+          </ion-item>
28
+        </ion-col>
29
+      </ion-row>
30
+      <ion-row>
31
+        <ion-col>
32
+          <ion-button type="submit" color="danger" expand="block" (click)="resetPassword()">ส่งรหัสผ่าน</ion-button>
33
+        </ion-col>
34
+      </ion-row>
35
+    </form>
36
+  </ion-grid>
37
+</ion-content>

+ 0 - 0
src/app/forgot-password/forgot-password.page.scss


+ 24 - 0
src/app/forgot-password/forgot-password.page.spec.ts

@@ -0,0 +1,24 @@
1
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2
+import { IonicModule } from '@ionic/angular';
3
+
4
+import { ForgotPasswordPage } from './forgot-password.page';
5
+
6
+describe('ForgotPasswordPage', () => {
7
+  let component: ForgotPasswordPage;
8
+  let fixture: ComponentFixture<ForgotPasswordPage>;
9
+
10
+  beforeEach(waitForAsync(() => {
11
+    TestBed.configureTestingModule({
12
+      declarations: [ ForgotPasswordPage ],
13
+      imports: [IonicModule.forRoot()]
14
+    }).compileComponents();
15
+
16
+    fixture = TestBed.createComponent(ForgotPasswordPage);
17
+    component = fixture.componentInstance;
18
+    fixture.detectChanges();
19
+  }));
20
+
21
+  it('should create', () => {
22
+    expect(component).toBeTruthy();
23
+  });
24
+});

+ 36 - 0
src/app/forgot-password/forgot-password.page.ts

@@ -0,0 +1,36 @@
1
+import { Component, OnInit } from '@angular/core';
2
+import { ModalController } from '@ionic/angular';
3
+import { WpServiceService } from '../wp-service.service';
4
+
5
+@Component({
6
+    selector: 'app-forgot-password',
7
+    templateUrl: './forgot-password.page.html',
8
+    styleUrls: ['./forgot-password.page.scss'],
9
+})
10
+export class ForgotPasswordPage implements OnInit {
11
+
12
+    email = "";
13
+
14
+    constructor(public modalController: ModalController, private wp:WpServiceService) { }
15
+
16
+    ngOnInit() {
17
+    }
18
+
19
+    async resetPassword() {
20
+        if( this.email == "" ) {
21
+            alert("Please Enter Valid Email");
22
+            return;
23
+        }
24
+        let r = await this.wp.resetPassword(this.email);
25
+        alert(r.msg);
26
+    }
27
+
28
+    dismiss() {
29
+        // using the injected ModalController this page
30
+        // can "dismiss" itself and optionally pass back data
31
+        this.modalController.dismiss({
32
+            'dismissed': true
33
+        });
34
+    }
35
+
36
+}

+ 17 - 0
src/app/gmap/gmap-routing.module.ts

@@ -0,0 +1,17 @@
1
+import { NgModule } from '@angular/core';
2
+import { Routes, RouterModule } from '@angular/router';
3
+
4
+import { GmapPage } from './gmap.page';
5
+
6
+const routes: Routes = [
7
+  {
8
+    path: '',
9
+    component: GmapPage
10
+  }
11
+];
12
+
13
+@NgModule({
14
+  imports: [RouterModule.forChild(routes)],
15
+  exports: [RouterModule],
16
+})
17
+export class GmapPageRoutingModule {}

+ 20 - 0
src/app/gmap/gmap.module.ts

@@ -0,0 +1,20 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+import { FormsModule } from '@angular/forms';
4
+
5
+import { IonicModule } from '@ionic/angular';
6
+
7
+import { GmapPageRoutingModule } from './gmap-routing.module';
8
+
9
+import { GmapPage } from './gmap.page';
10
+
11
+@NgModule({
12
+  imports: [
13
+    CommonModule,
14
+    FormsModule,
15
+    IonicModule,
16
+    GmapPageRoutingModule
17
+  ],
18
+  declarations: [GmapPage]
19
+})
20
+export class GmapPageModule {}

+ 9 - 0
src/app/gmap/gmap.page.html

@@ -0,0 +1,9 @@
1
+<ion-header>
2
+  <ion-toolbar>
3
+    <ion-title>gmap</ion-title>
4
+  </ion-toolbar>
5
+</ion-header>
6
+
7
+<ion-content>..
8
+<div #map id="map"></div>
9
+</ion-content>

+ 3 - 0
src/app/gmap/gmap.page.scss

@@ -0,0 +1,3 @@
1
+#map {
2
+    height: 300px;
3
+}

+ 24 - 0
src/app/gmap/gmap.page.spec.ts

@@ -0,0 +1,24 @@
1
+import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
2
+import { IonicModule } from '@ionic/angular';
3
+
4
+import { GmapPage } from './gmap.page';
5
+
6
+describe('GmapPage', () => {
7
+  let component: GmapPage;
8
+  let fixture: ComponentFixture<GmapPage>;
9
+
10
+  beforeEach(waitForAsync(() => {
11
+    TestBed.configureTestingModule({
12
+      declarations: [ GmapPage ],
13
+      imports: [IonicModule.forRoot()]
14
+    }).compileComponents();
15
+
16
+    fixture = TestBed.createComponent(GmapPage);
17
+    component = fixture.componentInstance;
18
+    fixture.detectChanges();
19
+  }));
20
+
21
+  it('should create', () => {
22
+    expect(component).toBeTruthy();
23
+  });
24
+});

+ 72 - 0
src/app/gmap/gmap.page.ts

@@ -0,0 +1,72 @@
1
+import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core';
2
+import { ActivatedRoute, Router } from '@angular/router';
3
+import { WpServiceService } from '../wp-service.service';
4
+import { Geolocation } from '@ionic-native/geolocation/ngx';
5
+import { NativeGeocoder, NativeGeocoderResult, NativeGeocoderOptions } from '@ionic-native/native-geocoder/ngx';
6
+
7
+declare var google: any;
8
+
9
+@Component({
10
+  selector: 'app-gmap',
11
+  templateUrl: './gmap.page.html',
12
+  styleUrls: ['./gmap.page.scss'],
13
+})
14
+export class GmapPage implements OnInit {
15
+  @Input() id: string;
16
+  data: any;
17
+  placelist: any;
18
+  latdynamic: any;
19
+  londynamic: any;
20
+  xxx: any;
21
+  yyy: any;
22
+  placeL: any;
23
+  map: any;
24
+  // @ViewChild('map', { static: false }) mapElement: ElementRef;
25
+  @ViewChild('map', { static: true }) mapRef: ElementRef;
26
+  // @ViewChild('map', { static: false }) mapElement: ElementRef;
27
+
28
+
29
+  constructor(private wpservice: WpServiceService, private route: ActivatedRoute, private router: Router, private geolocation: Geolocation) { }
30
+
31
+  ngOnInit() {
32
+    this.showMap();
33
+    // this.loadMap() 
34
+    let id = this.route.snapshot.paramMap.get('id') || this.id;
35
+    this.wpservice.getPlaceDetail(173).subscribe((data) => {
36
+      this.placelist = data;
37
+      this.latdynamic = data['acf']['gmap']['lat'];
38
+      this.londynamic = data['acf']['gmap']['lng'];
39
+
40
+      console.log("load Place Detail ...");
41
+      console.log(this.latdynamic);
42
+      console.log("load Lati ...");
43
+      console.log(this.londynamic);
44
+      console.log("load Lon ...");
45
+      console.log(data);
46
+      let xxx = this.londynamic;
47
+      const yyy = this.latdynamic;
48
+    }, error => {
49
+      console.log("errror ", error);
50
+    });
51
+
52
+    let watch = this.geolocation.watchPosition();
53
+    watch.subscribe((data) => {
54
+      // data can be a set of coordinates, or an error (if an error occurred).
55
+      // data.coords.latitude
56
+      // data.coords.longitude
57
+      console.log(data);
58
+    });
59
+  }
60
+
61
+  showMap() {
62
+    let location = new google.maps.LatLng(13.7643439, 100.6899729);
63
+    let options = {
64
+      center: location,
65
+      zoom: 15,
66
+      disableDefaultUI: true
67
+    }
68
+    this.map = new google.maps.Map(this.mapRef.nativeElement, options);
69
+    //this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
70
+  }
71
+
72
+}

+ 17 - 0
src/app/home/home-routing.module.ts

@@ -0,0 +1,17 @@
1
+import { NgModule } from '@angular/core';
2
+import { Routes, RouterModule } from '@angular/router';
3
+
4
+import { HomePage } from './home.page';
5
+
6
+const routes: Routes = [
7
+  {
8
+    path: '',
9
+    component: HomePage
10
+  }
11
+];
12
+
13
+@NgModule({
14
+  imports: [RouterModule.forChild(routes)],
15
+  exports: [RouterModule],
16
+})
17
+export class HomePageRoutingModule {}

+ 26 - 0
src/app/home/home.module.ts

@@ -0,0 +1,26 @@
1
+import { NgModule } from '@angular/core';
2
+import { CommonModule } from '@angular/common';
3
+import { FormsModule } from '@angular/forms';
4
+
5
+import { IonicModule } from '@ionic/angular';
6
+
7
+import { HomePageRoutingModule } from './home-routing.module';
8
+
9
+import { HomePage } from './home.page';
10
+import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
11
+import { IonSlides } from '@ionic/angular';
12
+
13
+import { PipeModule } from '../pipe/pipe.module';
14
+
15
+@NgModule({
16
+  imports: [
17
+    CommonModule,
18
+    FormsModule,
19
+    IonicModule,
20
+      PipeModule,
21
+    HomePageRoutingModule,
22
+    FontAwesomeModule
23
+  ],
24
+  declarations: [HomePage]
25
+})
26
+export class HomePageModule {}

+ 0 - 0
src/app/home/home.page.290921.html


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

golf/tge - Gogs: Simplico Git Service

Geen omschrijving

statement.js 41KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282
  1. "use strict";Object.defineProperty(exports, "__esModule", {value: true});/* eslint max-len: 0 */
  2. var _index = require('../index');
  3. var _flow = require('../plugins/flow');
  4. var _typescript = require('../plugins/typescript');
  5. var _tokenizer = require('../tokenizer');
  6. var _keywords = require('../tokenizer/keywords');
  7. var _state = require('../tokenizer/state');
  8. var _types = require('../tokenizer/types');
  9. var _charcodes = require('../util/charcodes');
  10. var _base = require('./base');
  11. var _expression = require('./expression');
  12. var _lval = require('./lval');
  13. var _util = require('./util');
  14. function parseTopLevel() {
  15. parseBlockBody(_types.TokenType.eof);
  16. _base.state.scopes.push(new (0, _state.Scope)(0, _base.state.tokens.length, true));
  17. if (_base.state.scopeDepth !== 0) {
  18. throw new Error(`Invalid scope depth at end of file: ${_base.state.scopeDepth}`);
  19. }
  20. return new (0, _index.File)(_base.state.tokens, _base.state.scopes);
  21. } exports.parseTopLevel = parseTopLevel;
  22. // Parse a single statement.
  23. //
  24. // If expecting a statement and finding a slash operator, parse a
  25. // regular expression literal. This is to handle cases like
  26. // `if (foo) /blah/.exec(foo)`, where looking at the previous token
  27. // does not help.
  28. function parseStatement(declaration) {
  29. if (_base.isFlowEnabled) {
  30. if (_flow.flowTryParseStatement.call(void 0, )) {
  31. return;
  32. }
  33. }
  34. if (_tokenizer.match.call(void 0, _types.TokenType.at)) {
  35. parseDecorators();
  36. }
  37. parseStatementContent(declaration);
  38. } exports.parseStatement = parseStatement;
  39. function parseStatementContent(declaration) {
  40. if (_base.isTypeScriptEnabled) {
  41. if (_typescript.tsTryParseStatementContent.call(void 0, )) {
  42. return;
  43. }
  44. }
  45. const starttype = _base.state.type;
  46. // Most types of statements are recognized by the keyword they
  47. // start with. Many are trivial to parse, some require a bit of
  48. // complexity.
  49. switch (starttype) {
  50. case _types.TokenType._break:
  51. case _types.TokenType._continue:
  52. parseBreakContinueStatement();
  53. return;
  54. case _types.TokenType._debugger:
  55. parseDebuggerStatement();
  56. return;
  57. case _types.TokenType._do:
  58. parseDoStatement();
  59. return;
  60. case _types.TokenType._for:
  61. parseForStatement();
  62. return;
  63. case _types.TokenType._function:
  64. if (_tokenizer.lookaheadType.call(void 0, ) === _types.TokenType.dot) break;
  65. if (!declaration) _util.unexpected.call(void 0, );
  66. parseFunctionStatement();
  67. return;
  68. case _types.TokenType._class:
  69. if (!declaration) _util.unexpected.call(void 0, );
  70. parseClass(true);
  71. return;
  72. case _types.TokenType._if:
  73. parseIfStatement();
  74. return;
  75. case _types.TokenType._return:
  76. parseReturnStatement();
  77. return;
  78. case _types.TokenType._switch:
  79. parseSwitchStatement();
  80. return;
  81. case _types.TokenType._throw:
  82. parseThrowStatement();
  83. return;
  84. case _types.TokenType._try:
  85. parseTryStatement();
  86. return;
  87. case _types.TokenType._let:
  88. case _types.TokenType._const:
  89. if (!declaration) _util.unexpected.call(void 0, ); // NOTE: falls through to _var
  90. case _types.TokenType._var:
  91. parseVarStatement(starttype !== _types.TokenType._var);
  92. return;
  93. case _types.TokenType._while:
  94. parseWhileStatement();
  95. return;
  96. case _types.TokenType.braceL:
  97. parseBlock();
  98. return;
  99. case _types.TokenType.semi:
  100. parseEmptyStatement();
  101. return;
  102. case _types.TokenType._export:
  103. case _types.TokenType._import: {
  104. const nextType = _tokenizer.lookaheadType.call(void 0, );
  105. if (nextType === _types.TokenType.parenL || nextType === _types.TokenType.dot) {
  106. break;
  107. }
  108. _tokenizer.next.call(void 0, );
  109. if (starttype === _types.TokenType._import) {
  110. parseImport();
  111. } else {
  112. parseExport();
  113. }
  114. return;
  115. }
  116. case _types.TokenType.name:
  117. if (_base.state.contextualKeyword === _keywords.ContextualKeyword._async) {
  118. const functionStart = _base.state.start;
  119. // peek ahead and see if next token is a function
  120. const snapshot = _base.state.snapshot();
  121. _tokenizer.next.call(void 0, );
  122. if (_tokenizer.match.call(void 0, _types.TokenType._function) && !_util.canInsertSemicolon.call(void 0, )) {
  123. _util.expect.call(void 0, _types.TokenType._function);
  124. parseFunction(functionStart, true);
  125. return;
  126. } else {
  127. _base.state.restoreFromSnapshot(snapshot);
  128. }
  129. } else if (
  130. _base.state.contextualKeyword === _keywords.ContextualKeyword._using &&
  131. !_util.hasFollowingLineBreak.call(void 0, ) &&
  132. // Statements like `using[0]` and `using in foo` aren't actual using
  133. // declarations.
  134. _tokenizer.lookaheadType.call(void 0, ) === _types.TokenType.name
  135. ) {
  136. parseVarStatement(true);
  137. return;
  138. }
  139. default:
  140. // Do nothing.
  141. break;
  142. }
  143. // If the statement does not start with a statement keyword or a
  144. // brace, it's an ExpressionStatement or LabeledStatement. We
  145. // simply start parsing an expression, and afterwards, if the
  146. // next token is a colon and the expression was a simple
  147. // Identifier node, we switch to interpreting it as a label.
  148. const initialTokensLength = _base.state.tokens.length;
  149. _expression.parseExpression.call(void 0, );
  150. let simpleName = null;
  151. if (_base.state.tokens.length === initialTokensLength + 1) {
  152. const token = _base.state.tokens[_base.state.tokens.length - 1];
  153. if (token.type === _types.TokenType.name) {
  154. simpleName = token.contextualKeyword;
  155. }
  156. }
  157. if (simpleName == null) {
  158. _util.semicolon.call(void 0, );
  159. return;
  160. }
  161. if (_tokenizer.eat.call(void 0, _types.TokenType.colon)) {
  162. parseLabeledStatement();
  163. } else {
  164. // This was an identifier, so we might want to handle flow/typescript-specific cases.
  165. parseIdentifierStatement(simpleName);
  166. }
  167. }
  168. function parseDecorators() {
  169. while (_tokenizer.match.call(void 0, _types.TokenType.at)) {
  170. parseDecorator();
  171. }
  172. } exports.parseDecorators = parseDecorators;
  173. function parseDecorator() {
  174. _tokenizer.next.call(void 0, );
  175. if (_tokenizer.eat.call(void 0, _types.TokenType.parenL)) {
  176. _expression.parseExpression.call(void 0, );
  177. _util.expect.call(void 0, _types.TokenType.parenR);
  178. } else {
  179. _expression.parseIdentifier.call(void 0, );
  180. while (_tokenizer.eat.call(void 0, _types.TokenType.dot)) {
  181. _expression.parseIdentifier.call(void 0, );
  182. }
  183. parseMaybeDecoratorArguments();
  184. }
  185. }
  186. function parseMaybeDecoratorArguments() {
  187. if (_base.isTypeScriptEnabled) {
  188. _typescript.tsParseMaybeDecoratorArguments.call(void 0, );
  189. } else {
  190. baseParseMaybeDecoratorArguments();
  191. }
  192. }
  193. function baseParseMaybeDecoratorArguments() {
  194. if (_tokenizer.eat.call(void 0, _types.TokenType.parenL)) {
  195. _expression.parseCallExpressionArguments.call(void 0, );
  196. }
  197. } exports.baseParseMaybeDecoratorArguments = baseParseMaybeDecoratorArguments;
  198. function parseBreakContinueStatement() {
  199. _tokenizer.next.call(void 0, );
  200. if (!_util.isLineTerminator.call(void 0, )) {
  201. _expression.parseIdentifier.call(void 0, );
  202. _util.semicolon.call(void 0, );
  203. }
  204. }
  205. function parseDebuggerStatement() {
  206. _tokenizer.next.call(void 0, );
  207. _util.semicolon.call(void 0, );
  208. }
  209. function parseDoStatement() {
  210. _tokenizer.next.call(void 0, );
  211. parseStatement(false);
  212. _util.expect.call(void 0, _types.TokenType._while);
  213. _expression.parseParenExpression.call(void 0, );
  214. _tokenizer.eat.call(void 0, _types.TokenType.semi);
  215. }
  216. function parseForStatement() {
  217. _base.state.scopeDepth++;
  218. const startTokenIndex = _base.state.tokens.length;
  219. parseAmbiguousForStatement();
  220. const endTokenIndex = _base.state.tokens.length;
  221. _base.state.scopes.push(new (0, _state.Scope)(startTokenIndex, endTokenIndex, false));
  222. _base.state.scopeDepth--;
  223. }
  224. /**
  225. * Determine if this token is a `using` declaration (explicit resource
  226. * management) as part of a loop.
  227. * https://github.com/tc39/proposal-explicit-resource-management
  228. */
  229. function isUsingInLoop() {
  230. if (!_util.isContextual.call(void 0, _keywords.ContextualKeyword._using)) {
  231. return false;
  232. }
  233. // This must be `for (using of`, where `using` is the name of the loop
  234. // variable.
  235. if (_util.isLookaheadContextual.call(void 0, _keywords.ContextualKeyword._of)) {
  236. return false;
  237. }
  238. return true;
  239. }
  240. // Disambiguating between a `for` and a `for`/`in` or `for`/`of`
  241. // loop is non-trivial. Basically, we have to parse the init `var`
  242. // statement or expression, disallowing the `in` operator (see
  243. // the second parameter to `parseExpression`), and then check
  244. // whether the next token is `in` or `of`. When there is no init
  245. // part (semicolon immediately after the opening parenthesis), it
  246. // is a regular `for` loop.
  247. function parseAmbiguousForStatement() {
  248. _tokenizer.next.call(void 0, );
  249. let forAwait = false;
  250. if (_util.isContextual.call(void 0, _keywords.ContextualKeyword._await)) {
  251. forAwait = true;
  252. _tokenizer.next.call(void 0, );
  253. }
  254. _util.expect.call(void 0, _types.TokenType.parenL);
  255. if (_tokenizer.match.call(void 0, _types.TokenType.semi)) {
  256. if (forAwait) {
  257. _util.unexpected.call(void 0, );
  258. }
  259. parseFor();
  260. return;
  261. }
  262. if (_tokenizer.match.call(void 0, _types.TokenType._var) || _tokenizer.match.call(void 0, _types.TokenType._let) || _tokenizer.match.call(void 0, _types.TokenType._const) || isUsingInLoop()) {
  263. _tokenizer.next.call(void 0, );
  264. parseVar(true, _base.state.type !== _types.TokenType._var);
  265. if (_tokenizer.match.call(void 0, _types.TokenType._in) || _util.isContextual.call(void 0, _keywords.ContextualKeyword._of)) {
  266. parseForIn(forAwait);
  267. return;
  268. }
  269. parseFor();
  270. return;
  271. }
  272. _expression.parseExpression.call(void 0, true);
  273. if (_tokenizer.match.call(void 0, _types.TokenType._in) || _util.isContextual.call(void 0, _keywords.ContextualKeyword._of)) {
  274. parseForIn(forAwait);
  275. return;
  276. }
  277. if (forAwait) {
  278. _util.unexpected.call(void 0, );
  279. }
  280. parseFor();
  281. }
  282. function parseFunctionStatement() {
  283. const functionStart = _base.state.start;
  284. _tokenizer.next.call(void 0, );
  285. parseFunction(functionStart, true);
  286. }
  287. function parseIfStatement() {
  288. _tokenizer.next.call(void 0, );
  289. _expression.parseParenExpression.call(void 0, );
  290. parseStatement(false);
  291. if (_tokenizer.eat.call(void 0, _types.TokenType._else)) {
  292. parseStatement(false);
  293. }
  294. }
  295. function parseReturnStatement() {
  296. _tokenizer.next.call(void 0, );
  297. // In `return` (and `break`/`continue`), the keywords with
  298. // optional arguments, we eagerly look for a semicolon or the
  299. // possibility to insert one.
  300. if (!_util.isLineTerminator.call(void 0, )) {
  301. _expression.parseExpression.call(void 0, );
  302. _util.semicolon.call(void 0, );
  303. }
  304. }
  305. function parseSwitchStatement() {
  306. _tokenizer.next.call(void 0, );
  307. _expression.parseParenExpression.call(void 0, );
  308. _base.state.scopeDepth++;
  309. const startTokenIndex = _base.state.tokens.length;
  310. _util.expect.call(void 0, _types.TokenType.braceL);
  311. // Don't bother validation; just go through any sequence of cases, defaults, and statements.
  312. while (!_tokenizer.match.call(void 0, _types.TokenType.braceR) && !_base.state.error) {
  313. if (_tokenizer.match.call(void 0, _types.TokenType._case) || _tokenizer.match.call(void 0, _types.TokenType._default)) {
  314. const isCase = _tokenizer.match.call(void 0, _types.TokenType._case);
  315. _tokenizer.next.call(void 0, );
  316. if (isCase) {
  317. _expression.parseExpression.call(void 0, );
  318. }
  319. _util.expect.call(void 0, _types.TokenType.colon);
  320. } else {
  321. parseStatement(true);
  322. }
  323. }
  324. _tokenizer.next.call(void 0, ); // Closing brace
  325. const endTokenIndex = _base.state.tokens.length;
  326. _base.state.scopes.push(new (0, _state.Scope)(startTokenIndex, endTokenIndex, false));
  327. _base.state.scopeDepth--;
  328. }
  329. function parseThrowStatement() {
  330. _tokenizer.next.call(void 0, );
  331. _expression.parseExpression.call(void 0, );
  332. _util.semicolon.call(void 0, );
  333. }
  334. function parseCatchClauseParam() {
  335. _lval.parseBindingAtom.call(void 0, true /* isBlockScope */);
  336. if (_base.isTypeScriptEnabled) {
  337. _typescript.tsTryParseTypeAnnotation.call(void 0, );
  338. }
  339. }
  340. function parseTryStatement() {
  341. _tokenizer.next.call(void 0, );
  342. parseBlock();
  343. if (_tokenizer.match.call(void 0, _types.TokenType._catch)) {
  344. _tokenizer.next.call(void 0, );
  345. let catchBindingStartTokenIndex = null;
  346. if (_tokenizer.match.call(void 0, _types.TokenType.parenL)) {
  347. _base.state.scopeDepth++;
  348. catchBindingStartTokenIndex = _base.state.tokens.length;
  349. _util.expect.call(void 0, _types.TokenType.parenL);
  350. parseCatchClauseParam();
  351. _util.expect.call(void 0, _types.TokenType.parenR);
  352. }
  353. parseBlock();
  354. if (catchBindingStartTokenIndex != null) {
  355. // We need a special scope for the catch binding which includes the binding itself and the
  356. // catch block.
  357. const endTokenIndex = _base.state.tokens.length;
  358. _base.state.scopes.push(new (0, _state.Scope)(catchBindingStartTokenIndex, endTokenIndex, false));
  359. _base.state.scopeDepth--;
  360. }
  361. }
  362. if (_tokenizer.eat.call(void 0, _types.TokenType._finally)) {
  363. parseBlock();
  364. }
  365. }
  366. function parseVarStatement(isBlockScope) {
  367. _tokenizer.next.call(void 0, );
  368. parseVar(false, isBlockScope);
  369. _util.semicolon.call(void 0, );
  370. } exports.parseVarStatement = parseVarStatement;
  371. function parseWhileStatement() {
  372. _tokenizer.next.call(void 0, );
  373. _expression.parseParenExpression.call(void 0, );
  374. parseStatement(false);
  375. }
  376. function parseEmptyStatement() {
  377. _tokenizer.next.call(void 0, );
  378. }
  379. function parseLabeledStatement() {
  380. parseStatement(true);
  381. }
  382. /**
  383. * Parse a statement starting with an identifier of the given name. Subclasses match on the name
  384. * to handle statements like "declare".
  385. */
  386. function parseIdentifierStatement(contextualKeyword) {
  387. if (_base.isTypeScriptEnabled) {
  388. _typescript.tsParseIdentifierStatement.call(void 0, contextualKeyword);
  389. } else if (_base.isFlowEnabled) {
  390. _flow.flowParseIdentifierStatement.call(void 0, contextualKeyword);
  391. } else {
  392. _util.semicolon.call(void 0, );
  393. }
  394. }
  395. // Parse a semicolon-enclosed block of statements.
  396. function parseBlock(isFunctionScope = false, contextId = 0) {
  397. const startTokenIndex = _base.state.tokens.length;
  398. _base.state.scopeDepth++;
  399. _util.expect.call(void 0, _types.TokenType.braceL);
  400. if (contextId) {
  401. _base.state.tokens[_base.state.tokens.length - 1].contextId = contextId;
  402. }
  403. parseBlockBody(_types.TokenType.braceR);
  404. if (contextId) {
  405. _base.state.tokens[_base.state.tokens.length - 1].contextId = contextId;
  406. }
  407. const endTokenIndex = _base.state.tokens.length;
  408. _base.state.scopes.push(new (0, _state.Scope)(startTokenIndex, endTokenIndex, isFunctionScope));
  409. _base.state.scopeDepth--;
  410. } exports.parseBlock = parseBlock;
  411. function parseBlockBody(end) {
  412. while (!_tokenizer.eat.call(void 0, end) && !_base.state.error) {
  413. parseStatement(true);
  414. }
  415. } exports.parseBlockBody = parseBlockBody;
  416. // Parse a regular `for` loop. The disambiguation code in
  417. // `parseStatement` will already have parsed the init statement or
  418. // expression.
  419. function parseFor() {
  420. _util.expect.call(void 0, _types.TokenType.semi);
  421. if (!_tokenizer.match.call(void 0, _types.TokenType.semi)) {
  422. _expression.parseExpression.call(void 0, );
  423. }
  424. _util.expect.call(void 0, _types.TokenType.semi);
  425. if (!_tokenizer.match.call(void 0, _types.TokenType.parenR)) {
  426. _expression.parseExpression.call(void 0, );
  427. }
  428. _util.expect.call(void 0, _types.TokenType.parenR);
  429. parseStatement(false);
  430. }
  431. // Parse a `for`/`in` and `for`/`of` loop, which are almost
  432. // same from parser's perspective.
  433. function parseForIn(forAwait) {
  434. if (forAwait) {
  435. _util.eatContextual.call(void 0, _keywords.ContextualKeyword._of);
  436. } else {
  437. _tokenizer.next.call(void 0, );
  438. }
  439. _expression.parseExpression.call(void 0, );
  440. _util.expect.call(void 0, _types.TokenType.parenR);
  441. parseStatement(false);
  442. }
  443. // Parse a list of variable declarations.
  444. function parseVar(isFor, isBlockScope) {
  445. while (true) {
  446. parseVarHead(isBlockScope);
  447. if (_tokenizer.eat.call(void 0, _types.TokenType.eq)) {
  448. const eqIndex = _base.state.tokens.length - 1;
  449. _expression.parseMaybeAssign.call(void 0, isFor);
  450. _base.state.tokens[eqIndex].rhsEndIndex = _base.state.tokens.length;
  451. }
  452. if (!_tokenizer.eat.call(void 0, _types.TokenType.comma)) {
  453. break;
  454. }
  455. }
  456. }
  457. function parseVarHead(isBlockScope) {
  458. _lval.parseBindingAtom.call(void 0, isBlockScope);
  459. if (_base.isTypeScriptEnabled) {
  460. _typescript.tsAfterParseVarHead.call(void 0, );
  461. } else if (_base.isFlowEnabled) {
  462. _flow.flowAfterParseVarHead.call(void 0, );
  463. }
  464. }
  465. // Parse a function declaration or literal (depending on the
  466. // `isStatement` parameter).
  467. function parseFunction(
  468. functionStart,
  469. isStatement,
  470. optionalId = false,
  471. ) {
  472. if (_tokenizer.match.call(void 0, _types.TokenType.star)) {
  473. _tokenizer.next.call(void 0, );
  474. }
  475. if (isStatement && !optionalId && !_tokenizer.match.call(void 0, _types.TokenType.name) && !_tokenizer.match.call(void 0, _types.TokenType._yield)) {
  476. _util.unexpected.call(void 0, );
  477. }
  478. let nameScopeStartTokenIndex = null;
  479. if (_tokenizer.match.call(void 0, _types.TokenType.name)) {
  480. // Expression-style functions should limit their name's scope to the function body, so we make
  481. // a new function scope to enforce that.
  482. if (!isStatement) {
  483. nameScopeStartTokenIndex = _base.state.tokens.length;
  484. _base.state.scopeDepth++;
  485. }
  486. _lval.parseBindingIdentifier.call(void 0, false);
  487. }
  488. const startTokenIndex = _base.state.tokens.length;
  489. _base.state.scopeDepth++;
  490. parseFunctionParams();
  491. _expression.parseFunctionBodyAndFinish.call(void 0, functionStart);
  492. const endTokenIndex = _base.state.tokens.length;
  493. // In addition to the block scope of the function body, we need a separate function-style scope
  494. // that includes the params.
  495. _base.state.scopes.push(new (0, _state.Scope)(startTokenIndex, endTokenIndex, true));
  496. _base.state.scopeDepth--;
  497. if (nameScopeStartTokenIndex !== null) {
  498. _base.state.scopes.push(new (0, _state.Scope)(nameScopeStartTokenIndex, endTokenIndex, true));
  499. _base.state.scopeDepth--;
  500. }
  501. } exports.parseFunction = parseFunction;
  502. function parseFunctionParams(
  503. allowModifiers = false,
  504. funcContextId = 0,
  505. ) {
  506. if (_base.isTypeScriptEnabled) {
  507. _typescript.tsStartParseFunctionParams.call(void 0, );
  508. } else if (_base.isFlowEnabled) {
  509. _flow.flowStartParseFunctionParams.call(void 0, );
  510. }
  511. _util.expect.call(void 0, _types.TokenType.parenL);
  512. if (funcContextId) {
  513. _base.state.tokens[_base.state.tokens.length - 1].contextId = funcContextId;
  514. }
  515. _lval.parseBindingList.call(void 0,
  516. _types.TokenType.parenR,
  517. false /* isBlockScope */,
  518. false /* allowEmpty */,
  519. allowModifiers,
  520. funcContextId,
  521. );
  522. if (funcContextId) {
  523. _base.state.tokens[_base.state.tokens.length - 1].contextId = funcContextId;
  524. }
  525. } exports.parseFunctionParams = parseFunctionParams;
  526. // Parse a class declaration or literal (depending on the
  527. // `isStatement` parameter).
  528. function parseClass(isStatement, optionalId = false) {
  529. // Put a context ID on the class keyword, the open-brace, and the close-brace, so that later
  530. // code can easily navigate to meaningful points on the class.
  531. const contextId = _base.getNextContextId.call(void 0, );
  532. _tokenizer.next.call(void 0, );
  533. _base.state.tokens[_base.state.tokens.length - 1].contextId = contextId;
  534. _base.state.tokens[_base.state.tokens.length - 1].isExpression = !isStatement;
  535. // Like with functions, we declare a special "name scope" from the start of the name to the end
  536. // of the class, but only with expression-style classes, to represent the fact that the name is
  537. // available to the body of the class but not an outer declaration.
  538. let nameScopeStartTokenIndex = null;
  539. if (!isStatement) {
  540. nameScopeStartTokenIndex = _base.state.tokens.length;
  541. _base.state.scopeDepth++;
  542. }
  543. parseClassId(isStatement, optionalId);
  544. parseClassSuper();
  545. const openBraceIndex = _base.state.tokens.length;
  546. parseClassBody(contextId);
  547. if (_base.state.error) {
  548. return;
  549. }
  550. _base.state.tokens[openBraceIndex].contextId = contextId;
  551. _base.state.tokens[_base.state.tokens.length - 1].contextId = contextId;
  552. if (nameScopeStartTokenIndex !== null) {
  553. const endTokenIndex = _base.state.tokens.length;
  554. _base.state.scopes.push(new (0, _state.Scope)(nameScopeStartTokenIndex, endTokenIndex, false));
  555. _base.state.scopeDepth--;
  556. }
  557. } exports.parseClass = parseClass;
  558. function isClassProperty() {
  559. return _tokenizer.match.call(void 0, _types.TokenType.eq) || _tokenizer.match.call(void 0, _types.TokenType.semi) || _tokenizer.match.call(void 0, _types.TokenType.braceR) || _tokenizer.match.call(void 0, _types.TokenType.bang) || _tokenizer.match.call(void 0, _types.TokenType.colon);
  560. }
  561. function isClassMethod() {
  562. return _tokenizer.match.call(void 0, _types.TokenType.parenL) || _tokenizer.match.call(void 0, _types.TokenType.lessThan);
  563. }
  564. function parseClassBody(classContextId) {
  565. _util.expect.call(void 0, _types.TokenType.braceL);
  566. while (!_tokenizer.eat.call(void 0, _types.TokenType.braceR) && !_base.state.error) {
  567. if (_tokenizer.eat.call(void 0, _types.TokenType.semi)) {
  568. continue;
  569. }
  570. if (_tokenizer.match.call(void 0, _types.TokenType.at)) {
  571. parseDecorator();
  572. continue;
  573. }
  574. const memberStart = _base.state.start;
  575. parseClassMember(memberStart, classContextId);
  576. }
  577. }
  578. function parseClassMember(memberStart, classContextId) {
  579. if (_base.isTypeScriptEnabled) {
  580. _typescript.tsParseModifiers.call(void 0, [
  581. _keywords.ContextualKeyword._declare,
  582. _keywords.ContextualKeyword._public,
  583. _keywords.ContextualKeyword._protected,
  584. _keywords.ContextualKeyword._private,
  585. _keywords.ContextualKeyword._override,
  586. ]);
  587. }
  588. let isStatic = false;
  589. if (_tokenizer.match.call(void 0, _types.TokenType.name) && _base.state.contextualKeyword === _keywords.ContextualKeyword._static) {
  590. _expression.parseIdentifier.call(void 0, ); // eats 'static'
  591. if (isClassMethod()) {
  592. parseClassMethod(memberStart, /* isConstructor */ false);
  593. return;
  594. } else if (isClassProperty()) {
  595. parseClassProperty();
  596. return;
  597. }
  598. // otherwise something static
  599. _base.state.tokens[_base.state.tokens.length - 1].type = _types.TokenType._static;
  600. isStatic = true;
  601. if (_tokenizer.match.call(void 0, _types.TokenType.braceL)) {
  602. // This is a static block. Mark the word "static" with the class context ID for class element
  603. // detection and parse as a regular block.
  604. _base.state.tokens[_base.state.tokens.length - 1].contextId = classContextId;
  605. parseBlock();
  606. return;
  607. }
  608. }
  609. parseClassMemberWithIsStatic(memberStart, isStatic, classContextId);
  610. }
  611. function parseClassMemberWithIsStatic(
  612. memberStart,
  613. isStatic,
  614. classContextId,
  615. ) {
  616. if (_base.isTypeScriptEnabled) {
  617. if (_typescript.tsTryParseClassMemberWithIsStatic.call(void 0, isStatic)) {
  618. return;
  619. }
  620. }
  621. if (_tokenizer.eat.call(void 0, _types.TokenType.star)) {
  622. // a generator
  623. parseClassPropertyName(classContextId);
  624. parseClassMethod(memberStart, /* isConstructor */ false);
  625. return;
  626. }
  627. // Get the identifier name so we can tell if it's actually a keyword like "async", "get", or
  628. // "set".
  629. parseClassPropertyName(classContextId);
  630. let isConstructor = false;
  631. const token = _base.state.tokens[_base.state.tokens.length - 1];
  632. // We allow "constructor" as either an identifier or a string.
  633. if (token.contextualKeyword === _keywords.ContextualKeyword._constructor) {
  634. isConstructor = true;
  635. }
  636. parsePostMemberNameModifiers();
  637. if (isClassMethod()) {
  638. parseClassMethod(memberStart, isConstructor);
  639. } else if (isClassProperty()) {
  640. parseClassProperty();
  641. } else if (token.contextualKeyword === _keywords.ContextualKeyword._async && !_util.isLineTerminator.call(void 0, )) {
  642. _base.state.tokens[_base.state.tokens.length - 1].type = _types.TokenType._async;
  643. // an async method
  644. const isGenerator = _tokenizer.match.call(void 0, _types.TokenType.star);
  645. if (isGenerator) {
  646. _tokenizer.next.call(void 0, );
  647. }
  648. // The so-called parsed name would have been "async": get the real name.
  649. parseClassPropertyName(classContextId);
  650. parsePostMemberNameModifiers();
  651. parseClassMethod(memberStart, false /* isConstructor */);
  652. } else if (
  653. (token.contextualKeyword === _keywords.ContextualKeyword._get ||
  654. token.contextualKeyword === _keywords.ContextualKeyword._set) &&
  655. !(_util.isLineTerminator.call(void 0, ) && _tokenizer.match.call(void 0, _types.TokenType.star))
  656. ) {
  657. if (token.contextualKeyword === _keywords.ContextualKeyword._get) {
  658. _base.state.tokens[_base.state.tokens.length - 1].type = _types.TokenType._get;
  659. } else {
  660. _base.state.tokens[_base.state.tokens.length - 1].type = _types.TokenType._set;
  661. }
  662. // `get\n*` is an uninitialized property named 'get' followed by a generator.
  663. // a getter or setter
  664. // The so-called parsed name would have been "get/set": get the real name.
  665. parseClassPropertyName(classContextId);
  666. parseClassMethod(memberStart, /* isConstructor */ false);
  667. } else if (token.contextualKeyword === _keywords.ContextualKeyword._accessor && !_util.isLineTerminator.call(void 0, )) {
  668. parseClassPropertyName(classContextId);
  669. parseClassProperty();
  670. } else if (_util.isLineTerminator.call(void 0, )) {
  671. // an uninitialized class property (due to ASI, since we don't otherwise recognize the next token)
  672. parseClassProperty();
  673. } else {
  674. _util.unexpected.call(void 0, );
  675. }
  676. }
  677. function parseClassMethod(functionStart, isConstructor) {
  678. if (_base.isTypeScriptEnabled) {
  679. _typescript.tsTryParseTypeParameters.call(void 0, );
  680. } else if (_base.isFlowEnabled) {
  681. if (_tokenizer.match.call(void 0, _types.TokenType.lessThan)) {
  682. _flow.flowParseTypeParameterDeclaration.call(void 0, );
  683. }
  684. }
  685. _expression.parseMethod.call(void 0, functionStart, isConstructor);
  686. }
  687. // Return the name of the class property, if it is a simple identifier.
  688. function parseClassPropertyName(classContextId) {
  689. _expression.parsePropertyName.call(void 0, classContextId);
  690. } exports.parseClassPropertyName = parseClassPropertyName;
  691. function parsePostMemberNameModifiers() {
  692. if (_base.isTypeScriptEnabled) {
  693. const oldIsType = _tokenizer.pushTypeContext.call(void 0, 0);
  694. _tokenizer.eat.call(void 0, _types.TokenType.question);
  695. _tokenizer.popTypeContext.call(void 0, oldIsType);
  696. }
  697. } exports.parsePostMemberNameModifiers = parsePostMemberNameModifiers;
  698. function parseClassProperty() {
  699. if (_base.isTypeScriptEnabled) {
  700. _tokenizer.eatTypeToken.call(void 0, _types.TokenType.bang);
  701. _typescript.tsTryParseTypeAnnotation.call(void 0, );
  702. } else if (_base.isFlowEnabled) {
  703. if (_tokenizer.match.call(void 0, _types.TokenType.colon)) {
  704. _flow.flowParseTypeAnnotation.call(void 0, );
  705. }
  706. }
  707. if (_tokenizer.match.call(void 0, _types.TokenType.eq)) {
  708. const equalsTokenIndex = _base.state.tokens.length;
  709. _tokenizer.next.call(void 0, );
  710. _expression.parseMaybeAssign.call(void 0, );
  711. _base.state.tokens[equalsTokenIndex].rhsEndIndex = _base.state.tokens.length;
  712. }
  713. _util.semicolon.call(void 0, );
  714. } exports.parseClassProperty = parseClassProperty;
  715. function parseClassId(isStatement, optionalId = false) {
  716. if (
  717. _base.isTypeScriptEnabled &&
  718. (!isStatement || optionalId) &&
  719. _util.isContextual.call(void 0, _keywords.ContextualKeyword._implements)
  720. ) {
  721. return;
  722. }
  723. if (_tokenizer.match.call(void 0, _types.TokenType.name)) {
  724. _lval.parseBindingIdentifier.call(void 0, true);
  725. }
  726. if (_base.isTypeScriptEnabled) {
  727. _typescript.tsTryParseTypeParameters.call(void 0, );
  728. } else if (_base.isFlowEnabled) {
  729. if (_tokenizer.match.call(void 0, _types.TokenType.lessThan)) {
  730. _flow.flowParseTypeParameterDeclaration.call(void 0, );
  731. }
  732. }
  733. }
  734. // Returns true if there was a superclass.
  735. function parseClassSuper() {
  736. let hasSuper = false;
  737. if (_tokenizer.eat.call(void 0, _types.TokenType._extends)) {
  738. _expression.parseExprSubscripts.call(void 0, );
  739. hasSuper = true;
  740. } else {
  741. hasSuper = false;
  742. }
  743. if (_base.isTypeScriptEnabled) {
  744. _typescript.tsAfterParseClassSuper.call(void 0, hasSuper);
  745. } else if (_base.isFlowEnabled) {
  746. _flow.flowAfterParseClassSuper.call(void 0, hasSuper);
  747. }
  748. }
  749. // Parses module export declaration.
  750. function parseExport() {
  751. const exportIndex = _base.state.tokens.length - 1;
  752. if (_base.isTypeScriptEnabled) {
  753. if (_typescript.tsTryParseExport.call(void 0, )) {
  754. return;
  755. }
  756. }
  757. // export * from '...'
  758. if (shouldParseExportStar()) {
  759. parseExportStar();
  760. } else if (isExportDefaultSpecifier()) {
  761. // export default from
  762. _expression.parseIdentifier.call(void 0, );
  763. if (_tokenizer.match.call(void 0, _types.TokenType.comma) && _tokenizer.lookaheadType.call(void 0, ) === _types.TokenType.star) {
  764. _util.expect.call(void 0, _types.TokenType.comma);
  765. _util.expect.call(void 0, _types.TokenType.star);
  766. _util.expectContextual.call(void 0, _keywords.ContextualKeyword._as);
  767. _expression.parseIdentifier.call(void 0, );
  768. } else {
  769. parseExportSpecifiersMaybe();
  770. }
  771. parseExportFrom();
  772. } else if (_tokenizer.eat.call(void 0, _types.TokenType._default)) {
  773. // export default ...
  774. parseExportDefaultExpression();
  775. } else if (shouldParseExportDeclaration()) {
  776. parseExportDeclaration();
  777. } else {
  778. // export { x, y as z } [from '...']
  779. parseExportSpecifiers();
  780. parseExportFrom();
  781. }
  782. _base.state.tokens[exportIndex].rhsEndIndex = _base.state.tokens.length;
  783. } exports.parseExport = parseExport;
  784. function parseExportDefaultExpression() {
  785. if (_base.isTypeScriptEnabled) {
  786. if (_typescript.tsTryParseExportDefaultExpression.call(void 0, )) {
  787. return;
  788. }
  789. }
  790. if (_base.isFlowEnabled) {
  791. if (_flow.flowTryParseExportDefaultExpression.call(void 0, )) {
  792. return;
  793. }
  794. }
  795. const functionStart = _base.state.start;
  796. if (_tokenizer.eat.call(void 0, _types.TokenType._function)) {
  797. parseFunction(functionStart, true, true);
  798. } else if (_util.isContextual.call(void 0, _keywords.ContextualKeyword._async) && _tokenizer.lookaheadType.call(void 0, ) === _types.TokenType._function) {
  799. // async function declaration
  800. _util.eatContextual.call(void 0, _keywords.ContextualKeyword._async);
  801. _tokenizer.eat.call(void 0, _types.TokenType._function);
  802. parseFunction(functionStart, true, true);
  803. } else if (_tokenizer.match.call(void 0, _types.TokenType._class)) {
  804. parseClass(true, true);
  805. } else if (_tokenizer.match.call(void 0, _types.TokenType.at)) {
  806. parseDecorators();
  807. parseClass(true, true);
  808. } else {
  809. _expression.parseMaybeAssign.call(void 0, );
  810. _util.semicolon.call(void 0, );
  811. }
  812. }
  813. function parseExportDeclaration() {
  814. if (_base.isTypeScriptEnabled) {
  815. _typescript.tsParseExportDeclaration.call(void 0, );
  816. } else if (_base.isFlowEnabled) {
  817. _flow.flowParseExportDeclaration.call(void 0, );
  818. } else {
  819. parseStatement(true);
  820. }
  821. }
  822. function isExportDefaultSpecifier() {
  823. if (_base.isTypeScriptEnabled && _typescript.tsIsDeclarationStart.call(void 0, )) {
  824. return false;
  825. } else if (_base.isFlowEnabled && _flow.flowShouldDisallowExportDefaultSpecifier.call(void 0, )) {
  826. return false;
  827. }
  828. if (_tokenizer.match.call(void 0, _types.TokenType.name)) {
  829. return _base.state.contextualKeyword !== _keywords.ContextualKeyword._async;
  830. }
  831. if (!_tokenizer.match.call(void 0, _types.TokenType._default)) {
  832. return false;
  833. }
  834. const _next = _tokenizer.nextTokenStart.call(void 0, );
  835. const lookahead = _tokenizer.lookaheadTypeAndKeyword.call(void 0, );
  836. const hasFrom =
  837. lookahead.type === _types.TokenType.name && lookahead.contextualKeyword === _keywords.ContextualKeyword._from;
  838. if (lookahead.type === _types.TokenType.comma) {
  839. return true;
  840. }
  841. // lookahead again when `export default from` is seen
  842. if (hasFrom) {
  843. const nextAfterFrom = _base.input.charCodeAt(_tokenizer.nextTokenStartSince.call(void 0, _next + 4));
  844. return nextAfterFrom === _charcodes.charCodes.quotationMark || nextAfterFrom === _charcodes.charCodes.apostrophe;
  845. }
  846. return false;
  847. }
  848. function parseExportSpecifiersMaybe() {
  849. if (_tokenizer.eat.call(void 0, _types.TokenType.comma)) {
  850. parseExportSpecifiers();
  851. }
  852. }
  853. function parseExportFrom() {
  854. if (_util.eatContextual.call(void 0, _keywords.ContextualKeyword._from)) {
  855. _expression.parseExprAtom.call(void 0, );
  856. maybeParseImportAssertions();
  857. }
  858. _util.semicolon.call(void 0, );
  859. } exports.parseExportFrom = parseExportFrom;
  860. function shouldParseExportStar() {
  861. if (_base.isFlowEnabled) {
  862. return _flow.flowShouldParseExportStar.call(void 0, );
  863. } else {
  864. return _tokenizer.match.call(void 0, _types.TokenType.star);
  865. }
  866. }
  867. function parseExportStar() {
  868. if (_base.isFlowEnabled) {
  869. _flow.flowParseExportStar.call(void 0, );
  870. } else {
  871. baseParseExportStar();
  872. }
  873. }
  874. function baseParseExportStar() {
  875. _util.expect.call(void 0, _types.TokenType.star);
  876. if (_util.isContextual.call(void 0, _keywords.ContextualKeyword._as)) {
  877. parseExportNamespace();
  878. } else {
  879. parseExportFrom();
  880. }
  881. } exports.baseParseExportStar = baseParseExportStar;
  882. function parseExportNamespace() {
  883. _tokenizer.next.call(void 0, );
  884. _base.state.tokens[_base.state.tokens.length - 1].type = _types.TokenType._as;
  885. _expression.parseIdentifier.call(void 0, );
  886. parseExportSpecifiersMaybe();
  887. parseExportFrom();
  888. }
  889. function shouldParseExportDeclaration() {
  890. return (
  891. (_base.isTypeScriptEnabled && _typescript.tsIsDeclarationStart.call(void 0, )) ||
  892. (_base.isFlowEnabled && _flow.flowShouldParseExportDeclaration.call(void 0, )) ||
  893. _base.state.type === _types.TokenType._var ||
  894. _base.state.type === _types.TokenType._const ||
  895. _base.state.type === _types.TokenType._let ||
  896. _base.state.type === _types.TokenType._function ||
  897. _base.state.type === _types.TokenType._class ||
  898. _util.isContextual.call(void 0, _keywords.ContextualKeyword._async) ||
  899. _tokenizer.match.call(void 0, _types.TokenType.at)
  900. );
  901. }
  902. // Parses a comma-separated list of module exports.
  903. function parseExportSpecifiers() {
  904. let first = true;
  905. // export { x, y as z } [from '...']
  906. _util.expect.call(void 0, _types.TokenType.braceL);
  907. while (!_tokenizer.eat.call(void 0, _types.TokenType.braceR) && !_base.state.error) {
  908. if (first) {
  909. first = false;
  910. } else {
  911. _util.expect.call(void 0, _types.TokenType.comma);
  912. if (_tokenizer.eat.call(void 0, _types.TokenType.braceR)) {
  913. break;
  914. }
  915. }
  916. parseExportSpecifier();
  917. }
  918. } exports.parseExportSpecifiers = parseExportSpecifiers;
  919. function parseExportSpecifier() {
  920. if (_base.isTypeScriptEnabled) {
  921. _typescript.tsParseExportSpecifier.call(void 0, );
  922. return;
  923. }
  924. _expression.parseIdentifier.call(void 0, );
  925. _base.state.tokens[_base.state.tokens.length - 1].identifierRole = _tokenizer.IdentifierRole.ExportAccess;
  926. if (_util.eatContextual.call(void 0, _keywords.ContextualKeyword._as)) {
  927. _expression.parseIdentifier.call(void 0, );
  928. }
  929. }
  930. /**
  931. * Starting at the `module` token in an import, determine if it was truly an
  932. * import reflection token or just looks like one.
  933. *
  934. * Returns true for:
  935. * import module foo from "foo";
  936. * import module from from "foo";
  937. *
  938. * Returns false for:
  939. * import module from "foo";
  940. * import module, {bar} from "foo";
  941. */
  942. function isImportReflection() {
  943. const snapshot = _base.state.snapshot();
  944. _util.expectContextual.call(void 0, _keywords.ContextualKeyword._module);
  945. if (_util.eatContextual.call(void 0, _keywords.ContextualKeyword._from)) {
  946. if (_util.isContextual.call(void 0, _keywords.ContextualKeyword._from)) {
  947. _base.state.restoreFromSnapshot(snapshot);
  948. return true;
  949. } else {
  950. _base.state.restoreFromSnapshot(snapshot);
  951. return false;
  952. }
  953. } else if (_tokenizer.match.call(void 0, _types.TokenType.comma)) {
  954. _base.state.restoreFromSnapshot(snapshot);
  955. return false;
  956. } else {
  957. _base.state.restoreFromSnapshot(snapshot);
  958. return true;
  959. }
  960. }
  961. /**
  962. * Eat the "module" token from the import reflection proposal.
  963. * https://github.com/tc39/proposal-import-reflection
  964. */
  965. function parseMaybeImportReflection() {
  966. // isImportReflection does snapshot/restore, so only run it if we see the word
  967. // "module".
  968. if (_util.isContextual.call(void 0, _keywords.ContextualKeyword._module) && isImportReflection()) {
  969. _tokenizer.next.call(void 0, );
  970. }
  971. }
  972. // Parses import declaration.
  973. function parseImport() {
  974. if (_base.isTypeScriptEnabled && _tokenizer.match.call(void 0, _types.TokenType.name) && _tokenizer.lookaheadType.call(void 0, ) === _types.TokenType.eq) {
  975. _typescript.tsParseImportEqualsDeclaration.call(void 0, );
  976. return;
  977. }
  978. if (_base.isTypeScriptEnabled && _util.isContextual.call(void 0, _keywords.ContextualKeyword._type)) {
  979. const lookahead = _tokenizer.lookaheadTypeAndKeyword.call(void 0, );
  980. if (lookahead.type === _types.TokenType.name && lookahead.contextualKeyword !== _keywords.ContextualKeyword._from) {
  981. // One of these `import type` cases:
  982. // import type T = require('T');
  983. // import type A from 'A';
  984. _util.expectContextual.call(void 0, _keywords.ContextualKeyword._type);
  985. if (_tokenizer.lookaheadType.call(void 0, ) === _types.TokenType.eq) {
  986. _typescript.tsParseImportEqualsDeclaration.call(void 0, );
  987. return;
  988. }
  989. // If this is an `import type...from` statement, then we already ate the
  990. // type token, so proceed to the regular import parser.
  991. } else if (lookahead.type === _types.TokenType.star || lookahead.type === _types.TokenType.braceL) {
  992. // One of these `import type` cases, in which case we can eat the type token
  993. // and proceed as normal:
  994. // import type * as A from 'A';
  995. // import type {a} from 'A';
  996. _util.expectContextual.call(void 0, _keywords.ContextualKeyword._type);
  997. }
  998. // Otherwise, we are importing the name "type".
  999. }
  1000. // import '...'
  1001. if (_tokenizer.match.call(void 0, _types.TokenType.string)) {
  1002. _expression.parseExprAtom.call(void 0, );
  1003. } else {
  1004. parseMaybeImportReflection();
  1005. parseImportSpecifiers();
  1006. _util.expectContextual.call(void 0, _keywords.ContextualKeyword._from);
  1007. _expression.parseExprAtom.call(void 0, );
  1008. }
  1009. maybeParseImportAssertions();
  1010. _util.semicolon.call(void 0, );
  1011. } exports.parseImport = parseImport;
  1012. // eslint-disable-next-line no-unused-vars
  1013. function shouldParseDefaultImport() {
  1014. return _tokenizer.match.call(void 0, _types.TokenType.name);
  1015. }
  1016. function parseImportSpecifierLocal() {
  1017. _lval.parseImportedIdentifier.call(void 0, );
  1018. }
  1019. // Parses a comma-separated list of module imports.
  1020. function parseImportSpecifiers() {
  1021. if (_base.isFlowEnabled) {
  1022. _flow.flowStartParseImportSpecifiers.call(void 0, );
  1023. }
  1024. let first = true;
  1025. if (shouldParseDefaultImport()) {
  1026. // import defaultObj, { x, y as z } from '...'
  1027. parseImportSpecifierLocal();
  1028. if (!_tokenizer.eat.call(void 0, _types.TokenType.comma)) return;
  1029. }
  1030. if (_tokenizer.match.call(void 0, _types.TokenType.star)) {
  1031. _tokenizer.next.call(void 0, );
  1032. _util.expectContextual.call(void 0, _keywords.ContextualKeyword._as);
  1033. parseImportSpecifierLocal();
  1034. return;
  1035. }
  1036. _util.expect.call(void 0, _types.TokenType.braceL);
  1037. while (!_tokenizer.eat.call(void 0, _types.TokenType.braceR) && !_base.state.error) {
  1038. if (first) {
  1039. first = false;
  1040. } else {
  1041. // Detect an attempt to deep destructure
  1042. if (_tokenizer.eat.call(void 0, _types.TokenType.colon)) {
  1043. _util.unexpected.call(void 0,
  1044. "ES2015 named imports do not destructure. Use another statement for destructuring after the import.",
  1045. );
  1046. }
  1047. _util.expect.call(void 0, _types.TokenType.comma);
  1048. if (_tokenizer.eat.call(void 0, _types.TokenType.braceR)) {
  1049. break;
  1050. }
  1051. }
  1052. parseImportSpecifier();
  1053. }
  1054. }
  1055. function parseImportSpecifier() {
  1056. if (_base.isTypeScriptEnabled) {
  1057. _typescript.tsParseImportSpecifier.call(void 0, );
  1058. return;
  1059. }
  1060. if (_base.isFlowEnabled) {
  1061. _flow.flowParseImportSpecifier.call(void 0, );
  1062. return;
  1063. }
  1064. _lval.parseImportedIdentifier.call(void 0, );
  1065. if (_util.isContextual.call(void 0, _keywords.ContextualKeyword._as)) {
  1066. _base.state.tokens[_base.state.tokens.length - 1].identifierRole = _tokenizer.IdentifierRole.ImportAccess;
  1067. _tokenizer.next.call(void 0, );
  1068. _lval.parseImportedIdentifier.call(void 0, );
  1069. }
  1070. }
  1071. /**
  1072. * Parse import assertions like `assert {type: "json"}`.
  1073. *
  1074. * Import assertions technically have their own syntax, but are always parseable
  1075. * as a plain JS object, so just do that for simplicity.
  1076. */
  1077. function maybeParseImportAssertions() {
  1078. if (_util.isContextual.call(void 0, _keywords.ContextualKeyword._assert) && !_util.hasPrecedingLineBreak.call(void 0, )) {
  1079. _tokenizer.next.call(void 0, );
  1080. _expression.parseObj.call(void 0, false, false);
  1081. }
  1082. }