Merge branch 'main' into manual-scripts
# Conflicts: # index.html
This commit is contained in:
commit
759b396f6d
4 changed files with 9 additions and 163 deletions
|
@ -436,9 +436,6 @@
|
|||
<!-- Base Libs -->
|
||||
<script src="js/lib/util.js?v=e82dd04" type="text/javascript"></script>
|
||||
<script src="js/lib/events.js?v=2ab7933" type="text/javascript"></script>
|
||||
<script
|
||||
src="js/lib/workspaces.js?v=75777c5"
|
||||
type="text/javascript"></script>
|
||||
<script src="js/lib/db.js?v=434363b" type="text/javascript"></script>
|
||||
<script src="js/lib/input.js?v=769485c" type="text/javascript"></script>
|
||||
<script src="js/lib/layers.js?v=1a452a1" type="text/javascript"></script>
|
||||
|
@ -457,7 +454,7 @@
|
|||
|
||||
<!-- Content -->
|
||||
<script src="js/prompt.js?v=7a1c68c" type="text/javascript"></script>
|
||||
<script src="js/index.js?v=b1402ee" type="text/javascript"></script>
|
||||
<script src="js/index.js?v=3642e58" type="text/javascript"></script>
|
||||
|
||||
<script
|
||||
src="js/ui/floating/history.js?v=4f29db4"
|
||||
|
|
25
js/index.js
25
js/index.js
|
@ -145,19 +145,6 @@ var url = "/sdapi/v1/";
|
|||
const basePixelCount = 64; //64 px - ALWAYS 64 PX
|
||||
var focused = true;
|
||||
|
||||
function getSDData() {
|
||||
const w = workspaces.current.settings;
|
||||
w.ste;
|
||||
return {
|
||||
prompt: w.prompt,
|
||||
negative_prompt: w.neg_prompt,
|
||||
seed: w.seed,
|
||||
|
||||
cfg_scale: w.cfg_scale,
|
||||
steps: w.steps,
|
||||
};
|
||||
}
|
||||
|
||||
function startup() {
|
||||
testHostConfiguration();
|
||||
loadSettings();
|
||||
|
@ -587,16 +574,16 @@ const makeSlider = (
|
|||
textStep = null,
|
||||
valuecb = null
|
||||
) => {
|
||||
const local = lsKey && workspaces.current.settings[lsKey];
|
||||
const local = lsKey && localStorage.getItem(`openoutpaint/${lsKey}`);
|
||||
const def = parseFloat(local === null ? defaultValue : local);
|
||||
let cb = (v) => {
|
||||
stableDiffusionData[lsKey] = v;
|
||||
if (lsKey) workspaces.current.settings[lsKey] = v;
|
||||
if (lsKey) localStorage.setItem(`openoutpaint/${lsKey}`, v);
|
||||
};
|
||||
if (valuecb) {
|
||||
cb = (v) => {
|
||||
valuecb(v);
|
||||
if (lsKey) workspaces.current.settings[lsKey] = v;
|
||||
localStorage.setItem(`openoutpaint/${lsKey}`, v);
|
||||
};
|
||||
}
|
||||
return createSlider(label, el, {
|
||||
|
@ -1284,6 +1271,10 @@ function loadSettings() {
|
|||
localStorage.getItem("openoutpaint/mask_blur") == null
|
||||
? 0
|
||||
: localStorage.getItem("openoutpaint/mask_blur");
|
||||
var _seed =
|
||||
localStorage.getItem("openoutpaint/seed") == null
|
||||
? -1
|
||||
: localStorage.getItem("openoutpaint/seed");
|
||||
let _enable_hr =
|
||||
localStorage.getItem("openoutpaint/enable_hr") === null
|
||||
? false
|
||||
|
@ -1314,7 +1305,7 @@ function loadSettings() {
|
|||
|
||||
// set the values into the UI
|
||||
document.getElementById("maskBlur").value = Number(_mask_blur);
|
||||
document.getElementById("seed").value = workspaces.current.settings.seed;
|
||||
document.getElementById("seed").value = Number(_seed);
|
||||
document.getElementById("cbxHRFix").checked = Boolean(_enable_hr);
|
||||
document.getElementById("cbxRestoreFaces").checked = Boolean(_restore_faces);
|
||||
document.getElementById("cbxSyncCursorSize").checked =
|
||||
|
|
|
@ -1,142 +0,0 @@
|
|||
/**
|
||||
* Workspaces (or sessions) are settings and canvas state storage structures that can be changed at will, saved, and restored.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Represents a workspace
|
||||
*
|
||||
* @template [S] Settings type
|
||||
*/
|
||||
class Workspace {
|
||||
/**
|
||||
* The name of the workspace
|
||||
* @type {string}
|
||||
*/
|
||||
name = "Workspace Name";
|
||||
|
||||
/**
|
||||
* Workspace default settings.
|
||||
*
|
||||
* @type {S}
|
||||
*/
|
||||
defaults = {};
|
||||
|
||||
/**
|
||||
* Storage for workspace settings.
|
||||
*
|
||||
* @type {S}
|
||||
*/
|
||||
settings = new Proxy(
|
||||
{},
|
||||
{
|
||||
get: (t, name) => {
|
||||
if (t[name] === undefined)
|
||||
t[name] =
|
||||
JSON.parse(localStorage.getItem(`openoutpaint/${name}`)) ??
|
||||
this.defaults[name];
|
||||
return t[name];
|
||||
},
|
||||
set: (t, name, value) => {
|
||||
localStorage.setItem(`openoutpaint/${name}`, JSON.stringify(value));
|
||||
t[name] = value;
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* Storage for other data
|
||||
*
|
||||
* @type {Record<string, any>}
|
||||
*/
|
||||
data = new Proxy({}, {});
|
||||
|
||||
/**
|
||||
* Saves the data to the workspace
|
||||
*
|
||||
* @param {string} key The key of the data to be saved (eg. history or layers)
|
||||
* @param {any} data The data to be saved on this key. MUST BE SERIALIZABLE.
|
||||
*/
|
||||
save(key, data) {
|
||||
this.data[key] = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets saved data from the workspace
|
||||
*
|
||||
* @param {string} key The key of the data to be saved (eg. history or layers)
|
||||
* @param {any} data The data to be saved on this key. MUST BE SERIALIZABLE.
|
||||
*/
|
||||
load(key) {
|
||||
return this.data[key];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name The name of the workspace
|
||||
* @param {Object} options
|
||||
* @param {S} options.defaults Default workspace settings
|
||||
*/
|
||||
constructor(name, options = {}) {
|
||||
defaultOpt(options, {
|
||||
defaults: {
|
||||
/** Default Prompt - REQ */
|
||||
prompt: "ocean floor scientific expedition, underwater wildlife",
|
||||
/** Default Negative Prompt - REQ */
|
||||
neg_prompt:
|
||||
"people, person, humans, human, divers, diver, glitch, error, text, watermark, bad quality, blurry",
|
||||
/** Default Stable Diffusion Seed - REQ */
|
||||
seed: -1,
|
||||
/** Default CFG Scale - REQ */
|
||||
cfg_scale: 7.0,
|
||||
/** Default steps - REQ */
|
||||
steps: 30,
|
||||
/** Default Resolution */
|
||||
resolution: 512,
|
||||
},
|
||||
});
|
||||
|
||||
this.name = name;
|
||||
this.defaults = options.defaults;
|
||||
}
|
||||
}
|
||||
|
||||
const workspaces = {
|
||||
/**
|
||||
* Loaded workspace
|
||||
*
|
||||
* @type {Workspace<workspaceDefaults>}
|
||||
*/
|
||||
_workspace: null,
|
||||
|
||||
get current() {
|
||||
return this._workspace;
|
||||
},
|
||||
|
||||
/**
|
||||
* On Workspace Changed
|
||||
*
|
||||
* @type {Observer<{workspace: Workspace<workspaceDefaults>}>}
|
||||
*/
|
||||
onchange: new Observer(),
|
||||
|
||||
/**
|
||||
* Loads a workspace
|
||||
*
|
||||
* @param {Workspace<workspaceDefaults>} workspace Workspace to load
|
||||
*/
|
||||
loadWorkspace(workspace) {
|
||||
console.info(`[workspaces] Loading workspace: ${workspace.name}`);
|
||||
|
||||
// Set current workspace
|
||||
this._workspace = workspace;
|
||||
|
||||
// Notify observers that the workspace has changed
|
||||
this.onchange.emit({workspace});
|
||||
},
|
||||
};
|
||||
|
||||
// Creates a new workspace instance
|
||||
workspaces.loadWorkspace(
|
||||
new Workspace("Default", {
|
||||
workspaceDefaults,
|
||||
})
|
||||
);
|
Loading…
Reference in a new issue