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/cli.js CHANGED
@@ -17650,6 +17650,12 @@ async function currentArt(entry, spec) {
17650
17650
  }
17651
17651
  return { path: file, contentType, width, height };
17652
17652
  }
17653
+ async function cachedFrame(url) {
17654
+ if (!url.startsWith("file://")) return null;
17655
+ const file = url.slice("file://".length);
17656
+ const contentType = mediaTypeFromExtension(file) ?? detectMediaType(await readFile23(file).catch(() => Buffer.alloc(0))) ?? "application/octet-stream";
17657
+ return { path: file, contentType };
17658
+ }
17653
17659
  async function prepareReview(provider, lock, opts = {}) {
17654
17660
  const log2 = opts.onProgress ?? (() => {
17655
17661
  });
@@ -17659,6 +17665,7 @@ async function prepareReview(provider, lock, opts = {}) {
17659
17665
  );
17660
17666
  const reviewAssets = /* @__PURE__ */ new Map();
17661
17667
  const prefix = opts.routePrefix ?? "";
17668
+ const providerUrls = /* @__PURE__ */ new Map();
17662
17669
  const groups = [];
17663
17670
  for (const [key, entry] of Object.entries(lock.entries)) {
17664
17671
  if (entry.provider !== provider.id || selectedKeys && !selectedKeys.has(key)) continue;
@@ -17667,7 +17674,19 @@ async function prepareReview(provider, lock, opts = {}) {
17667
17674
  const spec = specByKey.get(key);
17668
17675
  const state = await provider.poll(entry.reviewObjectId, entry.generator, { spec, metadata: entry.providerMetadata?.[provider.id] });
17669
17676
  if (state.status !== "review" && state.status !== "review-set" || (state.status === "review" ? !state.candidateUrls.length : !state.frameUrls.length)) continue;
17670
- const frameUrls = state.status === "review" ? state.candidateUrls : state.frameUrls;
17677
+ const urls = state.status === "review" ? state.candidateUrls : state.frameUrls;
17678
+ const frameUrls = [];
17679
+ const frameAssets = [];
17680
+ for (const [index, url] of urls.entries()) {
17681
+ const cached = await cachedFrame(url);
17682
+ if (!cached) {
17683
+ frameUrls.push(url);
17684
+ continue;
17685
+ }
17686
+ const route = `${prefix}/review-frame/${encodeURIComponent(String(groups.length))}/${index}`;
17687
+ frameAssets.push([route, cached]);
17688
+ frameUrls.push(route);
17689
+ }
17671
17690
  const sourceRoute = spec?.revision ? `${prefix}/revision-source/${encodeURIComponent(String(groups.length))}` : null;
17672
17691
  if (sourceRoute && spec?.revision) {
17673
17692
  reviewAssets.set(sourceRoute, {
@@ -17680,6 +17699,8 @@ async function prepareReview(provider, lock, opts = {}) {
17680
17699
  if (current && currentRoute) {
17681
17700
  reviewAssets.set(currentRoute, { path: current.path, contentType: current.contentType });
17682
17701
  }
17702
+ for (const [route, asset] of frameAssets) reviewAssets.set(route, asset);
17703
+ providerUrls.set(key, urls);
17683
17704
  groups.push({
17684
17705
  key,
17685
17706
  assetId: entry.assetId,
@@ -17762,7 +17783,7 @@ async function prepareReview(provider, lock, opts = {}) {
17762
17783
  status: "selected",
17763
17784
  objectId,
17764
17785
  candidateIndex: index,
17765
- sourceUrl: sourceUrl ?? group.frameUrls[index] ?? null,
17786
+ sourceUrl: sourceUrl ?? providerUrls.get(key)?.[index] ?? null,
17766
17787
  sourceUrls: [],
17767
17788
  provider: provider.id,
17768
17789
  providerMetadata: metadata ? {