Skip to content

Commit

Permalink
fix: options passed into Session should parse strings into booleans
Browse files Browse the repository at this point in the history
  • Loading branch information
calebjclark committed Jun 21, 2022
1 parent d537d28 commit 3990f84
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion core/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export const dataDir = process.env.ULX_DATA_DIR || Path.join(Os.tmpdir(), '.ulix

function booleanOrUndefined(envValue): boolean | undefined {
if (envValue === undefined) return undefined;
return Boolean(JSON.parse(envValue ?? 'false'));
return Boolean(typeof envValue === 'string' ? JSON.parse(envValue.toLowerCase()) : envValue);
}
2 changes: 1 addition & 1 deletion core/lib/InjectedScripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ${heroIncludes}
${pageScripts.domStorage}
})();`;

export const showInteractionScript = `(function installInteractionsScript() {
const showInteractionScript = `(function installInteractionsScript() {
const exports = {}; // workaround for ts adding an exports variable
window.selfFrameIdPath = '';
Expand Down
8 changes: 8 additions & 0 deletions core/lib/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,13 @@ export default class Session

protected constructor(readonly options: ISessionCreateOptions) {
super();

['showChrome', 'showChromeAlive', 'showChromeInteractions', 'sessionKeepAlive'].forEach(k => {
if (!(k in options)) return;
const v = options[k];
options[k] = Boolean(typeof v === 'string' ? JSON.parse(v.toLowerCase()) : v);
});

this.createdTime = Date.now();
this.id = this.getId(options.sessionId);
const id = this.id;
Expand Down Expand Up @@ -202,6 +209,7 @@ export default class Session
options.disableDevtools ??= env.disableDevtools;

Session.events.emit('new', { session: this });

// if no settings for chrome visiblity, default to headless
options.showChrome ??= false;
options.showChromeInteractions ??= options.showChrome;
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
"timetravel",
"plugin-utils",
"plugins/*",
"../commons/build",
"../../commons/build",
"../../net/build",
"../../unblocked/agent/build/*",
Expand Down
28 changes: 11 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,12 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.3.tgz#fad0b069ec205b0e81429c805d306d2c12e26be1"
integrity sha512-aIYL9Eemcecs1y77XzFGiSc+FdfN58k4J23UEe6+hynf4Wd9g4DzQPwIKL080vSMuubFqy2hWwOzCtJdc6vFKw==

"@types/node@^14.17.9", "@types/node@^14.18.18":
"@types/node@^14.17.9":
version "14.18.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.21.tgz#0155ee46f6be28b2ff0342ca1a9b9fd4468bef41"
integrity sha512-x5W9s+8P4XteaxT/jKF0PSb7XEvo5VmqEWgsMlyeY4ZlLK8I6aH6g5TPPyDlLAep+GYf4kefb7HFyc7PAO3m+Q==

"@types/node@^14.18.18":
version "14.18.18"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.18.tgz#5c9503030df484ccffcbb935ea9a9e1d6fad1a20"
integrity sha512-B9EoJFjhqcQ9OmQrNorItO+OwEOORNn3S31WuiHvZY/dm9ajkB7AKD/8toessEtHHNL+58jofbq7hMMY9v4yig==
Expand Down Expand Up @@ -2287,17 +2292,6 @@
progress "^2.0.3"
tar "^6.1.0"

"@ulixee/commons@2.0.0-alpha.4":
version "2.0.0-alpha.4"
resolved "https://registry.yarnpkg.com/@ulixee/commons/-/commons-2.0.0-alpha.4.tgz#06894ec878442cfdb3f9442eeba194d5844b8f0a"
integrity sha512-2ywccC6JgSX2CPeZRyi7V7njOhx/KU4xzg4u1lvDLbDHLYYZkl5bmDzN6Vj1ThyN9SzoLSFjQ54Z/0++ej+qEA==
dependencies:
bech32 "^2.0.0"
devtools-protocol "^0.0.981744"
https-proxy-agent "^5.0.0"
semver "^7.3.7"
source-map-js "^1.0.1"

"@ulixee/repo-tools@^1.0.11":
version "1.0.11"
resolved "https://registry.yarnpkg.com/@ulixee/repo-tools/-/repo-tools-1.0.11.tgz#57325e26adba2446a50c80c2cc7eddc7513b5c94"
Expand Down Expand Up @@ -3287,9 +3281,9 @@ core-js-pure@^3.16.0:
integrity sha512-qfskyO/KjtbYn09bn1IPkuhHl5PlJ6IzJ9s9sraJ1EqcuGyLGKzhSM1cY0zgyL9hx42eulQLZ6WaeK5ycJCkqw==

core-js-pure@^3.20.2:
version "3.22.7"
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.22.7.tgz#f58489d9b309fa7b26486a0f70d4ec19a418084e"
integrity sha512-wTriFxiZI+C8msGeh7fJcbC/a0V8fdInN1oS2eK79DMBGs8iIJiXhtFJCiT3rBa8w6zroHWW3p8ArlujZ/Mz+w==
version "3.23.2"
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.23.2.tgz#efe5e486469c5ed2d088d76e973eb12e74a930e7"
integrity sha512-t6u7H4Ff/yZNk+zqTr74UjCcZ3k8ApBryeLLV4rYQd9aF3gqmjjGjjR44ENfeBMH8VVvSynIjAJ0mUuFhzQtrA==

core-util-is@1.0.2:
version "1.0.2"
Expand Down Expand Up @@ -5683,7 +5677,7 @@ lerna@^4.0.0:
leven@2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/leven/-/leven-2.1.0.tgz#c2e7a9f772094dee9d34202ae8acce4687875580"
integrity sha1-wuep93IJTe6dNCAq6KzORoeHVYA=
integrity sha512-nvVPLpIHUxCUoRLrFqTgSxXJ614d8AgQoWl7zPe/2VadE8+1dpU3LBhowRuBAcuwruWtOdD8oYC9jDNJjXDPyA==

leven@^3.1.0:
version "3.1.0"
Expand Down Expand Up @@ -8085,7 +8079,7 @@ tr46@~0.0.3:
"traverse@>=0.3.0 <0.4":
version "0.3.9"
resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.3.9.tgz#717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9"
integrity sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk=
integrity sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ==

trim-newlines@^3.0.0:
version "3.0.1"
Expand Down

0 comments on commit 3990f84

Please sign in to comment.