Image optimization & Lazy Load by Optimole - Version 2.0.0

Version Description

Download this release

Release Info

Developer optimole
Plugin Icon 128x128 Image optimization & Lazy Load by Optimole
Version 2.0.0
Comparing to
See all releases

Code changes from version 1.1.2 to 2.0.0

Files changed (132) hide show
  1. CHANGELOG.md +102 -60
  2. README.md +223 -0
  3. assets/css/style.scss +189 -164
  4. assets/js/bundle.js +20296 -17468
  5. assets/js/bundle.min.js +21 -16
  6. inc/admin.php +562 -523
  7. inc/api.php +241 -166
  8. inc/app_replacer.php +288 -0
  9. inc/config.php +81 -0
  10. inc/image.php +143 -0
  11. inc/image_properties/height.php +60 -0
  12. inc/image_properties/property_type.php +31 -0
  13. inc/image_properties/quality.php +78 -0
  14. inc/image_properties/resize.php +162 -0
  15. inc/image_properties/watermark.php +73 -0
  16. inc/image_properties/width.php +62 -0
  17. inc/lazyload_replacer.php +161 -0
  18. inc/main.php +229 -197
  19. inc/manager.php +352 -0
  20. inc/replacer.php +0 -1050
  21. inc/rest.php +451 -356
  22. inc/settings.php +308 -227
  23. inc/tag_replacer.php +361 -0
  24. inc/traits/normalizer.php +196 -0
  25. inc/traits/validator.php +44 -0
  26. inc/url_replacer.php +143 -0
  27. optimole-wp.php +95 -61
  28. readme.md +0 -117
  29. readme.txt +223 -117
  30. themeisle-hash.json +1 -1
  31. vendor/autoload.php +2 -2
  32. vendor/codeinwp/themeisle-sdk/CHANGELOG.md +14 -0
  33. vendor/codeinwp/themeisle-sdk/load.php +2 -2
  34. vendor/composer/ClassLoader.php +46 -14
  35. vendor/composer/LICENSE +1 -1
  36. vendor/composer/autoload_psr4.php +0 -1
  37. vendor/composer/autoload_real.php +28 -17
  38. vendor/composer/autoload_static.php +19 -0
  39. vendor/composer/installed.json +7 -132
  40. vendor/composer/installers/LICENSE +0 -19
  41. vendor/composer/installers/composer.json +0 -105
  42. vendor/composer/installers/src/Composer/Installers/AglInstaller.php +0 -21
  43. vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php +0 -9
  44. vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php +0 -11
  45. vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php +0 -49
  46. vendor/composer/installers/src/Composer/Installers/AttogramInstaller.php +0 -9
  47. vendor/composer/installers/src/Composer/Installers/BaseInstaller.php +0 -136
  48. vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php +0 -126
  49. vendor/composer/installers/src/Composer/Installers/BonefishInstaller.php +0 -9
  50. vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php +0 -82
  51. vendor/composer/installers/src/Composer/Installers/ChefInstaller.php +0 -11
  52. vendor/composer/installers/src/Composer/Installers/CiviCrmInstaller.php +0 -9
  53. vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php +0 -10
  54. vendor/composer/installers/src/Composer/Installers/CockpitInstaller.php +0 -34
  55. vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php +0 -11
  56. vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php +0 -13
  57. vendor/composer/installers/src/Composer/Installers/CraftInstaller.php +0 -35
  58. vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php +0 -21
  59. vendor/composer/installers/src/Composer/Installers/DecibelInstaller.php +0 -10
  60. vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php +0 -50
  61. vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php +0 -16
  62. vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php +0 -16
  63. vendor/composer/installers/src/Composer/Installers/ElggInstaller.php +0 -9
  64. vendor/composer/installers/src/Composer/Installers/EliasisInstaller.php +0 -12
  65. vendor/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php +0 -29
  66. vendor/composer/installers/src/Composer/Installers/EzPlatformInstaller.php +0 -10
  67. vendor/composer/installers/src/Composer/Installers/FuelInstaller.php +0 -11
  68. vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php +0 -9
  69. vendor/composer/installers/src/Composer/Installers/GravInstaller.php +0 -30
  70. vendor/composer/installers/src/Composer/Installers/HuradInstaller.php +0 -25
  71. vendor/composer/installers/src/Composer/Installers/ImageCMSInstaller.php +0 -11
  72. vendor/composer/installers/src/Composer/Installers/Installer.php +0 -274
  73. vendor/composer/installers/src/Composer/Installers/ItopInstaller.php +0 -9
  74. vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php +0 -15
  75. vendor/composer/installers/src/Composer/Installers/KanboardInstaller.php +0 -18
  76. vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php +0 -11
  77. vendor/composer/installers/src/Composer/Installers/KodiCMSInstaller.php +0 -10
  78. vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php +0 -9
  79. vendor/composer/installers/src/Composer/Installers/LanManagementSystemInstaller.php +0 -27
  80. vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php +0 -9
  81. vendor/composer/installers/src/Composer/Installers/LavaLiteInstaller.php +0 -10
  82. vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php +0 -10
  83. vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php +0 -9
  84. vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php +0 -16
  85. vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php +0 -11
  86. vendor/composer/installers/src/Composer/Installers/MajimaInstaller.php +0 -37
  87. vendor/composer/installers/src/Composer/Installers/MakoInstaller.php +0 -9
  88. vendor/composer/installers/src/Composer/Installers/MauticInstaller.php +0 -25
  89. vendor/composer/installers/src/Composer/Installers/MayaInstaller.php +0 -33
  90. vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php +0 -51
  91. vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php +0 -111
  92. vendor/composer/installers/src/Composer/Installers/ModxInstaller.php +0 -12
  93. vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php +0 -57
  94. vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php +0 -47
  95. vendor/composer/installers/src/Composer/Installers/OntoWikiInstaller.php +0 -24
  96. vendor/composer/installers/src/Composer/Installers/OsclassInstaller.php +0 -14
  97. vendor/composer/installers/src/Composer/Installers/OxidInstaller.php +0 -59
  98. vendor/composer/installers/src/Composer/Installers/PPIInstaller.php +0 -9
  99. vendor/composer/installers/src/Composer/Installers/PhiftyInstaller.php +0 -11
  100. vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php +0 -11
  101. vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php +0 -21
  102. vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php +0 -32
  103. vendor/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php +0 -29
  104. vendor/composer/installers/src/Composer/Installers/Plugin.php +0 -17
  105. vendor/composer/installers/src/Composer/Installers/PortoInstaller.php +0 -9
  106. vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php +0 -10
  107. vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php +0 -11
  108. vendor/composer/installers/src/Composer/Installers/PxcmsInstaller.php +0 -63
  109. vendor/composer/installers/src/Composer/Installers/RadPHPInstaller.php +0 -24
  110. vendor/composer/installers/src/Composer/Installers/ReIndexInstaller.php +0 -10
  111. vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php +0 -10
  112. vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php +0 -22
  113. vendor/composer/installers/src/Composer/Installers/SMFInstaller.php +0 -10
  114. vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php +0 -60
  115. vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php +0 -35
  116. vendor/composer/installers/src/Composer/Installers/SiteDirectInstaller.php +0 -25
  117. vendor/composer/installers/src/Composer/Installers/SyDESInstaller.php +0 -49
  118. vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php +0 -26
  119. vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php +0 -16
  120. vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php +0 -38
  121. vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php +0 -12
  122. vendor/composer/installers/src/Composer/Installers/TuskInstaller.php +0 -14
  123. vendor/composer/installers/src/Composer/Installers/UserFrostingInstaller.php +0 -9
  124. vendor/composer/installers/src/Composer/Installers/VanillaInstaller.php +0 -10
  125. vendor/composer/installers/src/Composer/Installers/VgmcpInstaller.php +0 -49
  126. vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php +0 -10
  127. vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php +0 -9
  128. vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php +0 -12
  129. vendor/composer/installers/src/Composer/Installers/YawikInstaller.php +0 -32
  130. vendor/composer/installers/src/Composer/Installers/ZendInstaller.php +0 -11
  131. vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php +0 -10
  132. vendor/composer/installers/src/bootstrap.php +0 -13
CHANGELOG.md CHANGED
@@ -1,60 +1,102 @@
1
-
2
- ### v1.1.2 - 2018-12-24
3
- **Changes:**
4
- * Minor fixes to Optimole dashboard page.
5
- * Fixes DNS prefetch call when lazyload is off.
6
- * Enable lazyload and javascript replacement by default for new users.
7
-
8
- ### v1.1.1 - 2018-12-10
9
- **Changes:**
10
- * Improve the lazy loading mechanism and adds compatibility with the new javascript library.
11
- * Improve sample images and quality selector integration.
12
- * Adds a notice when the Rest API is not available.
13
- * Adds notice for new users on how the plugin works.
14
- * Tested up with WordPress 5.0, all working smooth.
15
- * Fix possible issues with thumbnails when the original image is available on a different url scheme.
16
- * Ignore lazyload replacement on feed/amp pages.
17
-
18
- ### v1.1.0 - 2018-11-16
19
- **Changes:**
20
- * Integrates lazy load feature with support for low-quality placeholders ( LQIP ).
21
- * Integrates Javascript library which delivers images at the right size for each device, including Retina.
22
- * Improve image replacement algorithm.
23
- * Improves compatibility with Elementor and Gutenberg.
24
- * Adds support for Custom CNAME and Client hints.
25
- * Improves support for custom CDN.
26
- * Improves AMP support.
27
- * Improves compatibility with WordPress Multisites.
28
-
29
- ### v1.0.5 - 2018-10-05
30
- **Changes:**
31
- * Adds max width/height option.
32
- * Improves registration workflow.
33
- * Adds image comparison slider ratio.
34
- * Adds logo on link preload.
35
-
36
- ### v1.0.4 - 2018-10-03
37
- **Changes:**
38
- * Adds in-plugin service registration.
39
- * Adds image quality control.
40
- * Adds slider for image comparison.
41
- * Improvements to UX and workflow.
42
-
43
- ### v1.0.3 - 2018-09-26
44
- **Changes:**
45
- * Adds redirect on first install.
46
- * Improve elementor assets replacement.
47
-
48
- ### v1.0.2 - 2018-09-25
49
- **Changes:**
50
- * Improve compatibility with elementor external css files.
51
- * Adds generator tag.
52
- * Improve replacer handler hook register.
53
-
54
- ### v1.0.1 - 2018-09-23
55
- **Changes:**
56
- * Tag first stable version for wordpress.org.
57
-
58
- ### v1.0.0 - 2018-09-11
59
- **Changes:**
60
- * First version of the plugin
1
+ ### [2.0.0](https://github.com/Codeinwp/optimole-wp/compare/v1.1.2...v2.0.0) (2019-01-21)
2
+
3
+
4
+ #### Bug Fixes
5
+
6
+ * errors on low PHP environments when PHP_INT_MIN constant is not available ([44eb4af](https://github.com/Codeinwp/optimole-wp/commit/44eb4af))
7
+
8
+ * fix tag replacement on lazy load, preserve image size when found ([5c6ef70](https://github.com/Codeinwp/optimole-wp/commit/5c6ef70))
9
+
10
+ * improve image size replacement mapping for custom image sizes ([d816ccb](https://github.com/Codeinwp/optimole-wp/commit/d816ccb))
11
+
12
+ * improve lazyload fade in effect, fixes [#71](https://github.com/Codeinwp/optimole-wp/issues/71) ([eb0f76c](https://github.com/Codeinwp/optimole-wp/commit/eb0f76c))
13
+
14
+ * possible issue with image replacement not taking place when other buffer handler is registered ([3ce600a](https://github.com/Codeinwp/optimole-wp/commit/3ce600a))
15
+
16
+ * resize behaviour for WordPress defined image sizes, preserve cropping for custom sizes ([a42f830](https://github.com/Codeinwp/optimole-wp/commit/a42f830))
17
+
18
+
19
+
20
+ #### Documentation
21
+
22
+ * add basic faq to readme file ([2c09d26](https://github.com/Codeinwp/optimole-wp/commit/2c09d26))
23
+
24
+ * adds contributor related docs and github templates ([c7bbce2](https://github.com/Codeinwp/optimole-wp/commit/c7bbce2))
25
+
26
+
27
+
28
+ #### Features
29
+
30
+ * adds new service schema ([330fba0](https://github.com/Codeinwp/optimole-wp/commit/330fba0))
31
+
32
+ * adds watermark integration along with various options for watermark position ([6a4538a](https://github.com/Codeinwp/optimole-wp/commit/6a4538a))
33
+
34
+ * deactivate plugin on lower php versions, adds notice for PHP for upgrade ([58d2607](https://github.com/Codeinwp/optimole-wp/commit/58d2607))
35
+
36
+
37
+
38
+ #### Performance Improvements
39
+
40
+ * improve srcset replacement, use attachement id when present ([5587221](https://github.com/Codeinwp/optimole-wp/commit/5587221))
41
+
42
+ * improve type casting on size constrain ([589b046](https://github.com/Codeinwp/optimole-wp/commit/589b046))
43
+
44
+ ### v1.1.2 - 2018-12-24
45
+ **Changes:**
46
+ * Minor fixes to Optimole dashboard page.
47
+ * Fixes DNS prefetch call when lazyload is off.
48
+ * Enable lazyload and javascript replacement by default for new users.
49
+
50
+ ### v1.1.1 - 2018-12-10
51
+ **Changes:**
52
+ * Improve the lazy loading mechanism and adds compatibility with the new javascript library.
53
+ * Improve sample images and quality selector integration.
54
+ * Adds a notice when the Rest API is not available.
55
+ * Adds notice for new users on how the plugin works.
56
+ * Tested up with WordPress 5.0, all working smooth.
57
+ * Fix possible issues with thumbnails when the original image is available on a different url scheme.
58
+ * Ignore lazyload replacement on feed/amp pages.
59
+
60
+ ### v1.1.0 - 2018-11-16
61
+ **Changes:**
62
+ * Integrates lazy load feature with support for low-quality placeholders ( LQIP ).
63
+ * Integrates Javascript library which delivers images at the right size for each device, including Retina.
64
+ * Improve image replacement algorithm.
65
+ * Improves compatibility with Elementor and Gutenberg.
66
+ * Adds support for Custom CNAME and Client hints.
67
+ * Improves support for custom CDN.
68
+ * Improves AMP support.
69
+ * Improves compatibility with WordPress Multisites.
70
+
71
+ ### v1.0.5 - 2018-10-05
72
+ **Changes:**
73
+ * Adds max width/height option.
74
+ * Improves registration workflow.
75
+ * Adds image comparison slider ratio.
76
+ * Adds logo on link preload.
77
+
78
+ ### v1.0.4 - 2018-10-03
79
+ **Changes:**
80
+ * Adds in-plugin service registration.
81
+ * Adds image quality control.
82
+ * Adds slider for image comparison.
83
+ * Improvements to UX and workflow.
84
+
85
+ ### v1.0.3 - 2018-09-26
86
+ **Changes:**
87
+ * Adds redirect on first install.
88
+ * Improve elementor assets replacement.
89
+
90
+ ### v1.0.2 - 2018-09-25
91
+ **Changes:**
92
+ * Improve compatibility with elementor external css files.
93
+ * Adds generator tag.
94
+ * Improve replacer handler hook register.
95
+
96
+ ### v1.0.1 - 2018-09-23
97
+ **Changes:**
98
+ * Tag first stable version for wordpress.org.
99
+
100
+ ### v1.0.0 - 2018-09-11
101
+ **Changes:**
102
+ * First version of the plugin
README.md ADDED
@@ -0,0 +1,223 @@
1
+ # Image optimization service by Optimole #
2
+ **Contributors:** [optimole](https://profiles.wordpress.org/optimole)
3
+ **Tags:** image optmization, cdn, image compression, compress image, images, optimization, perfomance, photos
4
+ **Requires at least:** 4.7
5
+ **Tested up to:** 5.0
6
+ **Requires PHP:** 5.4
7
+ **License:** GPLv3
8
+ **License URI:** https://www.gnu.org/licenses/gpl-3.0.en.html
9
+
10
+ End-to-end image processing
11
+ With OptiMole, your site’s images will be cropped, optimized and processed on-the-fly.
12
+
13
+
14
+ ## Description ##
15
+ **Image optimization & resizing**
16
+ Images are processed for best results with both lossless and lossy optimization and are automatically resized for any device.
17
+
18
+ **Image acceleration through CDN**
19
+ If you dont use a CDN, we got you covered, we will serve the images using our default CDN. You already have one, just let us know and we can integrate yours.
20
+
21
+ **On-the-fly image handling**
22
+ Dynamic manipulation of images and videos (resize, compress and serve via CDN on the fly).
23
+
24
+ **Easy tracking & monitoring**
25
+ Check how OptiMole is improving your site from day 1. Transparent optimization stats are always available.
26
+
27
+ ### How does it work? ###
28
+
29
+ This plugin connects via API to OptiMole [image optimization service](https://optimole.com/) in order to send the images to its servers and crop, optimize and process them on-the-fly. The EXIF data will either be stripped and it is not stored on our servers. Optimole does not interact with the visitors on your website. We care about your privacy so check our [terms of use](https://optimole.com/terms/).
30
+
31
+ The plugin will rewrite your image URLs to replace them with OptiMole URLs. Your origin images will be downloaded from your storage, processed by the OptiMole infrastructure and cached in the CDN. NO development needed. Simply set up your account and enjoy faster image loading.
32
+
33
+
34
+ ## Screenshots ##
35
+
36
+ 1. Welcome screen
37
+ 2. Connect screen
38
+ 3. Plugin dashboard
39
+ 4. Plugin settings
40
+
41
+ ## Changelog ##
42
+
43
+ ### [2.0.0](https://github.com/Codeinwp/optimole-wp/compare/v1.1.2...v2.0.0) (2019-01-21)
44
+
45
+
46
+ #### Bug Fixes
47
+
48
+ * errors on low PHP environments when PHP_INT_MIN constant is not available ([44eb4af](https://github.com/Codeinwp/optimole-wp/commit/44eb4af))
49
+
50
+ * fix tag replacement on lazy load, preserve image size when found ([5c6ef70](https://github.com/Codeinwp/optimole-wp/commit/5c6ef70))
51
+
52
+ * improve image size replacement mapping for custom image sizes ([d816ccb](https://github.com/Codeinwp/optimole-wp/commit/d816ccb))
53
+
54
+ * improve lazyload fade in effect, fixes [#71](https://github.com/Codeinwp/optimole-wp/issues/71) ([eb0f76c](https://github.com/Codeinwp/optimole-wp/commit/eb0f76c))
55
+
56
+ * possible issue with image replacement not taking place when other buffer handler is registered ([3ce600a](https://github.com/Codeinwp/optimole-wp/commit/3ce600a))
57
+
58
+ * resize behaviour for WordPress defined image sizes, preserve cropping for custom sizes ([a42f830](https://github.com/Codeinwp/optimole-wp/commit/a42f830))
59
+
60
+
61
+
62
+ #### Documentation
63
+
64
+ * add basic faq to readme file ([2c09d26](https://github.com/Codeinwp/optimole-wp/commit/2c09d26))
65
+
66
+ * adds contributor related docs and github templates ([c7bbce2](https://github.com/Codeinwp/optimole-wp/commit/c7bbce2))
67
+
68
+
69
+
70
+ #### Features
71
+
72
+ * adds new service schema ([330fba0](https://github.com/Codeinwp/optimole-wp/commit/330fba0))
73
+
74
+ * adds watermark integration along with various options for watermark position ([6a4538a](https://github.com/Codeinwp/optimole-wp/commit/6a4538a))
75
+
76
+ * deactivate plugin on lower php versions, adds notice for PHP for upgrade ([58d2607](https://github.com/Codeinwp/optimole-wp/commit/58d2607))
77
+
78
+
79
+
80
+ #### Performance Improvements
81
+
82
+ * improve srcset replacement, use attachement id when present ([5587221](https://github.com/Codeinwp/optimole-wp/commit/5587221))
83
+
84
+ * improve type casting on size constrain ([589b046](https://github.com/Codeinwp/optimole-wp/commit/589b046))
85
+
86
+
87
+
88
+
89
+
90
+ ### 1.1.2 - 2018-12-24 ###
91
+
92
+ * Minor fixes to Optimole dashboard page.
93
+ * Fixes DNS prefetch call when lazyload is off.
94
+ * Enable lazyload and javascript replacement by default for new users.
95
+
96
+
97
+ ### 1.1.1 - 2018-12-10 ###
98
+
99
+ * Improve the lazy loading mechanism and adds compatibility with the new javascript library.
100
+ * Improve sample images and quality selector integration.
101
+ * Adds a notice when the Rest API is not available.
102
+ * Adds notice for new users on how the plugin works.
103
+ * Tested up with WordPress 5.0, all working smooth.
104
+ * Fix possible issues with thumbnails when the original image is available on a different url scheme.
105
+ * Ignore lazyload replacement on feed/amp pages.
106
+
107
+
108
+ ### 1.1.0 - 2018-11-16 ###
109
+
110
+ * Integrates lazy load feature with support for low-quality placeholders ( LQIP ).
111
+ * Integrates Javascript library which delivers images at the right size for each device, including Retina.
112
+ * Improve image replacement algorithm.
113
+ * Improves compatibility with Elementor and Gutenberg.
114
+ * Adds support for Custom CNAME and Client hints.
115
+ * Improves support for custom CDN.
116
+ * Improves AMP support.
117
+ * Improves compatibility with WordPress Multisites.
118
+
119
+
120
+ ### 1.0.5 - 2018-10-05 ###
121
+
122
+ * Adds max width/height option.
123
+ * Improves registration workflow.
124
+ * Adds image comparison slider ratio.
125
+ * Adds logo on link preload.
126
+
127
+
128
+ ### 1.0.4 - 2018-10-03 ###
129
+
130
+ * Adds in-plugin service registration.
131
+ * Adds image quality control.
132
+ * Adds slider for image comparison.
133
+ * Improvements to UX and workflow.
134
+
135
+
136
+ ### 1.0.3 - 2018-09-26 ###
137
+
138
+ * Adds redirect on first install.
139
+ * Improve elementor assets replacement.
140
+
141
+
142
+ ### 1.0.2 - 2018-09-25 ###
143
+
144
+ * Improve compatibility with elementor external css files.
145
+ * Adds generator tag.
146
+ * Improve replacer handler hook register.
147
+
148
+
149
+ ### 1.0.1 - 2018-09-23 ###
150
+
151
+ * Tag first stable version for wordpress.org.
152
+
153
+
154
+
155
+ ### 1.0.0 - 2018-09-22 ###
156
+ * First version of the plugin
157
+
158
+ ## Installation ##
159
+ The following are the steps to install the OptiMole plugin
160
+
161
+ 1. In your WordPress Administration Panels, click on Add New option under Plugins from the menu.
162
+ Click on upload at the top.
163
+ 2. Browse the location and select the OptiMole Plugin and click install now.
164
+ 3. Go to Media -> OptiMole and follow in the instructions on how to enable the service.
165
+
166
+ ## Frequently Asked Questions ##
167
+
168
+ ### How many images I can optimize with each plan? ###
169
+
170
+ The number of images that you can optimize depends on your original image size and the number of transformations you do for it. Using the Free plan you can optimize up to 1 GB of images, which means around 2000 images at an average of 500Kb per image.
171
+
172
+ ### What happens if I exceed plan limits? ###
173
+
174
+ Once you exceed these, we will contact you and kindly ask to upgrade to the plan that fits you best.
175
+
176
+ ### What Content Delivery Network (CDN) do you use? ###
177
+
178
+ Our FREE plan uses our custom made CDN built with 7 locations around the globe. For the paid plans, we have direct integration with Amazon Cloudfront, with more than 130 locations around the globe.
179
+
180
+ ### I'm already using a CDN, can I use that instead of yours ? ###
181
+
182
+ Short answer, YES. We can help you integrate your default CDN but it will require some additional work from our side and is available to Enterprise plans.
183
+
184
+ ### I'm already using an image optimization plugin, why should I switch to OptiMole? ###
185
+
186
+ You don’t need to change your existing optimization plugin, image optimization is just a small part of what we do, if you are happy with ShortPixel for e.g, feel free to continue to use it, OptiMole would then take care only of serving your image at the RIGHT size, advanced cropping and smart lazy-loading.
187
+
188
+ ### Will the original images be deleted? ###
189
+
190
+ Absolutely No. We use your original images as sources when deliver the optimized images.
191
+
192
+ ### What is the difference between the Auto, High, Medium, Low compression levels? ###
193
+
194
+ A higher compression might result in a small loss of image quality. Selecting the auto level will let Optimole choose the minimum size with no loss in the quality of your picture.
195
+
196
+ ### I used Kraken, Shortpixel, Optimus, EWWW or WP Smush, Imagify will OptiMole further optimize my images? ###
197
+
198
+ Yes, Optimole will also take care of serving your image at the RIGHT size for your visitors and optimize them to the best possible format for their browser.
199
+
200
+ ### Which formats can be optimized ? ###
201
+
202
+ For now we support jpg, png and svg format.
203
+
204
+ ### Does Optimole automatically serve WebP for Chrome users ? ###
205
+
206
+ Yes. We automatically detect user browser and serve WebP if is supported, otherwise we optimize the image in the original format.
207
+
208
+ ### Can i disable lazyload for PNG images ? ###
209
+
210
+ Yes. You need to add `define("OPTML_DISABLE_PNG_LAZYLOAD",true);` to `your wp-config.php` file.
211
+
212
+ ### Can i disable optimization for a certain image ? ###
213
+
214
+ Yes, you can follow this code snippet and replace the sample image with the one you need:
215
+ <code>
216
+ add_filter('optml_dont_replace_url', function( $old, $url ) {
217
+ if ( $url === 'https://example.com/wp-content/uploads/2018/09/1.jpg' ) {
218
+ return true;
219
+ }
220
+ return $old;
221
+
222
+ }, 10, 2);
223
+ </code>
assets/css/style.scss CHANGED
@@ -1,164 +1,189 @@
1
-
2
- #optimole-app {
3
- padding: 0 30px 0 20px;
4
-
5
- $primary: #EF686B;
6
- $success: #34a85e;
7
- $danger: #D54222;
8
- $info: #5180C1;
9
-
10
- @import "~bulma/bulma";
11
-
12
- .card {
13
- transition: all 750ms ease-in-out;
14
- border: 0;
15
- border-radius: .1875rem;
16
- -webkit-box-shadow: 0 1px 15px 1px rgba(39, 39, 39, .1);
17
- box-shadow: 0 1px 15px 1px rgba(39, 39, 39, .1);
18
- }
19
-
20
- .logo {
21
- margin-bottom: 10px;
22
- img {
23
- max-width: 180px;
24
- margin: 0 auto;
25
- }
26
- }
27
- .vue-js-switch {
28
- align-self: center;
29
- }
30
- .api-key-control {
31
- padding: 0 15px 0 0;
32
- }
33
-
34
- .api-key-field .button.is-danger {
35
- padding-left: 20px;
36
- padding-right: 20px;
37
- }
38
-
39
- .api-key-label {
40
- align-self: center;
41
- margin: 0.5em 10px 0.5em 0;
42
- font-size: 1em;
43
- }
44
- .header {
45
- padding: 0 1.5rem 0;
46
- &.level {
47
- margin-bottom: 0;
48
- }
49
- }
50
- .account {
51
- img {
52
- border-top-right-radius: 4px;
53
- border-bottom-right-radius: 4px;
54
- }
55
- .label {
56
- margin-bottom: 0;
57
- }
58
- }
59
-
60
- //Optimized images.
61
- .optimized-images {
62
-
63
- table td, table th {
64
- vertical-align: middle;
65
- }
66
- }
67
- .media-diff {
68
- position: relative;
69
- margin: 0 auto;
70
- video, img {
71
- display: block;
72
- position: absolute;
73
- top: 0;
74
- left: 0;
75
- width: 100%;
76
- height: 100%;
77
- }
78
- }
79
-
80
- .origin-wrapper {
81
- position: absolute;
82
- left: 0;
83
- top: 0;
84
- width: 100%;
85
- height: 100%;
86
- overflow: hidden;
87
- z-index: 1;
88
- transform: translateZ(0);
89
- will-change: width;
90
- }
91
-
92
- .handle {
93
- position: absolute;
94
- top: 0;
95
- bottom: 0;
96
- color: rgba(255, 255, 255, 0.80);
97
- background-color: rgba(255, 255, 255, 0.80);;
98
- width: 2px;
99
- cursor: ew-resize;
100
- transform: translateX(-50%) translateZ(0);
101
- z-index: 2;
102
- will-change: left;
103
- left: 200px;
104
- }
105
-
106
- .cursor {
107
- position: absolute;
108
- top: 50%;
109
- left: 50%;
110
- transform: translateX(-50%) translateZ(0);
111
- .circle {
112
- background-color: rgba(255, 255, 255, 0.80);
113
- width: 24px;
114
- height: 24px;
115
- border-radius: 50%;
116
- }
117
- }
118
- .no-padding-right{
119
- padding-right:0px !important;
120
- }
121
- }
122
-
123
- //Fade animation.
124
- .fade-enter-active, .fade-leave-active {
125
- transition: opacity .5s;
126
- }
127
-
128
- .fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */
129
- {
130
- opacity: 0;
131
- }
132
-
133
- .media_page_optimole #wpbody-content > * {
134
- display: none !important;
135
- }
136
-
137
- .media_page_optimole #wpbody-content > #optimole-app {
138
- display: block !important;
139
- }
140
-
141
- #optimole-app img.optml-image {
142
- float: left;
143
- max-width: 100px;
144
- width: auto;
145
- margin: auto;
146
- }
147
-
148
- .optml-ratio-feedback .emoji {
149
- font-size: 1.5em;
150
- }
151
-
152
-
153
- .optml-ratio-feedback {
154
- float: right;
155
- padding-right: 20px;
156
- }
157
- .optml-image-heading {
158
- text-align: left;
159
- }
160
-
161
- th.optml-image-ratio-heading {
162
- text-align: right !important;
163
- font-size: 150%;
164
- }
1
+
2
+ #optimole-app {
3
+ padding: 0 30px 0 20px;
4
+
5
+ $primary: #EF686B;
6
+ $success: #34a85e;
7
+ $danger: #D54222;
8
+ $info: #5180C1;
9
+
10
+ @import "~bulma/bulma";
11
+
12
+ .card {
13
+ transition: all 750ms ease-in-out;
14
+ border: 0;
15
+ border-radius: .1875rem;
16
+ -webkit-box-shadow: 0 1px 15px 1px rgba(39, 39, 39, .1);
17
+ box-shadow: 0 1px 15px 1px rgba(39, 39, 39, .1);
18
+ }
19
+
20
+ .logo {
21
+ margin-bottom: 10px;
22
+ img {
23
+ max-width: 180px;
24
+ margin: 0 auto;
25
+ }
26
+ }
27
+ .vue-js-switch {
28
+ align-self: center;
29
+ }
30
+ .api-key-control {
31
+ padding: 0 15px 0 0;
32
+ }
33
+
34
+ .api-key-field .button.is-danger {
35
+ padding-left: 20px;
36
+ padding-right: 20px;
37
+ }
38
+
39
+ .api-key-label {
40
+ align-self: center;
41
+ margin: 0.5em 10px 0.5em 0;
42
+ font-size: 1em;
43
+ }
44
+ .header {
45
+ padding: 0 1.5rem 0;
46
+ &.level {
47
+ margin-bottom: 0;
48
+ }
49
+ }
50
+ .account {
51
+ img {
52
+ border-top-right-radius: 4px;
53
+ border-bottom-right-radius: 4px;
54
+ }
55
+ .label {
56
+ margin-bottom: 0;
57
+ }
58
+ }
59
+
60
+ //Optimized images.
61
+ .optimized-images {
62
+
63
+ table td, table th {
64
+ vertical-align: middle;
65
+ }
66
+ }
67
+ .media-diff {
68
+ position: relative;
69
+ margin: 0 auto;
70
+ video, img {
71
+ display: block;
72
+ position: absolute;
73
+ top: 0;
74
+ left: 0;
75
+ width: 100%;
76
+ height: 100%;
77
+ }
78
+ }
79
+
80
+ .origin-wrapper {
81
+ position: absolute;
82
+ left: 0;
83
+ top: 0;
84
+ width: 100%;
85
+ height: 100%;
86
+ overflow: hidden;
87
+ z-index: 1;
88
+ transform: translateZ(0);
89
+ will-change: width;
90
+ }
91
+
92
+ .handle {
93
+ position: absolute;
94
+ top: 0;
95
+ bottom: 0;
96
+ color: rgba(255, 255, 255, 0.80);
97
+ background-color: rgba(255, 255, 255, 0.80);;
98
+ width: 2px;
99
+ cursor: ew-resize;
100
+ transform: translateX(-50%) translateZ(0);
101
+ z-index: 2;
102
+ will-change: left;
103
+ left: 200px;
104
+ }
105
+
106
+ .cursor {
107
+ position: absolute;
108
+ top: 50%;
109
+ left: 50%;
110
+ transform: translateX(-50%) translateZ(0);
111
+ .circle {
112
+ background-color: rgba(255, 255, 255, 0.80);
113
+ width: 24px;
114
+ height: 24px;
115
+ border-radius: 50%;
116
+ }
117
+ }
118
+ .no-padding-right{
119
+ padding-right:0px !important;
120
+ }
121
+ }
122
+
123
+ //Fade animation.
124
+ .fade-enter-active, .fade-leave-active {
125
+ transition: opacity .5s;
126
+ }
127
+
128
+ .fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */
129
+ {
130
+ opacity: 0;
131
+ }
132
+
133
+ .media_page_optimole #wpbody-content > * {
134
+ display: none !important;
135
+ }
136
+
137
+ .media_page_optimole #wpbody-content > #optimole-app {
138
+ display: block !important;
139
+ }
140
+
141
+ #optimole-app img.optml-image {
142
+ float: left;
143
+ max-width: 100px;
144
+ width: auto;
145
+ margin: auto;
146
+ }
147
+ #optimole-app img.optml-image-watermark {
148
+ width:50px;
149
+ }
150
+
151
+ .optml-ratio-feedback .emoji {
152
+ font-size: 1.5em;
153
+ }
154
+
155
+
156
+ .optml-ratio-feedback {
157
+ float: right;
158
+ padding-right: 20px;
159
+ }
160
+ .optml-image-heading {
161
+ text-align: left;
162
+ }
163
+
164
+ th.optml-image-ratio-heading {
165
+ text-align: right !important;
166
+ font-size: 150%;
167
+ }
168
+ @media screen and (max-width: 768px) {
169
+ li:not(.is-active) > a > span:not(.icon) {
170
+ visibility: hidden;
171
+ position: absolute;
172
+ }
173
+
174
+ nav.tabs li:not(.is-active) {
175
+ -webkit-box-flex: 0;
176
+ -ms-flex-positive: 0;
177
+ flex-grow: 0;
178
+ -ms-flex-negative: 1;
179
+ flex-shrink: 1;
180
+ }
181
+
182
+ .tabs .icon {
183
+ margin-left: 0.5em;
184
+ }
185
+ }
186
+
187
+ .tabs li {
188
+ transition: flex-grow 1s ease;
189
+ }
assets/js/bundle.js CHANGED
@@ -1,17469 +1,20297 @@
1
- /******/ (function(modules) { // webpackBootstrap
2
- /******/ // The module cache
3
- /******/ var installedModules = {};
4
- /******/
5
- /******/ // The require function
6
- /******/ function __webpack_require__(moduleId) {
7
- /******/
8
- /******/ // Check if module is in cache
9
- /******/ if(installedModules[moduleId]) {
10
- /******/ return installedModules[moduleId].exports;
11
- /******/ }
12
- /******/ // Create a new module (and put it into the cache)
13
- /******/ var module = installedModules[moduleId] = {
14
- /******/ i: moduleId,
15
- /******/ l: false,
16
- /******/ exports: {}
17
- /******/ };
18
- /******/
19
- /******/ // Execute the module function
20
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21
- /******/
22
- /******/ // Flag the module as loaded
23
- /******/ module.l = true;
24
- /******/
25
- /******/ // Return the exports of the module
26
- /******/ return module.exports;
27
- /******/ }
28
- /******/
29
- /******/
30
- /******/ // expose the modules object (__webpack_modules__)
31
- /******/ __webpack_require__.m = modules;
32
- /******/
33
- /******/ // expose the module cache
34
- /******/ __webpack_require__.c = installedModules;
35
- /******/
36
- /******/ // define getter function for harmony exports
37
- /******/ __webpack_require__.d = function(exports, name, getter) {
38
- /******/ if(!__webpack_require__.o(exports, name)) {
39
- /******/ Object.defineProperty(exports, name, {
40
- /******/ configurable: false,
41
- /******/ enumerable: true,
42
- /******/ get: getter
43
- /******/ });
44
- /******/ }
45
- /******/ };
46
- /******/
47
- /******/ // getDefaultExport function for compatibility with non-harmony modules
48
- /******/ __webpack_require__.n = function(module) {
49
- /******/ var getter = module && module.__esModule ?
50
- /******/ function getDefault() { return module['default']; } :
51
- /******/ function getModuleExports() { return module; };
52
- /******/ __webpack_require__.d(getter, 'a', getter);
53
- /******/ return getter;
54
- /******/ };
55
- /******/
56
- /******/ // Object.prototype.hasOwnProperty.call
57
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
58
- /******/
59
- /******/ // __webpack_public_path__
60
- /******/ __webpack_require__.p = "/";
61
- /******/
62
- /******/ // Load entry module and return exports
63
- /******/ return __webpack_require__(__webpack_require__.s = 7);
64
- /******/ })
65
- /************************************************************************/
66
- /******/ ([
67
- /* 0 */
68
- /***/ (function(module, exports) {
69
-
70
- /*
71
- MIT License http://www.opensource.org/licenses/mit-license.php
72
- Author Tobias Koppers @sokra
73
- */
74
- // css base code, injected by the css-loader
75
- module.exports = function() {
76
- var list = [];
77
-
78
- // return the list of modules as css string
79
- list.toString = function toString() {
80
- var result = [];
81
- for(var i = 0; i < this.length; i++) {
82
- var item = this[i];
83
- if(item[2]) {
84
- result.push("@media " + item[2] + "{" + item[1] + "}");
85
- } else {
86
- result.push(item[1]);
87
- }
88
- }
89
- return result.join("");
90
- };
91
-
92
- // import a list of modules into the list
93
- list.i = function(modules, mediaQuery) {
94
- if(typeof modules === "string")
95
- modules = [[null, modules, ""]];
96
- var alreadyImportedModules = {};
97
- for(var i = 0; i < this.length; i++) {
98
- var id = this[i][0];
99
- if(typeof id === "number")
100
- alreadyImportedModules[id] = true;
101
- }
102
- for(i = 0; i < modules.length; i++) {
103
- var item = modules[i];
104
- // skip already imported module
105
- // this implementation is not 100% perfect for weird media query combinations
106
- // when a module is imported multiple times with different media queries.
107
- // I hope this will never occur (Hey this way we have smaller bundles)
108
- if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
109
- if(mediaQuery && !item[2]) {
110
- item[2] = mediaQuery;
111
- } else if(mediaQuery) {
112
- item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
113
- }
114
- list.push(item);
115
- }
116
- }
117
- };
118
- return list;
119
- };
120
-
121
-
122
- /***/ }),
123
- /* 1 */
124
- /***/ (function(module, exports) {
125
-
126
- /*
127
- MIT License http://www.opensource.org/licenses/mit-license.php
128
- Author Tobias Koppers @sokra
129
- */
130
- var stylesInDom = {},
131
- memoize = function(fn) {
132
- var memo;
133
- return function () {
134
- if (typeof memo === "undefined") memo = fn.apply(this, arguments);
135
- return memo;
136
- };
137
- },
138
- isOldIE = memoize(function() {
139
- return /msie [6-9]\b/.test(self.navigator.userAgent.toLowerCase());
140
- }),
141
- getHeadElement = memoize(function () {
142
- return document.head || document.getElementsByTagName("head")[0];
143
- }),
144
- singletonElement = null,
145
- singletonCounter = 0,
146
- styleElementsInsertedAtTop = [];
147
-
148
- module.exports = function(list, options) {
149
- if(typeof DEBUG !== "undefined" && DEBUG) {
150
- if(typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
151
- }
152
-
153
- options = options || {};
154
- // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
155
- // tags it will allow on a page
156
- if (typeof options.singleton === "undefined") options.singleton = isOldIE();
157
-
158
- // By default, add <style> tags to the bottom of <head>.
159
- if (typeof options.insertAt === "undefined") options.insertAt = "bottom";
160
-
161
- var styles = listToStyles(list);
162
- addStylesToDom(styles, options);
163
-
164
- return function update(newList) {
165
- var mayRemove = [];
166
- for(var i = 0; i < styles.length; i++) {
167
- var item = styles[i];
168
- var domStyle = stylesInDom[item.id];
169
- domStyle.refs--;
170
- mayRemove.push(domStyle);
171
- }
172
- if(newList) {
173
- var newStyles = listToStyles(newList);
174
- addStylesToDom(newStyles, options);
175
- }
176
- for(var i = 0; i < mayRemove.length; i++) {
177
- var domStyle = mayRemove[i];
178
- if(domStyle.refs === 0) {
179
- for(var j = 0; j < domStyle.parts.length; j++)
180
- domStyle.parts[j]();
181
- delete stylesInDom[domStyle.id];
182
- }
183
- }
184
- };
185
- }
186
-
187
- function addStylesToDom(styles, options) {
188
- for(var i = 0; i < styles.length; i++) {
189
- var item = styles[i];
190
- var domStyle = stylesInDom[item.id];
191
- if(domStyle) {
192
- domStyle.refs++;
193
- for(var j = 0; j < domStyle.parts.length; j++) {
194
- domStyle.parts[j](item.parts[j]);
195
- }
196
- for(; j < item.parts.length; j++) {
197
- domStyle.parts.push(addStyle(item.parts[j], options));
198
- }
199
- } else {
200
- var parts = [];
201
- for(var j = 0; j < item.parts.length; j++) {
202
- parts.push(addStyle(item.parts[j], options));
203
- }
204
- stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
205
- }
206
- }
207
- }
208
-
209
- function listToStyles(list) {
210
- var styles = [];
211
- var newStyles = {};
212
- for(var i = 0; i < list.length; i++) {
213
- var item = list[i];
214
- var id = item[0];
215
- var css = item[1];
216
- var media = item[2];
217
- var sourceMap = item[3];
218
- var part = {css: css, media: media, sourceMap: sourceMap};
219
- if(!newStyles[id])
220
- styles.push(newStyles[id] = {id: id, parts: [part]});
221
- else
222
- newStyles[id].parts.push(part);
223
- }
224
- return styles;
225
- }
226
-
227
- function insertStyleElement(options, styleElement) {
228
- var head = getHeadElement();
229
- var lastStyleElementInsertedAtTop = styleElementsInsertedAtTop[styleElementsInsertedAtTop.length - 1];
230
- if (options.insertAt === "top") {
231
- if(!lastStyleElementInsertedAtTop) {
232
- head.insertBefore(styleElement, head.firstChild);
233
- } else if(lastStyleElementInsertedAtTop.nextSibling) {
234
- head.insertBefore(styleElement, lastStyleElementInsertedAtTop.nextSibling);
235
- } else {
236
- head.appendChild(styleElement);
237
- }
238
- styleElementsInsertedAtTop.push(styleElement);
239
- } else if (options.insertAt === "bottom") {
240
- head.appendChild(styleElement);
241
- } else {
242
- throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");
243
- }
244
- }
245
-
246
- function removeStyleElement(styleElement) {
247
- styleElement.parentNode.removeChild(styleElement);
248
- var idx = styleElementsInsertedAtTop.indexOf(styleElement);
249
- if(idx >= 0) {
250
- styleElementsInsertedAtTop.splice(idx, 1);
251
- }
252
- }
253
-
254
- function createStyleElement(options) {
255
- var styleElement = document.createElement("style");
256
- styleElement.type = "text/css";
257
- insertStyleElement(options, styleElement);
258
- return styleElement;
259
- }
260
-
261
- function createLinkElement(options) {
262
- var linkElement = document.createElement("link");
263
- linkElement.rel = "stylesheet";
264
- insertStyleElement(options, linkElement);
265
- return linkElement;
266
- }
267
-
268
- function addStyle(obj, options) {
269
- var styleElement, update, remove;
270
-
271
- if (options.singleton) {
272
- var styleIndex = singletonCounter++;
273
- styleElement = singletonElement || (singletonElement = createStyleElement(options));
274
- update = applyToSingletonTag.bind(null, styleElement, styleIndex, false);
275
- remove = applyToSingletonTag.bind(null, styleElement, styleIndex, true);
276
- } else if(obj.sourceMap &&
277
- typeof URL === "function" &&
278
- typeof URL.createObjectURL === "function" &&
279
- typeof URL.revokeObjectURL === "function" &&
280
- typeof Blob === "function" &&
281
- typeof btoa === "function") {
282
- styleElement = createLinkElement(options);
283
- update = updateLink.bind(null, styleElement);
284
- remove = function() {
285
- removeStyleElement(styleElement);
286
- if(styleElement.href)
287
- URL.revokeObjectURL(styleElement.href);
288
- };
289
- } else {
290
- styleElement = createStyleElement(options);
291
- update = applyToTag.bind(null, styleElement);
292
- remove = function() {
293
- removeStyleElement(styleElement);
294
- };
295
- }
296
-
297
- update(obj);
298
-
299
- return function updateStyle(newObj) {
300
- if(newObj) {
301
- if(newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap)
302
- return;
303
- update(obj = newObj);
304
- } else {
305
- remove();
306
- }
307
- };
308
- }
309
-
310
- var replaceText = (function () {
311
- var textStore = [];
312
-
313
- return function (index, replacement) {
314
- textStore[index] = replacement;
315
- return textStore.filter(Boolean).join('\n');
316
- };
317
- })();
318
-
319
- function applyToSingletonTag(styleElement, index, remove, obj) {
320
- var css = remove ? "" : obj.css;
321
-
322
- if (styleElement.styleSheet) {
323
- styleElement.styleSheet.cssText = replaceText(index, css);
324
- } else {
325
- var cssNode = document.createTextNode(css);
326
- var childNodes = styleElement.childNodes;
327
- if (childNodes[index]) styleElement.removeChild(childNodes[index]);
328
- if (childNodes.length) {
329
- styleElement.insertBefore(cssNode, childNodes[index]);
330
- } else {
331
- styleElement.appendChild(cssNode);
332
- }
333
- }
334
- }
335
-
336
- function applyToTag(styleElement, obj) {
337
- var css = obj.css;
338
- var media = obj.media;
339
-
340
- if(media) {
341
- styleElement.setAttribute("media", media)
342
- }
343
-
344
- if(styleElement.styleSheet) {
345
- styleElement.styleSheet.cssText = css;
346
- } else {
347
- while(styleElement.firstChild) {
348
- styleElement.removeChild(styleElement.firstChild);
349
- }
350
- styleElement.appendChild(document.createTextNode(css));
351
- }
352
- }
353
-
354
- function updateLink(linkElement, obj) {
355
- var css = obj.css;
356
- var sourceMap = obj.sourceMap;
357
-
358
- if(sourceMap) {
359
- // http://stackoverflow.com/a/26603875
360
- css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
361
- }
362
-
363
- var blob = new Blob([css], { type: "text/css" });
364
-
365
- var oldSrc = linkElement.href;
366
-
367
- linkElement.href = URL.createObjectURL(blob);
368
-
369
- if(oldSrc)
370
- URL.revokeObjectURL(oldSrc);
371
- }
372
-
373
-
374
- /***/ }),
375
- /* 2 */
376
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
377
-
378
- "use strict";
379
- Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
380
- /* WEBPACK VAR INJECTION */(function(process, global, setImmediate) {/*!
381
- * Vue.js v2.5.17
382
- * (c) 2014-2018 Evan You
383
- * Released under the MIT License.
384
- */
385
- /* */
386
-
387
- var emptyObject = Object.freeze({});
388
-
389
- // these helpers produces better vm code in JS engines due to their
390
- // explicitness and function inlining
391
- function isUndef (v) {
392
- return v === undefined || v === null
393
- }
394
-
395
- function isDef (v) {
396
- return v !== undefined && v !== null
397
- }
398
-
399
- function isTrue (v) {
400
- return v === true
401
- }
402
-
403
- function isFalse (v) {
404
- return v === false
405
- }
406
-
407
- /**
408
- * Check if value is primitive
409
- */
410
- function isPrimitive (value) {
411
- return (
412
- typeof value === 'string' ||
413
- typeof value === 'number' ||
414
- // $flow-disable-line
415
- typeof value === 'symbol' ||
416
- typeof value === 'boolean'
417
- )
418
- }
419
-
420
- /**
421
- * Quick object check - this is primarily used to tell
422
- * Objects from primitive values when we know the value
423
- * is a JSON-compliant type.
424
- */
425
- function isObject (obj) {
426
- return obj !== null && typeof obj === 'object'
427
- }
428
-
429
- /**
430
- * Get the raw type string of a value e.g. [object Object]
431
- */
432
- var _toString = Object.prototype.toString;
433
-
434
- function toRawType (value) {
435
- return _toString.call(value).slice(8, -1)
436
- }
437
-
438
- /**
439
- * Strict object type check. Only returns true
440
- * for plain JavaScript objects.
441
- */
442
- function isPlainObject (obj) {
443
- return _toString.call(obj) === '[object Object]'
444
- }
445
-
446
- function isRegExp (v) {
447
- return _toString.call(v) === '[object RegExp]'
448
- }
449
-
450
- /**
451
- * Check if val is a valid array index.
452
- */
453
- function isValidArrayIndex (val) {
454
- var n = parseFloat(String(val));
455
- return n >= 0 && Math.floor(n) === n && isFinite(val)
456
- }
457
-
458
- /**
459
- * Convert a value to a string that is actually rendered.
460
- */
461
- function toString (val) {
462
- return val == null
463
- ? ''
464
- : typeof val === 'object'
465
- ? JSON.stringify(val, null, 2)
466
- : String(val)
467
- }
468
-
469
- /**
470
- * Convert a input value to a number for persistence.
471
- * If the conversion fails, return original string.
472
- */
473
- function toNumber (val) {
474
- var n = parseFloat(val);
475
- return isNaN(n) ? val : n
476
- }
477
-
478
- /**
479
- * Make a map and return a function for checking if a key
480
- * is in that map.
481
- */
482
- function makeMap (
483
- str,
484
- expectsLowerCase
485
- ) {
486
- var map = Object.create(null);
487
- var list = str.split(',');
488
- for (var i = 0; i < list.length; i++) {
489
- map[list[i]] = true;
490
- }
491
- return expectsLowerCase
492
- ? function (val) { return map[val.toLowerCase()]; }
493
- : function (val) { return map[val]; }
494
- }
495
-
496
- /**
497
- * Check if a tag is a built-in tag.
498
- */
499
- var isBuiltInTag = makeMap('slot,component', true);
500
-
501
- /**
502
- * Check if a attribute is a reserved attribute.
503
- */
504
- var isReservedAttribute = makeMap('key,ref,slot,slot-scope,is');
505
-
506
- /**
507
- * Remove an item from an array
508
- */
509
- function remove (arr, item) {
510
- if (arr.length) {
511
- var index = arr.indexOf(item);
512
- if (index > -1) {
513
- return arr.splice(index, 1)
514
- }
515
- }
516
- }
517
-
518
- /**
519
- * Check whether the object has the property.
520
- */
521
- var hasOwnProperty = Object.prototype.hasOwnProperty;
522
- function hasOwn (obj, key) {
523
- return hasOwnProperty.call(obj, key)
524
- }
525
-
526
- /**
527
- * Create a cached version of a pure function.
528
- */
529
- function cached (fn) {
530
- var cache = Object.create(null);
531
- return (function cachedFn (str) {
532
- var hit = cache[str];
533
- return hit || (cache[str] = fn(str))
534
- })
535
- }
536
-
537
- /**
538
- * Camelize a hyphen-delimited string.
539
- */
540
- var camelizeRE = /-(\w)/g;
541
- var camelize = cached(function (str) {
542
- return str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; })
543
- });
544
-
545
- /**
546
- * Capitalize a string.
547
- */
548
- var capitalize = cached(function (str) {
549
- return str.charAt(0).toUpperCase() + str.slice(1)
550
- });
551
-
552
- /**
553
- * Hyphenate a camelCase string.
554
- */
555
- var hyphenateRE = /\B([A-Z])/g;
556
- var hyphenate = cached(function (str) {
557
- return str.replace(hyphenateRE, '-$1').toLowerCase()
558
- });
559
-
560
- /**
561
- * Simple bind polyfill for environments that do not support it... e.g.
562
- * PhantomJS 1.x. Technically we don't need this anymore since native bind is
563
- * now more performant in most browsers, but removing it would be breaking for
564
- * code that was able to run in PhantomJS 1.x, so this must be kept for
565
- * backwards compatibility.
566
- */
567
-
568
- /* istanbul ignore next */
569
- function polyfillBind (fn, ctx) {
570
- function boundFn (a) {
571
- var l = arguments.length;
572
- return l
573
- ? l > 1
574
- ? fn.apply(ctx, arguments)
575
- : fn.call(ctx, a)
576
- : fn.call(ctx)
577
- }
578
-
579
- boundFn._length = fn.length;
580
- return boundFn
581
- }
582
-
583
- function nativeBind (fn, ctx) {
584
- return fn.bind(ctx)
585
- }
586
-
587
- var bind = Function.prototype.bind
588
- ? nativeBind
589
- : polyfillBind;
590
-
591
- /**
592
- * Convert an Array-like object to a real Array.
593
- */
594
- function toArray (list, start) {
595
- start = start || 0;
596
- var i = list.length - start;
597
- var ret = new Array(i);
598
- while (i--) {
599
- ret[i] = list[i + start];
600
- }
601
- return ret
602
- }
603
-
604
- /**
605
- * Mix properties into target object.
606
- */
607
- function extend (to, _from) {
608
- for (var key in _from) {
609
- to[key] = _from[key];
610
- }
611
- return to
612
- }
613
-
614
- /**
615
- * Merge an Array of Objects into a single Object.
616
- */
617
- function toObject (arr) {
618
- var res = {};
619
- for (var i = 0; i < arr.length; i++) {
620
- if (arr[i]) {
621
- extend(res, arr[i]);
622
- }
623
- }
624
- return res
625
- }
626
-
627
- /**
628
- * Perform no operation.
629
- * Stubbing args to make Flow happy without leaving useless transpiled code
630
- * with ...rest (https://flow.org/blog/2017/05/07/Strict-Function-Call-Arity/)
631
- */
632
- function noop (a, b, c) {}
633
-
634
- /**
635
- * Always return false.
636
- */
637
- var no = function (a, b, c) { return false; };
638
-
639
- /**
640
- * Return same value
641
- */
642
- var identity = function (_) { return _; };
643
-
644
- /**
645
- * Generate a static keys string from compiler modules.
646
- */
647
- function genStaticKeys (modules) {
648
- return modules.reduce(function (keys, m) {
649
- return keys.concat(m.staticKeys || [])
650
- }, []).join(',')
651
- }
652
-
653
- /**
654
- * Check if two values are loosely equal - that is,
655
- * if they are plain objects, do they have the same shape?
656
- */
657
- function looseEqual (a, b) {
658
- if (a === b) { return true }
659
- var isObjectA = isObject(a);
660
- var isObjectB = isObject(b);
661
- if (isObjectA && isObjectB) {
662
- try {
663
- var isArrayA = Array.isArray(a);
664
- var isArrayB = Array.isArray(b);
665
- if (isArrayA && isArrayB) {
666
- return a.length === b.length && a.every(function (e, i) {
667
- return looseEqual(e, b[i])
668
- })
669
- } else if (!isArrayA && !isArrayB) {
670
- var keysA = Object.keys(a);
671
- var keysB = Object.keys(b);
672
- return keysA.length === keysB.length && keysA.every(function (key) {
673
- return looseEqual(a[key], b[key])
674
- })
675
- } else {
676
- /* istanbul ignore next */
677
- return false
678
- }
679
- } catch (e) {
680
- /* istanbul ignore next */
681
- return false
682
- }
683
- } else if (!isObjectA && !isObjectB) {
684
- return String(a) === String(b)
685
- } else {
686
- return false
687
- }
688
- }
689
-
690
- function looseIndexOf (arr, val) {
691
- for (var i = 0; i < arr.length; i++) {
692
- if (looseEqual(arr[i], val)) { return i }
693
- }
694
- return -1
695
- }
696
-
697
- /**
698
- * Ensure a function is called only once.
699
- */
700
- function once (fn) {
701
- var called = false;
702
- return function () {
703
- if (!called) {
704
- called = true;
705
- fn.apply(this, arguments);
706
- }
707
- }
708
- }
709
-
710
- var SSR_ATTR = 'data-server-rendered';
711
-
712
- var ASSET_TYPES = [
713
- 'component',
714
- 'directive',
715
- 'filter'
716
- ];
717
-
718
- var LIFECYCLE_HOOKS = [
719
- 'beforeCreate',
720
- 'created',
721
- 'beforeMount',
722
- 'mounted',
723
- 'beforeUpdate',
724
- 'updated',
725
- 'beforeDestroy',
726
- 'destroyed',
727
- 'activated',
728
- 'deactivated',
729
- 'errorCaptured'
730
- ];
731
-
732
- /* */
733
-
734
- var config = ({
735
- /**
736
- * Option merge strategies (used in core/util/options)
737
- */
738
- // $flow-disable-line
739
- optionMergeStrategies: Object.create(null),
740
-
741
- /**
742
- * Whether to suppress warnings.
743
- */
744
- silent: false,
745
-
746
- /**
747
- * Show production mode tip message on boot?
748
- */
749
- productionTip: process.env.NODE_ENV !== 'production',
750
-
751
- /**
752
- * Whether to enable devtools
753
- */
754
- devtools: process.env.NODE_ENV !== 'production',
755
-
756
- /**
757
- * Whether to record perf
758
- */
759
- performance: false,
760
-
761
- /**
762
- * Error handler for watcher errors
763
- */
764
- errorHandler: null,
765
-
766
- /**
767
- * Warn handler for watcher warns
768
- */
769
- warnHandler: null,
770
-
771
- /**
772
- * Ignore certain custom elements
773
- */
774
- ignoredElements: [],
775
-
776
- /**
777
- * Custom user key aliases for v-on
778
- */
779
- // $flow-disable-line
780
- keyCodes: Object.create(null),
781
-
782
- /**
783
- * Check if a tag is reserved so that it cannot be registered as a
784
- * component. This is platform-dependent and may be overwritten.
785
- */
786
- isReservedTag: no,
787
-
788
- /**
789
- * Check if an attribute is reserved so that it cannot be used as a component
790
- * prop. This is platform-dependent and may be overwritten.
791
- */
792
- isReservedAttr: no,
793
-
794
- /**
795
- * Check if a tag is an unknown element.
796
- * Platform-dependent.
797
- */
798
- isUnknownElement: no,
799
-
800
- /**
801
- * Get the namespace of an element
802
- */
803
- getTagNamespace: noop,
804
-
805
- /**
806
- * Parse the real tag name for the specific platform.
807
- */
808
- parsePlatformTagName: identity,
809
-
810
- /**
811
- * Check if an attribute must be bound using property, e.g. value
812
- * Platform-dependent.
813
- */
814
- mustUseProp: no,
815
-
816
- /**
817
- * Exposed for legacy reasons
818
- */
819
- _lifecycleHooks: LIFECYCLE_HOOKS
820
- })
821
-
822
- /* */
823
-
824
- /**
825
- * Check if a string starts with $ or _
826
- */
827
- function isReserved (str) {
828
- var c = (str + '').charCodeAt(0);
829
- return c === 0x24 || c === 0x5F
830
- }
831
-
832
- /**
833
- * Define a property.
834
- */
835
- function def (obj, key, val, enumerable) {
836
- Object.defineProperty(obj, key, {
837
- value: val,
838
- enumerable: !!enumerable,
839
- writable: true,
840
- configurable: true
841
- });
842
- }
843
-
844
- /**
845
- * Parse simple path.
846
- */
847
- var bailRE = /[^\w.$]/;
848
- function parsePath (path) {
849
- if (bailRE.test(path)) {
850
- return
851
- }
852
- var segments = path.split('.');
853
- return function (obj) {
854
- for (var i = 0; i < segments.length; i++) {
855
- if (!obj) { return }
856
- obj = obj[segments[i]];
857
- }
858
- return obj
859
- }
860
- }
861
-
862
- /* */
863
-
864
- // can we use __proto__?
865
- var hasProto = '__proto__' in {};
866
-
867
- // Browser environment sniffing
868
- var inBrowser = typeof window !== 'undefined';
869
- var inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform;
870
- var weexPlatform = inWeex && WXEnvironment.platform.toLowerCase();
871
- var UA = inBrowser && window.navigator.userAgent.toLowerCase();
872
- var isIE = UA && /msie|trident/.test(UA);
873
- var isIE9 = UA && UA.indexOf('msie 9.0') > 0;
874
- var isEdge = UA && UA.indexOf('edge/') > 0;
875
- var isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android');
876
- var isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios');
877
- var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
878
-
879
- // Firefox has a "watch" function on Object.prototype...
880
- var nativeWatch = ({}).watch;
881
-
882
- var supportsPassive = false;
883
- if (inBrowser) {
884
- try {
885
- var opts = {};
886
- Object.defineProperty(opts, 'passive', ({
887
- get: function get () {
888
- /* istanbul ignore next */
889
- supportsPassive = true;
890
- }
891
- })); // https://github.com/facebook/flow/issues/285
892
- window.addEventListener('test-passive', null, opts);
893
- } catch (e) {}
894
- }
895
-
896
- // this needs to be lazy-evaled because vue may be required before
897
- // vue-server-renderer can set VUE_ENV
898
- var _isServer;
899
- var isServerRendering = function () {
900
- if (_isServer === undefined) {
901
- /* istanbul ignore if */
902
- if (!inBrowser && !inWeex && typeof global !== 'undefined') {
903
- // detect presence of vue-server-renderer and avoid
904
- // Webpack shimming the process
905
- _isServer = global['process'].env.VUE_ENV === 'server';
906
- } else {
907
- _isServer = false;
908
- }
909
- }
910
- return _isServer
911
- };
912
-
913
- // detect devtools
914
- var devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__;
915
-
916
- /* istanbul ignore next */
917
- function isNative (Ctor) {
918
- return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
919
- }
920
-
921
- var hasSymbol =
922
- typeof Symbol !== 'undefined' && isNative(Symbol) &&
923
- typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys);
924
-
925
- var _Set;
926
- /* istanbul ignore if */ // $flow-disable-line
927
- if (typeof Set !== 'undefined' && isNative(Set)) {
928
- // use native Set when available.
929
- _Set = Set;
930
- } else {
931
- // a non-standard Set polyfill that only works with primitive keys.
932
- _Set = (function () {
933
- function Set () {
934
- this.set = Object.create(null);
935
- }
936
- Set.prototype.has = function has (key) {
937
- return this.set[key] === true
938
- };
939
- Set.prototype.add = function add (key) {
940
- this.set[key] = true;
941
- };
942
- Set.prototype.clear = function clear () {
943
- this.set = Object.create(null);
944
- };
945
-
946
- return Set;
947
- }());
948
- }
949
-
950
- /* */
951
-
952
- var warn = noop;
953
- var tip = noop;
954
- var generateComponentTrace = (noop); // work around flow check
955
- var formatComponentName = (noop);
956
-
957
- if (process.env.NODE_ENV !== 'production') {
958
- var hasConsole = typeof console !== 'undefined';
959
- var classifyRE = /(?:^|[-_])(\w)/g;
960
- var classify = function (str) { return str
961
- .replace(classifyRE, function (c) { return c.toUpperCase(); })
962
- .replace(/[-_]/g, ''); };
963
-
964
- warn = function (msg, vm) {
965
- var trace = vm ? generateComponentTrace(vm) : '';
966
-
967
- if (config.warnHandler) {
968
- config.warnHandler.call(null, msg, vm, trace);
969
- } else if (hasConsole && (!config.silent)) {
970
- console.error(("[Vue warn]: " + msg + trace));
971
- }
972
- };
973
-
974
- tip = function (msg, vm) {
975
- if (hasConsole && (!config.silent)) {
976
- console.warn("[Vue tip]: " + msg + (
977
- vm ? generateComponentTrace(vm) : ''
978
- ));
979
- }
980
- };
981
-
982
- formatComponentName = function (vm, includeFile) {
983
- if (vm.$root === vm) {
984
- return '<Root>'
985
- }
986
- var options = typeof vm === 'function' && vm.cid != null
987
- ? vm.options
988
- : vm._isVue
989
- ? vm.$options || vm.constructor.options
990
- : vm || {};
991
- var name = options.name || options._componentTag;
992
- var file = options.__file;
993
- if (!name && file) {
994
- var match = file.match(/([^/\\]+)\.vue#x2F;);
995
- name = match && match[1];
996
- }
997
-
998
- return (
999
- (name ? ("<" + (classify(name)) + ">") : "<Anonymous>") +
1000
- (file && includeFile !== false ? (" at " + file) : '')
1001
- )
1002
- };
1003
-
1004
- var repeat = function (str, n) {
1005
- var res = '';
1006
- while (n) {
1007
- if (n % 2 === 1) { res += str; }
1008
- if (n > 1) { str += str; }
1009
- n >>= 1;
1010
- }
1011
- return res
1012
- };
1013
-
1014
- generateComponentTrace = function (vm) {
1015
- if (vm._isVue && vm.$parent) {
1016
- var tree = [];
1017
- var currentRecursiveSequence = 0;
1018
- while (vm) {
1019
- if (tree.length > 0) {
1020
- var last = tree[tree.length - 1];
1021
- if (last.constructor === vm.constructor) {
1022
- currentRecursiveSequence++;
1023
- vm = vm.$parent;
1024
- continue
1025
- } else if (currentRecursiveSequence > 0) {
1026
- tree[tree.length - 1] = [last, currentRecursiveSequence];
1027
- currentRecursiveSequence = 0;
1028
- }
1029
- }
1030
- tree.push(vm);
1031
- vm = vm.$parent;
1032
- }
1033
- return '\n\nfound in\n\n' + tree
1034
- .map(function (vm, i) { return ("" + (i === 0 ? '---> ' : repeat(' ', 5 + i * 2)) + (Array.isArray(vm)
1035
- ? ((formatComponentName(vm[0])) + "... (" + (vm[1]) + " recursive calls)")
1036
- : formatComponentName(vm))); })
1037
- .join('\n')
1038
- } else {
1039
- return ("\n\n(found in " + (formatComponentName(vm)) + ")")
1040
- }
1041
- };
1042
- }
1043
-
1044
- /* */
1045
-
1046
-
1047
- var uid = 0;
1048
-
1049
- /**
1050
- * A dep is an observable that can have multiple
1051
- * directives subscribing to it.
1052
- */
1053
- var Dep = function Dep () {
1054
- this.id = uid++;
1055
- this.subs = [];
1056
- };
1057
-
1058
- Dep.prototype.addSub = function addSub (sub) {
1059
- this.subs.push(sub);
1060
- };
1061
-
1062
- Dep.prototype.removeSub = function removeSub (sub) {
1063
- remove(this.subs, sub);
1064
- };
1065
-
1066
- Dep.prototype.depend = function depend () {
1067
- if (Dep.target) {
1068
- Dep.target.addDep(this);
1069
- }
1070
- };
1071
-
1072
- Dep.prototype.notify = function notify () {
1073
- // stabilize the subscriber list first
1074
- var subs = this.subs.slice();
1075
- for (var i = 0, l = subs.length; i < l; i++) {
1076
- subs[i].update();
1077
- }
1078
- };
1079
-
1080
- // the current target watcher being evaluated.
1081
- // this is globally unique because there could be only one
1082
- // watcher being evaluated at any time.
1083
- Dep.target = null;
1084
- var targetStack = [];
1085
-
1086
- function pushTarget (_target) {
1087
- if (Dep.target) { targetStack.push(Dep.target); }
1088
- Dep.target = _target;
1089
- }
1090
-
1091
- function popTarget () {
1092
- Dep.target = targetStack.pop();
1093
- }
1094
-
1095
- /* */
1096
-
1097
- var VNode = function VNode (
1098
- tag,
1099
- data,
1100
- children,
1101
- text,
1102
- elm,
1103
- context,
1104
- componentOptions,
1105
- asyncFactory
1106
- ) {
1107
- this.tag = tag;
1108
- this.data = data;
1109
- this.children = children;
1110
- this.text = text;
1111
- this.elm = elm;
1112
- this.ns = undefined;
1113
- this.context = context;
1114
- this.fnContext = undefined;
1115
- this.fnOptions = undefined;
1116
- this.fnScopeId = undefined;
1117
- this.key = data && data.key;
1118
- this.componentOptions = componentOptions;
1119
- this.componentInstance = undefined;
1120
- this.parent = undefined;
1121
- this.raw = false;
1122
- this.isStatic = false;
1123
- this.isRootInsert = true;
1124
- this.isComment = false;
1125
- this.isCloned = false;
1126
- this.isOnce = false;
1127
- this.asyncFactory = asyncFactory;
1128
- this.asyncMeta = undefined;
1129
- this.isAsyncPlaceholder = false;
1130
- };
1131
-
1132
- var prototypeAccessors = { child: { configurable: true } };
1133
-
1134
- // DEPRECATED: alias for componentInstance for backwards compat.
1135
- /* istanbul ignore next */
1136
- prototypeAccessors.child.get = function () {
1137
- return this.componentInstance
1138
- };
1139
-
1140
- Object.defineProperties( VNode.prototype, prototypeAccessors );
1141
-
1142
- var createEmptyVNode = function (text) {
1143
- if ( text === void 0 ) text = '';
1144
-
1145
- var node = new VNode();
1146
- node.text = text;
1147
- node.isComment = true;
1148
- return node
1149
- };
1150
-
1151
- function createTextVNode (val) {
1152
- return new VNode(undefined, undefined, undefined, String(val))
1153
- }
1154
-
1155
- // optimized shallow clone
1156
- // used for static nodes and slot nodes because they may be reused across
1157
- // multiple renders, cloning them avoids errors when DOM manipulations rely
1158
- // on their elm reference.
1159
- function cloneVNode (vnode) {
1160
- var cloned = new VNode(
1161
- vnode.tag,
1162
- vnode.data,
1163
- vnode.children,
1164
- vnode.text,
1165
- vnode.elm,
1166
- vnode.context,
1167
- vnode.componentOptions,
1168
- vnode.asyncFactory
1169
- );
1170
- cloned.ns = vnode.ns;
1171
- cloned.isStatic = vnode.isStatic;
1172
- cloned.key = vnode.key;
1173
- cloned.isComment = vnode.isComment;
1174
- cloned.fnContext = vnode.fnContext;
1175
- cloned.fnOptions = vnode.fnOptions;
1176
- cloned.fnScopeId = vnode.fnScopeId;
1177
- cloned.isCloned = true;
1178
- return cloned
1179
- }
1180
-
1181
- /*
1182
- * not type checking this file because flow doesn't play well with
1183
- * dynamically accessing methods on Array prototype
1184
- */
1185
-
1186
- var arrayProto = Array.prototype;
1187
- var arrayMethods = Object.create(arrayProto);
1188
-
1189
- var methodsToPatch = [
1190
- 'push',
1191
- 'pop',
1192
- 'shift',
1193
- 'unshift',
1194
- 'splice',
1195
- 'sort',
1196
- 'reverse'
1197
- ];
1198
-
1199
- /**
1200
- * Intercept mutating methods and emit events
1201
- */
1202
- methodsToPatch.forEach(function (method) {
1203
- // cache original method
1204
- var original = arrayProto[method];
1205
- def(arrayMethods, method, function mutator () {
1206
- var args = [], len = arguments.length;
1207
- while ( len-- ) args[ len ] = arguments[ len ];
1208
-
1209
- var result = original.apply(this, args);
1210
- var ob = this.__ob__;
1211
- var inserted;
1212
- switch (method) {
1213
- case 'push':
1214
- case 'unshift':
1215
- inserted = args;
1216
- break
1217
- case 'splice':
1218
- inserted = args.slice(2);
1219
- break
1220
- }
1221
- if (inserted) { ob.observeArray(inserted); }
1222
- // notify change
1223
- ob.dep.notify();
1224
- return result
1225
- });
1226
- });
1227
-
1228
- /* */
1229
-
1230
- var arrayKeys = Object.getOwnPropertyNames(arrayMethods);
1231
-
1232
- /**
1233
- * In some cases we may want to disable observation inside a component's
1234
- * update computation.
1235
- */
1236
- var shouldObserve = true;
1237
-
1238
- function toggleObserving (value) {
1239
- shouldObserve = value;
1240
- }
1241
-
1242
- /**
1243
- * Observer class that is attached to each observed
1244
- * object. Once attached, the observer converts the target
1245
- * object's property keys into getter/setters that
1246
- * collect dependencies and dispatch updates.
1247
- */
1248
- var Observer = function Observer (value) {
1249
- this.value = value;
1250
- this.dep = new Dep();
1251
- this.vmCount = 0;
1252
- def(value, '__ob__', this);
1253
- if (Array.isArray(value)) {
1254
- var augment = hasProto
1255
- ? protoAugment
1256
- : copyAugment;
1257
- augment(value, arrayMethods, arrayKeys);
1258
- this.observeArray(value);
1259
- } else {
1260
- this.walk(value);
1261
- }
1262
- };
1263
-
1264
- /**
1265
- * Walk through each property and convert them into
1266
- * getter/setters. This method should only be called when
1267
- * value type is Object.
1268
- */
1269
- Observer.prototype.walk = function walk (obj) {
1270
- var keys = Object.keys(obj);
1271
- for (var i = 0; i < keys.length; i++) {
1272
- defineReactive(obj, keys[i]);
1273
- }
1274
- };
1275
-
1276
- /**
1277
- * Observe a list of Array items.
1278
- */
1279
- Observer.prototype.observeArray = function observeArray (items) {
1280
- for (var i = 0, l = items.length; i < l; i++) {
1281
- observe(items[i]);
1282
- }
1283
- };
1284
-
1285
- // helpers
1286
-
1287
- /**
1288
- * Augment an target Object or Array by intercepting
1289
- * the prototype chain using __proto__
1290
- */
1291
- function protoAugment (target, src, keys) {
1292
- /* eslint-disable no-proto */
1293
- target.__proto__ = src;
1294
- /* eslint-enable no-proto */
1295
- }
1296
-
1297
- /**
1298
- * Augment an target Object or Array by defining
1299
- * hidden properties.
1300
- */
1301
- /* istanbul ignore next */
1302
- function copyAugment (target, src, keys) {
1303
- for (var i = 0, l = keys.length; i < l; i++) {
1304
- var key = keys[i];
1305
- def(target, key, src[key]);
1306
- }
1307
- }
1308
-
1309
- /**
1310
- * Attempt to create an observer instance for a value,
1311
- * returns the new observer if successfully observed,
1312
- * or the existing observer if the value already has one.
1313
- */
1314
- function observe (value, asRootData) {
1315
- if (!isObject(value) || value instanceof VNode) {
1316
- return
1317
- }
1318
- var ob;
1319
- if (hasOwn(value, '__ob__') && value.__ob__ instanceof Observer) {
1320
- ob = value.__ob__;
1321
- } else if (
1322
- shouldObserve &&
1323
- !isServerRendering() &&
1324
- (Array.isArray(value) || isPlainObject(value)) &&
1325
- Object.isExtensible(value) &&
1326
- !value._isVue
1327
- ) {
1328
- ob = new Observer(value);
1329
- }
1330
- if (asRootData && ob) {
1331
- ob.vmCount++;
1332
- }
1333
- return ob
1334
- }
1335
-
1336
- /**
1337
- * Define a reactive property on an Object.
1338
- */
1339
- function defineReactive (
1340
- obj,
1341
- key,
1342
- val,
1343
- customSetter,
1344
- shallow
1345
- ) {
1346
- var dep = new Dep();
1347
-
1348
- var property = Object.getOwnPropertyDescriptor(obj, key);
1349
- if (property && property.configurable === false) {
1350
- return
1351
- }
1352
-
1353
- // cater for pre-defined getter/setters
1354
- var getter = property && property.get;
1355
- if (!getter && arguments.length === 2) {
1356
- val = obj[key];
1357
- }
1358
- var setter = property && property.set;
1359
-
1360
- var childOb = !shallow && observe(val);
1361
- Object.defineProperty(obj, key, {
1362
- enumerable: true,
1363
- configurable: true,
1364
- get: function reactiveGetter () {
1365
- var value = getter ? getter.call(obj) : val;
1366
- if (Dep.target) {
1367
- dep.depend();
1368
- if (childOb) {
1369
- childOb.dep.depend();
1370
- if (Array.isArray(value)) {
1371
- dependArray(value);
1372
- }
1373
- }
1374
- }
1375
- return value
1376
- },
1377
- set: function reactiveSetter (newVal) {
1378
- var value = getter ? getter.call(obj) : val;
1379
- /* eslint-disable no-self-compare */
1380
- if (newVal === value || (newVal !== newVal && value !== value)) {
1381
- return
1382
- }
1383
- /* eslint-enable no-self-compare */
1384
- if (process.env.NODE_ENV !== 'production' && customSetter) {
1385
- customSetter();
1386
- }
1387
- if (setter) {
1388
- setter.call(obj, newVal);
1389
- } else {
1390
- val = newVal;
1391
- }
1392
- childOb = !shallow && observe(newVal);
1393
- dep.notify();
1394
- }
1395
- });
1396
- }
1397
-
1398
- /**
1399
- * Set a property on an object. Adds the new property and
1400
- * triggers change notification if the property doesn't
1401
- * already exist.
1402
- */
1403
- function set (target, key, val) {
1404
- if (process.env.NODE_ENV !== 'production' &&
1405
- (isUndef(target) || isPrimitive(target))
1406
- ) {
1407
- warn(("Cannot set reactive property on undefined, null, or primitive value: " + ((target))));
1408
- }
1409
- if (Array.isArray(target) && isValidArrayIndex(key)) {
1410
- target.length = Math.max(target.length, key);
1411
- target.splice(key, 1, val);
1412
- return val
1413
- }
1414
- if (key in target && !(key in Object.prototype)) {
1415
- target[key] = val;
1416
- return val
1417
- }
1418
- var ob = (target).__ob__;
1419
- if (target._isVue || (ob && ob.vmCount)) {
1420
- process.env.NODE_ENV !== 'production' && warn(
1421
- 'Avoid adding reactive properties to a Vue instance or its root $data ' +
1422
- 'at runtime - declare it upfront in the data option.'
1423
- );
1424
- return val
1425
- }
1426
- if (!ob) {
1427
- target[key] = val;
1428
- return val
1429
- }
1430
- defineReactive(ob.value, key, val);
1431
- ob.dep.notify();
1432
- return val
1433
- }
1434
-
1435
- /**
1436
- * Delete a property and trigger change if necessary.
1437
- */
1438
- function del (target, key) {
1439
- if (process.env.NODE_ENV !== 'production' &&
1440
- (isUndef(target) || isPrimitive(target))
1441
- ) {
1442
- warn(("Cannot delete reactive property on undefined, null, or primitive value: " + ((target))));
1443
- }
1444
- if (Array.isArray(target) && isValidArrayIndex(key)) {
1445
- target.splice(key, 1);
1446
- return
1447
- }
1448
- var ob = (target).__ob__;
1449
- if (target._isVue || (ob && ob.vmCount)) {
1450
- process.env.NODE_ENV !== 'production' && warn(
1451
- 'Avoid deleting properties on a Vue instance or its root $data ' +
1452
- '- just set it to null.'
1453
- );
1454
- return
1455
- }
1456
- if (!hasOwn(target, key)) {
1457
- return
1458
- }
1459
- delete target[key];
1460
- if (!ob) {
1461
- return
1462
- }
1463
- ob.dep.notify();
1464
- }
1465
-
1466
- /**
1467
- * Collect dependencies on array elements when the array is touched, since
1468
- * we cannot intercept array element access like property getters.
1469
- */
1470
- function dependArray (value) {
1471
- for (var e = (void 0), i = 0, l = value.length; i < l; i++) {
1472
- e = value[i];
1473
- e && e.__ob__ && e.__ob__.dep.depend();
1474
- if (Array.isArray(e)) {
1475
- dependArray(e);
1476
- }
1477
- }
1478
- }
1479
-
1480
- /* */
1481
-
1482
- /**
1483
- * Option overwriting strategies are functions that handle
1484
- * how to merge a parent option value and a child option
1485
- * value into the final value.
1486
- */
1487
- var strats = config.optionMergeStrategies;
1488
-
1489
- /**
1490
- * Options with restrictions
1491
- */
1492
- if (process.env.NODE_ENV !== 'production') {
1493
- strats.el = strats.propsData = function (parent, child, vm, key) {
1494
- if (!vm) {
1495
- warn(
1496
- "option \"" + key + "\" can only be used during instance " +
1497
- 'creation with the `new` keyword.'
1498
- );
1499
- }
1500
- return defaultStrat(parent, child)
1501
- };
1502
- }
1503
-
1504
- /**
1505
- * Helper that recursively merges two data objects together.
1506
- */
1507
- function mergeData (to, from) {
1508
- if (!from) { return to }
1509
- var key, toVal, fromVal;
1510
- var keys = Object.keys(from);
1511
- for (var i = 0; i < keys.length; i++) {
1512
- key = keys[i];
1513
- toVal = to[key];
1514
- fromVal = from[key];
1515
- if (!hasOwn(to, key)) {
1516
- set(to, key, fromVal);
1517
- } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
1518
- mergeData(toVal, fromVal);
1519
- }
1520
- }
1521
- return to
1522
- }
1523
-
1524
- /**
1525
- * Data
1526
- */
1527
- function mergeDataOrFn (
1528
- parentVal,
1529
- childVal,
1530
- vm
1531
- ) {
1532
- if (!vm) {
1533
- // in a Vue.extend merge, both should be functions
1534
- if (!childVal) {
1535
- return parentVal
1536
- }
1537
- if (!parentVal) {
1538
- return childVal
1539
- }
1540
- // when parentVal & childVal are both present,
1541
- // we need to return a function that returns the
1542
- // merged result of both functions... no need to
1543
- // check if parentVal is a function here because
1544
- // it has to be a function to pass previous merges.
1545
- return function mergedDataFn () {
1546
- return mergeData(
1547
- typeof childVal === 'function' ? childVal.call(this, this) : childVal,
1548
- typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
1549
- )
1550
- }
1551
- } else {
1552
- return function mergedInstanceDataFn () {
1553
- // instance merge
1554
- var instanceData = typeof childVal === 'function'
1555
- ? childVal.call(vm, vm)
1556
- : childVal;
1557
- var defaultData = typeof parentVal === 'function'
1558
- ? parentVal.call(vm, vm)
1559
- : parentVal;
1560
- if (instanceData) {
1561
- return mergeData(instanceData, defaultData)
1562
- } else {
1563
- return defaultData
1564
- }
1565
- }
1566
- }
1567
- }
1568
-
1569
- strats.data = function (
1570
- parentVal,
1571
- childVal,
1572
- vm
1573
- ) {
1574
- if (!vm) {
1575
- if (childVal && typeof childVal !== 'function') {
1576
- process.env.NODE_ENV !== 'production' && warn(
1577
- 'The "data" option should be a function ' +
1578
- 'that returns a per-instance value in component ' +
1579
- 'definitions.',
1580
- vm
1581
- );
1582
-
1583
- return parentVal
1584
- }
1585
- return mergeDataOrFn(parentVal, childVal)
1586
- }
1587
-
1588
- return mergeDataOrFn(parentVal, childVal, vm)
1589
- };
1590
-
1591
- /**
1592
- * Hooks and props are merged as arrays.
1593
- */
1594
- function mergeHook (
1595
- parentVal,
1596
- childVal
1597
- ) {
1598
- return childVal
1599
- ? parentVal
1600
- ? parentVal.concat(childVal)
1601
- : Array.isArray(childVal)
1602
- ? childVal
1603
- : [childVal]
1604
- : parentVal
1605
- }
1606
-
1607
- LIFECYCLE_HOOKS.forEach(function (hook) {
1608
- strats[hook] = mergeHook;
1609
- });
1610
-
1611
- /**
1612
- * Assets
1613
- *
1614
- * When a vm is present (instance creation), we need to do
1615
- * a three-way merge between constructor options, instance
1616
- * options and parent options.
1617
- */
1618
- function mergeAssets (
1619
- parentVal,
1620
- childVal,
1621
- vm,
1622
- key
1623
- ) {
1624
- var res = Object.create(parentVal || null);
1625
- if (childVal) {
1626
- process.env.NODE_ENV !== 'production' && assertObjectType(key, childVal, vm);
1627
- return extend(res, childVal)
1628
- } else {
1629
- return res
1630
- }
1631
- }
1632
-
1633
- ASSET_TYPES.forEach(function (type) {
1634
- strats[type + 's'] = mergeAssets;
1635
- });
1636
-
1637
- /**
1638
- * Watchers.
1639
- *
1640
- * Watchers hashes should not overwrite one
1641
- * another, so we merge them as arrays.
1642
- */
1643
- strats.watch = function (
1644
- parentVal,
1645
- childVal,
1646
- vm,
1647
- key
1648
- ) {
1649
- // work around Firefox's Object.prototype.watch...
1650
- if (parentVal === nativeWatch) { parentVal = undefined; }
1651
- if (childVal === nativeWatch) { childVal = undefined; }
1652
- /* istanbul ignore if */
1653
- if (!childVal) { return Object.create(parentVal || null) }
1654
- if (process.env.NODE_ENV !== 'production') {
1655
- assertObjectType(key, childVal, vm);
1656
- }
1657
- if (!parentVal) { return childVal }
1658
- var ret = {};
1659
- extend(ret, parentVal);
1660
- for (var key$1 in childVal) {
1661
- var parent = ret[key$1];
1662
- var child = childVal[key$1];
1663
- if (parent && !Array.isArray(parent)) {
1664
- parent = [parent];
1665
- }
1666
- ret[key$1] = parent
1667
- ? parent.concat(child)
1668
- : Array.isArray(child) ? child : [child];
1669
- }
1670
- return ret
1671
- };
1672
-
1673
- /**
1674
- * Other object hashes.
1675
- */
1676
- strats.props =
1677
- strats.methods =
1678
- strats.inject =
1679
- strats.computed = function (
1680
- parentVal,
1681
- childVal,
1682
- vm,
1683
- key
1684
- ) {
1685
- if (childVal && process.env.NODE_ENV !== 'production') {
1686
- assertObjectType(key, childVal, vm);
1687
- }
1688
- if (!parentVal) { return childVal }
1689
- var ret = Object.create(null);
1690
- extend(ret, parentVal);
1691
- if (childVal) { extend(ret, childVal); }
1692
- return ret
1693
- };
1694
- strats.provide = mergeDataOrFn;
1695
-
1696
- /**
1697
- * Default strategy.
1698
- */
1699
- var defaultStrat = function (parentVal, childVal) {
1700
- return childVal === undefined
1701
- ? parentVal
1702
- : childVal
1703
- };
1704
-
1705
- /**
1706
- * Validate component names
1707
- */
1708
- function checkComponents (options) {
1709
- for (var key in options.components) {
1710
- validateComponentName(key);
1711
- }
1712
- }
1713
-
1714
- function validateComponentName (name) {
1715
- if (!/^[a-zA-Z][\w-]*#x2F;.test(name)) {
1716
- warn(
1717
- 'Invalid component name: "' + name + '". Component names ' +
1718
- 'can only contain alphanumeric characters and the hyphen, ' +
1719
- 'and must start with a letter.'
1720
- );
1721
- }
1722
- if (isBuiltInTag(name) || config.isReservedTag(name)) {
1723
- warn(
1724
- 'Do not use built-in or reserved HTML elements as component ' +
1725
- 'id: ' + name
1726
- );
1727
- }
1728
- }
1729
-
1730
- /**
1731
- * Ensure all props option syntax are normalized into the
1732
- * Object-based format.
1733
- */
1734
- function normalizeProps (options, vm) {
1735
- var props = options.props;
1736
- if (!props) { return }
1737
- var res = {};
1738
- var i, val, name;
1739
- if (Array.isArray(props)) {
1740
- i = props.length;
1741
- while (i--) {
1742
- val = props[i];
1743
- if (typeof val === 'string') {
1744
- name = camelize(val);
1745
- res[name] = { type: null };
1746
- } else if (process.env.NODE_ENV !== 'production') {
1747
- warn('props must be strings when using array syntax.');
1748
- }
1749
- }
1750
- } else if (isPlainObject(props)) {
1751
- for (var key in props) {
1752
- val = props[key];
1753
- name = camelize(key);
1754
- res[name] = isPlainObject(val)
1755
- ? val
1756
- : { type: val };
1757
- }
1758
- } else if (process.env.NODE_ENV !== 'production') {
1759
- warn(
1760
- "Invalid value for option \"props\": expected an Array or an Object, " +
1761
- "but got " + (toRawType(props)) + ".",
1762
- vm
1763
- );
1764
- }
1765
- options.props = res;
1766
- }
1767
-
1768
- /**
1769
- * Normalize all injections into Object-based format
1770
- */
1771
- function normalizeInject (options, vm) {
1772
- var inject = options.inject;
1773
- if (!inject) { return }
1774
- var normalized = options.inject = {};
1775
- if (Array.isArray(inject)) {
1776
- for (var i = 0; i < inject.length; i++) {
1777
- normalized[inject[i]] = { from: inject[i] };
1778
- }
1779
- } else if (isPlainObject(inject)) {
1780
- for (var key in inject) {
1781
- var val = inject[key];
1782
- normalized[key] = isPlainObject(val)
1783
- ? extend({ from: key }, val)
1784
- : { from: val };
1785
- }
1786
- } else if (process.env.NODE_ENV !== 'production') {
1787
- warn(
1788
- "Invalid value for option \"inject\": expected an Array or an Object, " +
1789
- "but got " + (toRawType(inject)) + ".",
1790
- vm
1791
- );
1792
- }
1793
- }
1794
-
1795
- /**
1796
- * Normalize raw function directives into object format.
1797
- */
1798
- function normalizeDirectives (options) {
1799
- var dirs = options.directives;
1800
- if (dirs) {
1801
- for (var key in dirs) {
1802
- var def = dirs[key];
1803
- if (typeof def === 'function') {
1804
- dirs[key] = { bind: def, update: def };
1805
- }
1806
- }
1807
- }
1808
- }
1809
-
1810
- function assertObjectType (name, value, vm) {
1811
- if (!isPlainObject(value)) {
1812
- warn(
1813
- "Invalid value for option \"" + name + "\": expected an Object, " +
1814
- "but got " + (toRawType(value)) + ".",
1815
- vm
1816
- );
1817
- }
1818
- }
1819
-
1820
- /**
1821
- * Merge two option objects into a new one.
1822
- * Core utility used in both instantiation and inheritance.
1823
- */
1824
- function mergeOptions (
1825
- parent,
1826
- child,
1827
- vm
1828
- ) {
1829
- if (process.env.NODE_ENV !== 'production') {
1830
- checkComponents(child);
1831
- }
1832
-
1833
- if (typeof child === 'function') {
1834
- child = child.options;
1835
- }
1836
-
1837
- normalizeProps(child, vm);
1838
- normalizeInject(child, vm);
1839
- normalizeDirectives(child);
1840
- var extendsFrom = child.extends;
1841
- if (extendsFrom) {
1842
- parent = mergeOptions(parent, extendsFrom, vm);
1843
- }
1844
- if (child.mixins) {
1845
- for (var i = 0, l = child.mixins.length; i < l; i++) {
1846
- parent = mergeOptions(parent, child.mixins[i], vm);
1847
- }
1848
- }
1849
- var options = {};
1850
- var key;
1851
- for (key in parent) {
1852
- mergeField(key);
1853
- }
1854
- for (key in child) {
1855
- if (!hasOwn(parent, key)) {
1856
- mergeField(key);
1857
- }
1858
- }
1859
- function mergeField (key) {
1860
- var strat = strats[key] || defaultStrat;
1861
- options[key] = strat(parent[key], child[key], vm, key);
1862
- }
1863
- return options
1864
- }
1865
-
1866
- /**
1867
- * Resolve an asset.
1868
- * This function is used because child instances need access
1869
- * to assets defined in its ancestor chain.
1870
- */
1871
- function resolveAsset (
1872
- options,
1873
- type,
1874
- id,
1875
- warnMissing
1876
- ) {
1877
- /* istanbul ignore if */
1878
- if (typeof id !== 'string') {
1879
- return
1880
- }
1881
- var assets = options[type];
1882
- // check local registration variations first
1883
- if (hasOwn(assets, id)) { return assets[id] }
1884
- var camelizedId = camelize(id);
1885
- if (hasOwn(assets, camelizedId)) { return assets[camelizedId] }
1886
- var PascalCaseId = capitalize(camelizedId);
1887
- if (hasOwn(assets, PascalCaseId)) { return assets[PascalCaseId] }
1888
- // fallback to prototype chain
1889
- var res = assets[id] || assets[camelizedId] || assets[PascalCaseId];
1890
- if (process.env.NODE_ENV !== 'production' && warnMissing && !res) {
1891
- warn(
1892
- 'Failed to resolve ' + type.slice(0, -1) + ': ' + id,
1893
- options
1894
- );
1895
- }
1896
- return res
1897
- }
1898
-
1899
- /* */
1900
-
1901
- function validateProp (
1902
- key,
1903
- propOptions,
1904
- propsData,
1905
- vm
1906
- ) {
1907
- var prop = propOptions[key];
1908
- var absent = !hasOwn(propsData, key);
1909
- var value = propsData[key];
1910
- // boolean casting
1911
- var booleanIndex = getTypeIndex(Boolean, prop.type);
1912
- if (booleanIndex > -1) {
1913
- if (absent && !hasOwn(prop, 'default')) {
1914
- value = false;
1915
- } else if (value === '' || value === hyphenate(key)) {
1916
- // only cast empty string / same name to boolean if
1917
- // boolean has higher priority
1918
- var stringIndex = getTypeIndex(String, prop.type);
1919
- if (stringIndex < 0 || booleanIndex < stringIndex) {
1920
- value = true;
1921
- }
1922
- }
1923
- }
1924
- // check default value
1925
- if (value === undefined) {
1926
- value = getPropDefaultValue(vm, prop, key);
1927
- // since the default value is a fresh copy,
1928
- // make sure to observe it.
1929
- var prevShouldObserve = shouldObserve;
1930
- toggleObserving(true);
1931
- observe(value);
1932
- toggleObserving(prevShouldObserve);
1933
- }
1934
- if (
1935
- process.env.NODE_ENV !== 'production' &&
1936
- // skip validation for weex recycle-list child component props
1937
- !(false && isObject(value) && ('@binding' in value))
1938
- ) {
1939
- assertProp(prop, key, value, vm, absent);
1940
- }
1941
- return value
1942
- }
1943
-
1944
- /**
1945
- * Get the default value of a prop.
1946
- */
1947
- function getPropDefaultValue (vm, prop, key) {
1948
- // no default, return undefined
1949
- if (!hasOwn(prop, 'default')) {
1950
- return undefined
1951
- }
1952
- var def = prop.default;
1953
- // warn against non-factory defaults for Object & Array
1954
- if (process.env.NODE_ENV !== 'production' && isObject(def)) {
1955
- warn(
1956
- 'Invalid default value for prop "' + key + '": ' +
1957
- 'Props with type Object/Array must use a factory function ' +
1958
- 'to return the default value.',
1959
- vm
1960
- );
1961
-