create-crossbind 2.0.0-beta.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +63 -0
- package/package.json +47 -0
- package/src/index.js +182 -0
- package/src/manifest.json +14 -0
- package/src/utils.js +8 -0
- package/templates/backend-nodejs-wasm/CHANGELOG.md +34 -0
- package/templates/backend-nodejs-wasm/README.md +32 -0
- package/templates/backend-nodejs-wasm/crossbind.config.mjs +14 -0
- package/templates/backend-nodejs-wasm/package.json +25 -0
- package/templates/backend-nodejs-wasm/src/index.js +5 -0
- package/templates/backend-nodejs-wasm/src/index.mjs +5 -0
- package/templates/backend-nodejs-wasm/src/native/native.cpp +9 -0
- package/templates/backend-nodejs-wasm/src/native/native.h +12 -0
- package/templates/cloud-cloudflare-worker/CHANGELOG.md +27 -0
- package/templates/cloud-cloudflare-worker/Readme.md +46 -0
- package/templates/cloud-cloudflare-worker/crossbind.config.mjs +9 -0
- package/templates/cloud-cloudflare-worker/e2e/crossbind.spec.cjs +7 -0
- package/templates/cloud-cloudflare-worker/index.js +10 -0
- package/templates/cloud-cloudflare-worker/package.json +38 -0
- package/templates/cloud-cloudflare-worker/playwright.dev.config.cjs +48 -0
- package/templates/cloud-cloudflare-worker/src/native/native.cpp +5 -0
- package/templates/cloud-cloudflare-worker/src/native/native.h +11 -0
- package/templates/cloud-cloudflare-worker/wrangler.toml +3 -0
- package/templates/lib-cmake/CHANGELOG.md +20 -0
- package/templates/lib-cmake/CMakeLists.txt +16 -0
- package/templates/lib-cmake/README.md +51 -0
- package/templates/lib-cmake/crossbind.config.js +9 -0
- package/templates/lib-cmake/package.json +16 -0
- package/templates/lib-cmake/src/native/crossbind-lib-samplebasic-cmake/samplebasiccmake.h +11 -0
- package/templates/lib-cmake/src/native/samplebasiccmake.cpp +5 -0
- package/templates/lib-prebuilt/AGENTS.md +78 -0
- package/templates/lib-prebuilt/CHANGELOG.md +20 -0
- package/templates/lib-prebuilt/README.md +81 -0
- package/templates/lib-prebuilt/crossbind-example-lib-prebuilt-matrix.podspec +21 -0
- package/templates/lib-prebuilt/crossbind.config.js +13 -0
- package/templates/lib-prebuilt/package.json +36 -0
- package/templates/lib-prebuilt/playground/Matrix.js +19 -0
- package/templates/lib-prebuilt/playground/index.html +74 -0
- package/templates/lib-prebuilt/src/native/Matrix.cpp +17 -0
- package/templates/lib-prebuilt/src/native/Matrix.h +12 -0
- package/templates/lib-source/CHANGELOG.md +20 -0
- package/templates/lib-source/README.md +51 -0
- package/templates/lib-source/crossbind.config.js +8 -0
- package/templates/lib-source/package.json +12 -0
- package/templates/lib-source/src/native/crossbind-lib-samplebasic/samplebasic.h +13 -0
- package/templates/mobile-reactnative-cli/.bundle/config +2 -0
- package/templates/mobile-reactnative-cli/.eslintrc.js +4 -0
- package/templates/mobile-reactnative-cli/.prettierrc.js +7 -0
- package/templates/mobile-reactnative-cli/AGENTS.md +89 -0
- package/templates/mobile-reactnative-cli/CHANGELOG.md +38 -0
- package/templates/mobile-reactnative-cli/Gemfile +20 -0
- package/templates/mobile-reactnative-cli/README.md +55 -0
- package/templates/mobile-reactnative-cli/__tests__/App.test.tsx +13 -0
- package/templates/mobile-reactnative-cli/android/app/build.gradle +119 -0
- package/templates/mobile-reactnative-cli/android/app/debug.keystore +0 -0
- package/templates/mobile-reactnative-cli/android/app/proguard-rules.pro +10 -0
- package/templates/mobile-reactnative-cli/android/app/src/debug/AndroidManifest.xml +9 -0
- package/templates/mobile-reactnative-cli/android/app/src/main/AndroidManifest.xml +27 -0
- package/templates/mobile-reactnative-cli/android/app/src/main/java/dev/crossbind/sampleReactNativeCLI/MainActivity.kt +22 -0
- package/templates/mobile-reactnative-cli/android/app/src/main/java/dev/crossbind/sampleReactNativeCLI/MainApplication.kt +27 -0
- package/templates/mobile-reactnative-cli/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
- package/templates/mobile-reactnative-cli/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/templates/mobile-reactnative-cli/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/templates/mobile-reactnative-cli/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/templates/mobile-reactnative-cli/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/templates/mobile-reactnative-cli/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/templates/mobile-reactnative-cli/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/templates/mobile-reactnative-cli/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/templates/mobile-reactnative-cli/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/templates/mobile-reactnative-cli/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/templates/mobile-reactnative-cli/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/templates/mobile-reactnative-cli/android/app/src/main/res/values/strings.xml +3 -0
- package/templates/mobile-reactnative-cli/android/app/src/main/res/values/styles.xml +9 -0
- package/templates/mobile-reactnative-cli/android/build.gradle +21 -0
- package/templates/mobile-reactnative-cli/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/templates/mobile-reactnative-cli/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/templates/mobile-reactnative-cli/android/gradle.properties +44 -0
- package/templates/mobile-reactnative-cli/android/gradlew +248 -0
- package/templates/mobile-reactnative-cli/android/gradlew.bat +98 -0
- package/templates/mobile-reactnative-cli/android/settings.gradle +6 -0
- package/templates/mobile-reactnative-cli/app.json +4 -0
- package/templates/mobile-reactnative-cli/babel.config.js +3 -0
- package/templates/mobile-reactnative-cli/ci/crossbind-snapshot/cache.json +12 -0
- package/templates/mobile-reactnative-cli/crossbind.config.mjs +10 -0
- package/templates/mobile-reactnative-cli/index.js +9 -0
- package/templates/mobile-reactnative-cli/ios/.xcode.env +11 -0
- package/templates/mobile-reactnative-cli/ios/Podfile +42 -0
- package/templates/mobile-reactnative-cli/ios/crossbindSampleReactNativeCLI/AppDelegate.swift +48 -0
- package/templates/mobile-reactnative-cli/ios/crossbindSampleReactNativeCLI/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/templates/mobile-reactnative-cli/ios/crossbindSampleReactNativeCLI/Images.xcassets/Contents.json +6 -0
- package/templates/mobile-reactnative-cli/ios/crossbindSampleReactNativeCLI/Info.plist +60 -0
- package/templates/mobile-reactnative-cli/ios/crossbindSampleReactNativeCLI/LaunchScreen.storyboard +47 -0
- package/templates/mobile-reactnative-cli/ios/crossbindSampleReactNativeCLI/PrivacyInfo.xcprivacy +37 -0
- package/templates/mobile-reactnative-cli/ios/crossbindSampleReactNativeCLI.xcodeproj/project.pbxproj +494 -0
- package/templates/mobile-reactnative-cli/ios/crossbindSampleReactNativeCLI.xcodeproj/xcshareddata/xcschemes/crossbindSampleReactNativeCLI.xcscheme +88 -0
- package/templates/mobile-reactnative-cli/ios/crossbindSampleReactNativeCLI.xcworkspace/contents.xcworkspacedata +10 -0
- package/templates/mobile-reactnative-cli/jest.config.js +3 -0
- package/templates/mobile-reactnative-cli/maestro.yaml +4 -0
- package/templates/mobile-reactnative-cli/metro.config.js +17 -0
- package/templates/mobile-reactnative-cli/package.json +68 -0
- package/templates/mobile-reactnative-cli/src/App.tsx +53 -0
- package/templates/mobile-reactnative-cli/src/native/native.cpp +9 -0
- package/templates/mobile-reactnative-cli/src/native/native.h +12 -0
- package/templates/mobile-reactnative-cli/tsconfig.json +16 -0
- package/templates/mobile-reactnative-expo/README.md +34 -0
- package/templates/mobile-reactnative-expo/app.json +51 -0
- package/templates/mobile-reactnative-expo/assets/expo.icon/Assets/expo-symbol 2.svg +3 -0
- package/templates/mobile-reactnative-expo/assets/expo.icon/Assets/grid.png +0 -0
- package/templates/mobile-reactnative-expo/assets/expo.icon/icon.json +40 -0
- package/templates/mobile-reactnative-expo/assets/images/android-icon-background.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/android-icon-foreground.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/android-icon-monochrome.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/expo-badge-white.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/expo-badge.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/expo-logo.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/favicon.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/icon.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/logo-glow.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/react-logo.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/react-logo@2x.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/react-logo@3x.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/splash-icon.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/tabIcons/explore.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/tabIcons/explore@2x.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/tabIcons/explore@3x.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/tabIcons/home.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/tabIcons/home@2x.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/tabIcons/home@3x.png +0 -0
- package/templates/mobile-reactnative-expo/assets/images/tutorial-web.png +0 -0
- package/templates/mobile-reactnative-expo/crossbind.config.mjs +10 -0
- package/templates/mobile-reactnative-expo/maestro.yaml +4 -0
- package/templates/mobile-reactnative-expo/metro.config.js +13 -0
- package/templates/mobile-reactnative-expo/package-lock.json +9433 -0
- package/templates/mobile-reactnative-expo/package.json +82 -0
- package/templates/mobile-reactnative-expo/scripts/reset-project.js +113 -0
- package/templates/mobile-reactnative-expo/src/app/_layout.tsx +16 -0
- package/templates/mobile-reactnative-expo/src/app/explore.tsx +181 -0
- package/templates/mobile-reactnative-expo/src/app/index.tsx +110 -0
- package/templates/mobile-reactnative-expo/src/components/animated-icon.module.css +6 -0
- package/templates/mobile-reactnative-expo/src/components/animated-icon.tsx +132 -0
- package/templates/mobile-reactnative-expo/src/components/animated-icon.web.tsx +108 -0
- package/templates/mobile-reactnative-expo/src/components/app-tabs.tsx +33 -0
- package/templates/mobile-reactnative-expo/src/components/app-tabs.web.tsx +116 -0
- package/templates/mobile-reactnative-expo/src/components/external-link.tsx +25 -0
- package/templates/mobile-reactnative-expo/src/components/hint-row.tsx +35 -0
- package/templates/mobile-reactnative-expo/src/components/themed-text.tsx +73 -0
- package/templates/mobile-reactnative-expo/src/components/themed-view.tsx +16 -0
- package/templates/mobile-reactnative-expo/src/components/ui/collapsible.tsx +65 -0
- package/templates/mobile-reactnative-expo/src/components/web-badge.tsx +44 -0
- package/templates/mobile-reactnative-expo/src/constants/theme.ts +65 -0
- package/templates/mobile-reactnative-expo/src/global.css +9 -0
- package/templates/mobile-reactnative-expo/src/hooks/use-color-scheme.ts +1 -0
- package/templates/mobile-reactnative-expo/src/hooks/use-color-scheme.web.ts +21 -0
- package/templates/mobile-reactnative-expo/src/hooks/use-theme.ts +14 -0
- package/templates/mobile-reactnative-expo/src/native/native.cpp +9 -0
- package/templates/mobile-reactnative-expo/src/native/native.h +12 -0
- package/templates/mobile-reactnative-expo/tsconfig.json +20 -0
- package/templates/web-react-rspack/CHANGELOG.md +35 -0
- package/templates/web-react-rspack/README.md +38 -0
- package/templates/web-react-rspack/crossbind.config.mjs +13 -0
- package/templates/web-react-rspack/e2e/crossbind.spec.cjs +7 -0
- package/templates/web-react-rspack/index.html +11 -0
- package/templates/web-react-rspack/package.json +44 -0
- package/templates/web-react-rspack/playwright.dev.config.cjs +48 -0
- package/templates/web-react-rspack/playwright.prod.config.cjs +52 -0
- package/templates/web-react-rspack/rspack.config.mjs +78 -0
- package/templates/web-react-rspack/src/App.css +41 -0
- package/templates/web-react-rspack/src/App.jsx +19 -0
- package/templates/web-react-rspack/src/index.css +70 -0
- package/templates/web-react-rspack/src/main.jsx +10 -0
- package/templates/web-react-rspack/src/native/native.cpp +9 -0
- package/templates/web-react-rspack/src/native/native.h +12 -0
- package/templates/web-react-vite/CHANGELOG.md +34 -0
- package/templates/web-react-vite/README.md +38 -0
- package/templates/web-react-vite/crossbind.config.js +13 -0
- package/templates/web-react-vite/e2e/crossbind.spec.cjs +7 -0
- package/templates/web-react-vite/eslint.config.js +38 -0
- package/templates/web-react-vite/index.html +13 -0
- package/templates/web-react-vite/package.json +44 -0
- package/templates/web-react-vite/playwright.dev.config.cjs +48 -0
- package/templates/web-react-vite/playwright.prod.config.cjs +52 -0
- package/templates/web-react-vite/public/vite.svg +1 -0
- package/templates/web-react-vite/src/App.css +42 -0
- package/templates/web-react-vite/src/App.jsx +21 -0
- package/templates/web-react-vite/src/assets/react.svg +1 -0
- package/templates/web-react-vite/src/index.css +68 -0
- package/templates/web-react-vite/src/main.jsx +10 -0
- package/templates/web-react-vite/src/native/native.cpp +9 -0
- package/templates/web-react-vite/src/native/native.h +12 -0
- package/templates/web-react-vite/vite.config.js +8 -0
- package/templates/web-svelte-vite/CHANGELOG.md +34 -0
- package/templates/web-svelte-vite/README.md +38 -0
- package/templates/web-svelte-vite/crossbind.config.js +13 -0
- package/templates/web-svelte-vite/e2e/crossbind.spec.cjs +7 -0
- package/templates/web-svelte-vite/index.html +13 -0
- package/templates/web-svelte-vite/jsconfig.json +32 -0
- package/templates/web-svelte-vite/package.json +35 -0
- package/templates/web-svelte-vite/playwright.dev.config.cjs +48 -0
- package/templates/web-svelte-vite/playwright.prod.config.cjs +52 -0
- package/templates/web-svelte-vite/public/vite.svg +1 -0
- package/templates/web-svelte-vite/src/App.svelte +12 -0
- package/templates/web-svelte-vite/src/app.css +79 -0
- package/templates/web-svelte-vite/src/main.js +9 -0
- package/templates/web-svelte-vite/src/native/native.cpp +9 -0
- package/templates/web-svelte-vite/src/native/native.h +12 -0
- package/templates/web-svelte-vite/src/vite-env.d.ts +2 -0
- package/templates/web-svelte-vite/svelte.config.js +7 -0
- package/templates/web-svelte-vite/vite.config.js +8 -0
- package/templates/web-vanilla/CHANGELOG.md +34 -0
- package/templates/web-vanilla/README.md +32 -0
- package/templates/web-vanilla/crossbind.config.mjs +14 -0
- package/templates/web-vanilla/e2e/crossbind.spec.cjs +7 -0
- package/templates/web-vanilla/index.html +37 -0
- package/templates/web-vanilla/package.json +29 -0
- package/templates/web-vanilla/playwright.prod.config.cjs +52 -0
- package/templates/web-vanilla/serve.json +17 -0
- package/templates/web-vanilla/src/native/native.cpp +9 -0
- package/templates/web-vanilla/src/native/native.h +12 -0
- package/templates/web-vue-vite/CHANGELOG.md +34 -0
- package/templates/web-vue-vite/README.md +38 -0
- package/templates/web-vue-vite/crossbind.config.js +13 -0
- package/templates/web-vue-vite/e2e/crossbind.spec.cjs +7 -0
- package/templates/web-vue-vite/index.html +13 -0
- package/templates/web-vue-vite/package.json +35 -0
- package/templates/web-vue-vite/playwright.dev.config.cjs +48 -0
- package/templates/web-vue-vite/playwright.prod.config.cjs +52 -0
- package/templates/web-vue-vite/public/vite.svg +1 -0
- package/templates/web-vue-vite/serve.json +17 -0
- package/templates/web-vue-vite/src/App.vue +14 -0
- package/templates/web-vue-vite/src/main.js +5 -0
- package/templates/web-vue-vite/src/native/native.cpp +9 -0
- package/templates/web-vue-vite/src/native/native.h +12 -0
- package/templates/web-vue-vite/src/style.css +38 -0
- package/templates/web-vue-vite/vite.config.js +18 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
const { defineConfig, devices } = require('@playwright/test');
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @see https://playwright.dev/docs/test-configuration
|
|
6
|
+
*/
|
|
7
|
+
module.exports = defineConfig({
|
|
8
|
+
testDir: './e2e',
|
|
9
|
+
timeout: 30 * 1000,
|
|
10
|
+
expect: {
|
|
11
|
+
timeout: 50000,
|
|
12
|
+
},
|
|
13
|
+
fullyParallel: true,
|
|
14
|
+
forbidOnly: !!process.env.CI,
|
|
15
|
+
retries: process.env.CI ? 2 : 0,
|
|
16
|
+
workers: process.env.CI ? 1 : undefined,
|
|
17
|
+
|
|
18
|
+
reporter: 'html',
|
|
19
|
+
|
|
20
|
+
use: {
|
|
21
|
+
baseURL: 'http://localhost:8787',
|
|
22
|
+
trace: 'on-first-retry',
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
projects: [
|
|
26
|
+
{
|
|
27
|
+
name: 'chromium',
|
|
28
|
+
use: { ...devices['Desktop Chrome'] },
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
{
|
|
32
|
+
name: 'firefox',
|
|
33
|
+
use: { ...devices['Desktop Firefox'] },
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
{
|
|
37
|
+
name: 'webkit',
|
|
38
|
+
use: { ...devices['Desktop Safari'] },
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
|
|
42
|
+
/* Run your local dev server before starting the tests */
|
|
43
|
+
webServer: {
|
|
44
|
+
command: 'pnpm run dev',
|
|
45
|
+
url: 'http://localhost:8787',
|
|
46
|
+
reuseExistingServer: !process.env.CI,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @crossbind/example-lib-cmake
|
|
2
|
+
|
|
3
|
+
## 2.0.0-beta.50
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Aligned on the 2.0.0-beta.50 baseline. No source change; the version exists so every package in
|
|
8
|
+
the workspace names the same release.
|
|
9
|
+
|
|
10
|
+
## 1.0.0
|
|
11
|
+
|
|
12
|
+
### Major Changes
|
|
13
|
+
|
|
14
|
+
- 🚀 first stable release
|
|
15
|
+
|
|
16
|
+
## 1.0.0-beta.6
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- chore: add initial version of CHANGELOGS files
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.28)
|
|
2
|
+
set(CMAKE_CXX_STANDARD 11)
|
|
3
|
+
|
|
4
|
+
# The consuming crossbind build adds this file with add_subdirectory and links the library by
|
|
5
|
+
# the name it passes in as CROSSBIND_LIB_NAME; PUBLIC includes only propagate to the app when
|
|
6
|
+
# the target carries exactly that name.
|
|
7
|
+
if(NOT DEFINED CROSSBIND_LIB_NAME)
|
|
8
|
+
set(CROSSBIND_LIB_NAME crossbind-lib-samplebasiccmake-wasm)
|
|
9
|
+
endif()
|
|
10
|
+
project(${CROSSBIND_LIB_NAME})
|
|
11
|
+
|
|
12
|
+
add_library(${CROSSBIND_LIB_NAME} STATIC ${CMAKE_CURRENT_SOURCE_DIR}/src/native/samplebasiccmake.cpp)
|
|
13
|
+
|
|
14
|
+
target_include_directories(${CROSSBIND_LIB_NAME} PUBLIC
|
|
15
|
+
${CMAKE_CURRENT_SOURCE_DIR}/src/native
|
|
16
|
+
)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @crossbind/example-lib-cmake
|
|
2
|
+
**crossbind sample library: simple cmake library**
|
|
3
|
+
|
|
4
|
+
<a href="https://www.npmjs.com/package/@crossbind/example-lib-cmake">
|
|
5
|
+
<img alt="NPM version" src="https://img.shields.io/npm/v/@crossbind/example-lib-cmake?style=for-the-badge" />
|
|
6
|
+
</a>
|
|
7
|
+
<a href="https://github.com/crossbind/crossbind/blob/main/LICENSE">
|
|
8
|
+
<img alt="License" src="https://img.shields.io/github/license/crossbind/crossbind?style=for-the-badge" />
|
|
9
|
+
</a>
|
|
10
|
+
|
|
11
|
+
## Integration
|
|
12
|
+
Start by installing these package with the following command:
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install @crossbind/example-lib-cmake
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
To enable the library, modify the crossbind.config.js file as shown below.
|
|
19
|
+
```diff
|
|
20
|
+
+import cmakeSample from '@crossbind/example-lib-cmake/crossbind.config.js';
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
dependencies: [
|
|
24
|
+
+ cmakeSample
|
|
25
|
+
]
|
|
26
|
+
paths: {
|
|
27
|
+
config: import.meta.url,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
Below are the steps to use the library in your C++ or JavaScript code.
|
|
34
|
+
|
|
35
|
+
### Usage in C++ Code
|
|
36
|
+
```diff
|
|
37
|
+
+#include <crossbind-lib-samplebasic-cmake/samplebasiccmake.h>
|
|
38
|
+
|
|
39
|
+
std::string Native::sample() {
|
|
40
|
+
+ return SampleBasicCmake::sample();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Usage in JavaScript Code (web, with plugin)
|
|
46
|
+
```js
|
|
47
|
+
import { initNative, SampleBasicCmake } from '@crossbind/example-lib-cmake/crossbind-lib-samplebasic-cmake/samplebasiccmake.h';
|
|
48
|
+
|
|
49
|
+
await initNative();
|
|
50
|
+
console.log(SampleBasicCmake.sample());
|
|
51
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@crossbind/example-lib-cmake",
|
|
3
|
+
"version": "2.0.0-beta.50",
|
|
4
|
+
"description": "crossbind sample library: simple cmake library",
|
|
5
|
+
"homepage": "https://github.com/crossbind/crossbind/tree/main/examples/lib-cmake#readme",
|
|
6
|
+
"repository": "https://github.com/crossbind/crossbind.git",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"crossbind-sample",
|
|
11
|
+
"cmake",
|
|
12
|
+
"crossbind-sample",
|
|
13
|
+
"webassembly",
|
|
14
|
+
"react-native"
|
|
15
|
+
]
|
|
16
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# AGENTS.md — @crossbind/example-lib-prebuilt-matrix
|
|
2
|
+
|
|
3
|
+
> Canonical minimal **C++ library packaging** reference. This is what `docs/playbooks/new-package.md` (Persona 3) and most other samples point at when they need a small `@crossbind/port-*`-shaped consumable.
|
|
4
|
+
|
|
5
|
+
## What this sample is for
|
|
6
|
+
|
|
7
|
+
- Smallest possible working example of "I have a tiny C++ project, package it for crossbind so other samples / RN apps / web apps can consume it."
|
|
8
|
+
- Used by `examples/mobile-reactnative-cli`, `examples/backend-nodejs-wasm`, and a few playgrounds as their dependency.
|
|
9
|
+
- Reference for `crossbind.config.js` shape with `export.type: 'cmake'`.
|
|
10
|
+
|
|
11
|
+
## Layout
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
examples/lib-prebuilt-matrix/
|
|
15
|
+
├── src/ ← C++ source (matrix multiplier)
|
|
16
|
+
├── playground/ ← optional standalone test
|
|
17
|
+
├── crossbind.config.js ← export.type cmake, base + output paths
|
|
18
|
+
├── examples/lib-prebuilt-matrix.podspec ← iOS package manifest
|
|
19
|
+
├── examples/lib-prebuilt-matrix.xcframework ← prebuilt iOS slices
|
|
20
|
+
├── dist/ ← built artifacts (committed for prebuilt consumption)
|
|
21
|
+
├── package.json
|
|
22
|
+
└── README.md
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
`dist/prebuilt/<target>/{lib,include}` is **committed** so consumers can `pnpm add @crossbind/example-lib-prebuilt-matrix` and link without rebuilding.
|
|
26
|
+
|
|
27
|
+
## Why a sample, not a real crossbind-package
|
|
28
|
+
|
|
29
|
+
Two reasons:
|
|
30
|
+
1. The matrix-multiplier C++ is too small to justify a full `ports/*` family; sample status keeps the surface light.
|
|
31
|
+
2. Demonstrates the inline alternative to packaging: the user's own C++ wrapped in a `crossbind.config.js` and exported as a workspace dep.
|
|
32
|
+
|
|
33
|
+
If you're looking at how a real prebuilt package is shaped, see `ports/zlib/` instead — that's the canonical for new `ports/*`.
|
|
34
|
+
|
|
35
|
+
## Build matrix
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Everything (default)
|
|
39
|
+
pnpm --filter=@crossbind/example-lib-prebuilt-matrix run build
|
|
40
|
+
|
|
41
|
+
# Per-platform
|
|
42
|
+
pnpm --filter=@crossbind/example-lib-prebuilt-matrix run build:wasm
|
|
43
|
+
pnpm --filter=@crossbind/example-lib-prebuilt-matrix run build:android
|
|
44
|
+
pnpm --filter=@crossbind/example-lib-prebuilt-matrix run build:ios # macOS only
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`prepublishOnly` runs `crossbind build` so `pnpm publish` always ships fresh artifacts.
|
|
48
|
+
|
|
49
|
+
## Common pitfalls
|
|
50
|
+
|
|
51
|
+
- **Treating this as a `ports/` template.** It's a sample first; for real package authoring follow `docs/playbooks/new-package.md` and mirror `ports/zlib/`.
|
|
52
|
+
- **Deleting committed `dist/prebuilt/`.** Consumers (`examples/mobile-reactnative-cli`, etc.) link against these artifacts. Rebuild + recommit if you change the C++.
|
|
53
|
+
- **Forgetting `prepublishOnly`.** Without it, npm could publish a stale `dist/`. The script is the safety net.
|
|
54
|
+
- **Adding a heavy native dep** (e.g. another package). Defeats the "smallest possible" purpose. Keep it tiny.
|
|
55
|
+
- **Wrapping with extra plugins** (Metro, Vite, etc.). The sample is plugin-free; consumers add their own plugins.
|
|
56
|
+
|
|
57
|
+
## Validation
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Build
|
|
61
|
+
pnpm --filter=@crossbind/example-lib-prebuilt-matrix run build
|
|
62
|
+
|
|
63
|
+
# Verify prebuilt artifacts
|
|
64
|
+
pnpm run check:dist | grep sample-lib-prebuilt-matrix
|
|
65
|
+
|
|
66
|
+
# Smoke a downstream consumer
|
|
67
|
+
pnpm --filter=@crossbind/example-backend-nodejs-wasm run build
|
|
68
|
+
node examples/backend-nodejs-wasm/src/index.js
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Reference
|
|
72
|
+
|
|
73
|
+
- Package author playbook (the real flow for `ports/*`): `docs/playbooks/new-package.md`
|
|
74
|
+
- Real-package canonical template: `ports/zlib/`
|
|
75
|
+
- Downstream consumers of this sample:
|
|
76
|
+
- `examples/mobile-reactnative-cli/`
|
|
77
|
+
- `examples/mobile-reactnative-expo/`
|
|
78
|
+
- `examples/backend-nodejs-wasm/`
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @crossbind/example-lib-prebuilt-matrix
|
|
2
|
+
|
|
3
|
+
## 2.0.0-beta.50
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Aligned on the 2.0.0-beta.50 baseline. No source change; the version exists so every package in
|
|
8
|
+
the workspace names the same release.
|
|
9
|
+
|
|
10
|
+
## 1.0.0
|
|
11
|
+
|
|
12
|
+
### Major Changes
|
|
13
|
+
|
|
14
|
+
- 🚀 first stable release
|
|
15
|
+
|
|
16
|
+
## 1.0.0-beta.32
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- chore: add initial version of CHANGELOGS files
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# @crossbind/example-lib-prebuilt-matrix
|
|
2
|
+
**Simple matrix multiplier**
|
|
3
|
+
|
|
4
|
+
<a href="https://www.npmjs.com/package/@crossbind/example-lib-prebuilt-matrix">
|
|
5
|
+
<img alt="NPM version" src="https://img.shields.io/npm/v/@crossbind/example-lib-prebuilt-matrix?style=for-the-badge" />
|
|
6
|
+
</a>
|
|
7
|
+
<a href="https://github.com/crossbind/crossbind/blob/main/LICENSE">
|
|
8
|
+
<img alt="License" src="https://img.shields.io/github/license/crossbind/crossbind?style=for-the-badge" />
|
|
9
|
+
</a>
|
|
10
|
+
|
|
11
|
+
## Integration
|
|
12
|
+
Start by installing these package with the following command:
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install @crossbind/example-lib-prebuilt-matrix
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
To enable the library, modify the crossbind.config.js file as shown below.
|
|
19
|
+
```diff
|
|
20
|
+
+import matrix from '@crossbind/example-lib-prebuilt-matrix/crossbind.config.js';
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
dependencies: [
|
|
24
|
+
+ matrix
|
|
25
|
+
]
|
|
26
|
+
paths: {
|
|
27
|
+
config: import.meta.url,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
Below are the steps to use the Simple Matrix Multiplier in your C++ or JavaScript code.
|
|
34
|
+
|
|
35
|
+
### Usage in C++ Code
|
|
36
|
+
```diff
|
|
37
|
+
+#include <Matrix.h>
|
|
38
|
+
|
|
39
|
+
std::string Native::sample() {
|
|
40
|
+
+ auto firstMatrix = std::make_shared<Matrix>(9, 1);
|
|
41
|
+
+ auto secondMatrix = std::make_shared<Matrix>(9, 2);
|
|
42
|
+
+ auto resultStr = std::to_string(firstMatrix->multiple(secondMatrix)->get(0));
|
|
43
|
+
+ return "J₃ * (2*J₃) = " + resultStr + "*J₃";
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Usage in JavaScript Code (web, with plugin)
|
|
49
|
+
```js
|
|
50
|
+
import { initNative, Matrix } from '@crossbind/example-lib-prebuilt-matrix/Matrix.h';
|
|
51
|
+
|
|
52
|
+
await initNative();
|
|
53
|
+
const a = new Matrix(1210000, 1);
|
|
54
|
+
const b = new Matrix(1210000, 2);
|
|
55
|
+
const result = a.multiple(b);
|
|
56
|
+
console.log(result.get(0));
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Usage in JavaScript Code (web, without plugin)
|
|
60
|
+
```js
|
|
61
|
+
import 'node_modules/@crossbind/example-lib-prebuilt-matrix/dist/crossbind-example-lib-prebuilt-matrix.browser.js';
|
|
62
|
+
|
|
63
|
+
initNative({ path: 'node_modules/@crossbind/example-lib-prebuilt-matrix/dist' }).then(({ Matrix }) => {
|
|
64
|
+
const a = new Matrix(1210000, 1);
|
|
65
|
+
const b = new Matrix(1210000, 2);
|
|
66
|
+
const result = a.multiple(b);
|
|
67
|
+
console.log(result.get(0));
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Usage in JavaScript Code (node.js)
|
|
72
|
+
```js
|
|
73
|
+
import 'node_modules/@crossbind/example-lib-prebuilt-matrix/dist/crossbind-example-lib-prebuilt-matrix.node.js';
|
|
74
|
+
|
|
75
|
+
initNative().then(({ Matrix }) => {
|
|
76
|
+
const a = new Matrix(1210000, 1);
|
|
77
|
+
const b = new Matrix(1210000, 2);
|
|
78
|
+
const result = a.multiple(b);
|
|
79
|
+
console.log(result.get(0));
|
|
80
|
+
});
|
|
81
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
3
|
+
|
|
4
|
+
Pod::Spec.new do |s|
|
|
5
|
+
s.module_name = "MatrixMultiplier"
|
|
6
|
+
s.name = "crossbind-example-lib-prebuilt-matrix"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.author = "crossbind Authors"
|
|
12
|
+
s.source = { :http => "https://crossbind.dev" }
|
|
13
|
+
|
|
14
|
+
s.vendored_frameworks = 'crossbind-example-lib-prebuilt-matrix.xcframework'
|
|
15
|
+
# arm64-only iOS simulator slice; drop x86_64 on both pod and consumer targets.
|
|
16
|
+
# pod_target_xcconfig is required so CocoaPods' [CP] Copy XCFrameworks slice selector
|
|
17
|
+
# (which reads $ARCHS in the pod target's context) matches ios-arm64-simulator instead
|
|
18
|
+
# of silently warning and skipping the copy, which would leave the .a missing at link time.
|
|
19
|
+
s.pod_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
|
|
20
|
+
s.user_target_xcconfig = { 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'x86_64' }
|
|
21
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@crossbind/example-lib-prebuilt-matrix",
|
|
3
|
+
"version": "2.0.0-beta.50",
|
|
4
|
+
"description": "crossbind sample prebuilt library: matrix multiplier",
|
|
5
|
+
"homepage": "https://github.com/crossbind/crossbind/tree/main/examples/lib-prebuilt-matrix#readme",
|
|
6
|
+
"repository": "https://github.com/crossbind/crossbind.git",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "crossbind build",
|
|
11
|
+
"builda": "crossbind build -p wasm -p android",
|
|
12
|
+
"build:wasm": "crossbind build -p wasm",
|
|
13
|
+
"build:android": "crossbind build -p android",
|
|
14
|
+
"build:ios": "crossbind build -p ios",
|
|
15
|
+
"clear": "rm -rf .crossbind dist *.xcframework",
|
|
16
|
+
"prepublishOnly": "crossbind build"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"crossbind": "^2.0.0-beta.51"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"crossbind-sample",
|
|
23
|
+
"matrix",
|
|
24
|
+
"crossbind-sample",
|
|
25
|
+
"webassembly",
|
|
26
|
+
"react-native"
|
|
27
|
+
],
|
|
28
|
+
"types": "./dist/types/index.d.ts",
|
|
29
|
+
"typesVersions": {
|
|
30
|
+
"*": {
|
|
31
|
+
"*.h": [
|
|
32
|
+
"./dist/types/index.d.ts"
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class Matrix extends Array {
|
|
2
|
+
constructor(size, initValue) { super(size); this.fill(initValue); }
|
|
3
|
+
|
|
4
|
+
get(i) { return this[i]; }
|
|
5
|
+
|
|
6
|
+
multiple(otherMatrix) {
|
|
7
|
+
const size = Math.sqrt(this.length);
|
|
8
|
+
const result = new Matrix(this.length, 0);
|
|
9
|
+
|
|
10
|
+
for (let i = 0; i < size; i += 1) {
|
|
11
|
+
for (let j = 0; j < size; j += 1) {
|
|
12
|
+
for (let k = 0; k < size; k += 1) {
|
|
13
|
+
result[i * size + j] += this[i * size + k] * otherMatrix[k * size + j];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset = "utf-8">
|
|
6
|
+
<title>C++ Matrix Multiplier</title>
|
|
7
|
+
<script src="./Matrix.js"></script>
|
|
8
|
+
<script type="module">
|
|
9
|
+
import '../dist/crossbind-example-lib-prebuilt-matrix.browser.js';
|
|
10
|
+
let wasmModule;
|
|
11
|
+
initNative();
|
|
12
|
+
const SIZE = Math.pow(1100, 2);
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
async function init () {
|
|
16
|
+
wasmModule = await initNative({ path: '../dist' });
|
|
17
|
+
new wasmModule.Matrix(10, 0);
|
|
18
|
+
toggleVisible(true);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function runCore(type) {
|
|
22
|
+
const MatrixClass = type === 'wasm' ? wasmModule.Matrix : Matrix;
|
|
23
|
+
const a = new MatrixClass(SIZE, 1);
|
|
24
|
+
const b = new MatrixClass(SIZE, 2);
|
|
25
|
+
|
|
26
|
+
const startTime = new Date();
|
|
27
|
+
const result = a.multiple(b);
|
|
28
|
+
|
|
29
|
+
writeResult(type, result.get(0), ((new Date()) - startTime) / 1000);
|
|
30
|
+
}
|
|
31
|
+
function run(type) {
|
|
32
|
+
toggleVisible(false);
|
|
33
|
+
setTimeout(() => runCore(type), 200);
|
|
34
|
+
setTimeout(() => toggleVisible(true), 200);
|
|
35
|
+
}
|
|
36
|
+
function writeResult(type, result, duration) {
|
|
37
|
+
document.querySelector(`#${type}-result`).innerHTML = result;
|
|
38
|
+
document.querySelector(`#${type}-duration`).innerHTML = duration;
|
|
39
|
+
}
|
|
40
|
+
function toggleVisible(visible) {
|
|
41
|
+
document.querySelector('#loading').style.display = visible ? "none" : "block";
|
|
42
|
+
document.querySelector('main').style.display = visible ? "block" : "none";
|
|
43
|
+
}
|
|
44
|
+
window.run = run;
|
|
45
|
+
</script>
|
|
46
|
+
<style>
|
|
47
|
+
body {
|
|
48
|
+
padding: 50px;
|
|
49
|
+
}
|
|
50
|
+
table, th, td {
|
|
51
|
+
border: 1px solid red;
|
|
52
|
+
border-collapse: collapse;
|
|
53
|
+
}
|
|
54
|
+
table {
|
|
55
|
+
width: 400px;
|
|
56
|
+
margin-top: 20px;
|
|
57
|
+
}
|
|
58
|
+
</style>
|
|
59
|
+
</head>
|
|
60
|
+
<body>
|
|
61
|
+
<div id="loading">Loading ...</div>
|
|
62
|
+
<main style="display: none;">
|
|
63
|
+
<div>
|
|
64
|
+
<button type="button" onclick="run('js')">Calculate using JS</button>
|
|
65
|
+
<button type="button" onclick="run('wasm')">Calculate using WASM</button>
|
|
66
|
+
</div>
|
|
67
|
+
<table>
|
|
68
|
+
<tr><td>Type</td><td>result[0]</td><td>Duration (s)</td></tr>
|
|
69
|
+
<tr><td>JS</td><td id="js-result"></td><td id="js-duration"></td></tr>
|
|
70
|
+
<tr><td>WASM</td><td id="wasm-result"></td><td id="wasm-duration"></td></tr>
|
|
71
|
+
</table>
|
|
72
|
+
</main>
|
|
73
|
+
</body>
|
|
74
|
+
</html>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#include "Matrix.h"
|
|
2
|
+
|
|
3
|
+
int Matrix::get(int i) { return this->at(i); }
|
|
4
|
+
|
|
5
|
+
std::shared_ptr<Matrix> Matrix::multiple(std::shared_ptr<Matrix> b) {
|
|
6
|
+
int size = sqrt(this->size());
|
|
7
|
+
auto result = std::make_shared<Matrix>(this->size(), 0);
|
|
8
|
+
|
|
9
|
+
for (int i = 0; i < size; i += 1) {
|
|
10
|
+
for (int j = 0; j < size; j += 1) {
|
|
11
|
+
for (int k = 0; k < size; k += 1) {
|
|
12
|
+
(*result)[i * size + j] += this->at(i * size + k) * (*b)[k * size + j];
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <vector>
|
|
4
|
+
#include <memory>
|
|
5
|
+
#include <cmath>
|
|
6
|
+
|
|
7
|
+
class Matrix : public std::vector<int> {
|
|
8
|
+
public:
|
|
9
|
+
Matrix(int size, int initValue) : std::vector<int>(size, initValue) {}
|
|
10
|
+
int get(int i);
|
|
11
|
+
std::shared_ptr<Matrix> multiple(std::shared_ptr<Matrix> b);
|
|
12
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# @crossbind/example-lib-source
|
|
2
|
+
|
|
3
|
+
## 2.0.0-beta.50
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Aligned on the 2.0.0-beta.50 baseline. No source change; the version exists so every package in
|
|
8
|
+
the workspace names the same release.
|
|
9
|
+
|
|
10
|
+
## 1.0.0
|
|
11
|
+
|
|
12
|
+
### Major Changes
|
|
13
|
+
|
|
14
|
+
- 🚀 first stable release
|
|
15
|
+
|
|
16
|
+
## 1.0.0-beta.5
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- chore: add initial version of CHANGELOGS files
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# @crossbind/example-lib-source
|
|
2
|
+
**crossbind sample library: simple source library**
|
|
3
|
+
|
|
4
|
+
<a href="https://www.npmjs.com/package/@crossbind/example-lib-source">
|
|
5
|
+
<img alt="NPM version" src="https://img.shields.io/npm/v/@crossbind/example-lib-source?style=for-the-badge" />
|
|
6
|
+
</a>
|
|
7
|
+
<a href="https://github.com/crossbind/crossbind/blob/main/LICENSE">
|
|
8
|
+
<img alt="License" src="https://img.shields.io/github/license/crossbind/crossbind?style=for-the-badge" />
|
|
9
|
+
</a>
|
|
10
|
+
|
|
11
|
+
## Integration
|
|
12
|
+
Start by installing these package with the following command:
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install @crossbind/example-lib-source
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
To enable the library, modify the crossbind.config.js file as shown below.
|
|
19
|
+
```diff
|
|
20
|
+
+import sourceSample from '@crossbind/example-lib-source/crossbind.config.js';
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
dependencies: [
|
|
24
|
+
+ sourceSample
|
|
25
|
+
]
|
|
26
|
+
paths: {
|
|
27
|
+
config: import.meta.url,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
Below are the steps to use the library in your C++ or JavaScript code.
|
|
34
|
+
|
|
35
|
+
### Usage in C++ Code
|
|
36
|
+
```diff
|
|
37
|
+
+#include <crossbind-lib-samplebasic/samplebasic.h>
|
|
38
|
+
|
|
39
|
+
std::string Native::sample() {
|
|
40
|
+
+ return SampleBasic::sample();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Usage in JavaScript Code (web, with plugin)
|
|
46
|
+
```js
|
|
47
|
+
import { initNative, SampleBasic } from '@crossbind/example-lib-source/crossbind-lib-samplebasic/samplebasic.h';
|
|
48
|
+
|
|
49
|
+
await initNative();
|
|
50
|
+
console.log(SampleBasic.sample());
|
|
51
|
+
```
|