Skip to content

Commit

Permalink
chore: v2 final (#120)
Browse files Browse the repository at this point in the history
* chore: clean up

* fix: c2d scaling

fix: c2d to webgl drawing
chore: replace image asset lib

* fix: texImage2d  & texImage3d using alt image types

* chore: bump

* fix: image handling

* fix: scaling

* chore: remove autoScale

* chore: updates

* chore: updates

* fix(pixi): set global after extension

* chore: bump

* chore: updates

fixes: svg crash

* chore: improve svg handling

* chore: improve svg rendering

* feat: render svg directly in 2d and 3d context

* chore: updates

* chore: updates

* chore: move crates to root

* feat: init webgpu

* chore: use webgpu-core

* feat(webgpu): texture

* chore: updates

* feat: GPUCommandEncoder

* feat: GPUQueue

* feat: GPURenderBundle

* feat: GPURenderPass

* chore: clean up

* feat: GPURenderPipeline

* chore: updates

* feat: updates

* chore: updates

* chore: updates

* chore: updates

* chore: updates

* chore: bump wgpu-core

* chore: working demos

* chore: updates

* chore: webgpu.0

* chore: webgpu.1

* chore: refactor (#125)

* chore: webgpu.11 (#126)

* chore: refactor

* chore: updates

* chore: updates

* chore: render direct

* chore: updates

* chore: webgpu.2

* chore: config

* chore: webgpu.4

* chore: ci

* chore: ci targets

* chore: ci

* chore: ci

* fix: ci

* fix: ci

* chore: cii

* chore: ci

* chore: ci

* chore: ci

* chore: ci

* chore: ci

* chore: ci

* fix: ci

* chore: ci

* chore: ci

* chore: ci

* chore: ci

* chore: ci

* chore: webgpu.5

* chore: cleanup with TS 5.5

* chore: webgpu.6

* chore: webgpu.7

* chore: webgpu.8

* chore: webgpu.9

* chore: webgpu.11

---------

Co-authored-by: Nathan Walker <[email protected]>

* chore: webgpu.12

* fix: android default limits

* chore: webgpu.14

* chore: webgpu.15

---------

Co-authored-by: Nathan Walker <[email protected]>
  • Loading branch information
triniwiz and NathanWalker authored Aug 22, 2024
1 parent 5b3672d commit 9a5723f
Show file tree
Hide file tree
Showing 1,108 changed files with 164,068 additions and 107,138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ rustflags = [
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
"-C", "target-cpu=native",
"-C", "panic=abort"
]

Expand Down
18 changes: 12 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nrwl/nx"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nrwl/nx/enforce-module-boundaries": [
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
Expand All @@ -23,13 +23,19 @@
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier", "plugin:@nrwl/nx/typescript"],
"rules": {}
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier", "plugin:@nx/typescript"],
"rules": {
"@typescript-eslint/no-extra-semi": "error",
"no-extra-semi": "off"
}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nrwl/nx/javascript"],
"rules": {}
"extends": ["plugin:@nx/javascript"],
"rules": {
"@typescript-eslint/no-extra-semi": "error",
"no-extra-semi": "off"
}
},
{
"files": ["references.d.ts"],
Expand Down
254 changes: 254 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
name: Canvas Native
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

env:
NPM_TAG: "pr"
EMULATOR_NAME: "runtime-emu"
NDK_VERSION: r23c
ANDROID_API: 29
ANDROID_ABI: x86_64
NDK_ARCH: linux
CARGO_TERM_COLOR: always
NDK_HOST: linux
XCODE_VERSION: "^15.0"
NPM_PACKAGES: canvas,canvas-babylon,canvas-media,canvas-phaser,canvas-phaser-ce,canvas-pixi,canvas-polyfill,canvas-three,canvas-svg

jobs:
android:
name: Android Build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Use Rust nightly
run: |
rustup default nightly
- name: Install Rust Component rust-src
run: |
rustup component add --toolchain nightly rust-src
- name: 'Install Rust target i686-linux-android'
shell: bash
run: |
rustup target add i686-linux-android
- name: 'Install Rust target x86_64-linux-android'
shell: bash
run: |
rustup target add x86_64-linux-android
- name: 'Install Rust target armv7-linux-androideabi'
shell: bash
run: |
rustup target add armv7-linux-androideabi
- name: 'Install Rust target aarch64-linux-android'
shell: bash
run: |
rustup target add aarch64-linux-android
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: "https://registry.npmjs.org"
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
cache: gradle
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Setup NDK
run: |
echo "y" | sdkmanager "cmake;3.6.4111459"
wget https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-$NDK_ARCH.zip
chmod +x android-ndk-$NDK_VERSION-$NDK_ARCH.zip
unzip -q android-ndk-$NDK_VERSION-$NDK_ARCH.zip
rm -rf android-ndk-$NDK_VERSION-$NDK_ARCH.zip
export ANDROID_NDK_HOME=`pwd`/android-ndk-$NDK_VERSION
export ANDROID_NDK_ROOT=$ANDROID_NDK_HOME
export ANDROID_NDK=$ANDROID_NDK_HOME
export NDK_PATH=$ANDROID_NDK
export CC_armv7_linux_androideabi=armv7a-linux-androideabi21-clang
export CXX_armv7_linux_androideabi=armv7a-linux-androideabi21-clang++
export AR_armv7_linux_androideabi=llvm-ar
export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=armv7a-linux-androideabi21-clang
export CC_aarch64_linux_android=aarch64-linux-android21-clang
export CXX_aarch64_linux_android=aarch64-linux-android21-clang++
export AR_aarch64_linux_android=llvm-ar
export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=aarch64-linux-android21-clang
export CC_i686_linux_android=i686-linux-android21-clang
export CXX_i686_linux_android=i686-linux-android21-clang++
export AR_i686_linux_android=llvm-ar
export CARGO_TARGET_I686_LINUX_ANDROID_LINKER=i686-linux-android21-clang
export CC_x86_64_linux_android=x86_64-linux-android21-clang
export CXX_x86_64_linux_android=x86_64-linux-android21-clang++
export AR_x86_64_linux_android=llvm-ar
export CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=x86_64-linux-android21-clang
echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME} >> $GITHUB_ENV
echo ANDROID_NDK_ROOT=${ANDROID_NDK_ROOT} >> $GITHUB_ENV
echo ANDROID_NDK=${ANDROID_NDK} >> $GITHUB_ENV
echo NDK_PATH=${NDK_PATH} >> $GITHUB_ENV
echo CC_armv7_linux_androideabi=${CC_armv7_linux_androideabi} >> $GITHUB_ENV
echo CXX_armv7_linux_androideabi=${CXX_armv7_linux_androideabi} >> $GITHUB_ENV
echo AR_armv7_linux_androideabi=${AR_armv7_linux_androideabi} >> $GITHUB_ENV
echo CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER=${CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER} >> $GITHUB_ENV
echo CC_aarch64_linux_android=${CC_aarch64_linux_android} >> $GITHUB_ENV
echo CXX_aarch64_linux_android=${CXX_aarch64_linux_android} >> $GITHUB_ENV
echo AR_aarch64_linux_android=${AR_aarch64_linux_android} >> $GITHUB_ENV
echo CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER=${CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER} >> $GITHUB_ENV
echo CC_i686_linux_android=${CC_i686_linux_android} >> $GITHUB_ENV
echo CXX_i686_linux_android=${CXX_i686_linux_android} >> $GITHUB_ENV
echo AR_i686_linux_android=${AR_i686_linux_android} >> $GITHUB_ENV
echo CARGO_TARGET_I686_LINUX_ANDROID_LINKER=${CARGO_TARGET_I686_LINUX_ANDROID_LINKER} >> $GITHUB_ENV
echo CC_x86_64_linux_android=${CC_x86_64_linux_android} >> $GITHUB_ENV
echo CXX_x86_64_linux_android=${CXX_x86_64_linux_android} >> $GITHUB_ENV
echo AR_x86_64_linux_android=${AR_x86_64_linux_android} >> $GITHUB_ENV
echo CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER=${CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER} >> $GITHUB_ENV
echo ${ANDROID_NDK_HOME} >> $GITHUB_PATH
echo ${ANDROID_NDK}/toolchains/llvm/prebuilt/${NDK_ARCH}-x86_64/bin >> $GITHUB_PATH
echo ${CC_armv7_linux_androideabi} >> $GITHUB_PATH
echo ${CXX_armv7_linux_androideabi} >> $GITHUB_PATH
echo ${AR_armv7_linux_androideabi} >> $GITHUB_PATH
echo ${CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER} >> $GITHUB_PATH
echo ${CC_aarch64_linux_android} >> $GITHUB_PATH
echo ${CXX_aarch64_linux_android} >> $GITHUB_PATH
echo ${AR_aarch64_linux_android} >> $GITHUB_PATH
echo ${CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER} >> $GITHUB_PATH
echo ${CC_i686_linux_android} >> $GITHUB_PATH
echo ${CXX_i686_linux_android} >> $GITHUB_PATH
echo ${AR_i686_linux_android} >> $GITHUB_PATH
echo ${CARGO_TARGET_I686_LINUX_ANDROID_LINKER} >> $GITHUB_PATH
echo ${CC_x86_64_linux_android} >> $GITHUB_PATH
echo ${CXX_x86_64_linux_android} >> $GITHUB_PATH
echo ${AR_x86_64_linux_android} >> $GITHUB_PATH
echo ${CARGO_TARGET_X86_64_LINUX_ANDROID_LINKER} >> $GITHUB_PATH
- name: Install Build Tools
run: |
sudo apt-get install pkg-config libssl-dev -y
- name: Build Canvas Native
run: |
make android
ios:
name: iOS Build
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Use Rust nightly
run: |
rustup default nightly
- name: Install Rust Component rust-src
run: |
rustup component add --toolchain nightly rust-src
- name: 'Install Rust target x86_64-apple-ios'
shell: bash
run: |
rustup target add x86_64-apple-ios
- name: 'Install Rust target aarch64-apple-ios'
shell: bash
run: |
rustup target add aarch64-apple-ios
- name: 'Install Rust target aarch64-apple-ios-sim'
shell: bash
run: |
rustup target add aarch64-apple-ios-sim
- name: Install cbindgen
run: |
cargo install --force cbindgen
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3"

- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: "https://registry.npmjs.org"
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{env.XCODE_VERSION}}
- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3"
- name: Install Dependencies
run: |
npm install
python3 -m pip install --upgrade pip six
brew install cmake
[ ! -f /usr/local/bin/cmake ] && ln -s /usr/local/bin/cmake $(which cmake) || true
- name: Build
run: |
make ios
npm run build.canvas.ios.framework.release
npm:
name: Npm Build
runs-on: ubuntu-22.04
needs: [android, ios]
outputs:
npm_version: ${{ steps.npm_version_output.outputs.NPM_VERSION }}
npm_tag: ${{ steps.npm_version_output.outputs.NPM_TAG }}
steps:
- uses: actions/setup-node@v4
with:
node-version: 22
registry-url: "https://registry.npmjs.org"

- name: Generate Version
run: |
echo NPM_VERSION=$(node -e "console.log(require('./packages/canvas/package.json').version);")-$NPM_TAG-$(date +"%m-%d-%Y")-$GITHUB_RUN_ID >> $GITHUB_ENV
- name: Bump canvas
working-directory: packages/canvas
run: npm version $NPM_VERSION

- name: Bump canvas-babylon
working-directory: packages/canvas-babylon
run: npm version $NPM_VERSION

- name: Bump canvas-media
working-directory: packages/canvas-media
run: npm version $NPM_VERSION

- name: Bump canvas-phaser
working-directory: packages/canvas-phaser
run: npm version $NPM_VERSION

- name: Bump canvas-phaser-ce
working-directory: packages/canvas-phaser-ce
run: npm version $NPM_VERSION

- name: Bump canvas-pixi
working-directory: packages/canvas-pixi
run: npm version $NPM_VERSION

- name: Bump canvas-polyfill
working-directory: packages/canvas-polyfill
run: npm version $NPM_VERSION

- name: Bump canvas-three
working-directory: packages/canvas-three
run: npm version $NPM_VERSION

- name: Bump canvas-svg
working-directory: packages/canvas-svg
run: npm version $NPM_VERSION

- name: Build all packages
run: npx nx run canvas:build.all

- name: Publish @nativescript/core
env:
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ../../.npmrc
echo "Publishing @nativescript/canvas@$NPM_VERSION to NPM with tag $NPM_TAG..."
npm run publish-packages --name $NPM_PACKAGES --verify true --version $NPM_VERSION
15 changes: 0 additions & 15 deletions .github/workflows/rust.yml

This file was deleted.

12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,14 @@ Thumbs.db
*.tgz
packages/**/angular/dist
apps/demo/times.html
rust-skia
rust-skia

/target
/**/*.rs.bk
/Cargo.lock

**/canvas-native/target
**/.fingerprint
.build
.nx/cache
.nx/workspace-data
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
# . "$(dirname "$0")/_/husky.sh"

npx lint-staged --allow-empty
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
/dist
/coverage
native-src

/.nx/cache
/.nx/workspace-data
Loading

0 comments on commit 9a5723f

Please sign in to comment.