oorja 2.1.2 → 2.1.4

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.
@@ -4,6 +4,7 @@ import { getDimensions, initScreen, areDimensionEqual, resizeBestFit } from './a
4
4
  import chalk from 'chalk';
5
5
  import { Unauthorized } from '../connect/errors.js';
6
6
  import { encrypt, decrypt } from '../encryption.js';
7
+ import { Future } from '../utils.js';
7
8
  var MessageType;
8
9
  (function (MessageType) {
9
10
  MessageType["IN"] = "i";
@@ -28,6 +29,8 @@ export const teletypeApp = (options) => {
28
29
  };
29
30
  return new Promise((resolve, reject) => {
30
31
  let sessionCount = 0;
32
+ let ptyReady = false;
33
+ const ptyFuture = new Future();
31
34
  const channel = options.joinChannel({
32
35
  channel: `teletype:${options.roomKey.roomId}`,
33
36
  params: {
@@ -47,28 +50,32 @@ export const teletypeApp = (options) => {
47
50
  cwd: options.process.cwd(),
48
51
  env: options.process.env,
49
52
  });
50
- setTimeout(() => {
53
+ ptyFuture.promise.then(() => {
51
54
  if (options.shell.endsWith('bash')) {
52
55
  stdout.write('Adjusting shell prompt to show streaming indicator\n');
53
56
  term.write("export PS1='📡 [streaming] '$PS1\n");
54
57
  }
55
58
  if (options.shell.endsWith('zsh')) {
56
59
  stdout.write('Adjusting shell prompt to show streaming indicator\n');
57
- const zshFunc = ' _streaming_prompt_precmd() { if [[ "$PROMPT" != *\'📡 [streaming] \'* ]]; then PROMPT="📡 [streaming] $PROMPT"; fi; }\n';
58
- const zshHook = ' precmd_functions+=(_streaming_prompt_precmd)\n';
59
- term.write(zshFunc);
60
- term.write(zshHook);
60
+ // FIXME: this doesnt work on macos (or its probably due to some conflict with powerlevel10k)
61
+ term.write("PROMPT='📡 [streaming] '$PROMPT\n");
61
62
  }
62
63
  if (options.shell.endsWith('fish')) {
63
64
  stdout.write('Adjusting shell prompt to show streaming indicator\n');
64
65
  term.write('functions -c fish_prompt __orig_fish_prompt; ' +
65
66
  "function fish_prompt; echo -n '📡 [streaming] '; __orig_fish_prompt; end\n");
66
67
  }
67
- }, 100); // wait for shell to be ready
68
+ });
68
69
  // track own dimensions and keep it up to date
69
70
  setInterval(reEvaluateOwnDimensions, 1000);
70
71
  term.onData((d) => {
71
72
  stdout.write(d);
73
+ if (!ptyReady) {
74
+ ptyReady = true;
75
+ setTimeout(() => {
76
+ ptyFuture.resolve(true);
77
+ }, 100);
78
+ }
72
79
  if (sessionCount < 2) {
73
80
  // 1 sub for own channel session
74
81
  // < 2 means no subscribers. no point pushing data.
@@ -1 +1,8 @@
1
1
  export declare const promptRoomLink: () => Promise<any>;
2
+ export declare class Future<T> {
3
+ promise: Promise<T>;
4
+ resolve?: (arg: T) => void;
5
+ reject?: (e: any) => void;
6
+ onFinally?: () => void;
7
+ constructor(futureBase?: (resolve: (arg: T) => void, reject: (e: any) => void) => void, onFinally?: () => void);
8
+ }
package/dist/lib/utils.js CHANGED
@@ -9,3 +9,20 @@ export const promptRoomLink = async () => {
9
9
  ]);
10
10
  return spaceLink;
11
11
  };
12
+ export class Future {
13
+ promise;
14
+ resolve;
15
+ reject;
16
+ onFinally;
17
+ constructor(futureBase, onFinally) {
18
+ this.onFinally = onFinally;
19
+ // eslint-disable-next-line no-async-promise-executor
20
+ this.promise = new Promise(async (resolve, reject) => {
21
+ this.resolve = resolve;
22
+ this.reject = reject;
23
+ if (futureBase) {
24
+ await futureBase(resolve, reject);
25
+ }
26
+ }).finally(() => this.onFinally?.());
27
+ }
28
+ }
@@ -85,5 +85,5 @@
85
85
  ]
86
86
  }
87
87
  },
88
- "version": "2.1.2"
88
+ "version": "2.1.4"
89
89
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "oorja",
3
3
  "description": "stream terminals to the web and more.",
4
- "version": "2.1.2",
4
+ "version": "2.1.4",
5
5
  "keywords": [
6
6
  "teletype",
7
7
  "terminal",