Published
Edited
Jul 9, 2022
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Endpoints = ({
[Subdomains.api]: {
recent: { defaults: { num_items: 1 } },

random: { defaults: { num_items: 1 }, fetchFn: fetchFn_random },

rgb: {
defaults: {
r: 128,
g: 128,
b: 128,
color_range: 128,
num_items: 9,
index: 1
}
},

userfeed: { defaults: { user_id: undefined, num_items: 64, index: 1 } },

myhistory: {
defaults: { user_id: undefined, status: undefined }, // status = archived | completed | processing | queued | rejected
fetchFn: fetchFn_history
},

job: { defaults: { uuid: undefined } },

query: { defaults: { uuid: undefined } }
},

[Subdomains.images]: {
thumbs: {
defaults: { uuid: undefined, size: 1024 },
urlFn: urlFn_thumbs
},

images: { defaults: { uuid: undefined }, urlFn: urlFn_images },

jpg: { defaults: { uuid: undefined }, urlFn: urlFn_jpg }
},

[Subdomains.website]: {
website: { urlFn: (urlFn) => () => Subdomains.website },

gallery: { defaults: { user_id: undefined, num_items: 1, index: 1 } },

piece: { defaults: { uuid: undefined } }
}
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
getImageURL = (job, thumbnail_size, preferPNG = false) => {
// - thumbnail -
if (thumbnail_size) return FeverDreams.thumbs.url(job?.uuid, thumbnail_size);

// - progress -
if (!job?.filename) return FeverDreams.images.url(job?.uuid, false);

// - png -
if (preferPNG) return FeverDreams.images.url(job?.uuid, true);

// - jpg -
if (job?.jpg) return FeverDreams.jpg.url(job?.uuid);

throw new Error(`Found no image url for uuid: ${job?.uuid}`);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewImage = (job, size, hrefFn = (job) => FeverDreams.piece.url(job?.uuid)) => {
const src = getImageURL(job, size);

const href = hrefFn(job);

const title = job?.text_prompt || "";

const div_style = `
background-color: black;
height:100%;
min-height:0;
max-height:100%;
`;
const anchor_style = `display:contents;`;
const img_style = `
display:block;
margin:auto;
object-fit:contain;
height:100%;
max-width:100%;
`;

const view = htl.html`
<div style=${div_style}>
<a style=${anchor_style} href=${href}>
<img style=${img_style} src=${src} title="${title}"/>
`;

view.value = job;

return view;
}
Insert cell
// AspectRatios = ({
// portrait: { width: 768, height: 1280 },
// landscape: { width: 1280, height: 768 },
// square: { width: 1024, height: 1024 },
// panorama: { width: 2048, height: 512 },
// "tiny-square": { width: 512, height: 512 },
// skyscraper: { width: 512, height: 2048 }
// })
Insert cell
FeverDreams.jpg.url(job_uuid)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
PP.iframefromURIwithProxy(getImageURL(job))
Insert cell
getImageURL(job)
Insert cell
Insert cell
Insert cell
viewJob(job)
Insert cell
Insert cell
viewIconFn("😊")()
Insert cell
Users.joshie
Insert cell
Insert cell
userfeed = FeverDreams.userfeed(Users.joshie)
Insert cell
FeverDreams.myhistory.url(Users.joshie)
Insert cell
Insert cell
linkCopy(job?.uuid)
Insert cell
Insert cell
Insert cell
mutate_view
Insert cell
<button onclick=${(viewof mutate_view).reset}>reset
Insert cell
<button onclick=${(viewof mutate_view).highlight}>focus
Insert cell
viewTextPrompt(job)
Insert cell
viewParent(job)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more