Skip to content
This repository was archived by the owner on Nov 17, 2022. It is now read-only.

Commit 882bd51

Browse files
chore: update to {N} 7 imports (#1935)
* chore: update to {N} 7 imports wip * chore: update imports * Update docs/releases/running-latest.md * Update docs/core-concepts/application-lifecycle.md * chore: update links Co-authored-by: Igor Randjelovic <[email protected]>
1 parent ee857b6 commit 882bd51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+638
-824
lines changed

build/_layouts/landing.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ <h3 class="start-links__title">NativeScript & Angular</h3>
107107
<li><a href="/angular/core-concepts/navigation">Core Concepts</a></li>
108108
<li><a href="/angular/ui/overview">Components</a></li>
109109
<li><a href="/angular/ui/layouts/layouts">Layouts</a></li>
110-
<li><a href="/angular/app-and-screen-templates/app-templates">Application Templates</a></li>
110+
<li><a href="/angular/app-templates/app-templates">Application Templates</a></li>
111111
<li><a href="/angular/tooling/testing/testing">Tooling</a></li>
112112
<li><a href="/angular/code-sharing/intro">Code Sharing</a></li>
113113
<li><a href="/angular/ui/overview#nativescript-ui-overview">NativeScript UI</a></li>
@@ -117,11 +117,11 @@ <h3 class="start-links__title">NativeScript & Angular</h3>
117117
<h3 class="start-links__title">NativeScript Core</h3>
118118
<ul>
119119
<li><a href="/start/introduction">Getting Started</a></li>
120-
<li><a href="/core-concepts">Core Concepts</a></li>
120+
<li><a href="/core-concepts/technical-overview">Core Concepts</a></li>
121121
<li><a href="/ui/overview">Components</a></li>
122-
<li><a href="/ui/layouts">Layouts</a></li>
123-
<li><a href="/app-and-screen-templates/app-templates">Application Templates</a></li>
124-
<li><a href="/tooling">Tooling</a></li>
122+
<li><a href="/ui/layouts/layouts">Layouts</a></li>
123+
<li><a href="/app-templates/app-templates">Application Templates</a></li>
124+
<li><a href="/tooling/visual-studio-code-extension">Tooling</a></li>
125125
<li><a href="/ui/overview#nativescript-ui-overview">NativeScript UI</a></li>
126126
</ul>
127127
</div>

docs/core-concepts/accessing-native-apis-with-javascript.md

+11-17
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ slug: access-native-apis
88

99
# Accessing native iOS and Android APIs through JavaScript
1010

11-
In this article we are going through the basic concepts of how native APIs are accessed through JavaScript. Our focus is on how primitive types are mapped between JavaScript and the corresponding native platform. We then continue with explaining how complex objects are represented and accessed. At the end, we talk about TypeScript and the `tns-platform-declarations` add-on which gives you TypeScript definitions for the Android and iOS development platforms.
11+
In this article we are going through the basic concepts of how native APIs are accessed through JavaScript. Our focus is on how primitive types are mapped between JavaScript and the corresponding native platform. We then continue with explaining how complex objects are represented and accessed. At the end, we talk about TypeScript and the `@nativescript/types` add-on which gives you TypeScript definitions for the Android and iOS development platforms.
1212

1313
NativeScript lets you access all native APIs from the underlying platform. To achieve this behaviour, many things happen under the hood. One of them is marshalling - the conversion between JavaScript and Objective-C data types for iOS and Java data types for Android.
1414

@@ -223,25 +223,24 @@ button.setOnClickListener(undefined); // the Java call will be made using the nu
223223

224224
## IntelliSense and Access to the Native APIs via TypeScript
225225

226-
To have access and Intellisense for the native APIs, you have to add a developer dependency to `tns-platform-declarations`.
226+
To have access and Intellisense for the native APIs, you have to add a developer dependency to `@nativescript/types`.
227227

228228
Steps to install and enable
229229

230-
- `npm install tns-platform-declarations --save-dev`
230+
- `npm install @nativescript/types --save-dev`
231231

232-
> **Note:** Always install the plugin as a `devDependency` (`npm i tns-platform-declarations --save-dev` flag) to avoid bringing the enormously big declaration files in the output built file.
232+
> **Note:** Always install the plugin as a `devDependency` (`npm i @nativescript/types --save-dev` flag) to avoid bringing the enormously big declaration files in the output built file.
233233
234234
Create `reference.d.ts` in the root project directory and add the following:
235235
```
236-
/// <reference path="node_modules/tns-platform-declarations/android.d.ts" />
237-
/// <reference path="node_modules/tns-platform-declarations/ios.d.ts" />
236+
/// <reference path="node_modules/@nativescript/types/index.d.ts" />
238237
```
239238

240-
By default, the file `android.d.ts` comes with typings generated for API level 17. As an Android developer, you might need access to a specific class, method, or property introduced in a newer API level. The `tns-platform-declarations` plugin comes with generated typings for all API levels from 17 to 27 including the related typings from the respective support library. To use typings for a specific Android level replace the reference to the default declaration file with the preferred one. The files for each API level comes postfixed with a dash followed by the number of the API level (e.g. for API 21 the file is named `android-21.d.ts`).
239+
By default, the file `android.d.ts` comes with typings generated for API level 17. As an Android developer, you might need access to a specific class, method, or property introduced in a newer API level. The `@nativescript/types` plugin comes with generated typings for all API levels from 17 to 27 including the related typings from the respective support library. To use typings for a specific Android level replace the reference to the default declaration file with the preferred one. The files for each API level comes postfixed with a dash followed by the number of the API level (e.g. for API 21 the file is named `android-21.d.ts`).
241240

242241
For example, let's assume you are developing an application for API 21+ and you need typings generated for that API level:
243242
```
244-
/// <reference path="node_modules/tns-platform-declarations/android-21.d.ts" />
243+
/// <reference path="node_modules/@nativescript/types-android/lib/android-21.d.ts" />
245244
```
246245

247246
> **Note:** Proceed with caution when using functionalities introduced in newer API level. If you attempt
@@ -252,18 +251,13 @@ For example, let's assume you are developing an application for API 21+ and you
252251
{
253252
"compilerOptions": {
254253
...
255-
"lib": ["es6", "dom"],
256-
"baseUrl": ".",
257-
"paths": {
258-
"*": [
259-
"./node_modules/tns-core-modules/*",
260-
"./node_modules/*"
261-
]
262-
}
254+
"module": "esnext",
255+
"target": "es2015",
256+
"moduleResolution": "node",
257+
"lib": ["es2018", "dom"],
263258
}
264259
```
265260
Note that `d.ts` files require a lot of memory and CPU. Consider adding **skipLibCheck** option to `tsconfig.json`.
266-
For more information visit the GitHub repository of [tns-platform-declarations](https://github.com/NativeScript/NativeScript/tree/master/tns-platform-declarations)
267261

268262

269263
# See Also

docs/core-concepts/android-runtime/advanced-topics/extend-application-activity.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,19 @@ The core modules ship with a default `androidx.appcompat.app.AppCompatActivity`
105105
2. Declare the extend:
106106

107107
```javascript
108-
const frame = require("tns-core-modules/ui/frame");
108+
import { Frame, Application, setActivityCallbacks } from "@nativescript/core";
109109
110110
const superProto = androidx.appcompat.app.AppCompatActivity.prototype;
111111
androidx.appcompat.app.AppCompatActivity.extend("org.myApp.MainActivity", {
112112
onCreate: function(savedInstanceState) {
113113
// Used to make sure the App is inited in case onCreate is called before the rest of the framework
114-
appModule.android.init(this.getApplication());
114+
Application.android.init(this.getApplication());
115115
116116
// Set the isNativeScriptActivity in onCreate (as done in the original NativeScript activity code)
117117
// The JS constructor might not be called because the activity is created from Android.
118118
this.isNativeScriptActivity = true;
119119
if(!this._callbacks) {
120-
frame.setActivityCallbacks(this);
120+
setActivityCallbacks(this);
121121
}
122122
// Modules will take care of calling super.onCreate, do not call it here
123123
this._callbacks.onCreate(this, savedInstanceState, this.getIntent(), superProto.onCreate);
@@ -155,7 +155,7 @@ The core modules ship with a default `androidx.appcompat.app.AppCompatActivity`
155155
});
156156
```
157157
```typescript
158-
import {setActivityCallbacks, AndroidActivityCallbacks} from "tns-core-modules/ui/frame";
158+
import { Frame, Application, setActivityCallbacks, AndroidActivityCallbacks } from "@nativescript/core";
159159
160160
@JavaProxy("org.myApp.MainActivity")
161161
class Activity extends androidx.appcompat.app.AppCompatActivity {
@@ -219,8 +219,8 @@ The core modules ship with a default `androidx.appcompat.app.AppCompatActivity`
219219

220220
```javascript
221221
const appComponents = [
222-
"tns-core-modules/ui/frame",
223-
"tns-core-modules/ui/frame/activity",
222+
"@nativescript/core/ui/frame",
223+
"@nativescript/core/ui/frame/activity",
224224
resolve(__dirname, "app/activity.android.ts"),
225225
];
226226
```

docs/core-concepts/android-runtime/advanced-topics/marking-mode-none.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ slug: marking-mode-none
99

1010
Starting with NativeScript 3.2, a new (experimental at the time) feature was added to the Android runtime called `markingMode`. Its purpose is to speed up garbage collection in the V8 engine. In some cases, a GC pass could take from 0.5 to 1 second and since it runs on the main UI thread, the user would experience a frozen app until GC is done. Setting “markingMode” to “none” will speed up the garbage collection greatly, so it would be less noticeable (if at all) to the app user. The downside of this approach is that some objects could be collected while their counterparts (in V8 or Android) are still in use. Such case is when JavaScript objects are referenced only from native code and in the eyes of the V8 GC no JS object holds reference to them. In other words – the objects are no longer “marked” as used and the V8 GC might collect them too early.
1111

12-
The code inside `tns-core-modules` and all plugins published by the NativeScript Team (since version 5.1.0) are written in such a way, that it does not depend on the scope to keep those Java/Kotlin instances alive. This makes apps using these plugins fully compatible with the much more performant `markingMode: "none"` option.
12+
The code inside `@nativescript/core` and all plugins published by the NativeScript Team (since version 5.1.0) are written in such a way, that it does not depend on the scope to keep those Java/Kotlin instances alive. This makes apps using these plugins fully compatible with the much more performant `markingMode: "none"` option.
1313

1414
## Benefits and drawbacks of using markingMode: none
1515

docs/core-concepts/android-runtime/advanced-topics/memory-management.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ There's a `app/package.json` option which apps can set in order to disable `Mark
4848
}
4949
```
5050

51-
The code inside `tns-core-modules` and all plugins published by the NativeScript Team (since version 5.1.0) are written in such a way, that it does not depend on the scope to keep those Java/Kotlin instances alive. This makes apps using these plugins fully compatible with the much more performant `markingMode: "none"` option. [More information on `markingMode:none`](./marking-mode-none).
51+
The code inside `@nativescript/core` and all plugins published by the NativeScript Team (since version 5.1.0) are written in such a way, that it does not depend on the scope to keep those Java/Kotlin instances alive. This makes apps using these plugins fully compatible with the much more performant `markingMode: "none"` option. [More information on `markingMode:none`](./marking-mode-none).
5252

5353
> **WARNING**: Enabling this option if the JavaScript code dealing with native objects (either in the application or any plugins you are using) does not correctly take care of the lifetime of Java/Kotlin instances may cause unexpected and unpredictable crashes of the application. This would be caused by Java/Kotlin instances being prematurely collected. Use caution when enabling it and make sure to thoroughly test your apps with different memory constrains and devices! The errors generated in such cases look like this:
5454
`Error: com.tns.NativeScriptException: Attempt to use cleared object reference id=<some-object-id-number>`

docs/core-concepts/android-runtime/metadata/accessing-packages.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ To find out the package name of an Android class, refer to the [Android SDK Refe
4343

4444
For example, if you need to work with the Google API for Google Maps, after following the installation guide, you may need to access packages from the plugin like `com.google.android.gms.maps`, which you can find a reference for at [Google APIs for Android Reference](https://developers.google.com/android/reference/com/google/android/gms/maps/package-summary)
4545

46-
> **Note:** To have access and Intellisense for the native APIs with **NativeScript + TypeScript** or **NativeScript + Angular** projects, you have to add a dev dependency to `tns-platform-declarations`. More details about accessing native APIs with TypeScript can be found [here]({% slug access-native-apis %}#intellisense-and-access-to-native-apis-via-typescript).
46+
> **Note:** To have access and Intellisense for the native APIs with **NativeScript + TypeScript** or **NativeScript + Angular** projects, you have to add a dev dependency to `@nativescript/types`. More details about accessing native APIs with TypeScript can be found [here]({% slug access-native-apis %}#intellisense-and-access-to-native-apis-via-typescript).
4747
4848

4949
> **Note:** **(Experimental)** Alternatively, to get Intellisense for the native APIs based on the available Android Platform SDK and imported Android Support packages (added by default to your Android project), supply the `--androidTypings` flag with your `tns run | build android` command. The resulting `android.d.ts` file can then be used to provide auto-completion.

docs/core-concepts/android-runtime/metadata/generating-typescript-declarations.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ The above is a bad practice for two reasons:
2929

3030
### The Good Practice
3131

32-
To resolve the above, in NativeScript, there is a developer dependency called [tns-platform-declarations].(https://preview.npmjs.com/package/tns-platform-declarations) After the intial instalation and setup, you could directly access the `android` namespace from the Android SDK.
32+
To resolve the above, in NativeScript, there is a developer dependency called [@nativescript/types].(https://preview.npmjs.com/package/@nativescript/types) After the intial instalation and setup, you could directly access the `android` namespace from the Android SDK.
3333
```TypeScript
34-
// npm i tns-platform-declarations --save-dev
35-
// follow the setup instructions at https://preview.npmjs.com/package/tns-platform-declarations
34+
// npm i @nativescript/types --save-dev
35+
// follow the setup instructions at https://preview.npmjs.com/package/@nativescript/types
3636
let androidContext = android.content.Context;
3737
```
3838

39-
The `tns-platform-declarations` plugin is providing access to the Android SDK. The plugin comes with pre-generated TypeScript declaration files for all API levels from 17 to 27 exclusive (detailed usage instructions in [this documentation section](../../accessing-native-apis-with-javascript#intellisense-and-access-to-the-native-apis-via-typescript)). In cases, where we need a declaration file for a third-party library or newer API (e.g. API 28) we can generate our own definitions using the **[Android DTS generator](#android-dts-generator)**.
39+
The `@nativescript/types` plugin is providing access to the Android SDK. The plugin comes with pre-generated TypeScript declaration files for all API levels from 17 to 27 exclusive (detailed usage instructions in [this documentation section](../../accessing-native-apis-with-javascript#intellisense-and-access-to-the-native-apis-via-typescript)). In cases, where we need a declaration file for a third-party library or newer API (e.g. API 28) we can generate our own definitions using the **[Android DTS generator](#android-dts-generator)**.
4040

4141
## Android DTS Generator
4242

@@ -154,4 +154,4 @@ By repeating the steps above, we've found that:
154154
- Android support 23 typings(built with super jar from Android API 23) can be reused until Android API 25
155155
- Android support 26 typings(built with super jar from Android API 26) can be reused for API 26 and 27
156156

157-
The corresponding typings files can be found in the `tns-platform-declarations` package. The repo's [Makefile](https://github.com/NativeScript/android-dts-generator/blob/master/Makefile) can be used as a reference for creating these typings files.
157+
The corresponding typings files can be found in the `@nativescript/types` package. The repo's [Makefile](https://github.com/NativeScript/android-dts-generator/blob/master/Makefile) can be used as a reference for creating these typings files.

0 commit comments

Comments
 (0)