promptOptions.context
Send in a JS object or a list as a context the prompt has access to. Perhaps options to overload the window (falls through to the window if a name isn't found within the context), or completely contained (only things within the context can be accessed: avoids any name clashing issues).
image({ plain_object })
Allow a normal JS object to be used. Currently the plugin relies on list properties here and there, which means it breaks when a simple JS object is sent even if it has the same exact used properties.
As JS is used to create these images in a lot of generators, this would cut out the need for the engine to get involved and generate the promptOptions object at all. And the creator doesn't have to worry about how the lists work to be able to use the image generator.
promptOptions.select()
When a button is clicked to "select" a particular generated image's settings... if there's a .select()
function available, call it with everything to do with that generation: prompt object, etc. Maybe if there is no such function, don't show that button.
This could be used to set up the generator's textarea and other options in whatever way the creator sees fit. Or even to use this function for any other thing.
We can sort of half do this by giving each generation an id, and adding our own button next to it. And I think we can get some sort of info about a generation from its iframe? Maybe? Not sure.
But anyway, this would be a simple way of reaching in and out of the generation iframes.
Show prompt while loading: and just an idea to show the text prompt/negative prompt while the image is loading. It's useful as a creator/user to see what the prompt is that's actually generated--and nip it in the bud if we can see it's malformed or bugged in some way. Just an idea.
@[email protected] Started making my own image-gen page now. And got context working using this code:
See what I mean? This way, the prompt is evaluated against just whatever code the user has set up for it to use, and has no access to the page's root or code at all. It's safer because of that, is what I was talking about. (Apart from
[window.root]
or something I guess?)Also, they just have full perchance capabilities, and can use any names they wish to.
Ah I see what you mean. Sounds like you basically want an "isolated" version of
createPerchanceTree
? The way I do something similar on perchance.org/ai-character-chat (where bots can havecustomCode
which could be malicious for shared characters, and so needs to be sandboxed) is to create an iframe. Open that page and ctrl+f forevaluatePerchanceTextInSandbox
in the list editor. I think you should actually be able to just copy-paste that function and it'll work - I definitely won't make backwards-incompatible changes to/ai-character-chat-sandboxed-executor
, since forks of/ai-character-chat
are relying on it. But you may need to make some changes depending on the specific thing(s) you're trying to achieve.But if I understand your request correctly, the "real" solution to this will probably require waiting for the
ShadowRealm
proposal to become available in all major browsers, since otherwise it has to be an async call, which is annoying.ShadowRealm
is finally making solid progress lately, so I'm hopeful that we'll get it in Chrome/Edge within a year or so. Firefox and Safari may take longer though. I think it may be possible to use something like this: https://github.com/endojs/endo/blob/master/packages/ses/README.md but I'm not sure - seems fragile to new browser features and stuff, so would probably need to be kept up to date to maintain the security boundary (maybe not - I'm not entirely sure how it works).Yes, exactly. I've actually been able to do this with just createPerchanceTree. They can probably mess with the window--that's up to them. But at least they cannot access the main generator's properties and such. And this also means you can give people full perchance coding abilities, without the requirement of only all-caps property names and polluting the window namespace and such.
I've integrated it into my advanced text to image plugin :)
Oh, nice! I might steal some of these ideas eventually ^^'