From c03257fe3a324338cca78860e581c7f48f829d02 Mon Sep 17 00:00:00 2001 From: JensLincke Date: Wed, 7 Feb 2024 18:49:32 +0100 Subject: [PATCH 1/3] new basic openInWindow SQUASHED: SQUASHED-AUTO-COMMIT-src-client-lively.js-AUTO-COMMIT-src-client-vivide-scripts-scripts-vivide-script-namexxx.json, --- src/client/lively.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/client/lively.js b/src/client/lively.js index ba9a0d30c..6245b61e2 100644 --- a/src/client/lively.js +++ b/src/client/lively.js @@ -1796,6 +1796,15 @@ export default class Lively { return w } + static async openInWindow(comp) { + let w = await () + 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")); From a2b0c940c05ec28f1b9c048ca6069b72734756f0 Mon Sep 17 00:00:00 2001 From: JensLincke Date: Mon, 12 Feb 2024 13:45:43 +0100 Subject: [PATCH 2/3] fixed workspace ar disable SQUASHED: AUTO-COMMIT-src-plugin-babel.js,AUTO-COMMIT-test-bindings-test.js, --- src/plugin-babel.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/plugin-babel.js b/src/plugin-babel.js index 36d25d1a4..f0f4496dd 100644 --- a/src/plugin-babel.js +++ b/src/plugin-babel.js @@ -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) From 30de476349561ededd9b39a0b9ad5dbd5b844a3f Mon Sep 17 00:00:00 2001 From: JensLincke Date: Tue, 13 Feb 2024 11:11:35 +0100 Subject: [PATCH 3/3] directly load modules in component tags via load_module attribute SQUASHED: AUTO-COMMIT-src-client-morphic-component-loader.js,AUTO-COMMIT-src-client-persistence.js, --- src/client/morphic/component-loader.js | 51 +++++++++++++++++--------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/src/client/morphic/component-loader.js b/src/client/morphic/component-loader.js index a3da642c0..471512344 100644 --- a/src/client/morphic/component-loader.js +++ b/src/client/morphic/component-loader.js @@ -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 @@ -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) => {