UNPKG

@nativescript-community/flipper

Version:

A desktop debugging platform for mobile developers.

82 lines 3.74 kB
import { ClientBase } from './flipper.common'; import { Application } from '@nativescript/core'; var Client = /** @class */ (function (_super) { __extends(Client, _super); function Client() { return _super !== null && _super.apply(this, arguments) || this; } Client.prototype.runInit = function () { var client = this._client = FlipperClient.sharedClient(); var layoutDescriptorMapper = SKDescriptorMapper.alloc().initWithDefaults(); FlipperKitLayoutComponentKitSupport.setUpWithDescriptorMapper(layoutDescriptorMapper); var plugins = (this.config && this.config.plugins) || []; plugins.forEach(function (s) { if (!(typeof s === 'string') && s.install) { try { s.install(client); } catch (err) { console.error(err); } } switch (s) { case 'network': client.addPlugin(FlipperKitNetworkPlugin.alloc().initWithNetworkAdapter(SKIOSNetworkAdapter.new())); break; case 'layout': client.addPlugin(FlipperKitLayoutPlugin.alloc().initWithRootNodeWithDescriptorMapper(Application.ios.nativeApp, layoutDescriptorMapper)); break; // case 'database': // client.addPlugin(new com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin(context)); // break; // case 'image': // client.addPlugin(new com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin()); // break; case 'prefs': client.addPlugin(FKUserDefaultsPlugin.alloc().initWithSuiteName(null)); break; // case 'crash': // client.addPlugin(com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin.getInstance()); // break; } }); client.start(); }; Client.prototype.triggerCrash = function (error) { // com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin.getInstance().sendExceptionMessage(android.os.Thread.currentThread(), error); }; Client.prototype.start = function (conf) { var _this = this; // clog('Bugnsag', 'init', conf, !!this._client, knownFolders.currentApp().path, application.launchEvent); if (!this._client) { this.config = conf; return new Promise(function (resolve, reject) { var onLaunched = function () { try { // clog('Bugnsag', 'onLaunched'); Application.off(Application.launchEvent, onLaunched); _this.runInit(); resolve(_this._client); } catch (ex) { console.log('Error in Flipper.init: ' + ex); reject(ex); } }; // clog('Bugnsag', 'will init', !!application.android.nativeApp, !!application.android.context, !!application.android.startActivity); if (Application.ios.nativeApp) { onLaunched(); } else { // console.log('Bugnsag', 'will init on launchEvent'); Application.on(Application.launchEvent, onLaunched); } }); } return Promise.resolve(this._client); // return !!this._client; }; return Client; }(ClientBase)); export { Client }; //# sourceMappingURL=flipper.ios.js.map