@vibes.diy/prompts 14.3.341 → 14.3.342
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/llms/backend.md +47 -1
- package/llms/calendar.md +98 -32
- package/llms/match-style.md +2 -1
- package/llms/reskin.md +13 -2
- package/llms/web-audio.md +17 -0
- package/llms/web-music.md +2 -0
- package/package.json +5 -5
- package/themes/style-presets.d.ts +4 -0
- package/themes/style-presets.js +15 -0
package/llms/backend.md
CHANGED
|
@@ -1181,15 +1181,61 @@ if (url.pathname === "/feed-token" && request.method === "POST") {
|
|
|
1181
1181
|
await ctx.db.put({ type: "feedToken", ownerHandle: me }, { db: "planner", id: "feedToken:" + token });
|
|
1182
1182
|
return json({ ok: true, token });
|
|
1183
1183
|
}
|
|
1184
|
+
if (url.pathname === "/feed-token/revoke" && request.method === "POST") {
|
|
1185
|
+
const me = ctx.userInfo?.userHandle;
|
|
1186
|
+
if (!me) return json({ ok: false, reason: "sign in to change a feed link" }, 401);
|
|
1187
|
+
const { token } = await request.json();
|
|
1188
|
+
const grant = await ctx.db.get("feedToken:" + token, { db: "planner" });
|
|
1189
|
+
if (grant?.type !== "feedToken" || grant.ownerHandle !== me) return json({ ok: false, reason: "your own feed links" }, 403);
|
|
1190
|
+
await ctx.db.delete("feedToken:" + token, { db: "planner" }); // the link drains on its next refresh
|
|
1191
|
+
return json({ ok: true });
|
|
1192
|
+
}
|
|
1184
1193
|
if (url.pathname === "/feed.ics") {
|
|
1185
1194
|
const token = url.searchParams.get("t") ?? "";
|
|
1186
1195
|
const grant = token ? await ctx.db.get("feedToken:" + token, { db: "planner" }) : null;
|
|
1187
1196
|
if (grant?.type !== "feedToken") return new Response("not found", { status: 404 });
|
|
1188
1197
|
const rows = await ctx.db.query({ db: "planner", field: "ownerHandle", key: grant.ownerHandle, limit: 200 });
|
|
1189
|
-
|
|
1198
|
+
const work = rows.filter((row) => row.type === "assignment");
|
|
1199
|
+
return new Response(toIcs(work), { headers: { "content-type": "text/calendar" } });
|
|
1200
|
+
}
|
|
1201
|
+
```
|
|
1202
|
+
|
|
1203
|
+
The token is drawn in the route, so the server chose it for the person it names.
|
|
1204
|
+
Every token record is one the route wrote, at an id made from fresh
|
|
1205
|
+
randomness, so a link one person shares with a friend stays theirs. In
|
|
1206
|
+
`access.js` the token type admits only the route, names its writer, is kept
|
|
1207
|
+
or revoked whole (the revoke route deletes it), and sits on its owner's private
|
|
1208
|
+
channel; each assignment names its writer the same way, and ids that start
|
|
1209
|
+
`feedToken:` hold feed links alone:
|
|
1210
|
+
|
|
1211
|
+
### `access.js`
|
|
1212
|
+
```js partial
|
|
1213
|
+
if (doc.type === "feedToken") {
|
|
1214
|
+
ctx.requireBackend("fetch"); // only the /feed-token route mints one
|
|
1215
|
+
if (!user?.userHandle || doc.ownerHandle !== user.userHandle) throw { forbidden: "a feed link is its owner's" };
|
|
1216
|
+
// Kept or revoked whole: the revoke route's delete passes, an edit is refused. A repair goes through admin mode.
|
|
1217
|
+
if (oldDoc && !doc._deleted) throw { forbidden: "a feed link is kept or revoked whole" };
|
|
1218
|
+
const mine = "user:" + user.userHandle;
|
|
1219
|
+
return { channels: [mine], grant: { users: { [user.userHandle]: [mine] } } };
|
|
1220
|
+
}
|
|
1221
|
+
if (String(doc._id ?? "").startsWith("feedToken:")) throw { forbidden: "feedToken: ids hold feed links" };
|
|
1222
|
+
if (doc.type === "assignment") {
|
|
1223
|
+
if (!user?.userHandle || doc.ownerHandle !== user.userHandle) throw { forbidden: "your own assignments" };
|
|
1224
|
+
if (oldDoc && oldDoc.ownerHandle !== user.userHandle) throw { forbidden: "your own assignments" };
|
|
1225
|
+
const mine = "user:" + user.userHandle;
|
|
1226
|
+
return { channels: [mine], grant: { users: { [user.userHandle]: [mine] } } };
|
|
1190
1227
|
}
|
|
1191
1228
|
```
|
|
1192
1229
|
|
|
1230
|
+
A link for one record a person keeps, such as one student on a parent's or a
|
|
1231
|
+
teacher's list, comes from the same route with that record's id in the body
|
|
1232
|
+
(`{ recordId }`). The route reads the record, mints when its `ownerHandle`
|
|
1233
|
+
equals `me`, and saves `{ type: "feedToken", ownerHandle: me, recordId }`. The
|
|
1234
|
+
feed serves the assignments whose `recordId` and `ownerHandle` both match the
|
|
1235
|
+
token record,
|
|
1236
|
+
so each link shows one student's work as the person who keeps that student
|
|
1237
|
+
entered it.
|
|
1238
|
+
|
|
1193
1239
|
OAuth state ties the user who starts the flow to the user who finishes it.
|
|
1194
1240
|
A visitor's own account on another service is a connection first (the
|
|
1195
1241
|
`connections` skill), and the platform holds that flow end to end. A flow the
|
package/llms/calendar.md
CHANGED
|
@@ -145,9 +145,10 @@ after a deploy and the first one after a token is minted.
|
|
|
145
145
|
## The architecture (each piece is load-bearing)
|
|
146
146
|
|
|
147
147
|
Calendar clients (iPhone, Google) refresh subscriptions with **anonymous
|
|
148
|
-
GETs** — no login, no headers you control.
|
|
149
|
-
|
|
150
|
-
|
|
148
|
+
GETs** — no login, no headers you control. A `fetch` handler reads a bound
|
|
149
|
+
database as its caller: the signed-in page's `apiFetch` call (the mint route
|
|
150
|
+
below) reads that person's own records, and an anonymous GET reads none of
|
|
151
|
+
them. So:
|
|
151
152
|
|
|
152
153
|
1. **A `scheduled` tick aggregates; the `fetch` lane serves.** `scheduled`
|
|
153
154
|
runs as the owner in admin mode and CAN read everything. Every minute it
|
|
@@ -158,21 +159,36 @@ lane can't query access-fn-bound databases at all). So:
|
|
|
158
159
|
2. **The URL carries a per-user RANDOM TOKEN — a capability, not a handle.**
|
|
159
160
|
Subscription URLs are unauthenticated and long-lived; a handle-keyed URL
|
|
160
161
|
(`?u=<handle>`) is guessable, which silently makes every user's items
|
|
161
|
-
world-readable. Instead,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
162
|
+
world-readable. Instead, the backend mints the token for the person
|
|
163
|
+
asking.
|
|
164
|
+
The feed token is minted by a signed-in route in `backend.js`. The first
|
|
165
|
+
time the user opens the calendar surface with subscribable content, the
|
|
166
|
+
page calls `POST /caltoken` through `apiFetch`; the route reads the caller
|
|
167
|
+
from `ctx.userInfo`, reads `caltoken-<handle>` first and answers with the
|
|
168
|
+
token kept there, so phones already subscribed keep their link. Only when
|
|
169
|
+
there is none (or the person pressed "New link", `{ rotate: true }`) does
|
|
170
|
+
it draw a token from `crypto.getRandomValues` and save
|
|
171
|
+
`{ type: "caltoken", userId: me, token }` at `caltoken-<handle>`. Ids that
|
|
172
|
+
start `caltoken-` hold calendar links alone, so every other branch of
|
|
173
|
+
`access.js` keeps them for that.
|
|
174
|
+
`access.js` admits a `caltoken` only from that route
|
|
175
|
+
(`ctx.requireBackend("fetch")`) with `userId` equal to the writer, on the
|
|
176
|
+
owner's PRIVATE channel (like notes — the token IS the secret; the
|
|
177
|
+
scheduled lane reads it regardless). So every token is fresh randomness the
|
|
178
|
+
server drew for the person it names, and a link one person shares with a
|
|
179
|
+
friend stays theirs alone. The route answers with the token, so the URL
|
|
180
|
+
shows as soon as the press settles, and it stays **opt-in**: users who
|
|
181
|
+
never open that surface get no token and no ics aggregate — the scheduled
|
|
182
|
+
tick must skip aggregating any user without a token. Every item the tick
|
|
183
|
+
files under a person is one `access.js` checked they wrote
|
|
184
|
+
(`doc.userId === user.userHandle`), so each feed holds that person's own
|
|
185
|
+
items. The URL is `?t=<token>&n=<handle>` (`n` is a validated
|
|
171
186
|
DISPLAY label only — iOS captures the calendar name at subscribe time,
|
|
172
187
|
often before the tick has learned a fresh token; the token alone gates
|
|
173
188
|
data): unguessable, shareable on purpose (handing out the link is the
|
|
174
|
-
sharing feature), and
|
|
175
|
-
|
|
189
|
+
sharing feature), and renewable — a "New link" press asks the route with
|
|
190
|
+
`{ rotate: true }`, it draws a fresh token in place, and the old link
|
|
191
|
+
drains on the next refresh. Because the token maps to the user (not to item ids),
|
|
176
192
|
the feed is still LIVE: new items reach every subscriber automatically.
|
|
177
193
|
Never let private types (notes, drafts) enter the aggregation.
|
|
178
194
|
3. **Never answer a subscription GET with an error or emptiness you can
|
|
@@ -224,33 +240,38 @@ lane can't query access-fn-bound databases at all). So:
|
|
|
224
240
|
|
|
225
241
|
## The UI
|
|
226
242
|
|
|
227
|
-
The token is
|
|
243
|
+
The token is minted when the calendar surface opens, so the Subscribe
|
|
228
244
|
button is simply there once the user has subscribable content.
|
|
229
245
|
|
|
230
246
|
⚠️ Read the token from its OWN live query on `type: "caltoken"` (as below). A
|
|
231
247
|
`caltoken` doc never appears in your items/favorites query — looking for it
|
|
232
|
-
there means the Subscribe link never renders, even though the mint
|
|
248
|
+
there means the Subscribe link never renders, even though the mint route and
|
|
233
249
|
the feed itself work.
|
|
234
250
|
|
|
235
251
|
### `App.jsx`
|
|
236
252
|
```jsx app=calendar-feed
|
|
237
|
-
//
|
|
238
|
-
// channel (like notes) — the token is the secret.
|
|
253
|
+
// `apiFetch` comes from use-vibes: the route runs as the signed-in person.
|
|
239
254
|
const { docs: calTokens } = useLiveQuery(byTypeUser, { key: ["caltoken", me.userHandle] });
|
|
240
|
-
const
|
|
255
|
+
const [mintedToken, setMintedToken] = useState(null);
|
|
256
|
+
const [asked, setAsked] = useState(false);
|
|
257
|
+
const calToken = mintedToken || calTokens[0]?.token || null;
|
|
258
|
+
// The route answers with the person's kept token, or a fresh one when they have none.
|
|
259
|
+
const askForLink = (rotate) =>
|
|
260
|
+
apiFetch("/caltoken", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ rotate }) })
|
|
261
|
+
.then((res) => (res.ok ? res.json() : null))
|
|
262
|
+
.then((body) => body?.token && setMintedToken(body.token))
|
|
263
|
+
.catch(() => {}); // asked stays true: the next visit to this view asks again
|
|
241
264
|
useEffect(() => {
|
|
242
|
-
//
|
|
243
|
-
//
|
|
244
|
-
// token
|
|
245
|
-
//
|
|
246
|
-
if (!signedIn || myItems.length === 0 || calToken) return;
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
database.put({ _id: `caltoken-${me.userHandle}`, type: "caltoken", userId: me.userHandle, token, createdAt: Date.now() }).catch(() => {});
|
|
253
|
-
}, [signedIn, myItems.length, calToken]);
|
|
265
|
+
// The route mints on the first visit to this view with content, and users
|
|
266
|
+
// who never come here never get a token. Until the backend tick learns the
|
|
267
|
+
// token (≤1m), the endpoint serves a valid placeholder calendar, so even an
|
|
268
|
+
// immediate subscribe can't fail.
|
|
269
|
+
if (!signedIn || myItems.length === 0 || calToken || asked) return;
|
|
270
|
+
setAsked(true);
|
|
271
|
+
askForLink(false);
|
|
272
|
+
}, [signedIn, myItems.length, calToken, asked]);
|
|
273
|
+
// "New link" draws a fresh token in place; the old link drains on the next refresh.
|
|
274
|
+
{calToken && <Button onClick={() => askForLink(true)}>New link</Button>}
|
|
254
275
|
// The feed lives at the app's public address, which also serves backend.js:
|
|
255
276
|
// https://vibes.diy/vibe/<handle>/<app>/_api/faves.ics. The app's own host,
|
|
256
277
|
// `<app>--<handle>.…`, names both in its first label.
|
|
@@ -364,6 +385,19 @@ export async function scheduled(event, ctx) {
|
|
|
364
385
|
|
|
365
386
|
export async function fetch(request, ctx) {
|
|
366
387
|
const url = new URL(request.url);
|
|
388
|
+
if (url.pathname === "/caltoken" && request.method === "POST") {
|
|
389
|
+
// The signed-in person's own token: the kept one, or one drawn here and saved under their handle.
|
|
390
|
+
const me = ctx.userInfo?.userHandle;
|
|
391
|
+
if (!me) return Response.json({ ok: false, reason: "sign in to make a calendar link" }, { status: 401 });
|
|
392
|
+
const { rotate } = await request.json().catch(() => ({}));
|
|
393
|
+
const kept = await ctx.db.get(`caltoken-${me}`, { db: "items" });
|
|
394
|
+
// Phones already subscribed keep their link until the person presses New link.
|
|
395
|
+
if (!rotate && kept?.type === "caltoken" && kept.userId === me) return Response.json({ ok: true, token: kept.token });
|
|
396
|
+
const b = crypto.getRandomValues(new Uint8Array(16));
|
|
397
|
+
const token = btoa(String.fromCharCode(...b)).replace(/[+]/g, "-").replace(/[/]/g, "_").replace(/=+$/, "");
|
|
398
|
+
await ctx.db.put({ type: "caltoken", userId: me, token, createdAt: Date.now() }, { db: "items", id: `caltoken-${me}` });
|
|
399
|
+
return Response.json({ ok: true, token });
|
|
400
|
+
}
|
|
367
401
|
if (url.pathname !== "/faves.ics") return new Response("not found", { status: 404 });
|
|
368
402
|
if (request.method !== "GET" && request.method !== "HEAD")
|
|
369
403
|
return new Response("method not allowed", { status: 405, headers: { allow: "GET" } });
|
|
@@ -388,6 +422,38 @@ export async function fetch(request, ctx) {
|
|
|
388
422
|
}
|
|
389
423
|
```
|
|
390
424
|
|
|
425
|
+
`access.js` holds both halves of the feed: a `caltoken` comes only from the
|
|
426
|
+
mint route, sits at its owner's own `caltoken-<handle>` id and names its
|
|
427
|
+
writer, and a `favorite` names its writer too and lives at an id of its own,
|
|
428
|
+
so the tick files each person's own picks under each person's own token:
|
|
429
|
+
|
|
430
|
+
### `access.js`
|
|
431
|
+
```js app=calendar-feed
|
|
432
|
+
export function items(doc, oldDoc, user, ctx) {
|
|
433
|
+
if (oldDoc && oldDoc.type !== doc.type) throw { forbidden: "a record keeps its type" };
|
|
434
|
+
// Ids that start `caltoken-` hold calendar links alone.
|
|
435
|
+
const linkId = String(doc._id ?? "").startsWith("caltoken-");
|
|
436
|
+
if (doc.type === "caltoken") {
|
|
437
|
+
ctx.requireBackend("fetch"); // only the /caltoken route mints one
|
|
438
|
+
if (!user?.userHandle || doc.userId !== user.userHandle) throw { forbidden: "a calendar link is its owner's" };
|
|
439
|
+
if (doc._id !== "caltoken-" + user.userHandle) throw { forbidden: "a calendar link sits at its owner's id" };
|
|
440
|
+
const mine = "user:" + user.userHandle;
|
|
441
|
+
return { channels: [mine], grant: { users: { [user.userHandle]: [mine] } } };
|
|
442
|
+
}
|
|
443
|
+
if (linkId) throw { forbidden: "caltoken- ids hold calendar links" };
|
|
444
|
+
if (doc.type === "favorite") {
|
|
445
|
+
if (!user?.userHandle) throw { forbidden: "sign in" };
|
|
446
|
+
if (doc.userId !== user.userHandle) throw { forbidden: "a pick is its picker's" };
|
|
447
|
+
if (oldDoc && oldDoc.userId !== user.userHandle) throw { forbidden: "a pick is its picker's" };
|
|
448
|
+
const mine = "user:" + user.userHandle;
|
|
449
|
+
return { channels: [mine], grant: { users: { [user.userHandle]: [mine] } } };
|
|
450
|
+
}
|
|
451
|
+
throw { forbidden: "unknown document type" };
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// Summary: each person's picks and calendar link are theirs alone. A favorite carries its picker's handle in userId, and a caltoken, minted by the backend's /caltoken route, carries its owner's handle in userId.
|
|
455
|
+
```
|
|
456
|
+
|
|
391
457
|
If items should track a live external events API, add the join inside `fetch`:
|
|
392
458
|
fetch the API window with `globalThis.fetch`, key rows by the same item id,
|
|
393
459
|
prefer the live row over the stored snapshot, skip items the API marks
|
package/llms/match-style.md
CHANGED
|
@@ -56,7 +56,8 @@ already wears a look (an earlier reskin's CSS string and the wrapper element
|
|
|
56
56
|
it scopes, or an earlier `THEME_CSS`) trades it for the new block in the same
|
|
57
57
|
pass: the new `THEME_CSS` takes that string's place, its `<style>` element and
|
|
58
58
|
wrapper go with it, and the ornament it drew (a texture, a glow, a heading prefix,
|
|
59
|
-
letter-spaced capitals
|
|
59
|
+
letter-spaced capitals, stripes, borders, a hard shadow) and the plain elements it
|
|
60
|
+
added (a title bar, a menu strip) give way to what the new style asks for. The app
|
|
60
61
|
then carries one stylesheet of its own, the block above.
|
|
61
62
|
|
|
62
63
|
### The variables
|
package/llms/reskin.md
CHANGED
|
@@ -16,7 +16,10 @@ technique.
|
|
|
16
16
|
- A style the person BRINGS — a brand guide, pasted CSS or tokens, Material 3,
|
|
17
17
|
a screenshot to copy — is the `match-style` skill, which replaces the
|
|
18
18
|
components with the app's own and makes its `THEME_CSS` the app's one look,
|
|
19
|
-
in this skin's place.
|
|
19
|
+
in this skin's place. A build that stays on this skill for it (a palette and
|
|
20
|
+
fonts pasted onto a reskinned app) writes a new skin from that design in this
|
|
21
|
+
string's place, as step 3 says; either way the app wears the brought design
|
|
22
|
+
alone.
|
|
20
23
|
- Everything between — a mood, a named style, a site named with nothing
|
|
21
24
|
supplied — is a reskin.
|
|
22
25
|
|
|
@@ -57,7 +60,15 @@ open modal and dropdown included.
|
|
|
57
60
|
**3. The skin is one module-level CSS string.** Declare `const SKIN = \`…\``
|
|
58
61
|
above the component and render `<style>{SKIN}</style>` as the wrapper's first
|
|
59
62
|
child. A later reskin rewrites this same string, so the app wears one skin
|
|
60
|
-
at a time.
|
|
63
|
+
at a time. A design the person brings replaces this string whole — a pasted
|
|
64
|
+
palette, fonts or tokens, "use this design for the whole app": the new string
|
|
65
|
+
is drawn from their design alone, and the earlier skin's stripes, borders, hard
|
|
66
|
+
shadows, glow and the plain elements it added (a title bar, a menu strip) leave
|
|
67
|
+
with its colours, back only where their design asks for them, while every
|
|
68
|
+
component, control and record stays. A change to one colour or one face of the
|
|
69
|
+
skin is an edit to that value in this string, and the skin keeps its shapes and
|
|
70
|
+
chrome: "make the accent green" moves the accent token, and the title bar stays.
|
|
71
|
+
Web fonts load from Google Fonts with an `@import` at the top of that
|
|
61
72
|
string. A heading face reads the Font card's pick first,
|
|
62
73
|
`font-family: var(--font-pick, 'Silkscreen', monospace)`, so the skin's face is
|
|
63
74
|
the default and a font the person picks in the Look tab reaches every heading
|
package/llms/web-audio.md
CHANGED
|
@@ -63,6 +63,23 @@ Practical: clean up disconnected nodes; check browser support; use headphones to
|
|
|
63
63
|
- Latency budget: device `baseLatency` + your lookahead + any Worklet buffering.
|
|
64
64
|
- Headphones recommended for monitoring to avoid acoustic feedback.
|
|
65
65
|
|
|
66
|
+
## 2b) Sound that plays with the iPhone's silent switch on
|
|
67
|
+
|
|
68
|
+
When sound is the point of the app — a drum machine, a synth, a soundboard, a metronome, a timer whose chime is the thing it does — set the playback audio session when the person first presses to start sound, before the context is created, so the app keeps playing with the silent switch on the way a music app does. iOS otherwise plays Web Audio in the ambient session, which the switch mutes after the first sound. Feature-detect it: `navigator.audioSession` exists in Safari 17 and later, and every other browser skips the line and plays as before.
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
// Sound is the point of this app: it plays with the silent switch on, like a music app.
|
|
72
|
+
function playThroughSilentSwitch() {
|
|
73
|
+
if ("audioSession" in navigator) navigator.audioSession.type = "playback";
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// The first line of the sound core's unlockAudio(), ahead of new AudioContext():
|
|
77
|
+
// playThroughSilentSwitch();
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
An app whose sound is feedback on its actions (a game's blips, a tap
|
|
81
|
+
confirmation) leaves the session alone, so the phone's switch quiets it.
|
|
82
|
+
|
|
66
83
|
## 3) Restraint
|
|
67
84
|
|
|
68
85
|
The sound core's restraint rule holds here too: an audio toy plays what the person plays, and an app whose sound is feedback keeps it to the core actions.
|
package/llms/web-music.md
CHANGED
|
@@ -343,6 +343,8 @@ let drums;
|
|
|
343
343
|
|
|
344
344
|
// The sound core's gate: synchronous, inside the tap, with one real (silent) sound.
|
|
345
345
|
function unlockAudio() {
|
|
346
|
+
// A drum machine's point is sound: play with the iPhone's silent switch on (web-audio § 2b).
|
|
347
|
+
if ("audioSession" in navigator) navigator.audioSession.type = "playback";
|
|
346
348
|
audioCtx ||= new (window.AudioContext || window.webkitAudioContext)();
|
|
347
349
|
if (audioCtx.state !== "running") {
|
|
348
350
|
audioCtx.resume();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibes.diy/prompts",
|
|
3
|
-
"version": "14.3.
|
|
3
|
+
"version": "14.3.342",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"exports": {
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@adviser/cement": "~0.5.37",
|
|
42
|
-
"@vibes.diy/api-types": "14.3.
|
|
43
|
-
"@vibes.diy/call-ai-v2": "14.3.
|
|
44
|
-
"@vibes.diy/identity": "14.3.
|
|
45
|
-
"@vibes.diy/use-vibes-types": "14.3.
|
|
42
|
+
"@vibes.diy/api-types": "14.3.342",
|
|
43
|
+
"@vibes.diy/call-ai-v2": "14.3.342",
|
|
44
|
+
"@vibes.diy/identity": "14.3.342",
|
|
45
|
+
"@vibes.diy/use-vibes-types": "14.3.342",
|
|
46
46
|
"arktype": "~2.2.9",
|
|
47
47
|
"json-schema-faker": "~0.6.4"
|
|
48
48
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PaletteSeed } from "./palette-gen.js";
|
|
2
2
|
import type { Ornament } from "./ornament-pad.js";
|
|
3
|
+
import { type PoufSeed } from "./pouf-rooms.js";
|
|
3
4
|
export interface StylePreset {
|
|
4
5
|
readonly slug: string;
|
|
5
6
|
readonly label: string;
|
|
@@ -17,3 +18,6 @@ export declare const POUF_ROOM_ACCENT_PINS: Readonly<Record<string, number>>;
|
|
|
17
18
|
export declare const POUF_STYLE_PRESETS: readonly StylePreset[];
|
|
18
19
|
export declare const POUF_BOLD_TONE = 1;
|
|
19
20
|
export declare const POUF_BOLD_PRESETS: readonly StylePreset[];
|
|
21
|
+
export declare function poufSeedEqualsPreset(seed: PoufSeed | undefined, preset: PoufSeed | undefined): boolean;
|
|
22
|
+
export declare function poufPresetOfSeed(seed: PoufSeed | undefined): string | undefined;
|
|
23
|
+
export declare function poufRoomOfSeed(seed: PoufSeed | undefined): string | undefined;
|
package/themes/style-presets.js
CHANGED
|
@@ -174,3 +174,18 @@ export const POUF_BOLD_PRESETS = POUF_STYLE_PRESETS.filter((p) => p.slug !== "po
|
|
|
174
174
|
},
|
|
175
175
|
};
|
|
176
176
|
});
|
|
177
|
+
export function poufSeedEqualsPreset(seed, preset) {
|
|
178
|
+
if (seed === undefined || preset === undefined)
|
|
179
|
+
return false;
|
|
180
|
+
if (seed.up !== undefined || seed.down !== undefined)
|
|
181
|
+
return false;
|
|
182
|
+
return preset.lead === seed.lead && preset.locked === seed.locked && preset.tone === seed.tone && preset.gap === seed.gap;
|
|
183
|
+
}
|
|
184
|
+
export function poufPresetOfSeed(seed) {
|
|
185
|
+
const slugs = [...POUF_ROOM_SLUGS, ...POUF_BOLD_PRESETS.map((p) => p.slug)];
|
|
186
|
+
return slugs.find((slug) => poufSeedEqualsPreset(seed, getStylePreset(slug)?.palette.pouf));
|
|
187
|
+
}
|
|
188
|
+
export function poufRoomOfSeed(seed) {
|
|
189
|
+
const slug = poufPresetOfSeed(seed);
|
|
190
|
+
return slug?.endsWith("-bold") === true ? slug.slice(0, -"-bold".length) : slug;
|
|
191
|
+
}
|