Skip to content

Commit

Permalink
Merge branch 'gh-pages' of https://github.com/LivelyKernel/lively4-core
Browse files Browse the repository at this point in the history
… into gh-pages
  • Loading branch information
onsetsu committed Feb 15, 2024
2 parents 07937f4 + 30de476 commit d7258b1
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 29 deletions.
9 changes: 9 additions & 0 deletions src/client/lively.js
Original file line number Diff line number Diff line change
Expand Up @@ -1796,6 +1796,15 @@ export default class Lively {
return w
}

static async openInWindow(comp) {
let w = await (<lively-window></lively-window>)
w.appendChild(comp)
let pos = lively.findPositionForWindow(document.body);
document.body.appendChild(w)
lively.setPosition(w, pos)
w.focus()
}

static findPositionForWindow(worldContext) {
// this gets complicated: find a free spot starting top left going down right
var windows = Array.from(worldContext.querySelectorAll(":scope > lively-window"));
Expand Down
51 changes: 33 additions & 18 deletions src/client/morphic/component-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,30 @@ export default class ComponentLoader {

window.customElements.define(componentName, aClass);
}

static findUnresolvedDeep(root) {
const selector = ":not(:defined)";
var shadow = root.shadowRoot;
if (!shadow) {
return [];
}

var result = Array.from(shadow.querySelectorAll(selector));

Array.from(shadow.children).forEach((child) => {
result = result.concat(this.findUnresolvedDeep(child));
});

return result;
}

// this function loads all unregistered elements, starts looking in lookupRoot,
// if lookupRoot is not set, it looks in the whole document.body,
// if deep is set, it also looks into shadow roots
static loadUnresolved(lookupRoot, deep, debuggingHint, withChildren=false, withyourself=false) {
lookupRoot = lookupRoot || document.body;

var selector = ":not(:defined)";
const selector = ":not(:defined)";
var unresolved = []

// check if lookupRoot is unresolved
Expand All @@ -198,35 +214,34 @@ export default class ComponentLoader {

// look into the shadow?
if (deep) {
var deepUnresolved = findUnresolvedDeep(lookupRoot);
var deepUnresolved = this.findUnresolvedDeep(lookupRoot);
unresolved = unresolved.concat(deepUnresolved);
}

function findUnresolvedDeep(root) {
var shadow = root.shadowRoot;
if (!shadow) {
return [];
}

var result = Array.from(shadow.querySelectorAll(selector));

Array.from(shadow.children).forEach((child) => {
result = result.concat(findUnresolvedDeep(child));
});

return result;
}

// helper set to filter for unique tags
var unique = new Set();


var __debugOpenPromisedComponents = new Set()

let directlyLoaded = new Set()
for(let element of unresolved) {
if (!element.getAttribute) continue

let mod = element.getAttribute("load-module")
if (mod) {
debugger
directlyLoaded.add(element.nodeName.toLowerCase())
import(lively4url + "/" + mod)
}

}

var promises = unresolved.filter((el) => {
// filter for unique tag names
if (!el.nodeName || el.nodeName.toLowerCase() == "undefined") return false;
var name = el.nodeName.toLowerCase();
if (directlyLoaded.has(name)) return false

return !unique.has(name) && unique.add(name);
})
.map((el) => {
Expand Down
22 changes: 11 additions & 11 deletions src/plugin-babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,22 +489,22 @@ async function workspacePlugins(options = {}) {

result.push(await importDefaultOf('babel-plugin-var-recorder'))

if (!localStorage.getItem("DisableAExpWorkspace")) {
result.push(await importDefaultOf('babel-plugin-ILA'), {
if (localStorage.getItem("DisableAExpWorkspace") !== "true") {
result.push([await importDefaultOf('babel-plugin-ILA'), {
executedIn: 'file'
})
result.push(await importDefaultOf('babel-plugin-databindings'), {
}])
result.push([await importDefaultOf('babel-plugin-databindings'), {
executedIn: 'file'
})
result.push(await importDefaultOf('babel-plugin-active-expression-rewriting'), {
}])
result.push([await importDefaultOf('babel-plugin-active-expression-rewriting'), {
executedIn: 'workspace'
})
result.push(await importDefaultOf('babel-plugin-databindings-post-process'), {
}])
result.push([await importDefaultOf('babel-plugin-databindings-post-process'), {
executedIn: 'file'
})
result.push(await importDefaultOf('babel-plugin-active-expression-proxies'), {
}])
result.push([await importDefaultOf('babel-plugin-active-expression-proxies'), {
executedIn: 'workspace'
})
}])
}
if (!options.fortesting) {
result.push(babel7.babelPluginProposalDynamicImport)
Expand Down

0 comments on commit d7258b1

Please sign in to comment.