pixelkiln 0.86.2 → 0.86.3

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.d.cts CHANGED
@@ -18206,7 +18206,11 @@ interface ReviewReadyInfo {
18206
18206
  */
18207
18207
  interface ReviewSession {
18208
18208
  groups: SheetGroup[];
18209
- /** Exact local media routes the sheet references (revision sources). */
18209
+ /**
18210
+ * Exact local media routes the sheet references: revision sources, the art
18211
+ * a regeneration replaces, and any frame or candidate the provider cached
18212
+ * on local disk.
18213
+ */
18210
18214
  assets: ReadonlyMap<string, {
18211
18215
  path: string;
18212
18216
  contentType: string;
package/dist/index.d.ts CHANGED
@@ -18206,7 +18206,11 @@ interface ReviewReadyInfo {
18206
18206
  */
18207
18207
  interface ReviewSession {
18208
18208
  groups: SheetGroup[];
18209
- /** Exact local media routes the sheet references (revision sources). */
18209
+ /**
18210
+ * Exact local media routes the sheet references: revision sources, the art
18211
+ * a regeneration replaces, and any frame or candidate the provider cached
18212
+ * on local disk.
18213
+ */
18210
18214
  assets: ReadonlyMap<string, {
18211
18215
  path: string;
18212
18216
  contentType: string;
package/dist/index.js CHANGED
@@ -15073,6 +15073,12 @@ async function currentArt(entry, spec) {
15073
15073
  }
15074
15074
  return { path: file, contentType, width, height };
15075
15075
  }
15076
+ async function cachedFrame(url) {
15077
+ if (!url.startsWith("file://")) return null;
15078
+ const file = url.slice("file://".length);
15079
+ const contentType = mediaTypeFromExtension(file) ?? detectMediaType(await readFile17(file).catch(() => Buffer.alloc(0))) ?? "application/octet-stream";
15080
+ return { path: file, contentType };
15081
+ }
15076
15082
  async function prepareReview(provider, lock, opts = {}) {
15077
15083
  const log = opts.onProgress ?? (() => {
15078
15084
  });
@@ -15082,6 +15088,7 @@ async function prepareReview(provider, lock, opts = {}) {
15082
15088
  );
15083
15089
  const reviewAssets = /* @__PURE__ */ new Map();
15084
15090
  const prefix = opts.routePrefix ?? "";
15091
+ const providerUrls = /* @__PURE__ */ new Map();
15085
15092
  const groups = [];
15086
15093
  for (const [key, entry] of Object.entries(lock.entries)) {
15087
15094
  if (entry.provider !== provider.id || selectedKeys && !selectedKeys.has(key)) continue;
@@ -15090,7 +15097,19 @@ async function prepareReview(provider, lock, opts = {}) {
15090
15097
  const spec = specByKey.get(key);
15091
15098
  const state = await provider.poll(entry.reviewObjectId, entry.generator, { spec, metadata: entry.providerMetadata?.[provider.id] });
15092
15099
  if (state.status !== "review" && state.status !== "review-set" || (state.status === "review" ? !state.candidateUrls.length : !state.frameUrls.length)) continue;
15093
- const frameUrls = state.status === "review" ? state.candidateUrls : state.frameUrls;
15100
+ const urls = state.status === "review" ? state.candidateUrls : state.frameUrls;
15101
+ const frameUrls = [];
15102
+ const frameAssets = [];
15103
+ for (const [index, url] of urls.entries()) {
15104
+ const cached = await cachedFrame(url);
15105
+ if (!cached) {
15106
+ frameUrls.push(url);
15107
+ continue;
15108
+ }
15109
+ const route = `${prefix}/review-frame/${encodeURIComponent(String(groups.length))}/${index}`;
15110
+ frameAssets.push([route, cached]);
15111
+ frameUrls.push(route);
15112
+ }
15094
15113
  const sourceRoute = spec?.revision ? `${prefix}/revision-source/${encodeURIComponent(String(groups.length))}` : null;
15095
15114
  if (sourceRoute && spec?.revision) {
15096
15115
  reviewAssets.set(sourceRoute, {
@@ -15103,6 +15122,8 @@ async function prepareReview(provider, lock, opts = {}) {
15103
15122
  if (current && currentRoute) {
15104
15123
  reviewAssets.set(currentRoute, { path: current.path, contentType: current.contentType });
15105
15124
  }
15125
+ for (const [route, asset] of frameAssets) reviewAssets.set(route, asset);
15126
+ providerUrls.set(key, urls);
15106
15127
  groups.push({
15107
15128
  key,
15108
15129
  assetId: entry.assetId,
@@ -15185,7 +15206,7 @@ async function prepareReview(provider, lock, opts = {}) {
15185
15206
  status: "selected",
15186
15207
  objectId,
15187
15208
  candidateIndex: index,
15188
- sourceUrl: sourceUrl ?? group.frameUrls[index] ?? null,
15209
+ sourceUrl: sourceUrl ?? providerUrls.get(key)?.[index] ?? null,
15189
15210
  sourceUrls: [],
15190
15211
  provider: provider.id,
15191
15212
  providerMetadata: metadata ? {