a zip code crypto-currency system good for red ONLY

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = Object.setPrototypeOf ||
  3. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5. return function (d, b) {
  6. extendStatics(d, b);
  7. function __() { this.constructor = d; }
  8. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9. };
  10. })();
  11. import { NgZone } from '@angular/core';
  12. import { App } from '../components/app/app';
  13. import { Config } from '../config/config';
  14. import { Content } from '../components/content/content';
  15. import { DeepLinker } from '../navigation/deep-linker';
  16. import { DomController } from '../platform/dom-controller';
  17. import { GestureController } from '../gestures/gesture-controller';
  18. import { Haptic } from '../tap-click/haptic';
  19. import { IonicApp } from '../components/app/app-root';
  20. import { Menu } from '../components/menu/menu';
  21. import { NavControllerBase } from '../navigation/nav-controller-base';
  22. import { OverlayPortal } from '../components/app/overlay-portal';
  23. import { PageTransition } from '../transitions/page-transition';
  24. import { Platform } from '../platform/platform';
  25. import { QueryParams } from '../platform/query-params';
  26. import { Tab } from '../components/tabs/tab';
  27. import { Tabs } from '../components/tabs/tabs';
  28. import { TransitionController } from '../transitions/transition-controller';
  29. import { UrlSerializer } from '../navigation/url-serializer';
  30. import { ViewController } from '../navigation/view-controller';
  31. import { ModuleLoader } from './module-loader';
  32. import { NgModuleLoader } from './ng-module-loader';
  33. import { STATE_INITIALIZED } from '../navigation/nav-util';
  34. import { Ion } from '../components/ion';
  35. import { Item } from '../components/item/item';
  36. import { Form } from './form';
  37. export function mockConfig(config, _url, platform) {
  38. if (_url === void 0) { _url = '/'; }
  39. var c = new Config();
  40. var p = platform || mockPlatform();
  41. c.init(config, p);
  42. return c;
  43. }
  44. export function mockQueryParams(url) {
  45. if (url === void 0) { url = '/'; }
  46. var qp = new QueryParams();
  47. qp.parseUrl(url);
  48. return qp;
  49. }
  50. export function mockPlatform() {
  51. return new MockPlatform();
  52. }
  53. var MockPlatform = (function (_super) {
  54. __extends(MockPlatform, _super);
  55. function MockPlatform() {
  56. var _this = _super.call(this) || this;
  57. _this.timeoutIds = 0;
  58. _this.timeouts = [];
  59. _this.rafIds = 0;
  60. _this.timeStamps = 0;
  61. _this.rafs = [];
  62. var doc = document.implementation.createHTMLDocument('');
  63. _this.setWindow(window);
  64. _this.setDocument(doc);
  65. _this.setCssProps(doc.documentElement);
  66. return _this;
  67. }
  68. MockPlatform.prototype.timeout = function (callback, timeout) {
  69. var timeoutId = ++this.timeoutIds;
  70. this.timeouts.push({
  71. callback: callback,
  72. timeout: timeout,
  73. timeoutId: timeoutId
  74. });
  75. return timeoutId;
  76. };
  77. MockPlatform.prototype.cancelTimeout = function (timeoutId) {
  78. for (var i = 0; i < this.timeouts.length; i++) {
  79. if (timeoutId === this.timeouts[i].timeoutId) {
  80. this.timeouts.splice(i, 1);
  81. break;
  82. }
  83. }
  84. };
  85. MockPlatform.prototype.flushTimeouts = function (done) {
  86. var _this = this;
  87. setTimeout(function () {
  88. _this.timeouts.sort(function (a, b) {
  89. if (a.timeout < b.timeout)
  90. return -1;
  91. if (a.timeout > b.timeout)
  92. return 1;
  93. return 0;
  94. }).forEach(function (t) {
  95. t.callback();
  96. });
  97. _this.timeouts.length = 0;
  98. done();
  99. });
  100. };
  101. MockPlatform.prototype.flushTimeoutsUntil = function (timeout, done) {
  102. var _this = this;
  103. setTimeout(function () {
  104. _this.timeouts.sort(function (a, b) {
  105. if (a.timeout < b.timeout)
  106. return -1;
  107. if (a.timeout > b.timeout)
  108. return 1;
  109. return 0;
  110. });
  111. var keepers = [];
  112. _this.timeouts.forEach(function (t) {
  113. if (t.timeout < timeout) {
  114. t.callback();
  115. }
  116. else {
  117. keepers.push(t);
  118. }
  119. });
  120. _this.timeouts = keepers;
  121. done();
  122. });
  123. };
  124. MockPlatform.prototype.raf = function (callback) {
  125. var rafId = ++this.rafIds;
  126. this.rafs.push({
  127. callback: callback,
  128. rafId: rafId
  129. });
  130. return rafId;
  131. };
  132. MockPlatform.prototype.cancelRaf = function (rafId) {
  133. for (var i = 0; i < this.rafs.length; i++) {
  134. if (rafId === this.rafs[i].rafId) {
  135. this.rafs.splice(i, 1);
  136. break;
  137. }
  138. }
  139. };
  140. MockPlatform.prototype.flushRafs = function (done) {
  141. var _this = this;
  142. var timestamp = ++this.timeStamps;
  143. setTimeout(function () {
  144. _this.rafs.forEach(function (raf) {
  145. raf.callback(timestamp);
  146. });
  147. _this.rafs.length = 0;
  148. done(timestamp);
  149. });
  150. };
  151. return MockPlatform;
  152. }(Platform));
  153. export { MockPlatform };
  154. export function mockDomController(platform) {
  155. platform = platform || mockPlatform();
  156. return new MockDomController(platform);
  157. }
  158. var MockDomController = (function (_super) {
  159. __extends(MockDomController, _super);
  160. function MockDomController(mockedPlatform) {
  161. var _this = _super.call(this, mockedPlatform) || this;
  162. _this.mockedPlatform = mockedPlatform;
  163. return _this;
  164. }
  165. MockDomController.prototype.flush = function (done) {
  166. var _this = this;
  167. this.mockedPlatform.flushTimeouts(function () {
  168. _this.mockedPlatform.flushRafs(function (timeStamp) {
  169. done(timeStamp);
  170. });
  171. });
  172. };
  173. MockDomController.prototype.flushUntil = function (timeout, done) {
  174. var _this = this;
  175. this.mockedPlatform.flushTimeoutsUntil(timeout, function () {
  176. _this.mockedPlatform.flushRafs(function (timeStamp) {
  177. done(timeStamp);
  178. });
  179. });
  180. };
  181. return MockDomController;
  182. }(DomController));
  183. export { MockDomController };
  184. export function mockApp(config, platform) {
  185. platform = platform || mockPlatform();
  186. config = config || mockConfig(null, '/', platform);
  187. var app = new App(config, platform);
  188. mockIonicApp(app, config, platform);
  189. return app;
  190. }
  191. export function mockIonicApp(app, config, plt) {
  192. var appRoot = new IonicApp(null, null, mockElementRef(), mockRenderer(), config, plt, app);
  193. appRoot._loadingPortal = mockOverlayPortal(app, config, plt);
  194. appRoot._toastPortal = mockOverlayPortal(app, config, plt);
  195. appRoot._overlayPortal = mockOverlayPortal(app, config, plt);
  196. appRoot._modalPortal = mockOverlayPortal(app, config, plt);
  197. return appRoot;
  198. }
  199. export var mockTrasitionController = function (config) {
  200. var platform = mockPlatform();
  201. platform.raf = function (callback) {
  202. callback();
  203. };
  204. var trnsCtrl = new TransitionController(platform, config);
  205. trnsCtrl.get = function (trnsId, enteringView, leavingView, opts) {
  206. var trns = new PageTransition(platform, enteringView, leavingView, opts);
  207. trns.trnsId = trnsId;
  208. return trns;
  209. };
  210. return trnsCtrl;
  211. };
  212. export function mockContent() {
  213. var platform = mockPlatform();
  214. return new Content(mockConfig(), platform, mockDomController(platform), mockElementRef(), mockRenderer(), null, null, mockZone(), null, null);
  215. }
  216. export function mockZone() {
  217. return new NgZone({ enableLongStackTrace: false });
  218. }
  219. export function mockChangeDetectorRef() {
  220. var cd = {
  221. reattach: function () { },
  222. detach: function () { },
  223. detectChanges: function () { }
  224. };
  225. return cd;
  226. }
  227. export function mockGestureController(app) {
  228. if (!app) {
  229. app = mockApp();
  230. }
  231. return new GestureController(app);
  232. }
  233. var MockElementRef = (function () {
  234. function MockElementRef(ele) {
  235. this.nativeElement = ele;
  236. }
  237. return MockElementRef;
  238. }());
  239. export { MockElementRef };
  240. var MockElement = (function () {
  241. function MockElement() {
  242. this.children = [];
  243. this.classList = new ClassList();
  244. this.attributes = {};
  245. this.style = {};
  246. this.nodeName = 'ION-MOCK';
  247. this.clientWidth = 0;
  248. this.clientHeight = 0;
  249. this.clientTop = 0;
  250. this.clientLeft = 0;
  251. this.offsetWidth = 0;
  252. this.offsetHeight = 0;
  253. this.offsetTop = 0;
  254. this.offsetLeft = 0;
  255. this.scrollTop = 0;
  256. this.scrollHeight = 0;
  257. }
  258. Object.defineProperty(MockElement.prototype, "className", {
  259. get: function () {
  260. return this.classList.classes.join(' ');
  261. },
  262. set: function (val) {
  263. this.classList.classes = val.split(' ');
  264. },
  265. enumerable: true,
  266. configurable: true
  267. });
  268. MockElement.prototype.hasAttribute = function (name) {
  269. return !!this.attributes[name];
  270. };
  271. MockElement.prototype.getAttribute = function (name) {
  272. return this.attributes[name];
  273. };
  274. MockElement.prototype.setAttribute = function (name, val) {
  275. this.attributes[name] = val;
  276. };
  277. MockElement.prototype.addEventListener = function (_type, _listener, _options) { };
  278. MockElement.prototype.removeEventListener = function (_type, _listener, _options) { };
  279. MockElement.prototype.removeAttribute = function (name) {
  280. delete this.attributes[name];
  281. };
  282. return MockElement;
  283. }());
  284. export { MockElement };
  285. var ClassList = (function () {
  286. function ClassList() {
  287. this.classes = [];
  288. }
  289. ClassList.prototype.add = function (className) {
  290. if (!this.contains(className)) {
  291. this.classes.push(className);
  292. }
  293. };
  294. ClassList.prototype.remove = function (className) {
  295. var index = this.classes.indexOf(className);
  296. if (index > -1) {
  297. this.classes.splice(index, 1);
  298. }
  299. };
  300. ClassList.prototype.toggle = function (className) {
  301. if (this.contains(className)) {
  302. this.remove(className);
  303. }
  304. else {
  305. this.add(className);
  306. }
  307. };
  308. ClassList.prototype.contains = function (className) {
  309. return this.classes.indexOf(className) > -1;
  310. };
  311. return ClassList;
  312. }());
  313. export { ClassList };
  314. export function mockElementRef() {
  315. return new MockElementRef(new MockElement());
  316. }
  317. export function mockElementRefEle(ele) {
  318. return new MockElementRef(ele);
  319. }
  320. var MockRenderer = (function () {
  321. function MockRenderer() {
  322. }
  323. MockRenderer.prototype.setElementAttribute = function (renderElement, name, val) {
  324. if (name === null) {
  325. renderElement.removeAttribute(name);
  326. }
  327. else {
  328. renderElement.setAttribute(name, val);
  329. }
  330. };
  331. MockRenderer.prototype.setElementClass = function (renderElement, className, isAdd) {
  332. if (isAdd) {
  333. renderElement.classList.add(className);
  334. }
  335. else {
  336. renderElement.classList.remove(className);
  337. }
  338. };
  339. MockRenderer.prototype.setElementStyle = function (renderElement, styleName, styleValue) {
  340. renderElement.style[styleName] = styleValue;
  341. };
  342. return MockRenderer;
  343. }());
  344. export { MockRenderer };
  345. export function mockRenderer() {
  346. var renderer = new MockRenderer();
  347. return renderer;
  348. }
  349. export function mockLocation() {
  350. var location = {
  351. path: function () { return ''; },
  352. subscribe: function () { },
  353. go: function () { },
  354. back: function () { },
  355. prepareExternalUrl: function () { }
  356. };
  357. return location;
  358. }
  359. export function mockView(component, data) {
  360. if (!component) {
  361. component = MockView;
  362. }
  363. var view = new ViewController(component, data);
  364. view.init(mockComponentRef());
  365. return view;
  366. }
  367. export function mockViews(nav, views) {
  368. nav._views = views;
  369. views.forEach(function (v) {
  370. v._setNav(nav);
  371. });
  372. }
  373. export function mockComponentRef() {
  374. var componentRef = {
  375. location: mockElementRef(),
  376. changeDetectorRef: mockChangeDetectorRef(),
  377. destroy: function () { }
  378. };
  379. return componentRef;
  380. }
  381. export function mockDeepLinker(linkConfig, app) {
  382. if (linkConfig === void 0) { linkConfig = null; }
  383. app = app || mockApp(mockConfig(), mockPlatform());
  384. var serializer = new UrlSerializer(app, linkConfig);
  385. var location = mockLocation();
  386. return new DeepLinker(app || mockApp(), serializer, location, null, null);
  387. }
  388. export function mockNavController() {
  389. var platform = mockPlatform();
  390. var config = mockConfig(null, '/', platform);
  391. var app = mockApp(config, platform);
  392. var zone = mockZone();
  393. var dom = mockDomController(platform);
  394. var elementRef = mockElementRef();
  395. var renderer = mockRenderer();
  396. var componentFactoryResolver = null;
  397. var gestureCtrl = new GestureController(app);
  398. var linker = mockDeepLinker(null, app);
  399. var trnsCtrl = mockTrasitionController(config);
  400. var nav = new NavControllerBase(null, app, config, platform, elementRef, zone, renderer, componentFactoryResolver, gestureCtrl, trnsCtrl, linker, dom, null);
  401. nav._viewInit = function (enteringView) {
  402. enteringView.init(mockComponentRef());
  403. enteringView._state = STATE_INITIALIZED;
  404. };
  405. nav._orgViewInsert = nav._viewAttachToDOM;
  406. nav._viewAttachToDOM = function (view, componentRef, _viewport) {
  407. var mockedViewport = {
  408. insert: function () { }
  409. };
  410. nav._orgViewInsert(view, componentRef, mockedViewport);
  411. };
  412. return nav;
  413. }
  414. export function mockOverlayPortal(app, config, plt) {
  415. var zone = mockZone();
  416. var dom = mockDomController(plt);
  417. var elementRef = mockElementRef();
  418. var renderer = mockRenderer();
  419. var componentFactoryResolver = null;
  420. var gestureCtrl = new GestureController(app);
  421. var serializer = new UrlSerializer(app, null);
  422. var location = mockLocation();
  423. var deepLinker = new DeepLinker(app, serializer, location, null, null);
  424. return new OverlayPortal(app, config, plt, elementRef, zone, renderer, componentFactoryResolver, gestureCtrl, null, deepLinker, null, dom, null);
  425. }
  426. export function mockTab(parentTabs, overrideLoad) {
  427. if (overrideLoad === void 0) { overrideLoad = true; }
  428. var platform = mockPlatform();
  429. var config = mockConfig(null, '/', platform);
  430. var app = parentTabs._app || mockApp(config, platform);
  431. var zone = mockZone();
  432. var dom = mockDomController(platform);
  433. var elementRef = mockElementRef();
  434. var renderer = mockRenderer();
  435. var changeDetectorRef = mockChangeDetectorRef();
  436. var compiler = null;
  437. var gestureCtrl = new GestureController(app);
  438. var linker = mockDeepLinker(null, app);
  439. var tab = new Tab(parentTabs, app, config, platform, elementRef, zone, renderer, compiler, changeDetectorRef, gestureCtrl, null, linker, dom, null);
  440. if (overrideLoad) {
  441. tab.load = function (_opts) {
  442. return Promise.resolve();
  443. };
  444. }
  445. return tab;
  446. }
  447. export function mockForm() {
  448. return new Form();
  449. }
  450. export function mockIon() {
  451. var config = mockConfig();
  452. var elementRef = mockElementRef();
  453. var renderer = mockRenderer();
  454. return new Ion(config, elementRef, renderer, 'ion');
  455. }
  456. export function mockItem() {
  457. var form = mockForm();
  458. var config = mockConfig();
  459. var elementRef = mockElementRef();
  460. var renderer = mockRenderer();
  461. return new Item(form, config, elementRef, renderer, null);
  462. }
  463. export function mockTabs(app) {
  464. var platform = mockPlatform();
  465. var config = mockConfig(null, '/', platform);
  466. app = app || mockApp(config, platform);
  467. var elementRef = mockElementRef();
  468. var renderer = mockRenderer();
  469. var linker = mockDeepLinker();
  470. return new Tabs(null, null, app, config, elementRef, platform, renderer, linker);
  471. }
  472. export function mockMenu(platform) {
  473. if (platform === void 0) { platform = null; }
  474. var app = mockApp();
  475. var gestureCtrl = new GestureController(app);
  476. var dom = mockDomController();
  477. var elementRef = mockElementRef();
  478. var renderer = mockRenderer();
  479. var plt = platform === null ? mockPlatform() : platform;
  480. return new Menu(null, elementRef, null, plt, renderer, null, gestureCtrl, dom, app);
  481. }
  482. export function mockDeepLinkConfig(links) {
  483. return {
  484. links: links || [
  485. { component: MockView1, name: 'viewone' },
  486. { component: MockView2, name: 'viewtwo' },
  487. { component: MockView3, name: 'viewthree' },
  488. { component: MockView4, name: 'viewfour' },
  489. { component: MockView5, name: 'viewfive' }
  490. ]
  491. };
  492. }
  493. export function mockHaptic() {
  494. return new Haptic(mockPlatform());
  495. }
  496. var MockView = (function () {
  497. function MockView() {
  498. }
  499. return MockView;
  500. }());
  501. export { MockView };
  502. var MockView1 = (function () {
  503. function MockView1() {
  504. }
  505. return MockView1;
  506. }());
  507. export { MockView1 };
  508. var MockView2 = (function () {
  509. function MockView2() {
  510. }
  511. return MockView2;
  512. }());
  513. export { MockView2 };
  514. var MockView3 = (function () {
  515. function MockView3() {
  516. }
  517. return MockView3;
  518. }());
  519. export { MockView3 };
  520. var MockView4 = (function () {
  521. function MockView4() {
  522. }
  523. return MockView4;
  524. }());
  525. export { MockView4 };
  526. var MockView5 = (function () {
  527. function MockView5() {
  528. }
  529. return MockView5;
  530. }());
  531. export { MockView5 };
  532. export function noop() { return 'noop'; }
  533. export function mockModuleLoader(ngModuleLoader) {
  534. ngModuleLoader = ngModuleLoader || mockNgModuleLoader();
  535. return new ModuleLoader(ngModuleLoader, null);
  536. }
  537. export function mockNgModuleLoader() {
  538. return new NgModuleLoader(null);
  539. }
  540. export function mockOverlay() {
  541. return {
  542. present: function (_opts) { return Promise.resolve(); },
  543. dismiss: function (_data, _role, _navOptions) { return Promise.resolve(); },
  544. onDidDismiss: function (_callback) { },
  545. onWillDismiss: function (_callback) { }
  546. };
  547. }
  548. //# sourceMappingURL=mock-providers.js.map