pixelkiln 0.75.0 → 0.77.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.
package/dist/index.cjs CHANGED
@@ -221,6 +221,7 @@ __export(index_exports, {
221
221
  paletteDistance: () => paletteDistance,
222
222
  parentAssetId: () => parentAssetId,
223
223
  parseLock: () => parseLock,
224
+ parseProFlashQuote: () => parseProFlashQuote,
224
225
  parseTerrainDescriptions: () => parseTerrainDescriptions,
225
226
  parseWorkspace: () => parseWorkspace,
226
227
  pickHistory: () => pickHistory,
@@ -2032,6 +2033,25 @@ function cleanupResults(images, sent, operation) {
2032
2033
  }
2033
2034
  return images.map((image) => Buffer.from(image.base64, "base64"));
2034
2035
  }
2036
+ function parseProFlashQuote(raw) {
2037
+ const body = raw && typeof raw === "object" ? raw : {};
2038
+ const nested = [body, body.usage, body.cost, body.estimate].filter((v) => Boolean(v) && typeof v === "object");
2039
+ const pick = (...names) => {
2040
+ for (const obj of nested) {
2041
+ for (const name of names) {
2042
+ const value = obj[name];
2043
+ if (typeof value === "number" && Number.isFinite(value) && value >= 0) return value;
2044
+ }
2045
+ }
2046
+ return null;
2047
+ };
2048
+ const image = pick("image", "image_generations", "first_image", "first_image_generations");
2049
+ const rotations = pick("rotations", "rotation", "rotations_generations", "rotation_generations");
2050
+ const total = pick("total", "total_generations", "generations");
2051
+ if (total !== null) return { image, rotations, total };
2052
+ if (image !== null || rotations !== null) return { image, rotations, total: (image ?? 0) + (rotations ?? 0) };
2053
+ throw new Error(`GET /pro-flash/cost returned no price: ${JSON.stringify(raw).slice(0, 200)}`);
2054
+ }
2035
2055
  var PixelLabError = class extends ProviderError {
2036
2056
  constructor(message6, status, body) {
2037
2057
  super("pixellab", message6, { status });
@@ -2090,6 +2110,19 @@ var PixelLabClient = class {
2090
2110
  plan: raw.subscription?.plan ?? "unknown"
2091
2111
  };
2092
2112
  }
2113
+ /**
2114
+ * `GET /pro-flash/cost`: PixelLab's own quote for one Pro Flash job, split
2115
+ * into the first image and the v3 rotations. Free, and provisional by
2116
+ * PixelLab's own description; the billed amount on the finished job is
2117
+ * the real one. The response schema is undocumented (`{}` in the spec),
2118
+ * so this reads it leniently: a total if one is given, else the sum of
2119
+ * the parts, and refuses an answer with no number in it.
2120
+ */
2121
+ async proFlashCost(args) {
2122
+ const query = new URLSearchParams({ operation: args.operation, width: String(args.width), height: String(args.height) });
2123
+ if (args.nDirections !== void 0) query.set("n_directions", String(args.nDirections));
2124
+ return parseProFlashQuote(await this.request(`/pro-flash/cost?${query}`));
2125
+ }
2093
2126
  /**
2094
2127
  * Square objects that persist indefinitely.
2095
2128
  *
@@ -17031,6 +17064,9 @@ ${css}</style>
17031
17064
  <button id="studio" type="button" hidden title="Draft a new character: its style, base, loops, and portrait, priced as you go">+ New character</button>
17032
17065
  <button id="refresh" type="button" title="Re-read the manifest, lockfile, and disk">Refresh</button>
17033
17066
  <label class="chip" title="Refresh every 5 seconds while this tab is visible"><input id="auto" type="checkbox"> auto</label>
17067
+ <label class="chip" title="Play every loop on the grid; without this, a loop plays while the pointer is over it"><input id="playloops" type="checkbox"> play loops</label>
17068
+ <span id="backdrop-slot"></span>
17069
+ <label class="chip" id="notify-chip" hidden title="A system notification when a job finishes while this tab is in the background"><input id="notify" type="checkbox"> notify</label>
17034
17070
  </div>
17035
17071
  <div class="totals" id="totals"></div>
17036
17072
  <div class="chips" id="chips"></div>
@@ -17040,7 +17076,7 @@ ${css}</style>
17040
17076
  <main id="root"></main>
17041
17077
  <footer>
17042
17078
  Click a sprite for its full record; <kbd>shift</kbd>-click adds it to a side-by-side comparison. <kbd>\u2190</kbd>/<kbd>\u2192</kbd> step through the visible set while a record
17043
- is open, <kbd>Esc</kbd> closes it, and <kbd>/</kbd> jumps to search. This page reads the manifest, lockfile,
17079
+ is open, <kbd>,</kbd>/<kbd>.</kbd> step a loop's frames and <kbd>space</kbd> plays it, <kbd>Esc</kbd> closes it, and <kbd>/</kbd> jumps to search. This page reads the manifest, lockfile,
17044
17080
  and disk only. It never contacts a provider<span id="foot-edit"> and never writes anything</span><span id="foot-editing" hidden>.
17045
17081
  Editing is on: saving rewrites the manifest and nothing else</span><span id="foot-gen" hidden>.
17046
17082
  Generation is on under the session budget shown above; every run is the same submit, poll, and fetch as <code>pixelkiln gen</code></span>.
@@ -18865,6 +18901,7 @@ async function workspaceStatus(ws, dir) {
18865
18901
  paletteDistance,
18866
18902
  parentAssetId,
18867
18903
  parseLock,
18904
+ parseProFlashQuote,
18868
18905
  parseTerrainDescriptions,
18869
18906
  parseWorkspace,
18870
18907
  pickHistory,