@cameronsjo/artificer 0.25.0 → 0.28.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 (37) hide show
  1. package/README.md +14 -12
  2. package/dist/artificer-chromium-dark.zip +0 -0
  3. package/dist/artificer-chromium-light.zip +0 -0
  4. package/dist/artificer-firefox.zip +0 -0
  5. package/package.json +5 -1
  6. package/reference/SKILL.md +30 -24
  7. package/src/artificer-editorial.css +3 -1
  8. package/src/artificer-sploot.js +303 -0
  9. package/src/artificer-texture.css +129 -23
  10. package/src/artificer-whimsy.css +209 -30
  11. package/src/artificer-whimsy.js +227 -5
  12. package/src/artificer.css +334 -117
  13. package/src/assets/app-icon-1024.png +0 -0
  14. package/src/assets/app-icon.svg +1 -0
  15. package/src/assets/favicon-16.png +0 -0
  16. package/src/assets/favicon-180.png +0 -0
  17. package/src/assets/favicon-32.png +0 -0
  18. package/src/assets/favicon-48.png +0 -0
  19. package/src/assets/favicon-512.png +0 -0
  20. package/src/assets/favicon-legacy.svg +5 -0
  21. package/src/assets/favicon.ico +0 -0
  22. package/src/assets/favicon.svg +1 -5
  23. package/src/assets/fonts/bricolage-grotesque-variable.woff2 +0 -0
  24. package/src/assets/fonts/jetbrains-mono-blocks.woff2 +0 -0
  25. package/src/assets/fonts/recursive-variable.woff2 +0 -0
  26. package/src/assets/og-image.png +0 -0
  27. package/src/assets/og-image.svg +14 -20
  28. package/src/primitives.json +77 -4
  29. package/src/print.css +4 -3
  30. package/src/tokens.json +4 -4
  31. package/types/sploot.d.ts +48 -0
  32. package/src/assets/fonts/ia-writer-quattro-s-400-italic.woff2 +0 -0
  33. package/src/assets/fonts/ia-writer-quattro-s-400.woff2 +0 -0
  34. package/src/assets/fonts/ia-writer-quattro-s-700-italic.woff2 +0 -0
  35. package/src/assets/fonts/ia-writer-quattro-s-700.woff2 +0 -0
  36. package/src/assets/fonts/ia-writer-quattro-v-400-italic.woff2 +0 -0
  37. package/src/assets/fonts/ia-writer-quattro-v-400.woff2 +0 -0
@@ -1,5 +1,5 @@
1
1
  /* ═══════════════════════════════════════════════════════════════════════════
2
- ARTIFICER · Whimsy helper · v0.25.0
2
+ ARTIFICER · Whimsy helper · v0.28.0
3
3
  ─────────────────────────────────────────────────────────────────────────
4
4
  Tiny, dependency-free. Pairs with artificer-whimsy.css. Exposes window.Whimsy.
5
5
 
@@ -35,7 +35,16 @@
35
35
  Whimsy.run(el, opts) ignite el, then settle after opts.loops
36
36
  hue-cycles. For long "thinking" states.
37
37
  opts = { loops?, settle? }
38
- Whimsy.scheduleSettle(el, n, mode) rest el after n loops; returns cancel().
38
+ Whimsy.scheduleSettle(el, n, mode, opts?) rest el after n loops; returns
39
+ cancel(). opts = { seconds?, group? }.
40
+ Whimsy.starfield(el, opts?) render a seeded starfield into a night sky
41
+ ([data-whimsy~="sky"] hydrates on its own)
42
+ and rest it with its wordmark on one timer.
43
+ opts = { seed?, count?, sparkles?, clear?,
44
+ loops?, settle? }
45
+ Whimsy.starPositions(seed, opts?) PURE — the star placement behind
46
+ starfield(). Deterministic per seed.
47
+ Whimsy.mulberry32(seed) PURE — the seeded PRNG starPositions draws.
39
48
  Whimsy.settle(el, mode) / .unsettle(el) manual rest / wake.
40
49
  mode: "static" (default) | "glacial".
41
50
  Whimsy.ignite(el) / .clear(el) manual toggle.
@@ -110,12 +119,21 @@
110
119
  }
111
120
 
112
121
  /* Rest `el` after `loops` hue-cycles. loops <= 0 / Infinity = never settle.
113
- mode: "static" (default) | "glacial". Returns a cancel() fn. */
114
- function scheduleSettle(el, loops, mode) {
122
+ mode: "static" (default) | "glacial". Returns a cancel() fn.
123
+ opts = { seconds?, group? } — seconds overrides the cycle length (default:
124
+ the element's live --whimsy-speed); group also settles every .whimsy-star
125
+ and .whimsy inside el on the same tick, so a sky and the wordmark it
126
+ frames rest together as one whimsy moment (#501). */
127
+ function scheduleSettle(el, loops, mode, opts) {
115
128
  if (!el || !loops || loops === Infinity || loops <= 0) return function () {};
129
+ opts = opts || {};
130
+ var seconds = opts.seconds > 0 ? opts.seconds : flowSeconds(el);
116
131
  var id = window.setTimeout(function () {
117
132
  settle(el, mode);
118
- }, flowSeconds(el) * loops * 1000);
133
+ if (!opts.group) return;
134
+ var inner = el.querySelectorAll(".whimsy-star, .whimsy");
135
+ for (var i = 0; i < inner.length; i++) settle(inner[i], mode);
136
+ }, seconds * loops * 1000);
119
137
  return function cancel() { window.clearTimeout(id); };
120
138
  }
121
139
 
@@ -149,6 +167,198 @@
149
167
  el.dataset.whimsyHydrated = "1";
150
168
  }
151
169
 
170
+ /* ── Night sky ── seeded starfield (#501) ──────────────────────────────────
171
+ The algorithm is a contract: a starfield spec describes it draw by draw
172
+ so native ports reproduce the same sky from the same seed, and a
173
+ conformance table pins it. Change the draw order here and both must move
174
+ with it. */
175
+
176
+ // Tints are token ROLE names; CSS resolves each through
177
+ // color-mix(in oklab, var(--<role>) 70%, var(--fg)). Index order is part of
178
+ // the contract — a draw picks by index.
179
+ var STAR_TINTS = ["accent", "attention", "brand-purple-bright", "steel", "success"];
180
+ // Star radii in px at 1×, the stars2.py set (duplicates weight the draw).
181
+ var STAR_SIZES = [1.3, 1.4, 1.7, 1.7, 2.0, 2.3, 2.6];
182
+ var SPARKLE_RADIUS = 11;
183
+ var MAX_ATTEMPTS = 5000;
184
+ var MAX_SPARKLE_PICKS = 100;
185
+ var SKY_DEFAULTS = {
186
+ count: 48,
187
+ sparkles: 4,
188
+ spacing: 0.034, // min distance between star centers, 0–1 units
189
+ topBias: 0.15, // density falloff: accept if draw <= 1 + topBias - t
190
+ bounds: [0.04, 0.03, 0.96, 0.97], // x0, y0, x1, y1 — where stars may land
191
+ clear: null // { cx, cy, rx, ry } ellipse kept empty, or null
192
+ };
193
+
194
+ /* PURE — mulberry32, integer-only (Math.imul + >>>) so every language with
195
+ wrapping 32-bit multiply reproduces it exactly. Returns a draw fn → [0, 1). */
196
+ function mulberry32(seed) {
197
+ var a = seed >>> 0;
198
+ return function () {
199
+ a = (a + 0x6d2b79f5) >>> 0;
200
+ var t = Math.imul(a ^ (a >>> 15), a | 1);
201
+ t = (t + Math.imul(t ^ (t >>> 7), t | 61)) ^ t;
202
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
203
+ };
204
+ }
205
+
206
+ function quantize(v) { return Math.round(v * 1e6) / 1e6; }
207
+
208
+ function toSeed(seed) {
209
+ var n = typeof seed === "string" && seed.trim() !== "" ? Number(seed) : seed;
210
+ if (typeof n !== "number" || !isFinite(n) || Math.floor(n) !== n) {
211
+ throw new TypeError("Whimsy.starPositions: seed must be an integer, got " + JSON.stringify(seed));
212
+ }
213
+ return n >>> 0;
214
+ }
215
+
216
+ /* PURE — place a seeded starfield. Returns
217
+ [{ x, y, r, o, tint, sparkle, phase, period }]: x/y in 0–1 of the sky box,
218
+ r in px at 1×, o = base opacity, tint = a STAR_TINTS role, phase in [0, 1)
219
+ and period in seconds (4–9) for the twinkle. Stops at MAX_ATTEMPTS, so an
220
+ over-packed request returns fewer stars instead of hanging. */
221
+ function starPositions(seed, opts) {
222
+ var o = {};
223
+ var k;
224
+ for (k in SKY_DEFAULTS) o[k] = SKY_DEFAULTS[k];
225
+ for (k in (opts || {})) if (opts[k] !== undefined) o[k] = opts[k];
226
+ var b = o.bounds;
227
+ if (!(o.count >= 0) || Math.floor(o.count) !== o.count) {
228
+ throw new RangeError("Whimsy.starPositions: count must be a non-negative integer, got " + o.count);
229
+ }
230
+ if (!(o.sparkles >= 0)) {
231
+ throw new RangeError("Whimsy.starPositions: sparkles must be >= 0, got " + o.sparkles);
232
+ }
233
+ if (!b || b.length !== 4 || !(b[0] < b[2]) || !(b[1] < b[3])) {
234
+ throw new RangeError("Whimsy.starPositions: bounds must be [x0, y0, x1, y1] with x0 < x1 and y0 < y1, got " + JSON.stringify(b));
235
+ }
236
+ var rand = mulberry32(toSeed(seed));
237
+ var stars = [];
238
+ for (var tries = 0; stars.length < o.count && tries < MAX_ATTEMPTS; tries++) {
239
+ var x = b[0] + (b[2] - b[0]) * rand();
240
+ var y = b[1] + (b[3] - b[1]) * rand();
241
+ var t = (y - b[1]) / (b[3] - b[1]);
242
+ if (rand() > 1 + o.topBias - t) continue; // thinner toward the bottom
243
+ if (o.clear) {
244
+ var ex = (x - o.clear.cx) / o.clear.rx;
245
+ var ey = (y - o.clear.cy) / o.clear.ry;
246
+ if (ex * ex + ey * ey < 1) continue; // keep the focal zone clear
247
+ }
248
+ var crowded = false;
249
+ for (var i = 0; i < stars.length && !crowded; i++) {
250
+ crowded = Math.hypot(x - stars[i].x, y - stars[i].y) < o.spacing;
251
+ }
252
+ if (crowded) continue;
253
+ stars.push({
254
+ x: x, y: y,
255
+ r: STAR_SIZES[Math.floor(rand() * STAR_SIZES.length)],
256
+ o: 0.35 + 0.5 * rand(),
257
+ tint: STAR_TINTS[Math.floor(rand() * STAR_TINTS.length)],
258
+ sparkle: false,
259
+ phase: rand(),
260
+ period: 4 + 5 * rand()
261
+ });
262
+ }
263
+ var want = Math.min(o.sparkles, stars.length);
264
+ for (var s = 0, picks = 0; s < want && picks < MAX_SPARKLE_PICKS; picks++) {
265
+ var star = stars[Math.floor(rand() * stars.length)];
266
+ if (star.sparkle) continue;
267
+ star.sparkle = true;
268
+ star.r = SPARKLE_RADIUS;
269
+ s++;
270
+ }
271
+ return stars.map(function (st) {
272
+ return { x: quantize(st.x), y: quantize(st.y), r: st.r, o: quantize(st.o),
273
+ tint: st.tint, sparkle: st.sparkle,
274
+ phase: quantize(st.phase), period: quantize(st.period) };
275
+ });
276
+ }
277
+
278
+ // el → cancel() for its pending sky settle, so a re-render re-arms one timer.
279
+ var skySettles = new WeakMap();
280
+
281
+ function readInt(v, fallback) {
282
+ var n = parseInt(v, 10);
283
+ return isNaN(n) ? fallback : n;
284
+ }
285
+
286
+ /* DOM — render a seeded starfield into a .whimsy-sky element and arm the
287
+ shared settle. Stars are aria-hidden decoration; CSS hides them in light
288
+ mode, so a theme toggle needs no re-render. Idempotent: the same options
289
+ on an already-rendered sky do nothing; different options replace the
290
+ field. opts = { seed?, count?, sparkles?, clear?, loops?, settle? } —
291
+ omitted values read data-whimsy-seed / -stars / -loops / -settle.
292
+ settle: "glacial" (default) | "static" | "none". */
293
+ function starfield(el, opts) {
294
+ if (!el) return;
295
+ opts = opts || {};
296
+ var d = el.dataset;
297
+ var seed = opts.seed != null ? opts.seed : (d.whimsySeed || 1);
298
+ var placement = {
299
+ count: opts.count != null ? opts.count : readInt(d.whimsyStars, SKY_DEFAULTS.count),
300
+ sparkles: opts.sparkles,
301
+ clear: opts.clear
302
+ };
303
+ var mode = opts.settle || d.whimsySettle || "glacial";
304
+ var loops = opts.loops != null ? opts.loops : readInt(d.whimsyLoops, 3);
305
+ var signature = JSON.stringify([seed, placement, mode, loops]);
306
+ // Its own flag, not whimsyHydrated: a node marked data-whimsy="sky wave"
307
+ // must still get its wave split (splitWave skips whimsyHydrated nodes).
308
+ if (d.whimsySky === signature) return;
309
+
310
+ var stars;
311
+ try {
312
+ stars = starPositions(seed, placement);
313
+ } catch (err) {
314
+ // Bad data-* on a decorative layer must not break the page: say what
315
+ // was wrong and render the default field instead.
316
+ console.warn("Whimsy.starfield: " + err.message + " — rendering the default field.");
317
+ stars = starPositions(1);
318
+ }
319
+
320
+ el.classList.add("whimsy-sky");
321
+ // Read the cycle length before writing the stars, so the style read does
322
+ // not force a recalc over freshly inserted nodes.
323
+ var seconds = parseMs(getComputedStyle(el).getPropertyValue("--whimsy-sky-speed")) / 1000;
324
+ var layer = el.querySelector(":scope > .whimsy-sky__stars");
325
+ if (layer) layer.textContent = "";
326
+ else {
327
+ layer = document.createElement("div");
328
+ layer.className = "whimsy-sky__stars";
329
+ layer.setAttribute("aria-hidden", "true");
330
+ el.insertBefore(layer, el.firstChild);
331
+ }
332
+ var batch = document.createDocumentFragment();
333
+ for (var i = 0; i < stars.length; i++) {
334
+ var s = stars[i];
335
+ var span = document.createElement("span");
336
+ span.className = s.sparkle ? "whimsy-star whimsy-star--sparkle" : "whimsy-star";
337
+ span.style.left = (s.x * 100).toFixed(4) + "%";
338
+ span.style.top = (s.y * 100).toFixed(4) + "%";
339
+ span.style.setProperty("--star-r", s.r + "px");
340
+ span.style.setProperty("--star-o", String(s.o));
341
+ span.style.setProperty("--star-tint", "var(--" + s.tint + ")");
342
+ span.style.setProperty("--star-period", s.period.toFixed(3) + "s");
343
+ span.style.setProperty("--d", (-s.phase * s.period).toFixed(3) + "s");
344
+ batch.appendChild(span);
345
+ }
346
+ layer.appendChild(batch);
347
+
348
+ // One timer for the whole moment: the sky, its stars, and any .whimsy
349
+ // wordmark inside rest together after `loops` sky cycles.
350
+ var prior = skySettles.get(el);
351
+ if (prior) prior();
352
+ unsettle(el);
353
+ var inner = el.querySelectorAll(".whimsy");
354
+ for (var j = 0; j < inner.length; j++) unsettle(inner[j]);
355
+ if (mode !== "none") {
356
+ skySettles.set(el, scheduleSettle(el, loops, mode,
357
+ { seconds: seconds > 0 ? seconds : 40, group: true }));
358
+ }
359
+ d.whimsySky = signature;
360
+ }
361
+
152
362
  function hydrate(root) {
153
363
  root = root || document;
154
364
  var waves = root.querySelectorAll('[data-whimsy~="wave"]');
@@ -165,6 +375,14 @@
165
375
  if (plain[j].dataset.whimsyCleared === "1") continue;
166
376
  plain[j].classList.add("whimsy");
167
377
  }
378
+ // Skies last: splitWave rewrites textContent, which would wipe a stars
379
+ // layer already inserted into a node marked data-whimsy="sky wave".
380
+ var skies = root.querySelectorAll('[data-whimsy~="sky"]');
381
+ for (var s = 0; s < skies.length; s++) {
382
+ if (skies[s].dataset.whimsyCleared === "1") continue;
383
+ if (skies[s].dataset.whimsySky) continue;
384
+ starfield(skies[s]);
385
+ }
168
386
  }
169
387
 
170
388
  /* The "ultrathink" gesture. Watch a text input; when its value contains any
@@ -419,6 +637,10 @@
419
637
  settle: settle,
420
638
  unsettle: unsettle,
421
639
  scheduleSettle: scheduleSettle,
640
+ starfield: starfield,
641
+ starPositions: starPositions,
642
+ mulberry32: mulberry32,
643
+ STAR_TINTS: STAR_TINTS.slice(),
422
644
  ignite: igniteEl,
423
645
  clear: clearEl
424
646
  };