bare-stow-target-react-native 0.1.2 → 0.2.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 +11 -2
- package/index.js +34 -35
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ const stow = require('bare-stow')
|
|
|
15
15
|
const target = require('bare-stow-target-react-native')
|
|
16
16
|
|
|
17
17
|
const entry = new URL('file:///app/core.js')
|
|
18
|
-
const out = new URL('file:///app/
|
|
18
|
+
const out = new URL('file:///app/core-harness/')
|
|
19
19
|
|
|
20
20
|
for await (const artifact of stow(entry, target, out)) {
|
|
21
21
|
console.log(artifact.url.href)
|
|
@@ -25,7 +25,16 @@ for await (const artifact of stow(entry, target, out)) {
|
|
|
25
25
|
On the command line, `bare-stow` resolves `--target react-native` to this package:
|
|
26
26
|
|
|
27
27
|
```console
|
|
28
|
-
$ bare-stow --target react-native --out ./
|
|
28
|
+
$ bare-stow pack --target react-native --out ./core-harness ./core.js
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The harness imports `bare-stow-host` and `react-native-bare-kit`, which the generated `package.json` declares as dependencies, along with the RPC library when a `client` is requested.
|
|
32
|
+
|
|
33
|
+
The addons and assets of the bundle are left to the application, which links those of all of its bundles once with `bare-stow link`:
|
|
34
|
+
|
|
35
|
+
```console
|
|
36
|
+
$ bare-stow link --target bare-kit --language swift --out ./ios/BareKitAddons ./core.js ./push.js
|
|
37
|
+
$ bare-stow link --target bare-kit --language kotlin --language-option package=com.example.addons --out ./android/addons ./core.js ./push.js
|
|
29
38
|
```
|
|
30
39
|
|
|
31
40
|
## License
|
package/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
exports.name = 'react-native'
|
|
2
|
+
exports.isolation = 'thread'
|
|
2
3
|
exports.linked = true
|
|
4
|
+
exports.linking = 'app'
|
|
3
5
|
exports.offload = false
|
|
4
6
|
exports.format = 'bundle.mjs'
|
|
5
7
|
exports.encoding = 'utf8'
|
|
6
8
|
exports.extension = '.bundle.mjs'
|
|
7
|
-
exports.module = 'esm'
|
|
8
9
|
exports.hosts = [
|
|
9
10
|
'ios-arm64',
|
|
10
11
|
'ios-arm64-simulator',
|
|
@@ -15,61 +16,59 @@ exports.hosts = [
|
|
|
15
16
|
'android-x64'
|
|
16
17
|
]
|
|
17
18
|
|
|
18
|
-
exports.
|
|
19
|
-
|
|
19
|
+
exports.languages = {
|
|
20
|
+
javascript: {
|
|
21
|
+
options: { module: 'esm' },
|
|
22
|
+
generate: javascript
|
|
23
|
+
}
|
|
24
|
+
}
|
|
20
25
|
|
|
21
|
-
|
|
26
|
+
function javascript(context) {
|
|
27
|
+
const { bundle, client, resources } = context
|
|
22
28
|
|
|
23
29
|
const handle = client
|
|
24
|
-
? `{
|
|
25
|
-
: `{
|
|
30
|
+
? `{ ipc: import('bare-stow-host').IPC; rpc: ReturnType<typeof import(${JSON.stringify(client)}).attach> }`
|
|
31
|
+
: `{ ipc: import('bare-stow-host').IPC }`
|
|
26
32
|
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
source: `\
|
|
33
|
+
const source = `\
|
|
30
34
|
import { Worklet } from 'react-native-bare-kit'
|
|
31
|
-
import stow from 'bare-stow
|
|
32
|
-
import bundle from ${JSON.stringify(
|
|
33
|
-
|
|
35
|
+
import stow from 'bare-stow-host'
|
|
36
|
+
import bundle from ${JSON.stringify(bundle)}
|
|
37
|
+
${client ? `import * as client from ${JSON.stringify(client)}\n` : ''}
|
|
34
38
|
export default {
|
|
35
|
-
async start({ timeout, grace, ...opts } = {}) {
|
|
39
|
+
async start({ timeout, grace, ${client ? 'handlers = () => {}, ' : ''}...opts } = {}) {
|
|
36
40
|
const worklet = new Worklet(opts)
|
|
37
41
|
|
|
38
|
-
worklet.start('
|
|
42
|
+
worklet.start(${JSON.stringify(resources + '.bundle')}, bundle)
|
|
39
43
|
|
|
40
|
-
const
|
|
44
|
+
const ipc = stow.wrap(worklet.IPC, { kill: () => worklet.terminate(), timeout, grace })
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
${client ? '\n' + indent(client.source, 4) : ''}
|
|
46
|
-
await ${ipc}.ready
|
|
46
|
+
ipc.on('exit', () => worklet.terminate())
|
|
47
|
+
${client ? '\n const rpc = client.attach(ipc, handlers)\n' : ''}
|
|
48
|
+
await ipc.ready
|
|
47
49
|
|
|
48
|
-
return ${
|
|
50
|
+
return ${client ? '{ ipc, rpc }' : '{ ipc }'}
|
|
49
51
|
}
|
|
50
52
|
}
|
|
51
53
|
`
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
extension: '.d.ts',
|
|
55
|
-
source: `\
|
|
54
|
+
|
|
55
|
+
const types = `\
|
|
56
56
|
declare const harness: {
|
|
57
57
|
start(
|
|
58
58
|
opts?: import('react-native-bare-kit').WorkletOptions &
|
|
59
|
-
Omit<import('bare-stow
|
|
59
|
+
Omit<import('bare-stow-host').IPCOptions, 'kill'>${client ? ` & { handlers?: import(${JSON.stringify(client)}).Handlers }` : ''}
|
|
60
60
|
): Promise<${handle}>
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
export default harness
|
|
64
64
|
`
|
|
65
|
-
}
|
|
66
|
-
]
|
|
67
|
-
}
|
|
68
65
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
return {
|
|
67
|
+
source,
|
|
68
|
+
types,
|
|
69
|
+
dependencies: {
|
|
70
|
+
'bare-stow-host': '^0.1.0',
|
|
71
|
+
'react-native-bare-kit': '^0.16.0'
|
|
72
|
+
}
|
|
73
|
+
}
|
|
75
74
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-stow-target-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "React Native target for bare-stow",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package": "./package.json",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/holepunchto/bare-stow-target-react-native#readme",
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"bare-stow": "^0.
|
|
34
|
+
"bare-stow": "^0.2.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"brittle": "^4.0.2",
|