@adaas/are-html 0.0.4 → 0.0.6
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/dist/browser/index.d.mts +22 -5
- package/dist/browser/index.mjs +66 -17
- package/dist/browser/index.mjs.map +1 -1
- package/dist/node/engine/AreHTML.compiler.js +10 -0
- package/dist/node/engine/AreHTML.compiler.js.map +1 -1
- package/dist/node/engine/AreHTML.compiler.mjs +10 -0
- package/dist/node/engine/AreHTML.compiler.mjs.map +1 -1
- package/dist/node/engine/AreHTML.constants.d.mts +10 -1
- package/dist/node/engine/AreHTML.constants.d.ts +10 -1
- package/dist/node/engine/AreHTML.constants.js +21 -0
- package/dist/node/engine/AreHTML.constants.js.map +1 -1
- package/dist/node/engine/AreHTML.constants.mjs +20 -1
- package/dist/node/engine/AreHTML.constants.mjs.map +1 -1
- package/dist/node/engine/AreHTML.engine.d.mts +2 -2
- package/dist/node/engine/AreHTML.engine.d.ts +2 -2
- package/dist/node/engine/AreHTML.engine.js +15 -2
- package/dist/node/engine/AreHTML.engine.js.map +1 -1
- package/dist/node/engine/AreHTML.engine.mjs +16 -3
- package/dist/node/engine/AreHTML.engine.mjs.map +1 -1
- package/dist/node/engine/AreHTML.interpreter.js +1 -0
- package/dist/node/engine/AreHTML.interpreter.js.map +1 -1
- package/dist/node/engine/AreHTML.interpreter.mjs +1 -0
- package/dist/node/engine/AreHTML.interpreter.mjs.map +1 -1
- package/dist/node/engine/AreHTML.lifecycle.d.mts +11 -3
- package/dist/node/engine/AreHTML.lifecycle.d.ts +11 -3
- package/dist/node/engine/AreHTML.lifecycle.js +20 -11
- package/dist/node/engine/AreHTML.lifecycle.js.map +1 -1
- package/dist/node/engine/AreHTML.lifecycle.mjs +21 -12
- package/dist/node/engine/AreHTML.lifecycle.mjs.map +1 -1
- package/dist/node/index.d.mts +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/node/lib/AreRoot/AreRoot.component.js +2 -3
- package/dist/node/lib/AreRoot/AreRoot.component.js.map +1 -1
- package/dist/node/lib/AreRoot/AreRoot.component.mjs +2 -3
- package/dist/node/lib/AreRoot/AreRoot.component.mjs.map +1 -1
- package/examples/dashboard/dist/index.html +1 -1
- package/examples/dashboard/dist/{mpioi5ab-8c3oa9.js → mpmt0gys-1r9rcu.js} +80 -22
- package/examples/dashboard/src/components/DashboardLogo.component.ts +9 -0
- package/package.json +1 -1
- package/src/engine/AreHTML.compiler.ts +19 -1
- package/src/engine/AreHTML.constants.ts +16 -0
- package/src/engine/AreHTML.engine.ts +17 -1
- package/src/engine/AreHTML.interpreter.ts +3 -0
- package/src/engine/AreHTML.lifecycle.ts +44 -13
- package/src/lib/AreRoot/AreRoot.component.ts +5 -6
|
@@ -10846,7 +10846,7 @@ AreEngine = __decorateClass3([
|
|
|
10846
10846
|
})
|
|
10847
10847
|
], AreEngine);
|
|
10848
10848
|
var _a144;
|
|
10849
|
-
var
|
|
10849
|
+
var AreWatcher = (_a144 = class extends v {
|
|
10850
10850
|
/**
|
|
10851
10851
|
* Initialize the watcher. This method is called once when the watcher is first created. Use this to set up any necessary state or start observing changes.
|
|
10852
10852
|
*/
|
|
@@ -10859,16 +10859,16 @@ var AreRouteWatcher = (_a144 = class extends v {
|
|
|
10859
10859
|
}
|
|
10860
10860
|
destroy() {
|
|
10861
10861
|
}
|
|
10862
|
-
}, __name(_a144, "
|
|
10862
|
+
}, __name(_a144, "AreWatcher"), _a144);
|
|
10863
10863
|
__decorateClass3([
|
|
10864
10864
|
Ce.Stop()
|
|
10865
|
-
],
|
|
10866
|
-
|
|
10865
|
+
], AreWatcher.prototype, "destroy", 1);
|
|
10866
|
+
AreWatcher = __decorateClass3([
|
|
10867
10867
|
A3.Define({
|
|
10868
10868
|
namespace: "A-ARE",
|
|
10869
10869
|
description: "Abstract base component that observes external changes and emits A_Signals to drive reactive updates within the ARE pipeline. Subclasses override init() to set up initial state and watch() to begin observing \u2014 for example, polling a data source, listening to DOM events, or subscribing to a store \u2014 and call the appropriate signal methods to notify the engine when a re-render is needed."
|
|
10870
10870
|
})
|
|
10871
|
-
],
|
|
10871
|
+
], AreWatcher);
|
|
10872
10872
|
var _a145;
|
|
10873
10873
|
var _a146;
|
|
10874
10874
|
var AreContainer = (_a146 = class extends A_Service {
|
|
@@ -10907,7 +10907,7 @@ __decorateClass3([
|
|
|
10907
10907
|
__decorateParam3(1, ke(AreContext)),
|
|
10908
10908
|
__decorateParam3(2, F.All()),
|
|
10909
10909
|
__decorateParam3(2, F.Flat()),
|
|
10910
|
-
__decorateParam3(2, ke(
|
|
10910
|
+
__decorateParam3(2, ke(AreWatcher)),
|
|
10911
10911
|
__decorateParam3(3, ke(A_Logger))
|
|
10912
10912
|
], AreContainer.prototype, _a145, 1);
|
|
10913
10913
|
var _a147;
|
|
@@ -11032,6 +11032,9 @@ var _DashboardLogo = class _DashboardLogo extends Are {
|
|
|
11032
11032
|
brandName: "ARE Platform"
|
|
11033
11033
|
});
|
|
11034
11034
|
}
|
|
11035
|
+
async onMount(node, store) {
|
|
11036
|
+
console.log("!!!!!!!!!!!!!!!!!!!!!!!!!DashboardLogo mounted");
|
|
11037
|
+
}
|
|
11035
11038
|
};
|
|
11036
11039
|
__name(_DashboardLogo, "DashboardLogo");
|
|
11037
11040
|
__decorateClass([
|
|
@@ -11042,6 +11045,11 @@ __decorateClass([
|
|
|
11042
11045
|
Are.Data,
|
|
11043
11046
|
__decorateParam(0, ke(AreStore))
|
|
11044
11047
|
], _DashboardLogo.prototype, "data", 1);
|
|
11048
|
+
__decorateClass([
|
|
11049
|
+
Are.onAfterMount,
|
|
11050
|
+
__decorateParam(0, ke(G)),
|
|
11051
|
+
__decorateParam(1, ke(AreStore))
|
|
11052
|
+
], _DashboardLogo.prototype, "onMount", 1);
|
|
11045
11053
|
var DashboardLogo = _DashboardLogo;
|
|
11046
11054
|
|
|
11047
11055
|
// examples/dashboard/src/components/DashboardNav.component.ts
|
|
@@ -12318,6 +12326,26 @@ AreText = __decorateClass([
|
|
|
12318
12326
|
], AreText);
|
|
12319
12327
|
|
|
12320
12328
|
// src/engine/AreHTML.constants.ts
|
|
12329
|
+
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
12330
|
+
"area",
|
|
12331
|
+
"base",
|
|
12332
|
+
"br",
|
|
12333
|
+
"col",
|
|
12334
|
+
"embed",
|
|
12335
|
+
"hr",
|
|
12336
|
+
"img",
|
|
12337
|
+
"input",
|
|
12338
|
+
"link",
|
|
12339
|
+
"meta",
|
|
12340
|
+
"param",
|
|
12341
|
+
"source",
|
|
12342
|
+
"track",
|
|
12343
|
+
"wbr"
|
|
12344
|
+
]);
|
|
12345
|
+
function isVoidElement(tagName) {
|
|
12346
|
+
return VOID_ELEMENTS.has(tagName.toLowerCase());
|
|
12347
|
+
}
|
|
12348
|
+
__name(isVoidElement, "isVoidElement");
|
|
12321
12349
|
var BOOLEAN_ATTRIBUTES = /* @__PURE__ */ new Set([
|
|
12322
12350
|
"allowfullscreen",
|
|
12323
12351
|
"async",
|
|
@@ -12609,6 +12637,16 @@ var AreHTMLCompiler = class extends AreCompiler {
|
|
|
12609
12637
|
title: "Scene Host Not Found",
|
|
12610
12638
|
description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`
|
|
12611
12639
|
});
|
|
12640
|
+
const content = attribute.content;
|
|
12641
|
+
if (content.includes("{{")) {
|
|
12642
|
+
const transformed = '"' + content.replace(/\{\{([^}]+)\}\}/g, '"+($1)+"') + '"';
|
|
12643
|
+
scene.plan(new AddAttributeInstruction(scene.host, {
|
|
12644
|
+
name: attribute.name,
|
|
12645
|
+
content: transformed,
|
|
12646
|
+
evaluate: true
|
|
12647
|
+
}));
|
|
12648
|
+
return;
|
|
12649
|
+
}
|
|
12612
12650
|
scene.plan(new AddAttributeInstruction(scene.host, {
|
|
12613
12651
|
name: attribute.name,
|
|
12614
12652
|
content: attribute.content
|
|
@@ -12919,6 +12957,7 @@ var AreHTMLInterpreter = class extends AreInterpreter {
|
|
|
12919
12957
|
event.set("args", effectiveArgs);
|
|
12920
12958
|
event.set("element", element);
|
|
12921
12959
|
event.set("instruction", mutation);
|
|
12960
|
+
if (liveEvent) event.set("native", liveEvent);
|
|
12922
12961
|
mutation.owner.emit(event);
|
|
12923
12962
|
}, "handlerFn");
|
|
12924
12963
|
handlerScope[`$${handler}`] = handlerFn;
|
|
@@ -13241,10 +13280,7 @@ AreHTMLTokenizer = __decorateClass([
|
|
|
13241
13280
|
|
|
13242
13281
|
// src/engine/AreHTML.lifecycle.ts
|
|
13243
13282
|
var AreHTMLLifecycle = class extends AreLifecycle {
|
|
13244
|
-
initComponent(node, scope, context, logger, ...args) {
|
|
13245
|
-
super.init(node, scope, context, logger, ...args);
|
|
13246
|
-
}
|
|
13247
|
-
initRoot(node, scope, context, signalsContext, logger, ...args) {
|
|
13283
|
+
initComponent(node, scope, context, signalsContext, logger, ...args) {
|
|
13248
13284
|
signalsContext?.subscribe(node);
|
|
13249
13285
|
super.init(node, scope, context, logger, ...args);
|
|
13250
13286
|
}
|
|
@@ -13256,6 +13292,14 @@ var AreHTMLLifecycle = class extends AreLifecycle {
|
|
|
13256
13292
|
const scene = new AreScene(node.aseid);
|
|
13257
13293
|
scope.register(scene);
|
|
13258
13294
|
}
|
|
13295
|
+
mount(node, scene, logger, ...args) {
|
|
13296
|
+
logger?.debug(`[Mount] Component Trigger for <${node.aseid.entity}> with aseid :{${node.aseid.toString()}}`);
|
|
13297
|
+
node.interpret();
|
|
13298
|
+
for (let i4 = 0; i4 < node.children.length; i4++) {
|
|
13299
|
+
const child = node.children[i4];
|
|
13300
|
+
child.mount();
|
|
13301
|
+
}
|
|
13302
|
+
}
|
|
13259
13303
|
updateDirectiveAttribute(directive, scope, feature, logger, ...args) {
|
|
13260
13304
|
if (directive.component) {
|
|
13261
13305
|
feature.chain(directive.component, AreDirectiveFeatures.Update, directive.owner.scope);
|
|
@@ -13267,19 +13311,13 @@ var AreHTMLLifecycle = class extends AreLifecycle {
|
|
|
13267
13311
|
__name(AreHTMLLifecycle, "AreHTMLLifecycle");
|
|
13268
13312
|
__decorateClass([
|
|
13269
13313
|
AreLifecycle.Init(AreComponentNode),
|
|
13270
|
-
__decorateParam(0, ke(G)),
|
|
13271
|
-
__decorateParam(1, ke(D)),
|
|
13272
|
-
__decorateParam(2, ke(AreHTMLEngineContext)),
|
|
13273
|
-
__decorateParam(3, ke(A_Logger))
|
|
13274
|
-
], AreHTMLLifecycle.prototype, "initComponent", 1);
|
|
13275
|
-
__decorateClass([
|
|
13276
13314
|
AreLifecycle.Init(AreRootNode),
|
|
13277
13315
|
__decorateParam(0, ke(G)),
|
|
13278
13316
|
__decorateParam(1, ke(D)),
|
|
13279
13317
|
__decorateParam(2, ke(AreHTMLEngineContext)),
|
|
13280
13318
|
__decorateParam(3, ke(AreSignalsContext)),
|
|
13281
13319
|
__decorateParam(4, ke(A_Logger))
|
|
13282
|
-
], AreHTMLLifecycle.prototype, "
|
|
13320
|
+
], AreHTMLLifecycle.prototype, "initComponent", 1);
|
|
13283
13321
|
__decorateClass([
|
|
13284
13322
|
AreLifecycle.Init(AreText),
|
|
13285
13323
|
__decorateParam(0, ke(G)),
|
|
@@ -13294,6 +13332,15 @@ __decorateClass([
|
|
|
13294
13332
|
__decorateParam(2, ke(AreHTMLEngineContext)),
|
|
13295
13333
|
__decorateParam(3, ke(A_Logger))
|
|
13296
13334
|
], AreHTMLLifecycle.prototype, "initInterpolation", 1);
|
|
13335
|
+
__decorateClass([
|
|
13336
|
+
w.Extend({
|
|
13337
|
+
name: AreNodeFeatures.onMount,
|
|
13338
|
+
scope: [AreHTMLNode]
|
|
13339
|
+
}),
|
|
13340
|
+
__decorateParam(0, ke(G)),
|
|
13341
|
+
__decorateParam(1, ke(AreScene)),
|
|
13342
|
+
__decorateParam(2, ke(A_Logger))
|
|
13343
|
+
], AreHTMLLifecycle.prototype, "mount", 1);
|
|
13297
13344
|
__decorateClass([
|
|
13298
13345
|
w.Extend({
|
|
13299
13346
|
name: AreAttributeFeatures.Update,
|
|
@@ -13386,7 +13433,7 @@ var AreHTMLEngine = class extends AreEngine {
|
|
|
13386
13433
|
]
|
|
13387
13434
|
});
|
|
13388
13435
|
}
|
|
13389
|
-
async init(scope) {
|
|
13436
|
+
async init(scope, signalContext) {
|
|
13390
13437
|
this.package(scope, {
|
|
13391
13438
|
context: new AreHTMLEngineContext({}),
|
|
13392
13439
|
syntax: this.DefaultSyntax,
|
|
@@ -13396,6 +13443,10 @@ var AreHTMLEngine = class extends AreEngine {
|
|
|
13396
13443
|
lifecycle: AreHTMLLifecycle,
|
|
13397
13444
|
transformer: AreHTMLTransformer
|
|
13398
13445
|
});
|
|
13446
|
+
if (!signalContext) {
|
|
13447
|
+
signalContext = new AreSignalsContext();
|
|
13448
|
+
scope.register(signalContext);
|
|
13449
|
+
}
|
|
13399
13450
|
}
|
|
13400
13451
|
rootElementMatcher(source, from, to, build) {
|
|
13401
13452
|
const rootTag = "are-root";
|
|
@@ -13440,6 +13491,13 @@ var AreHTMLEngine = class extends AreEngine {
|
|
|
13440
13491
|
match2.payload = { entity: tagName, selfClose: true, id };
|
|
13441
13492
|
return match2;
|
|
13442
13493
|
}
|
|
13494
|
+
if (isVoidElement(tagName)) {
|
|
13495
|
+
const raw = source.slice(tagStart, openingTagEnd + 1);
|
|
13496
|
+
const content2 = source.slice(tagStart + tagNameMatch[0].length, openingTagEnd);
|
|
13497
|
+
const match2 = build(raw, content2, tagStart, ">");
|
|
13498
|
+
match2.payload = { entity: tagName, selfClose: true, id };
|
|
13499
|
+
return match2;
|
|
13500
|
+
}
|
|
13443
13501
|
const closingTag = `</${tagName}>`;
|
|
13444
13502
|
let level = 0;
|
|
13445
13503
|
let searchIndex = openingTagEnd + 1;
|
|
@@ -13498,7 +13556,8 @@ __decorateClass([
|
|
|
13498
13556
|
name: A_ServiceFeatures.onBeforeLoad,
|
|
13499
13557
|
before: /.*/
|
|
13500
13558
|
}),
|
|
13501
|
-
__decorateParam(0, ke(D))
|
|
13559
|
+
__decorateParam(0, ke(D)),
|
|
13560
|
+
__decorateParam(1, ke(AreSignalsContext))
|
|
13502
13561
|
], AreHTMLEngine.prototype, "init", 1);
|
|
13503
13562
|
AreHTMLEngine = __decorateClass([
|
|
13504
13563
|
A3.Define({
|
|
@@ -13537,8 +13596,8 @@ var AreRoot = class extends Are {
|
|
|
13537
13596
|
}
|
|
13538
13597
|
}
|
|
13539
13598
|
if (!componentName) {
|
|
13540
|
-
const
|
|
13541
|
-
componentName =
|
|
13599
|
+
const defaultMatch = root.markup?.match(/\bdefault=["']([^"']*)["']/);
|
|
13600
|
+
componentName = defaultMatch?.[1];
|
|
13542
13601
|
}
|
|
13543
13602
|
if (!componentName) {
|
|
13544
13603
|
logger.warning('AreRoot: No component found for initial render. Please ensure a route condition or "default" attribute is set.');
|
|
@@ -13547,7 +13606,6 @@ var AreRoot = class extends Are {
|
|
|
13547
13606
|
root.setContent(`<${componentName}></${componentName}>`);
|
|
13548
13607
|
}
|
|
13549
13608
|
async onSignal(root, vector, store, logger, signalsContext) {
|
|
13550
|
-
console.log("Received signal vector in AreRoot:", root, vector);
|
|
13551
13609
|
const rootId = root.id;
|
|
13552
13610
|
if (signalsContext && !signalsContext.hasRoot(rootId)) {
|
|
13553
13611
|
return;
|
|
@@ -26,4 +26,13 @@ export class DashboardLogo extends Are {
|
|
|
26
26
|
brandName: 'ARE Platform',
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@Are.onAfterMount
|
|
32
|
+
async onMount(
|
|
33
|
+
@A_Inject(A_Caller) node: AreNode,
|
|
34
|
+
@A_Inject(AreStore) store: AreStore,
|
|
35
|
+
) {
|
|
36
|
+
console.log('!!!!!!!!!!!!!!!!!!!!!!!!!DashboardLogo mounted');
|
|
37
|
+
}
|
|
29
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaas/are-html",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "A-Concept Rendering Engine (ARE) is a powerful rendering engine designed to work seamlessly with the A-Concept framework. This library provides an HTML engine implementation of ARE, enabling developers to create dynamic and interactive user interfaces for web applications using standard HTML syntax.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"a-concept",
|
|
@@ -101,8 +101,26 @@ export class AreHTMLCompiler extends AreCompiler {
|
|
|
101
101
|
title: 'Scene Host Not Found',
|
|
102
102
|
description: `No host found for the scene with id: ${scene.id}. Please ensure that the scene is properly initialized and has a host before compiling binding attributes.`
|
|
103
103
|
});
|
|
104
|
+
|
|
105
|
+
const content = attribute.content;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* If the attribute value contains {{ }} interpolations, transform them into
|
|
109
|
+
* a JS string-concatenation expression so the interpreter can evaluate them.
|
|
110
|
+
* e.g. "color:{{expr}}" → '"color:"+(expr)+""'
|
|
111
|
+
*/
|
|
112
|
+
if (content.includes('{{')) {
|
|
113
|
+
const transformed = '"' + content.replace(/\{\{([^}]+)\}\}/g, '"+($1)+"') + '"';
|
|
114
|
+
scene.plan(new AddAttributeInstruction(scene.host, {
|
|
115
|
+
name: attribute.name,
|
|
116
|
+
content: transformed,
|
|
117
|
+
evaluate: true,
|
|
118
|
+
}));
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
|
|
104
122
|
/**
|
|
105
|
-
* Default case
|
|
123
|
+
* Default case: regular static attribute rendered as-is.
|
|
106
124
|
*/
|
|
107
125
|
scene.plan(new AddAttributeInstruction(scene.host, {
|
|
108
126
|
name: attribute.name,
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Void HTML elements that cannot have children and must not have a closing tag.
|
|
3
|
+
* Per the HTML5 spec these are treated as self-closing even when written as
|
|
4
|
+
* `<input>` (without the trailing slash `/>`).
|
|
5
|
+
*
|
|
6
|
+
* Reference: https://html.spec.whatwg.org/multipage/syntax.html#void-elements
|
|
7
|
+
*/
|
|
8
|
+
export const VOID_ELEMENTS = new Set<string>([
|
|
9
|
+
'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input',
|
|
10
|
+
'link', 'meta', 'param', 'source', 'track', 'wbr',
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
export function isVoidElement(tagName: string): boolean {
|
|
14
|
+
return VOID_ELEMENTS.has(tagName.toLowerCase());
|
|
15
|
+
}
|
|
16
|
+
|
|
1
17
|
/**
|
|
2
18
|
* Boolean HTML attributes whose presence (regardless of value) implies "true",
|
|
3
19
|
* and whose absence implies "false". Setting these via `setAttribute(name, value)`
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { A_Feature, A_Inject, A_Scope } from "@adaas/a-concept";
|
|
2
2
|
import { A_Frame } from "@adaas/a-frame/core"
|
|
3
3
|
import { A_ServiceFeatures } from "@adaas/a-utils/a-service";
|
|
4
|
-
import { AreEngine, AreSyntaxTokenMatch, AreSyntax } from "@adaas/are";
|
|
4
|
+
import { AreEngine, AreSyntaxTokenMatch, AreSyntax, AreSignalsContext } from "@adaas/are";
|
|
5
5
|
import { AreHTMLInterpreter } from "@adaas/are-html/interpreter";
|
|
6
6
|
import { AreHTMLEngineContext } from "./AreHTML.context";
|
|
7
7
|
import { AreInterpolation } from "@adaas/are-html/nodes/AreInterpolation";
|
|
@@ -13,6 +13,7 @@ import { AreRootNode } from "@adaas/are-html/nodes/AreRoot";
|
|
|
13
13
|
import { AreHTMLLifecycle } from "@adaas/are-html/lifecycle";
|
|
14
14
|
import { AreHTMLTransformer } from "@adaas/are-html/transformer";
|
|
15
15
|
import { AreHTMLCompiler } from "./AreHTML.compiler";
|
|
16
|
+
import { isVoidElement } from "./AreHTML.constants";
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
|
|
@@ -80,6 +81,7 @@ export class AreHTMLEngine extends AreEngine {
|
|
|
80
81
|
})
|
|
81
82
|
async init(
|
|
82
83
|
@A_Inject(A_Scope) scope: A_Scope,
|
|
84
|
+
@A_Inject(AreSignalsContext) signalContext?: AreSignalsContext
|
|
83
85
|
) {
|
|
84
86
|
this.package(scope, {
|
|
85
87
|
context: new AreHTMLEngineContext({}),
|
|
@@ -90,6 +92,11 @@ export class AreHTMLEngine extends AreEngine {
|
|
|
90
92
|
lifecycle: AreHTMLLifecycle,
|
|
91
93
|
transformer: AreHTMLTransformer,
|
|
92
94
|
});
|
|
95
|
+
|
|
96
|
+
if(!signalContext) {
|
|
97
|
+
signalContext = new AreSignalsContext();
|
|
98
|
+
scope.register(signalContext);
|
|
99
|
+
}
|
|
93
100
|
}
|
|
94
101
|
|
|
95
102
|
|
|
@@ -152,6 +159,15 @@ export class AreHTMLEngine extends AreEngine {
|
|
|
152
159
|
return match
|
|
153
160
|
}
|
|
154
161
|
|
|
162
|
+
// HTML5 void elements: <input>, <br>, <img>, etc. — treat as self-closing
|
|
163
|
+
if (isVoidElement(tagName)) {
|
|
164
|
+
const raw = source.slice(tagStart, openingTagEnd + 1)
|
|
165
|
+
const content = source.slice(tagStart + tagNameMatch[0].length, openingTagEnd)
|
|
166
|
+
const match = build(raw, content, tagStart, '>')
|
|
167
|
+
match.payload = { entity: tagName, selfClose: true, id }
|
|
168
|
+
return match
|
|
169
|
+
}
|
|
170
|
+
|
|
155
171
|
// find matching closing tag respecting nesting
|
|
156
172
|
const closingTag = `</${tagName}>`
|
|
157
173
|
let level = 0
|
|
@@ -337,6 +337,9 @@ export class AreHTMLInterpreter extends AreInterpreter {
|
|
|
337
337
|
event.set('args', effectiveArgs);
|
|
338
338
|
event.set('element', element);
|
|
339
339
|
event.set('instruction', mutation);
|
|
340
|
+
// Expose the raw DOM event under the conventional 'native' key so that
|
|
341
|
+
// event handlers can do: event.get('native')?.target as HTMLInputElement
|
|
342
|
+
if (liveEvent) event.set('native', liveEvent as any);
|
|
340
343
|
mutation.owner.emit(event);
|
|
341
344
|
};
|
|
342
345
|
handlerScope[`$${handler}`] = handlerFn;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A_Caller, A_Feature, A_FormatterHelper, A_Inject, A_Scope } from "@adaas/a-concept";
|
|
2
|
-
import { AreLifecycle, AreScene, AreAttributeFeatures, AreSignalsContext } from "@adaas/are";
|
|
2
|
+
import { AreLifecycle, AreScene, AreAttributeFeatures, AreSignalsContext, AreNodeFeatures, AreFeatures } from "@adaas/are";
|
|
3
3
|
import { A_Logger } from "@adaas/a-utils/a-logger";
|
|
4
4
|
import { AreComponentNode } from "@adaas/are-html/nodes/AreComponent";
|
|
5
5
|
import { AreRootNode } from "@adaas/are-html/nodes/AreRoot";
|
|
@@ -19,19 +19,8 @@ import { A_Frame } from "@adaas/a-frame/core";
|
|
|
19
19
|
export class AreHTMLLifecycle extends AreLifecycle {
|
|
20
20
|
|
|
21
21
|
@AreLifecycle.Init(AreComponentNode)
|
|
22
|
-
initComponent(
|
|
23
|
-
@A_Inject(A_Caller) node: AreHTMLNode,
|
|
24
|
-
@A_Inject(A_Scope) scope: A_Scope,
|
|
25
|
-
@A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,
|
|
26
|
-
@A_Inject(A_Logger) logger?: A_Logger,
|
|
27
|
-
...args: any[]
|
|
28
|
-
): void {
|
|
29
|
-
super.init(node, scope, context, logger, ...args);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
22
|
@AreLifecycle.Init(AreRootNode)
|
|
34
|
-
|
|
23
|
+
initComponent(
|
|
35
24
|
@A_Inject(A_Caller) node: AreHTMLNode,
|
|
36
25
|
@A_Inject(A_Scope) scope: A_Scope,
|
|
37
26
|
@A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,
|
|
@@ -44,6 +33,18 @@ export class AreHTMLLifecycle extends AreLifecycle {
|
|
|
44
33
|
}
|
|
45
34
|
|
|
46
35
|
|
|
36
|
+
// initRoot(
|
|
37
|
+
// @A_Inject(A_Caller) node: AreHTMLNode,
|
|
38
|
+
// @A_Inject(A_Scope) scope: A_Scope,
|
|
39
|
+
// @A_Inject(AreHTMLEngineContext) context: AreHTMLEngineContext,
|
|
40
|
+
// @A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,
|
|
41
|
+
// @A_Inject(A_Logger) logger?: A_Logger,
|
|
42
|
+
// ...args: any[]
|
|
43
|
+
// ): void {
|
|
44
|
+
// super.init(node, scope, context, logger, ...args);
|
|
45
|
+
// }
|
|
46
|
+
|
|
47
|
+
|
|
47
48
|
@AreLifecycle.Init(AreText)
|
|
48
49
|
initText(
|
|
49
50
|
@A_Inject(A_Caller) node: AreHTMLNode,
|
|
@@ -71,8 +72,38 @@ export class AreHTMLLifecycle extends AreLifecycle {
|
|
|
71
72
|
scope.register(scene);
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
@A_Feature.Extend({
|
|
76
|
+
name: AreNodeFeatures.onMount,
|
|
77
|
+
scope: [AreHTMLNode]
|
|
78
|
+
})
|
|
79
|
+
mount(
|
|
80
|
+
/**
|
|
81
|
+
* Node to be mounted
|
|
82
|
+
*/
|
|
83
|
+
@A_Inject(A_Caller) node: AreHTMLNode,
|
|
84
|
+
/**
|
|
85
|
+
* Node Content
|
|
86
|
+
*/
|
|
87
|
+
@A_Inject(AreScene) scene: AreScene,
|
|
74
88
|
|
|
89
|
+
@A_Inject(A_Logger) logger?: A_Logger,
|
|
90
|
+
...args: any[]
|
|
91
|
+
) {
|
|
75
92
|
|
|
93
|
+
logger?.debug(`[Mount] Component Trigger for <${node.aseid.entity}> with aseid :{${node.aseid.toString()}}`);
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 1. We should simply run and render node itself.
|
|
97
|
+
*/
|
|
98
|
+
node.interpret();
|
|
99
|
+
/**
|
|
100
|
+
* 2. Then go through all children of the node and mount the.
|
|
101
|
+
*/
|
|
102
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
103
|
+
const child = node.children[i];
|
|
104
|
+
child.mount();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
76
107
|
|
|
77
108
|
@A_Feature.Extend({
|
|
78
109
|
name: AreAttributeFeatures.Update,
|
|
@@ -54,11 +54,12 @@ export class AreRoot extends Are {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
// 3. Fall back to the 'default' attribute on the node directly
|
|
58
|
-
//
|
|
57
|
+
// 3. Fall back to the 'default' attribute on the node directly.
|
|
58
|
+
// Note: root.attributes is NOT populated at this stage because tokenize()
|
|
59
|
+
// runs after template() in the lifecycle. Read from raw markup instead.
|
|
59
60
|
if (!componentName) {
|
|
60
|
-
const
|
|
61
|
-
componentName =
|
|
61
|
+
const defaultMatch = root.markup?.match(/\bdefault=["']([^"']*)["']/);
|
|
62
|
+
componentName = defaultMatch?.[1];
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
if (!componentName) {
|
|
@@ -78,8 +79,6 @@ export class AreRoot extends Are {
|
|
|
78
79
|
@A_Inject(A_Logger) logger: A_Logger,
|
|
79
80
|
@A_Inject(AreSignalsContext) signalsContext?: AreSignalsContext,
|
|
80
81
|
) {
|
|
81
|
-
console.log('Received signal vector in AreRoot:', root, vector);
|
|
82
|
-
|
|
83
82
|
const rootId = root.id;
|
|
84
83
|
// No routing config for this root — signals do not affect its content
|
|
85
84
|
if (signalsContext && !signalsContext.hasRoot(rootId)) {
|