@andrew_l/app 0.3.7 → 0.4.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 CHANGED
@@ -170,9 +170,10 @@ export default defineWorker({
170
170
  },
171
171
  },
172
172
 
173
- async entry() {
173
+ async entry(props, abortSignal) {
174
174
  const pending = await fetchPending();
175
175
  for (const msg of pending) {
176
+ if (abortSignal.aborted) break;
176
177
  await this.send(msg.to, msg.body);
177
178
  }
178
179
  },
package/bin/vrun CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/bin/bash
2
2
 
3
- ROOT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
4
- SCRIPT_FILE="$ROOT_DIR/../dist/vrun.mjs"
5
- TSX_BIN="$ROOT_DIR/../node_modules/.bin/tsx"
3
+ ROOT_DIR="$(cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
4
+ PKG_DIR="$(cd -P -- "$ROOT_DIR/.." && pwd)"
5
+ SCRIPT_FILE="$PKG_DIR/dist/vrun.mjs"
6
6
  DEV_MODE=0
7
7
  WATCH_MODE=0
8
8
  ARGS=()
@@ -18,12 +18,35 @@ for arg in "$@"; do
18
18
  fi
19
19
  done
20
20
 
21
+ resolve_tsx_cli() {
22
+ # pnpm peer layout: peer is a sibling of the package's parent scope dir.
23
+ local candidate="$PKG_DIR/../../tsx/dist/cli.mjs"
24
+ if [ -f "$candidate" ]; then
25
+ printf '%s\n' "$candidate"
26
+ return
27
+ fi
28
+ # Hoisted layout: walk up looking for node_modules/tsx.
29
+ local dir="$PKG_DIR"
30
+ while [ -n "$dir" ] && [ "$dir" != "/" ]; do
31
+ if [ -f "$dir/node_modules/tsx/dist/cli.mjs" ]; then
32
+ printf '%s\n' "$dir/node_modules/tsx/dist/cli.mjs"
33
+ return
34
+ fi
35
+ dir="${dir%/*}"
36
+ done
37
+ }
38
+
21
39
  if [ $DEV_MODE -eq 1 ]; then
22
40
  if [ $WATCH_MODE -eq 1 ]; then
23
- exec env VRUN=true VRUN_TS_MODE=tsx VRUN_WATCH=true "$TSX_BIN" watch $SCRIPT_FILE "${ARGS[@]}"
41
+ TSX_CLI="$(resolve_tsx_cli)"
42
+ if [ -z "$TSX_CLI" ]; then
43
+ echo "vrun: cannot resolve tsx peer dependency. Install tsx ^4.22.4." >&2
44
+ exit 1
45
+ fi
46
+ exec env VRUN=true VRUN_TS_MODE=tsx-register VRUN_WATCH=true node --watch "$SCRIPT_FILE" "${ARGS[@]}"
24
47
  else
25
- exec env VRUN=true VRUN_TS_MODE=tsx-register node $SCRIPT_FILE "$@"
48
+ exec env VRUN=true VRUN_TS_MODE=tsx-register node "$SCRIPT_FILE" "$@"
26
49
  fi
27
50
  else
28
- exec env VRUN=true node $SCRIPT_FILE "$@"
51
+ exec env VRUN=true node "$SCRIPT_FILE" "$@"
29
52
  fi
@@ -0,0 +1,2 @@
1
+ import { cli } from "../index.mjs";
2
+ export { cli };