swan-game-adapter.js 133 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628
  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, { enumerable: true, get: getter });
  40. /******/ }
  41. /******/ };
  42. /******/
  43. /******/ // define __esModule on exports
  44. /******/ __webpack_require__.r = function(exports) {
  45. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  46. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  47. /******/ }
  48. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  49. /******/ };
  50. /******/
  51. /******/ // create a fake namespace object
  52. /******/ // mode & 1: value is a module id, require it
  53. /******/ // mode & 2: merge all properties of value into the ns
  54. /******/ // mode & 4: return value when already ns object
  55. /******/ // mode & 8|1: behave like require
  56. /******/ __webpack_require__.t = function(value, mode) {
  57. /******/ if(mode & 1) value = __webpack_require__(value);
  58. /******/ if(mode & 8) return value;
  59. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  60. /******/ var ns = Object.create(null);
  61. /******/ __webpack_require__.r(ns);
  62. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  63. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  64. /******/ return ns;
  65. /******/ };
  66. /******/
  67. /******/ // getDefaultExport function for compatibility with non-harmony modules
  68. /******/ __webpack_require__.n = function(module) {
  69. /******/ var getter = module && module.__esModule ?
  70. /******/ function getDefault() { return module['default']; } :
  71. /******/ function getModuleExports() { return module; };
  72. /******/ __webpack_require__.d(getter, 'a', getter);
  73. /******/ return getter;
  74. /******/ };
  75. /******/
  76. /******/ // Object.prototype.hasOwnProperty.call
  77. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  78. /******/
  79. /******/ // __webpack_public_path__
  80. /******/ __webpack_require__.p = "";
  81. /******/
  82. /******/
  83. /******/ // Load entry module and return exports
  84. /******/ return __webpack_require__(__webpack_require__.s = "./src/index.js");
  85. /******/ })
  86. /************************************************************************/
  87. /******/ ({
  88. /***/ "./node_modules/webpack/buildin/global.js":
  89. /*!***********************************!*\
  90. !*** (webpack)/buildin/global.js ***!
  91. \***********************************/
  92. /*! no static exports found */
  93. /***/ (function(module, exports) {
  94. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
  95. var g;
  96. // This works in non-strict mode
  97. g = function () {
  98. return this;
  99. }();
  100. try {
  101. // This works if eval is allowed (see CSP)
  102. g = g || Function("return this")() || (1, eval)("this");
  103. } catch (e) {
  104. // This works if the window reference is available
  105. if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === "object") g = window;
  106. }
  107. // g can still be undefined, but nothing to do about it...
  108. // We return undefined, instead of nothing here, so it's
  109. // easier to handle this case. if(!global) { ...}
  110. module.exports = g;
  111. /***/ }),
  112. /***/ "./src/Audio.js":
  113. /*!**********************!*\
  114. !*** ./src/Audio.js ***!
  115. \**********************/
  116. /*! exports provided: default */
  117. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118. "use strict";
  119. __webpack_require__.r(__webpack_exports__);
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Audio; });
  121. /* harmony import */ var _HTMLAudioElement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HTMLAudioElement */ "./src/HTMLAudioElement.js");
  122. var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
  123. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  124. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  125. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  126. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  127. /* eslint-disable */
  128. var SN_SEED = 1;
  129. var _innerAudioContextMap = {};
  130. var AudioMock = function () {
  131. function AudioMock() {
  132. _classCallCheck(this, AudioMock);
  133. }
  134. _createClass(AudioMock, [{
  135. key: 'play',
  136. value: function play() {}
  137. }, {
  138. key: 'pause',
  139. value: function pause() {}
  140. }, {
  141. key: 'stop',
  142. value: function stop() {}
  143. }, {
  144. key: 'seek',
  145. value: function seek() {}
  146. }, {
  147. key: 'destroy',
  148. value: function destroy() {}
  149. }, {
  150. key: 'onCanplay',
  151. value: function onCanplay() {}
  152. }, {
  153. key: 'offCanplay',
  154. value: function offCanplay() {}
  155. }, {
  156. key: 'onEnded',
  157. value: function onEnded() {}
  158. }, {
  159. key: 'offEnded',
  160. value: function offEnded() {}
  161. }, {
  162. key: 'onError',
  163. value: function onError() {}
  164. }, {
  165. key: 'offError',
  166. value: function offError() {}
  167. }, {
  168. key: 'onPause',
  169. value: function onPause() {}
  170. }, {
  171. key: 'offPause',
  172. value: function offPause() {}
  173. }, {
  174. key: 'onPlay',
  175. value: function onPlay() {}
  176. }, {
  177. key: 'offPlay',
  178. value: function offPlay() {}
  179. }, {
  180. key: 'onSeeked',
  181. value: function onSeeked() {}
  182. }, {
  183. key: 'offSeeked',
  184. value: function offSeeked() {}
  185. }, {
  186. key: 'onSeeking',
  187. value: function onSeeking() {}
  188. }, {
  189. key: 'offSeeking',
  190. value: function offSeeking() {}
  191. }, {
  192. key: 'onStop',
  193. value: function onStop() {}
  194. }, {
  195. key: 'offStop',
  196. value: function offStop() {}
  197. }, {
  198. key: 'onTimeUpdate',
  199. value: function onTimeUpdate() {}
  200. }, {
  201. key: 'offTimeUpdate',
  202. value: function offTimeUpdate() {}
  203. }, {
  204. key: 'offWaiting',
  205. value: function offWaiting() {}
  206. }, {
  207. key: 'onWaitin',
  208. value: function onWaitin() {}
  209. }]);
  210. return AudioMock;
  211. }();
  212. var Audio = function (_HTMLAudioElement) {
  213. _inherits(Audio, _HTMLAudioElement);
  214. function Audio(url) {
  215. _classCallCheck(this, Audio);
  216. var _this = _possibleConstructorReturn(this, (Audio.__proto__ || Object.getPrototypeOf(Audio)).call(this));
  217. _this._$sn = SN_SEED++;
  218. _this.readyState = Audio.HAVE_NOTHING;
  219. var innerAudioContext = swan.createInnerAudioContext ? swan.createInnerAudioContext() : new AudioMock();
  220. _innerAudioContextMap[_this._$sn] = innerAudioContext;
  221. _this._canplayEvents = ['load', 'loadend', 'canplay', 'canplaythrough', 'loadedmetadata'];
  222. innerAudioContext.onCanplay(function () {
  223. _this._loaded = true;
  224. _this.readyState = Audio.HAVE_CURRENT_DATA;
  225. _this._canplayEvents.forEach(function (type) {
  226. _this.dispatchEvent({ type: type });
  227. });
  228. });
  229. innerAudioContext.onPlay(function () {
  230. _this._paused = _innerAudioContextMap[_this._$sn].paused;
  231. _this.dispatchEvent({ type: 'play' });
  232. });
  233. innerAudioContext.onPause(function () {
  234. _this._paused = _innerAudioContextMap[_this._$sn].paused;
  235. _this.dispatchEvent({ type: 'pause' });
  236. });
  237. innerAudioContext.onEnded(function () {
  238. _this._paused = _innerAudioContextMap[_this._$sn].paused;
  239. if (_innerAudioContextMap[_this._$sn].loop === false) {
  240. _this.dispatchEvent({ type: 'ended' });
  241. }
  242. _this.readyState = Audio.HAVE_ENOUGH_DATA;
  243. });
  244. innerAudioContext.onError(function () {
  245. _this._paused = _innerAudioContextMap[_this._$sn].paused;
  246. _this.dispatchEvent({ type: 'error' });
  247. });
  248. if (url) {
  249. _this.src = url;
  250. } else {
  251. _this._src = '';
  252. }
  253. _this._loop = innerAudioContext.loop;
  254. _this._autoplay = innerAudioContext.autoplay;
  255. _this._paused = innerAudioContext.paused;
  256. _this._volume = innerAudioContext.volume;
  257. _this._muted = false;
  258. return _this;
  259. }
  260. _createClass(Audio, [{
  261. key: 'addEventListener',
  262. value: function addEventListener(type, listener) {
  263. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  264. type = String(type).toLowerCase();
  265. _get(Audio.prototype.__proto__ || Object.getPrototypeOf(Audio.prototype), 'addEventListener', this).call(this, type, listener, options);
  266. if (this._loaded && this._canplayEvents.indexOf(type) !== -1) {
  267. this.dispatchEvent({ type: type });
  268. }
  269. }
  270. }, {
  271. key: 'load',
  272. value: function load() {
  273. // console.warn('HTMLAudioElement.load() is not implemented.')
  274. // weixin doesn't need call load() manually
  275. }
  276. }, {
  277. key: 'play',
  278. value: function play() {
  279. _innerAudioContextMap[this._$sn].play();
  280. }
  281. }, {
  282. key: 'resume',
  283. value: function resume() {
  284. _innerAudioContextMap[this._$sn].resume();
  285. }
  286. }, {
  287. key: 'pause',
  288. value: function pause() {
  289. _innerAudioContextMap[this._$sn].pause();
  290. }
  291. }, {
  292. key: 'destroy',
  293. value: function destroy() {
  294. _innerAudioContextMap[this._$sn].destroy();
  295. }
  296. }, {
  297. key: 'canPlayType',
  298. value: function canPlayType() {
  299. var mediaType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  300. if (typeof mediaType !== 'string') {
  301. return '';
  302. }
  303. if (mediaType.indexOf('audio/mpeg') > -1 || mediaType.indexOf('audio/mp4')) {
  304. return 'probably';
  305. }
  306. return '';
  307. }
  308. }, {
  309. key: 'cloneNode',
  310. value: function cloneNode() {
  311. var newAudio = new Audio();
  312. newAudio.loop = this.loop;
  313. newAudio.autoplay = this.autoplay;
  314. newAudio.src = this.src;
  315. return newAudio;
  316. }
  317. }, {
  318. key: 'currentTime',
  319. get: function get() {
  320. return _innerAudioContextMap[this._$sn].currentTime;
  321. },
  322. set: function set(value) {
  323. _innerAudioContextMap[this._$sn].seek(value);
  324. }
  325. }, {
  326. key: 'duration',
  327. get: function get() {
  328. return _innerAudioContextMap[this._$sn].duration;
  329. }
  330. }, {
  331. key: 'src',
  332. get: function get() {
  333. return this._src;
  334. },
  335. set: function set(value) {
  336. this._src = value;
  337. this._loaded = false;
  338. this.readyState = Audio.HAVE_NOTHING;
  339. var innerAudioContext = _innerAudioContextMap[this._$sn];
  340. innerAudioContext.src = value;
  341. }
  342. }, {
  343. key: 'loop',
  344. get: function get() {
  345. return this._loop;
  346. },
  347. set: function set(value) {
  348. this._loop = value;
  349. _innerAudioContextMap[this._$sn].loop = value;
  350. }
  351. }, {
  352. key: 'autoplay',
  353. get: function get() {
  354. return this._autoplay;
  355. },
  356. set: function set(value) {
  357. this._autoplay = value;
  358. _innerAudioContextMap[this._$sn].autoplay = value;
  359. }
  360. }, {
  361. key: 'paused',
  362. get: function get() {
  363. return this._paused;
  364. }
  365. }, {
  366. key: 'volume',
  367. get: function get() {
  368. return this._volume;
  369. },
  370. set: function set(value) {
  371. this._volume = value;
  372. if (!this._muted) {
  373. _innerAudioContextMap[this._$sn].volume = value;
  374. }
  375. }
  376. }, {
  377. key: 'muted',
  378. get: function get() {
  379. return this._muted;
  380. },
  381. set: function set(value) {
  382. this._muted = value;
  383. if (value) {
  384. _innerAudioContextMap[this._$sn].volume = 0;
  385. } else {
  386. _innerAudioContextMap[this._$sn].volume = this._volume;
  387. }
  388. }
  389. }]);
  390. return Audio;
  391. }(_HTMLAudioElement__WEBPACK_IMPORTED_MODULE_0__["default"]);
  392. Audio.HAVE_NOTHING = 0;
  393. Audio.HAVE_METADATA = 1;
  394. Audio.HAVE_CURRENT_DATA = 2;
  395. Audio.HAVE_FUTURE_DATA = 3;
  396. Audio.HAVE_ENOUGH_DATA = 4;
  397. /***/ }),
  398. /***/ "./src/Base64.js":
  399. /*!***********************!*\
  400. !*** ./src/Base64.js ***!
  401. \***********************/
  402. /*! exports provided: btoa, atob */
  403. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  404. "use strict";
  405. __webpack_require__.r(__webpack_exports__);
  406. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "btoa", function() { return btoa; });
  407. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "atob", function() { return atob; });
  408. /* eslint-disable */
  409. var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  410. function InvalidCharacterError(message) {
  411. this.message = message;
  412. }
  413. InvalidCharacterError.prototype = new Error();
  414. InvalidCharacterError.prototype.name = 'InvalidCharacterError';
  415. // encoder
  416. // [https://gist.github.com/999166] by [https://github.com/nignag]
  417. function btoa(input) {
  418. var str = String(input);
  419. var output = '';
  420. for (
  421. // initialize result and counter
  422. var block, charCode, idx = 0, map = chars;
  423. // if the next str index does not exist:
  424. // change the mapping table to "="
  425. // check if d has no fractional digits
  426. str.charAt(idx | 0) || (map = '=', idx % 1);
  427. // "8 - idx % 1 * 8" generates the sequence 2, 4, 6, 8
  428. output += map.charAt(63 & block >> 8 - idx % 1 * 8)) {
  429. charCode = str.charCodeAt(idx += 3 / 4);
  430. if (charCode > 0xFF) {
  431. throw new InvalidCharacterError("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");
  432. }
  433. block = block << 8 | charCode;
  434. }
  435. return output;
  436. }
  437. // decoder
  438. // [https://gist.github.com/1020396] by [https://github.com/atk]
  439. function atob(input) {
  440. var str = String(input).replace(/=+$/, '');
  441. if (str.length % 4 === 1) {
  442. throw new InvalidCharacterError("'atob' failed: The string to be decoded is not correctly encoded.");
  443. }
  444. var output = '';
  445. for (
  446. // initialize result and counters
  447. var bc = 0, bs, buffer, idx = 0;
  448. // get next character
  449. buffer = str.charAt(idx++);
  450. // character found in table? initialize bit storage and add its ascii value;
  451. ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
  452. // and if not first of each 4 characters,
  453. // convert the first 8 bits to one ascii character
  454. bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0) {
  455. // try to find character in table (0-63, not found => -1)
  456. buffer = chars.indexOf(buffer);
  457. }
  458. return output;
  459. }
  460. /***/ }),
  461. /***/ "./src/Body.js":
  462. /*!*********************!*\
  463. !*** ./src/Body.js ***!
  464. \*********************/
  465. /*! exports provided: default */
  466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  467. "use strict";
  468. __webpack_require__.r(__webpack_exports__);
  469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Body; });
  470. /* harmony import */ var _HTMLElement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HTMLElement */ "./src/HTMLElement.js");
  471. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  472. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  473. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  474. /* eslint-disable */
  475. var Body = function (_HTMLElement) {
  476. _inherits(Body, _HTMLElement);
  477. function Body() {
  478. _classCallCheck(this, Body);
  479. // 为了性能, 此处不按照标准的DOM层级关系设计
  480. // 将 body 设置为 0级, parent元素为null
  481. return _possibleConstructorReturn(this, (Body.__proto__ || Object.getPrototypeOf(Body)).call(this, 'body', 0));
  482. }
  483. return Body;
  484. }(_HTMLElement__WEBPACK_IMPORTED_MODULE_0__["default"]);
  485. /***/ }),
  486. /***/ "./src/Canvas.js":
  487. /*!***********************!*\
  488. !*** ./src/Canvas.js ***!
  489. \***********************/
  490. /*! exports provided: default */
  491. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  492. "use strict";
  493. __webpack_require__.r(__webpack_exports__);
  494. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Canvas; });
  495. /* harmony import */ var _util_mixin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/mixin */ "./src/util/mixin.js");
  496. /* eslint-disable */
  497. // import HTMLCanvasElement from './HTMLCanvasElement'
  498. // TODO
  499. var hasModifiedCanvasPrototype = false;
  500. var hasInit2DContextConstructor = false;
  501. var hasInitWebGLContextConstructor = false;
  502. function Canvas() {
  503. var canvas = swan.createCanvas();
  504. var _getContext = canvas.getContext;
  505. // canvas.__proto__.__proto__.__proto__ = new HTMLCanvasElement()
  506. if (!('tagName' in canvas)) {
  507. canvas.tagName = 'CANVAS';
  508. }
  509. canvas.type = 'canvas';
  510. _util_mixin__WEBPACK_IMPORTED_MODULE_0__["parentNode"](canvas);
  511. _util_mixin__WEBPACK_IMPORTED_MODULE_0__["style"](canvas);
  512. _util_mixin__WEBPACK_IMPORTED_MODULE_0__["classList"](canvas);
  513. _util_mixin__WEBPACK_IMPORTED_MODULE_0__["clientRegion"](canvas);
  514. _util_mixin__WEBPACK_IMPORTED_MODULE_0__["offsetRegion"](canvas);
  515. canvas.focus = function () {};
  516. canvas.blur = function () {};
  517. canvas.addEventListener = function (type, listener) {
  518. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  519. // console.log('canvas.addEventListener', type);
  520. document.addEventListener(type, listener, options);
  521. };
  522. canvas.removeEventListener = function (type, listener) {
  523. // console.log('canvas.removeEventListener', type);
  524. document.removeEventListener(type, listener);
  525. };
  526. canvas.dispatchEvent = function () {
  527. var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  528. console.log('canvas.dispatchEvent', event.type, event);
  529. // nothing to do
  530. };
  531. return canvas;
  532. }
  533. /***/ }),
  534. /***/ "./src/DocumentElement.js":
  535. /*!********************************!*\
  536. !*** ./src/DocumentElement.js ***!
  537. \********************************/
  538. /*! exports provided: default */
  539. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  540. "use strict";
  541. __webpack_require__.r(__webpack_exports__);
  542. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return DocumentElement; });
  543. /* harmony import */ var _HTMLElement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HTMLElement */ "./src/HTMLElement.js");
  544. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  545. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  546. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  547. /* eslint-disable */
  548. var DocumentElement = function (_HTMLElement) {
  549. _inherits(DocumentElement, _HTMLElement);
  550. function DocumentElement() {
  551. _classCallCheck(this, DocumentElement);
  552. return _possibleConstructorReturn(this, (DocumentElement.__proto__ || Object.getPrototypeOf(DocumentElement)).call(this, 'html', 0));
  553. }
  554. return DocumentElement;
  555. }(_HTMLElement__WEBPACK_IMPORTED_MODULE_0__["default"]);
  556. /***/ }),
  557. /***/ "./src/Element.js":
  558. /*!************************!*\
  559. !*** ./src/Element.js ***!
  560. \************************/
  561. /*! exports provided: default */
  562. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  563. "use strict";
  564. __webpack_require__.r(__webpack_exports__);
  565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Element; });
  566. /* harmony import */ var _Node__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Node */ "./src/Node.js");
  567. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  568. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  569. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  570. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  571. /* eslint-disable */
  572. var Element = function (_Node) {
  573. _inherits(Element, _Node);
  574. function Element() {
  575. _classCallCheck(this, Element);
  576. var _this = _possibleConstructorReturn(this, (Element.__proto__ || Object.getPrototypeOf(Element)).call(this));
  577. _this.className = '';
  578. _this.children = [];
  579. return _this;
  580. }
  581. _createClass(Element, [{
  582. key: 'setAttribute',
  583. value: function setAttribute(name, value) {
  584. this[name] = value;
  585. }
  586. }, {
  587. key: 'getAttribute',
  588. value: function getAttribute(name) {
  589. return this[name];
  590. }
  591. }, {
  592. key: 'setAttributeNS',
  593. value: function setAttributeNS(name, value) {
  594. this[name] = value;
  595. }
  596. }, {
  597. key: 'getAttributeNS',
  598. value: function getAttributeNS(name) {
  599. return this[name];
  600. }
  601. }]);
  602. return Element;
  603. }(_Node__WEBPACK_IMPORTED_MODULE_0__["default"]);
  604. /***/ }),
  605. /***/ "./src/Event.js":
  606. /*!**********************!*\
  607. !*** ./src/Event.js ***!
  608. \**********************/
  609. /*! exports provided: default */
  610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  611. "use strict";
  612. __webpack_require__.r(__webpack_exports__);
  613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Event; });
  614. /* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/index.js */ "./src/util/index.js");
  615. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  616. /* eslint-disable */
  617. var Event = function Event(type) {
  618. _classCallCheck(this, Event);
  619. this.cancelBubble = false;
  620. this.cancelable = false;
  621. this.target = null;
  622. this.currentTarget = null;
  623. this.preventDefault = _util_index_js__WEBPACK_IMPORTED_MODULE_0__["noop"];
  624. this.stopPropagation = _util_index_js__WEBPACK_IMPORTED_MODULE_0__["noop"];
  625. this.type = type;
  626. this.timeStamp = Date.now();
  627. };
  628. /***/ }),
  629. /***/ "./src/EventIniter/MouseEvent.js":
  630. /*!***************************************!*\
  631. !*** ./src/EventIniter/MouseEvent.js ***!
  632. \***************************************/
  633. /*! exports provided: default */
  634. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  635. "use strict";
  636. __webpack_require__.r(__webpack_exports__);
  637. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return MouseEvent; });
  638. /* harmony import */ var _Event__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Event */ "./src/Event.js");
  639. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  640. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  641. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  642. /* eslint-disable */
  643. var MouseEvent = function (_Event) {
  644. _inherits(MouseEvent, _Event);
  645. function MouseEvent(type) {
  646. _classCallCheck(this, MouseEvent);
  647. return _possibleConstructorReturn(this, (MouseEvent.__proto__ || Object.getPrototypeOf(MouseEvent)).call(this, type));
  648. }
  649. return MouseEvent;
  650. }(_Event__WEBPACK_IMPORTED_MODULE_0__["default"]);
  651. /***/ }),
  652. /***/ "./src/EventIniter/PointerEvent.js":
  653. /*!*****************************************!*\
  654. !*** ./src/EventIniter/PointerEvent.js ***!
  655. \*****************************************/
  656. /*! exports provided: default */
  657. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  658. "use strict";
  659. __webpack_require__.r(__webpack_exports__);
  660. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return PointerEvent; });
  661. /* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/index.js */ "./src/util/index.js");
  662. /* harmony import */ var _Event__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Event */ "./src/Event.js");
  663. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  664. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  665. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  666. /* eslint-disable */
  667. var PointerEvent = function (_Event) {
  668. _inherits(PointerEvent, _Event);
  669. function PointerEvent(type) {
  670. _classCallCheck(this, PointerEvent);
  671. var _this = _possibleConstructorReturn(this, (PointerEvent.__proto__ || Object.getPrototypeOf(PointerEvent)).call(this, type));
  672. _this.target = window.canvas;
  673. _this.currentTarget = window.canvas;
  674. return _this;
  675. }
  676. return PointerEvent;
  677. }(_Event__WEBPACK_IMPORTED_MODULE_1__["default"]);
  678. var CLONE_PROPS = [
  679. // MouseEvent
  680. 'bubbles', 'cancelable', 'view', 'detail', 'screenX', 'screenY', 'clientX', 'clientY', 'ctrlKey', 'altKey', 'shiftKey', 'metaKey', 'button', 'relatedTarget',
  681. // PointerEvent
  682. 'pointerId', 'width', 'height', 'pressure', 'tiltX', 'tiltY', 'pointerType', 'hwTimestamp', 'isPrimary',
  683. // event instance
  684. 'pageX', 'pageY', 'timeStamp'];
  685. var CLONE_DEFAULTS = [
  686. // MouseEvent
  687. false, false, null, null, 0, 0, 0, 0, false, false, false, false, 0, null,
  688. // DOM Level 3
  689. 0,
  690. // PointerEvent
  691. 0, 0, 0, 0, 0, 0, '', 0, false,
  692. // event instance
  693. 0, 0, 0];
  694. var POINTER_TYPE = 'touch';
  695. function touchToPointer(type, touch, rawEvent) {
  696. var e = new PointerEvent(type);
  697. for (var i = 0; i < CLONE_PROPS.length; i++) {
  698. var p = CLONE_PROPS[i];
  699. e[p] = touch[p] || CLONE_DEFAULTS[i];
  700. }
  701. e.type = type;
  702. e.target = window.canvas;
  703. e.currentTarget = window.canvas;
  704. e.buttons = typeToButtons(type);
  705. e.which = e.buttons;
  706. e.pointerId = (touch.identifier || 0) + 2;
  707. e.bubbles = true;
  708. e.cancelable = true;
  709. // e.detail = this.clickCount;
  710. e.button = 0;
  711. e.width = (touch.radiusX || 0.5) * 2;
  712. e.height = (touch.radiusY || 0.5) * 2;
  713. e.pressure = touch.force || 0.5;
  714. e.isPrimary = isPrimaryPointer(touch);
  715. e.pointerType = POINTER_TYPE;
  716. // forward modifier keys
  717. e.altKey = rawEvent.altKey;
  718. e.ctrlKey = rawEvent.ctrlKey;
  719. e.metaKey = rawEvent.metaKey;
  720. e.shiftKey = rawEvent.shiftKey;
  721. if (rawEvent.preventDefault) {
  722. e.preventDefault = function () {
  723. rawEvent.preventDefault();
  724. };
  725. }
  726. return e;
  727. }
  728. function typeToButtons(type) {
  729. var ret = 0;
  730. if (type === 'touchstart' || type === 'touchmove' || type === 'pointerdown' || type === 'pointermove') {
  731. ret = 1;
  732. }
  733. return ret;
  734. }
  735. var firstPointer = null;
  736. function isPrimaryPointer(touch) {
  737. return firstPointer === touch.identifier;
  738. }
  739. function setPrimaryPointer(touch) {
  740. if (firstPointer === null) {
  741. firstPointer = touch.identifier;
  742. }
  743. }
  744. function removePrimaryPointer(touch) {
  745. if (firstPointer === touch.identifier) {
  746. firstPointer = null;
  747. }
  748. }
  749. function eventHandlerFactory(type) {
  750. return function (rawEvent) {
  751. var changedTouches = rawEvent.changedTouches;
  752. for (var i = 0; i < changedTouches.length; i++) {
  753. var touch = changedTouches[i];
  754. if (i === 0 && type === 'pointerdown') {
  755. setPrimaryPointer(touch);
  756. } else if (type === 'pointerup' || type === 'pointercancel') {
  757. removePrimaryPointer(touch);
  758. }
  759. var event = touchToPointer(type, touch, rawEvent);
  760. document.dispatchEvent(event);
  761. }
  762. };
  763. }
  764. if (swan.onTouchStart) {
  765. swan.onTouchStart(eventHandlerFactory('pointerdown'));
  766. swan.onTouchMove(eventHandlerFactory('pointermove'));
  767. swan.onTouchEnd(eventHandlerFactory('pointerup'));
  768. swan.onTouchCancel(eventHandlerFactory('pointercancel'));
  769. }
  770. /***/ }),
  771. /***/ "./src/EventIniter/TouchEvent.js":
  772. /*!***************************************!*\
  773. !*** ./src/EventIniter/TouchEvent.js ***!
  774. \***************************************/
  775. /*! exports provided: default */
  776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  777. "use strict";
  778. __webpack_require__.r(__webpack_exports__);
  779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return TouchEvent; });
  780. /* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/index.js */ "./src/util/index.js");
  781. /* harmony import */ var _Event__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Event */ "./src/Event.js");
  782. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  783. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  784. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  785. /* eslint-disable */
  786. var TouchEvent = function (_Event) {
  787. _inherits(TouchEvent, _Event);
  788. function TouchEvent(type) {
  789. _classCallCheck(this, TouchEvent);
  790. var _this = _possibleConstructorReturn(this, (TouchEvent.__proto__ || Object.getPrototypeOf(TouchEvent)).call(this, type));
  791. _this.touches = [];
  792. _this.targetTouches = [];
  793. _this.changedTouches = [];
  794. _this.target = window.canvas;
  795. _this.currentTarget = window.canvas;
  796. return _this;
  797. }
  798. return TouchEvent;
  799. }(_Event__WEBPACK_IMPORTED_MODULE_1__["default"]);
  800. function eventHandlerFactory(type) {
  801. return function (rawEvent) {
  802. var event = new TouchEvent(type);
  803. event.changedTouches = rawEvent.changedTouches;
  804. event.touches = rawEvent.touches;
  805. event.targetTouches = Array.prototype.slice.call(rawEvent.touches);
  806. event.timeStamp = rawEvent.timeStamp;
  807. document.dispatchEvent(event);
  808. };
  809. }
  810. if (swan.onTouchStart) {
  811. swan.onTouchStart(eventHandlerFactory('touchstart'));
  812. swan.onTouchMove(eventHandlerFactory('touchmove'));
  813. swan.onTouchEnd(eventHandlerFactory('touchend'));
  814. swan.onTouchCancel(eventHandlerFactory('touchcancel'));
  815. }
  816. /***/ }),
  817. /***/ "./src/EventIniter/index.js":
  818. /*!**********************************!*\
  819. !*** ./src/EventIniter/index.js ***!
  820. \**********************************/
  821. /*! exports provided: TouchEvent, PointerEvent, MouseEvent */
  822. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  823. "use strict";
  824. __webpack_require__.r(__webpack_exports__);
  825. /* harmony import */ var _TouchEvent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./TouchEvent */ "./src/EventIniter/TouchEvent.js");
  826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchEvent", function() { return _TouchEvent__WEBPACK_IMPORTED_MODULE_0__["default"]; });
  827. /* harmony import */ var _PointerEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./PointerEvent */ "./src/EventIniter/PointerEvent.js");
  828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEvent", function() { return _PointerEvent__WEBPACK_IMPORTED_MODULE_1__["default"]; });
  829. /* harmony import */ var _MouseEvent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./MouseEvent */ "./src/EventIniter/MouseEvent.js");
  830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MouseEvent", function() { return _MouseEvent__WEBPACK_IMPORTED_MODULE_2__["default"]; });
  831. /* eslint-disable */
  832. /***/ }),
  833. /***/ "./src/EventTarget.js":
  834. /*!****************************!*\
  835. !*** ./src/EventTarget.js ***!
  836. \****************************/
  837. /*! exports provided: default */
  838. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  839. "use strict";
  840. __webpack_require__.r(__webpack_exports__);
  841. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return EventTarget; });
  842. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  843. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  844. /* eslint-disable */
  845. var _events = new WeakMap();
  846. var EventTarget = function () {
  847. function EventTarget() {
  848. _classCallCheck(this, EventTarget);
  849. _events.set(this, {});
  850. }
  851. _createClass(EventTarget, [{
  852. key: "addEventListener",
  853. value: function addEventListener(type, listener) {
  854. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  855. var events = _events.get(this);
  856. if (!events) {
  857. events = {};
  858. _events.set(this, events);
  859. }
  860. if (!events[type]) {
  861. events[type] = [];
  862. }
  863. events[type].push(listener);
  864. if (options.capture) {
  865. // console.warn('EventTarget.addEventListener: options.capture is not implemented.')
  866. }
  867. if (options.once) {
  868. // console.warn('EventTarget.addEventListener: options.once is not implemented.')
  869. }
  870. if (options.passive) {
  871. // console.warn('EventTarget.addEventListener: options.passive is not implemented.')
  872. }
  873. }
  874. }, {
  875. key: "removeEventListener",
  876. value: function removeEventListener(type, listener) {
  877. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  878. var events = _events.get(this);
  879. if (events) {
  880. var listeners = events[type];
  881. if (listeners && listeners.length > 0) {
  882. for (var i = listeners.length; i--; i > 0) {
  883. if (listeners[i] === listener) {
  884. listeners.splice(i, 1);
  885. break;
  886. }
  887. }
  888. }
  889. }
  890. }
  891. }, {
  892. key: "dispatchEvent",
  893. value: function dispatchEvent() {
  894. var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  895. var listeners = _events.get(this)[event.type];
  896. if (listeners) {
  897. for (var i = 0; i < listeners.length; i++) {
  898. listeners[i](event);
  899. }
  900. }
  901. }
  902. }]);
  903. return EventTarget;
  904. }();
  905. /***/ }),
  906. /***/ "./src/FileReader.js":
  907. /*!***************************!*\
  908. !*** ./src/FileReader.js ***!
  909. \***************************/
  910. /*! exports provided: default */
  911. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  912. "use strict";
  913. __webpack_require__.r(__webpack_exports__);
  914. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return FileReader; });
  915. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  916. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  917. /* eslint-disable */
  918. /*
  919. * TODO 使用 swan.readFile 来封装 FileReader
  920. */
  921. var FileReader = function () {
  922. function FileReader() {
  923. _classCallCheck(this, FileReader);
  924. }
  925. _createClass(FileReader, [{
  926. key: "construct",
  927. value: function construct() {}
  928. }]);
  929. return FileReader;
  930. }();
  931. /***/ }),
  932. /***/ "./src/HTMLAudioElement.js":
  933. /*!*********************************!*\
  934. !*** ./src/HTMLAudioElement.js ***!
  935. \*********************************/
  936. /*! exports provided: default */
  937. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  938. "use strict";
  939. __webpack_require__.r(__webpack_exports__);
  940. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return HTMLAudioElement; });
  941. /* harmony import */ var _HTMLMediaElement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HTMLMediaElement */ "./src/HTMLMediaElement.js");
  942. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  943. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  944. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  945. /* eslint-disable */
  946. var HTMLAudioElement = function (_HTMLMediaElement) {
  947. _inherits(HTMLAudioElement, _HTMLMediaElement);
  948. function HTMLAudioElement() {
  949. _classCallCheck(this, HTMLAudioElement);
  950. return _possibleConstructorReturn(this, (HTMLAudioElement.__proto__ || Object.getPrototypeOf(HTMLAudioElement)).call(this, 'audio'));
  951. }
  952. return HTMLAudioElement;
  953. }(_HTMLMediaElement__WEBPACK_IMPORTED_MODULE_0__["default"]);
  954. /***/ }),
  955. /***/ "./src/HTMLCanvasElement.js":
  956. /*!**********************************!*\
  957. !*** ./src/HTMLCanvasElement.js ***!
  958. \**********************************/
  959. /*! exports provided: default */
  960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  961. "use strict";
  962. __webpack_require__.r(__webpack_exports__);
  963. /* harmony import */ var _Canvas__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Canvas */ "./src/Canvas.js");
  964. /* harmony import */ var _HTMLElement__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./HTMLElement */ "./src/HTMLElement.js");
  965. /* eslint-disable */
  966. // import HTMLElement from './HTMLElement';
  967. // export default class HTMLCanvasElement extends HTMLElement
  968. // {
  969. // constructor(){
  970. // super('canvas')
  971. // }
  972. // };
  973. GameGlobal.screencanvas = GameGlobal.screencanvas || new _Canvas__WEBPACK_IMPORTED_MODULE_0__["default"]();
  974. var canvas = GameGlobal.screencanvas;
  975. var canvasConstructor = canvas.constructor;
  976. // canvasConstructor.__proto__.__proto__ = new HTMLElement();
  977. /* harmony default export */ __webpack_exports__["default"] = (canvasConstructor);
  978. /***/ }),
  979. /***/ "./src/HTMLElement.js":
  980. /*!****************************!*\
  981. !*** ./src/HTMLElement.js ***!
  982. \****************************/
  983. /*! exports provided: default */
  984. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  985. "use strict";
  986. __webpack_require__.r(__webpack_exports__);
  987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return HTMLElement; });
  988. /* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/index.js */ "./src/util/index.js");
  989. /* harmony import */ var _util_mixin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./util/mixin */ "./src/util/mixin.js");
  990. /* harmony import */ var _Element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Element */ "./src/Element.js");
  991. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  992. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  993. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  994. /* eslint-disable */
  995. var HTMLElement = function (_Element) {
  996. _inherits(HTMLElement, _Element);
  997. function HTMLElement() {
  998. var tagName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  999. var level = arguments[1];
  1000. _classCallCheck(this, HTMLElement);
  1001. var _this = _possibleConstructorReturn(this, (HTMLElement.__proto__ || Object.getPrototypeOf(HTMLElement)).call(this));
  1002. _this.className = '';
  1003. _this.childern = [];
  1004. _this.focus = _util_index_js__WEBPACK_IMPORTED_MODULE_0__["noop"];
  1005. _this.blur = _util_index_js__WEBPACK_IMPORTED_MODULE_0__["noop"];
  1006. _this.insertBefore = _util_index_js__WEBPACK_IMPORTED_MODULE_0__["noop"];
  1007. _this.appendChild = _util_index_js__WEBPACK_IMPORTED_MODULE_0__["noop"];
  1008. _this.removeChild = _util_index_js__WEBPACK_IMPORTED_MODULE_0__["noop"];
  1009. _this.remove = _util_index_js__WEBPACK_IMPORTED_MODULE_0__["noop"];
  1010. _this.innerHTML = '';
  1011. _this.tagName = tagName.toUpperCase();
  1012. _util_mixin__WEBPACK_IMPORTED_MODULE_1__["parentNode"](_this, level);
  1013. _util_mixin__WEBPACK_IMPORTED_MODULE_1__["style"](_this);
  1014. _util_mixin__WEBPACK_IMPORTED_MODULE_1__["classList"](_this);
  1015. _util_mixin__WEBPACK_IMPORTED_MODULE_1__["clientRegion"](_this);
  1016. _util_mixin__WEBPACK_IMPORTED_MODULE_1__["offsetRegion"](_this);
  1017. _util_mixin__WEBPACK_IMPORTED_MODULE_1__["scrollRegion"](_this);
  1018. return _this;
  1019. }
  1020. return HTMLElement;
  1021. }(_Element__WEBPACK_IMPORTED_MODULE_2__["default"]);
  1022. /***/ }),
  1023. /***/ "./src/HTMLImageElement.js":
  1024. /*!*********************************!*\
  1025. !*** ./src/HTMLImageElement.js ***!
  1026. \*********************************/
  1027. /*! exports provided: default */
  1028. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1029. "use strict";
  1030. __webpack_require__.r(__webpack_exports__);
  1031. /* harmony import */ var _HTMLElement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HTMLElement */ "./src/HTMLElement.js");
  1032. /* eslint-disable */
  1033. // import HTMLElement from './HTMLElement';
  1034. // export default class HTMLImageElement extends HTMLElement
  1035. // {
  1036. // constructor(){
  1037. // super('img')
  1038. // }
  1039. // };
  1040. var imageConstructor = swan.createImage().constructor;
  1041. // imageConstructor.__proto__.__proto__ = new HTMLElement();
  1042. /* harmony default export */ __webpack_exports__["default"] = (imageConstructor);
  1043. /***/ }),
  1044. /***/ "./src/HTMLMediaElement.js":
  1045. /*!*********************************!*\
  1046. !*** ./src/HTMLMediaElement.js ***!
  1047. \*********************************/
  1048. /*! exports provided: default */
  1049. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1050. "use strict";
  1051. __webpack_require__.r(__webpack_exports__);
  1052. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return HTMLMediaElement; });
  1053. /* harmony import */ var _HTMLElement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HTMLElement */ "./src/HTMLElement.js");
  1054. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1055. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1056. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1057. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1058. /* eslint-disable */
  1059. var HTMLMediaElement = function (_HTMLElement) {
  1060. _inherits(HTMLMediaElement, _HTMLElement);
  1061. function HTMLMediaElement(tagName) {
  1062. _classCallCheck(this, HTMLMediaElement);
  1063. return _possibleConstructorReturn(this, (HTMLMediaElement.__proto__ || Object.getPrototypeOf(HTMLMediaElement)).call(this, tagName));
  1064. }
  1065. _createClass(HTMLMediaElement, [{
  1066. key: 'addTextTrack',
  1067. value: function addTextTrack() {}
  1068. }, {
  1069. key: 'captureStream',
  1070. value: function captureStream() {}
  1071. }, {
  1072. key: 'fastSeek',
  1073. value: function fastSeek() {}
  1074. }, {
  1075. key: 'load',
  1076. value: function load() {}
  1077. }, {
  1078. key: 'pause',
  1079. value: function pause() {}
  1080. }, {
  1081. key: 'play',
  1082. value: function play() {}
  1083. }]);
  1084. return HTMLMediaElement;
  1085. }(_HTMLElement__WEBPACK_IMPORTED_MODULE_0__["default"]);
  1086. /***/ }),
  1087. /***/ "./src/HTMLVideoElement.js":
  1088. /*!*********************************!*\
  1089. !*** ./src/HTMLVideoElement.js ***!
  1090. \*********************************/
  1091. /*! exports provided: default */
  1092. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1093. "use strict";
  1094. __webpack_require__.r(__webpack_exports__);
  1095. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return HTMLVideoElement; });
  1096. /* harmony import */ var _HTMLMediaElement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HTMLMediaElement */ "./src/HTMLMediaElement.js");
  1097. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1098. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1099. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1100. /* eslint-disable */
  1101. var HTMLVideoElement = function (_HTMLMediaElement) {
  1102. _inherits(HTMLVideoElement, _HTMLMediaElement);
  1103. function HTMLVideoElement() {
  1104. _classCallCheck(this, HTMLVideoElement);
  1105. return _possibleConstructorReturn(this, (HTMLVideoElement.__proto__ || Object.getPrototypeOf(HTMLVideoElement)).call(this, 'video'));
  1106. }
  1107. return HTMLVideoElement;
  1108. }(_HTMLMediaElement__WEBPACK_IMPORTED_MODULE_0__["default"]);
  1109. ;
  1110. /***/ }),
  1111. /***/ "./src/Image.js":
  1112. /*!**********************!*\
  1113. !*** ./src/Image.js ***!
  1114. \**********************/
  1115. /*! exports provided: default */
  1116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1117. "use strict";
  1118. __webpack_require__.r(__webpack_exports__);
  1119. /* harmony import */ var _util_mixin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/mixin */ "./src/util/mixin.js");
  1120. /* harmony import */ var _HTMLImageElement__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./HTMLImageElement */ "./src/HTMLImageElement.js");
  1121. /* eslint-disable */
  1122. /* harmony default export */ __webpack_exports__["default"] = (function () {
  1123. var image = swan.createImage();
  1124. // image.__proto__.__proto__.__proto__ = new HTMLImageElement();
  1125. if (!('tagName' in image)) {
  1126. image.tagName = 'IMG';
  1127. }
  1128. _util_mixin__WEBPACK_IMPORTED_MODULE_0__["parentNode"](image);
  1129. _util_mixin__WEBPACK_IMPORTED_MODULE_0__["classList"](image);
  1130. return image;
  1131. });;
  1132. /***/ }),
  1133. /***/ "./src/ImageBitmap.js":
  1134. /*!****************************!*\
  1135. !*** ./src/ImageBitmap.js ***!
  1136. \****************************/
  1137. /*! exports provided: default */
  1138. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1139. "use strict";
  1140. __webpack_require__.r(__webpack_exports__);
  1141. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return ImageBitmap; });
  1142. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1143. /* eslint-disable */
  1144. var ImageBitmap = function ImageBitmap() {
  1145. // TODO
  1146. _classCallCheck(this, ImageBitmap);
  1147. };
  1148. /***/ }),
  1149. /***/ "./src/Node.js":
  1150. /*!*********************!*\
  1151. !*** ./src/Node.js ***!
  1152. \*********************/
  1153. /*! exports provided: default */
  1154. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1155. "use strict";
  1156. __webpack_require__.r(__webpack_exports__);
  1157. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Node; });
  1158. /* harmony import */ var _EventTarget_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EventTarget.js */ "./src/EventTarget.js");
  1159. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1160. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1161. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1162. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1163. /* eslint-disable */
  1164. var Node = function (_EventTarget) {
  1165. _inherits(Node, _EventTarget);
  1166. function Node() {
  1167. _classCallCheck(this, Node);
  1168. var _this = _possibleConstructorReturn(this, (Node.__proto__ || Object.getPrototypeOf(Node)).call(this));
  1169. _this.childNodes = [];
  1170. return _this;
  1171. }
  1172. _createClass(Node, [{
  1173. key: 'appendChild',
  1174. value: function appendChild(node) {
  1175. this.childNodes.push(node);
  1176. // if (node instanceof Node) {
  1177. // this.childNodes.push(node)
  1178. // } else {
  1179. // throw new TypeError('Failed to executed \'appendChild\' on \'Node\': parameter 1 is not of type \'Node\'.')
  1180. // }
  1181. }
  1182. }, {
  1183. key: 'cloneNode',
  1184. value: function cloneNode() {
  1185. var copyNode = Object.create(this);
  1186. Object.assign(copyNode, this);
  1187. return copyNode;
  1188. }
  1189. }, {
  1190. key: 'removeChild',
  1191. value: function removeChild(node) {
  1192. var index = this.childNodes.findIndex(function (child) {
  1193. return child === node;
  1194. });
  1195. if (index > -1) {
  1196. return this.childNodes.splice(index, 1);
  1197. }
  1198. return null;
  1199. }
  1200. }]);
  1201. return Node;
  1202. }(_EventTarget_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
  1203. /***/ }),
  1204. /***/ "./src/WebGLRenderingContext.js":
  1205. /*!**************************************!*\
  1206. !*** ./src/WebGLRenderingContext.js ***!
  1207. \**************************************/
  1208. /*! exports provided: default */
  1209. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1210. "use strict";
  1211. __webpack_require__.r(__webpack_exports__);
  1212. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return WebGLRenderingContext; });
  1213. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1214. /* eslint-disable */
  1215. var WebGLRenderingContext = function WebGLRenderingContext() {
  1216. // TODO
  1217. _classCallCheck(this, WebGLRenderingContext);
  1218. };
  1219. /***/ }),
  1220. /***/ "./src/WebSocket.js":
  1221. /*!**************************!*\
  1222. !*** ./src/WebSocket.js ***!
  1223. \**************************/
  1224. /*! exports provided: default */
  1225. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1226. "use strict";
  1227. __webpack_require__.r(__webpack_exports__);
  1228. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return WebSocket; });
  1229. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1230. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1231. /* eslint-disable */
  1232. var _socketTask = new WeakMap();
  1233. var WebSocket = function () {
  1234. function WebSocket(url) {
  1235. var _this = this;
  1236. var protocols = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  1237. _classCallCheck(this, WebSocket);
  1238. this.binaryType = ''; // TODO 更新 binaryType
  1239. this.bufferedAmount = 0; // TODO 更新 bufferedAmount
  1240. this.extensions = '';
  1241. this.onclose = null;
  1242. this.onerror = null;
  1243. this.onmessage = null;
  1244. this.onopen = null;
  1245. this.protocol = ''; // TODO 小程序内目前获取不到,实际上需要根据服务器选择的 sub-protocol 返回
  1246. this.readyState = 3;
  1247. if (typeof url !== 'string' || !/(^ws:\/\/)|(^wss:\/\/)/.test(url)) {
  1248. throw new TypeError('Failed to construct \'WebSocket\': The URL \'' + url + '\' is invalid');
  1249. }
  1250. this.url = url;
  1251. this.readyState = WebSocket.CONNECTING;
  1252. var socketTask = swan.connectSocket({
  1253. url: url,
  1254. protocols: Array.isArray(protocols) ? protocols : [protocols]
  1255. });
  1256. _socketTask.set(this, socketTask);
  1257. socketTask.onClose(function (res) {
  1258. _this.readyState = WebSocket.CLOSED;
  1259. if (typeof _this.onclose === 'function') {
  1260. _this.onclose(res);
  1261. }
  1262. });
  1263. socketTask.onMessage(function (res) {
  1264. if (typeof _this.onmessage === 'function') {
  1265. _this.onmessage(res);
  1266. }
  1267. });
  1268. socketTask.onOpen(function () {
  1269. _this.readyState = WebSocket.OPEN;
  1270. if (typeof _this.onopen === 'function') {
  1271. _this.onopen();
  1272. }
  1273. });
  1274. socketTask.onError(function (res) {
  1275. if (typeof _this.onerror === 'function') {
  1276. _this.onerror(new Error(res.errMsg));
  1277. }
  1278. });
  1279. return this;
  1280. }
  1281. _createClass(WebSocket, [{
  1282. key: 'close',
  1283. value: function close(code, reason) {
  1284. this.readyState = WebSocket.CLOSING;
  1285. var socketTask = _socketTask.get(this);
  1286. socketTask.close({
  1287. code: code,
  1288. reason: reason
  1289. });
  1290. }
  1291. }, {
  1292. key: 'send',
  1293. value: function send(data) {
  1294. if (typeof data !== 'string' && !(data instanceof ArrayBuffer)) {
  1295. throw new TypeError('Failed to send message: The data ' + data + ' is invalid');
  1296. }
  1297. var socketTask = _socketTask.get(this);
  1298. socketTask.send({
  1299. data: data
  1300. });
  1301. }
  1302. }]);
  1303. return WebSocket;
  1304. }();
  1305. WebSocket.CONNECTING = 0; // The connection is not yet open.
  1306. WebSocket.OPEN = 1; // The connection is open and ready to communicate.
  1307. WebSocket.CLOSING = 2; // The connection is in the process of closing.
  1308. WebSocket.CLOSED = 3; // The connection is closed or couldn't be opened.
  1309. /***/ }),
  1310. /***/ "./src/WindowProperties.js":
  1311. /*!*********************************!*\
  1312. !*** ./src/WindowProperties.js ***!
  1313. \*********************************/
  1314. /*! exports provided: innerWidth, innerHeight, devicePixelRatio, screen, scrollX, scrollY, ontouchstart, ontouchmove, ontouchend, performance */
  1315. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1316. "use strict";
  1317. __webpack_require__.r(__webpack_exports__);
  1318. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "innerWidth", function() { return innerWidth; });
  1319. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "innerHeight", function() { return innerHeight; });
  1320. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "devicePixelRatio", function() { return devicePixelRatio; });
  1321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "screen", function() { return screen; });
  1322. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scrollX", function() { return scrollX; });
  1323. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scrollY", function() { return scrollY; });
  1324. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ontouchstart", function() { return ontouchstart; });
  1325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ontouchmove", function() { return ontouchmove; });
  1326. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ontouchend", function() { return ontouchend; });
  1327. /* harmony import */ var _performance__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./performance */ "./src/performance.js");
  1328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "performance", function() { return _performance__WEBPACK_IMPORTED_MODULE_0__["default"]; });
  1329. /* eslint-disable */
  1330. var _ref = swan.getSystemInfoSync ? swan.getSystemInfoSync() : { screenWidth: 0, screenHeight: 0, devicePixelRatio: 1 // Mock data
  1331. },
  1332. screenWidth = _ref.screenWidth,
  1333. screenHeight = _ref.screenHeight,
  1334. devicePixelRatio = _ref.devicePixelRatio;
  1335. var innerWidth = screenWidth;
  1336. var innerHeight = screenHeight;
  1337. var screen = {
  1338. width: screenWidth,
  1339. height: screenHeight,
  1340. availWidth: innerWidth,
  1341. availHeight: innerHeight,
  1342. availLeft: 0,
  1343. availTop: 0
  1344. };
  1345. var scrollX = 0;
  1346. var scrollY = 0;
  1347. var ontouchstart = null;
  1348. var ontouchmove = null;
  1349. var ontouchend = null;
  1350. /***/ }),
  1351. /***/ "./src/Worker.js":
  1352. /*!***********************!*\
  1353. !*** ./src/Worker.js ***!
  1354. \***********************/
  1355. /*! exports provided: default */
  1356. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1357. "use strict";
  1358. __webpack_require__.r(__webpack_exports__);
  1359. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return Worker; });
  1360. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1361. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1362. /* eslint-disable */
  1363. var Worker = function () {
  1364. function Worker(file) {
  1365. var _this = this;
  1366. _classCallCheck(this, Worker);
  1367. this.onmessage = null;
  1368. // 目前 微信小游戏中 Worker 最大并发数量限制为 1 个,
  1369. // 所以创建新Worker前, 需要结束现有的 Worker.terminate
  1370. if (Worker.previousWorker) {
  1371. Worker.previousWorker.terminate();
  1372. }
  1373. Worker.previousWorker = this;
  1374. this._file = file;
  1375. this._worker = swan.createWorker(file);
  1376. this._worker.onMessage(function (res) {
  1377. if (_this.onmessage) {
  1378. _this.onmessage({
  1379. target: _this,
  1380. data: res
  1381. });
  1382. }
  1383. });
  1384. }
  1385. _createClass(Worker, [{
  1386. key: "postMessage",
  1387. value: function postMessage(message, transferList) {
  1388. this._worker.postMessage(message, transferList);
  1389. }
  1390. }, {
  1391. key: "terminate",
  1392. value: function terminate() {
  1393. this._worker.terminate();
  1394. Worker.previousWorker = null;
  1395. }
  1396. }]);
  1397. return Worker;
  1398. }();
  1399. Worker.previousWorker = null;
  1400. // export default function(file) {
  1401. // const worker = swan.createWorker(file)
  1402. // return worker
  1403. // }
  1404. /***/ }),
  1405. /***/ "./src/XMLHttpRequest.js":
  1406. /*!*******************************!*\
  1407. !*** ./src/XMLHttpRequest.js ***!
  1408. \*******************************/
  1409. /*! exports provided: default */
  1410. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1411. "use strict";
  1412. __webpack_require__.r(__webpack_exports__);
  1413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return XMLHttpRequest; });
  1414. /* harmony import */ var _EventTarget_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EventTarget.js */ "./src/EventTarget.js");
  1415. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  1416. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1417. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  1418. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  1419. /* eslint-disable */
  1420. var _url = new WeakMap();
  1421. var _method = new WeakMap();
  1422. var _requestHeader = new WeakMap();
  1423. var _responseHeader = new WeakMap();
  1424. var _requestTask = new WeakMap();
  1425. var fs = void 0;
  1426. function _triggerEvent(type) {
  1427. var event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1428. event.target = event.target || this;
  1429. if (typeof this['on' + type] === 'function') {
  1430. this['on' + type].call(this, event);
  1431. }
  1432. }
  1433. function _changeReadyState(readyState) {
  1434. var event = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  1435. this.readyState = readyState;
  1436. event.readyState = readyState;
  1437. _triggerEvent.call(this, 'readystatechange', event);
  1438. }
  1439. function _isRelativePath(url) {
  1440. return !/^(http|https|ftp|wxfile):\/\/.*/i.test(url);
  1441. }
  1442. var XMLHttpRequest = function (_EventTarget) {
  1443. _inherits(XMLHttpRequest, _EventTarget);
  1444. function XMLHttpRequest() {
  1445. _classCallCheck(this, XMLHttpRequest);
  1446. /*
  1447. * TODO 这一批事件应该是在 XMLHttpRequestEventTarget.prototype 上面的
  1448. */
  1449. var _this = _possibleConstructorReturn(this, (XMLHttpRequest.__proto__ || Object.getPrototypeOf(XMLHttpRequest)).call(this));
  1450. _this.onabort = null;
  1451. _this.onerror = null;
  1452. _this.onload = null;
  1453. _this.onloadstart = null;
  1454. _this.onprogress = null;
  1455. _this.ontimeout = null;
  1456. _this.onloadend = null;
  1457. _this.onreadystatechange = null;
  1458. _this.readyState = 0;
  1459. _this.response = null;
  1460. _this.responseText = null;
  1461. _this.responseType = '';
  1462. _this.responseXML = null;
  1463. _this.status = 0;
  1464. _this.statusText = '';
  1465. _this.upload = {};
  1466. _this.withCredentials = false;
  1467. _requestHeader.set(_this, {
  1468. 'content-type': 'application/x-www-form-urlencoded'
  1469. });
  1470. _responseHeader.set(_this, {});
  1471. return _this;
  1472. }
  1473. _createClass(XMLHttpRequest, [{
  1474. key: 'abort',
  1475. value: function abort() {
  1476. var myRequestTask = _requestTask.get(this);
  1477. if (myRequestTask) {
  1478. myRequestTask.abort();
  1479. }
  1480. }
  1481. }, {
  1482. key: 'getAllResponseHeaders',
  1483. value: function getAllResponseHeaders() {
  1484. var responseHeader = _responseHeader.get(this);
  1485. return Object.keys(responseHeader).map(function (header) {
  1486. return header + ': ' + responseHeader[header];
  1487. }).join('\n');
  1488. }
  1489. }, {
  1490. key: 'getResponseHeader',
  1491. value: function getResponseHeader(header) {
  1492. return _responseHeader.get(this)[header];
  1493. }
  1494. }, {
  1495. key: 'open',
  1496. value: function open(method, url /* async, user, password 这几个参数在小程序内不支持*/) {
  1497. _method.set(this, method);
  1498. _url.set(this, url);
  1499. _changeReadyState.call(this, XMLHttpRequest.OPENED);
  1500. }
  1501. }, {
  1502. key: 'overrideMimeType',
  1503. value: function overrideMimeType() {}
  1504. }, {
  1505. key: 'send',
  1506. value: function send() {
  1507. var _this2 = this;
  1508. var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  1509. if (this.readyState !== XMLHttpRequest.OPENED) {
  1510. throw new Error("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.");
  1511. } else {
  1512. var url = _url.get(this);
  1513. var header = _requestHeader.get(this);
  1514. var responseType = this.responseType;
  1515. var relative = _isRelativePath(url);
  1516. var encoding = void 0;
  1517. if (responseType === 'arraybuffer') {
  1518. // encoding = 'binary'
  1519. } else {
  1520. encoding = 'utf8';
  1521. }
  1522. delete this.response;
  1523. this.response = null;
  1524. var onSuccess = function onSuccess(_ref) {
  1525. var data = _ref.data,
  1526. statusCode = _ref.statusCode,
  1527. header = _ref.header;
  1528. statusCode = statusCode === undefined ? 200 : statusCode;
  1529. if (typeof data !== 'string' && !(data instanceof ArrayBuffer)) {
  1530. try {
  1531. data = JSON.stringify(data);
  1532. } catch (e) {
  1533. data = data;
  1534. }
  1535. }
  1536. _this2.status = statusCode;
  1537. if (header) {
  1538. _responseHeader.set(_this2, header);
  1539. }
  1540. _triggerEvent.call(_this2, 'loadstart');
  1541. _changeReadyState.call(_this2, XMLHttpRequest.HEADERS_RECEIVED);
  1542. _changeReadyState.call(_this2, XMLHttpRequest.LOADING);
  1543. _this2.response = data;
  1544. if (data instanceof ArrayBuffer) {
  1545. Object.defineProperty(_this2, 'responseText', {
  1546. enumerable: true,
  1547. configurable: true,
  1548. get: function get() {
  1549. throw "InvalidStateError : responseType is " + this.responseType;
  1550. }
  1551. });
  1552. } else {
  1553. Object.defineProperty(_this2, 'responseText', {
  1554. enumerable: true,
  1555. configurable: true,
  1556. value: data
  1557. });
  1558. }
  1559. _changeReadyState.call(_this2, XMLHttpRequest.DONE);
  1560. _triggerEvent.call(_this2, 'load');
  1561. _triggerEvent.call(_this2, 'loadend');
  1562. };
  1563. var onFail = function onFail(_ref2) {
  1564. var errMsg = _ref2.errMsg;
  1565. // TODO 规范错误
  1566. if (errMsg.indexOf('abort') !== -1) {
  1567. _triggerEvent.call(_this2, 'abort');
  1568. } else {
  1569. _triggerEvent.call(_this2, 'error', {
  1570. message: errMsg
  1571. });
  1572. }
  1573. _triggerEvent.call(_this2, 'loadend');
  1574. if (relative) {
  1575. // 用户即使没监听error事件, 也给出相应的警告
  1576. console.warn(errMsg);
  1577. }
  1578. };
  1579. if (relative) {
  1580. var options = {
  1581. 'filePath': url,
  1582. 'success': onSuccess,
  1583. 'fail': onFail
  1584. };
  1585. if (encoding) {
  1586. options['encoding'] = encoding;
  1587. }
  1588. if (!fs) {
  1589. fs = swan.getFileSystemManager();
  1590. }
  1591. fs.readFile(options);
  1592. return;
  1593. }
  1594. swan.request({
  1595. data: data,
  1596. url: url,
  1597. method: _method.get(this),
  1598. header: header,
  1599. responseType: responseType,
  1600. success: onSuccess,
  1601. fail: onFail
  1602. });
  1603. }
  1604. }
  1605. }, {
  1606. key: 'setRequestHeader',
  1607. value: function setRequestHeader(header, value) {
  1608. var myHeader = _requestHeader.get(this);
  1609. myHeader[header] = value;
  1610. _requestHeader.set(this, myHeader);
  1611. }
  1612. }, {
  1613. key: 'addEventListener',
  1614. value: function addEventListener(type, listener) {
  1615. var _this3 = this;
  1616. if (typeof listener !== 'function') {
  1617. return;
  1618. }
  1619. this['on' + type] = function () {
  1620. var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1621. event.target = event.target || _this3;
  1622. listener.call(_this3, event);
  1623. };
  1624. }
  1625. }, {
  1626. key: 'removeEventListener',
  1627. value: function removeEventListener(type, listener) {
  1628. if (this['on' + type] === listener) {
  1629. this['on' + type] = null;
  1630. }
  1631. }
  1632. }]);
  1633. return XMLHttpRequest;
  1634. }(_EventTarget_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
  1635. // TODO 没法模拟 HEADERS_RECEIVED 和 LOADING 两个状态
  1636. XMLHttpRequest.UNSEND = 0;
  1637. XMLHttpRequest.OPENED = 1;
  1638. XMLHttpRequest.HEADERS_RECEIVED = 2;
  1639. XMLHttpRequest.LOADING = 3;
  1640. XMLHttpRequest.DONE = 4;
  1641. /***/ }),
  1642. /***/ "./src/document.js":
  1643. /*!*************************!*\
  1644. !*** ./src/document.js ***!
  1645. \*************************/
  1646. /*! exports provided: default */
  1647. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1648. "use strict";
  1649. __webpack_require__.r(__webpack_exports__);
  1650. /* harmony import */ var _window__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./window */ "./src/window.js");
  1651. /* harmony import */ var _Event__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Event */ "./src/Event.js");
  1652. /* harmony import */ var _HTMLElement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./HTMLElement */ "./src/HTMLElement.js");
  1653. /* harmony import */ var _HTMLVideoElement__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./HTMLVideoElement */ "./src/HTMLVideoElement.js");
  1654. /* harmony import */ var _Image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Image */ "./src/Image.js");
  1655. /* harmony import */ var _Audio__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Audio */ "./src/Audio.js");
  1656. /* harmony import */ var _Canvas__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Canvas */ "./src/Canvas.js");
  1657. /* harmony import */ var _DocumentElement__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./DocumentElement */ "./src/DocumentElement.js");
  1658. /* harmony import */ var _Body__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Body */ "./src/Body.js");
  1659. /* harmony import */ var _EventIniter_index_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./EventIniter/index.js */ "./src/EventIniter/index.js");
  1660. /* harmony import */ var _location__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./location */ "./src/location.js");
  1661. /* eslint-disable */
  1662. var events = {};
  1663. var document = {
  1664. readyState: 'complete',
  1665. visibilityState: 'visible', // 'visible' , 'hidden'
  1666. hidden: false,
  1667. fullscreen: true,
  1668. URL: _location__WEBPACK_IMPORTED_MODULE_10__["default"].href,
  1669. location: _window__WEBPACK_IMPORTED_MODULE_0__["location"],
  1670. scripts: [],
  1671. style: {},
  1672. ontouchstart: null,
  1673. ontouchmove: null,
  1674. ontouchend: null,
  1675. onvisibilitychange: null,
  1676. parentNode: null,
  1677. parentElement: null,
  1678. createElement: function createElement(tagName) {
  1679. tagName = tagName.toLowerCase();
  1680. if (tagName === 'canvas') {
  1681. return new _Canvas__WEBPACK_IMPORTED_MODULE_6__["default"]();
  1682. } else if (tagName === 'audio') {
  1683. return new _Audio__WEBPACK_IMPORTED_MODULE_5__["default"]();
  1684. } else if (tagName === 'img') {
  1685. return new _Image__WEBPACK_IMPORTED_MODULE_4__["default"]();
  1686. } else if (tagName === 'video') {
  1687. return new _HTMLVideoElement__WEBPACK_IMPORTED_MODULE_3__["default"]();
  1688. }
  1689. return new _HTMLElement__WEBPACK_IMPORTED_MODULE_2__["default"](tagName);
  1690. },
  1691. createElementNS: function createElementNS(nameSpace, tagName) {
  1692. return this.createElement(tagName);
  1693. },
  1694. createTextNode: function createTextNode(text) {
  1695. // TODO: Do we need the TextNode Class ???
  1696. return text;
  1697. },
  1698. getElementById: function getElementById(id) {
  1699. if (id === _window__WEBPACK_IMPORTED_MODULE_0__["canvas"].id) {
  1700. return _window__WEBPACK_IMPORTED_MODULE_0__["canvas"];
  1701. }
  1702. return null;
  1703. },
  1704. getElementsByTagName: function getElementsByTagName(tagName) {
  1705. tagName = tagName.toLowerCase();
  1706. if (tagName === 'head') {
  1707. return [document.head];
  1708. } else if (tagName === 'body') {
  1709. return [document.body];
  1710. } else if (tagName === 'canvas') {
  1711. return [_window__WEBPACK_IMPORTED_MODULE_0__["canvas"]];
  1712. }
  1713. return [];
  1714. },
  1715. getElementsByTagNameNS: function getElementsByTagNameNS(nameSpace, tagName) {
  1716. return this.getElementsByTagName(tagName);
  1717. },
  1718. getElementsByName: function getElementsByName(tagName) {
  1719. if (tagName === 'head') {
  1720. return [document.head];
  1721. } else if (tagName === 'body') {
  1722. return [document.body];
  1723. } else if (tagName === 'canvas') {
  1724. return [_window__WEBPACK_IMPORTED_MODULE_0__["canvas"]];
  1725. }
  1726. return [];
  1727. },
  1728. querySelector: function querySelector(query) {
  1729. if (query === 'head') {
  1730. return document.head;
  1731. } else if (query === 'body') {
  1732. return document.body;
  1733. } else if (query === 'canvas') {
  1734. return _window__WEBPACK_IMPORTED_MODULE_0__["canvas"];
  1735. } else if (query === '#' + _window__WEBPACK_IMPORTED_MODULE_0__["canvas"].id) {
  1736. return _window__WEBPACK_IMPORTED_MODULE_0__["canvas"];
  1737. }
  1738. return null;
  1739. },
  1740. querySelectorAll: function querySelectorAll(query) {
  1741. if (query === 'head') {
  1742. return [document.head];
  1743. } else if (query === 'body') {
  1744. return [document.body];
  1745. } else if (query === 'canvas') {
  1746. return [_window__WEBPACK_IMPORTED_MODULE_0__["canvas"]];
  1747. }
  1748. return [];
  1749. },
  1750. addEventListener: function addEventListener(type, listener) {
  1751. if (!events[type]) {
  1752. events[type] = [];
  1753. }
  1754. events[type].push(listener);
  1755. },
  1756. removeEventListener: function removeEventListener(type, listener) {
  1757. var listeners = events[type];
  1758. if (listeners && listeners.length > 0) {
  1759. for (var i = listeners.length; i--; i > 0) {
  1760. if (listeners[i] === listener) {
  1761. listeners.splice(i, 1);
  1762. break;
  1763. }
  1764. }
  1765. }
  1766. },
  1767. dispatchEvent: function dispatchEvent(event) {
  1768. var type = event.type;
  1769. var listeners = events[type];
  1770. if (listeners) {
  1771. for (var i = 0; i < listeners.length; i++) {
  1772. listeners[i](event);
  1773. }
  1774. }
  1775. if (event.target && typeof event.target['on' + type] === 'function') {
  1776. event.target['on' + type](event);
  1777. }
  1778. }
  1779. };
  1780. document.documentElement = new _DocumentElement__WEBPACK_IMPORTED_MODULE_7__["default"]();
  1781. document.head = new _HTMLElement__WEBPACK_IMPORTED_MODULE_2__["default"]('head');
  1782. document.body = new _Body__WEBPACK_IMPORTED_MODULE_8__["default"]();
  1783. function onVisibilityChange(visible) {
  1784. return function () {
  1785. document.visibilityState = visible ? 'visible' : 'hidden';
  1786. var hidden = !visible;
  1787. if (document.hidden === hidden) {
  1788. return;
  1789. }
  1790. document.hidden = hidden;
  1791. var event = new _Event__WEBPACK_IMPORTED_MODULE_1__["default"]('visibilitychange');
  1792. event.target = document;
  1793. event.timeStamp = Date.now();
  1794. document.dispatchEvent(event);
  1795. };
  1796. }
  1797. if (swan.onHide) {
  1798. swan.onHide(onVisibilityChange(false));
  1799. swan.onShow(onVisibilityChange(true));
  1800. }
  1801. /* harmony default export */ __webpack_exports__["default"] = (document);
  1802. /***/ }),
  1803. /***/ "./src/index.js":
  1804. /*!**********************!*\
  1805. !*** ./src/index.js ***!
  1806. \**********************/
  1807. /*! no exports provided */
  1808. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1809. "use strict";
  1810. __webpack_require__.r(__webpack_exports__);
  1811. /* harmony import */ var _window__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./window */ "./src/window.js");
  1812. /* harmony import */ var _document__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./document */ "./src/document.js");
  1813. /* harmony import */ var _util_isDevtool__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./util/isDevtool */ "./src/util/isDevtool.js");
  1814. /* eslint-disable */
  1815. // Avoid being static analyzed in webpack
  1816. var _window = _window__WEBPACK_IMPORTED_MODULE_0__;
  1817. var global = GameGlobal;
  1818. GameGlobal.global = GameGlobal.global || global;
  1819. function inject() {
  1820. _window.document = _document__WEBPACK_IMPORTED_MODULE_1__["default"];
  1821. _window.addEventListener = function (type, listener) {
  1822. _window.document.addEventListener(type, listener);
  1823. };
  1824. _window.removeEventListener = function (type, listener) {
  1825. _window.document.removeEventListener(type, listener);
  1826. };
  1827. _window.dispatchEvent = function () {
  1828. var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1829. console.log('window.dispatchEvent', event.type, event);
  1830. // nothing to do
  1831. };
  1832. if (Object(_util_isDevtool__WEBPACK_IMPORTED_MODULE_2__["default"])()) {
  1833. for (var key in _window) {
  1834. var descriptor = Object.getOwnPropertyDescriptor(global, key);
  1835. if (!descriptor || descriptor.configurable === true) {
  1836. Object.defineProperty(window, key, {
  1837. value: _window[key]
  1838. });
  1839. }
  1840. }
  1841. for (var _key in _window.document) {
  1842. var _descriptor = Object.getOwnPropertyDescriptor(global.document, _key);
  1843. if (!_descriptor || _descriptor.configurable === true) {
  1844. Object.defineProperty(global.document, _key, {
  1845. value: _window.document[_key]
  1846. });
  1847. }
  1848. }
  1849. window.parent = window;
  1850. } else {
  1851. for (var _key2 in _window) {
  1852. global[_key2] = _window[_key2];
  1853. }
  1854. global.window = global;
  1855. global.top = global.parent = global;
  1856. }
  1857. }
  1858. if (!GameGlobal.__isAdapterInjected) {
  1859. GameGlobal.__isAdapterInjected = true;
  1860. inject();
  1861. }
  1862. /***/ }),
  1863. /***/ "./src/localStorage.js":
  1864. /*!*****************************!*\
  1865. !*** ./src/localStorage.js ***!
  1866. \*****************************/
  1867. /*! exports provided: default */
  1868. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1869. "use strict";
  1870. __webpack_require__.r(__webpack_exports__);
  1871. /* eslint-disable */
  1872. var localStorage = {
  1873. get length() {
  1874. var _swan$getStorageInfoS = swan.getStorageInfoSync(),
  1875. keys = _swan$getStorageInfoS.keys;
  1876. return keys.length;
  1877. },
  1878. key: function key(n) {
  1879. var _swan$getStorageInfoS2 = swan.getStorageInfoSync(),
  1880. keys = _swan$getStorageInfoS2.keys;
  1881. return keys[n];
  1882. },
  1883. getItem: function getItem(key) {
  1884. var value = swan.getStorageSync(key);
  1885. return value === "" ? null : value;
  1886. },
  1887. setItem: function setItem(key, value) {
  1888. return swan.setStorageSync(key, value);
  1889. },
  1890. removeItem: function removeItem(key) {
  1891. swan.removeStorageSync(key);
  1892. },
  1893. clear: function clear() {
  1894. swan.clearStorageSync();
  1895. }
  1896. };
  1897. /* harmony default export */ __webpack_exports__["default"] = (localStorage);
  1898. /***/ }),
  1899. /***/ "./src/location.js":
  1900. /*!*************************!*\
  1901. !*** ./src/location.js ***!
  1902. \*************************/
  1903. /*! exports provided: default */
  1904. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1905. "use strict";
  1906. __webpack_require__.r(__webpack_exports__);
  1907. /* eslint-disable */
  1908. var location = {
  1909. href: 'game.js',
  1910. search: '',
  1911. hash: '',
  1912. reload: function reload() {},
  1913. replace: function replace(href) {
  1914. this.href = href;
  1915. }
  1916. };
  1917. /* harmony default export */ __webpack_exports__["default"] = (location);
  1918. /***/ }),
  1919. /***/ "./src/navigator.js":
  1920. /*!**************************!*\
  1921. !*** ./src/navigator.js ***!
  1922. \**************************/
  1923. /*! exports provided: default */
  1924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1925. "use strict";
  1926. __webpack_require__.r(__webpack_exports__);
  1927. /* harmony import */ var _util_index_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/index.js */ "./src/util/index.js");
  1928. /* eslint-disable */
  1929. // TODO 开放域下用 userAgent
  1930. var systemInfo = swan.getSystemInfoSync && swan.getSystemInfoSync();
  1931. var system = systemInfo && systemInfo.system || '';
  1932. var platform = systemInfo && systemInfo.platform || '';
  1933. var language = systemInfo && systemInfo.language || '"zh_CN"';
  1934. var android = system.toLowerCase().indexOf('android') !== -1;
  1935. var uaDesc = android ? 'Android; CPU Android 6.0' : 'iPhone; CPU iPhone OS 10_3_1 like Mac OS X';
  1936. var ua = 'Mozilla/5.0 (' + uaDesc + ') AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14E8301 MicroMessenger/6.6.0 SwanGame NetType/WIFI Language/' + language;
  1937. var navigator = {
  1938. platform: platform,
  1939. language: language,
  1940. appVersion: '5.0 (' + uaDesc + ') AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
  1941. userAgent: ua,
  1942. onLine: true, // TODO 用 swan.getNetworkStateChange 和 swan.onNetworkStateChange 来返回真实的状态
  1943. // TODO 用 swan.getLocation 来封装 geolocation
  1944. geolocation: {
  1945. getCurrentPosition: _util_index_js__WEBPACK_IMPORTED_MODULE_0__["noop"],
  1946. watchPosition: _util_index_js__WEBPACK_IMPORTED_MODULE_0__["noop"],
  1947. clearWatch: _util_index_js__WEBPACK_IMPORTED_MODULE_0__["noop"]
  1948. }
  1949. };
  1950. if (swan.onNetworkStatusChange) {
  1951. swan.onNetworkStatusChange(function (event) {
  1952. navigator.onLine = event.isConnected;
  1953. });
  1954. }
  1955. /* harmony default export */ __webpack_exports__["default"] = (navigator);
  1956. /***/ }),
  1957. /***/ "./src/performance.js":
  1958. /*!****************************!*\
  1959. !*** ./src/performance.js ***!
  1960. \****************************/
  1961. /*! exports provided: default */
  1962. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1963. "use strict";
  1964. __webpack_require__.r(__webpack_exports__);
  1965. /* harmony import */ var _util_isDevtool__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./util/isDevtool */ "./src/util/isDevtool.js");
  1966. /* eslint-disable */
  1967. var performance = void 0;
  1968. if (swan.getPerformance) {
  1969. var wxPerf = swan.getPerformance();
  1970. var initTime = wxPerf.now();
  1971. var clientPerfAdapter = Object.assign({}, wxPerf, {
  1972. now: function now() {
  1973. return (wxPerf.now() - initTime) / 1000;
  1974. }
  1975. });
  1976. performance = Object(_util_isDevtool__WEBPACK_IMPORTED_MODULE_0__["default"])() ? wxPerf : clientPerfAdapter;
  1977. }
  1978. /* harmony default export */ __webpack_exports__["default"] = (performance);
  1979. /***/ }),
  1980. /***/ "./src/style/CanvasComputedStyle.js":
  1981. /*!******************************************!*\
  1982. !*** ./src/style/CanvasComputedStyle.js ***!
  1983. \******************************************/
  1984. /*! exports provided: default */
  1985. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1986. "use strict";
  1987. __webpack_require__.r(__webpack_exports__);
  1988. /* harmony import */ var _CommonComputedStyle__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./CommonComputedStyle */ "./src/style/CommonComputedStyle.js");
  1989. /* eslint-disable */
  1990. function getCanvasComputedStyle(canvas) {
  1991. var rect = canvas.getBoundingClientRect();
  1992. var style = Object.assign(_CommonComputedStyle__WEBPACK_IMPORTED_MODULE_0__["default"], {
  1993. "display": "inline",
  1994. "position": "static",
  1995. "inlineSize": rect.width + "px",
  1996. "perspectiveOrigin": rect.width / 2 + "px " + rect.height / 2 + "px",
  1997. "transformOrigin": rect.width / 2 + "px " + rect.height / 2 + "px",
  1998. "webkitLogicalWidth": rect.width + "px",
  1999. "webkitLogicalHeight": rect.height + "px",
  2000. "width": rect.width + "px",
  2001. "height": rect.height + "px"
  2002. });
  2003. return style;
  2004. }
  2005. /* harmony default export */ __webpack_exports__["default"] = (getCanvasComputedStyle);
  2006. /***/ }),
  2007. /***/ "./src/style/CommonComputedStyle.js":
  2008. /*!******************************************!*\
  2009. !*** ./src/style/CommonComputedStyle.js ***!
  2010. \******************************************/
  2011. /*! exports provided: default */
  2012. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2013. "use strict";
  2014. __webpack_require__.r(__webpack_exports__);
  2015. /* eslint-disable */
  2016. var style = {
  2017. "0": "animation-delay",
  2018. "1": "animation-direction",
  2019. "2": "animation-duration",
  2020. "3": "animation-fill-mode",
  2021. "4": "animation-iteration-count",
  2022. "5": "animation-name",
  2023. "6": "animation-play-state",
  2024. "7": "animation-timing-function",
  2025. "8": "background-attachment",
  2026. "9": "background-blend-mode",
  2027. "10": "background-clip",
  2028. "11": "background-color",
  2029. "12": "background-image",
  2030. "13": "background-origin",
  2031. "14": "background-position",
  2032. "15": "background-repeat",
  2033. "16": "background-size",
  2034. "17": "border-bottom-color",
  2035. "18": "border-bottom-left-radius",
  2036. "19": "border-bottom-right-radius",
  2037. "20": "border-bottom-style",
  2038. "21": "border-bottom-width",
  2039. "22": "border-collapse",
  2040. "23": "border-image-outset",
  2041. "24": "border-image-repeat",
  2042. "25": "border-image-slice",
  2043. "26": "border-image-source",
  2044. "27": "border-image-width",
  2045. "28": "border-left-color",
  2046. "29": "border-left-style",
  2047. "30": "border-left-width",
  2048. "31": "border-right-color",
  2049. "32": "border-right-style",
  2050. "33": "border-right-width",
  2051. "34": "border-top-color",
  2052. "35": "border-top-left-radius",
  2053. "36": "border-top-right-radius",
  2054. "37": "border-top-style",
  2055. "38": "border-top-width",
  2056. "39": "bottom",
  2057. "40": "box-shadow",
  2058. "41": "box-sizing",
  2059. "42": "break-after",
  2060. "43": "break-before",
  2061. "44": "break-inside",
  2062. "45": "caption-side",
  2063. "46": "clear",
  2064. "47": "clip",
  2065. "48": "color",
  2066. "49": "content",
  2067. "50": "cursor",
  2068. "51": "direction",
  2069. "52": "display",
  2070. "53": "empty-cells",
  2071. "54": "float",
  2072. "55": "font-family",
  2073. "56": "font-kerning",
  2074. "57": "font-size",
  2075. "58": "font-stretch",
  2076. "59": "font-style",
  2077. "60": "font-variant",
  2078. "61": "font-variant-ligatures",
  2079. "62": "font-variant-caps",
  2080. "63": "font-variant-numeric",
  2081. "64": "font-variant-east-asian",
  2082. "65": "font-weight",
  2083. "66": "height",
  2084. "67": "image-rendering",
  2085. "68": "isolation",
  2086. "69": "justify-items",
  2087. "70": "justify-self",
  2088. "71": "left",
  2089. "72": "letter-spacing",
  2090. "73": "line-height",
  2091. "74": "list-style-image",
  2092. "75": "list-style-position",
  2093. "76": "list-style-type",
  2094. "77": "margin-bottom",
  2095. "78": "margin-left",
  2096. "79": "margin-right",
  2097. "80": "margin-top",
  2098. "81": "max-height",
  2099. "82": "max-width",
  2100. "83": "min-height",
  2101. "84": "min-width",
  2102. "85": "mix-blend-mode",
  2103. "86": "object-fit",
  2104. "87": "object-position",
  2105. "88": "offset-distance",
  2106. "89": "offset-path",
  2107. "90": "offset-rotate",
  2108. "91": "opacity",
  2109. "92": "orphans",
  2110. "93": "outline-color",
  2111. "94": "outline-offset",
  2112. "95": "outline-style",
  2113. "96": "outline-width",
  2114. "97": "overflow-anchor",
  2115. "98": "overflow-wrap",
  2116. "99": "overflow-x",
  2117. "100": "overflow-y",
  2118. "101": "padding-bottom",
  2119. "102": "padding-left",
  2120. "103": "padding-right",
  2121. "104": "padding-top",
  2122. "105": "pointer-events",
  2123. "106": "position",
  2124. "107": "resize",
  2125. "108": "right",
  2126. "109": "scroll-behavior",
  2127. "110": "speak",
  2128. "111": "table-layout",
  2129. "112": "tab-size",
  2130. "113": "text-align",
  2131. "114": "text-align-last",
  2132. "115": "text-decoration",
  2133. "116": "text-decoration-line",
  2134. "117": "text-decoration-style",
  2135. "118": "text-decoration-color",
  2136. "119": "text-decoration-skip-ink",
  2137. "120": "text-underline-position",
  2138. "121": "text-indent",
  2139. "122": "text-rendering",
  2140. "123": "text-shadow",
  2141. "124": "text-size-adjust",
  2142. "125": "text-overflow",
  2143. "126": "text-transform",
  2144. "127": "top",
  2145. "128": "touch-action",
  2146. "129": "transition-delay",
  2147. "130": "transition-duration",
  2148. "131": "transition-property",
  2149. "132": "transition-timing-function",
  2150. "133": "unicode-bidi",
  2151. "134": "vertical-align",
  2152. "135": "visibility",
  2153. "136": "white-space",
  2154. "137": "widows",
  2155. "138": "width",
  2156. "139": "will-change",
  2157. "140": "word-break",
  2158. "141": "word-spacing",
  2159. "142": "word-wrap",
  2160. "143": "z-index",
  2161. "144": "zoom",
  2162. "145": "-webkit-appearance",
  2163. "146": "backface-visibility",
  2164. "147": "-webkit-border-horizontal-spacing",
  2165. "148": "-webkit-border-image",
  2166. "149": "-webkit-border-vertical-spacing",
  2167. "150": "-webkit-box-align",
  2168. "151": "-webkit-box-decoration-break",
  2169. "152": "-webkit-box-direction",
  2170. "153": "-webkit-box-flex",
  2171. "154": "-webkit-box-flex-group",
  2172. "155": "-webkit-box-lines",
  2173. "156": "-webkit-box-ordinal-group",
  2174. "157": "-webkit-box-orient",
  2175. "158": "-webkit-box-pack",
  2176. "159": "-webkit-box-reflect",
  2177. "160": "column-count",
  2178. "161": "column-gap",
  2179. "162": "column-rule-color",
  2180. "163": "column-rule-style",
  2181. "164": "column-rule-width",
  2182. "165": "column-span",
  2183. "166": "column-width",
  2184. "167": "align-content",
  2185. "168": "align-items",
  2186. "169": "align-self",
  2187. "170": "flex-basis",
  2188. "171": "flex-grow",
  2189. "172": "flex-shrink",
  2190. "173": "flex-direction",
  2191. "174": "flex-wrap",
  2192. "175": "justify-content",
  2193. "176": "-webkit-font-smoothing",
  2194. "177": "grid-auto-columns",
  2195. "178": "grid-auto-flow",
  2196. "179": "grid-auto-rows",
  2197. "180": "grid-column-end",
  2198. "181": "grid-column-start",
  2199. "182": "grid-template-areas",
  2200. "183": "grid-template-columns",
  2201. "184": "grid-template-rows",
  2202. "185": "grid-row-end",
  2203. "186": "grid-row-start",
  2204. "187": "grid-column-gap",
  2205. "188": "grid-row-gap",
  2206. "189": "-webkit-highlight",
  2207. "190": "hyphens",
  2208. "191": "-webkit-hyphenate-character",
  2209. "192": "-webkit-line-break",
  2210. "193": "-webkit-line-clamp",
  2211. "194": "-webkit-locale",
  2212. "195": "-webkit-margin-before-collapse",
  2213. "196": "-webkit-margin-after-collapse",
  2214. "197": "-webkit-mask-box-image",
  2215. "198": "-webkit-mask-box-image-outset",
  2216. "199": "-webkit-mask-box-image-repeat",
  2217. "200": "-webkit-mask-box-image-slice",
  2218. "201": "-webkit-mask-box-image-source",
  2219. "202": "-webkit-mask-box-image-width",
  2220. "203": "-webkit-mask-clip",
  2221. "204": "-webkit-mask-composite",
  2222. "205": "-webkit-mask-image",
  2223. "206": "-webkit-mask-origin",
  2224. "207": "-webkit-mask-position",
  2225. "208": "-webkit-mask-repeat",
  2226. "209": "-webkit-mask-size",
  2227. "210": "order",
  2228. "211": "perspective",
  2229. "212": "perspective-origin",
  2230. "213": "-webkit-print-color-adjust",
  2231. "214": "-webkit-rtl-ordering",
  2232. "215": "shape-outside",
  2233. "216": "shape-image-threshold",
  2234. "217": "shape-margin",
  2235. "218": "-webkit-tap-highlight-color",
  2236. "219": "-webkit-text-combine",
  2237. "220": "-webkit-text-decorations-in-effect",
  2238. "221": "-webkit-text-emphasis-color",
  2239. "222": "-webkit-text-emphasis-position",
  2240. "223": "-webkit-text-emphasis-style",
  2241. "224": "-webkit-text-fill-color",
  2242. "225": "-webkit-text-orientation",
  2243. "226": "-webkit-text-security",
  2244. "227": "-webkit-text-stroke-color",
  2245. "228": "-webkit-text-stroke-width",
  2246. "229": "transform",
  2247. "230": "transform-origin",
  2248. "231": "transform-style",
  2249. "232": "-webkit-user-drag",
  2250. "233": "-webkit-user-modify",
  2251. "234": "user-select",
  2252. "235": "-webkit-writing-mode",
  2253. "236": "-webkit-app-region",
  2254. "237": "buffered-rendering",
  2255. "238": "clip-path",
  2256. "239": "clip-rule",
  2257. "240": "mask",
  2258. "241": "filter",
  2259. "242": "flood-color",
  2260. "243": "flood-opacity",
  2261. "244": "lighting-color",
  2262. "245": "stop-color",
  2263. "246": "stop-opacity",
  2264. "247": "color-interpolation",
  2265. "248": "color-interpolation-filters",
  2266. "249": "color-rendering",
  2267. "250": "fill",
  2268. "251": "fill-opacity",
  2269. "252": "fill-rule",
  2270. "253": "marker-end",
  2271. "254": "marker-mid",
  2272. "255": "marker-start",
  2273. "256": "mask-type",
  2274. "257": "shape-rendering",
  2275. "258": "stroke",
  2276. "259": "stroke-dasharray",
  2277. "260": "stroke-dashoffset",
  2278. "261": "stroke-linecap",
  2279. "262": "stroke-linejoin",
  2280. "263": "stroke-miterlimit",
  2281. "264": "stroke-opacity",
  2282. "265": "stroke-width",
  2283. "266": "alignment-baseline",
  2284. "267": "baseline-shift",
  2285. "268": "dominant-baseline",
  2286. "269": "text-anchor",
  2287. "270": "writing-mode",
  2288. "271": "vector-effect",
  2289. "272": "paint-order",
  2290. "273": "d",
  2291. "274": "cx",
  2292. "275": "cy",
  2293. "276": "x",
  2294. "277": "y",
  2295. "278": "r",
  2296. "279": "rx",
  2297. "280": "ry",
  2298. "281": "caret-color",
  2299. "282": "line-break",
  2300. "display": "inline",
  2301. "dominantBaseline": "auto",
  2302. "emptyCells": "show",
  2303. "fill": "rgb(0, 0, 0)",
  2304. "fillOpacity": "1",
  2305. "fillRule": "nonzero",
  2306. "filter": "none",
  2307. "flex": "0 1 auto",
  2308. "flexBasis": "auto",
  2309. "flexDirection": "row",
  2310. "flexFlow": "row nowrap",
  2311. "flexGrow": "0",
  2312. "flexShrink": "1",
  2313. "flexWrap": "nowrap",
  2314. "float": "none",
  2315. "floodColor": "rgb(0, 0, 0)",
  2316. "floodOpacity": "1",
  2317. "font": "normal normal 400 normal 16px / normal \"PingFang SC\"",
  2318. "fontDisplay": "",
  2319. "fontFamily": "\"PingFang SC\"",
  2320. "fontFeatureSettings": "normal",
  2321. "fontKerning": "auto",
  2322. "fontSize": "16px",
  2323. "fontStretch": "100%",
  2324. "fontStyle": "normal",
  2325. "fontVariant": "normal",
  2326. "fontVariantCaps": "normal",
  2327. "fontVariantEastAsian": "normal",
  2328. "fontVariantLigatures": "normal",
  2329. "fontVariantNumeric": "normal",
  2330. "fontVariationSettings": "normal",
  2331. "fontWeight": "400",
  2332. "grid": "none / none / none / row / auto / auto",
  2333. "gridArea": "auto / auto / auto / auto",
  2334. "gridAutoColumns": "auto",
  2335. "gridAutoFlow": "row",
  2336. "gridAutoRows": "auto",
  2337. "gridColumn": "auto / auto",
  2338. "gridColumnEnd": "auto",
  2339. "gridColumnGap": "0px",
  2340. "gridColumnStart": "auto",
  2341. "gridGap": "0px 0px",
  2342. "gridRow": "auto / auto",
  2343. "gridRowEnd": "auto",
  2344. "gridRowGap": "0px",
  2345. "gridRowStart": "auto",
  2346. "gridTemplate": "none / none / none",
  2347. "gridTemplateAreas": "none",
  2348. "gridTemplateColumns": "none",
  2349. "gridTemplateRows": "none",
  2350. "height": "0px",
  2351. "hyphens": "manual",
  2352. "imageRendering": "auto",
  2353. "inlineSize": "0px",
  2354. "isolation": "auto",
  2355. "justifyContent": "normal",
  2356. "justifyItems": "normal",
  2357. "justifySelf": "auto",
  2358. "left": "auto",
  2359. "letterSpacing": "normal",
  2360. "lightingColor": "rgb(255, 255, 255)",
  2361. "lineBreak": "auto",
  2362. "lineHeight": "normal",
  2363. "listStyle": "disc outside none",
  2364. "listStyleImage": "none",
  2365. "listStylePosition": "outside",
  2366. "listStyleType": "disc",
  2367. "margin": "0px",
  2368. "marginBottom": "0px",
  2369. "marginLeft": "0px",
  2370. "marginRight": "0px",
  2371. "marginTop": "0px",
  2372. "marker": "",
  2373. "markerEnd": "none",
  2374. "markerMid": "none",
  2375. "markerStart": "none",
  2376. "mask": "none",
  2377. "maskType": "luminance",
  2378. "maxBlockSize": "none",
  2379. "maxHeight": "none",
  2380. "maxInlineSize": "none",
  2381. "maxWidth": "none",
  2382. "maxZoom": "",
  2383. "minBlockSize": "0px",
  2384. "minHeight": "0px",
  2385. "minInlineSize": "0px",
  2386. "minWidth": "0px",
  2387. "minZoom": "",
  2388. "mixBlendMode": "normal",
  2389. "objectFit": "fill",
  2390. "objectPosition": "50% 50%",
  2391. "offset": "none 0px auto 0deg",
  2392. "offsetDistance": "0px",
  2393. "offsetPath": "none",
  2394. "offsetRotate": "auto 0deg",
  2395. "opacity": "1",
  2396. "order": "0",
  2397. "orientation": "",
  2398. "orphans": "2",
  2399. "outline": "rgb(0, 0, 0) none 0px",
  2400. "outlineColor": "rgb(0, 0, 0)",
  2401. "outlineOffset": "0px",
  2402. "outlineStyle": "none",
  2403. "outlineWidth": "0px",
  2404. "overflow": "visible",
  2405. "overflowAnchor": "auto",
  2406. "overflowWrap": "normal",
  2407. "overflowX": "visible",
  2408. "overflowY": "visible",
  2409. "overscrollBehavior": "auto auto",
  2410. "overscrollBehaviorX": "auto",
  2411. "overscrollBehaviorY": "auto",
  2412. "padding": "0px",
  2413. "paddingBottom": "0px",
  2414. "paddingLeft": "0px",
  2415. "paddingRight": "0px",
  2416. "paddingTop": "0px",
  2417. "page": "",
  2418. "pageBreakAfter": "auto",
  2419. "pageBreakBefore": "auto",
  2420. "pageBreakInside": "auto",
  2421. "paintOrder": "fill stroke markers",
  2422. "perspective": "none",
  2423. "perspectiveOrigin": "0px 0px",
  2424. "placeContent": "normal normal",
  2425. "placeItems": "normal normal",
  2426. "placeSelf": "auto auto",
  2427. "pointerEvents": "auto",
  2428. "position": "static",
  2429. "quotes": "",
  2430. "r": "0px",
  2431. "resize": "none",
  2432. "right": "auto",
  2433. "rx": "auto",
  2434. "ry": "auto",
  2435. "scrollBehavior": "auto",
  2436. "shapeImageThreshold": "0",
  2437. "shapeMargin": "0px",
  2438. "shapeOutside": "none",
  2439. "shapeRendering": "auto",
  2440. "size": "",
  2441. "speak": "normal",
  2442. "src": "",
  2443. "stopColor": "rgb(0, 0, 0)",
  2444. "stopOpacity": "1",
  2445. "stroke": "none",
  2446. "strokeDasharray": "none",
  2447. "strokeDashoffset": "0px",
  2448. "strokeLinecap": "butt",
  2449. "strokeLinejoin": "miter",
  2450. "strokeMiterlimit": "4",
  2451. "strokeOpacity": "1",
  2452. "strokeWidth": "1px",
  2453. "tabSize": "8",
  2454. "tableLayout": "auto",
  2455. "textAlign": "start",
  2456. "textAlignLast": "auto",
  2457. "textAnchor": "start",
  2458. "textCombineUpright": "none",
  2459. "textDecoration": "none solid rgb(0, 0, 0)",
  2460. "textDecorationColor": "rgb(0, 0, 0)",
  2461. "textDecorationLine": "none",
  2462. "textDecorationSkipInk": "auto",
  2463. "textDecorationStyle": "solid",
  2464. "textIndent": "0px",
  2465. "textOrientation": "mixed",
  2466. "textOverflow": "clip",
  2467. "textRendering": "auto",
  2468. "textShadow": "none",
  2469. "textSizeAdjust": "auto",
  2470. "textTransform": "none",
  2471. "textUnderlinePosition": "auto",
  2472. "top": "auto",
  2473. "touchAction": "auto",
  2474. "transform": "none",
  2475. "transformBox": "view-box",
  2476. "transformOrigin": "0px 0px",
  2477. "transformStyle": "flat",
  2478. "transition": "all 0s ease 0s",
  2479. "transitionDelay": "0s",
  2480. "transitionDuration": "0s",
  2481. "transitionProperty": "all",
  2482. "transitionTimingFunction": "ease",
  2483. "unicodeBidi": "normal",
  2484. "unicodeRange": "",
  2485. "userSelect": "auto",
  2486. "userZoom": "",
  2487. "vectorEffect": "none",
  2488. "verticalAlign": "baseline",
  2489. "visibility": "visible",
  2490. "webkitAppRegion": "no-drag",
  2491. "webkitAppearance": "none",
  2492. "webkitBorderAfter": "0px none rgb(0, 0, 0)",
  2493. "webkitBorderAfterColor": "rgb(0, 0, 0)",
  2494. "webkitBorderAfterStyle": "none",
  2495. "webkitBorderAfterWidth": "0px",
  2496. "webkitBorderBefore": "0px none rgb(0, 0, 0)",
  2497. "webkitBorderBeforeColor": "rgb(0, 0, 0)",
  2498. "webkitBorderBeforeStyle": "none",
  2499. "webkitBorderBeforeWidth": "0px",
  2500. "webkitBorderEnd": "0px none rgb(0, 0, 0)",
  2501. "webkitBorderEndColor": "rgb(0, 0, 0)",
  2502. "webkitBorderEndStyle": "none",
  2503. "webkitBorderEndWidth": "0px",
  2504. "webkitBorderHorizontalSpacing": "0px",
  2505. "webkitBorderImage": "none",
  2506. "webkitBorderStart": "0px none rgb(0, 0, 0)",
  2507. "webkitBorderStartColor": "rgb(0, 0, 0)",
  2508. "webkitBorderStartStyle": "none",
  2509. "webkitBorderStartWidth": "0px",
  2510. "webkitBorderVerticalSpacing": "0px",
  2511. "webkitBoxAlign": "stretch",
  2512. "webkitBoxDecorationBreak": "slice",
  2513. "webkitBoxDirection": "normal",
  2514. "webkitBoxFlex": "0",
  2515. "webkitBoxFlexGroup": "1",
  2516. "webkitBoxLines": "single",
  2517. "webkitBoxOrdinalGroup": "1",
  2518. "webkitBoxOrient": "horizontal",
  2519. "webkitBoxPack": "start",
  2520. "webkitBoxReflect": "none",
  2521. "webkitColumnBreakAfter": "auto",
  2522. "webkitColumnBreakBefore": "auto",
  2523. "webkitColumnBreakInside": "auto",
  2524. "webkitFontSizeDelta": "",
  2525. "webkitFontSmoothing": "auto",
  2526. "webkitHighlight": "none",
  2527. "webkitHyphenateCharacter": "auto",
  2528. "webkitLineBreak": "auto",
  2529. "webkitLineClamp": "none",
  2530. "webkitLocale": "auto",
  2531. "webkitLogicalHeight": "0px",
  2532. "webkitLogicalWidth": "0px",
  2533. "webkitMarginAfter": "0px",
  2534. "webkitMarginAfterCollapse": "collapse",
  2535. "webkitMarginBefore": "0px",
  2536. "webkitMarginBeforeCollapse": "collapse",
  2537. "webkitMarginBottomCollapse": "collapse",
  2538. "webkitMarginCollapse": "",
  2539. "webkitMarginEnd": "0px",
  2540. "webkitMarginStart": "0px",
  2541. "webkitMarginTopCollapse": "collapse",
  2542. "webkitMask": "",
  2543. "webkitMaskBoxImage": "none",
  2544. "webkitMaskBoxImageOutset": "0px",
  2545. "webkitMaskBoxImageRepeat": "stretch",
  2546. "webkitMaskBoxImageSlice": "0 fill",
  2547. "webkitMaskBoxImageSource": "none",
  2548. "webkitMaskBoxImageWidth": "auto",
  2549. "webkitMaskClip": "border-box",
  2550. "webkitMaskComposite": "source-over",
  2551. "webkitMaskImage": "none",
  2552. "webkitMaskOrigin": "border-box",
  2553. "webkitMaskPosition": "0% 0%",
  2554. "webkitMaskPositionX": "0%",
  2555. "webkitMaskPositionY": "0%",
  2556. "webkitMaskRepeat": "repeat",
  2557. "webkitMaskRepeatX": "",
  2558. "webkitMaskRepeatY": "",
  2559. "webkitMaskSize": "auto",
  2560. "webkitMaxLogicalHeight": "none",
  2561. "webkitMaxLogicalWidth": "none",
  2562. "webkitMinLogicalHeight": "0px",
  2563. "webkitMinLogicalWidth": "0px",
  2564. "webkitPaddingAfter": "0px",
  2565. "webkitPaddingBefore": "0px",
  2566. "webkitPaddingEnd": "0px",
  2567. "webkitPaddingStart": "0px",
  2568. "webkitPerspectiveOriginX": "",
  2569. "webkitPerspectiveOriginY": "",
  2570. "webkitPrintColorAdjust": "economy",
  2571. "webkitRtlOrdering": "logical",
  2572. "webkitRubyPosition": "before",
  2573. "webkitTapHighlightColor": "rgba(0, 0, 0, 0.4)",
  2574. "webkitTextCombine": "none",
  2575. "webkitTextDecorationsInEffect": "none",
  2576. "webkitTextEmphasis": "",
  2577. "webkitTextEmphasisColor": "rgb(0, 0, 0)",
  2578. "webkitTextEmphasisPosition": "over right",
  2579. "webkitTextEmphasisStyle": "none",
  2580. "webkitTextFillColor": "rgb(0, 0, 0)",
  2581. "webkitTextOrientation": "vertical-right",
  2582. "webkitTextSecurity": "none",
  2583. "webkitTextStroke": "",
  2584. "webkitTextStrokeColor": "rgb(0, 0, 0)",
  2585. "webkitTextStrokeWidth": "0px",
  2586. "webkitTransformOriginX": "",
  2587. "webkitTransformOriginY": "",
  2588. "webkitTransformOriginZ": "",
  2589. "webkitUserDrag": "auto",
  2590. "webkitUserModify": "read-only",
  2591. "webkitWritingMode": "horizontal-tb",
  2592. "whiteSpace": "normal",
  2593. "widows": "2",
  2594. "width": "0px",
  2595. "willChange": "auto",
  2596. "wordBreak": "normal",
  2597. "wordSpacing": "0px",
  2598. "wordWrap": "normal",
  2599. "writingMode": "horizontal-tb",
  2600. "x": "0px",
  2601. "y": "0px",
  2602. "zIndex": "auto",
  2603. "zoom": "1"
  2604. };
  2605. /* harmony default export */ __webpack_exports__["default"] = (style);
  2606. /***/ }),
  2607. /***/ "./src/style/ImageComputedStyle.js":
  2608. /*!*****************************************!*\
  2609. !*** ./src/style/ImageComputedStyle.js ***!
  2610. \*****************************************/
  2611. /*! exports provided: default */
  2612. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2613. "use strict";
  2614. __webpack_require__.r(__webpack_exports__);
  2615. /* harmony import */ var _CommonComputedStyle__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./CommonComputedStyle */ "./src/style/CommonComputedStyle.js");
  2616. /* eslint-disable */
  2617. function getImageComputedStyle(image) {
  2618. var width = image.width;
  2619. var height = image.height;
  2620. var style = Object.assign(_CommonComputedStyle__WEBPACK_IMPORTED_MODULE_0__["default"], {
  2621. "display": "inline",
  2622. "position": "static",
  2623. "inlineSize": width + "px",
  2624. "perspectiveOrigin": width / 2 + "px " + height / 2 + "px",
  2625. "transformOrigin": width / 2 + "px " + height / 2 + "px",
  2626. "webkitLogicalWidth": width + "px",
  2627. "webkitLogicalHeight": height + "px",
  2628. "width": width + "px",
  2629. "height": height + "px"
  2630. });
  2631. return style;
  2632. }
  2633. /* harmony default export */ __webpack_exports__["default"] = (getImageComputedStyle);
  2634. /***/ }),
  2635. /***/ "./src/util/index.js":
  2636. /*!***************************!*\
  2637. !*** ./src/util/index.js ***!
  2638. \***************************/
  2639. /*! exports provided: noop */
  2640. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2641. "use strict";
  2642. __webpack_require__.r(__webpack_exports__);
  2643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noop", function() { return noop; });
  2644. /* eslint-disable */
  2645. function noop() {}
  2646. /***/ }),
  2647. /***/ "./src/util/isDevtool.js":
  2648. /*!*******************************!*\
  2649. !*** ./src/util/isDevtool.js ***!
  2650. \*******************************/
  2651. /*! exports provided: default */
  2652. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2653. "use strict";
  2654. __webpack_require__.r(__webpack_exports__);
  2655. /* WEBPACK VAR INJECTION */(function(global) {/* eslint-disable */
  2656. var isDevtool = false;
  2657. if (swan.getSystemInfoSync) {
  2658. var _swan$getSystemInfoSy = swan.getSystemInfoSync(),
  2659. platform = _swan$getSystemInfoSy.platform;
  2660. isDevtool = platform === 'devtools';
  2661. } else {
  2662. var descriptor = Object.getOwnPropertyDescriptor(global, 'window');
  2663. // 开发者工具无法重定义 window
  2664. isDevtool = !(!descriptor || descriptor.configurable === true);
  2665. }
  2666. /* harmony default export */ __webpack_exports__["default"] = (function () {
  2667. return isDevtool;
  2668. });
  2669. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  2670. /***/ }),
  2671. /***/ "./src/util/mixin.js":
  2672. /*!***************************!*\
  2673. !*** ./src/util/mixin.js ***!
  2674. \***************************/
  2675. /*! exports provided: parentNode, style, clientRegion, offsetRegion, scrollRegion, classList */
  2676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2677. "use strict";
  2678. __webpack_require__.r(__webpack_exports__);
  2679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parentNode", function() { return parentNode; });
  2680. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "style", function() { return style; });
  2681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clientRegion", function() { return clientRegion; });
  2682. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "offsetRegion", function() { return offsetRegion; });
  2683. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scrollRegion", function() { return scrollRegion; });
  2684. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "classList", function() { return classList; });
  2685. /* harmony import */ var _WindowProperties__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../WindowProperties */ "./src/WindowProperties.js");
  2686. /* eslint-disable */
  2687. function parentNode(obj, level) {
  2688. if (!('parentNode' in obj)) {
  2689. var _parent = void 0;
  2690. if (level === 0) {
  2691. _parent = function _parent() {
  2692. // return document
  2693. return null;
  2694. };
  2695. } else if (level === 1) {
  2696. _parent = function _parent() {
  2697. return document.documentElement;
  2698. };
  2699. } else {
  2700. _parent = function _parent() {
  2701. return document.body;
  2702. };
  2703. }
  2704. Object.defineProperty(obj, 'parentNode', {
  2705. enumerable: true,
  2706. get: _parent
  2707. });
  2708. }
  2709. if (!('parentElement' in obj)) {
  2710. var _parent2 = void 0;
  2711. if (level === 0) {
  2712. _parent2 = function _parent2() {
  2713. return null;
  2714. };
  2715. } else if (level === 1) {
  2716. _parent2 = function _parent2() {
  2717. return document.documentElement;
  2718. };
  2719. } else {
  2720. _parent2 = function _parent2() {
  2721. return document.body;
  2722. };
  2723. }
  2724. Object.defineProperty(obj, 'parentElement', {
  2725. enumerable: true,
  2726. get: _parent2
  2727. });
  2728. }
  2729. }
  2730. function style(obj) {
  2731. obj.style = obj.style || {};
  2732. Object.assign(obj.style, {
  2733. top: '0px',
  2734. left: '0px',
  2735. width: _WindowProperties__WEBPACK_IMPORTED_MODULE_0__["innerWidth"] + 'px',
  2736. height: _WindowProperties__WEBPACK_IMPORTED_MODULE_0__["innerHeight"] + 'px',
  2737. margin: '0px',
  2738. padding: '0px',
  2739. removeProperty: function removeProperty() {},
  2740. setProperty: function setProperty() {}
  2741. });
  2742. }
  2743. function clientRegion(obj) {
  2744. if (!('clientLeft' in obj)) {
  2745. obj.clientLeft = 0;
  2746. obj.clientTop = 0;
  2747. }
  2748. if (!('clientWidth' in obj)) {
  2749. obj.clientWidth = _WindowProperties__WEBPACK_IMPORTED_MODULE_0__["innerWidth"];
  2750. obj.clientHeight = _WindowProperties__WEBPACK_IMPORTED_MODULE_0__["innerHeight"];
  2751. }
  2752. if (!('getBoundingClientRect' in obj)) {
  2753. obj.getBoundingClientRect = function () {
  2754. var ret = {
  2755. x: 0,
  2756. y: 0,
  2757. top: 0,
  2758. left: 0,
  2759. width: this.clientWidth,
  2760. height: this.clientHeight
  2761. };
  2762. ret.right = ret.width;
  2763. ret.bottom = ret.height;
  2764. return ret;
  2765. };
  2766. }
  2767. }
  2768. function offsetRegion(obj) {
  2769. if (!('offsetLeft' in obj)) {
  2770. obj.offsetLeft = 0;
  2771. obj.offsetTop = 0;
  2772. }
  2773. if (!('offsetWidth' in obj)) {
  2774. obj.offsetWidth = _WindowProperties__WEBPACK_IMPORTED_MODULE_0__["innerWidth"];
  2775. obj.offsetHeight = _WindowProperties__WEBPACK_IMPORTED_MODULE_0__["innerHeight"];
  2776. }
  2777. }
  2778. function scrollRegion(obj) {
  2779. if (!('scrollLeft' in obj)) {
  2780. obj.scrollLeft = 0;
  2781. obj.scrollTop = 0;
  2782. }
  2783. if (!('scrollWidth' in obj)) {
  2784. obj.scrollWidth = _WindowProperties__WEBPACK_IMPORTED_MODULE_0__["innerWidth"];
  2785. obj.scrollHeight = _WindowProperties__WEBPACK_IMPORTED_MODULE_0__["innerHeight"];
  2786. }
  2787. }
  2788. function classList(obj) {
  2789. var noop = function noop() {};
  2790. obj.classList = [];
  2791. obj.classList.add = noop;
  2792. obj.classList.remove = noop;
  2793. obj.classList.contains = noop;
  2794. obj.classList.toggle = noop;
  2795. }
  2796. /***/ }),
  2797. /***/ "./src/window.js":
  2798. /*!***********************!*\
  2799. !*** ./src/window.js ***!
  2800. \***********************/
  2801. /*! exports provided: navigator, XMLHttpRequest, WebSocket, Worker, Image, ImageBitmap, Audio, FileReader, HTMLElement, HTMLImageElement, HTMLCanvasElement, HTMLMediaElement, HTMLAudioElement, HTMLVideoElement, WebGLRenderingContext, TouchEvent, PointerEvent, MouseEvent, localStorage, location, btoa, atob, canvas, alert, focus, blur, getComputedStyle, scrollTo, scrollBy, setTimeout, clearTimeout, setInterval, clearInterval, requestAnimationFrame, cancelAnimationFrame, innerWidth, innerHeight, devicePixelRatio, screen, scrollX, scrollY, ontouchstart, ontouchmove, ontouchend, performance */
  2802. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2803. "use strict";
  2804. __webpack_require__.r(__webpack_exports__);
  2805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "canvas", function() { return canvas; });
  2806. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "alert", function() { return alert; });
  2807. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "focus", function() { return focus; });
  2808. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blur", function() { return blur; });
  2809. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getComputedStyle", function() { return getComputedStyle; });
  2810. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scrollTo", function() { return scrollTo; });
  2811. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scrollBy", function() { return scrollBy; });
  2812. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setTimeout", function() { return _setTimeout; });
  2813. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clearTimeout", function() { return _clearTimeout; });
  2814. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setInterval", function() { return _setInterval; });
  2815. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clearInterval", function() { return _clearInterval; });
  2816. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "requestAnimationFrame", function() { return _requestAnimationFrame; });
  2817. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cancelAnimationFrame", function() { return _cancelAnimationFrame; });
  2818. /* harmony import */ var _Canvas__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Canvas */ "./src/Canvas.js");
  2819. /* harmony import */ var _style_CommonComputedStyle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./style/CommonComputedStyle */ "./src/style/CommonComputedStyle.js");
  2820. /* harmony import */ var _style_ImageComputedStyle__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./style/ImageComputedStyle */ "./src/style/ImageComputedStyle.js");
  2821. /* harmony import */ var _style_CanvasComputedStyle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./style/CanvasComputedStyle */ "./src/style/CanvasComputedStyle.js");
  2822. /* harmony import */ var _Event__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Event */ "./src/Event.js");
  2823. /* harmony import */ var _util_isDevtool__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./util/isDevtool */ "./src/util/isDevtool.js");
  2824. /* harmony import */ var _navigator__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./navigator */ "./src/navigator.js");
  2825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "navigator", function() { return _navigator__WEBPACK_IMPORTED_MODULE_6__["default"]; });
  2826. /* harmony import */ var _XMLHttpRequest__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./XMLHttpRequest */ "./src/XMLHttpRequest.js");
  2827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "XMLHttpRequest", function() { return _XMLHttpRequest__WEBPACK_IMPORTED_MODULE_7__["default"]; });
  2828. /* harmony import */ var _WebSocket__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./WebSocket */ "./src/WebSocket.js");
  2829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebSocket", function() { return _WebSocket__WEBPACK_IMPORTED_MODULE_8__["default"]; });
  2830. /* harmony import */ var _Worker__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Worker */ "./src/Worker.js");
  2831. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Worker", function() { return _Worker__WEBPACK_IMPORTED_MODULE_9__["default"]; });
  2832. /* harmony import */ var _Image__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Image */ "./src/Image.js");
  2833. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _Image__WEBPACK_IMPORTED_MODULE_10__["default"]; });
  2834. /* harmony import */ var _ImageBitmap__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ImageBitmap */ "./src/ImageBitmap.js");
  2835. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageBitmap", function() { return _ImageBitmap__WEBPACK_IMPORTED_MODULE_11__["default"]; });
  2836. /* harmony import */ var _Audio__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Audio */ "./src/Audio.js");
  2837. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Audio", function() { return _Audio__WEBPACK_IMPORTED_MODULE_12__["default"]; });
  2838. /* harmony import */ var _FileReader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./FileReader */ "./src/FileReader.js");
  2839. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FileReader", function() { return _FileReader__WEBPACK_IMPORTED_MODULE_13__["default"]; });
  2840. /* harmony import */ var _HTMLElement__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./HTMLElement */ "./src/HTMLElement.js");
  2841. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HTMLElement", function() { return _HTMLElement__WEBPACK_IMPORTED_MODULE_14__["default"]; });
  2842. /* harmony import */ var _HTMLImageElement__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./HTMLImageElement */ "./src/HTMLImageElement.js");
  2843. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HTMLImageElement", function() { return _HTMLImageElement__WEBPACK_IMPORTED_MODULE_15__["default"]; });
  2844. /* harmony import */ var _HTMLCanvasElement__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./HTMLCanvasElement */ "./src/HTMLCanvasElement.js");
  2845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HTMLCanvasElement", function() { return _HTMLCanvasElement__WEBPACK_IMPORTED_MODULE_16__["default"]; });
  2846. /* harmony import */ var _HTMLMediaElement__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./HTMLMediaElement */ "./src/HTMLMediaElement.js");
  2847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HTMLMediaElement", function() { return _HTMLMediaElement__WEBPACK_IMPORTED_MODULE_17__["default"]; });
  2848. /* harmony import */ var _HTMLAudioElement__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./HTMLAudioElement */ "./src/HTMLAudioElement.js");
  2849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HTMLAudioElement", function() { return _HTMLAudioElement__WEBPACK_IMPORTED_MODULE_18__["default"]; });
  2850. /* harmony import */ var _HTMLVideoElement__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./HTMLVideoElement */ "./src/HTMLVideoElement.js");
  2851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HTMLVideoElement", function() { return _HTMLVideoElement__WEBPACK_IMPORTED_MODULE_19__["default"]; });
  2852. /* harmony import */ var _WebGLRenderingContext__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./WebGLRenderingContext */ "./src/WebGLRenderingContext.js");
  2853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebGLRenderingContext", function() { return _WebGLRenderingContext__WEBPACK_IMPORTED_MODULE_20__["default"]; });
  2854. /* harmony import */ var _EventIniter_index_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./EventIniter/index.js */ "./src/EventIniter/index.js");
  2855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchEvent", function() { return _EventIniter_index_js__WEBPACK_IMPORTED_MODULE_21__["TouchEvent"]; });
  2856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEvent", function() { return _EventIniter_index_js__WEBPACK_IMPORTED_MODULE_21__["PointerEvent"]; });
  2857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MouseEvent", function() { return _EventIniter_index_js__WEBPACK_IMPORTED_MODULE_21__["MouseEvent"]; });
  2858. /* harmony import */ var _localStorage__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./localStorage */ "./src/localStorage.js");
  2859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "localStorage", function() { return _localStorage__WEBPACK_IMPORTED_MODULE_22__["default"]; });
  2860. /* harmony import */ var _location__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./location */ "./src/location.js");
  2861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "location", function() { return _location__WEBPACK_IMPORTED_MODULE_23__["default"]; });
  2862. /* harmony import */ var _Base64_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Base64.js */ "./src/Base64.js");
  2863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "btoa", function() { return _Base64_js__WEBPACK_IMPORTED_MODULE_24__["btoa"]; });
  2864. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "atob", function() { return _Base64_js__WEBPACK_IMPORTED_MODULE_24__["atob"]; });
  2865. /* harmony import */ var _WindowProperties__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./WindowProperties */ "./src/WindowProperties.js");
  2866. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "innerWidth", function() { return _WindowProperties__WEBPACK_IMPORTED_MODULE_25__["innerWidth"]; });
  2867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "innerHeight", function() { return _WindowProperties__WEBPACK_IMPORTED_MODULE_25__["innerHeight"]; });
  2868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "devicePixelRatio", function() { return _WindowProperties__WEBPACK_IMPORTED_MODULE_25__["devicePixelRatio"]; });
  2869. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "screen", function() { return _WindowProperties__WEBPACK_IMPORTED_MODULE_25__["screen"]; });
  2870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "scrollX", function() { return _WindowProperties__WEBPACK_IMPORTED_MODULE_25__["scrollX"]; });
  2871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "scrollY", function() { return _WindowProperties__WEBPACK_IMPORTED_MODULE_25__["scrollY"]; });
  2872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ontouchstart", function() { return _WindowProperties__WEBPACK_IMPORTED_MODULE_25__["ontouchstart"]; });
  2873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ontouchmove", function() { return _WindowProperties__WEBPACK_IMPORTED_MODULE_25__["ontouchmove"]; });
  2874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ontouchend", function() { return _WindowProperties__WEBPACK_IMPORTED_MODULE_25__["ontouchend"]; });
  2875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "performance", function() { return _WindowProperties__WEBPACK_IMPORTED_MODULE_25__["performance"]; });
  2876. /* eslint-disable */
  2877. // 暴露全局的 canvas
  2878. GameGlobal.screencanvas = GameGlobal.screencanvas || new _Canvas__WEBPACK_IMPORTED_MODULE_0__["default"]();
  2879. var canvas = GameGlobal.screencanvas;
  2880. function getComputedStyle(dom) {
  2881. var tagName = dom.tagName;
  2882. if (tagName === "CANVAS") {
  2883. return Object(_style_CanvasComputedStyle__WEBPACK_IMPORTED_MODULE_3__["default"])(dom);
  2884. } else if (tagName === "IMG") {
  2885. return Object(_style_ImageComputedStyle__WEBPACK_IMPORTED_MODULE_2__["default"])(dom);
  2886. }
  2887. return _style_CommonComputedStyle__WEBPACK_IMPORTED_MODULE_1__["default"];
  2888. }
  2889. function scrollTo(x, y) {
  2890. // x = Math.min(window.innerWidth, Math.max(0, x));
  2891. // y = Math.min(window.innerHeight, Math.max(0, y));
  2892. // We can't scroll the page of WeChatTinyGame, so it'll always be 0.
  2893. // window.scrollX = 0;
  2894. // window.scrollY = 0;
  2895. }
  2896. function scrollBy(dx, dy) {
  2897. window.scrollTo(window.scrollX + dx, window.scrollY + dy);
  2898. }
  2899. function alert(msg) {
  2900. console.log(msg);
  2901. }
  2902. function focus() {}
  2903. function blur() {}
  2904. if (Object(_util_isDevtool__WEBPACK_IMPORTED_MODULE_5__["default"])() && swan.getPerformance) {
  2905. var wxPerf = swan.getPerformance();
  2906. var consoleTimers = {};
  2907. console.time = function (name) {
  2908. consoleTimers[name] = wxPerf.now();
  2909. };
  2910. console.timeEnd = function (name) {
  2911. var timeStart = consoleTimers[name];
  2912. if (!timeStart) {
  2913. return;
  2914. }
  2915. var timeElapsed = wxPerf.now() - timeStart;
  2916. console.log(name + ": " + timeElapsed / 1000 + "ms");
  2917. delete consoleTimers[name];
  2918. };
  2919. }
  2920. function eventHandlerFactory() {
  2921. return function (res) {
  2922. var event = new _Event__WEBPACK_IMPORTED_MODULE_4__["default"]('resize');
  2923. event.target = window;
  2924. event.timeStamp = Date.now();
  2925. event.res = res;
  2926. event.windowWidth = res.windowWidth;
  2927. event.windowHeight = res.windowHeight;
  2928. document.dispatchEvent(event);
  2929. };
  2930. }
  2931. // TODO
  2932. // swan.onWindowResize(eventHandlerFactory())
  2933. var _setTimeout = setTimeout;
  2934. var _clearTimeout = clearTimeout;
  2935. var _setInterval = setInterval;
  2936. var _clearInterval = clearInterval;
  2937. var _requestAnimationFrame = requestAnimationFrame;
  2938. var _cancelAnimationFrame = cancelAnimationFrame;
  2939. /***/ })
  2940. /******/ });