Skip to content

Commit 5c79dfb

Browse files
committed
work
1 parent 75d1829 commit 5c79dfb

11 files changed

Lines changed: 23 additions & 58 deletions

File tree

‎README.md‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ JavaScript land. Made using Node-API and `libffi` under the hood.
55

66
## Building
77

8-
Only macOS supported right now.
9-
108
```sh
119
deno task build-libffi
1210

@@ -15,22 +13,31 @@ deno task build macos
1513
deno task build ios-universal
1614
```
1715

18-
## Bundling sample AppKit app
16+
## Run examples
1917

2018
```sh
21-
deno task bundle # bundle app
22-
deno task open-bundle # run app
19+
node examples/foundation.js
20+
# or
21+
deno run -A examples/foundation.js
22+
23+
# ML Compute example
24+
node examples/mlcompute.js
25+
26+
# AppKit related examples
27+
node examples/appkit.js
28+
node examples/split_view.js
29+
node examples/view_controller.js
30+
node examples/spritekit.js
2331
```
2432

2533
## Notes
2634

27-
AppKit usage currently relies on struct support, which has an issue with Deno
28-
right now.
35+
Deno Node-API has an issue with `napi_get_all_property_names`.
2936

30-
So without a custom deno build from the below PR, you can't use AppKit in Deno
37+
Without a custom deno build from the below PR, you can't use AppKit in Deno
3138
(works in Node).
3239

33-
Upstream PR: https://github.com/denoland/deno/pull/19551
40+
Upstream PR: https://github.com/denoland/deno/pull/19585
3441

3542
## License
3643

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

‎deno.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"app": {
33
"name": "NativeScript for macOS",
44
"identifier": "com.nativescript.AppKit",
5-
"entryPoint": "test/spritekit.js",
5+
"entryPoint": "examples/split_view.js",
66
"assets": "./assets",
77
"icon": "./assets/NativeScript.icns",
88
"version": "0.1.0"
@@ -11,7 +11,7 @@
1111
"tasks": {
1212
"build-libffi": "deno run -A scripts/build_libffi.ts",
1313
"build": "deno run -A scripts/build.ts",
14-
"bench": "node test/main.js",
14+
"bench": "node examples/main.js",
1515
"deno": "../deno/target/release/deno run -A",
1616
"bundle": "deno run -A --unstable scripts/bundler.ts",
1717
"open-bundle": "open \"NativeScript for macOS.app\""

‎examples/foundation.js‎

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,7 @@
11
import { classes } from "../index.js";
22

3-
// const {
4-
// NSString,
5-
// } = classes;
3+
const {
4+
NSString,
5+
} = classes;
66

7-
// function measure(time) {
8-
// const before = performance.now();
9-
// NSTextAlignment.center;
10-
// const after = performance.now();
11-
// console.log(time, ((after - before) * 1000000).toFixed(2) + "ns");
12-
// }
13-
14-
// measure("first get");
15-
// measure("second get");
16-
// measure("third get");
17-
// measure("fourth get");
18-
// measure("fifth get");
19-
// measure("sixth get");
20-
21-
// console.log(NSString.stringWithUTF8String("Hello, macOS").length);
22-
23-
const { NSBundle } = classes;
24-
25-
// NSBundle.bundleWithPath("/System/Library/Frameworks/CoreML.framework").load();
26-
// NSBundle.bundleWithPath("/System/Library/Frameworks/Metal.framework").load();
27-
NSBundle.bundleWithPath("/System/Library/Frameworks/CoreFoundation.framework")
28-
.load();
29-
30-
console.log(CFAbsoluteTimeGetCurrent());
31-
const date = CFDateCreate(null, CFAbsoluteTimeGetCurrent());
32-
console.log(date);
33-
34-
// console.log(MTLCreateSystemDefaultDevice());
35-
36-
// const { MLNeuralEngineComputeDevice } = classes;
37-
38-
// console.log(Object.keys(MLNeuralEngineComputeDevice.prototype));
39-
40-
// const device = MLNeuralEngineComputeDevice.physicalDevice();
41-
42-
// console.log(device, device.totalCoreCount);
7+
console.log(NSString.stringWithUTF8String("Hello, macOS").length);
File renamed without changes.

‎examples/split_view.js‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,6 @@ export class ApplicationDelegate extends NSObject {
7676
}
7777

7878
export class Node extends NSObject {
79-
static exposedMethods = {
80-
initWithSymbolTitleChildren: {
81-
params: ["string", "string", "id"],
82-
returns: "id",
83-
},
84-
};
85-
8679
static {
8780
objc.registerClass(this);
8881
}

0 commit comments

Comments
 (0)