@crossbind/example-lib-prebuilt-matrix 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/AGENTS.md +78 -0
- package/CHANGELOG.md +20 -0
- package/LICENSE +21 -0
- package/README.md +81 -0
- package/crossbind-example-lib-prebuilt-matrix.podspec +21 -0
- package/crossbind-example-lib-prebuilt-matrix.xcframework/Info.plist +47 -0
- package/crossbind-example-lib-prebuilt-matrix.xcframework/ios-arm64/Headers/Matrix.h +12 -0
- package/crossbind-example-lib-prebuilt-matrix.xcframework/ios-arm64/libcrossbind-example-lib-prebuilt-matrix.a +0 -0
- package/crossbind-example-lib-prebuilt-matrix.xcframework/ios-arm64-simulator/Headers/Matrix.h +12 -0
- package/crossbind-example-lib-prebuilt-matrix.xcframework/ios-arm64-simulator/libcrossbind-example-lib-prebuilt-matrix.a +0 -0
- package/crossbind.config.js +14 -0
- package/dist/crossbind-example-lib-prebuilt-matrix-wasi-wasm32-st-release.wasm +0 -0
- package/dist/crossbind-example-lib-prebuilt-matrix-wasm-wasm32-mt-release.browser.js +1363 -0
- package/dist/crossbind-example-lib-prebuilt-matrix-wasm-wasm32-mt-release.browser.wasm +0 -0
- package/dist/crossbind-example-lib-prebuilt-matrix-wasm-wasm32-mt-release.node.js +508 -0
- package/dist/crossbind-example-lib-prebuilt-matrix-wasm-wasm32-mt-release.node.wasm +0 -0
- package/dist/crossbind-example-lib-prebuilt-matrix-wasm-wasm32-st-release.browser.js +1363 -0
- package/dist/crossbind-example-lib-prebuilt-matrix-wasm-wasm32-st-release.browser.wasm +0 -0
- package/dist/crossbind-example-lib-prebuilt-matrix-wasm-wasm32-st-release.edge.js +478 -0
- package/dist/crossbind-example-lib-prebuilt-matrix-wasm-wasm32-st-release.edge.wasm +0 -0
- package/dist/crossbind-example-lib-prebuilt-matrix-wasm-wasm32-st-release.node.js +508 -0
- package/dist/crossbind-example-lib-prebuilt-matrix-wasm-wasm32-st-release.node.wasm +0 -0
- package/dist/prebuilt/CMakeLists.txt +57 -0
- package/dist/prebuilt/android-arm64-v8a-mt-release/crossbind-emccflags.fingerprint +1 -0
- package/dist/prebuilt/android-arm64-v8a-mt-release/include/Matrix.h +12 -0
- package/dist/prebuilt/android-arm64-v8a-mt-release/lib/libcrossbind-example-lib-prebuilt-matrix.so +0 -0
- package/dist/prebuilt/android-x86_64-mt-release/crossbind-emccflags.fingerprint +1 -0
- package/dist/prebuilt/android-x86_64-mt-release/include/Matrix.h +12 -0
- package/dist/prebuilt/android-x86_64-mt-release/lib/libcrossbind-example-lib-prebuilt-matrix.so +0 -0
- package/dist/prebuilt/ios-iphoneos-mt-release/crossbind-emccflags.fingerprint +1 -0
- package/dist/prebuilt/ios-iphoneos-mt-release/include/Matrix.h +12 -0
- package/dist/prebuilt/ios-iphoneos-mt-release/lib/libcrossbind-example-lib-prebuilt-matrix.a +0 -0
- package/dist/prebuilt/ios-iphonesimulator-mt-release/crossbind-emccflags.fingerprint +1 -0
- package/dist/prebuilt/ios-iphonesimulator-mt-release/include/Matrix.h +12 -0
- package/dist/prebuilt/ios-iphonesimulator-mt-release/lib/libcrossbind-example-lib-prebuilt-matrix.a +0 -0
- package/dist/prebuilt/wasi-wasm32-st-release/crossbind-emccflags.fingerprint +1 -0
- package/dist/prebuilt/wasi-wasm32-st-release/include/Matrix.h +12 -0
- package/dist/prebuilt/wasi-wasm32-st-release/lib/libcrossbind-example-lib-prebuilt-matrix.a +0 -0
- package/dist/prebuilt/wasm-wasm32-mt-release/crossbind-emccflags.fingerprint +1 -0
- package/dist/prebuilt/wasm-wasm32-mt-release/include/Matrix.h +12 -0
- package/dist/prebuilt/wasm-wasm32-mt-release/lib/libcrossbind-example-lib-prebuilt-matrix.a +0 -0
- package/dist/prebuilt/wasm-wasm32-st-release/crossbind-emccflags.fingerprint +1 -0
- package/dist/prebuilt/wasm-wasm32-st-release/include/Matrix.h +12 -0
- package/dist/prebuilt/wasm-wasm32-st-release/lib/libcrossbind-example-lib-prebuilt-matrix.a +0 -0
- package/dist/types/index.d.ts +9 -0
- package/package.json +38 -0
- package/playground/Matrix.js +19 -0
- package/playground/index.html +74 -0
- package/src/native/Matrix.cpp +17 -0
- package/src/native/Matrix.h +12 -0
package/AGENTS.md
ADDED
|
@@ -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/`
|
package/CHANGELOG.md
ADDED
|
@@ -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
|
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,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,47 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>AvailableLibraries</key>
|
|
6
|
+
<array>
|
|
7
|
+
<dict>
|
|
8
|
+
<key>BinaryPath</key>
|
|
9
|
+
<string>libcrossbind-example-lib-prebuilt-matrix.a</string>
|
|
10
|
+
<key>HeadersPath</key>
|
|
11
|
+
<string>Headers</string>
|
|
12
|
+
<key>LibraryIdentifier</key>
|
|
13
|
+
<string>ios-arm64</string>
|
|
14
|
+
<key>LibraryPath</key>
|
|
15
|
+
<string>libcrossbind-example-lib-prebuilt-matrix.a</string>
|
|
16
|
+
<key>SupportedArchitectures</key>
|
|
17
|
+
<array>
|
|
18
|
+
<string>arm64</string>
|
|
19
|
+
</array>
|
|
20
|
+
<key>SupportedPlatform</key>
|
|
21
|
+
<string>ios</string>
|
|
22
|
+
</dict>
|
|
23
|
+
<dict>
|
|
24
|
+
<key>BinaryPath</key>
|
|
25
|
+
<string>libcrossbind-example-lib-prebuilt-matrix.a</string>
|
|
26
|
+
<key>HeadersPath</key>
|
|
27
|
+
<string>Headers</string>
|
|
28
|
+
<key>LibraryIdentifier</key>
|
|
29
|
+
<string>ios-arm64-simulator</string>
|
|
30
|
+
<key>LibraryPath</key>
|
|
31
|
+
<string>libcrossbind-example-lib-prebuilt-matrix.a</string>
|
|
32
|
+
<key>SupportedArchitectures</key>
|
|
33
|
+
<array>
|
|
34
|
+
<string>arm64</string>
|
|
35
|
+
</array>
|
|
36
|
+
<key>SupportedPlatform</key>
|
|
37
|
+
<string>ios</string>
|
|
38
|
+
<key>SupportedPlatformVariant</key>
|
|
39
|
+
<string>simulator</string>
|
|
40
|
+
</dict>
|
|
41
|
+
</array>
|
|
42
|
+
<key>CFBundlePackageType</key>
|
|
43
|
+
<string>XFWK</string>
|
|
44
|
+
<key>XCFrameworkFormatVersion</key>
|
|
45
|
+
<string>1.0</string>
|
|
46
|
+
</dict>
|
|
47
|
+
</plist>
|
|
@@ -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
|
+
};
|
|
Binary file
|
package/crossbind-example-lib-prebuilt-matrix.xcframework/ios-arm64-simulator/Headers/Matrix.h
ADDED
|
@@ -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
|
+
};
|
|
Binary file
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
general: {
|
|
3
|
+
name: 'crossbind-example-lib-prebuilt-matrix',
|
|
4
|
+
},
|
|
5
|
+
types: true,
|
|
6
|
+
export: {
|
|
7
|
+
type: 'cmake',
|
|
8
|
+
},
|
|
9
|
+
paths: {
|
|
10
|
+
config: import.meta.url,
|
|
11
|
+
base: '../..', /* Delete this line for create-crossbind */
|
|
12
|
+
output: 'dist',
|
|
13
|
+
},
|
|
14
|
+
};
|