Skip to content

Commit

Permalink
fix refactor regression
Browse files Browse the repository at this point in the history
  • Loading branch information
blurymind committed Aug 10, 2024
1 parent 94f8895 commit 6b0c6bd
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/public/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ export var Plugins = function(app) {
});
});

dbStorage.getDbValue('volatilePlugins').then(volatilePlugins => {
getVloatilePlugins().then(volatilePlugins => {
volatilePlugins = volatilePlugins || {};
// load builtin plugins
const builtInVolatilePlugins = {};
const builtInPlugins = {}; // so we can revert the volatile one to the built in one as fallback
Expand Down Expand Up @@ -351,9 +352,9 @@ export var Plugins = function(app) {
const loadPluginsFromCacheOrGist = () => {
getGistPluginFiles().then(plugins =>
plugins.forEach(gistFile => {
console.log({ gistFile });
if (!(gistFile.filename in volatilePlugins)) {
loadPluginWithDependencies(content, gistFile.filename);
console.log({ gistFile, volatilePlugins });
if (volatilePlugins && !(gistFile.filename in volatilePlugins)) {
loadPluginWithDependencies(gistFile.content, gistFile.filename);

volatileGistPlugins[gistFile.filename] = gistFile;
setVloatilePlugin(
Expand Down
51 changes: 51 additions & 0 deletions src/public/plugins/plugin-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export var PluginEditor = function({
this.onSetEditingFile = () => {
const fileName = document.getElementById('edited-plugin-file').value;
getVloatilePlugins().then(volatilePlugins => {
console.log({volatilePlugins})
this.volatilePlugins = volatilePlugins;
let fileContents = this.volatilePlugins[fileName].content;
this.editingFile = fileName;
Expand Down Expand Up @@ -212,3 +213,53 @@ export var PluginEditor = function({
});
});
};

const example =({resources}) => ({// straight to output
head: [],//goes in head - as src/style = detected by file type
body: `<div></div>`,// can have css tags,etc
resources, // passed from editor to output
script: ({resources, onLoad, modules}) => { // then to script
const {kaboom} = modules;// stuff imported from head
const myFunc=()=> {
//err
}

const myImage = resources["imagekey"] //this returns the base64 - keep flat to save size
onLoad()
}
})
// example output
const exampleOutput = `
<head>
..modules and css here
<body>
<div>
</body>
<script>
// stringified from script
const run = ({resources, onLoad, modules}) => {
const {kaboom} = modules;// stuff imported from head
const myFunc=()=> {
//err
}
const myImage = resources["imagekey"] //this returns the base64 - keep flat to save size
onLoad()
}
// <=== added by renderer
import kaboom from "blahblah"
run({
modules: {
kaboom
},
resources: {
imagekey: "base64Strjhkdfhkdfgh"
},
onLoad: document.body.onload
}) // <=== added by renderer
<script>
`

0 comments on commit 6b0c6bd

Please sign in to comment.