mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00

* chore: move tns-core-modules to nativescript-core * chore: preparing compat generate script * chore: add missing definitions * chore: no need for http-request to be private * chore: packages chore * test: generate tests for tns-core-modules * chore: add anroid module for consistency * chore: add .npmignore * chore: added privateModulesWhitelist * chore(webpack): added bundle-entry-points * chore: scripts * chore: tests changed to use @ns/core * test: add scoped-packages test project * test: fix types * test: update test project * chore: build scripts * chore: update build script * chore: npm scripts cleanup * chore: make the compat pgk work with old wp config * test: generate diff friendly tests * chore: create barrel exports * chore: move files after rebase * chore: typedoc config * chore: compat mode * chore: review of barrels * chore: remove tns-core-modules import after rebase * chore: dev workflow setup * chore: update developer-workflow * docs: experiment with API extractor * chore: api-extractor and barrel exports * chore: api-extractor configs * chore: generate d.ts rollup with api-extractor * refactor: move methods inside Frame * chore: fic tests to use Frame static methods * refactor: create Builder class * refactor: use Builder class in tests * refactor: include Style in ui barrel * chore: separate compat build script * chore: fix tslint errors * chore: update NATIVESCRIPT_CORE_ARGS * chore: fix compat pack * chore: fix ui-test-app build with linked modules * chore: Application, ApplicationSettings, Connectivity and Http * chore: export Trace, Profiling and Utils * refactor: Static create methods for ImageSource * chore: fix deprecated usages of ImageSource * chore: move Span and FormattedString to ui * chore: add events-args and ImageSource to index files * chore: check for CLI >= 6.2 when building for IOS * chore: update travis build * chore: copy Pod file to compat package * chore: update error msg ui-tests-app * refactor: Apply suggestions from code review Co-Authored-By: Martin Yankov <m.i.yankov@gmail.com> * chore: typings and refs * chore: add missing d.ts files for public API * chore: adress code review FB * chore: update api-report * chore: dev-workflow for other apps * chore: api update * chore: update api-report
148 lines
6.6 KiB
TypeScript
148 lines
6.6 KiB
TypeScript
let start;
|
|
if (typeof NSDate !== "undefined") {
|
|
start = NSDate.date();
|
|
} else {
|
|
start = java.lang.System.currentTimeMillis();
|
|
}
|
|
|
|
import * as application from "@nativescript/core/application";
|
|
|
|
if (application.ios) {
|
|
// Observe application notifications.
|
|
application.ios.addNotificationObserver(UIApplicationDidFinishLaunchingNotification, (notification: NSNotification) => {
|
|
console.log("UIApplicationDidFinishLaunchingNotification: " + notification);
|
|
});
|
|
}
|
|
|
|
// Common events for both Android and iOS.
|
|
application.on(application.displayedEvent, function (args: application.ApplicationEventData) {
|
|
(<any>global).isDisplayedEventFired = true;
|
|
|
|
if (args.android) {
|
|
// For Android applications, args.android is an Android activity class.
|
|
console.log("Displayed Activity: " + args.android);
|
|
} else if (args.ios) {
|
|
// For iOS applications, args.ios is UIApplication.
|
|
console.log("Displayed UIApplication: " + args.ios);
|
|
}
|
|
});
|
|
|
|
application.on(application.launchEvent, function (args: application.ApplicationEventData) {
|
|
if (args.android) {
|
|
// For Android applications, args.android is an android.content.Intent class.
|
|
console.log("Launched Android application with the following intent: " + args.android + ".");
|
|
} else if (args.ios !== undefined) {
|
|
// For iOS applications, args.ios is NSDictionary (launchOptions).
|
|
console.log("Launched iOS application with options: " + args.ios);
|
|
}
|
|
});
|
|
|
|
application.on(application.suspendEvent, function (args: application.ApplicationEventData) {
|
|
if (args.android) {
|
|
// For Android applications, args.android is an Android activity class.
|
|
console.log("Suspend Activity: " + args.android);
|
|
} else if (args.ios) {
|
|
// For iOS applications, args.ios is UIApplication.
|
|
console.log("Suspend UIApplication: " + args.ios);
|
|
}
|
|
});
|
|
|
|
application.on(application.resumeEvent, function (args: application.ApplicationEventData) {
|
|
if (args.android) {
|
|
// For Android applications, args.android is an Android activity class.
|
|
console.log("Resume Activity: " + args.android);
|
|
} else if (args.ios) {
|
|
// For iOS applications, args.ios is UIApplication.
|
|
console.log("Resume UIApplication: " + args.ios);
|
|
}
|
|
});
|
|
|
|
application.on(application.exitEvent, function (args: application.ApplicationEventData) {
|
|
if (args.android) {
|
|
// For Android applications, args.android is an Android activity class.
|
|
console.log("Exit Activity: " + args.android);
|
|
} else if (args.ios) {
|
|
// For iOS applications, args.ios is UIApplication.
|
|
console.log("Exit UIApplication: " + args.ios);
|
|
}
|
|
});
|
|
|
|
application.on(application.lowMemoryEvent, function (args: application.ApplicationEventData) {
|
|
if (args.android) {
|
|
// For Android applications, args.android is an Android activity class.
|
|
console.log("Low Memory: " + args.android);
|
|
} else if (args.ios) {
|
|
// For iOS applications, args.ios is UIApplication.
|
|
console.log("Low Memory: " + args.ios);
|
|
}
|
|
});
|
|
|
|
// Error events.
|
|
application.on(application.uncaughtErrorEvent, function (args: application.UnhandledErrorEventData) {
|
|
console.log("NativeScriptError: " + args.error);
|
|
console.log((<any>args.error).nativeException || (<any>args.error).nativeError);
|
|
console.log((<any>args.error).stackTrace || (<any>args.error).stack);
|
|
});
|
|
|
|
application.on(application.discardedErrorEvent, function (args: application.DiscardedErrorEventData) {
|
|
console.log("[Discarded] NativeScriptError: " + args.error);
|
|
console.log((<any>args.error).nativeException || (<any>args.error).nativeError);
|
|
console.log((<any>args.error).stackTrace || (<any>args.error).stack);
|
|
});
|
|
|
|
// Android activity events.
|
|
if (application.android) {
|
|
application.android.on(application.AndroidApplication.activityCreatedEvent, function (args: application.AndroidActivityBundleEventData) {
|
|
console.log("Event: " + args.eventName + ", Activity: " + args.activity + ", Bundle: " + args.bundle);
|
|
});
|
|
|
|
application.android.on(application.AndroidApplication.activityDestroyedEvent, function (args: application.AndroidActivityEventData) {
|
|
console.log("Event: " + args.eventName + ", Activity: " + args.activity);
|
|
});
|
|
|
|
application.android.on(application.AndroidApplication.activityStartedEvent, function (args: application.AndroidActivityEventData) {
|
|
console.log("Event: " + args.eventName + ", Activity: " + args.activity);
|
|
});
|
|
|
|
application.android.on(application.AndroidApplication.activityPausedEvent, function (args: application.AndroidActivityEventData) {
|
|
console.log("Event: " + args.eventName + ", Activity: " + args.activity);
|
|
});
|
|
|
|
application.android.on(application.AndroidApplication.activityResumedEvent, function (args: application.AndroidActivityEventData) {
|
|
console.log("Event: " + args.eventName + ", Activity: " + args.activity);
|
|
});
|
|
|
|
application.android.on(application.AndroidApplication.activityStoppedEvent, function (args: application.AndroidActivityEventData) {
|
|
console.log("Event: " + args.eventName + ", Activity: " + args.activity);
|
|
});
|
|
|
|
application.android.on(application.AndroidApplication.saveActivityStateEvent, function (args: application.AndroidActivityBundleEventData) {
|
|
console.log("Event: " + args.eventName + ", Activity: " + args.activity + ", Bundle: " + args.bundle);
|
|
});
|
|
|
|
application.android.on(application.AndroidApplication.activityResultEvent, function (args: application.AndroidActivityResultEventData) {
|
|
console.log("Event: " + args.eventName + ", Activity: " + args.activity +
|
|
", requestCode: " + args.requestCode + ", resultCode: " + args.resultCode + ", Intent: " + args.intent);
|
|
});
|
|
|
|
application.android.on(application.AndroidApplication.activityBackPressedEvent, function (args: application.AndroidActivityBackPressedEventData) {
|
|
console.log("Event: " + args.eventName + ", Activity: " + args.activity);
|
|
// Set args.cancel = true to cancel back navigation and do something custom.
|
|
});
|
|
|
|
application.android.on(application.AndroidApplication.activityNewIntentEvent, function (args: application.AndroidActivityNewIntentEventData) {
|
|
console.log("Event: " + args.eventName + ", Activity: " + args.activity + ", Intent: " + args.intent);
|
|
});
|
|
}
|
|
|
|
let time;
|
|
if (typeof NSDate !== "undefined") {
|
|
time = NSDate.date().timeIntervalSinceDate(start) * 1000;
|
|
} else {
|
|
time = java.lang.System.currentTimeMillis() - start;
|
|
}
|
|
|
|
console.log(`TIME TO LOAD APP: ${time} ms`);
|
|
|
|
application.run({ moduleName: "app-root" });
|