arrmatura 5.0.1 → 5.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -15
- package/commons/components/viewport.xml +1 -1
- package/commons/pipes/showCounts.ts +1 -1
- package/core/Arrmatura.ts +8 -3
- package/core/CNode.ts +1 -1
- package/core/Component.ts +40 -45
- package/core/cnodes/composition.ts +2 -2
- package/core/cnodes/conditionals.ts +2 -2
- package/core/cnodes/elementary.ts +2 -3
- package/core/cnodes/iterations.ts +3 -5
- package/core/cnodes/routing.ts +1 -1
- package/core/index.ts +0 -1
- package/core/utils.ts +1 -1
- package/core-web/WebPlatform.ts +25 -0
- package/core-web/attributes.ts +190 -0
- package/core-web/elements.ts +64 -0
- package/core-web/index.ts +16 -0
- package/core-web/reflow.ts +28 -0
- package/core-web/type.ts +18 -0
- package/docs/index.js +119 -55
- package/lib/arraySortBy.ts +3 -3
- package/lib/geospatial.js +22 -0
- package/lib/obj.ts +2 -0
- package/package.json +5 -6
- package/core/Platform.ts +0 -3
package/README.md
CHANGED
|
@@ -1,36 +1,40 @@
|
|
|
1
1
|
# Arrmatura
|
|
2
2
|
|
|
3
|
-
`Arrmatura` is a
|
|
3
|
+
`Arrmatura` is a mimimalistic component framework that designed to be:
|
|
4
4
|
|
|
5
5
|
- declarative and codeless
|
|
6
|
+
- reactive and functional
|
|
6
7
|
- non-obtrusive, platform-independent
|
|
7
|
-
- reactive and functional oriented
|
|
8
8
|
- easy to learn and get started.
|
|
9
9
|
|
|
10
10
|
# Get Started
|
|
11
11
|
|
|
12
12
|
npm i arrmatura
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
import { launchWeb } from 'arrmatura';
|
|
16
|
-
|
|
17
|
-
const components = `
|
|
14
|
+
./templates.xml
|
|
18
15
|
|
|
16
|
+
```xml
|
|
19
17
|
<component id="Application">
|
|
20
18
|
<Main name="Joe"/>
|
|
21
19
|
</component>
|
|
22
20
|
|
|
23
21
|
<component id="Main">
|
|
24
|
-
<Button title="{:greeting}, {name|upper}">
|
|
22
|
+
<Button title="{:greeting}, {name|upper}!">
|
|
25
23
|
</component>
|
|
26
|
-
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
index.ts
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
import { arrmatura } from 'arrmatura';
|
|
30
|
+
import templates from './templates.xml';
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
types: [
|
|
32
|
+
arrmatura('<Application />', {
|
|
33
|
+
types: [templates],
|
|
30
34
|
resources: {
|
|
31
|
-
greeting: 'Hello
|
|
35
|
+
greeting: 'Hello',
|
|
32
36
|
},
|
|
33
|
-
|
|
37
|
+
functions: {
|
|
34
38
|
upper: (x) => x.toUpperCase(),
|
|
35
39
|
},
|
|
36
40
|
});
|
|
@@ -44,6 +48,7 @@ launchWeb('<Application />', {
|
|
|
44
48
|
|
|
45
49
|
# Samples
|
|
46
50
|
|
|
47
|
-
- [TodoMVC](https://alitskevich.github.io/arrmatura/todo.html)
|
|
48
|
-
- [Tasks](https://alitskevich.github.io/arrmatura/task.html)
|
|
49
|
-
- [
|
|
51
|
+
- [TodoMVC](https://alitskevich.github.io/arrmatura/todo.html) ([source](https://github.com/alitskevich/arrmatura/blob/master/docs/todo.html))
|
|
52
|
+
- [Tasks list](https://alitskevich.github.io/arrmatura/task.html) ([source](https://github.com/alitskevich/arrmatura/tree/master/app-task))
|
|
53
|
+
- [Game Solver](https://dlitskevich.github.io/solver/) ([source](https://github.com/dlitskevich/solver/tree/master/app))
|
|
54
|
+
- [Input Templates](https://alitskevich.github.io/templain/) ([source](https://github.com/alitskevich/templain/tree/master/app))
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<component id="Sidebar">
|
|
20
20
|
<div class="off-canvas off-canvas-sidebar-show">
|
|
21
21
|
<a class="off-canvas-toggle btn btn-primary btn-action show-lg" href="#sidebar">
|
|
22
|
-
<Icon type="
|
|
22
|
+
<Icon type="menu" />
|
|
23
23
|
</a>
|
|
24
24
|
<div id="sidebar" class="off-canvas-sidebar">
|
|
25
25
|
<Aside caption="{caption}">
|
package/core/Arrmatura.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { CNode } from './CNode';
|
|
|
2
2
|
import { compileNodes } from './compileNode';
|
|
3
3
|
import { Component } from './Component';
|
|
4
4
|
import { xmlParse } from '../lib/xml';
|
|
5
|
-
import { Platform } from './Platform';
|
|
6
5
|
import { registerTypes } from './register';
|
|
7
6
|
|
|
8
7
|
export class Arrmatura extends Component<CArrmaturaNode> implements IArrmatura {
|
|
@@ -16,10 +15,14 @@ export class Arrmatura extends Component<CArrmaturaNode> implements IArrmatura {
|
|
|
16
15
|
return this;
|
|
17
16
|
}
|
|
18
17
|
|
|
18
|
+
get platform(): IPlatform {
|
|
19
|
+
return this.node.platform;
|
|
20
|
+
}
|
|
21
|
+
|
|
19
22
|
requestReflow() {
|
|
20
23
|
if (this.reflowId) return;
|
|
21
24
|
this.reflowId = setTimeout(() => {
|
|
22
|
-
|
|
25
|
+
this.platform.reflow(this);
|
|
23
26
|
this.reflowId = undefined;
|
|
24
27
|
}, 10);
|
|
25
28
|
}
|
|
@@ -53,14 +56,16 @@ export class Arrmatura extends Component<CArrmaturaNode> implements IArrmatura {
|
|
|
53
56
|
export class CArrmaturaNode extends CNode<Arrmatura> {
|
|
54
57
|
functions?: Hash;
|
|
55
58
|
resources: Hash<any> | undefined;
|
|
59
|
+
platform: IPlatform;
|
|
56
60
|
|
|
57
|
-
constructor(template: string, { types, functions, resources }: ArrmaturaOptions) {
|
|
61
|
+
constructor(template: string, { types, functions, resources }: ArrmaturaOptions, platform: IPlatform) {
|
|
58
62
|
super();
|
|
59
63
|
|
|
60
64
|
registerTypes(types);
|
|
61
65
|
|
|
62
66
|
this.functions = functions;
|
|
63
67
|
this.resources = resources;
|
|
68
|
+
this.platform = platform;
|
|
64
69
|
|
|
65
70
|
this.content = compileNodes(xmlParse(template));
|
|
66
71
|
}
|
package/core/CNode.ts
CHANGED
|
@@ -58,7 +58,7 @@ export abstract class CNode<T extends Component = Component> implements INode<T>
|
|
|
58
58
|
addEmitter(expr: Expression, k: PropertyKey) {
|
|
59
59
|
const { key, pipec } = compilePipeExpression(expr);
|
|
60
60
|
this.initializers.push((c) => ({
|
|
61
|
-
payload: { [k]: (data: unknown) => c
|
|
61
|
+
payload: { [k]: (data: unknown) => c.$scope?.emit(key, pipec(c, data) as Delta) },
|
|
62
62
|
}));
|
|
63
63
|
}
|
|
64
64
|
|
package/core/Component.ts
CHANGED
|
@@ -7,18 +7,14 @@ import { createListeners } from 'createListeners';
|
|
|
7
7
|
* Runtime Component class.
|
|
8
8
|
*/
|
|
9
9
|
export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
10
|
-
impl: IComponentImplementation;
|
|
11
|
-
element?: any;
|
|
10
|
+
readonly $impl: IComponentImplementation;
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
children?: Map<Uid, IComponent>;
|
|
12
|
+
$children?: Map<Uid, IComponent>;
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
private _parent?: IComponent;
|
|
14
|
+
readonly $scope: IScope;
|
|
15
|
+
readonly #parent?: IComponent;
|
|
19
16
|
#isInited: boolean = false;
|
|
20
17
|
#isDone: boolean = false;
|
|
21
|
-
// #notifying: boolean = false;
|
|
22
18
|
#listeners?: Listeners<void>;
|
|
23
19
|
#defered?: Array<ComponentProcedure> = [];
|
|
24
20
|
#weak?: Map<any, any>;
|
|
@@ -26,17 +22,17 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
26
22
|
#propFnMap?: Hash<Procedure>;
|
|
27
23
|
|
|
28
24
|
constructor(readonly _node: INode, _parent?: IComponent, scope?: IScope) {
|
|
29
|
-
this
|
|
30
|
-
this
|
|
31
|
-
this
|
|
25
|
+
this.$scope = scope || this;
|
|
26
|
+
this.#parent = _parent;
|
|
27
|
+
this.$impl = this.createImplementation(this.getInitialState());
|
|
32
28
|
|
|
33
29
|
if (this.refId) {
|
|
34
|
-
this
|
|
30
|
+
this.$scope.addComponentReference(this.refId, this);
|
|
35
31
|
}
|
|
36
32
|
}
|
|
37
33
|
|
|
38
34
|
get parent(): IComponent {
|
|
39
|
-
return this
|
|
35
|
+
return this.#parent || this;
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
get node(): T {
|
|
@@ -79,9 +75,8 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
79
75
|
const pv = v as Promise<any>;
|
|
80
76
|
if (v && pv.then && pv.catch) {
|
|
81
77
|
this.upAsync(pv, k);
|
|
82
|
-
} else if (k && typeof v !== 'undefined' && v !== this
|
|
78
|
+
} else if (k && typeof v !== 'undefined' && v !== this.$impl[k]) {
|
|
83
79
|
changes.set(k, v);
|
|
84
|
-
this.state[k] = v;
|
|
85
80
|
}
|
|
86
81
|
});
|
|
87
82
|
|
|
@@ -107,15 +102,15 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
107
102
|
}
|
|
108
103
|
|
|
109
104
|
stateChanged(changes: Map<string, unknown>) {
|
|
110
|
-
if (this
|
|
111
|
-
this
|
|
105
|
+
if (this.$impl.stateChanged) {
|
|
106
|
+
this.$impl.stateChanged(changes);
|
|
112
107
|
} else {
|
|
113
108
|
changes.forEach((v, k) => {
|
|
114
|
-
const setter = this
|
|
109
|
+
const setter = this.$impl[methodName(k, 'set')];
|
|
115
110
|
if (typeof setter === 'function') {
|
|
116
|
-
setter.call(this
|
|
111
|
+
setter.call(this.$impl, v);
|
|
117
112
|
} else {
|
|
118
|
-
this
|
|
113
|
+
this.$impl[k] = v;
|
|
119
114
|
}
|
|
120
115
|
});
|
|
121
116
|
}
|
|
@@ -128,7 +123,7 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
128
123
|
return fn();
|
|
129
124
|
}
|
|
130
125
|
|
|
131
|
-
const impl = this
|
|
126
|
+
const impl = this.$impl;
|
|
132
127
|
const instant = impl[propId];
|
|
133
128
|
if (instant && typeof instant === 'function') {
|
|
134
129
|
const bound = instant.bind(impl);
|
|
@@ -148,7 +143,7 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
148
143
|
}
|
|
149
144
|
|
|
150
145
|
getFromScope(propId: string): unknown {
|
|
151
|
-
return this
|
|
146
|
+
return this.$scope.get(propId);
|
|
152
147
|
}
|
|
153
148
|
|
|
154
149
|
// --- Left Arrow.
|
|
@@ -175,12 +170,12 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
175
170
|
|
|
176
171
|
connect(key: string, applicator: (x: unknown) => unknown): undefined | ComponentSubsription {
|
|
177
172
|
const [refId, propId = '*'] = key.split('.');
|
|
178
|
-
const ref = this
|
|
173
|
+
const ref = this.$scope.getByRef(refId) as Component;
|
|
179
174
|
if (!ref) {
|
|
180
175
|
this.logError('Connect: No such ref: ' + refId);
|
|
181
176
|
return;
|
|
182
177
|
}
|
|
183
|
-
return ref.subscribe(this, (c: Component) => applyValue(propId === '*' ? c
|
|
178
|
+
return ref.subscribe(this, (c: Component) => applyValue(propId === '*' ? c.$impl : c.get(propId), applicator));
|
|
184
179
|
}
|
|
185
180
|
|
|
186
181
|
// --- Right Arrow.
|
|
@@ -188,7 +183,7 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
188
183
|
emit(key: string, data: Delta): void {
|
|
189
184
|
if (!key || !key.includes('.')) {
|
|
190
185
|
this.up(key ? { [key]: data } : data);
|
|
191
|
-
this.log('update:' + key, data, this
|
|
186
|
+
this.log('update:' + key, data, this.$impl);
|
|
192
187
|
return;
|
|
193
188
|
}
|
|
194
189
|
|
|
@@ -200,7 +195,7 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
200
195
|
}
|
|
201
196
|
|
|
202
197
|
const propId = methodName(target, 'on');
|
|
203
|
-
const impl = ref
|
|
198
|
+
const impl = ref.$impl;
|
|
204
199
|
|
|
205
200
|
const method = impl[propId];
|
|
206
201
|
if (!method || !(typeof method === 'function')) {
|
|
@@ -250,8 +245,8 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
250
245
|
args.reduce((r, e) => Object.assign(r, e), initials),
|
|
251
246
|
true
|
|
252
247
|
);
|
|
253
|
-
if (this
|
|
254
|
-
const d = this
|
|
248
|
+
if (this.$impl.init) {
|
|
249
|
+
const d = this.$impl.init(this);
|
|
255
250
|
if (d) {
|
|
256
251
|
this.up(d);
|
|
257
252
|
}
|
|
@@ -259,8 +254,8 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
259
254
|
});
|
|
260
255
|
} else {
|
|
261
256
|
this.up(initials, true);
|
|
262
|
-
if (this
|
|
263
|
-
const d = this
|
|
257
|
+
if (this.$impl.init) {
|
|
258
|
+
const d = this.$impl.init(this);
|
|
264
259
|
if (d) {
|
|
265
260
|
this.up(d);
|
|
266
261
|
}
|
|
@@ -275,19 +270,19 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
275
270
|
}
|
|
276
271
|
this.#isDone = true;
|
|
277
272
|
|
|
278
|
-
this
|
|
273
|
+
this.$impl.done?.(this);
|
|
279
274
|
|
|
280
|
-
const parent = this
|
|
281
|
-
this
|
|
275
|
+
const parent = this.#parent;
|
|
276
|
+
this.#parent = undefined;
|
|
282
277
|
|
|
283
|
-
this
|
|
278
|
+
this.$children?.forEach((c) => c.done());
|
|
284
279
|
|
|
285
|
-
parent
|
|
280
|
+
parent?.$children?.delete(this.uid);
|
|
286
281
|
|
|
287
282
|
this.#defered?.forEach((f) => f(this));
|
|
288
283
|
this.#defered = undefined;
|
|
289
284
|
|
|
290
|
-
this
|
|
285
|
+
this.$impl.$ = null;
|
|
291
286
|
}
|
|
292
287
|
|
|
293
288
|
// -- Contents --------------------------------------------------------
|
|
@@ -297,11 +292,11 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
297
292
|
}
|
|
298
293
|
|
|
299
294
|
get recontentScope(): IScope {
|
|
300
|
-
return this
|
|
295
|
+
return this.$scope;
|
|
301
296
|
}
|
|
302
297
|
|
|
303
298
|
setupChildren(children: ComponentChildren) {
|
|
304
|
-
this
|
|
299
|
+
this.$children = children;
|
|
305
300
|
|
|
306
301
|
children.forEach((e) => e.settleAsChild());
|
|
307
302
|
}
|
|
@@ -320,7 +315,7 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
320
315
|
|
|
321
316
|
this.arrmatura.requestReflow();
|
|
322
317
|
|
|
323
|
-
this
|
|
318
|
+
this.$children?.forEach((e, uid) => {
|
|
324
319
|
if (!nodes?.get(uid)) {
|
|
325
320
|
e.done();
|
|
326
321
|
}
|
|
@@ -329,7 +324,7 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
329
324
|
const children = new Map<Uid, IComponent>();
|
|
330
325
|
|
|
331
326
|
nodes?.forEach((node, uid) => {
|
|
332
|
-
const e = this
|
|
327
|
+
const e = this.$children?.get(uid) || node.createComponent(this, scope);
|
|
333
328
|
children.set(e.uid, e);
|
|
334
329
|
});
|
|
335
330
|
|
|
@@ -354,7 +349,7 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
354
349
|
if (local) {
|
|
355
350
|
return local as Component;
|
|
356
351
|
}
|
|
357
|
-
const ref = this === this
|
|
352
|
+
const ref = this === this.$scope ? null : this.$scope.getByRef(refId);
|
|
358
353
|
return ref as Component;
|
|
359
354
|
}
|
|
360
355
|
|
|
@@ -372,7 +367,7 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
372
367
|
try {
|
|
373
368
|
const [id, ...args] = key.split(':');
|
|
374
369
|
const fn = this.pipe(id);
|
|
375
|
-
return fn.apply(this
|
|
370
|
+
return fn.apply(this, [
|
|
376
371
|
value,
|
|
377
372
|
...args.map((a) => (a[0] === '@' ? this.getFromScope(a.slice(1)) : scalarParse(a))),
|
|
378
373
|
]);
|
|
@@ -415,14 +410,14 @@ export class Component<T extends INode = INode> implements IComponent, IScope {
|
|
|
415
410
|
}
|
|
416
411
|
|
|
417
412
|
stringify(tab = '') {
|
|
418
|
-
const { uid, displayName: tag = uid,
|
|
413
|
+
const { uid, displayName: tag = uid, $impl: impl, $children: children } = this;
|
|
419
414
|
if (tag === '#text') {
|
|
420
|
-
return `${tab}` +
|
|
415
|
+
return `${tab}` + impl.text;
|
|
421
416
|
}
|
|
422
417
|
const ssubs: string = children?.size
|
|
423
418
|
? [...children.values()].map((c) => (c as Component).stringify(` ${tab}`)).join('\n')
|
|
424
419
|
: '';
|
|
425
|
-
return `${tab}<${tag}${stringifyState(
|
|
420
|
+
return `${tab}<${tag}${stringifyState(impl)}` + (!ssubs ? '/>' : `>\n${ssubs}\n${tab}</${tag}>`);
|
|
426
421
|
}
|
|
427
422
|
|
|
428
423
|
toString() {
|
|
@@ -24,7 +24,7 @@ export class SlotComponent extends Component {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
get compositeScope(): CompositeComponent {
|
|
27
|
-
return this
|
|
27
|
+
return this.$scope as CompositeComponent;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
get content(): ComponentContent {
|
|
@@ -32,7 +32,7 @@ export class SlotComponent extends Component {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
get recontentScope(): IScope {
|
|
35
|
-
return this.compositeScope
|
|
35
|
+
return this.compositeScope.$scope;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -6,7 +6,7 @@ import { Component } from '../Component';
|
|
|
6
6
|
|
|
7
7
|
class IfComponent extends Component<CIfNode> {
|
|
8
8
|
get content() {
|
|
9
|
-
return this.
|
|
9
|
+
return this.$impl.condition ? this.node.then : this.node.else;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
@@ -43,7 +43,7 @@ export class CIfNode extends CNode<IfComponent> {
|
|
|
43
43
|
} else if (expr.slice(0, 5) === 'slot(') {
|
|
44
44
|
const slotId = expr.slice(5, -1);
|
|
45
45
|
// DO NOT place inside iterations.
|
|
46
|
-
this.addPropertyResolver((c: IComponent) => (c
|
|
46
|
+
this.addPropertyResolver((c: IComponent) => (c.$scope as CompositeComponent).slotContent?.(slotId), 'condition');
|
|
47
47
|
} else {
|
|
48
48
|
this.addPropertyResolver(compileExpression(expr[0] === '{' ? expr : `{${expr}}`), 'condition');
|
|
49
49
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Platform } from '../Platform';
|
|
2
1
|
import { CNode } from '../CNode';
|
|
3
2
|
import { compileNodes } from '../compileNode';
|
|
4
3
|
import { Component } from '../Component';
|
|
@@ -9,13 +8,13 @@ export class ElementComponent extends Component<CElementNode> {
|
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
createImplementation(initials: Hash): IComponentImplementation {
|
|
12
|
-
return
|
|
11
|
+
return this.arrmatura.platform.createElement(this.node.tag, initials, this);
|
|
13
12
|
}
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
export class TextElementComponent extends Component<CTextElementNode> {
|
|
17
16
|
createImplementation(initials: Hash) {
|
|
18
|
-
return
|
|
17
|
+
return this.arrmatura.platform.createTextElement(initials, this);
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
|
|
@@ -10,9 +10,7 @@ class ForComponent extends Component<CForNode> {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
get content() {
|
|
13
|
-
const
|
|
14
|
-
state: { each },
|
|
15
|
-
} = this;
|
|
13
|
+
const each: any = this.$impl.each;
|
|
16
14
|
const itemNode = this.node.itemNode;
|
|
17
15
|
const nodes: ComponentContent = new Map();
|
|
18
16
|
this.pkHash = {};
|
|
@@ -62,12 +60,12 @@ class ItemComponent extends Component<CItemNode> {
|
|
|
62
60
|
}
|
|
63
61
|
|
|
64
62
|
emit(key: string, data: Delta): void {
|
|
65
|
-
return this
|
|
63
|
+
return this.$scope.emit(key, data);
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
get(propId: string) {
|
|
69
67
|
const iName: string = this.node.itemName;
|
|
70
|
-
const value = propId.startsWith(iName + '.') || propId === iName ? super.get(propId) : this
|
|
68
|
+
const value = propId.startsWith(iName + '.') || propId === iName ? super.get(propId) : this.$scope.get(propId);
|
|
71
69
|
// this.log(propId, value);
|
|
72
70
|
return value;
|
|
73
71
|
}
|
package/core/cnodes/routing.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Component } from '../Component';
|
|
|
4
4
|
|
|
5
5
|
export class DynamicTagComponent extends Component<CDynamicTagNode> {
|
|
6
6
|
get content(): ComponentContent | undefined {
|
|
7
|
-
const
|
|
7
|
+
const tag = this.$impl.tag;
|
|
8
8
|
const uid = this.node.uid + ':' + tag;
|
|
9
9
|
return new Map([[uid, Object.assign(compileNode(Object.assign(this.node.xml, { tag })), { uid })]]);
|
|
10
10
|
}
|
package/core/index.ts
CHANGED
package/core/utils.ts
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DomElement, DomTextElement } from './elements';
|
|
2
|
+
import { reflow } from './reflow';
|
|
3
|
+
|
|
4
|
+
export class WebPlatform implements IPlatform {
|
|
5
|
+
rootElement: HTMLElement;
|
|
6
|
+
|
|
7
|
+
constructor(root: HTMLElement | string = 'root') {
|
|
8
|
+
if (typeof root === 'string') {
|
|
9
|
+
root = document.getElementById(root) || window.document.body;
|
|
10
|
+
}
|
|
11
|
+
this.rootElement = root || window.document.body;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
createTextElement(initials: Hash, _: IComponent): IComponentImplementation {
|
|
15
|
+
return new DomTextElement(initials);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
createElement(tag: string, initials: Hash, owner: IComponent): IComponentImplementation {
|
|
19
|
+
return new DomElement(tag, initials, owner);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
reflow(root: IComponent) {
|
|
23
|
+
reflow(root, this.rootElement);
|
|
24
|
+
}
|
|
25
|
+
}
|