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 Dec 9, 2023
2 parents 8e639f1 + 7890e5a commit 75414fc
Show file tree
Hide file tree
Showing 70 changed files with 462 additions and 224 deletions.
3 changes: 0 additions & 3 deletions demos/domain-code/index.md

This file was deleted.

6 changes: 6 additions & 0 deletions demos/javascript/sb.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
let a = 3

function hello() {


}
10 changes: 10 additions & 0 deletions doc/domain-code/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Domain Code Project

- [domain-code-explorer](edit://src/components/tools/domain-code-explorer.js) ([open](open://domain-code-explorer))


## TODO

- Editor Shards
- Replace booleon with checkboxes query

Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export default class BabylonianProgrammingEditor extends Morph {
}


detachedCallback() {
disconnectedCallback() {
BabylonianManager.unregisterEditor(this)
}

Expand Down
3 changes: 2 additions & 1 deletion src/client/graphics.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
"disable deepeval"

// import { num, string, grid } from "lively.lang";
// import { cssLengthToPixels } from "./convert-css-length.js";

/* copied from lively.graphics and removed dependency to lively.lang */


export class Point {

static ensure(duck) {
Expand Down
177 changes: 68 additions & 109 deletions src/client/morphic/component-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,6 @@ export function register(componentName, template, prototype) {
return ComponentLoader.register(componentName, template, prototype);
}

/* #FutureWork should interactive state change of "(module) global" state be preserved while reloading / developing modules
ComponentLoader.foo = 3
ComponentLoader.foo
#Discussion
pro) expected in Smalltalk-like developent and live-programmning experience
contra) gap between development-time and runtime (those manualy changes could make something work that without it won't...)
synthese) if modules and classes are also objects that can have run-time-specific state they should be migrated the same as objects.
*/



export default class ComponentLoader {

Expand Down Expand Up @@ -131,36 +117,6 @@ export default class ComponentLoader {
this._livelyLoadingDep
}

static async onAttachedCallback(object, componentName) {

if (this._livelyLoading) {
await this._livelyLoading // should we provicde this robustness here? Or should these be more pure metal...
}

_log("onAttachedCallback " + componentName)

if (object.attachedCallback &&
ComponentLoader.proxies[componentName].attachedCallback != object.attachedCallback) {
object.attachedCallback.call(object);
} else if (ComponentLoader.prototypes[componentName].attachedCallback) {
ComponentLoader.prototypes[componentName].attachedCallback.call(object);
}
}

static async onDetachedCallback(object, componentName) {

if (this._livelyLoading) {
await this._livelyLoading
}

if (object.detachedCallback
&& ComponentLoader.proxies[componentName].detachedCallback != object.detachedCallback) {
object.detachedCallback.call(object);
} else if (ComponentLoader.prototypes[componentName].detachedCallback) {
ComponentLoader.prototypes[componentName].detachedCallback.call(object);
}
}

static applyTemplate(element, componentName) {
var template = this.templates[componentName]
return this.applyTemplateElement(element, template)
Expand All @@ -179,7 +135,7 @@ export default class ComponentLoader {
})
}
}

// this function registers a custom element,
// it is called from the bootstap code in the component templates
static async register(componentName, template, aClass, componentUrl) {
Expand All @@ -195,70 +151,7 @@ export default class ComponentLoader {
await lively.fillTemplateStyles(template, "source: " + componentName, componentUrl)
}

if (!this.proxies[componentName]) {
proxy = class extends HTMLElement {
static get name() {
return componentName
}

get _lively4version() {
return 2
}

constructor() {
_log("[component loader] Proxy Constructor " + componentName)

super(); // always call super() first in the constructor.

ComponentLoader.applyTemplate(this, componentName)
ComponentLoader.onCreatedCallback(this, componentName)
}

connectedCallback( args) {
_log('connectedCallback ' + componentName )


// return super.connectedCallback(...args)
// super seams to bind early?
ComponentLoader.onAttachedCallback(this, componentName)
if (this.constructor.__proto__.prototype.connectedCallback) {
return this.constructor.__proto__.prototype.connectedCallback.apply(this, args)
}
}
disconnectedCallback(...args) {
_log('diconnectedCallback ' + componentName )

// return super.disconnectedCallback(...args)
ComponentLoader.onDetachedCallback(this, componentName)
if (this.constructor.__proto__.prototype.disconnectedCallback) {
return this.constructor.__proto__.prototype.disconnectedCallback.apply(this, args)
}
}

adoptedCallback(...args) {
_log('adoptedCallback ' + componentName )
// return super.adoptedCallback(...args)
if (this.constructor.__proto__.prototype.adoptedCallback) {
return this.constructor.__proto__.prototype.adoptedCallback.apply(this, args)
}
}
}
// set the prototype of the proxy the first time
// #Idea: use "extemds aClass" ?
// proxy.__proto__ = aClass
// proxy.prototype.__proto__ = aClass.prototype

_log("[component loader] define component: " + componentName)
window.customElements.define(componentName, proxy); // #WebComponent #Magic
this.proxies[componentName] = proxy
} else {
proxy = this.proxies[componentName]

}

// change the prototype of the proxy
proxy.__proto__ = aClass
proxy.prototype.__proto__ = aClass.prototype
window.customElements.define(componentName, aClass);
}

// this function loads all unregistered elements, starts looking in lookupRoot,
Expand Down Expand Up @@ -670,3 +563,69 @@ export default class ComponentLoader {

ComponentLoader.load()
ComponentLoader.resetTemplatePathCache()


if (!window.lively4OriginalCustomElementsDefine) {
window.lively4OriginalCustomElementsDefine = window.customElements.define
}
// poor man's #COP
window.customElements.define = function define(componentName, aClass) {
var proxy = ComponentLoader.proxies[componentName]
if (!proxy) {
proxy = class extends HTMLElement {

constructor(...args) {
_log("[component loader] Proxy Constructor " + componentName)

super(...args); // always call super() first in the constructor.

ComponentLoader.applyTemplate(this, componentName)
ComponentLoader.onCreatedCallback(this, componentName)
}

static get name() {
return componentName
}

static get observedAttributes() {
return this.__proto__.observedAttributes
}
// We need to declare these callbacks, because they are early bound...
connectedCallback( args) {
_log('connectedCallback ' + componentName )
if (this.constructor.__proto__.prototype.connectedCallback) {
return this.constructor.__proto__.prototype.connectedCallback.apply(this, args)
}
}
disconnectedCallback(...args) {
_log('disconnectedCallback ' + componentName )
if (this.constructor.__proto__.prototype.disconnectedCallback) {
return this.constructor.__proto__.prototype.disconnectedCallback.apply(this, args)
}
}
attributeChangedCallback(...args) {
_log('attributeChangedCallback ' + componentName )
if (this.constructor.__proto__.prototype.attributeChangedCallback) {
return this.constructor.__proto__.prototype.attributeChangedCallback.apply(this, args)
}
}
adoptedCallback(...args) {
_log('adoptedCallback ' + componentName )
if (this.constructor.__proto__.prototype.adoptedCallback) {
return this.constructor.__proto__.prototype.adoptedCallback.apply(this, args)
}
}
}
ComponentLoader.proxies[componentName] = proxy
proxy.__proto__ = aClass
proxy.prototype.__proto__ = aClass.prototype
window.lively4OriginalCustomElementsDefine.apply(window.customElements, [componentName, proxy])
} else {
// do nothing
proxy.__proto__ = aClass
proxy.prototype.__proto__ = aClass.prototype
}
}



1 change: 1 addition & 0 deletions src/client/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default class Preferences {
CommandModeAsDefault: {default: false, short: "command mode as default in editor"},
CircumventCodeMirrorModes: {default: false, short: "circumvent code mirror modes"},
BabylonianProgramming: {default: false, short: "use babylonian programming editor"},
SandblocksText: {default: false, short: "use sandblocks text editor"},
TabbedWindows: {default: false, short: "use experimental window tabs"},
SWEDebugging: {default: false, short: "bug showcase in swe lecture"},
AEXPGraphExperimental: {default: false, short: "AExpr graph experimental"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ MD*/export default class AexprGraph extends Morph {
AExprRegistry.removeEventListener(this);
}

detachedCallback() {
disconnectedCallback() {
AExprRegistry.removeEventListener(this);
}

Expand Down
2 changes: 1 addition & 1 deletion src/client/reactive/components/basic/aexpr-monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export default class AexprTable extends Morph {

}

detachedCallback() {
disconnectedCallback() {
this.detached = true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/client/reactive/components/basic/aexpr-timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ export default class EventDrops extends Morph {
this.dataFromSource = other.dataFromSource;
}

detachedCallback() {
disconnectedCallback() {
this.detached = true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/client/reactive/components/basic/rx-drawboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export default class LivelyDrawboard extends Morph {
this.setAttribute("tabindex", 0);
}

attachedCallback() {
connectedCallback() {
if (this.parentElement.isWindow) {
this.fixedControls = true;
this.get("#controls").hidden = false ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { router } from 'src/client/reactive/components/rewritten/conduit/rpCompo

export default class Link extends ReactiveMorph {

attachedCallback() {
connectedCallback() {
if (this.isDummy()) return;
this._innerHTML = this.innerHTML;
this.addAExpr(aexpr(() => this.lastChild).onChange(lastChild => {
Expand All @@ -18,7 +18,7 @@ export default class Link extends ReactiveMorph {
.then(htmlDoc => this.differentialUpdate(htmlDoc))
}
}));
super.attachedCallback();
super.connectedCallback();
}

onClick(evt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ export default class ReactiveMorph extends Morph {
}

/* component lifecycle */
attachedCallback() {
connectedCallback() {
if(this.isDummy()) return Promise.resolve();
return this.hookRender();
}

detachedCallback() {
disconnectedCallback() {
this.disposeAExpr();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ class Router extends ReactiveMorph {
return this._config || (this._config = {});
}

attachedCallback() {
super.attachedCallback().then(() => {
connectedCallback() {
super.connectedCallback().then(() => {
if (this.isDummy()) return;
this.attachChildPropsListener(this.children);
_router = this;
});
}

detachedCallback() {
super.detachedCallback();
disconnectedCallback() {
super.disconnectedCallback();
if (_router === this)
_router = undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import userStore from 'src/client/reactive/components/rewritten/conduit/src/stor

export default class App extends ReactiveMorph {

attachedCallback() {
super.attachedCallback().then(() => {
connectedCallback() {
super.connectedCallback().then(() => {
if (this.isDummy()) return;
if (!commonStore.token)
commonStore.appLoaded = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { router } from 'src/client/reactive/components/rewritten/conduit/rpCompo

export default class Article extends ReactiveMorph {

attachedCallback() {
super.attachedCallback().then(() => {
connectedCallback() {
super.connectedCallback().then(() => {
if (this.isDummy()) return;
const slug = this.getSlugFromRoutingProps();
articleStore.loadArticle(slug, { acceptCached: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import ListErrors from 'src/client/reactive/components/rewritten/conduit/src/com

export default class Editor extends ReactiveMorph {

attachedCallback() {
super.attachedCallback().then(() => {
connectedCallback() {
super.connectedCallback().then(() => {
if (this.isDummy()) return;
this.tagInput = '';
const slug = this.getSlugFromRoutingProps();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import Tags from 'src/client/reactive/components/rewritten/conduit/src/component

export default class Home extends ReactiveMorph {

attachedCallback() {
super.attachedCallback().then(() => {
connectedCallback() {
super.connectedCallback().then(() => {
if (this.isDummy()) return;
commonStore.loadTags();
});
Expand Down
Loading

0 comments on commit 75414fc

Please sign in to comment.