bare-stow 0.0.0 → 0.1.1

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.
@@ -0,0 +1,63 @@
1
+ exports.name = 'bare-sidecar'
2
+ exports.linked = false
3
+ exports.offload = true
4
+ exports.format = 'bundle'
5
+ exports.encoding = null
6
+ exports.extension = '.bundle'
7
+ exports.module = 'cjs'
8
+ exports.hosts = [
9
+ 'darwin-arm64',
10
+ 'darwin-x64',
11
+ 'linux-arm64',
12
+ 'linux-x64',
13
+ 'win32-arm64',
14
+ 'win32-x64'
15
+ ]
16
+
17
+ exports.generate = function generate(opts) {
18
+ const { bundleSpecifier, ipc, rpc, client = null } = opts
19
+
20
+ const returned = client ? `{ ${ipc}, ${rpc} }` : `{ ${ipc} }`
21
+
22
+ const handle = client
23
+ ? `{ ${ipc}: import('bare-stow/host').IPC; ${rpc}: ${client.type} }`
24
+ : `{ ${ipc}: import('bare-stow/host').IPC }`
25
+
26
+ return [
27
+ {
28
+ source: `\
29
+ const path = require('path')
30
+ const Sidecar = require('bare-sidecar')
31
+ const stow = require('bare-stow/host')
32
+
33
+ const bundle = path.join(__dirname, ${JSON.stringify(bundleSpecifier)})
34
+
35
+ module.exports = {
36
+ async start(opts = {}) {
37
+ const sidecar = new Sidecar(bundle, opts)
38
+
39
+ const ${ipc} = stow.wrap(sidecar)
40
+ ${client ? '\n' + indent(client.source, 4) : ''}
41
+ await ${ipc}.ready
42
+
43
+ return ${returned}
44
+ }
45
+ }
46
+ `
47
+ },
48
+ {
49
+ extension: '.d.ts',
50
+ source: `\
51
+ export function start(opts?: import('bare-sidecar').SidecarOptions): Promise<${handle}>
52
+ `
53
+ }
54
+ ]
55
+ }
56
+
57
+ function indent(source, spaces) {
58
+ const pad = ' '.repeat(spaces)
59
+ return source
60
+ .split('\n')
61
+ .map((line) => (line.length === 0 ? line : pad + line))
62
+ .join('\n')
63
+ }
package/lib/target.js ADDED
@@ -0,0 +1,27 @@
1
+ const registry = {
2
+ 'bare-sidecar': () => require('./target/bare-sidecar')
3
+ }
4
+
5
+ module.exports = function target(name, resolve) {
6
+ if (typeof name !== 'string') return validate(name)
7
+
8
+ const load = registry[name]
9
+
10
+ if (load) return load()
11
+
12
+ if (resolve) return validate(resolve(name))
13
+
14
+ throw new Error(`Unknown target '${name}'`)
15
+ }
16
+
17
+ function validate(target) {
18
+ if (!target || typeof target.generate !== 'function') {
19
+ throw new Error('Target must provide a generate() function')
20
+ }
21
+
22
+ if (!Array.isArray(target.hosts)) {
23
+ throw new Error('Target must provide a hosts array')
24
+ }
25
+
26
+ return target
27
+ }
package/package.json CHANGED
@@ -1 +1,93 @@
1
- {"name":"bare-stow","version":"0.0.0"}
1
+ {
2
+ "name": "bare-stow",
3
+ "version": "0.1.1",
4
+ "description": "Module bundling and harness generation for Bare",
5
+ "exports": {
6
+ "./package": "./package.json",
7
+ ".": {
8
+ "types": "./index.d.ts",
9
+ "default": "./index.js"
10
+ },
11
+ "./protocol": {
12
+ "types": "./lib/protocol.d.ts",
13
+ "default": "./lib/protocol.js"
14
+ },
15
+ "./host": {
16
+ "types": "./lib/host.d.ts",
17
+ "default": "./lib/host.js"
18
+ }
19
+ },
20
+ "imports": {
21
+ "fs": {
22
+ "bare": "bare-fs",
23
+ "default": "fs"
24
+ },
25
+ "path": {
26
+ "bare": "bare-path",
27
+ "default": "path"
28
+ },
29
+ "url": {
30
+ "bare": "bare-url",
31
+ "default": "url"
32
+ }
33
+ },
34
+ "bin": {
35
+ "bare-stow": "bin.js"
36
+ },
37
+ "files": [
38
+ "index.js",
39
+ "index.d.ts",
40
+ "bin.js",
41
+ "lib"
42
+ ],
43
+ "scripts": {
44
+ "format": "prettier --write . && lunte --fix",
45
+ "lint": "prettier --check . && lunte",
46
+ "test": "npm run test:bare && npm run test:node",
47
+ "test:bare": "brittle-bare --coverage test.js",
48
+ "test:node": "brittle-node --coverage test.js"
49
+ },
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/holepunchto/bare-stow.git"
53
+ },
54
+ "author": "Holepunch",
55
+ "license": "Apache-2.0",
56
+ "bugs": {
57
+ "url": "https://github.com/holepunchto/bare-stow/issues"
58
+ },
59
+ "homepage": "https://github.com/holepunchto/bare-stow#readme",
60
+ "dependencies": {
61
+ "bare-bundle": "^1.8.3",
62
+ "bare-bundle-id": "^1.0.0",
63
+ "bare-fs": "^4.2.1",
64
+ "bare-module-lexer": "^1.5.2",
65
+ "bare-module-traverse": "^2.1.1",
66
+ "bare-pack": "^2.1.0",
67
+ "bare-path": "^3.0.0",
68
+ "bare-stream": "^2.13.1",
69
+ "bare-type-stripper": "^0.1.2",
70
+ "paparam": "^1.5.0"
71
+ },
72
+ "devDependencies": {
73
+ "bare-rpc": "^1.3.2",
74
+ "bare-sidecar": "^0.5.0",
75
+ "brittle": "^4.0.2",
76
+ "lunte": "^1.7.0",
77
+ "prettier": "^3.3.3",
78
+ "prettier-config-holepunch": "^2.0.0",
79
+ "which-runtime": "^1.4.0"
80
+ },
81
+ "peerDependencies": {
82
+ "bare-buffer": "^3.6.0",
83
+ "bare-url": "^2.4.0"
84
+ },
85
+ "peerDependenciesMeta": {
86
+ "bare-buffer": {
87
+ "optional": true
88
+ },
89
+ "bare-url": {
90
+ "optional": true
91
+ }
92
+ }
93
+ }