Skip to content

Commit fab02a3

Browse files
committed
#6876 manager.ClassHierarchy: added into all workers (except service), updated Neo.setupClass() to feed a tmp map until the manager is ready.
1 parent c975123 commit fab02a3

9 files changed

Lines changed: 40 additions & 31 deletions

File tree

src/Neo.mjs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,11 @@ Neo = globalThis.Neo = Object.assign({
466466
proto = cls.prototype || cls,
467467
ns = Neo.ns(proto.constructor.config.className, false),
468468
protos = [],
469-
cfg, config, ctor, ntype;
469+
cfg, config, ctor, hierarchyInfo, ntype;
470470

471471
/*
472472
* If the namespace already exists, directly return it.
473-
* This can happen when using different versions of neo.mjs
473+
* This can happen when using different versions of Neo.mjs
474474
* => Especially singletons (IdGenerator) must stay unique.
475475
*
476476
* This can also happen when using different environments of neo.mjs in parallel.
@@ -574,6 +574,19 @@ Neo = globalThis.Neo = Object.assign({
574574

575575
proto = cls.prototype || cls;
576576

577+
hierarchyInfo = {
578+
className : proto.className,
579+
ntype : Object.hasOwn(proto, 'ntype') ? proto.ntype : null,
580+
parentClassName: proto.__proto__?.className || null
581+
};
582+
583+
if (Neo.manager?.ClassHierarchy) {
584+
Neo.manager.ClassHierarchy.add(hierarchyInfo)
585+
} else {
586+
Neo.classHierarchyMap ??= {};
587+
Neo.classHierarchyMap[proto.className] = hierarchyInfo
588+
}
589+
577590
ntypeChain.forEach(ntype => {
578591
proto[`is${Neo.capitalize(Neo.camel(ntype))}`] = true
579592
});

src/core/Base.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ class Base {
203203
if (hasManager) {
204204
Neo.manager.Instance.register(me);
205205
} else {
206-
Neo.idMap = Neo.idMap || {};
206+
Neo.idMap ??= {};
207207
Neo.idMap[me.id] = me
208208
}
209209
}

src/manager/ClassHierarchy.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import Manager from './Base.mjs';
1+
import BaseManager from './Base.mjs';
22

33
/**
44
* @class Neo.manager.ClassHierarchy
55
* @extends Neo.manager.Base
66
* @singleton
77
*/
8-
class Instance extends Manager {
8+
class ClassHierarchy extends BaseManager {
99
static config = {
1010
/**
1111
* @member {String} className='Neo.manager.ClassHierarchy'
@@ -29,17 +29,17 @@ class Instance extends Manager {
2929
*/
3030
construct(config) {
3131
super.construct(config);
32-
this.consumeNeoClassHierarchyMap()
32+
this.consumeTempMap()
3333
}
3434

3535
/**
3636
* Register all classes that got applied to the Neo namespace before this instance got created
3737
* @protected
3838
*/
39-
consumeNeoClassHierarchyMap() {
39+
consumeTempMap() {
4040
this.add(Object.values(Neo.classHierarchyMap));
4141
delete Neo.classHierarchyMap
4242
}
4343
}
4444

45-
export default Neo.setupClass(Instance);
45+
export default Neo.setupClass(ClassHierarchy);

src/worker/App.mjs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import Neo from '../Neo.mjs';
22
import Base from './Base.mjs';
3-
import * as core from '../core/_export.mjs';
43
import Application from '../controller/Application.mjs';
5-
import Instance from '../manager/Instance.mjs';
4+
import InstanceManager from '../manager/Instance.mjs';
65
import DomEventManager from '../manager/DomEvent.mjs';
76
import HashHistory from '../util/HashHistory.mjs';
87

src/worker/Base.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import Base from '../core/Base.mjs';
2-
import Observable from '../core/Observable.mjs';
3-
import Message from './Message.mjs';
4-
import RemoteMethodAccess from './mixin/RemoteMethodAccess.mjs';
1+
import Base from '../core/Base.mjs';
2+
import * as core from '../core/_export.mjs';
3+
import Observable from '../core/Observable.mjs';
4+
import ClassHierarchyManager from '../manager/ClassHierarchy.mjs';
5+
import Message from './Message.mjs';
6+
import RemoteMethodAccess from './mixin/RemoteMethodAccess.mjs';
57

68
/**
79
* The abstract base class for e.g. the App, Data & VDom worker

src/worker/Canvas.mjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import Neo from '../Neo.mjs';
2-
import Base from './Base.mjs';
3-
import * as core from '../core/_export.mjs';
1+
import Neo from '../Neo.mjs';
2+
import Base from './Base.mjs';
43

54
/**
65
* The Canvas worker is responsible for dynamically manipulating offscreen canvas.

src/worker/Data.mjs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import Neo from '../Neo.mjs';
2-
import Base from './Base.mjs';
3-
import Compare from '../core/Compare.mjs';
4-
import Fetch from '../Fetch.mjs';
5-
import Util from '../core/Util.mjs';
6-
import Xhr from '../Xhr.mjs';
1+
import Neo from '../Neo.mjs';
2+
import Base from './Base.mjs';
3+
import Fetch from '../Fetch.mjs';
4+
import Xhr from '../Xhr.mjs';
75

86
/**
9-
* The Data worker is responsible to handle all of the communication to the backend (e.g. Ajax-calls).
7+
* The Data worker is responsible to handle all the communication to the backend (e.g. Ajax-calls).
108
* See the tutorials for further infos.
119
* @class Neo.worker.Data
1210
* @extends Neo.worker.Base

src/worker/Task.mjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import Neo from '../Neo.mjs';
2-
import Base from './Base.mjs';
3-
import * as core from '../core/_export.mjs';
1+
import Neo from '../Neo.mjs';
2+
import Base from './Base.mjs';
43

54
/**
65
* The Task worker can get filled with custom remote methods as needed.

src/worker/VDom.mjs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import Neo from '../Neo.mjs';
2-
import Base from './Base.mjs';
3-
import * as core from '../core/_export.mjs';
4-
import Helper from '../vdom/Helper.mjs';
1+
import Neo from '../Neo.mjs';
2+
import Base from './Base.mjs';
3+
import Helper from '../vdom/Helper.mjs';
54

65
/**
76
* The Vdom worker converts vdom templates into vnodes, as well as creating delta-updates.

0 commit comments

Comments
 (0)