@vibes.diy/prompts 14.3.248 → 14.3.250

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 (114) hide show
  1. package/generation-variety.js +1 -1
  2. package/index.d.ts +1 -1
  3. package/index.js +1 -1
  4. package/index.js.map +1 -1
  5. package/llms/backend.js +1 -0
  6. package/llms/backend.js.map +1 -1
  7. package/llms/blockly.js +1 -0
  8. package/llms/blockly.js.map +1 -1
  9. package/llms/blockly.md +2 -3
  10. package/llms/board-games.js +9 -4
  11. package/llms/board-games.js.map +1 -1
  12. package/llms/board-games.md +3 -153
  13. package/llms/callai.js +1 -0
  14. package/llms/callai.js.map +1 -1
  15. package/llms/callai.md +1 -1
  16. package/llms/canvas-theme-colors.d.ts +2 -0
  17. package/llms/canvas-theme-colors.js +7 -0
  18. package/llms/canvas-theme-colors.js.map +1 -0
  19. package/llms/canvas-theme-colors.md +70 -0
  20. package/llms/image-gen.js +1 -0
  21. package/llms/image-gen.js.map +1 -1
  22. package/llms/image-gen.md +1 -1
  23. package/llms/index.d.ts +20 -1
  24. package/llms/index.js +55 -0
  25. package/llms/index.js.map +1 -1
  26. package/llms/keepsake.d.ts +2 -0
  27. package/llms/keepsake.js +9 -0
  28. package/llms/keepsake.js.map +1 -0
  29. package/llms/keepsake.md +74 -0
  30. package/llms/live-rooms.d.ts +2 -0
  31. package/llms/live-rooms.js +28 -0
  32. package/llms/live-rooms.js.map +1 -0
  33. package/llms/live-rooms.md +288 -0
  34. package/llms/media-capture.d.ts +2 -0
  35. package/llms/media-capture.js +27 -0
  36. package/llms/media-capture.js.map +1 -0
  37. package/llms/media-capture.md +190 -0
  38. package/llms/mic-capture.d.ts +2 -0
  39. package/llms/mic-capture.js +7 -0
  40. package/llms/mic-capture.js.map +1 -0
  41. package/llms/mic-capture.md +76 -0
  42. package/llms/needs.d.ts +12 -0
  43. package/llms/needs.js +71 -0
  44. package/llms/needs.js.map +1 -0
  45. package/llms/p5.js +1 -0
  46. package/llms/p5.js.map +1 -1
  47. package/llms/p5.md +15 -69
  48. package/llms/photo-input.d.ts +2 -0
  49. package/llms/photo-input.js +7 -0
  50. package/llms/photo-input.js.map +1 -0
  51. package/llms/photo-input.md +141 -0
  52. package/llms/physics.js +1 -0
  53. package/llms/physics.js.map +1 -1
  54. package/llms/physics.md +7 -16
  55. package/llms/reskin.js +3 -8
  56. package/llms/reskin.js.map +1 -1
  57. package/llms/reskin.md +4 -72
  58. package/llms/richtext.md +2 -0
  59. package/llms/social-post.js +1 -0
  60. package/llms/social-post.js.map +1 -1
  61. package/llms/social-post.md +22 -4
  62. package/llms/sound-core.d.ts +2 -0
  63. package/llms/sound-core.js +7 -0
  64. package/llms/sound-core.js.map +1 -0
  65. package/llms/sound-core.md +131 -0
  66. package/llms/strudel.js +2 -0
  67. package/llms/strudel.js.map +1 -1
  68. package/llms/strudel.md +24 -25
  69. package/llms/surface-board.d.ts +2 -0
  70. package/llms/surface-board.js +8 -0
  71. package/llms/surface-board.js.map +1 -0
  72. package/llms/surface-board.md +140 -0
  73. package/llms/surface-play-area.d.ts +2 -0
  74. package/llms/surface-play-area.js +8 -0
  75. package/llms/surface-play-area.js.map +1 -0
  76. package/llms/surface-play-area.md +51 -0
  77. package/llms/surface-presence.d.ts +2 -0
  78. package/llms/surface-presence.js +9 -0
  79. package/llms/surface-presence.js.map +1 -0
  80. package/llms/surface-presence.md +118 -0
  81. package/llms/three-js.js +1 -1
  82. package/llms/three-js.js.map +1 -1
  83. package/llms/three-js.md +52 -18
  84. package/llms/touch-games.js +11 -11
  85. package/llms/touch-games.js.map +1 -1
  86. package/llms/touch-games.md +59 -354
  87. package/llms/types.d.ts +5 -0
  88. package/llms/ui-chat.js +2 -1
  89. package/llms/ui-chat.js.map +1 -1
  90. package/llms/ui-chat.md +25 -14
  91. package/llms/use-vibe.js +1 -0
  92. package/llms/use-vibe.js.map +1 -1
  93. package/llms/use-viewer.js +1 -0
  94. package/llms/use-viewer.js.map +1 -1
  95. package/llms/voxel.js +1 -0
  96. package/llms/voxel.js.map +1 -1
  97. package/llms/voxel.md +33 -109
  98. package/llms/web-audio.js +4 -21
  99. package/llms/web-audio.js.map +1 -1
  100. package/llms/web-audio.md +19 -951
  101. package/llms/web-music.d.ts +2 -0
  102. package/llms/web-music.js +8 -0
  103. package/llms/web-music.js.map +1 -0
  104. package/llms/web-music.md +895 -0
  105. package/llms/world-controls.d.ts +2 -0
  106. package/llms/world-controls.js +14 -0
  107. package/llms/world-controls.js.map +1 -0
  108. package/llms/world-controls.md +262 -0
  109. package/llms/worlds.js +2 -1
  110. package/llms/worlds.js.map +1 -1
  111. package/llms/worlds.md +5 -14
  112. package/package.json +5 -5
  113. package/prompts.js +5 -19
  114. package/prompts.js.map +1 -1
@@ -0,0 +1,141 @@
1
+ # Photo input — the picker that offers the camera and the photo library
2
+
3
+ **A photo comes from `<input type="file" accept="image/*">` with no `capture` attribute.** On a
4
+ phone that one input opens the system sheet with Take Photo, Photo Library and Choose File; on a
5
+ desktop it opens the file picker. A `capture` attribute removes the library and opens the camera
6
+ alone, so the photo someone already took is out of reach. Hide the input and open it from a
7
+ `Button` in the app's own words ("Add a photo", "Snap the plant"), give it `multiple` when the app
8
+ takes several, and accept paste and drag-and-drop too, which is how a desktop visitor hands over a
9
+ picture.
10
+
11
+ ## `lib/photos.js` — shrink before storing
12
+
13
+ ```js
14
+ // lib/photos.js — plain module, no React.
15
+ // Re-encoding through a canvas downscales the picture, applies the camera's rotation and drops
16
+ // the EXIF block, the phone's GPS location included, before the photo is stored or sent.
17
+ // `type` forces one output format (Instagram takes JPEG only); PNG otherwise stays PNG for its transparency.
18
+ // Resolves null for a picture this browser cannot draw: the original, location and all, is never stored.
19
+ export async function shrinkPhoto(file, { maxEdge = 1600, quality = 0.85, type } = {}) {
20
+ const source = await decode(file);
21
+ if (!source) return null;
22
+ const w = source.naturalWidth ?? source.width;
23
+ const h = source.naturalHeight ?? source.height;
24
+ const scale = Math.min(1, maxEdge / Math.max(w, h));
25
+ const canvas = document.createElement("canvas");
26
+ canvas.width = Math.round(w * scale);
27
+ canvas.height = Math.round(h * scale);
28
+ canvas.getContext("2d").drawImage(source, 0, 0, canvas.width, canvas.height);
29
+ source.close?.();
30
+ const out = type ?? (file.type === "image/png" ? "image/png" : "image/jpeg");
31
+ const blob = await new Promise((resolve) => canvas.toBlob(resolve, out, quality));
32
+ const name = file.name.replace(/\.[^.]*$/, "") + (out === "image/png" ? ".png" : ".jpg");
33
+ return new File([blob], name, { type: out, lastModified: Date.now() });
34
+ }
35
+
36
+ // createImageBitmap first; an <img> decode where it refuses (older Safari); null when both do.
37
+ async function decode(file) {
38
+ try {
39
+ return await createImageBitmap(file, { imageOrientation: "from-image" });
40
+ } catch {
41
+ const url = URL.createObjectURL(file);
42
+ const img = new Image();
43
+ img.src = url;
44
+ try {
45
+ await img.decode();
46
+ return img;
47
+ } catch {
48
+ return null;
49
+ } finally {
50
+ URL.revokeObjectURL(url);
51
+ }
52
+ }
53
+ }
54
+ ```
55
+
56
+ ## `PhotoPicker` — pick, paste or drop, then preview with remove and replace
57
+
58
+ ```jsx
59
+ import { Button, Icon, IconButton, Row, Text } from "@vibes.diy/ui";
60
+ import { shrinkPhoto } from "./lib/photos.js";
61
+
62
+ // Reports the chosen Files through onChange; previews them at once.
63
+ function PhotoPicker({ multiple = false, label = "Add a photo", onChange }) {
64
+ const inputRef = React.useRef(null);
65
+ const [photos, setPhotos] = React.useState([]); // [{ file, url }]
66
+ const [over, setOver] = React.useState(false);
67
+ const [problem, setProblem] = React.useState("");
68
+
69
+ React.useEffect(() => onChange?.(photos.map((p) => p.file)), [photos]);
70
+ // Object URLs hold memory until revoked.
71
+ const urls = React.useRef([]);
72
+ React.useEffect(() => () => urls.current.forEach((u) => URL.revokeObjectURL(u)), []);
73
+
74
+ const add = React.useCallback(async (files) => {
75
+ const images = [...files].filter((f) => f.type.startsWith("image/"));
76
+ if (images.length === 0) return;
77
+ const shrunk = await Promise.all(images.map((f) => shrinkPhoto(f)));
78
+ const ready = shrunk.filter(Boolean);
79
+ setProblem(ready.length < images.length ? "That picture didn't open here. Try a JPEG or PNG." : "");
80
+ if (ready.length === 0) return;
81
+ const fresh = ready.map((file) => ({ file, url: URL.createObjectURL(file) }));
82
+ urls.current.push(...fresh.map((p) => p.url));
83
+ setPhotos((now) => (multiple ? [...now, ...fresh] : fresh.slice(0, 1)));
84
+ }, [multiple]);
85
+
86
+ // Paste a screenshot or a copied image anywhere on the page.
87
+ React.useEffect(() => {
88
+ const onPaste = (e) => add(e.clipboardData?.files ?? []);
89
+ window.addEventListener("paste", onPaste);
90
+ return () => window.removeEventListener("paste", onPaste);
91
+ }, [add]);
92
+
93
+ const remove = (url) => setPhotos((now) => now.filter((p) => p.url !== url));
94
+
95
+ return (
96
+ <div
97
+ onDragOver={(e) => { e.preventDefault(); setOver(true); }}
98
+ onDragLeave={() => setOver(false)}
99
+ onDrop={(e) => { e.preventDefault(); setOver(false); add(e.dataTransfer.files); }}
100
+ className={`flex flex-col gap-2 rounded-md border-2 border-dashed p-3 ${over ? "border-primary bg-muted" : "border-border"}`}>
101
+ <Row gap={2} align="center">
102
+ <Button type="button" variant="quiet" onClick={() => inputRef.current?.click()}>
103
+ {photos.length > 0 && !multiple ? "Replace photo" : label}
104
+ </Button>
105
+ <Text muted size="sm">or drop or paste one here</Text>
106
+ </Row>
107
+ {problem && <Text size="sm">{problem}</Text>}
108
+ <input ref={inputRef} type="file" accept="image/*" multiple={multiple} hidden
109
+ onChange={(e) => { add(e.target.files); e.target.value = ""; }} />
110
+ {photos.length > 0 && (
111
+ <Row gap={2} wrap>
112
+ {photos.map((p) => (
113
+ <div key={p.url} className="relative">
114
+ <img src={p.url} alt="Your photo" className="h-24 w-24 rounded-md object-cover" />
115
+ <span className="absolute right-1 top-1">
116
+ <IconButton size="sm" icon={<Icon name="close" />} label="Remove photo" onClick={() => remove(p.url)} />
117
+ </span>
118
+ </div>
119
+ ))}
120
+ </Row>
121
+ )}
122
+ </div>
123
+ );
124
+ }
125
+ ```
126
+
127
+ Clearing `e.target.value` after each pick lets the person choose the same photo again. Save a
128
+ picked `File` as `_files: { photo: file }` on the record it belongs to.
129
+
130
+ ## When the camera is the whole point
131
+
132
+ A scanner or a photo booth may open the camera straight away: one input with
133
+ `capture="environment"` (the back camera) or `capture="user"` (the front), behind the main button.
134
+ Keep the library one tap away as a second, quieter button over a second input without `capture`:
135
+
136
+ ```jsx
137
+ <Button onClick={() => cameraRef.current?.click()}>Take a photo</Button>
138
+ <Button variant="quiet" onClick={() => libraryRef.current?.click()}>Choose from library</Button>
139
+ <input ref={cameraRef} type="file" accept="image/*" capture="environment" hidden onChange={(e) => add(e.target.files)} />
140
+ <input ref={libraryRef} type="file" accept="image/*" hidden onChange={(e) => add(e.target.files)} />
141
+ ```
package/llms/physics.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export const physicsConfig = {
2
2
  name: "physics",
3
+ needs: ["canvas-theme-colors"],
3
4
  label: "Physics (Matter.js)",
4
5
  description: "2D physics toys and games built with Matter.js, where objects have mass and meet other objects: " +
5
6
  "marble runs and Rube Goldberg builders whose pieces are documents with build and play modes, " +
@@ -1 +1 @@
1
- {"version":3,"file":"physics.js","sourceRoot":"","sources":["../../jsr/llms/physics.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,aAAa,GAAc;IACtC,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,qBAAqB;IAC5B,WAAW,EACT,kGAAkG;QAClG,+FAA+F;QAC/F,4FAA4F;QAC5F,gGAAgG;QAChG,6FAA6F;QAC7F,2FAA2F;QAC3F,2FAA2F;QAC3F,oGAAoG;QACpG,iGAAiG;QACjG,qLAAqL;IACvL,IAAI,EAAE;QACJ,SAAS;QACT,SAAS;QACT,QAAQ;QACR,QAAQ;QACR,UAAU;QACV,SAAS;QACT,WAAW;QACX,YAAY;QACZ,QAAQ;QACR,YAAY;QACZ,QAAQ;QACR,eAAe;QACf,QAAQ;QACR,UAAU;QACV,UAAU;QACV,WAAW;QACX,QAAQ;QACR,UAAU;QACV,YAAY;QACZ,YAAY;QACZ,SAAS;QACT,SAAS;QACT,WAAW;QACX,WAAW;QACX,WAAW;QACX,UAAU;QACV,YAAY;KACb;CACF,CAAC"}
1
+ {"version":3,"file":"physics.js","sourceRoot":"","sources":["../../jsr/llms/physics.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,aAAa,GAAc;IACtC,IAAI,EAAE,SAAS;IAEf,KAAK,EAAE,CAAC,qBAAqB,CAAC;IAC9B,KAAK,EAAE,qBAAqB;IAC5B,WAAW,EACT,kGAAkG;QAClG,+FAA+F;QAC/F,4FAA4F;QAC5F,gGAAgG;QAChG,6FAA6F;QAC7F,2FAA2F;QAC3F,2FAA2F;QAC3F,oGAAoG;QACpG,iGAAiG;QACjG,qLAAqL;IACvL,IAAI,EAAE;QACJ,SAAS;QACT,SAAS;QACT,QAAQ;QACR,QAAQ;QACR,UAAU;QACV,SAAS;QACT,WAAW;QACX,YAAY;QACZ,QAAQ;QACR,YAAY;QACZ,QAAQ;QACR,eAAe;QACf,QAAQ;QACR,UAAU;QACV,UAAU;QACV,WAAW;QACX,QAAQ;QACR,UAAU;QACV,YAAY;QACZ,YAAY;QACZ,SAAS;QACT,SAAS;QACT,WAAW;QACX,WAAW;QACX,WAAW;QACX,UAAU;QACV,YAAY;KACb;CACF,CAAC"}
package/llms/physics.md CHANGED
@@ -37,6 +37,7 @@ regular polygons need nothing extra, and most toys are made of those.
37
37
  ```
38
38
  App.jsx the chrome: mode switch, piece picker, play controls, score, saved levels
39
39
  lib/physics.js the engine: world creation, the fixed-step loop, painting, picking, collisions
40
+ lib/look.js the theme tokens as paintable colours (the canvas theme colours)
40
41
  access.js who may save a level
41
42
  seed.json two or three finished levels so the first visit has something to drop a marble into
42
43
  ```
@@ -54,6 +55,7 @@ colours, and helpers that turn piece documents into bodies and back.
54
55
  ### `lib/physics.js`
55
56
  ```js
56
57
  import Matter from "https://esm.sh/matter-js@0.20.0";
58
+ import { cssColor } from "./look.js";
57
59
 
58
60
  const { Engine, Bodies, Body, Composite, Mouse, MouseConstraint, Events, Common, Query } = Matter;
59
61
  export { Matter };
@@ -61,17 +63,6 @@ export { Matter };
61
63
  /** One physics step, in milliseconds. Every world steps by exactly this, so a replay is a replay. */
62
64
  export const STEP = 1000 / 60;
63
65
 
64
- /** Resolve one of the app's theme tokens to a colour the canvas can paint with. */
65
- export function cssColor(host, token, fallback) {
66
- const probe = document.createElement("span");
67
- probe.style.display = "none";
68
- probe.style.color = `var(${token}, ${fallback})`;
69
- host.appendChild(probe);
70
- const resolved = window.getComputedStyle(probe).color;
71
- probe.remove();
72
- return resolved || fallback;
73
- }
74
-
75
66
  /** A body from a piece document; the document is the source of truth, the body is its stand-in. */
76
67
  export function bodyFromPiece(piece) {
77
68
  const common = { label: piece.kind, isStatic: piece.kind !== "marble", angle: piece.angle ?? 0, isSensor: piece.kind === "goal", restitution: piece.kind === "bumper" ? 1.2 : 0.4, friction: 0.05 };
@@ -429,7 +420,7 @@ so painting and stepping share one frame.
429
420
  colours.** The canvas is `width * dpr` pixels wide and `width` CSS pixels
430
421
  wide, `ctx.setTransform(dpr, 0, 0, dpr, 0, 0)` once, and every body is a
431
422
  closed path of its vertices filled by label. The colours come from the
432
- injected tokens through `cssColor` (the p5 doc's probe trick), so the
423
+ injected tokens through `cssColor` from `lib/look.js`, so the
433
424
  owner's restyle reaches the stage. Matter's own `Render` is a fine wireframe
434
425
  prototype (`Render.create({ element, engine, options: { wireframes: true } })`,
435
426
  `Render.run`), with one measured catch: **create it before the first
@@ -480,9 +471,8 @@ goes through `Common.random()` so the seed covers it.
480
471
 
481
472
  **Label bodies and listen on `collisionStart` for the pair you care about.**
482
473
  `onMeet("marble", "goal", fn)` above wraps it; `isSensor: true` on the goal
483
- makes it fire without stopping the marble. The same hook drives sounds (the
484
- web-audio doc's restraint rule: a sound on the goal, none on every peg),
485
- particle bursts, or a tower's "knocked down" check (count the pieces whose
474
+ makes it fire without stopping the marble. The same hook drives sounds
475
+ (sounds belong to the `web-audio` skill), particle bursts, or a tower's "knocked down" check (count the pieces whose
486
476
  `position.y` crossed a line). `collisionActive` and `collisionEnd` exist for
487
477
  resting contact and release.
488
478
 
@@ -496,7 +486,8 @@ button that applies a force to every body.
496
486
  ```jsx app=tumble
497
487
  import React, { useEffect, useRef, useState } from "react";
498
488
  import { Button, Field, Heading, Input, Row, Spacer, Stack, Text } from "@vibes.diy/ui";
499
- import { Matter, createWorld, cssColor } from "./lib/physics.js";
489
+ import { Matter, createWorld } from "./lib/physics.js";
490
+ import { cssColor } from "./lib/look.js";
500
491
 
501
492
  const { Bodies, Body, Composite } = Matter;
502
493
  const WIDTH = 360;
package/llms/reskin.js CHANGED
@@ -1,7 +1,8 @@
1
1
  export const reskinConfig = {
2
2
  name: "reskin",
3
3
  label: "Reskin",
4
- description: 'The person says "look like…", "make it feel…" or names a style or mood — "a 90s Mac app", "a newspaper", "chopped and screwed", "Y2K", "neo-brutalist", "like Stripe\'s dashboard" — with nothing to copy supplied: keep the look\'s components, logic and Look tab, and give them that appearance — the look\'s tokens re-scoped on one wrapper, its hook classes styled from a <style> string, web fonts, borders, texture, motion and a recomposed layout. Also the keepsake pattern for a thing people print, share or hand out — a ticket, invitation, menu, poster or certificate: one framed artifact drawn by the skin, with the components as its editing controls and a print style',
4
+ description: 'The person says "look like…", "make it feel…" or names a style or mood — "a 90s Mac app", "a newspaper", "chopped and screwed", "Y2K", "neo-brutalist", "like Stripe\'s dashboard" — with nothing to copy supplied: keep the look\'s components, logic and Look tab, and give them that appearance — the look\'s tokens re-scoped on one wrapper, its hook classes styled from a <style> string, web fonts, borders, texture, motion and a recomposed layout',
5
+ teaches: ["data-reskin"],
5
6
  cues: [
6
7
  "look like a",
7
8
  "looks like a",
@@ -26,13 +27,7 @@ export const reskinConfig = {
26
27
  "linear style",
27
28
  "like linear",
28
29
  "like stripe",
29
- "printable",
30
- "to print",
31
- "print out",
32
- "invitation card",
33
- "a poster",
34
- "certificate",
35
- "place card",
36
30
  ],
31
+ rail: "reskin",
37
32
  };
38
33
  //# sourceMappingURL=reskin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"reskin.js","sourceRoot":"","sources":["../../jsr/llms/reskin.ts"],"names":[],"mappings":"AAyBA,MAAM,CAAC,MAAM,YAAY,GAAc;IACrC,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,QAAQ;IACf,WAAW,EACT,+pBAA+pB;IACjqB,IAAI,EAAE;QACJ,aAAa;QACb,cAAc;QACd,mBAAmB;QACnB,mBAAmB;QACnB,cAAc;QACd,aAAa;QACb,iBAAiB;QACjB,SAAS;QACT,aAAa;QACb,YAAY;QACZ,KAAK;QACL,WAAW;QACX,qBAAqB;QACrB,iBAAiB;QACjB,eAAe;QACf,cAAc;QACd,cAAc;QACd,gBAAgB;QAChB,kBAAkB;QAClB,iBAAiB;QACjB,cAAc;QACd,aAAa;QACb,aAAa;QACb,WAAW;QACX,UAAU;QACV,WAAW;QACX,iBAAiB;QACjB,UAAU;QACV,aAAa;QACb,YAAY;KACb;CACF,CAAC"}
1
+ {"version":3,"file":"reskin.js","sourceRoot":"","sources":["../../jsr/llms/reskin.ts"],"names":[],"mappings":"AAwBA,MAAM,CAAC,MAAM,YAAY,GAAc;IACrC,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,QAAQ;IACf,WAAW,EACT,8bAA8b;IAEhc,OAAO,EAAE,CAAC,aAAa,CAAC;IACxB,IAAI,EAAE;QACJ,aAAa;QACb,cAAc;QACd,mBAAmB;QACnB,mBAAmB;QACnB,cAAc;QACd,aAAa;QACb,iBAAiB;QACjB,SAAS;QACT,aAAa;QACb,YAAY;QACZ,KAAK;QACL,WAAW;QACX,qBAAqB;QACrB,iBAAiB;QACjB,eAAe;QACf,cAAc;QACd,cAAc;QACd,gBAAgB;QAChB,kBAAkB;QAClB,iBAAiB;QACjB,cAAc;QACd,aAAa;QACb,aAAa;KACd;IAGD,IAAI,EAAE,QAAQ;CACf,CAAC"}
package/llms/reskin.md CHANGED
@@ -215,84 +215,16 @@ export default function App() {
215
215
  }
216
216
  ```
217
217
 
218
- ## Keepsake — the thing they print, share or hand out
219
-
220
- Tickets, invitations, menus, posters, certificates, place cards, a recipe
221
- card: the designed object is the point, and a page of `Card`s and `RowCard`s
222
- around it makes it look like an admin screen. Build one framed artifact and
223
- let the components edit it.
224
-
225
- - **The keepsake is plain elements styled by the skin.** One `.keepsake`
226
- element with a fixed shape (`aspect-ratio: 5 / 7` for a card, `2 / 1` for a
227
- ticket, `1 / 1.414` for an A-size poster) holds the words as `div`s and
228
- `span`s with the app's own classes (`.keepsake-title`, `.keepsake-meta`), set
229
- in the display face, with the border, ornament, paper and stamp drawn in the
230
- `SKIN` string. It is never a `Card`, and its words are never `Heading`s:
231
- the hook classes belong to the screen, the keepsake has its own.
232
- - **The components are the editing controls around it.** `Field` and `Input`
233
- for the words, `Segmented` for a variant (theme, size), `Button` for Print
234
- and Share. On a wide screen they sit beside the keepsake; on a phone the
235
- keepsake comes first and the controls follow, so the first frame is the
236
- thing itself, filled with a believable example rather than blanks.
237
- - **Print shows only the keepsake.** A `@media print` block in the skin hides
238
- everything else and sets `@page` to the keepsake's size; the Print button
239
- calls `window.print()`.
240
- - **Its colours come from the wrapper's tokens**, so the Look tab and a later
241
- reskin restyle the keepsake along with the controls.
218
+ ## Keepsake
242
219
 
243
- ```jsx
244
- import React, { useState } from "react";
245
- import { Button, Field, Input, Stack } from "@vibes.diy/ui";
246
-
247
- const SKIN = `
248
- @import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,wght@0,600;1,400&display=swap');
249
- [data-reskin] .studio { display: grid; gap: 24px; padding: 16px; grid-template-columns: 1fr; }
250
- @media (min-width: 48rem) { [data-reskin] .studio { grid-template-columns: 22rem 1fr; align-items: start; } [data-reskin] .studio > .keepsake { order: 2; } }
251
- [data-reskin] .keepsake { aspect-ratio: 5 / 7; width: min(100%, 26rem); margin-inline: auto; padding: 12%; display: grid; place-content: center; gap: 14px;
252
- text-align: center; background: var(--surface); color: var(--ink); outline: 1px solid var(--ink); outline-offset: -14px;
253
- box-shadow: 0 18px 40px color-mix(in srgb, var(--ink) 18%, transparent); font-family: 'Fraunces', serif; }
254
- [data-reskin] .keepsake-eyebrow { font-style: italic; color: var(--text-secondary); }
255
- [data-reskin] .keepsake-title { font-size: clamp(28px, 7vw, 44px); font-weight: 600; line-height: 1.05; }
256
- [data-reskin] .keepsake-rule { width: 40%; height: 1px; margin-inline: auto; background: var(--purple); }
257
- @media print {
258
- @page { size: 5in 7in; margin: 0; }
259
- body:has([data-reskin]) * { visibility: hidden; }
260
- [data-reskin] .keepsake, [data-reskin] .keepsake * { visibility: visible; }
261
- [data-reskin] .keepsake { position: fixed; inset: 0; width: 100%; box-shadow: none; }
262
- }
263
- `;
264
-
265
- export default function App() {
266
- const [title, setTitle] = useState("Maya turns thirty");
267
- const [when, setWhen] = useState("Saturday 14 June · 7pm · The Rooftop");
268
-
269
- return (
270
- <div data-reskin>
271
- <style>{SKIN}</style>
272
- <div className="studio">
273
- <div className="keepsake">
274
- <span className="keepsake-eyebrow">You are invited</span>
275
- <span className="keepsake-title">{title}</span>
276
- <span className="keepsake-rule" />
277
- <span>{when}</span>
278
- </div>
279
- <Stack gap={3}>
280
- <Field label="Headline">{(id, d) => <Input id={id} describedBy={d} value={title} onChange={setTitle} />}</Field>
281
- <Field label="When and where">{(id, d) => <Input id={id} describedBy={d} value={when} onChange={setWhen} />}</Field>
282
- <Button onClick={() => window.print()}>Print the invitation</Button>
283
- </Stack>
284
- </div>
285
- </div>
286
- );
287
- }
288
- ```
220
+ A thing people print, share or hand out (a ticket, an invitation, a menu, a poster, a
221
+ certificate) is the `keepsake` skill.
289
222
 
290
223
  ## Board surface
291
224
 
292
225
  A game board, a puzzle or a card table is the same split: the board is plain
293
226
  elements the skin draws, the look's components frame it (score, buttons, the
294
- win dialog). The board-games skill's _Board surface_ section has the worked
295
- example.
227
+ win dialog). The board-games skill carries the worked example.
296
228
 
297
229
  ## Reading a named style
298
230
 
package/llms/richtext.md CHANGED
@@ -488,6 +488,8 @@ picture is bytes on the document rather than a base64 string in the JSON.
488
488
 
489
489
  ## A shared page
490
490
 
491
+ To show who else has the page open, with faces and an invite, name the `live-rooms` skill beside this one; this page's saves stay as they are.
492
+
491
493
  ### `lib/editor.js`
492
494
  ```js app=page
493
495
  // The same helper module as the notebook, kept once per app; shown here in the part the shared
@@ -1,5 +1,6 @@
1
1
  export const socialPostConfig = {
2
2
  name: "social-post",
3
+ needs: ["photo-input"],
3
4
  label: "Post as you",
4
5
  description: "Post as the visitor to their own Threads, LinkedIn and Instagram — a composer that cross-posts one update with an optional photo, a Connect and Renew button per network, one result and link per network — config.connections posting scopes, useConnection, apiFetch, threads/linkedin/instagram from @vibes.diy/social",
5
6
  cues: [
@@ -1 +1 @@
1
- {"version":3,"file":"social-post.js","sourceRoot":"","sources":["../../jsr/llms/social-post.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,gBAAgB,GAAc;IACzC,IAAI,EAAE,aAAa;IACnB,KAAK,EAAE,aAAa;IACpB,WAAW,EACT,2TAA2T;IAC7T,IAAI,EAAE;QACJ,qBAAqB;QACrB,kBAAkB;QAClB,mBAAmB;QACnB,iBAAiB;QACjB,oBAAoB;QACpB,mBAAmB;QACnB,sBAAsB;QACtB,YAAY;QACZ,WAAW;QACX,oBAAoB;QACpB,gBAAgB;QAChB,mBAAmB;QACnB,iBAAiB;QACjB,YAAY;KACb;IACD,YAAY,EAAE,WAAW;IACzB,UAAU,EAAE,eAAe;CAC5B,CAAC"}
1
+ {"version":3,"file":"social-post.js","sourceRoot":"","sources":["../../jsr/llms/social-post.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,gBAAgB,GAAc;IACzC,IAAI,EAAE,aAAa;IAGnB,KAAK,EAAE,CAAC,aAAa,CAAC;IACtB,KAAK,EAAE,aAAa;IACpB,WAAW,EACT,2TAA2T;IAC7T,IAAI,EAAE;QACJ,qBAAqB;QACrB,kBAAkB;QAClB,mBAAmB;QACnB,iBAAiB;QACjB,oBAAoB;QACpB,mBAAmB;QACnB,sBAAsB;QACtB,YAAY;QACZ,WAAW;QACX,oBAAoB;QACpB,gBAAgB;QAChB,mBAAmB;QACnB,iBAAiB;QACjB,YAAY;KACb;IACD,YAAY,EAAE,WAAW;IACzB,UAAU,EAAE,eAAe;CAC5B,CAAC"}
@@ -74,8 +74,9 @@ _started_, never one that already works.
74
74
 
75
75
  **A picture is a public https URL that every network can fetch.** Use a JPEG to
76
76
  post the same picture everywhere: Instagram takes JPEG only, Threads takes JPEG
77
- or PNG, and LinkedIn takes JPEG, PNG or GIF up to 8 MB. A picture the visitor
78
- picks is saved as a file on a record every visitor can read (its own
77
+ or PNG, and LinkedIn takes JPEG, PNG or GIF up to 8 MB. The visitor picks any
78
+ photo through the photo input above, and `shrinkPhoto(file, { type: "image/jpeg" })`
79
+ turns it into that JPEG, location stripped. The picture is saved as a file on a record every visitor can read (its own
79
80
  `grant.public` channel in `access.js`), holding the picture alone (the post's
80
81
  words stay off it until a network has them); wait for that save's `synced`
81
82
  receipt to read `"accepted"`, then read the record back and its
@@ -190,6 +191,7 @@ import React, { useRef, useState } from "react";
190
191
  import { useFireproof } from "use-fireproof";
191
192
  import { useConnection, apiFetch } from "use-vibes";
192
193
  import { Badge, Button, Card, ErrorNote, Field, Heading, Row, Stack, Text, Textarea } from "@vibes.diy/ui";
194
+ import { shrinkPhoto } from "./lib/photos.js";
193
195
 
194
196
  const NETWORKS = [
195
197
  { id: "threads", name: "Threads", limit: 500 },
@@ -250,6 +252,12 @@ export default function App() {
250
252
  const [busy, setBusy] = useState(false);
251
253
  const [problem, setProblem] = useState("");
252
254
  const fileRef = useRef(null);
255
+ const [photoUrl, setPhotoUrl] = useState("");
256
+ const pickPhoto = (file) => {
257
+ if (photoUrl) URL.revokeObjectURL(photoUrl);
258
+ setPhoto(file);
259
+ setPhotoUrl(file ? URL.createObjectURL(file) : "");
260
+ };
253
261
 
254
262
  const networks = NETWORKS.filter((n) => picked[n.id]).map((n) => n.id);
255
263
  // Instagram takes a photo with no caption; every other network needs words.
@@ -305,9 +313,19 @@ export default function App() {
305
313
  <Button type="button" variant="quiet" onClick={() => fileRef.current?.click()}>
306
314
  {photo ? "Pick a different photo" : "Add a photo"}
307
315
  </Button>
308
- {photo && <Text muted size="sm">{photo.name}</Text>}
316
+ {photo && <img src={photoUrl} alt="Your photo" className="h-16 w-16 rounded-md object-cover" />}
317
+ {photo && <Button type="button" variant="quiet" onClick={() => pickPhoto(null)}>Remove</Button>}
309
318
  </Row>
310
- <input ref={fileRef} type="file" accept="image/jpeg" hidden onChange={(e) => setPhoto(e.target.files?.[0] ?? null)} />
319
+ {/* Any photo from the camera or library; shrinkPhoto hands Instagram the JPEG it needs, location stripped. */}
320
+ <input ref={fileRef} type="file" accept="image/*" hidden
321
+ onChange={async (e) => {
322
+ const f = e.target.files?.[0];
323
+ e.target.value = "";
324
+ if (!f) return;
325
+ const jpeg = await shrinkPhoto(f, { type: "image/jpeg" });
326
+ if (jpeg) pickPhoto(jpeg);
327
+ else setProblem("That picture didn't open here. Try a JPEG or PNG.");
328
+ }} />
311
329
  </Stack>
312
330
  </Card>
313
331
  <Stack gap={2}>
@@ -0,0 +1,2 @@
1
+ import type { LlmConfig } from "./types.js";
2
+ export declare const soundCoreConfig: LlmConfig;
@@ -0,0 +1,7 @@
1
+ export const soundCoreConfig = {
2
+ name: "sound-core",
3
+ label: "Sound core",
4
+ description: "Short sound effects that play on a phone: the AudioContext unlock inside the gesture, a synthesized blip per core action, one master gain with a mute toggle, and restraint (core actions only, never spawns or ticks).",
5
+ menu: false,
6
+ };
7
+ //# sourceMappingURL=sound-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sound-core.js","sourceRoot":"","sources":["../../jsr/llms/sound-core.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,eAAe,GAAc;IACxC,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,YAAY;IACnB,WAAW,EACT,yNAAyN;IAC3N,IAAI,EAAE,KAAK;CACZ,CAAC"}
@@ -0,0 +1,131 @@
1
+ # Sound core — short sound effects that play on a phone
2
+
3
+ Web Audio is a browser built-in: use `window.AudioContext` (with the `window.webkitAudioContext`
4
+ fallback) directly. Synthesize effects with an oscillator and a gain envelope; a sound effect needs
5
+ no audio file.
6
+
7
+ **Unlock audio first, synchronously, in the gesture handler.** iOS Safari plays sound only when it
8
+ *directly results* from a trusted `pointerdown`, `touchend`, `click` or `keydown`. Inside that handler,
9
+ before any other work: create or resume the `AudioContext` **and start one real sound** (a ~10ms
10
+ blip at `gain ≈ 0.0001`). An unlock that runs later — from a `setTimeout`, `Promise.then`, `await`,
11
+ `requestAnimationFrame`, a React state update's effect, or a game-loop tick — stays silent on iOS.
12
+ Once the context runs, sounds may start from anywhere, the game loop included. iOS suspends audio
13
+ after the app goes to the background or the phone locks, so the gate re-checks the context on
14
+ every gesture.
15
+
16
+ ## `lib/sfx.js` — the one module that touches audio
17
+
18
+ ```js
19
+ // lib/sfx.js — plain module, no React, so no re-render rebuilds the context.
20
+ let audioCtx;
21
+ let master; // every effect plays through this gain; muting sets it to 0
22
+ let muted = false;
23
+ const LEVEL = 0.8;
24
+
25
+ // Call FIRST, synchronously, at the top of every pointerdown (and the Start button's handler).
26
+ export function unlockAudio() {
27
+ if (!audioCtx) {
28
+ audioCtx = new (window.AudioContext || window.webkitAudioContext)();
29
+ master = audioCtx.createGain();
30
+ master.gain.value = muted ? 0 : LEVEL;
31
+ master.connect(audioCtx.destination);
32
+ }
33
+ // Re-check every gesture: iOS suspends audio after backgrounding or a lock.
34
+ if (audioCtx.state !== "running") {
35
+ audioCtx.resume();
36
+ // One real, silent sound inside the gesture: the part a resume() alone misses on iOS.
37
+ const osc = audioCtx.createOscillator();
38
+ const gain = audioCtx.createGain();
39
+ gain.gain.value = 0.0001;
40
+ osc.connect(gain).connect(audioCtx.destination);
41
+ osc.start();
42
+ osc.stop(audioCtx.currentTime + 0.01);
43
+ }
44
+ return audioCtx;
45
+ }
46
+
47
+ export function setMuted(next) {
48
+ muted = next;
49
+ if (master) master.gain.setTargetAtTime(next ? 0 : LEVEL, audioCtx.currentTime, 0.02);
50
+ }
51
+
52
+ // One short effect: a pitch sweep with a fast fade, 80–150ms, never longer than the action.
53
+ export function blip({ from = 660, to = 990, ms = 90, type = "square", vol = 0.15 } = {}) {
54
+ if (!audioCtx || muted) return; // guard on the context alone, never on audioCtx.state
55
+ const t = audioCtx.currentTime;
56
+ const osc = audioCtx.createOscillator();
57
+ const gain = audioCtx.createGain();
58
+ osc.type = type;
59
+ osc.frequency.setValueAtTime(from, t);
60
+ osc.frequency.exponentialRampToValueAtTime(to, t + ms / 1000);
61
+ gain.gain.setValueAtTime(vol, t);
62
+ gain.gain.exponentialRampToValueAtTime(0.0001, t + ms / 1000);
63
+ osc.connect(gain).connect(master);
64
+ osc.start(t);
65
+ osc.stop(t + ms / 1000 + 0.02);
66
+ }
67
+
68
+ // The core actions, one sound each. Tune by parameter; keep the set this small.
69
+ export const sfx = {
70
+ hit: () => blip(),
71
+ score: () => blip({ from: 523, to: 1047, ms: 120, type: "triangle" }),
72
+ jump: () => blip({ from: 300, to: 600, ms: 100, type: "sine", vol: 0.2 }),
73
+ miss: () => blip({ from: 220, to: 110, ms: 140, type: "triangle", vol: 0.2 }),
74
+ lose: () => blip({ from: 300, to: 60, ms: 400, type: "sawtooth", vol: 0.12 }),
75
+ win: () => [523, 659, 784].forEach((f, i) => setTimeout(() => blip({ from: f, to: f * 1.01, ms: 110, type: "triangle" }), i * 90)),
76
+ };
77
+ ```
78
+
79
+ **Why `blip` checks the context and not its state.** `resume()` is asynchronous, so in the very tap
80
+ that unlocks, `audioCtx.state` still reads `"suspended"` when that tap's effect plays. A sound started
81
+ on a suspended context plays the moment it resumes. A `state !== "running"` early return drops the
82
+ first tap's sound and the first hit after the app comes back from the background.
83
+
84
+ ## Wire it to the gesture
85
+
86
+ ```js
87
+ import { unlockAudio, sfx } from "./lib/sfx.js";
88
+
89
+ function onPointerDown(e) {
90
+ unlockAudio(); // first line of the handler, every gesture
91
+ // ...then the tap, swipe or hold logic, which may call sfx.jump() right here
92
+ }
93
+ // In the game loop, after the context runs: sfx.hit() on a hit, sfx.score() on a point,
94
+ // sfx.miss() on a miss, sfx.lose() at game over, sfx.win() on a cleared round.
95
+ ```
96
+
97
+ ✗ Too late on iOS: `useEffect(() => new AudioContext(), [])` on mount, a context created in a state
98
+ update's effect, `el.onclick = () => requestAnimationFrame(() => audioCtx.resume())`, or any
99
+ `setTimeout`, `await` or `.then` before the first sound.
100
+
101
+ ## A mute toggle beside the menu
102
+
103
+ Every app with sound effects carries one mute toggle, a small icon button next to the menu
104
+ button, that silences the master gain at once:
105
+
106
+ ```jsx
107
+ import { IconButton } from "@vibes.diy/ui";
108
+ import { setMuted } from "./lib/sfx.js";
109
+
110
+ const [muted, setMutedState] = React.useState(false);
111
+
112
+ <IconButton
113
+ icon={muted ? "🔇" : "🔊"}
114
+ label={muted ? "Turn sound on" : "Mute sound"}
115
+ onClick={() => {
116
+ setMuted(!muted);
117
+ setMutedState(!muted);
118
+ }}
119
+ />;
120
+ ```
121
+
122
+ ## Restraint — sound belongs on the core actions
123
+
124
+ - Sound plays on the core actions: a hit lands, a point scores, a shot misses, the player jumps,
125
+ a round is won or lost. One or two of them carry most of the feel; failure gets at most one
126
+ distinct sound.
127
+ - Not on spawns or ticks: an enemy appearing, a timer counting, every frame, every hover,
128
+ keystroke or list render stays silent. No ambient loop or background music unless the person
129
+ asks for it.
130
+ - Never autoplay on load; the first sound follows a gesture, through `unlockAudio()`.
131
+ - Menus, settings and leaderboards stay quiet.
package/llms/strudel.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export const strudelConfig = {
2
2
  name: "strudel",
3
+ needs: ["web-audio"],
3
4
  label: "Strudel live coding",
4
5
  description: "Live-coding music with Strudel, where the music is a pattern written as text: a pattern pad " +
5
6
  "with an editor, examples, play and stop and saved patterns; a groovebox whose pads write " +
@@ -13,6 +14,7 @@ export const strudelConfig = {
13
14
  "onEvalError for patterns that did not compile, hush on stop, and onTrigger for visuals. " +
14
15
  "strudel, tidal, tidalcycles, live coding, livecoding, algorave, mini-notation, pattern music, " +
15
16
  "algorithmic music, generative music, text patterns, code music",
17
+ teaches: ["initStrudel", "setAudioContext"],
16
18
  cues: [
17
19
  "strudel",
18
20
  "tidal",
@@ -1 +1 @@
1
- {"version":3,"file":"strudel.js","sourceRoot":"","sources":["../../jsr/llms/strudel.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,aAAa,GAAc;IACtC,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,qBAAqB;IAC5B,WAAW,EACT,8FAA8F;QAC9F,2FAA2F;QAC3F,+FAA+F;QAC/F,6FAA6F;QAC7F,+FAA+F;QAC/F,gGAAgG;QAChG,iGAAiG;QACjG,2FAA2F;QAC3F,yBAAyB;QACzB,0FAA0F;QAC1F,gGAAgG;QAChG,gEAAgE;IAClE,IAAI,EAAE;QACJ,SAAS;QACT,OAAO;QACP,aAAa;QACb,cAAc;QACd,aAAa;QACb,aAAa;QACb,YAAY;QACZ,iBAAiB;QACjB,UAAU;QACV,eAAe;QACf,cAAc;QACd,eAAe;QACf,mBAAmB;QACnB,kBAAkB;QAClB,YAAY;QACZ,iBAAiB;QACjB,eAAe;KAChB;CACF,CAAC"}
1
+ {"version":3,"file":"strudel.js","sourceRoot":"","sources":["../../jsr/llms/strudel.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,MAAM,aAAa,GAAc;IACtC,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,CAAC,WAAW,CAAC;IACpB,KAAK,EAAE,qBAAqB;IAC5B,WAAW,EACT,8FAA8F;QAC9F,2FAA2F;QAC3F,+FAA+F;QAC/F,6FAA6F;QAC7F,+FAA+F;QAC/F,gGAAgG;QAChG,iGAAiG;QACjG,2FAA2F;QAC3F,yBAAyB;QACzB,0FAA0F;QAC1F,gGAAgG;QAChG,gEAAgE;IAElE,OAAO,EAAE,CAAC,aAAa,EAAE,iBAAiB,CAAC;IAC3C,IAAI,EAAE;QACJ,SAAS;QACT,OAAO;QACP,aAAa;QACb,cAAc;QACd,aAAa;QACb,aAAa;QACb,YAAY;QACZ,iBAAiB;QACjB,UAAU;QACV,eAAe;QACf,cAAc;QACd,eAAe;QACf,mBAAmB;QACnB,kBAAkB;QAClB,YAAY;QACZ,iBAAiB;QACjB,eAAe;KAChB;CACF,CAAC"}