@adaas/are-html 0.0.8 → 0.0.9
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 +49 -5
- package/dist/browser/index.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/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
|
@@ -828,6 +828,12 @@ AreRoute = __decorateClass([
|
|
|
828
828
|
], AreRoute);
|
|
829
829
|
|
|
830
830
|
// src/engine/AreHTML.constants.ts
|
|
831
|
+
var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
832
|
+
var SVG_ATTRIBUTE_NS = {
|
|
833
|
+
xlink: "http://www.w3.org/1999/xlink",
|
|
834
|
+
xml: "http://www.w3.org/XML/1998/namespace",
|
|
835
|
+
xmlns: "http://www.w3.org/2000/xmlns/"
|
|
836
|
+
};
|
|
831
837
|
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
832
838
|
"area",
|
|
833
839
|
"base",
|
|
@@ -1284,6 +1290,7 @@ var AreHTMLInterpreter = class extends AreInterpreter {
|
|
|
1284
1290
|
parent = parent.parent;
|
|
1285
1291
|
}
|
|
1286
1292
|
const tag = node.tag;
|
|
1293
|
+
const isSVG = tag === "svg" || this.isInSVGContext(node);
|
|
1287
1294
|
if (parent) {
|
|
1288
1295
|
const mountPoint = context.getNodeElement(parent);
|
|
1289
1296
|
if (!mountPoint) {
|
|
@@ -1292,7 +1299,7 @@ var AreHTMLInterpreter = class extends AreInterpreter {
|
|
|
1292
1299
|
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
1300
|
});
|
|
1294
1301
|
}
|
|
1295
|
-
const element = context.container.createElement(tag);
|
|
1302
|
+
const element = isSVG ? context.container.createElementNS(SVG_NAMESPACE, tag) : context.container.createElement(tag);
|
|
1296
1303
|
if (mountPoint.nodeType === Node.ELEMENT_NODE) {
|
|
1297
1304
|
mountPoint.appendChild(element);
|
|
1298
1305
|
} else {
|
|
@@ -1307,7 +1314,7 @@ var AreHTMLInterpreter = class extends AreInterpreter {
|
|
|
1307
1314
|
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
1315
|
});
|
|
1309
1316
|
}
|
|
1310
|
-
const element = context.container.createElement(tag);
|
|
1317
|
+
const element = isSVG ? context.container.createElementNS(SVG_NAMESPACE, tag) : context.container.createElement(tag);
|
|
1311
1318
|
mountPoint.parentNode?.replaceChild(element, mountPoint);
|
|
1312
1319
|
context.setInstructionElement(declaration, element);
|
|
1313
1320
|
}
|
|
@@ -1338,6 +1345,15 @@ var AreHTMLInterpreter = class extends AreInterpreter {
|
|
|
1338
1345
|
}) : content;
|
|
1339
1346
|
const el = element;
|
|
1340
1347
|
const lowerName = name.toLowerCase();
|
|
1348
|
+
const colonIdx = name.indexOf(":");
|
|
1349
|
+
if (colonIdx > 0) {
|
|
1350
|
+
const ns = SVG_ATTRIBUTE_NS[name.slice(0, colonIdx)];
|
|
1351
|
+
if (ns) {
|
|
1352
|
+
el.setAttributeNS(ns, name, toDOMString(rawValue));
|
|
1353
|
+
mutation.cache = toDOMString(rawValue);
|
|
1354
|
+
return;
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1341
1357
|
if (isBooleanAttribute(lowerName)) {
|
|
1342
1358
|
if (rawValue) {
|
|
1343
1359
|
el.setAttribute(lowerName, "");
|
|
@@ -1414,7 +1430,17 @@ var AreHTMLInterpreter = class extends AreInterpreter {
|
|
|
1414
1430
|
if (!element) return;
|
|
1415
1431
|
const { name } = mutation.payload;
|
|
1416
1432
|
if (name && element.nodeType === Node.ELEMENT_NODE) {
|
|
1417
|
-
|
|
1433
|
+
const colonIdx = name.indexOf(":");
|
|
1434
|
+
if (colonIdx > 0) {
|
|
1435
|
+
const ns = SVG_ATTRIBUTE_NS[name.slice(0, colonIdx)];
|
|
1436
|
+
if (ns) {
|
|
1437
|
+
element.removeAttributeNS(ns, name.slice(colonIdx + 1));
|
|
1438
|
+
} else {
|
|
1439
|
+
element.removeAttribute(name);
|
|
1440
|
+
}
|
|
1441
|
+
} else {
|
|
1442
|
+
element.removeAttribute(name);
|
|
1443
|
+
}
|
|
1418
1444
|
}
|
|
1419
1445
|
} catch (error) {
|
|
1420
1446
|
console.log("Error removing attribute:", error);
|
|
@@ -1588,6 +1614,23 @@ var AreHTMLInterpreter = class extends AreInterpreter {
|
|
|
1588
1614
|
element.parentNode?.removeChild(element);
|
|
1589
1615
|
context.removeInstructionElement(declaration);
|
|
1590
1616
|
}
|
|
1617
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
1618
|
+
// ── SVG helpers ───────────────────────────────────────────────────────────────
|
|
1619
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
1620
|
+
/**
|
|
1621
|
+
* Returns true when any ancestor of the given node has the tag `svg`,
|
|
1622
|
+
* meaning the node lives inside an SVG subtree and its DOM element must be
|
|
1623
|
+
* created via createElementNS(SVG_NAMESPACE, tag).
|
|
1624
|
+
*/
|
|
1625
|
+
isInSVGContext(node) {
|
|
1626
|
+
let current = node.parent;
|
|
1627
|
+
while (current) {
|
|
1628
|
+
if (current.tag === "svg") return true;
|
|
1629
|
+
if (current.tag === "foreignobject") return false;
|
|
1630
|
+
current = current.parent;
|
|
1631
|
+
}
|
|
1632
|
+
return false;
|
|
1633
|
+
}
|
|
1591
1634
|
};
|
|
1592
1635
|
__decorateClass([
|
|
1593
1636
|
A_Frame.Define({
|
|
@@ -1700,7 +1743,7 @@ AreHTMLInterpreter = __decorateClass([
|
|
|
1700
1743
|
var AreHTMLTokenizer = class extends AreTokenizer {
|
|
1701
1744
|
constructor() {
|
|
1702
1745
|
super(...arguments);
|
|
1703
|
-
this.ATTR_PATTERN = /([$:@]?[\w.-]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>/"'=]+)))?/g;
|
|
1746
|
+
this.ATTR_PATTERN = /([$:@]?[\w.-]+(?::[\w.-]+)?)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>/"'=]+)))?/g;
|
|
1704
1747
|
}
|
|
1705
1748
|
tokenize(node, context, logger) {
|
|
1706
1749
|
super.tokenize(node, context, logger);
|
|
@@ -1774,6 +1817,7 @@ var AreHTMLLifecycle = class extends AreLifecycle {
|
|
|
1774
1817
|
}
|
|
1775
1818
|
mount(node, scene, logger, ...args) {
|
|
1776
1819
|
logger?.debug(`[Mount] Component Trigger for <${node.aseid.entity}> with aseid :{${node.aseid.toString()}}`);
|
|
1820
|
+
if (scene.isInactive) return;
|
|
1777
1821
|
node.interpret();
|
|
1778
1822
|
for (let i = 0; i < node.children.length; i++) {
|
|
1779
1823
|
const child = node.children[i];
|
|
@@ -2197,6 +2241,6 @@ AreRouteWatcher = __decorateClass([
|
|
|
2197
2241
|
})
|
|
2198
2242
|
], AreRouteWatcher);
|
|
2199
2243
|
|
|
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 };
|
|
2244
|
+
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
2245
|
//# sourceMappingURL=index.mjs.map
|
|
2202
2246
|
//# sourceMappingURL=index.mjs.map
|