pi-pocket 0.25.0 → 0.26.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 (85) hide show
  1. package/AGENTS.md +2 -0
  2. package/README.md +5 -3
  3. package/docs/architecture.md +21 -0
  4. package/docs/design/design-mode.md +108 -0
  5. package/docs/design/notes-a.md +106 -0
  6. package/docs/design/notes-b.md +123 -0
  7. package/docs/design/notes-c.md +92 -0
  8. package/docs/design/notes-d.md +78 -0
  9. package/docs/design/release-notes-design.md +46 -0
  10. package/docs/extensions/browser-modules.md +2 -0
  11. package/docs/extensions/policies/api-stability.md +2 -0
  12. package/docs/extensions/reference/api-versions.md +1 -0
  13. package/docs/extensions/reference/host.md +1 -1
  14. package/docs/extensions/reference/limits.md +4 -0
  15. package/docs/extensions/reference/names.md +2 -2
  16. package/docs/extensions/reference/pocket.md +38 -0
  17. package/docs/features.md +19 -5
  18. package/docs/map.md +75 -54
  19. package/docs/release-notes.md +1 -1
  20. package/docs/self-editing.md +1 -1
  21. package/docs/systemd.md +1 -1
  22. package/npm-shrinkwrap.json +2 -2
  23. package/package.json +1 -1
  24. package/src/launcher/main.ts +20 -9
  25. package/src/server/app.ts +113 -4
  26. package/src/server/background.ts +3 -3
  27. package/src/server/cache-keeper.ts +605 -0
  28. package/src/server/compaction.ts +68 -15
  29. package/src/server/design/bundle.ts +65 -0
  30. package/src/server/design/export.ts +118 -0
  31. package/src/server/design/files.ts +49 -0
  32. package/src/server/design/guide.ts +56 -0
  33. package/src/server/design/index.ts +232 -0
  34. package/src/server/design/pptx.ts +304 -0
  35. package/src/server/design/render.ts +593 -0
  36. package/src/server/design/system.ts +248 -0
  37. package/src/server/docs.ts +55 -0
  38. package/src/server/extensions/artifacts.ts +202 -18
  39. package/src/server/extensions/design/canvas.js +304 -0
  40. package/src/server/extensions/design/comments.js +15 -0
  41. package/src/server/extensions/design/data.js +263 -0
  42. package/src/server/extensions/design/devices.js +70 -0
  43. package/src/server/extensions/design/docks.js +647 -0
  44. package/src/server/extensions/design/edits.js +37 -0
  45. package/src/server/extensions/design/index.js +326 -0
  46. package/src/server/extensions/design/messages.js +92 -0
  47. package/src/server/extensions/design/parts.js +160 -0
  48. package/src/server/extensions/design/state.js +146 -0
  49. package/src/server/extensions/design/style.css +1332 -0
  50. package/src/server/extensions/design/tweaks.js +161 -0
  51. package/src/server/extensions/design/views.js +375 -0
  52. package/src/server/extensions/design/workspace.js +723 -0
  53. package/src/server/extensions/design.ts +620 -0
  54. package/src/server/extensions/plan.ts +11 -9
  55. package/src/server/extensions/prompt.ts +11 -3
  56. package/src/server/extensions/subagents.ts +7 -1
  57. package/src/server/extensions/updates/index.js +16 -6
  58. package/src/server/extensions/updates.ts +2 -2
  59. package/src/server/http/artifact-assets.ts +216 -0
  60. package/src/server/http/artifact-inspect.ts +1281 -0
  61. package/src/server/http/artifacts.ts +89 -14
  62. package/src/server/http/conversation-routes.ts +46 -1
  63. package/src/server/http.ts +12 -4
  64. package/src/server/main.ts +4 -0
  65. package/src/server/npm-install.ts +82 -0
  66. package/src/server/npm-update.ts +100 -0
  67. package/src/server/reload.ts +5 -0
  68. package/src/server/room.ts +2 -0
  69. package/src/server/spend.ts +73 -9
  70. package/src/server/update-state.ts +257 -8
  71. package/src/server/updates.ts +268 -33
  72. package/src/server/zip.ts +163 -0
  73. package/types/pocket.d.ts +32 -0
  74. package/web/activity-fold.js +28 -0
  75. package/web/artifact-bridge.js +506 -82
  76. package/web/extension-ui.js +21 -1
  77. package/web/pip.js +46 -9
  78. package/web/sessions.js +1 -1
  79. package/web/sheets/appearance.js +10 -0
  80. package/web/sheets/viewers.js +26 -1
  81. package/web/style.css +11 -0
  82. package/web/taps.js +26 -0
  83. package/web/theme.js +6 -0
  84. package/web/transcript.js +19 -10
  85. package/src/server/http/public.ts +0 -30
@@ -0,0 +1,146 @@
1
+ // The workspace's state: one small store for the whole tab, made when the module loads. It lives outside the panel's
2
+ // component, so going back to the chat on a phone (which closes the panel) and coming again keeps the canvas as it was.
3
+
4
+ /** A store: `get()`, `set(patch or fn)`, and `subscribe(listener)`. */
5
+ export function createStore(initial) {
6
+ let state = initial;
7
+ const listeners = new Set();
8
+
9
+ return {
10
+ get: () => state,
11
+ set(patch) {
12
+ const next = typeof patch === "function" ? patch(state) : patch;
13
+
14
+ state = { ...state, ...next };
15
+
16
+ for (const listener of [...listeners]) {
17
+ listener(state);
18
+ }
19
+ },
20
+ subscribe(listener) {
21
+ listeners.add(listener);
22
+
23
+ return () => listeners.delete(listener);
24
+ },
25
+ };
26
+ }
27
+
28
+ /** The state of the store, drawn again when it changes. */
29
+ export function useStore(pocket, store) {
30
+ const [, draw] = pocket.useState(0);
31
+
32
+ pocket.useEffect(() => {
33
+ const stop = store.subscribe(() => draw((count) => count + 1));
34
+
35
+ draw((count) => count + 1);
36
+
37
+ return stop;
38
+ }, [store]);
39
+
40
+ return store.get();
41
+ }
42
+
43
+ const PREFS = "x.design.prefs";
44
+ const PICK = "x.design.pick";
45
+
46
+ const read = (storage, key) => {
47
+ try {
48
+ return JSON.parse(storage.getItem(key) ?? "null");
49
+ } catch {
50
+ return null;
51
+ }
52
+ };
53
+
54
+ const write = (storage, key, value) => {
55
+ try {
56
+ storage.setItem(key, JSON.stringify(value));
57
+ } catch {
58
+ // Private mode or a full store: the choice lasts until the page loads again.
59
+ }
60
+ };
61
+
62
+ /** What a person chose for how the canvas looks: kept in this browser. */
63
+ export function loadPrefs() {
64
+ const saved = read(localStorage, PREFS) ?? {};
65
+ const small = typeof innerWidth === "number" && innerWidth < 700;
66
+
67
+ return {
68
+ device: ["mobile", "tablet", "desktop", "slide", "custom"].includes(saved.device)
69
+ ? saved.device
70
+ : small
71
+ ? "mobile"
72
+ : "desktop",
73
+ custom: saved.custom ?? { w: 800, h: 600 },
74
+ zoom: saved.zoom === "fit" || typeof saved.zoom === "number" ? saved.zoom : "fit",
75
+ backdrop: ["auto", "light", "dark"].includes(saved.backdrop) ? saved.backdrop : "auto",
76
+ };
77
+ }
78
+
79
+ export function savePrefs(state) {
80
+ write(localStorage, PREFS, {
81
+ device: state.device,
82
+ custom: state.custom,
83
+ zoom: state.zoom,
84
+ backdrop: state.backdrop,
85
+ });
86
+ }
87
+
88
+ /** The design last open in a session, kept for the tab: a reload goes back to it. */
89
+ export function loadPick(conversation) {
90
+ const all = read(sessionStorage, PICK) ?? {};
91
+
92
+ return all[conversation] ?? null;
93
+ }
94
+
95
+ export function savePick(conversation, pick) {
96
+ const all = read(sessionStorage, PICK) ?? {};
97
+
98
+ all[conversation] = pick;
99
+ write(sessionStorage, PICK, all);
100
+ }
101
+
102
+ /** The parts of the state that belong to one session: all of it but how the canvas looks. */
103
+ export function sessionState() {
104
+ return {
105
+ /** The session's designs as the server lists them, with their group and kind: `null` until the first answer. */
106
+ listed: null,
107
+ /** The artifact open, and its version (`null` follows the newest). */
108
+ artifact: null,
109
+ version: null,
110
+ /** What fills the canvas: the frame, two versions side by side, or the group's variations. */
111
+ view: "canvas",
112
+ compare: null,
113
+ /** How the page answers a tap: not at all, a comment, or a text edit. */
114
+ mode: "view",
115
+ /** The side panel: `versions`, `comments`, `edits`, `tweaks`, or none. */
116
+ dock: null,
117
+ /** Comments and tweaks by artifact id, as the server has them. */
118
+ notes: {},
119
+ /** A pick not yet saved as a comment: the element and the version it was made on. */
120
+ draft: null,
121
+ /** The comments last put in the message box, by design: the ones "mark them done" is for. */
122
+ sent: {},
123
+ /** Text edits by `artifact@version`, not yet sent. */
124
+ edits: {},
125
+ /** The page's own tweak knobs, and what was set (by artifact id). */
126
+ knobs: [],
127
+ /** The frame (its address) the knobs came from. */
128
+ knobsKey: "",
129
+ tweaks: {},
130
+ deck: null,
131
+ /** The slide the deck was last on (0 first): a page that loads again goes back to it. */
132
+ slide: 0,
133
+ present: false,
134
+ /** A request from outside to open an artifact (the viewer's button, the command): the panel takes it once. */
135
+ wanted: null,
136
+ /** Bumped to load the frame again. */
137
+ reload: 0,
138
+ /** Whether the frame's bridge can inspect, edit, and tweak (it is there when the bridge has `send`). */
139
+ bridge: true,
140
+ };
141
+ }
142
+
143
+ /** The state before anything is chosen. */
144
+ export function initialState() {
145
+ return { ...loadPrefs(), width: 0, conversation: null, ...sessionState() };
146
+ }