sliftutils 1.7.8 → 1.7.10

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.
Files changed (43) hide show
  1. package/bin/storageserver.js +4 -0
  2. package/bundler/bundleEntry.ts +14 -10
  3. package/bundler/bundler.ts +6 -1
  4. package/{teststorage → examplestorage}/browser.tsx +18 -22
  5. package/{teststorage/server.ts → examplestorage/exampleserver.ts} +5 -5
  6. package/index.d.ts +528 -78
  7. package/misc/https/dns.d.ts +7 -3
  8. package/misc/https/dns.ts +4 -9
  9. package/misc/https/hostServer.d.ts +6 -3
  10. package/misc/https/hostServer.ts +6 -6
  11. package/package.json +2 -1
  12. package/spec.txt +77 -42
  13. package/storage/ArchivesDisk.d.ts +65 -0
  14. package/storage/ArchivesDisk.ts +365 -0
  15. package/storage/IArchives.d.ts +95 -1
  16. package/storage/IArchives.ts +146 -1
  17. package/storage/backblaze.d.ts +14 -2
  18. package/storage/backblaze.ts +18 -2
  19. package/storage/remoteStorage/ArchivesRemote.d.ts +29 -17
  20. package/storage/remoteStorage/ArchivesRemote.ts +63 -63
  21. package/storage/remoteStorage/ArchivesUrl.d.ts +46 -0
  22. package/storage/remoteStorage/ArchivesUrl.ts +74 -0
  23. package/storage/remoteStorage/accessPage.tsx +111 -28
  24. package/storage/remoteStorage/blobStore.d.ts +79 -25
  25. package/storage/remoteStorage/blobStore.ts +441 -287
  26. package/storage/remoteStorage/cliArgs.d.ts +1 -0
  27. package/storage/remoteStorage/cliArgs.ts +9 -0
  28. package/storage/remoteStorage/createArchives.d.ts +64 -0
  29. package/storage/remoteStorage/createArchives.ts +395 -0
  30. package/storage/remoteStorage/grantAccess.js +4 -0
  31. package/storage/remoteStorage/grantAccessCli.d.ts +1 -0
  32. package/storage/remoteStorage/grantAccessCli.ts +27 -0
  33. package/storage/remoteStorage/remoteConfig.d.ts +21 -0
  34. package/storage/remoteStorage/remoteConfig.ts +94 -0
  35. package/storage/remoteStorage/storageController.d.ts +19 -27
  36. package/storage/remoteStorage/storageController.ts +205 -136
  37. package/storage/remoteStorage/storageServer.d.ts +11 -0
  38. package/storage/remoteStorage/storageServer.ts +80 -93
  39. package/storage/remoteStorage/storageServerCli.d.ts +1 -0
  40. package/storage/remoteStorage/storageServerCli.ts +41 -0
  41. package/storage/remoteStorage/storageServerState.d.ts +37 -0
  42. package/storage/remoteStorage/storageServerState.ts +358 -0
  43. package/testsite/server.ts +1 -1
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ require("typenode");
4
+ require("../storage/remoteStorage/storageServerCli");
@@ -32,7 +32,6 @@ async function main() {
32
32
  if (name.endsWith(".ts") || name.endsWith(".tsx")) {
33
33
  name = name.split(".").slice(0, -1).join(".");
34
34
  }
35
- name += ".js";
36
35
 
37
36
  let modules = Object.values(require.cache).filter(x => x?.id !== module.id);
38
37
 
@@ -42,16 +41,21 @@ async function main() {
42
41
  entryPoints: [entryPoint],
43
42
  });
44
43
 
45
- let finalPath = `${outputFolder}/${name}`;
46
- let tempPath = `${finalPath}.tmp`;
47
-
48
- try {
49
- await fs.promises.writeFile(tempPath, bundled.bundle);
50
- await fs.promises.rename(tempPath, finalPath);
51
- } finally {
44
+ // Two artifacts: `name.js` without the sourcemap (the sourcemap is usually bigger than the code
45
+ // itself, so this is what production serves) and `name.debug.js` with the inline sourcemap
46
+ // appended (serve it behind something like a ?debug query param).
47
+ async function write(finalPath: string, contents: string) {
48
+ let tempPath = `${finalPath}.tmp`;
52
49
  try {
53
- await fs.promises.unlink(tempPath);
54
- } catch { }
50
+ await fs.promises.writeFile(tempPath, contents);
51
+ await fs.promises.rename(tempPath, finalPath);
52
+ } finally {
53
+ try {
54
+ await fs.promises.unlink(tempPath);
55
+ } catch { }
56
+ }
55
57
  }
58
+ await write(`${outputFolder}/${name}.js`, bundled.bundle);
59
+ await write(`${outputFolder}/${name}.debug.js`, bundled.bundle + "\n" + bundled.sourceMapComment);
56
60
  }
57
61
  main().catch(err => { console.error(err); process.exitCode = 1; }).finally(() => process.exit());
@@ -9,7 +9,12 @@ export async function bundle(config: {
9
9
  rootPath: string;
10
10
  entryPoints: string[];
11
11
  }): Promise<{
12
+ // The runnable bundle, WITHOUT the sourcemap comment (the sourcemap is usually bigger than the
13
+ // code itself, so the default artifact ships without it).
12
14
  bundle: string;
15
+ // The trailing inline-sourcemap line comment. Append to `bundle` (with a newline) for the debug
16
+ // variant of the bundle.
17
+ sourceMapComment: string;
13
18
  }> {
14
19
  const { modules, rootPath, entryPoints } = config;
15
20
 
@@ -55,9 +60,9 @@ export async function bundle(config: {
55
60
  code += `\n;globalThis.require(${JSON.stringify(entryPoint)});`;
56
61
  }
57
62
  code += "\n;});";
58
- code += "\n" + encodeSourceMapLineComment(finalizeInProgressSourceMap(inProgressSourceMap));
59
63
  return {
60
64
  bundle: code,
65
+ sourceMapComment: encodeSourceMapLineComment(finalizeInProgressSourceMap(inProgressSourceMap)),
61
66
  };
62
67
  }
63
68
 
@@ -9,24 +9,18 @@ import { formatNumber, formatDateTime } from "socket-function/src/formatting/for
9
9
  import { css } from "typesafecss";
10
10
  import { InputLabel } from "../render-utils/InputLabel";
11
11
  import { redButton, greenButton, errorMessage } from "../render-utils/colors";
12
- import { ArchivesRemote } from "../storage/remoteStorage/ArchivesRemote";
12
+ import { createArchives } from "../storage/remoteStorage/createArchives";
13
13
  import { ArchiveFileInfo } from "../storage/IArchives";
14
14
 
15
- const STORAGE_ADDRESS = "storage.vidgridweb.com";
16
- const STORAGE_PORT = 4444;
17
- const ACCOUNT = "test";
18
- const BUCKET = "testfiles";
15
+ // The bucket's routing URL: server, account ("example"), and bucket ("examplefiles") in one.
16
+ // Nothing else is needed - the first call creates the bucket if it doesn't exist yet.
17
+ const STORAGE_URL = "https://storage.vidgridweb.com:4444/file/example/examplefiles/storage/storagerouting.json";
19
18
  const ACCESS_CHECK_INTERVAL = 1000 * 15;
20
19
 
21
- const archives = new ArchivesRemote({
22
- address: STORAGE_ADDRESS,
23
- port: STORAGE_PORT,
24
- account: ACCOUNT,
25
- bucketName: BUCKET,
26
- });
20
+ const archives = createArchives(STORAGE_URL);
27
21
 
28
22
  @observer
29
- class TestStoragePage extends preact.Component {
23
+ class ExampleStoragePage extends preact.Component {
30
24
  synced = observable({
31
25
  files: [] as ArchiveFileInfo[],
32
26
  loaded: false,
@@ -34,16 +28,16 @@ class TestStoragePage extends preact.Component {
34
28
  content: "",
35
29
  contentLoaded: false,
36
30
  newFileName: "",
37
- accessLink: "",
31
+ access: undefined as { link: string; machineId: string; ip: string } | undefined,
38
32
  error: "",
39
33
  });
40
34
 
41
35
  componentDidMount() {
42
36
  void (async () => {
43
37
  while (true) {
44
- let link = await archives.waitingForAccess();
45
- this.synced.accessLink = link || "";
46
- if (!link) break;
38
+ let access = await archives.waitingForAccess();
39
+ this.synced.access = access;
40
+ if (!access) break;
47
41
  await delay(ACCESS_CHECK_INTERVAL);
48
42
  }
49
43
  await this.refresh();
@@ -90,12 +84,14 @@ class TestStoragePage extends preact.Component {
90
84
  render() {
91
85
  let synced = this.synced;
92
86
  return <div className={css.vbox(12).pad2(16)}>
93
- <div>Storage test site. Account {ACCOUNT}, bucket {BUCKET} on {STORAGE_ADDRESS}:{STORAGE_PORT}</div>
87
+ <div>Storage example site. Bucket {STORAGE_URL}</div>
94
88
  {synced.error && <div className={errorMessage}>{synced.error}</div>}
95
- {!synced.loaded && !synced.accessLink && <div>Loading files...</div>}
96
- {!synced.loaded && synced.accessLink && <div className={css.vbox(8)}>
97
- <div>This machine does not have access to the account yet. Grant it here:</div>
98
- <a href={synced.accessLink} target="_blank">{synced.accessLink}</a>
89
+ {!synced.loaded && !synced.access && <div>Loading files...</div>}
90
+ {!synced.loaded && synced.access && <div className={css.vbox(8)}>
91
+ <div>This machine does not have access to the account yet.</div>
92
+ <div>Machine: {synced.access.machineId}</div>
93
+ <div>IP: {synced.access.ip}</div>
94
+ <a href={synced.access.link} target="_blank">{synced.access.link}</a>
99
95
  </div>}
100
96
  {synced.loaded && <div className={css.hbox(24).alignItems("flex-start")}>
101
97
  <div className={css.vbox(8)}>
@@ -142,7 +138,7 @@ class TestStoragePage extends preact.Component {
142
138
 
143
139
  async function main() {
144
140
  if (isNode()) return;
145
- preact.render(<TestStoragePage />, document.body);
141
+ preact.render(<ExampleStoragePage />, document.body);
146
142
  }
147
143
 
148
144
  main().catch(console.error);
@@ -7,10 +7,10 @@ import { hostServer } from "../misc/https/hostServer";
7
7
  // Import browser code, so it is allowed to be required by the client
8
8
  import "./browser";
9
9
 
10
- // Static test site for the remote storage system (storage/remoteStorage). The browser talks to
10
+ // Static example site for the remote storage system (storage/remoteStorage). The browser talks to
11
11
  // the storage server directly, so this server only serves the page.
12
12
 
13
- const DOMAIN = "stest.vidgridweb.com";
13
+ const DOMAIN = "storageexample.vidgridweb.com";
14
14
  const PORT = 4445;
15
15
 
16
16
  process.on("unhandledRejection", (error) => {
@@ -24,17 +24,17 @@ async function main() {
24
24
  RequireController.allowAllNodeModules();
25
25
  SocketFunction.expose(RequireController);
26
26
  SocketFunction.setDefaultHTTPCall(RequireController, "requireHTML", {
27
- requireCalls: ["./teststorage/browser.tsx"],
27
+ requireCalls: ["./examplestorage/browser.tsx"],
28
28
  });
29
29
  RequireController.addStaticRoot(path.resolve("."));
30
30
 
31
31
  await hostServer({
32
32
  domain: DOMAIN,
33
33
  port: PORT,
34
- cloudflareApiTokenPath: os.homedir() + "/vidgridweb.com.key",
34
+ cloudflareApiToken: { path: os.homedir() + "/vidgridweb.com.key" },
35
35
  setDNSRecord: true,
36
36
  });
37
- console.log(`Storage test site running at https://${DOMAIN}:${PORT}`);
37
+ console.log(`Storage example site running at https://${DOMAIN}:${PORT}`);
38
38
  }
39
39
 
40
40
  main().catch(e => {