@x-tech-laboratories/x-libs 0.8.0 → 0.11.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.
Files changed (61) hide show
  1. package/README.md +49 -8
  2. package/dist/electron/bridge.d.ts +26 -3
  3. package/dist/electron/bridge.js +57 -5
  4. package/dist/electron/fetch.d.ts +27 -0
  5. package/dist/electron/fetch.js +109 -1
  6. package/dist/server/config.d.ts +39 -0
  7. package/dist/server/config.js +109 -0
  8. package/dist/server/cors.d.ts +8 -0
  9. package/dist/server/cors.js +13 -0
  10. package/dist/server/events.d.ts +33 -0
  11. package/dist/server/events.js +68 -0
  12. package/dist/server/login_page.d.ts +8 -0
  13. package/dist/server/login_page.js +79 -0
  14. package/dist/server/replies.d.ts +12 -0
  15. package/dist/server/replies.js +41 -0
  16. package/dist/server/sign_in.d.ts +27 -0
  17. package/dist/server/sign_in.js +95 -0
  18. package/dist/server/web_folder.d.ts +11 -0
  19. package/dist/server/web_folder.js +40 -0
  20. package/dist/web/dom.d.ts +2 -0
  21. package/dist/web/dom.js +5 -1
  22. package/dist/web/errors.d.ts +1 -0
  23. package/dist/web/errors.js +27 -0
  24. package/dist/web/react/badges.d.ts +9 -0
  25. package/dist/web/react/badges.js +4 -0
  26. package/dist/web/react/controls.d.ts +16 -2
  27. package/dist/web/react/controls.js +75 -10
  28. package/dist/web/react/following.d.ts +25 -0
  29. package/dist/web/react/following.js +34 -0
  30. package/dist/web/react/layout.d.ts +11 -0
  31. package/dist/web/react/layout.js +6 -1
  32. package/dist/web/react/markdown.d.ts +8 -0
  33. package/dist/web/react/markdown.js +40 -0
  34. package/dist/web/react/media.js +1 -1
  35. package/dist/web/react/menu_button.d.ts +1 -1
  36. package/dist/web/react/menu_button.js +7 -3
  37. package/dist/web/react/menus.d.ts +1 -1
  38. package/dist/web/react/menus.js +5 -3
  39. package/dist/web/react/page_view.d.ts +16 -0
  40. package/dist/web/react/page_view.js +6 -0
  41. package/dist/web/react/progress.d.ts +10 -0
  42. package/dist/web/react/progress.js +9 -0
  43. package/dist/web/react/rating.d.ts +8 -0
  44. package/dist/web/react/rating.js +23 -0
  45. package/dist/web/react/states.d.ts +11 -2
  46. package/dist/web/react/states.js +29 -14
  47. package/dist/web/react/store.d.ts +4 -0
  48. package/dist/web/react/store.js +7 -0
  49. package/dist/web/react/suggestions.d.ts +23 -0
  50. package/dist/web/react/suggestions.js +57 -0
  51. package/dist/web/react/table.d.ts +1 -0
  52. package/dist/web/react/table.js +2 -1
  53. package/dist/web/react/test_stubs.d.ts +1 -0
  54. package/dist/web/react/test_stubs.js +25 -0
  55. package/dist/web/react/volume.d.ts +8 -0
  56. package/dist/web/react/volume.js +42 -0
  57. package/dist/web/store.d.ts +11 -0
  58. package/dist/web/store.js +17 -0
  59. package/dist/web/watch.d.ts +5 -0
  60. package/dist/web/watch.js +20 -0
  61. package/package.json +24 -2
@@ -0,0 +1,17 @@
1
+ // A value a page reads and events change, with a watch that redraws only what reads it.
2
+ import { coalesce_bumps, create_watch } from "./watch.js";
3
+ export function create_store(initial, options = {}) {
4
+ let value = initial;
5
+ const watch = create_watch();
6
+ const bump = options.coalesce_in_milliseconds ? coalesce_bumps(watch, options.coalesce_in_milliseconds) : watch.bump;
7
+ const set = (next) => {
8
+ value = next;
9
+ bump();
10
+ };
11
+ return {
12
+ get: () => value,
13
+ set,
14
+ update: (make) => set(make(value)),
15
+ watch,
16
+ };
17
+ }
@@ -4,3 +4,8 @@ export interface Watch {
4
4
  subscribe(listener: () => void): () => void;
5
5
  }
6
6
  export declare function create_watch(): Watch;
7
+ export interface CoalescedBump {
8
+ (): void;
9
+ cancel(): void;
10
+ }
11
+ export declare function coalesce_bumps(watch: Watch, interval_in_milliseconds: number, now?: () => number): CoalescedBump;
package/dist/web/watch.js CHANGED
@@ -15,3 +15,23 @@ export function create_watch() {
15
15
  },
16
16
  };
17
17
  }
18
+ export function coalesce_bumps(watch, interval_in_milliseconds, now = () => performance.now()) {
19
+ let timer = null;
20
+ let last_bump_at = -Infinity;
21
+ const schedule = () => {
22
+ if (timer !== null)
23
+ return;
24
+ const wait = Math.max(0, interval_in_milliseconds - (now() - last_bump_at));
25
+ timer = setTimeout(() => {
26
+ timer = null;
27
+ last_bump_at = now();
28
+ watch.bump();
29
+ }, wait);
30
+ };
31
+ schedule.cancel = () => {
32
+ if (timer !== null)
33
+ clearTimeout(timer);
34
+ timer = null;
35
+ };
36
+ return schedule;
37
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@x-tech-laboratories/x-libs",
3
- "version": "0.8.0",
4
- "description": "Code the X-apps share: agents and their long runs, passwords, durations, and the web page's helpers and widgets",
3
+ "version": "0.11.0",
4
+ "description": "Code the X-apps share: agents and their long runs, passwords and sign-in, the Fastify server pieces, durations, and the web page's helpers and widgets",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {
7
7
  "type": "git",
@@ -27,12 +27,28 @@
27
27
  "prepack": "npm run build"
28
28
  },
29
29
  "peerDependencies": {
30
+ "@fastify/cookie": "^11.1.5",
31
+ "@fastify/cors": "^11.4.1",
32
+ "@fastify/formbody": "^9.0.1",
33
+ "@fastify/static": "^10.1.10",
30
34
  "@fastify/websocket": "^11.3.5",
31
35
  "fastify": "^5.12.7",
32
36
  "react": "^19",
33
37
  "react-dom": "^19"
34
38
  },
35
39
  "peerDependenciesMeta": {
40
+ "@fastify/cookie": {
41
+ "optional": true
42
+ },
43
+ "@fastify/cors": {
44
+ "optional": true
45
+ },
46
+ "@fastify/formbody": {
47
+ "optional": true
48
+ },
49
+ "@fastify/static": {
50
+ "optional": true
51
+ },
36
52
  "@fastify/websocket": {
37
53
  "optional": true
38
54
  },
@@ -47,6 +63,10 @@
47
63
  }
48
64
  },
49
65
  "devDependencies": {
66
+ "@fastify/cookie": "^11.1.5",
67
+ "@fastify/cors": "^11.4.1",
68
+ "@fastify/formbody": "^9.0.1",
69
+ "@fastify/static": "^10.1.10",
50
70
  "@fastify/websocket": "^11.3.5",
51
71
  "@testing-library/dom": "^10.4.2",
52
72
  "@testing-library/react": "^16.3.3",
@@ -65,6 +85,8 @@
65
85
  "dependencies": {
66
86
  "@inquirer/password": "^5.2.5",
67
87
  "@tanstack/react-table": "^8.21.3",
88
+ "dompurify": "^3.4.17",
89
+ "marked": "^18.1.3",
68
90
  "parse-duration": "^2.1.11",
69
91
  "pretty-bytes": "^7.2.0",
70
92
  "sshpk": "^1.18.0"