Skip to content

Commit c54a9eb

Browse files
authored
feat: 8.9 additions (#163)
2 parents 3cf29a7 + 720bf62 commit c54a9eb

File tree

422 files changed

+53573
-5720
lines changed

Some content is hidden

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

422 files changed

+53573
-5720
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
- name: Setup Node
1818
uses: actions/setup-node@v3
1919
with:
20-
node-version: 19
20+
node-version: 22.14.0
2121
cache: 'npm'
22-
- run: npm ci
22+
- run: yarn
2323
- run: npm run lint --if-present
2424
- run: npm run build --if-present
2525
env:

.vitepress/clientAppEnhance.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default ({ router }) => {
2+
router.afterEach(() => {
3+
// Ensure the DOM is updated before scrolling
4+
setTimeout(() => {
5+
window.scrollTo(0, 0)
6+
}, 0)
7+
})
8+
}

.vitepress/config.mts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import mainSidebar from '../content/sidebar'
44
import uiSidebar from '../content/ui/sidebar'
55
import pluginsSidebar from '../content/plugins/sidebar'
66
import nav from './nav'
7-
import './theme/cliLanguage'
7+
import './clientAppEnhance';
8+
// import './theme/cliLanguage'
89
import path from 'node:path'
910
import { SiteMap } from './genSitemap.mjs'
1011

@@ -71,6 +72,7 @@ export default defineConfig({
7172
},
7273
markdown: {
7374
headers: true,
75+
theme: "github-dark"
7476
},
7577
async transformPageData(pageData, { siteConfig }) {
7678
// const contributors = await githubAuthors.getAuthorsForFilePath(

.vitepress/theme/cliLanguage.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// https://mysticmind.dev/vitepress-fenced-code-block-syntax-highlighting-quirks-with-net-or-other-languages
2-
import { BUNDLED_LANGUAGES } from "shiki";
3-
import cliLanguageGrammar from "./shiki/cli.tmLanguage.json";
2+
import { bundledLanguages } from 'shiki'
3+
import cliLanguageGrammar from './shiki/cli.tmLanguage.json'
44

5-
BUNDLED_LANGUAGES.push({
6-
id: "cli",
7-
scopeName: "source.cli",
8-
// @ts-ignore
5+
bundledLanguages['cli'] = {
6+
id: 'cli',
7+
scopeName: 'source.cli',
98
grammar: cliLanguageGrammar,
10-
});
9+
}
10+
// bundledLanguages.push()
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

content/best-practices/ios-tips.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let applePayController: PKPaymentAuthorizationViewController
1818

1919
applePayController =
2020
PKPaymentAuthorizationViewController.alloc().initWithPaymentRequest(
21-
paymentRequest
21+
paymentRequest,
2222
)
2323
applePayController.delegate =
2424
PKPaymentAuthorizationViewControllerDelegateImpl.initWithOwner(this)
@@ -32,7 +32,7 @@ let applePayControllerDelegate: PKPaymentAuthorizationViewControllerDelegateImpl
3232

3333
applePayController =
3434
PKPaymentAuthorizationViewController.alloc().initWithPaymentRequest(
35-
paymentRequest
35+
paymentRequest,
3636
)
3737
applePayControllerDelegate =
3838
PKPaymentAuthorizationViewControllerDelegateImpl.initWithOwner(this)

content/best-practices/native-class.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ You can use setup methods in this case to mitigate any cross compilation issue,
2929
```ts
3030
let customClass
3131
function setupCustomClass() {
32-
if (global.isAndroid) {
32+
if (__ANDROID__) {
3333
@NativeClass()
3434
class CustomClass extends android.view.View {}
3535
customClass = CustomClass
@@ -44,7 +44,7 @@ setupCustomClass()
4444
const customClassInstance = new customClass() // can handle different platform args with ternary if needed
4545
```
4646

47-
The `global.isAndroid` conditional will get removed when building the app for iOS so your compiled code is clean and isolated while allowing you to handle in a single file.
47+
The `__ANDROID__` macro will get removed when building the app for iOS so your compiled code is clean and isolated while allowing you to handle in a single file.
4848

4949
## When exported from a file and used elsewhere
5050

content/best-practices/platform-file-split-or-not.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The advent of tree shaking and webpack builds does away with quite a bit of worr
2828

2929
## Conditional with tree shaking
3030

31-
When speaking of tree shaking ever since NativeScript 7, you've been able to use `global.isAndroid` or `global.isIOS` and anytime those are used as conditional splits in your code, only the applicable code for the platform that's being built would actually end up in your compiled code alleviating a lot of concern here.
31+
When speaking of tree shaking ever since NativeScript 7, you've been able to use `__ANDROID__` or `global.isIOS` and anytime those are used as conditional splits in your code, only the applicable code for the platform that's being built would actually end up in your compiled code alleviating a lot of concern here.
3232

3333
## Future maintenance
3434

content/configuration/nativescript.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,11 @@ ios.SPMPackages: Array<{
371371
libs: Array<string>;
372372
repositoryURL: string;
373373
version: string;
374+
/**
375+
* (8.9+) If you have more targets (like widgets for example),
376+
* you can list their names here to include the Swift Package with them.
377+
*/
378+
targets?: string[];
374379
}>
375380
```
376381

@@ -392,6 +397,63 @@ ios: {
392397
}
393398
```
394399

400+
### ios.NativeSource
401+
402+
::: tip
403+
404+
NativeSource config option is available in `nativescript@8.9.0` or newer.
405+
406+
:::
407+
408+
```ts
409+
ios.NativeSource: Array<{
410+
name: string;
411+
path: string;
412+
}>
413+
```
414+
415+
Include any native source code from anywhere in the project (or workspace). Glob patterns are fully supported.
416+
417+
#### Example
418+
419+
- Include any `.swift` files anywhere within the project `src` directory:
420+
421+
```ts
422+
// ...
423+
ios: {
424+
NativeSource: [
425+
{
426+
name: 'ProjectPlatformSrc',
427+
path: './src/**/*.swift'
428+
}
429+
],
430+
}
431+
```
432+
433+
This will create a file reference folder named `ProjectPlatformSrc` within the generated Xcode project containing any .swift files found anywhere within the project `src` directory.
434+
435+
- Include any `.swift` files anywhere within the project `src` directory, including any (Swift, Obj-C impl/headers, as well as any module.modulemap files) within a workspace `packages` or `libs` dir:
436+
437+
```ts
438+
// ...
439+
ios: {
440+
NativeSource: [
441+
{
442+
name: 'ProjectPlatformSrc',
443+
path: './src/**/*.swift'
444+
},
445+
{
446+
name: 'Auth',
447+
path: '../../packages/**/*.{swift,m,h,modulemap}'
448+
},
449+
{
450+
name: 'Purchasing',
451+
path: '../../libs/**/*.{swift,m,h,modulemap}'
452+
}
453+
],
454+
}
455+
```
456+
395457
## Hooks Configuration Reference
396458

397459
```ts

content/configuration/webpack.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Add file replacement rules. For source files (`.js` and `.ts`) this will add a n
4949

5050
Example:
5151

52-
```cli
52+
```bash
5353
--env.replace=./src/environments/environment.ts:./src/environments/environment.prod.ts
5454
```
5555

@@ -324,7 +324,7 @@ module.exports = (env) => {
324324
config.get('externals').concat([
325325
// add your own externals
326326
'some-external-dependency',
327-
])
327+
]),
328328
)
329329
})
330330

@@ -380,7 +380,7 @@ module.exports = (env) => {
380380

381381
To change an existing rule, it's useful to know how it has been set up first:
382382

383-
```cli
383+
```bash
384384
ns prepare android|ios --env.verbose
385385
# Note: we plan to add a separate command to just print the internal config
386386
```
@@ -518,7 +518,7 @@ module.exports = (env) => {
518518
'ignoreWarnings',
519519
(config.get('ignoreWarnings') || []).concat([
520520
/a regex that matches the warning to suppress/,
521-
])
521+
]),
522522
)
523523
})
524524

@@ -577,7 +577,7 @@ module.exports = (webpack) => {
577577
.test(/\.something$/)
578578
.use('something-loader')
579579
.loader('something-loader')
580-
} /*, options */
580+
} /*, options */,
581581
)
582582
}
583583
```
@@ -641,7 +641,7 @@ webpack.chainWebpack(
641641
(config, env) => {
642642
config.set('somethingThatShouldBeSetLast', true)
643643
},
644-
{ order: 10 }
644+
{ order: 10 },
645645
)
646646
```
647647

content/core/application.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if (isAndroid) {
4747
const androidApp: AndroidApplication = Application.android
4848

4949
androidApp.unregisterBroadcastReceiver(
50-
android.content.Intent.ACTION_BATTERY_CHANGED
50+
android.content.Intent.ACTION_BATTERY_CHANGED,
5151
)
5252
}
5353
```
@@ -76,7 +76,7 @@ To add an iOS notification observer, follow the steps below:
7676
UIDeviceOrientationDidChangeNotification,
7777
(notification: NSNotification) => {
7878
//Handle the notification
79-
}
79+
},
8080
)
8181
```
8282

@@ -89,7 +89,7 @@ To remove a notification observer, use the `removeNotificationObserver` method o
8989
```ts
9090
iOSApp.removeNotificationObserver(
9191
observer,
92-
UIDeviceBatteryStateDidChangeNotification
92+
UIDeviceBatteryStateDidChangeNotification,
9393
)
9494
```
9595

@@ -350,7 +350,7 @@ const MyDelegate = (function (_super) {
350350
}
351351
MyDelegate.prototype.applicationDidFinishLaunchingWithOptions = function (
352352
application,
353-
launchOptions
353+
launchOptions,
354354
) {
355355
console.log('applicationWillFinishLaunchingWithOptions: ' + launchOptions)
356356
return true
@@ -372,7 +372,7 @@ class MyDelegate extends UIResponder implements UIApplicationDelegate {
372372

373373
applicationDidFinishLaunchingWithOptions(
374374
application: UIApplication,
375-
launchOptions: NSDictionary<string, any>
375+
launchOptions: NSDictionary<string, any>,
376376
): boolean {
377377
console.log('applicationWillFinishLaunchingWithOptions: ' + launchOptions)
378378

content/core/http.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Http.getString('https://httpbin.org/get').then(
1717
(result: string) => {
1818
// do something with the string response
1919
},
20-
(e) => {}
20+
(e) => {},
2121
)
2222
```
2323

@@ -30,7 +30,7 @@ Http.getJSON('https://httpbin.org/get').then(
3030
(result) => {
3131
console.log(result)
3232
},
33-
(e) => {}
33+
(e) => {},
3434
)
3535
```
3636

@@ -40,12 +40,12 @@ Use the [getFile()](#getfile) method for a GET request with a response as a [Fil
4040

4141
```ts
4242
Http.getFile(
43-
'https://art.nativescript.org/logo/export/NativeScript_Logo_Wide_White_Blue_Rounded_Blue.png'
43+
'https://art.nativescript.org/logo/export/NativeScript_Logo_Wide_White_Blue_Rounded_Blue.png',
4444
).then(
4545
(resultFile: File) => {
4646
// The returned result will be File object
4747
},
48-
(e) => {}
48+
(e) => {},
4949
)
5050
```
5151

@@ -56,7 +56,7 @@ Use the [getImage()](#getimage) method for a GET request with a response as an i
5656
```ts
5757
Http.getImage('https://httpbin.org/image/jpeg').then(
5858
(res: ImageSource) => {},
59-
(e) => {}
59+
(e) => {},
6060
)
6161
```
6262

@@ -83,7 +83,7 @@ Http.request({
8383
},
8484
(e) => {
8585
// error
86-
}
86+
},
8787
)
8888
```
8989

content/core/image-source.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const color = new Color('black')
5858
const imageSource: ImageSource = ImageSource.fromFontIconCodeSync(
5959
'\uf004',
6060
font,
61-
color
61+
color,
6262
)
6363
```
6464
@@ -206,7 +206,7 @@ Create an ImageSource from the specified local file or resource (if specified wi
206206
const imageSource: ImageSource = ImageSource.fromFontIconCodeSync(
207207
source,
208208
font,
209-
color
209+
color,
210210
)
211211
```
212212

content/core/utils.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ To verify if a path is valid resource or local file path, use the [isFileOrResou
1212

1313
```ts
1414
const isPathValid: boolean = Utils.isFileOrResourcePath(
15-
'https://nativescript.org/'
15+
'https://nativescript.org/',
1616
) // false
1717

1818
// or
@@ -612,7 +612,7 @@ Gets the string id from a given resource name.
612612
```ts
613613
const paletteColor: number = Utils.android.resources.getPaletteColor(
614614
resourceName,
615-
Utils.android.getApplicationContext()
615+
Utils.android.getApplicationContext(),
616616
)
617617
```
618618

0 commit comments

Comments
 (0)