@adaas/are-html 0.0.8 → 0.0.10
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 +14 -1
- package/dist/browser/index.mjs +50 -5
- package/dist/browser/index.mjs.map +1 -1
- package/dist/node/directives/AreDirectiveFor.directive.js +1 -0
- package/dist/node/directives/AreDirectiveFor.directive.js.map +1 -1
- package/dist/node/directives/AreDirectiveFor.directive.mjs +1 -0
- package/dist/node/directives/AreDirectiveFor.directive.mjs.map +1 -1
- package/dist/node/engine/AreHTML.constants.d.mts +8 -1
- package/dist/node/engine/AreHTML.constants.d.ts +8 -1
- package/dist/node/engine/AreHTML.constants.js +8 -0
- package/dist/node/engine/AreHTML.constants.js.map +1 -1
- package/dist/node/engine/AreHTML.constants.mjs +7 -1
- package/dist/node/engine/AreHTML.constants.mjs.map +1 -1
- package/dist/node/engine/AreHTML.interpreter.d.mts +6 -0
- package/dist/node/engine/AreHTML.interpreter.d.ts +6 -0
- package/dist/node/engine/AreHTML.interpreter.js +40 -3
- package/dist/node/engine/AreHTML.interpreter.js.map +1 -1
- package/dist/node/engine/AreHTML.interpreter.mjs +41 -4
- package/dist/node/engine/AreHTML.interpreter.mjs.map +1 -1
- package/dist/node/engine/AreHTML.lifecycle.js +1 -0
- package/dist/node/engine/AreHTML.lifecycle.js.map +1 -1
- package/dist/node/engine/AreHTML.lifecycle.mjs +1 -0
- package/dist/node/engine/AreHTML.lifecycle.mjs.map +1 -1
- package/dist/node/engine/AreHTML.tokenizer.js +1 -1
- package/dist/node/engine/AreHTML.tokenizer.js.map +1 -1
- package/dist/node/engine/AreHTML.tokenizer.mjs +1 -1
- package/dist/node/engine/AreHTML.tokenizer.mjs.map +1 -1
- package/dist/node/index.d.mts +1 -1
- package/dist/node/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/directives/AreDirectiveFor.directive.ts +5 -0
- package/src/engine/AreHTML.constants.ts +21 -0
- package/src/engine/AreHTML.interpreter.ts +52 -6
- package/src/engine/AreHTML.lifecycle.ts +6 -0
- package/src/engine/AreHTML.tokenizer.ts +1 -1
package/dist/browser/index.d.mts
CHANGED
|
@@ -311,6 +311,13 @@ declare class AreRoute extends AreSignal<A_Route> {
|
|
|
311
311
|
compare(other: A_Signal<A_Route>): boolean;
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
+
/** XML namespace URI for SVG elements. */
|
|
315
|
+
declare const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
316
|
+
/**
|
|
317
|
+
* Maps namespace prefixes used in SVG/XML attributes to their canonical URIs.
|
|
318
|
+
* Used by the interpreter when calling setAttributeNS / removeAttributeNS.
|
|
319
|
+
*/
|
|
320
|
+
declare const SVG_ATTRIBUTE_NS: Record<string, string>;
|
|
314
321
|
/**
|
|
315
322
|
* Void HTML elements that cannot have children and must not have a closing tag.
|
|
316
323
|
* Per the HTML5 spec these are treated as self-closing even when written as
|
|
@@ -537,6 +544,12 @@ declare class AreHTMLInterpreter extends AreInterpreter {
|
|
|
537
544
|
removeText(declaration: AddTextInstruction, context: AreHTMLEngineContext): void;
|
|
538
545
|
addComment(declaration: AddCommentInstruction, context: AreHTMLEngineContext, store: AreStore, syntax: AreSyntax, directiveContext?: AreDirectiveContext, logger?: A_Logger): void;
|
|
539
546
|
removeComment(declaration: AddCommentInstruction, context: AreHTMLEngineContext): void;
|
|
547
|
+
/**
|
|
548
|
+
* Returns true when any ancestor of the given node has the tag `svg`,
|
|
549
|
+
* meaning the node lives inside an SVG subtree and its DOM element must be
|
|
550
|
+
* created via createElementNS(SVG_NAMESPACE, tag).
|
|
551
|
+
*/
|
|
552
|
+
private isInSVGContext;
|
|
540
553
|
}
|
|
541
554
|
|
|
542
555
|
declare class AreHTMLLifecycle extends AreLifecycle {
|
|
@@ -618,4 +631,4 @@ declare class AreRouteWatcher extends A_Component {
|
|
|
618
631
|
private notify;
|
|
619
632
|
}
|
|
620
633
|
|
|
621
|
-
export { AddAttributeInstruction, AddElementInstruction, AddInterpolationInstruction, AddListenerInstruction, AddStyleInstruction, AddTextInstruction, AreBindingAttribute, AreComment, AreComponentNode, AreDirective, AreDirectiveAttribute, AreDirectiveContext, AreDirectiveFeatures, AreDirectiveFor, AreDirectiveIf, AreDirectiveMeta, type AreDirectiveOrderDecoratorParameters, AreEventAttribute, AreHTMLAttribute, AreHTMLCompiler, type AreHTMLContextConstructor, AreHTMLEngine, AreHTMLEngineContext, AreHTMLInstructions, AreHTMLInterpreter, AreHTMLLifecycle, AreHTMLNode, AreHTMLTokenizer, AreHTMLTransformer, type AreHtmlAddAttributeInstructionPayload, type AreHtmlAddCommentInstructionPayload, type AreHtmlAddElementInstructionPayload, type AreHtmlAddInterpolationInstructionPayload, type AreHtmlAddListenerInstructionPayload, type AreHtmlAddStyleInstructionPayload, type AreHtmlAddTextInstructionPayload, AreInterpolation, AreRoot, AreRootNode, AreRoute, AreRouteWatcher, AreStaticAttribute, AreStyle, AreText, BOOLEAN_ATTRIBUTES, IDL_FORM_PROPERTIES, LISTENER_OPTION_MODIFIERS, type ParsedEventName, VOID_ELEMENTS, isBooleanAttribute, isIDLFormProperty, isVoidElement, normalizeClassValue, normalizeStyleValue, parseEventName, toDOMString };
|
|
634
|
+
export { AddAttributeInstruction, AddElementInstruction, AddInterpolationInstruction, AddListenerInstruction, AddStyleInstruction, AddTextInstruction, AreBindingAttribute, AreComment, AreComponentNode, AreDirective, AreDirectiveAttribute, AreDirectiveContext, AreDirectiveFeatures, AreDirectiveFor, AreDirectiveIf, AreDirectiveMeta, type AreDirectiveOrderDecoratorParameters, AreEventAttribute, AreHTMLAttribute, AreHTMLCompiler, type AreHTMLContextConstructor, AreHTMLEngine, AreHTMLEngineContext, AreHTMLInstructions, AreHTMLInterpreter, AreHTMLLifecycle, AreHTMLNode, AreHTMLTokenizer, AreHTMLTransformer, type AreHtmlAddAttributeInstructionPayload, type AreHtmlAddCommentInstructionPayload, type AreHtmlAddElementInstructionPayload, type AreHtmlAddInterpolationInstructionPayload, type AreHtmlAddListenerInstructionPayload, type AreHtmlAddStyleInstructionPayload, type AreHtmlAddTextInstructionPayload, AreInterpolation, AreRoot, AreRootNode, AreRoute, AreRouteWatcher, AreStaticAttribute, AreStyle, AreText, BOOLEAN_ATTRIBUTES, IDL_FORM_PROPERTIES, LISTENER_OPTION_MODIFIERS, type ParsedEventName, SVG_ATTRIBUTE_NS, SVG_NAMESPACE, VOID_ELEMENTS, isBooleanAttribute, isIDLFormProperty, isVoidElement, normalizeClassValue, normalizeStyleValue, parseEventName, toDOMString };
|
package/dist/browser/index.mjs
CHANGED
|
@@ -404,6 +404,7 @@ var AreDirectiveFor = class extends AreDirective {
|
|
|
404
404
|
} else {
|
|
405
405
|
result = store.get(arrayExpr);
|
|
406
406
|
}
|
|
407
|
+
if (result == null) return [];
|
|
407
408
|
if (!Array.isArray(result))
|
|
408
409
|
throw new AreCompilerError({
|
|
409
410
|
title: 'Invalid "for" Directive Value',
|
|
@@ -828,6 +829,12 @@ AreRoute = __decorateClass([
|
|
|
828
829
|
], AreRoute);
|
|
829
830
|
|
|
830
831
|
// src/engine/AreHTML.constants.ts
|
|
832
|
+
var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
833
|
+
var SVG_ATTRIBUTE_NS = {
|
|
834
|
+
xlink: "http://www.w3.org/1999/xlink",
|
|
835
|
+
xml: "http://www.w3.org/XML/1998/namespace",
|
|
836
|
+
xmlns: "http://www.w3.org/2000/xmlns/"
|
|
837
|
+
};
|
|
831
838
|
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
832
839
|
"area",
|
|
833
840
|
"base",
|
|
@@ -1284,6 +1291,7 @@ var AreHTMLInterpreter = class extends AreInterpreter {
|
|
|
1284
1291
|
parent = parent.parent;
|
|
1285
1292
|
}
|
|
1286
1293
|
const tag = node.tag;
|
|
1294
|
+
const isSVG = tag === "svg" || this.isInSVGContext(node);
|
|
1287
1295
|
if (parent) {
|
|
1288
1296
|
const mountPoint = context.getNodeElement(parent);
|
|
1289
1297
|
if (!mountPoint) {
|
|
@@ -1292,7 +1300,7 @@ var AreHTMLInterpreter = class extends AreInterpreter {
|
|
|
1292
1300
|
description: `Could not find a mount point for the node with id "${node.id}". Ensure that the parent node is rendered before its children, or that a valid root element with the corresponding id exists in the DOM.`
|
|
1293
1301
|
});
|
|
1294
1302
|
}
|
|
1295
|
-
const element = context.container.createElement(tag);
|
|
1303
|
+
const element = isSVG ? context.container.createElementNS(SVG_NAMESPACE, tag) : context.container.createElement(tag);
|
|
1296
1304
|
if (mountPoint.nodeType === Node.ELEMENT_NODE) {
|
|
1297
1305
|
mountPoint.appendChild(element);
|
|
1298
1306
|
} else {
|
|
@@ -1307,7 +1315,7 @@ var AreHTMLInterpreter = class extends AreInterpreter {
|
|
|
1307
1315
|
description: `Could not find a mount point for the node with id "${node.id}". Ensure that the parent node is rendered before its children, or that a valid root element with the corresponding id exists in the DOM.`
|
|
1308
1316
|
});
|
|
1309
1317
|
}
|
|
1310
|
-
const element = context.container.createElement(tag);
|
|
1318
|
+
const element = isSVG ? context.container.createElementNS(SVG_NAMESPACE, tag) : context.container.createElement(tag);
|
|
1311
1319
|
mountPoint.parentNode?.replaceChild(element, mountPoint);
|
|
1312
1320
|
context.setInstructionElement(declaration, element);
|
|
1313
1321
|
}
|
|
@@ -1338,6 +1346,15 @@ var AreHTMLInterpreter = class extends AreInterpreter {
|
|
|
1338
1346
|
}) : content;
|
|
1339
1347
|
const el = element;
|
|
1340
1348
|
const lowerName = name.toLowerCase();
|
|
1349
|
+
const colonIdx = name.indexOf(":");
|
|
1350
|
+
if (colonIdx > 0) {
|
|
1351
|
+
const ns = SVG_ATTRIBUTE_NS[name.slice(0, colonIdx)];
|
|
1352
|
+
if (ns) {
|
|
1353
|
+
el.setAttributeNS(ns, name, toDOMString(rawValue));
|
|
1354
|
+
mutation.cache = toDOMString(rawValue);
|
|
1355
|
+
return;
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1341
1358
|
if (isBooleanAttribute(lowerName)) {
|
|
1342
1359
|
if (rawValue) {
|
|
1343
1360
|
el.setAttribute(lowerName, "");
|
|
@@ -1414,7 +1431,17 @@ var AreHTMLInterpreter = class extends AreInterpreter {
|
|
|
1414
1431
|
if (!element) return;
|
|
1415
1432
|
const { name } = mutation.payload;
|
|
1416
1433
|
if (name && element.nodeType === Node.ELEMENT_NODE) {
|
|
1417
|
-
|
|
1434
|
+
const colonIdx = name.indexOf(":");
|
|
1435
|
+
if (colonIdx > 0) {
|
|
1436
|
+
const ns = SVG_ATTRIBUTE_NS[name.slice(0, colonIdx)];
|
|
1437
|
+
if (ns) {
|
|
1438
|
+
element.removeAttributeNS(ns, name.slice(colonIdx + 1));
|
|
1439
|
+
} else {
|
|
1440
|
+
element.removeAttribute(name);
|
|
1441
|
+
}
|
|
1442
|
+
} else {
|
|
1443
|
+
element.removeAttribute(name);
|
|
1444
|
+
}
|
|
1418
1445
|
}
|
|
1419
1446
|
} catch (error) {
|
|
1420
1447
|
console.log("Error removing attribute:", error);
|
|
@@ -1588,6 +1615,23 @@ var AreHTMLInterpreter = class extends AreInterpreter {
|
|
|
1588
1615
|
element.parentNode?.removeChild(element);
|
|
1589
1616
|
context.removeInstructionElement(declaration);
|
|
1590
1617
|
}
|
|
1618
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
1619
|
+
// ── SVG helpers ───────────────────────────────────────────────────────────────
|
|
1620
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
1621
|
+
/**
|
|
1622
|
+
* Returns true when any ancestor of the given node has the tag `svg`,
|
|
1623
|
+
* meaning the node lives inside an SVG subtree and its DOM element must be
|
|
1624
|
+
* created via createElementNS(SVG_NAMESPACE, tag).
|
|
1625
|
+
*/
|
|
1626
|
+
isInSVGContext(node) {
|
|
1627
|
+
let current = node.parent;
|
|
1628
|
+
while (current) {
|
|
1629
|
+
if (current.tag === "svg") return true;
|
|
1630
|
+
if (current.tag === "foreignobject") return false;
|
|
1631
|
+
current = current.parent;
|
|
1632
|
+
}
|
|
1633
|
+
return false;
|
|
1634
|
+
}
|
|
1591
1635
|
};
|
|
1592
1636
|
__decorateClass([
|
|
1593
1637
|
A_Frame.Define({
|
|
@@ -1700,7 +1744,7 @@ AreHTMLInterpreter = __decorateClass([
|
|
|
1700
1744
|
var AreHTMLTokenizer = class extends AreTokenizer {
|
|
1701
1745
|
constructor() {
|
|
1702
1746
|
super(...arguments);
|
|
1703
|
-
this.ATTR_PATTERN = /([$:@]?[\w.-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>/"'=]+)))?/g;
|
|
1747
|
+
this.ATTR_PATTERN = /([$:@]?[\w.-]+(?::[\w.-]+)?)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>/"'=]+)))?/g;
|
|
1704
1748
|
}
|
|
1705
1749
|
tokenize(node, context, logger) {
|
|
1706
1750
|
super.tokenize(node, context, logger);
|
|
@@ -1774,6 +1818,7 @@ var AreHTMLLifecycle = class extends AreLifecycle {
|
|
|
1774
1818
|
}
|
|
1775
1819
|
mount(node, scene, logger, ...args) {
|
|
1776
1820
|
logger?.debug(`[Mount] Component Trigger for <${node.aseid.entity}> with aseid :{${node.aseid.toString()}}`);
|
|
1821
|
+
if (scene.isInactive) return;
|
|
1777
1822
|
node.interpret();
|
|
1778
1823
|
for (let i = 0; i < node.children.length; i++) {
|
|
1779
1824
|
const child = node.children[i];
|
|
@@ -2197,6 +2242,6 @@ AreRouteWatcher = __decorateClass([
|
|
|
2197
2242
|
})
|
|
2198
2243
|
], AreRouteWatcher);
|
|
2199
2244
|
|
|
2200
|
-
export { AddAttributeInstruction, AddElementInstruction, AddInterpolationInstruction, AddListenerInstruction, AddStyleInstruction, AddTextInstruction, AreBindingAttribute, AreComment, AreComponentNode, AreDirective, AreDirectiveAttribute, AreDirectiveContext, AreDirectiveFeatures, AreDirectiveFor, AreDirectiveIf, AreDirectiveMeta, AreEventAttribute, AreHTMLAttribute, AreHTMLCompiler, AreHTMLEngine, AreHTMLEngineContext, AreHTMLInstructions, AreHTMLInterpreter, AreHTMLLifecycle, AreHTMLNode, AreHTMLTokenizer, AreHTMLTransformer, AreInterpolation, AreRoot, AreRootNode, AreRoute, AreRouteWatcher, AreStaticAttribute, AreStyle, AreText, BOOLEAN_ATTRIBUTES, IDL_FORM_PROPERTIES, LISTENER_OPTION_MODIFIERS, VOID_ELEMENTS, isBooleanAttribute, isIDLFormProperty, isVoidElement, normalizeClassValue, normalizeStyleValue, parseEventName, toDOMString };
|
|
2245
|
+
export { AddAttributeInstruction, AddElementInstruction, AddInterpolationInstruction, AddListenerInstruction, AddStyleInstruction, AddTextInstruction, AreBindingAttribute, AreComment, AreComponentNode, AreDirective, AreDirectiveAttribute, AreDirectiveContext, AreDirectiveFeatures, AreDirectiveFor, AreDirectiveIf, AreDirectiveMeta, AreEventAttribute, AreHTMLAttribute, AreHTMLCompiler, AreHTMLEngine, AreHTMLEngineContext, AreHTMLInstructions, AreHTMLInterpreter, AreHTMLLifecycle, AreHTMLNode, AreHTMLTokenizer, AreHTMLTransformer, AreInterpolation, AreRoot, AreRootNode, AreRoute, AreRouteWatcher, AreStaticAttribute, AreStyle, AreText, BOOLEAN_ATTRIBUTES, IDL_FORM_PROPERTIES, LISTENER_OPTION_MODIFIERS, SVG_ATTRIBUTE_NS, SVG_NAMESPACE, VOID_ELEMENTS, isBooleanAttribute, isIDLFormProperty, isVoidElement, normalizeClassValue, normalizeStyleValue, parseEventName, toDOMString };
|
|
2201
2246
|
//# sourceMappingURL=index.mjs.map
|
|
2202
2247
|
//# sourceMappingURL=index.mjs.map
|