Skip to content

Commit 02fa830

Browse files
authored
feat: visionOS, spm (#142)
1 parent d9ab766 commit 02fa830

836 files changed

Lines changed: 119298 additions & 40320 deletions

File tree

Some content is hidden

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

CanvasNative.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Pod::Spec.new do |s|
1313

1414
s.author = { "Osei Fortune" => "fortune.osei@yahoo.com" }
1515

16-
s.platform = :ios, "13.0"
16+
s.platforms = { :ios => "13.0", :visionos => "1.0" }
1717

1818
s.source = { :git => "https://github.com/nativescript/canvas.git", :tag => "#{s.version}" }
1919

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ canvas-webgl = { path = "./crates/canvas-webgl" }
7474
canvas-svg = { path = "./crates/canvas-svg" }
7575
gl-bindings = { path = "./crates/gl-bindings" }
7676
canvas-c = { path = "./crates/canvas-c" }
77-
skia-safe = { version = "0.97.0", features = ["textlayout"] }
77+
skia-safe = { git = "https://github.com/triniwiz/rust-skia", rev = "d4c4011", features = ["textlayout"] }
7878
itertools = "0.14.0"
7979
ustr = "1.1.0"
8080
wgpu-core = { git = "https://github.com/triniwiz/wgpu", rev = "7e0f39f", features = ["wgsl"] }

Makefile

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
ARCHS_IOS = x86_64-apple-ios aarch64-apple-ios aarch64-apple-ios-sim
2+
ARCHS_VISIONOS = aarch64-apple-visionos aarch64-apple-visionos-sim
23
ARCHS_ANDROID = i686-linux-android x86_64-linux-android aarch64-linux-android armv7-linux-androideabi
34

45
XCFRAMEWORK = CanvasNative.xcframework
@@ -8,17 +9,22 @@ all: GENERATE_HEADERS ios android
89

910
ios: $(XCFRAMEWORK)
1011

12+
visionos: $(ARCHS_VISIONOS)
13+
1114
android: GENERATE_ANDROID
1215

1316
ios-svg: GENERATE_IOS_SVG
1417

18+
visionos-svg: GENERATE_VISIONOS_SVG
19+
20+
svg: GENERATE_IOS_SVG GENERATE_VISIONOS_SVG
21+
1522
android-svg: GENERATE_ANDROID_SVG
1623

1724
.PHONY: GENERATE_HEADERS
1825
GENERATE_HEADERS:
1926
./tools/scripts/build-headers.sh
2027

21-
# --- iOS builds ---
2228
.PHONY: $(ARCHS_IOS)
2329
$(ARCHS_IOS): %:
2430
RUSTFLAGS="-Zlocation-detail=none -Zunstable-options -Cpanic=immediate-abort" \
@@ -27,15 +33,19 @@ $(ARCHS_IOS): %:
2733

2834
$(XCFRAMEWORK): $(ARCHS_IOS)
2935

30-
# --- Android builds ---
36+
.PHONY: $(ARCHS_VISIONOS)
37+
$(ARCHS_VISIONOS): %:
38+
RUSTFLAGS="-Zlocation-detail=none -Zunstable-options -Cpanic=immediate-abort" \
39+
cargo +nightly build -Z build-std='std,panic_abort' \
40+
--target $@ --release -p canvas-ios
41+
3142
.PHONY: $(ARCHS_ANDROID)
3243
$(ARCHS_ANDROID): %:
3344
./tools/scripts/build-android.sh $@
3445

3546
.PHONY: GENERATE_ANDROID
3647
GENERATE_ANDROID: $(ARCHS_ANDROID)
3748

38-
# --- iOS SVG builds ---
3949
.PHONY: $(addsuffix _svg,$(ARCHS_IOS))
4050
$(addsuffix _svg,$(ARCHS_IOS)): %_svg:
4151
RUSTFLAGS="-Zlocation-detail=none -Zunstable-options -Cpanic=immediate-abort" \
@@ -45,15 +55,24 @@ $(addsuffix _svg,$(ARCHS_IOS)): %_svg:
4555
.PHONY: GENERATE_IOS_SVG
4656
GENERATE_IOS_SVG: $(addsuffix _svg,$(ARCHS_IOS))
4757

48-
# --- Android SVG builds ---
58+
.PHONY: $(addsuffix _svg,$(ARCHS_VISIONOS))
59+
$(addsuffix _svg,$(ARCHS_VISIONOS)): %_svg:
60+
RUSTFLAGS="-Zlocation-detail=none -Zunstable-options -Cpanic=immediate-abort" \
61+
cargo +nightly build -Z build-std='std,panic_abort' \
62+
--target $* --release -p canvas-svg-ios
63+
64+
.PHONY: GENERATE_VISIONOS_SVG
65+
GENERATE_VISIONOS_SVG: $(addsuffix _svg,$(ARCHS_VISIONOS))
66+
67+
.PHONY: ios-svg visionos-svg svg
68+
4969
.PHONY: $(addsuffix _svg,$(ARCHS_ANDROID))
5070
$(addsuffix _svg,$(ARCHS_ANDROID)): %_svg:
5171
./tools/scripts/build-svg-android.sh $* svg
5272

5373
.PHONY: GENERATE_ANDROID_SVG
5474
GENERATE_ANDROID_SVG: $(addsuffix _svg,$(ARCHS_ANDROID))
5575

56-
# --- Debug targets ---
5776
.PHONY: ios_debug
5877
ios_debug: $(addsuffix _debug,$(ARCHS_IOS))
5978

@@ -64,11 +83,17 @@ android_debug: $(addsuffix _debug,$(ARCHS_ANDROID))
6483
$(addsuffix _debug,$(ARCHS_IOS)): %_debug:
6584
cargo +nightly build --target $* -p canvas-ios
6685

86+
.PHONY: visionos_debug
87+
visionos_debug: $(addsuffix _debug,$(ARCHS_VISIONOS))
88+
89+
.PHONY: $(addsuffix _debug,$(ARCHS_VISIONOS))
90+
$(addsuffix _debug,$(ARCHS_VISIONOS)): %_debug:
91+
cargo +nightly build -Z build-std='std,panic_abort' --target $* -p canvas-ios
92+
6793
.PHONY: $(addsuffix _debug,$(ARCHS_ANDROID))
6894
$(addsuffix _debug,$(ARCHS_ANDROID)): %_debug:
6995
./tools/scripts/build-android.sh $* debug
7096

71-
# --- Clean ---
7297
.PHONY: clean
7398
clean:
7499
rm -rf target

NativeScript.podspec

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Pod::Spec.new do |s|
2+
s.name = "NativeScript"
3+
s.version = '1.0.0'
4+
s.summary = "V8 + NativeScript runtime headers for canvas and audio-context"
5+
s.license = "MIT"
6+
7+
s.authors = "Osei Fortune"
8+
s.homepage = "https://github.com/NativeScript/canvas"
9+
s.platforms = { :ios => "12.0", :visionos => "1.0" }
10+
11+
# Both canvas and audio-context can depend on this pod from the same repo:
12+
# pod 'NativeScript', :git => 'https://github.com/NativeScript/canvas.git', :tag => 'v1.0.0'
13+
s.source = { :git => "https://github.com/NativeScript/canvas.git", :tag => "v#{s.version}" }
14+
s.cocoapods_version = ">= 1.10.1"
15+
16+
# Headers-only — the NativeScript.xcframework binary is provided by the
17+
# NativeScript runtime at app build time, not by this pod.
18+
s.source_files = "nativescript-v8/Headers/**/*.h"
19+
s.header_mappings_dir = "nativescript-v8/Headers"
20+
s.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(inherited) "${PODS_ROOT}/Headers/Public/NativeScript"' }
21+
end

Package.swift

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
1-
// swift-tools-version:5.3
2-
// The swift-tools-version declares the minimum version of Swift required to build this package.
3-
1+
// swift-tools-version:5.9
42
import PackageDescription
53

64
let package = Package(
75
name: "CanvasNative",
6+
platforms: [.iOS(.v12), .visionOS(.v1)],
87
products: [
9-
// Products define the executables and libraries a package produces, and make them visible to other packages.
10-
.library(
11-
name: "CanvasNative",
12-
targets: ["CanvasNative"]),
13-
],
14-
dependencies: [
15-
// Dependencies declare other packages that this package depends on.
16-
// .package(url: /* package url */, from: "1.0.0"),
8+
.library(name: "NativeScriptV8", targets: ["NativeScriptV8"]),
179
],
1810
targets: [
19-
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
20-
// Targets can depend on other targets in this package, and on products in packages this package depends on.
2111
.target(
22-
name: "CanvasNative",
23-
dependencies: []),
24-
.testTarget(
25-
name: "CanvasNativeTests",
26-
dependencies: ["CanvasNative"]),
12+
name: "NativeScriptV8",
13+
path: "nativescript-v8",
14+
sources: ["Sources"],
15+
publicHeadersPath: "Headers"
16+
),
2717
]
2818
)

apps/demo/nativescript.config.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@ export default {
1010
},
1111
appPath: 'src',
1212
ios: {
13-
discardUncaughtJsExceptions: false
13+
discardUncaughtJsExceptions: false,
14+
SPMPackages: [
15+
{
16+
name: 'CanvasNative',
17+
libs: ['NativeScriptV8'],
18+
path: '../../nativescript-v8',
19+
},
20+
],
1421
},
1522
cli: {
16-
packageManager: 'npm'
17-
}
23+
packageManager: 'npm',
24+
},
1825
} as NativeScriptConfig;

apps/demo/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@nativescript/canvas-polyfill": "file:../../packages/canvas-polyfill",
1515
"@nativescript/canvas-svg": "file:../../packages/canvas-svg",
1616
"@nativescript/canvas-three": "file:../../packages/canvas-three",
17-
"@nativescript/core": "file:../../node_modules/@nativescript/core",
17+
"@nativescript/core": "9.0.20",
1818
"@pixi-essentials/svg": "file:../../node_modules/@pixi-essentials/svg",
1919
"babylonjs": "file:../../node_modules/babylonjs",
2020
"babylonjs-materials": "file:../../node_modules/babylonjs-materials",
@@ -35,6 +35,6 @@
3535
"@nativescript/android": "~8.9.0",
3636
"@nativescript/devtools": "~0.0.1",
3737
"@nativescript/ios": "~8.9.0",
38-
"@nativescript/visionos": "~8.9.0"
38+
"@nativescript/visionos": "~9.0.1"
3939
}
4040
}

apps/demo/src/app-root.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
</Frame>
33
<!-- <Frame defaultPage="plugin-demos/canvas-three">
44
</Frame> -->
5+
6+
<!-- <Frame defaultPage="plugin-demos/canvas">
7+
</Frame> -->

apps/demo/src/app.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,31 @@ import { Canvas } from '@nativescript/canvas';
99
// const canvas = new Canvas();
1010
// }
1111

12+
const font = new FontFace('Serifa-Bold', 'url(~/fonts/Serifa-Bold.otf)', {
13+
weight: 'bold',
14+
});
15+
16+
document.fonts.add(font);
17+
18+
document.fonts.addEventListener('loading', (event) => {
19+
console.log('loading');
20+
});
21+
document.fonts.addEventListener('loadingerror', (event) => {
22+
console.log('loadingerror');
23+
});
24+
document.fonts.addEventListener('loadingdone', (event) => {
25+
console.log('loadingdone', event.fontfaces);
26+
});
27+
28+
document.fonts
29+
.load('12px Serifa-Bold')
30+
.then((fonts) => {
31+
console.log(document.fonts.check('12px Serifa-Bold'));
32+
})
33+
.catch(() => {
34+
console.log('error');
35+
});
36+
1237
/*
1338
1439
@@ -153,7 +178,7 @@ Application.on('launch', (args) => {
153178
//require('@nativescript/canvas-polyfill');
154179
if (__ANDROID__) {
155180
jp.wasabeef.takt.Takt.stock(Utils.android.getApplicationContext()).seat(jp.wasabeef.takt.Seat.TOP_CENTER).color(-65536);
156-
} else {
181+
} else if (__IOS__) {
157182
monitor = GDPerformanceMonitor.new();
158183
monitor.startMonitoringWithConfiguration((label) => {
159184
label.backgroundColor = UIColor.blackColor;
27.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)