sliftutils 1.4.6 → 1.4.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sliftutils",
3
- "version": "1.4.6",
3
+ "version": "1.4.8",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -95,6 +95,16 @@ function loadRemoteConfig(): RemoteConfig | undefined {
95
95
  }
96
96
  function saveRemoteConfig(c: RemoteConfig) { localStorage.setItem(remoteConfigKey(), JSON.stringify(c)); }
97
97
 
98
+ // The server is always HTTPS on the filehoster's default port, so the user only needs to type the host
99
+ // (e.g. "65.109.93.113"). We strip any scheme/path they include and default the port if omitted.
100
+ const DEFAULT_REMOTE_PORT = 8787; // matches remoteFileServer.js's default
101
+ function normalizeServerUrl(raw: string): string {
102
+ let s = raw.trim().replace(/^\w+:\/\//, "").replace(/\/.*$/, "");
103
+ if (!s) return "";
104
+ if (!/:\d+$/.test(s)) s += ":" + DEFAULT_REMOTE_PORT;
105
+ return "https://" + s;
106
+ }
107
+
98
108
  // One shared factory (and therefore one shared range cache) per remote config.
99
109
  let remoteFactory: { key: string; factory: ReturnType<typeof getRemoteFileStorage> } | undefined;
100
110
  function getRemoteFactory(remote: RemoteConfig) {
@@ -128,8 +138,8 @@ class DirectoryPrompter extends preact.Component {
128
138
  // reloads so getFileStorageNested2 picks up the remote storage.
129
139
  @observer
130
140
  class ServerConnectForm extends preact.Component {
131
- private obs = observable({ expanded: false, url: "", password: "", error: "", connecting: false, needsCert: false });
132
- private cleanUrl() { return this.obs.url.trim().replace(/\/+$/, ""); }
141
+ private obs = observable({ expanded: false, url: "", password: "", error: "", connecting: false, needsCert: false, showPassword: false });
142
+ private cleanUrl() { return normalizeServerUrl(this.obs.url); }
133
143
  private connect = async () => {
134
144
  const s = this.obs;
135
145
  s.error = "";
@@ -166,10 +176,15 @@ class ServerConnectForm extends preact.Component {
166
176
  }
167
177
  return (
168
178
  <div className={css.vbox(16).center}>
169
- <input className={inputCss} placeholder="https://host:8787" value={s.url}
179
+ <input className={inputCss} placeholder="server address (e.g. 65.109.93.113, or host:port)" value={s.url}
170
180
  onInput={e => s.url = (e.target as HTMLInputElement).value} />
171
- <input className={inputCss} type="password" placeholder="password (six words)" value={s.password}
172
- onInput={e => s.password = (e.target as HTMLInputElement).value} />
181
+ <div className={css.hbox(10).center}>
182
+ <input className={inputCss} type={s.showPassword ? "text" : "password"} placeholder="password (six words)" value={s.password}
183
+ onInput={e => s.password = (e.target as HTMLInputElement).value} />
184
+ <button className={css.fontSize(22).pad2(24, 12)} onClick={() => s.showPassword = !s.showPassword}>
185
+ {s.showPassword ? "Hide" : "Show"}
186
+ </button>
187
+ </div>
173
188
  {s.error ? <div className={css.fontSize(22).color("red").maxWidth("80vw")}>{s.error}</div> : null}
174
189
  {s.needsCert ? (
175
190
  <div className={css.vbox(10).center.fontSize(20).maxWidth(620).maxWidth("80vw").textAlign("center").color("hsl(0, 0%, 25%)")}>