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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Buğra Sarı and crossbind contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# create-crossbind
|
|
2
|
+
**Create crossbind Applications**
|
|
3
|
+
|
|
4
|
+
<a href="https://www.npmjs.com/package/create-crossbind">
|
|
5
|
+
<img alt="NPM version" src="https://img.shields.io/npm/v/create-crossbind?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
|
+
<a href="https://crossbind.dev/docs/guide/getting-started/create-a-project">
|
|
11
|
+
<img alt="Docs - Create App" src="https://img.shields.io/badge/Docs_-_Create_App-20B2AA?style=for-the-badge" />
|
|
12
|
+
</a>
|
|
13
|
+
|
|
14
|
+
# Getting Started
|
|
15
|
+
|
|
16
|
+
>**Note**: Make sure you have completed the [crossbind - Prerequisites](https://crossbind.dev/docs/guide/getting-started/prerequisites) instructions.
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm create crossbind@beta
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
This command will install and execute create-crossbind, the official crossbind project scaffolding tool. You will be presented with prompts for several optional features such as React.
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
Welcome to crossbind!
|
|
26
|
+
|
|
27
|
+
✔ Project Name … <your-project-name>
|
|
28
|
+
✔ Where should we create your project?
|
|
29
|
+
(leave blank to use current directory) … <your-project-name>
|
|
30
|
+
✔ Select a type: › Web
|
|
31
|
+
✔ Select a framework: › React
|
|
32
|
+
✔ Select a bundler: › Vite
|
|
33
|
+
|
|
34
|
+
Your project is ready!
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
If you are unsure about an option, simply choose Web, React and Vite. Once the project is created, follow the instructions to install dependencies and start the dev server:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
cd <your-project-name>
|
|
41
|
+
npm install
|
|
42
|
+
npm run dev
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
You should now have your first crossbind project running!
|
|
46
|
+
|
|
47
|
+
## Without the prompts
|
|
48
|
+
|
|
49
|
+
Every prompt can be preselected positionally, which is what CI and scripted setups use.
|
|
50
|
+
`npm create crossbind@beta -- --help` prints the list of templates.
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm create crossbind@beta -- my-app Web React Vite
|
|
54
|
+
npm create crossbind@beta -- my-lib Library Prebuilt
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
When you are ready to ship your app to production, run the following:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm run build
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
This will create a production-ready build of your app in the project's ./dist directory.
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "create-crossbind",
|
|
3
|
+
"version": "2.0.0-beta.50",
|
|
4
|
+
"description": "Create crossbind Applications",
|
|
5
|
+
"homepage": "https://github.com/crossbind/crossbind/tree/main/tooling/create-app#readme",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/crossbind/crossbind.git"
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"main": "src/index.js",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"src",
|
|
18
|
+
"templates"
|
|
19
|
+
],
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@clack/prompts": "^1.7.0"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"crossbind",
|
|
25
|
+
"webassembly",
|
|
26
|
+
"react-native",
|
|
27
|
+
"expo",
|
|
28
|
+
"bind",
|
|
29
|
+
"c++",
|
|
30
|
+
"react",
|
|
31
|
+
"vue",
|
|
32
|
+
"svelte",
|
|
33
|
+
"webpack",
|
|
34
|
+
"vite",
|
|
35
|
+
"rspack",
|
|
36
|
+
"create-react-app",
|
|
37
|
+
"metro",
|
|
38
|
+
"android",
|
|
39
|
+
"ios"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build-templates": "node scripts/build-templates.js"
|
|
43
|
+
},
|
|
44
|
+
"bin": {
|
|
45
|
+
"create-crossbind": "src/index.js"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import fsp from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { styleText } from 'node:util';
|
|
7
|
+
import * as p from '@clack/prompts';
|
|
8
|
+
import { pkgManager } from './utils.js';
|
|
9
|
+
|
|
10
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
const PKG_ROOT = path.resolve(__dirname, '..');
|
|
12
|
+
const TEMPLATES_DIR = path.join(PKG_ROOT, 'templates');
|
|
13
|
+
const MANIFEST = JSON.parse(fs.readFileSync(path.join(__dirname, 'manifest.json'), 'utf8'));
|
|
14
|
+
const { version } = JSON.parse(fs.readFileSync(path.join(PKG_ROOT, 'package.json'), 'utf8'));
|
|
15
|
+
|
|
16
|
+
const exitOnCancel = (value) => {
|
|
17
|
+
if (p.isCancel(value)) {
|
|
18
|
+
p.cancel('Cancelled.');
|
|
19
|
+
process.exit(0);
|
|
20
|
+
}
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const unique = (arr) => [...new Set(arr)];
|
|
25
|
+
|
|
26
|
+
async function pickTemplate(presetGroup, presetFirst, presetSecond) {
|
|
27
|
+
const groups = unique(MANIFEST.map((m) => m.group));
|
|
28
|
+
const group = presetGroup || exitOnCancel(await p.select({
|
|
29
|
+
message: 'What kind of project?',
|
|
30
|
+
options: groups.map((g) => ({ value: g, label: g })),
|
|
31
|
+
}));
|
|
32
|
+
const inGroup = MANIFEST.filter((m) => m.group === group);
|
|
33
|
+
|
|
34
|
+
// "first" = framework if present, else label (Library/Cloud have no framework level).
|
|
35
|
+
const firstChoices = unique(inGroup.map((m) => m.framework ?? m.label));
|
|
36
|
+
let first = presetFirst;
|
|
37
|
+
if (!first) {
|
|
38
|
+
first = firstChoices.length === 1
|
|
39
|
+
? firstChoices[0]
|
|
40
|
+
: exitOnCancel(await p.select({
|
|
41
|
+
message: 'Choose framework / variant',
|
|
42
|
+
options: firstChoices.map((c) => ({ value: c, label: c })),
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
const inFirst = inGroup.filter((m) => (m.framework ?? m.label) === first);
|
|
46
|
+
if (inFirst.length === 1) return inFirst[0];
|
|
47
|
+
|
|
48
|
+
const second = presetSecond || exitOnCancel(await p.select({
|
|
49
|
+
message: 'Choose bundler / ecosystem',
|
|
50
|
+
options: inFirst.map((m) => ({ value: m.label, label: m.label })),
|
|
51
|
+
}));
|
|
52
|
+
const entry = inFirst.find((m) => m.label === second);
|
|
53
|
+
if (!entry) {
|
|
54
|
+
p.cancel(`Unknown template: ${group} / ${first} / ${second}`);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
return entry;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function ensureEmpty(dir) {
|
|
61
|
+
if (!fs.existsSync(dir) || fs.readdirSync(dir).length === 0) return;
|
|
62
|
+
const cont = exitOnCancel(await p.confirm({
|
|
63
|
+
message: `Directory not empty (${dir}). Continue?`,
|
|
64
|
+
initialValue: false,
|
|
65
|
+
}));
|
|
66
|
+
if (!cont) { p.cancel('Cancelled.'); process.exit(0); }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Build the post-scaffold "Next steps" from the template's own scripts so we
|
|
70
|
+
// never suggest a command the template doesn't define (e.g. `run dev` only
|
|
71
|
+
// exists for some web/cloud templates; mobile needs platform-specific setup).
|
|
72
|
+
function runSteps(entry, scripts, pm) {
|
|
73
|
+
const has = (script) => Boolean(scripts[script]);
|
|
74
|
+
|
|
75
|
+
if (entry.group === 'Mobile') {
|
|
76
|
+
const launch = `${pm} run ios # or: ${pm} run android`;
|
|
77
|
+
if (entry.key === 'mobile-reactnative-expo') return ['npx expo prebuild', launch];
|
|
78
|
+
return ['cd ios && pod install && cd ..', launch];
|
|
79
|
+
}
|
|
80
|
+
if (entry.kind === 'lib') return [`${pm} run build`];
|
|
81
|
+
if (has('dev')) return [`${pm} run dev`];
|
|
82
|
+
if (has('start')) return [`${pm} start`];
|
|
83
|
+
if (has('preview')) return [`${pm} run build`, `${pm} run preview`];
|
|
84
|
+
if (has('build')) return [`${pm} run build`];
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Every prompt can be preselected positionally, so CI and docs can scaffold without a TTY.
|
|
89
|
+
function usage() {
|
|
90
|
+
const rows = MANIFEST.map((m) => ` ${[m.group, m.framework ?? m.label, m.framework ? m.label : ''].filter(Boolean).join(' ')}`);
|
|
91
|
+
return [
|
|
92
|
+
`create-crossbind v${version}`,
|
|
93
|
+
'',
|
|
94
|
+
'Usage:',
|
|
95
|
+
' npm create crossbind@beta interactive',
|
|
96
|
+
' npm create crossbind@beta -- <dir> <group> <framework|variant> [<variant>] preselected',
|
|
97
|
+
'',
|
|
98
|
+
'Examples:',
|
|
99
|
+
' npm create crossbind@beta -- my-app Web Vanilla',
|
|
100
|
+
' npm create crossbind@beta -- my-app Web React Vite',
|
|
101
|
+
' npm create crossbind@beta -- my-lib Library Prebuilt',
|
|
102
|
+
'',
|
|
103
|
+
'Templates:',
|
|
104
|
+
...rows,
|
|
105
|
+
'',
|
|
106
|
+
].join('\n');
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function main() {
|
|
110
|
+
const args = process.argv.slice(2);
|
|
111
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
112
|
+
process.stdout.write(usage());
|
|
113
|
+
process.exit(0);
|
|
114
|
+
}
|
|
115
|
+
const flag = args.find((a) => a.startsWith('-'));
|
|
116
|
+
if (flag) {
|
|
117
|
+
process.stderr.write(`create-crossbind: unknown option '${flag}' - arguments are positional.\n\n${usage()}`);
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
p.intro(styleText(['cyan', 'bold'], `create-crossbind v${version}`));
|
|
122
|
+
|
|
123
|
+
const [argName, argGroup, argFirst, argSecond] = args;
|
|
124
|
+
|
|
125
|
+
const name = argName || exitOnCancel(await p.text({
|
|
126
|
+
message: 'Project name',
|
|
127
|
+
placeholder: 'sample',
|
|
128
|
+
initialValue: 'sample',
|
|
129
|
+
validate: (v) => ((!v || v.trim().length === 0) ? 'Required' : undefined),
|
|
130
|
+
}));
|
|
131
|
+
|
|
132
|
+
const dirArg = argName || exitOnCancel(await p.text({
|
|
133
|
+
message: 'Where should we create your project?',
|
|
134
|
+
placeholder: name,
|
|
135
|
+
initialValue: name,
|
|
136
|
+
validate: (v) => ((!v || v.trim().length === 0) ? 'Required' : undefined),
|
|
137
|
+
}));
|
|
138
|
+
const cwd = path.resolve(process.cwd(), dirArg);
|
|
139
|
+
|
|
140
|
+
await ensureEmpty(cwd);
|
|
141
|
+
|
|
142
|
+
const entry = await pickTemplate(argGroup, argFirst, argSecond);
|
|
143
|
+
const src = path.join(TEMPLATES_DIR, entry.key);
|
|
144
|
+
if (!fs.existsSync(src)) {
|
|
145
|
+
p.cancel(`Template missing: ${entry.key} (expected ${src}). Did you publish with prepublishOnly?`);
|
|
146
|
+
process.exit(1);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const spin = p.spinner();
|
|
150
|
+
spin.start(`Scaffolding ${entry.key}`);
|
|
151
|
+
await fsp.mkdir(cwd, { recursive: true });
|
|
152
|
+
await fsp.cp(src, cwd, { recursive: true });
|
|
153
|
+
|
|
154
|
+
const pjPath = path.join(cwd, 'package.json');
|
|
155
|
+
let scripts = {};
|
|
156
|
+
if (fs.existsSync(pjPath)) {
|
|
157
|
+
const pkg = JSON.parse(await fsp.readFile(pjPath, 'utf8'));
|
|
158
|
+
pkg.name = entry.kind === 'lib' ? `crossbind-lib-${name}` : name;
|
|
159
|
+
await fsp.writeFile(pjPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
160
|
+
scripts = pkg.scripts || {};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const gradlew = path.join(cwd, 'android', 'gradlew');
|
|
164
|
+
if (fs.existsSync(gradlew)) await fsp.chmod(gradlew, 0o755);
|
|
165
|
+
|
|
166
|
+
spin.stop(`Created ${path.relative(process.cwd(), cwd) || '.'}`);
|
|
167
|
+
|
|
168
|
+
const rel = path.relative(process.cwd(), cwd);
|
|
169
|
+
const steps = [
|
|
170
|
+
...(rel ? [`cd ${rel}`] : []),
|
|
171
|
+
`${pkgManager} install`,
|
|
172
|
+
...runSteps(entry, scripts, pkgManager),
|
|
173
|
+
];
|
|
174
|
+
|
|
175
|
+
p.note(steps.map((s, i) => `${i + 1}. ${styleText('cyan', s)}`).join('\n'), 'Next steps');
|
|
176
|
+
p.outro(styleText('green', 'Done!'));
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
main().catch((err) => {
|
|
180
|
+
process.stderr.write(`create-crossbind failed: ${err.stack || err}\n`);
|
|
181
|
+
process.exit(1);
|
|
182
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
[
|
|
2
|
+
{ "key": "web-vanilla", "group": "Web", "framework": null, "label": "Vanilla", "kind": "app", "source": "examples/web-vanilla" },
|
|
3
|
+
{ "key": "web-react-rspack", "group": "Web", "framework": "React", "label": "Rspack", "kind": "app", "source": "examples/web-react-rspack" },
|
|
4
|
+
{ "key": "web-react-vite", "group": "Web", "framework": "React", "label": "Vite", "kind": "app", "source": "examples/web-react-vite" },
|
|
5
|
+
{ "key": "web-vue-vite", "group": "Web", "framework": "Vue", "label": "Vite", "kind": "app", "source": "examples/web-vue-vite" },
|
|
6
|
+
{ "key": "web-svelte-vite", "group": "Web", "framework": "Svelte", "label": "Vite", "kind": "app", "source": "examples/web-svelte-vite" },
|
|
7
|
+
{ "key": "mobile-reactnative-cli", "group": "Mobile", "framework": "React Native", "label": "Native CLI", "kind": "app", "source": "examples/mobile-reactnative-cli", "nativeFolders": true },
|
|
8
|
+
{ "key": "mobile-reactnative-expo", "group": "Mobile", "framework": "React Native", "label": "Expo", "kind": "app", "source": "examples/mobile-reactnative-expo", "nativeFolders": false, "keepLockfile": true },
|
|
9
|
+
{ "key": "backend-nodejs-wasm", "group": "Backend", "framework": "Node.js", "label": "WebAssembly", "kind": "app", "source": "examples/backend-nodejs-wasm" },
|
|
10
|
+
{ "key": "cloud-cloudflare-worker", "group": "Cloud", "framework": null, "label": "Cloudflare Worker", "kind": "app", "source": "examples/cloud-cloudflare-worker" },
|
|
11
|
+
{ "key": "lib-prebuilt", "group": "Library", "framework": null, "label": "Prebuilt", "kind": "lib", "source": "examples/lib-prebuilt-matrix" },
|
|
12
|
+
{ "key": "lib-source", "group": "Library", "framework": null, "label": "Source", "kind": "lib", "source": "examples/lib-source" },
|
|
13
|
+
{ "key": "lib-cmake", "group": "Library", "framework": null, "label": "CMake", "kind": "lib", "source": "examples/lib-cmake" }
|
|
14
|
+
]
|
package/src/utils.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
function pkgFromUserAgent(userAgent) {
|
|
2
|
+
if (!userAgent) return {};
|
|
3
|
+
const [pkgSpec] = userAgent.split(' ');
|
|
4
|
+
const [name, version] = pkgSpec.split('/');
|
|
5
|
+
return { name, version };
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const pkgManager = pkgFromUserAgent(process.env.npm_config_user_agent).name || 'npm';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# @crossbind/example-backend-nodejs-wasm
|
|
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.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- crossbind@1.0.4
|
|
16
|
+
|
|
17
|
+
## 1.0.0
|
|
18
|
+
|
|
19
|
+
### Major Changes
|
|
20
|
+
|
|
21
|
+
- 🚀 first stable release
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
- @crossbind/example-lib-prebuilt-matrix@1.0.0
|
|
27
|
+
|
|
28
|
+
## 1.0.0-beta.14
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- chore: add initial version of CHANGELOGS files
|
|
33
|
+
- Updated dependencies
|
|
34
|
+
- @crossbind/example-lib-prebuilt-matrix@1.0.0-beta.32
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @crossbind/example-backend-nodejs-wasm
|
|
2
|
+
**crossbind Node.js webassembly sample**
|
|
3
|
+
|
|
4
|
+
<a href="https://www.npmjs.com/package/@crossbind/example-backend-nodejs-wasm">
|
|
5
|
+
<img alt="NPM version" src="https://img.shields.io/npm/v/@crossbind/example-backend-nodejs-wasm?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
|
+
<a href="https://crossbind.dev/docs/guide/integrate-into-existing-project/nodejs">
|
|
11
|
+
<img alt="Docs - Node.js" src="https://img.shields.io/badge/Docs_-_Node.js-20B2AA?style=for-the-badge" />
|
|
12
|
+
</a>
|
|
13
|
+
|
|
14
|
+
# Getting Started
|
|
15
|
+
|
|
16
|
+
>**Note**: Make sure you have completed the [crossbind - Prerequisites](https://crossbind.dev/docs/guide/getting-started/prerequisites) instructions.
|
|
17
|
+
|
|
18
|
+
## Setup
|
|
19
|
+
|
|
20
|
+
Install the dependencies:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pnpm install
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Get Started
|
|
27
|
+
|
|
28
|
+
Build native code to webassembly:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pnpm run build
|
|
32
|
+
```
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import Matrix from '@crossbind/example-lib-prebuilt-matrix/crossbind.config.js';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
general: {
|
|
5
|
+
name: 'crossbind-example-backend-nodejs-wasm',
|
|
6
|
+
},
|
|
7
|
+
dependencies: [
|
|
8
|
+
Matrix,
|
|
9
|
+
],
|
|
10
|
+
paths: {
|
|
11
|
+
config: import.meta.url,
|
|
12
|
+
output: 'dist',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@crossbind/example-backend-nodejs-wasm",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"description": "crossbind - Node.js webassembly sample",
|
|
6
|
+
"homepage": "https://github.com/crossbind/crossbind/tree/main/examples/backend-nodejs-wasm#readme",
|
|
7
|
+
"repository": "https://github.com/crossbind/crossbind.git",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "crossbind build -p wasm -a wasm32 -r st -e node -b release"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@crossbind/example-lib-prebuilt-matrix": "^2.0.0-beta.50"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"crossbind": "^2.0.0-beta.51"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"crossbind-sample",
|
|
20
|
+
"node",
|
|
21
|
+
"webassembly",
|
|
22
|
+
"bind",
|
|
23
|
+
"c++"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#include "native.h"
|
|
2
|
+
#include <Matrix.h>
|
|
3
|
+
|
|
4
|
+
std::string Native::sample() {
|
|
5
|
+
auto firstMatrix = std::make_shared<Matrix>(9, 1);
|
|
6
|
+
auto secondMatrix = std::make_shared<Matrix>(9, 2);
|
|
7
|
+
auto resultStr = std::to_string(firstMatrix->multiple(secondMatrix)->get(0));
|
|
8
|
+
return "J₃ * (2*J₃) = " + resultStr + "*J₃";
|
|
9
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @crossbind/example-cloud-cloudflare-worker
|
|
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.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- crossbind@1.0.4
|
|
16
|
+
|
|
17
|
+
## 1.0.0
|
|
18
|
+
|
|
19
|
+
### Major Changes
|
|
20
|
+
|
|
21
|
+
- 🚀 first stable release
|
|
22
|
+
|
|
23
|
+
## 1.0.0-beta.12
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- chore: add initial version of CHANGELOGS files
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# @crossbind/example-cloud-cloudflare-worker
|
|
2
|
+
**crossbind Cloudflare Worker sample**
|
|
3
|
+
|
|
4
|
+
<a href="https://www.npmjs.com/package/@crossbind/example-cloud-cloudflare-worker">
|
|
5
|
+
<img alt="NPM version" src="https://img.shields.io/npm/v/@crossbind/example-cloud-cloudflare-worker?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
|
+
<a href="https://crossbind.dev/docs/guide/integrate-into-existing-project/cloudflare-worker">
|
|
11
|
+
<img alt="Docs - Cloudflare Worker" src="https://img.shields.io/badge/Docs_-_Cloudflare_Worker-20B2AA?style=for-the-badge" />
|
|
12
|
+
</a>
|
|
13
|
+
|
|
14
|
+
<https://crossbind.bugra9.workers.dev>
|
|
15
|
+
|
|
16
|
+
# Getting Started
|
|
17
|
+
|
|
18
|
+
>**Note**: Make sure you have completed the [crossbind - Prerequisites](https://crossbind.dev/docs/guide/getting-started/prerequisites) instructions.
|
|
19
|
+
|
|
20
|
+
## Setup
|
|
21
|
+
|
|
22
|
+
Install the dependencies:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm install
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Get Started
|
|
29
|
+
|
|
30
|
+
Build native code to webassembly:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm run build
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Start the dev server:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pnpm run dev
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Deploy to the Cloudflare Workers:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pnpm run deploy
|
|
46
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import initNative from './dist/crossbind-example-cloud-cloudflare-worker-wasm-wasm32-st-release.edge.js';
|
|
2
|
+
import wasmContent from './dist/crossbind-example-cloud-cloudflare-worker-wasm-wasm32-st-release.edge.wasm';
|
|
3
|
+
|
|
4
|
+
const { Native } = await initNative({ getWasmFunction: () => wasmContent });
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
async fetch(request, env, ctx) {
|
|
8
|
+
return new Response(Native.sample());
|
|
9
|
+
},
|
|
10
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@crossbind/example-cloud-cloudflare-worker",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"description": "crossbind - Cloudflare webassembly sample",
|
|
6
|
+
"homepage": "https://github.com/crossbind/crossbind/tree/main/examples/cloud-cloudflare-worker#readme",
|
|
7
|
+
"repository": "https://github.com/crossbind/crossbind.git",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "crossbind build -p wasm -a wasm32 -r st -e edge -b release",
|
|
11
|
+
"dev": "wrangler dev",
|
|
12
|
+
"deploy": "wrangler dev",
|
|
13
|
+
"e2e:dev": "playwright test --config playwright.dev.config.cjs",
|
|
14
|
+
"e2e:prod": "playwright test --config playwright.dev.config.cjs"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/@crossbind/example-cloud-cloudflare.edge.js",
|
|
18
|
+
"dist/@crossbind/example-cloud-cloudflare.edge.wasm",
|
|
19
|
+
"index.js",
|
|
20
|
+
"crossbind.config.mjs",
|
|
21
|
+
"wrangler.toml",
|
|
22
|
+
"src"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"crossbind": "^2.0.0-beta.51",
|
|
27
|
+
"wrangler": "^4.120.0",
|
|
28
|
+
"@playwright/test": "^1.62.1"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"crossbind-sample",
|
|
32
|
+
"cloudflare",
|
|
33
|
+
"cloudflare-worker",
|
|
34
|
+
"webassembly",
|
|
35
|
+
"bind",
|
|
36
|
+
"c++"
|
|
37
|
+
]
|
|
38
|
+
}
|