react-native-web-serial-api 0.0.3 → 0.1.0
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/README.md +23 -0
- package/TESTING.md +301 -0
- package/android/build.gradle +2 -2
- package/lib/commonjs/UsbSerial.js +58 -26
- package/lib/commonjs/UsbSerial.js.map +1 -1
- package/lib/commonjs/WebSerial.js +169 -57
- package/lib/commonjs/WebSerial.js.map +1 -1
- package/lib/commonjs/index.js +13 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/lib/dom-exception.js +176 -0
- package/lib/commonjs/lib/dom-exception.js.map +1 -0
- package/lib/commonjs/lib/event-target.js +138 -0
- package/lib/commonjs/lib/event-target.js.map +1 -0
- package/lib/commonjs/lib/promise.js +23 -0
- package/lib/commonjs/lib/promise.js.map +1 -0
- package/lib/commonjs/testing/index.js +70 -0
- package/lib/commonjs/testing/index.js.map +1 -0
- package/lib/commonjs/testing/install.js +54 -0
- package/lib/commonjs/testing/install.js.map +1 -0
- package/lib/commonjs/testing/serial-device.js +164 -0
- package/lib/commonjs/testing/serial-device.js.map +1 -0
- package/lib/commonjs/testing/virtual-serial.js +615 -0
- package/lib/commonjs/testing/virtual-serial.js.map +1 -0
- package/lib/commonjs/transport.js +61 -0
- package/lib/commonjs/transport.js.map +1 -0
- package/lib/typescript/src/UsbSerial.d.ts +24 -67
- package/lib/typescript/src/UsbSerial.d.ts.map +1 -1
- package/lib/typescript/src/WebSerial.d.ts +11 -2
- package/lib/typescript/src/WebSerial.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/lib/dom-exception.d.ts +100 -0
- package/lib/typescript/src/lib/dom-exception.d.ts.map +1 -0
- package/lib/typescript/src/lib/event-target.d.ts +53 -0
- package/lib/typescript/src/lib/event-target.d.ts.map +1 -0
- package/lib/typescript/src/lib/promise.d.ts +11 -0
- package/lib/typescript/src/lib/promise.d.ts.map +1 -0
- package/lib/typescript/src/testing/index.d.ts +23 -0
- package/lib/typescript/src/testing/index.d.ts.map +1 -0
- package/lib/typescript/src/testing/install.d.ts +25 -0
- package/lib/typescript/src/testing/install.d.ts.map +1 -0
- package/lib/typescript/src/testing/serial-device.d.ts +127 -0
- package/lib/typescript/src/testing/serial-device.d.ts.map +1 -0
- package/lib/typescript/src/testing/virtual-serial.d.ts +205 -0
- package/lib/typescript/src/testing/virtual-serial.d.ts.map +1 -0
- package/lib/typescript/src/transport.d.ts +131 -0
- package/lib/typescript/src/transport.d.ts.map +1 -0
- package/package.json +38 -2
- package/src/UsbSerial.ts +65 -90
- package/src/WebSerial.ts +227 -88
- package/src/index.ts +2 -7
- package/src/lib/dom-exception.ts +129 -60
- package/src/lib/event-target.ts +46 -21
- package/src/lib/promise.ts +7 -7
- package/src/testing/index.ts +42 -0
- package/src/testing/install.ts +65 -0
- package/src/testing/serial-device.ts +193 -0
- package/src/testing/virtual-serial.ts +801 -0
- package/src/transport.ts +200 -0
- package/babel.config.js +0 -3
- package/biome.json +0 -35
- package/example/.watchmanconfig +0 -1
- package/example/App.tsx +0 -71
- package/example/__tests__/App.test.tsx +0 -16
- package/example/__tests__/connectEvents.test.tsx +0 -81
- package/example/__tests__/getPorts.test.tsx +0 -140
- package/example/android/app/build.gradle +0 -120
- package/example/android/app/debug.keystore +0 -0
- package/example/android/app/proguard-rules.pro +0 -10
- package/example/android/app/src/debug/AndroidManifest.xml +0 -9
- package/example/android/app/src/main/AndroidManifest.xml +0 -38
- package/example/android/app/src/main/java/dev/uzlopak/MainActivity.kt +0 -22
- package/example/android/app/src/main/java/dev/uzlopak/MainApplication.kt +0 -41
- package/example/android/app/src/main/res/drawable/rn_edit_text_material.xml +0 -37
- package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/example/android/app/src/main/res/values/strings.xml +0 -3
- package/example/android/app/src/main/res/values/styles.xml +0 -9
- package/example/android/build.gradle +0 -22
- package/example/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/example/android/gradle/wrapper/gradle-wrapper.properties +0 -7
- package/example/android/gradle.properties +0 -47
- package/example/android/gradlew +0 -252
- package/example/android/gradlew.bat +0 -94
- package/example/android/settings.gradle +0 -6
- package/example/app.json +0 -4
- package/example/babel.config.js +0 -21
- package/example/biome.json +0 -47
- package/example/deploy.sh +0 -11
- package/example/index.html +0 -26
- package/example/index.js +0 -9
- package/example/index.web.js +0 -8
- package/example/jest.config.js +0 -12
- package/example/metro.config.js +0 -58
- package/example/package-lock.json +0 -14510
- package/example/package.json +0 -48
- package/example/react-native.config.js +0 -17
- package/example/src/components/AppBar.tsx +0 -73
- package/example/src/components/Menu.tsx +0 -90
- package/example/src/components/SingleChoiceDialog.tsx +0 -120
- package/example/src/screens/ConnectScreen.tsx +0 -195
- package/example/src/screens/DevicesScreen.tsx +0 -252
- package/example/src/screens/TerminalScreen.tsx +0 -572
- package/example/src/settings.ts +0 -43
- package/example/src/theme.ts +0 -19
- package/example/src/util/TextUtil.ts +0 -129
- package/example/tsconfig.json +0 -10
- package/example/vite.config.mjs +0 -55
- package/scripts/deploy-release.sh +0 -127
- package/tsconfig.build.json +0 -7
- package/tsconfig.json +0 -20
package/example/biome.json
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/2.4.16/schema.json",
|
|
3
|
-
"files": {
|
|
4
|
-
"includes": [
|
|
5
|
-
"App.tsx",
|
|
6
|
-
"index.js",
|
|
7
|
-
"index.web.js",
|
|
8
|
-
"src/**/*.{ts,tsx}",
|
|
9
|
-
"__tests__/**/*.{ts,tsx}",
|
|
10
|
-
"*.config.{js,mjs}",
|
|
11
|
-
"!android",
|
|
12
|
-
"!dist",
|
|
13
|
-
"!node_modules"
|
|
14
|
-
]
|
|
15
|
-
},
|
|
16
|
-
"formatter": {
|
|
17
|
-
"enabled": true,
|
|
18
|
-
"indentStyle": "space",
|
|
19
|
-
"indentWidth": 2,
|
|
20
|
-
"lineWidth": 80
|
|
21
|
-
},
|
|
22
|
-
"javascript": {
|
|
23
|
-
"formatter": {
|
|
24
|
-
"quoteStyle": "single",
|
|
25
|
-
"trailingCommas": "all",
|
|
26
|
-
"bracketSpacing": false,
|
|
27
|
-
"bracketSameLine": true,
|
|
28
|
-
"arrowParentheses": "asNeeded"
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"linter": {
|
|
32
|
-
"enabled": true,
|
|
33
|
-
"rules": {
|
|
34
|
-
"recommended": true,
|
|
35
|
-
"style": {
|
|
36
|
-
"noNonNullAssertion": "off"
|
|
37
|
-
},
|
|
38
|
-
"suspicious": {
|
|
39
|
-
"noExplicitAny": "off",
|
|
40
|
-
"noArrayIndexKey": "off"
|
|
41
|
-
},
|
|
42
|
-
"complexity": {
|
|
43
|
-
"noBannedTypes": "off"
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
package/example/deploy.sh
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# Bundle neu bauen
|
|
2
|
-
npx react-native bundle \
|
|
3
|
-
--platform android \
|
|
4
|
-
--dev false \
|
|
5
|
-
--entry-file index.js \
|
|
6
|
-
--bundle-output android/app/src/main/assets/index.android.bundle \
|
|
7
|
-
--assets-dest android/app/src/main/res
|
|
8
|
-
|
|
9
|
-
# Dann APK bauen und installieren
|
|
10
|
-
cd android && ./gradlew assembleDebug && cd ..
|
|
11
|
-
npm run android -- --deviceId 192.168.178.73:5555
|
package/example/index.html
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta
|
|
6
|
-
name="viewport"
|
|
7
|
-
content="width=device-width, initial-scale=1, shrink-to-fit=no"
|
|
8
|
-
/>
|
|
9
|
-
<title>Web Serial API Demo</title>
|
|
10
|
-
<style>
|
|
11
|
-
html,
|
|
12
|
-
body,
|
|
13
|
-
#root {
|
|
14
|
-
height: 100%;
|
|
15
|
-
margin: 0;
|
|
16
|
-
}
|
|
17
|
-
#root {
|
|
18
|
-
display: flex;
|
|
19
|
-
}
|
|
20
|
-
</style>
|
|
21
|
-
</head>
|
|
22
|
-
<body>
|
|
23
|
-
<div id="root"></div>
|
|
24
|
-
<script type="module" src="/index.web.js"></script>
|
|
25
|
-
</body>
|
|
26
|
-
</html>
|
package/example/index.js
DELETED
package/example/index.web.js
DELETED
package/example/jest.config.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
// RN 0.85 moved the Jest preset out of `react-native` into its own package.
|
|
3
|
-
preset: '@react-native/jest-preset',
|
|
4
|
-
// The library is consumed from ../src (via the babel module-resolver alias),
|
|
5
|
-
// which physically lives outside this folder and would otherwise resolve a
|
|
6
|
-
// second, un-mocked copy of react-native / react from the repo root. Pin both
|
|
7
|
-
// to the example's copy so the RN jest preset's native mocks apply everywhere.
|
|
8
|
-
moduleNameMapper: {
|
|
9
|
-
'^react-native$': '<rootDir>/node_modules/react-native',
|
|
10
|
-
'^react$': '<rootDir>/node_modules/react',
|
|
11
|
-
},
|
|
12
|
-
};
|
package/example/metro.config.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
const path = require('node:path');
|
|
2
|
-
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
|
|
3
|
-
|
|
4
|
-
const pkg = require('../package.json');
|
|
5
|
-
|
|
6
|
-
const root = path.resolve(__dirname, '..');
|
|
7
|
-
const modules = Object.keys({...pkg.peerDependencies});
|
|
8
|
-
|
|
9
|
-
// Absolute paths to the example's single copy of each peer dependency.
|
|
10
|
-
const peerModulePaths = modules.reduce((acc, name) => {
|
|
11
|
-
acc[name] = path.resolve(__dirname, 'node_modules', name);
|
|
12
|
-
return acc;
|
|
13
|
-
}, {});
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Metro configuration for the example app inside the library monorepo.
|
|
17
|
-
*
|
|
18
|
-
* - watch the repo root so edits to the library's `src/` hot-reload here
|
|
19
|
-
* - force the library's peer deps (react / react-native) to resolve to the
|
|
20
|
-
* example's single copy. This is critical: the library source lives at the
|
|
21
|
-
* repo root (above this folder) and there is ALSO a react-native installed at
|
|
22
|
-
* the repo root (the library's own devDependency). Without forcing a single
|
|
23
|
-
* copy, `src/WebSerial.ts` resolves the root react-native while the app uses
|
|
24
|
-
* the example's copy — two separate RCTDeviceEventEmitter singletons, so
|
|
25
|
-
* native 'data' events are emitted into one and listened for on the other,
|
|
26
|
-
* and nothing is received. extraNodeModules alone does NOT fix this because
|
|
27
|
-
* the importing file is outside the project root, so we also intercept via
|
|
28
|
-
* resolveRequest.
|
|
29
|
-
*
|
|
30
|
-
* https://reactnative.dev/docs/metro
|
|
31
|
-
*/
|
|
32
|
-
const config = {
|
|
33
|
-
watchFolders: [root],
|
|
34
|
-
resolver: {
|
|
35
|
-
nodeModulesPaths: [
|
|
36
|
-
path.resolve(__dirname, 'node_modules'),
|
|
37
|
-
path.resolve(root, 'node_modules'),
|
|
38
|
-
],
|
|
39
|
-
extraNodeModules: peerModulePaths,
|
|
40
|
-
resolveRequest: (context, moduleName, platform) => {
|
|
41
|
-
// Pin every peer dependency (and its subpaths) to the example's copy,
|
|
42
|
-
// regardless of which file imports it.
|
|
43
|
-
for (const name of modules) {
|
|
44
|
-
if (moduleName === name || moduleName.startsWith(`${name}/`)) {
|
|
45
|
-
const rest = moduleName.slice(name.length); // '' or '/subpath'
|
|
46
|
-
return context.resolveRequest(
|
|
47
|
-
context,
|
|
48
|
-
peerModulePaths[name] + rest,
|
|
49
|
-
platform,
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return context.resolveRequest(context, moduleName, platform);
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
module.exports = mergeConfig(getDefaultConfig(__dirname), config);
|