Skip to content

Commit 0734412

Browse files
committed
fix examples
1 parent 99424aa commit 0734412

File tree

12 files changed

+43
-41
lines changed

12 files changed

+43
-41
lines changed

examples/appkit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-check
22

3-
import "../packages/macos/index.js";
3+
import "@nativescript/macos-node-api";
44

55
/**
66
* @implements {NSApplicationDelegate}

examples/calayer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// @ts-check
22

3-
// import "@nativescript/macos-node-api";
4-
5-
/// <reference path="../packages/macos/types/index.d.ts" />
3+
import "@nativescript/macos-node-api";
64

75
class ApplicationDelegate extends NSObject {
86
static ObjCProtocols = [NSApplicationDelegate, NSWindowDelegate];
@@ -31,7 +29,8 @@ class ApplicationDelegate extends NSObject {
3129

3230
window.title = "NativeScript for macOS";
3331
window.delegate = this;
34-
window.styleMask = NSWindowStyleMask.Titled |
32+
window.styleMask =
33+
NSWindowStyleMask.Titled |
3534
NSWindowStyleMask.Closable |
3635
NSWindowStyleMask.Miniaturizable |
3736
NSWindowStyleMask.Resizable |
@@ -117,6 +116,7 @@ class ViewController extends NSViewController {
117116
gradientLayer.endPoint = { x: 0.5, y: 1 };
118117

119118
const nsArray = NSMutableArray.arrayWithCapacity(3);
119+
// @ts-ignore
120120
nsArray[0] = "hello world";
121121
console.log(nsArray);
122122

examples/gamecontroller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// @ts-check
22

33
import "@nativescript/macos-node-api";
4-
import "@nativescript/macos-node-api/GameController";
5-
import "@nativescript/macos-node-api/CoreFoundation";
4+
import "@nativescript/macos-node-api/GameController.d.ts";
5+
import "@nativescript/macos-node-api/CoreFoundation.d.ts";
66

77
objc.import("GameController");
88

examples/metal_compute.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22

33
import "@nativescript/macos-node-api";
4-
import "@nativescript/macos-node-api/Metal";
4+
import "@nativescript/macos-node-api/Metal.d.ts";
55

66
objc.import("Metal");
77

examples/metal_graphics.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// https://developer.apple.com/documentation/metal/using_a_render_pipeline_to_render_primitives?language=objc
22

33
import "@nativescript/macos-node-api";
4-
import "@nativescript/macos-node-api/Metal";
5-
import "@nativescript/macos-node-api/MetalKit";
4+
import "@nativescript/macos-node-api/Metal.d.ts";
5+
import "@nativescript/macos-node-api/MetalKit.d.ts";
66

77
objc.import("Metal");
88
objc.import("MetalKit");
@@ -34,7 +34,8 @@ export class ApplicationDelegate extends NSObject {
3434

3535
window.title = "NativeScript for macOS";
3636
window.delegate = this;
37-
window.styleMask = NSWindowStyleMask.Titled |
37+
window.styleMask =
38+
NSWindowStyleMask.Titled |
3839
NSWindowStyleMask.Closable |
3940
NSWindowStyleMask.Miniaturizable |
4041
NSWindowStyleMask.Resizable |
@@ -218,9 +219,8 @@ fragment float4 fragmentShader(RasterizerData in [[stage_in]])
218219
const renderPassDescriptor = view.currentRenderPassDescriptor;
219220

220221
if (renderPassDescriptor !== null) {
221-
const renderEncoder = commandBuffer.renderCommandEncoderWithDescriptor(
222-
renderPassDescriptor,
223-
);
222+
const renderEncoder =
223+
commandBuffer.renderCommandEncoderWithDescriptor(renderPassDescriptor);
224224
renderEncoder.label = "MyRenderEncoder";
225225

226226
renderEncoder.setViewport({

examples/mlcompute.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22

33
import "@nativescript/macos-node-api";
4-
import "@nativescript/macos-node-api/MLCompute";
4+
import "@nativescript/macos-node-api/MLCompute.d.ts";
55

66
objc.import("MLCompute");
77

@@ -14,19 +14,19 @@ const tInput = MLCTensor.tensorWithShapeDataType(shape, MLCDataType.Float32);
1414
const tWeights = MLCTensor.tensorWithShapeRandomInitializerTypeDataType(
1515
[1, imageSize, layerSize, 1],
1616
MLCRandomInitializerType.GlorotUniform,
17-
MLCDataType.Float32
17+
MLCDataType.Float32,
1818
);
1919
const tBiases = MLCTensor.tensorWithShapeRandomInitializerTypeDataType(
2020
[1, layerSize, 1, 1],
2121
MLCRandomInitializerType.GlorotUniform,
22-
MLCDataType.Float32
22+
MLCDataType.Float32,
2323
);
2424

2525
const input = new Float32Array(imageSize * batchSize).fill(1);
2626

2727
const dataInput = MLCTensorData.dataWithBytesNoCopyLength(
2828
input,
29-
input.byteLength
29+
input.byteLength,
3030
);
3131

3232
const graph = MLCGraph.new();
@@ -38,8 +38,8 @@ const denseLayer = MLCFullyConnectedLayer.layerWithWeightsBiasesDescriptor(
3838
layerSize,
3939
imageSize,
4040
imageSize,
41-
layerSize
42-
)
41+
layerSize,
42+
),
4343
);
4444

4545
if (!denseLayer) {
@@ -59,7 +59,7 @@ inference.addInputs({ input: tInput });
5959

6060
inference.compileWithOptionsDevice(
6161
MLCGraphCompilationOptions.DebugLayers,
62-
device
62+
device,
6363
);
6464

6565
inference.executeWithInputsDataBatchSizeOptionsCompletionHandler(
@@ -68,5 +68,5 @@ inference.executeWithInputsDataBatchSizeOptionsCompletionHandler(
6868
MLCExecutionOptions.Synchronous,
6969
(output, error, time) => {
7070
console.log(output, error, time);
71-
}
71+
},
7272
);

examples/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"author": "DjDeveloperr <hey@djdev.me>",
99
"license": "MIT",
1010
"dependencies": {
11-
"popmotion": "^11.0.5",
12-
"@nativescript/macos-node-api": "file:../packages/macos"
11+
"@nativescript/macos-node-api": "*",
12+
"popmotion": "^11.0.5"
1313
}
1414
}

examples/spritekit.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// @ts-check
22

33
import "@nativescript/macos-node-api";
4-
import "@nativescript/macos-node-api/SpriteKit";
5-
import "@nativescript/macos-node-api/GameController";
6-
import "@nativescript/macos-node-api/CoreFoundation";
7-
import "@nativescript/macos-node-api/CoreGraphics";
4+
import "@nativescript/macos-node-api/SpriteKit.d.ts";
5+
import "@nativescript/macos-node-api/GameController.d.ts";
6+
import "@nativescript/macos-node-api/CoreFoundation.d.ts";
7+
import "@nativescript/macos-node-api/CoreGraphics.d.ts";
88

99
objc.import("SpriteKit");
1010
objc.import("GameController");
@@ -41,7 +41,7 @@ export class ApplicationDelegate extends NSObject {
4141
118 / 255,
4242
171 / 255,
4343
235 / 255,
44-
1
44+
1,
4545
);
4646

4747
window.acceptsMouseMovedEvents = true;
@@ -81,7 +81,7 @@ export class BattlefieldScene extends SKScene {
8181
this,
8282
"controllerDidConnect",
8383
GCControllerDidBecomeCurrentNotification,
84-
null
84+
null,
8585
);
8686
}
8787

@@ -94,7 +94,7 @@ export class BattlefieldScene extends SKScene {
9494
indicatorSize.height = indicatorHeight;
9595
this.indicator = SKSpriteNode.alloc().initWithColorSize(
9696
NSColor.colorWithSRGBRedGreenBlueAlpha(0, 1, 0, 1),
97-
indicatorSize
97+
indicatorSize,
9898
);
9999
this.indicator.position = {
100100
x: this.frame.size.width / 2,
@@ -105,7 +105,7 @@ export class BattlefieldScene extends SKScene {
105105
const heroSize = { width: 25, height: 25 };
106106
this.hero = SKSpriteNode.alloc().initWithColorSize(
107107
NSColor.colorWithSRGBRedGreenBlueAlpha(0, 0, 1, 1),
108-
heroSize
108+
heroSize,
109109
);
110110

111111
const heroPhysicsBody = SKPhysicsBody.bodyWithRectangleOfSize(heroSize);
@@ -123,7 +123,7 @@ export class BattlefieldScene extends SKScene {
123123
const villainSize = { width: 50, height: 50 };
124124
this.villain = SKSpriteNode.alloc().initWithColorSize(
125125
NSColor.colorWithSRGBRedGreenBlueAlpha(1, 0, 0, 1),
126-
villainSize
126+
villainSize,
127127
);
128128

129129
const villainPhysicsBody =
@@ -171,7 +171,7 @@ export class BattlefieldScene extends SKScene {
171171
currentPos,
172172
targetPos,
173173
deltaTime,
174-
currentRotationInRadians
174+
currentRotationInRadians,
175175
) {
176176
const xDiff = targetPos.x - currentPos.x;
177177
const yDiff = targetPos.y - currentPos.y;
@@ -200,8 +200,8 @@ export class BattlefieldScene extends SKScene {
200200
extraRotation < -180
201201
? 360 + extraRotation
202202
: extraRotation > 180
203-
? extraRotation - 360
204-
: extraRotation;
203+
? extraRotation - 360
204+
: extraRotation;
205205
const optimalEasedRotation = optimalRotation / easing;
206206
const newRotationInDegrees =
207207
(currentRotationInRadians + optimalEasedRotation) % 360;
@@ -233,14 +233,14 @@ export class BattlefieldScene extends SKScene {
233233
this.villain.position,
234234
this.hero.position,
235235
idealDeltaTime,
236-
this.villain.zRotation
236+
this.villain.zRotation,
237237
);
238238
const forHero = this.diffFn(
239239
this.heroBaseSpeed,
240240
this.hero.position,
241241
this.heroTargetPos,
242242
idealDeltaTime,
243-
this.hero.zRotation
243+
this.hero.zRotation,
244244
);
245245

246246
this.villain.zRotation = forVillain.rotation;

examples/webview.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22

33
import "@nativescript/macos-node-api";
4-
import "@nativescript/macos-node-api/WebKit";
4+
import "@nativescript/macos-node-api/WebKit.d.ts";
55

66
objc.import("WebKit");
77

@@ -32,7 +32,8 @@ export class ApplicationDelegate extends NSObject {
3232

3333
window.title = "NativeScript for macOS";
3434
window.delegate = this;
35-
window.styleMask = NSWindowStyleMask.Titled |
35+
window.styleMask =
36+
NSWindowStyleMask.Titled |
3637
NSWindowStyleMask.Closable |
3738
NSWindowStyleMask.Miniaturizable |
3839
NSWindowStyleMask.Resizable;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
},
1818
"workspaces": [
1919
"packages/*",
20+
"examples",
2021
"scripts"
2122
],
2223
"scripts": {

0 commit comments

Comments
 (0)