@webqit/oohtml 5.0.7 → 5.0.8

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/main.lite.js CHANGED
@@ -974,7 +974,9 @@ function set(target, prop, value, receiver = (x) => x, params = {}, def = false)
974
974
  const listenerRegistry = ListenerRegistry.getInstance(originalTarget, false, params.namespace);
975
975
  if (listenerRegistry)
976
976
  listenerRegistry.emit(descriptors, { eventsArePropertyDescriptors: !!def });
977
- return receiver(isPropsList(prop) ? descriptors.map((opr) => opr.status) : descriptors[0]?.status);
977
+ return receiver(
978
+ isPropsList(prop) ? descriptors.map((opr) => opr.status) : descriptors[0]?.status
979
+ );
978
980
  });
979
981
  }
980
982
  function defineProperty(target, prop, descriptor, receiver = (x) => x, params = {}) {
@@ -1020,7 +1022,9 @@ function deleteProperty(target, prop, receiver = (x) => x, params = {}) {
1020
1022
  const listenerRegistry = ListenerRegistry.getInstance(originalTarget, false, params.namespace);
1021
1023
  if (listenerRegistry)
1022
1024
  listenerRegistry.emit(descriptors);
1023
- return receiver(isPropsList(prop) ? descriptors.map((opr) => opr.status) : descriptors[0].status);
1025
+ return receiver(
1026
+ isPropsList(prop) ? descriptors.map((opr) => opr.status) : descriptors[0].status
1027
+ );
1024
1028
  });
1025
1029
  }
1026
1030
  function deleteProperties(target, props, receiver = (x) => x, params = {}) {
@@ -1042,7 +1046,11 @@ function apply(target, thisArgument, argumentsList, receiver = (x) => x, params
1042
1046
  listenerRegistry?.emit([descriptor], { eventIsArrayMethodDescriptor: true });
1043
1047
  }
1044
1048
  _wq(originalThis).set("$length", originalThis.length);
1045
- returnValue = batch(originalThis, () => exec(target, "apply", { thisArgument, argumentsList }, receiver, params), params);
1049
+ returnValue = batch(
1050
+ originalThis,
1051
+ () => exec(target, "apply", { thisArgument, argumentsList }, receiver, params),
1052
+ params
1053
+ );
1046
1054
  _wq(originalThis).delete("$length");
1047
1055
  } else {
1048
1056
  returnValue = exec(target, "apply", { thisArgument: originalThis, argumentsList }, receiver, params);
@@ -1524,7 +1532,11 @@ var Signal = class extends _EventTarget {
1524
1532
  signal(name, type = "prop") {
1525
1533
  let signal = this.signals.get(name);
1526
1534
  if (!signal) {
1527
- signal = new Signal(this, type, type === "object" ? name : _isTypeObject(this.state) ? Observer.get(this.state, name) : void 0);
1535
+ signal = new Signal(
1536
+ this,
1537
+ type,
1538
+ type === "object" ? name : _isTypeObject(this.state) ? Observer.get(this.state, name) : void 0
1539
+ );
1528
1540
  this.signals.set(name, signal);
1529
1541
  if (this.signals.size === 1) {
1530
1542
  this.watchMode();
@@ -2389,7 +2401,12 @@ function compile(sourceType, astTools, source, functionParams = [], params = {})
2389
2401
  } else if (isFunction) {
2390
2402
  if (isSource) {
2391
2403
  if (sourceIsProgram) {
2392
- source = Node_default.funcExpr(null, functionParams.map((param) => Node_default.identifier(param)), Node_default.blockStmt(liveMode ? [Node_default.literal("use live"), ...source.body] : source.body), isAsync);
2404
+ source = Node_default.funcExpr(
2405
+ null,
2406
+ functionParams.map((param) => Node_default.identifier(param)),
2407
+ Node_default.blockStmt(liveMode ? [Node_default.literal("use live"), ...source.body] : source.body),
2408
+ isAsync
2409
+ );
2393
2410
  source.isLiveFunction = originalProgram.isLiveProgram;
2394
2411
  } else {
2395
2412
  const body = ` ` + source.split(`
@@ -2851,7 +2868,7 @@ function containsNode(window2, a, b, crossRoots = false, testCache = null) {
2851
2868
  const rootNodeB = b.getRootNode();
2852
2869
  if (rootNodeA === rootNodeB)
2853
2870
  return response(a.contains(b));
2854
- if (crossRoots && rootNodeB instanceof window2.ShadowRoot)
2871
+ if (crossRoots && isShadowRoot(rootNodeB))
2855
2872
  return response(containsNode(window2, a, rootNodeB.host, crossRoots, testCache));
2856
2873
  return response(false);
2857
2874
  }
@@ -2907,7 +2924,7 @@ var Realtime = class {
2907
2924
  } else {
2908
2925
  args[0] = from_default(args[0], false);
2909
2926
  }
2910
- if (args[0].filter((x) => typeof x !== "string" && !(x instanceof DOMSpec) && !(x instanceof this.window.Node)).length) {
2927
+ if (args[0].filter((x) => typeof x !== "string" && !(x instanceof DOMSpec) && !isNode(x)).length) {
2911
2928
  throw new Error(`Argument #2 must be either a string or a Node object, or a list of those.`);
2912
2929
  }
2913
2930
  args[0] = args[0].map((s) => s instanceof DOMSpec ? s : new DOMSpec(s));
@@ -3285,10 +3302,12 @@ var DOMRealtime = class extends Realtime {
3285
3302
  dispatch2.call(window2, registration, record, context);
3286
3303
  }));
3287
3304
  mo.observe(context, { childList: true, subtree: params.subtree && true });
3288
- const disconnectable = { disconnect() {
3289
- registry2.delete(registration);
3290
- mo.disconnect();
3291
- } };
3305
+ const disconnectable = {
3306
+ disconnect() {
3307
+ registry2.delete(registration);
3308
+ mo.disconnect();
3309
+ }
3310
+ };
3292
3311
  const signalGenerator = params.signalGenerator || params.lifecycleSignals && this.createSignalGenerator();
3293
3312
  const registration = { context, spec, callback, params, signalGenerator, disconnectable };
3294
3313
  const registry2 = this.registry(interceptionTiming);
@@ -3491,7 +3510,7 @@ function domInterception(timing, callback) {
3491
3510
  _apiOriginals[DOMClassName][apiName] = _apiOriginal;
3492
3511
  });
3493
3512
  function method(...args) {
3494
- const DOMClassName = Object.keys(_apiOriginals).find((name) => this instanceof window2[name] && apiName in _apiOriginals[name]);
3513
+ const DOMClassName = Object.keys(_apiOriginals).find((name) => isNodeInterface(this, name) && apiName in _apiOriginals[name]);
3495
3514
  const $apiOriginals = _apiOriginals[DOMClassName];
3496
3515
  let exec3 = () => $apiOriginals[apiName].value.call(this, ...args);
3497
3516
  if (webqit2.realdom.domInterceptionNoRecurse.get(this) === apiName)
@@ -3550,17 +3569,17 @@ function domInterception(timing, callback) {
3550
3569
  });
3551
3570
  }
3552
3571
  function setter(value) {
3553
- const DOMClassName = Object.keys(_apiOriginals).find((name) => this instanceof window2[name] && apiName in _apiOriginals[name]);
3572
+ const DOMClassName = Object.keys(_apiOriginals).find((name) => isNodeInterface(this, name) && apiName in _apiOriginals[name]);
3554
3573
  const $apiOriginals = _apiOriginals[DOMClassName];
3555
3574
  let exec3 = () => $apiOriginals[apiName].set.call(this, value);
3556
- if (this instanceof HTMLScriptElement || webqit2.realdom.domInterceptionNoRecurse.get(this) === apiName)
3575
+ if (isNodeInterface(this, "HTMLScriptElement") || webqit2.realdom.domInterceptionNoRecurse.get(this) === apiName)
3557
3576
  return exec3();
3558
3577
  let exits = [], entrants = [], target = this;
3559
3578
  if (["outerHTML", "outerText"].includes(apiName)) {
3560
3579
  exits = [this];
3561
3580
  target = this.parentNode;
3562
3581
  } else {
3563
- if (this instanceof HTMLTemplateElement) {
3582
+ if (isNodeInterface(this, "HTMLTemplateElement")) {
3564
3583
  target = this.content;
3565
3584
  exits = [...this.content.childNodes];
3566
3585
  } else {
@@ -3576,18 +3595,18 @@ function domInterception(timing, callback) {
3576
3595
  }
3577
3596
  const temp = document2.createElement(tempNodeName.includes("-") ? "div" : tempNodeName);
3578
3597
  noRecurse(temp, apiName, () => temp[apiName] = value);
3579
- entrants = this instanceof HTMLTemplateElement ? [...temp.content.childNodes] : [...temp.childNodes];
3580
- if (this instanceof HTMLTemplateElement && this.hasAttribute("src") || this instanceof ShadowRoot) {
3598
+ entrants = isNodeInterface(this, "HTMLTemplateElement") ? [...temp.content.childNodes] : [...temp.childNodes];
3599
+ if (isNodeInterface(this, "HTMLTemplateElement") && this.hasAttribute("src") || isShadowRoot(this)) {
3581
3600
  const getScripts = (nodes) => nodes.reduce((scripts, el) => {
3582
- if (el instanceof HTMLScriptElement)
3601
+ if (isNodeInterface(el, "HTMLScriptElement"))
3583
3602
  return scripts.concat(el);
3584
- if (el instanceof HTMLTemplateElement)
3603
+ if (isNodeInterface(el, "HTMLTemplateElement"))
3585
3604
  return scripts.concat(getScripts([el.content]));
3586
3605
  scripts = scripts.concat(getScripts([...el.querySelectorAll?.("template") || []].map((t) => t.content)));
3587
3606
  return scripts.concat(...el.querySelectorAll?.("script") || []);
3588
3607
  }, []);
3589
3608
  for (const script of getScripts(entrants)) {
3590
- if (this instanceof ShadowRoot) {
3609
+ if (isShadowRoot(this)) {
3591
3610
  script.setAttribute("data-handling", "manual");
3592
3611
  continue;
3593
3612
  }
@@ -3602,7 +3621,7 @@ function domInterception(timing, callback) {
3602
3621
  noRecurse(value, "append", () => value.append(...entrants));
3603
3622
  exec3 = () => noRecurse(this, "replaceWith", () => Element.prototype.replaceWith.call(this, value));
3604
3623
  } else {
3605
- if (this instanceof HTMLTemplateElement) {
3624
+ if (isNodeInterface(this, "HTMLTemplateElement")) {
3606
3625
  exec3 = () => noRecurse(this.content, "replaceChildren", () => this.content.replaceChildren(...entrants));
3607
3626
  } else {
3608
3627
  exec3 = () => noRecurse(this, "replaceChildren", () => Element.prototype.replaceChildren.call(this, ...entrants));
@@ -3719,17 +3738,57 @@ function meta(name) {
3719
3738
  if (_el = window2.document.querySelector(`meta[name="${name}"]`)) {
3720
3739
  _content = (_el.content || "").split(";").filter((v) => v).reduce((_metaVars, directive) => {
3721
3740
  const directiveSplit = directive.split("=").map((d) => d.trim());
3722
- set_default(_metaVars, directiveSplit[0].split("."), directiveSplit[1] === "true" ? true : directiveSplit[1] === "false" ? false : isNumeric_default(directiveSplit[1]) ? parseInt(directiveSplit[1]) : directiveSplit[1]);
3741
+ set_default(
3742
+ _metaVars,
3743
+ directiveSplit[0].split("."),
3744
+ directiveSplit[1] === "true" ? true : directiveSplit[1] === "false" ? false : isNumeric_default(directiveSplit[1]) ? parseInt(directiveSplit[1]) : directiveSplit[1]
3745
+ );
3723
3746
  return _metaVars;
3724
3747
  }, {});
3725
3748
  }
3726
- return { get name() {
3727
- return name;
3728
- }, get content() {
3729
- return _el.content;
3730
- }, json() {
3731
- return JSON.parse(JSON.stringify(_content));
3732
- } };
3749
+ return {
3750
+ get name() {
3751
+ return name;
3752
+ },
3753
+ get content() {
3754
+ return _el.content;
3755
+ },
3756
+ json() {
3757
+ return JSON.parse(JSON.stringify(_content));
3758
+ }
3759
+ };
3760
+ }
3761
+ function isNode(value) {
3762
+ return value !== null && typeof value === "object" && typeof value.nodeType === "number" && typeof value.nodeName === "string";
3763
+ }
3764
+ function isElement(value) {
3765
+ return value?.nodeType === 1;
3766
+ }
3767
+ function isShadowRoot(value) {
3768
+ return value?.nodeType === 11 && Object.prototype.toString.call(value) === "[object ShadowRoot]";
3769
+ }
3770
+ function isDocument(value) {
3771
+ return value?.nodeType === 9 && Object.prototype.toString.call(value) === "[object Document]";
3772
+ }
3773
+ function isCharacterData(value) {
3774
+ const toStringValue = Object.prototype.toString.call(value);
3775
+ return toStringValue === "[object Text]" || toStringValue === "[object Comment]" || toStringValue === "[object CDATASection]" || toStringValue === "[object ProcessingInstruction]";
3776
+ }
3777
+ function isNodeInterface(value, interfaceName) {
3778
+ if (!isNode(value))
3779
+ return false;
3780
+ if (interfaceName === "ShadowRoot") {
3781
+ return isShadowRoot(value);
3782
+ HTMLUnknownElement;
3783
+ }
3784
+ const toStringValue = Object.prototype.toString.call(value);
3785
+ if (toStringValue === `[object ${interfaceName}]`)
3786
+ return true;
3787
+ if (interfaceName === "DocumentFragment" && isShadowRoot(value))
3788
+ return true;
3789
+ if (interfaceName === "CharacterData" && isCharacterData(value))
3790
+ return true;
3791
+ return (interfaceName === "Node" || interfaceName === "Element" || interfaceName === "HTMLElement") && isElement(value) || interfaceName === "Node" && isNode(value);
3733
3792
  }
3734
3793
 
3735
3794
  // node_modules/@webqit/util/str/toTitle.js
@@ -3955,7 +4014,7 @@ var _DOMContext = class {
3955
4014
  return configs;
3956
4015
  }
3957
4016
  get name() {
3958
- return [env3.window.Document, env3.window.ShadowRoot].some((x) => this.host instanceof x) ? Infinity : this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname);
4017
+ return isDocument(this.host) || isShadowRoot(this.host) ? Infinity : this.host.getAttribute(this.configs.CONTEXT_API.attr.contextname);
3959
4018
  }
3960
4019
  subscribed(event) {
3961
4020
  }
@@ -4155,7 +4214,7 @@ function getOwnNamespaceObject(node) {
4155
4214
  if (!_wq2(node).has("namespace")) {
4156
4215
  const namespaceObj = /* @__PURE__ */ Object.create(null);
4157
4216
  _wq2(node).set("namespace", namespaceObj);
4158
- const isDocumentRoot = [window2.Document, window2.ShadowRoot].some((x) => node instanceof x);
4217
+ const isDocumentRoot = isDocument(node) || isShadowRoot(node);
4159
4218
  Object.defineProperty(namespaceObj, Symbol.toStringTag, {
4160
4219
  get() {
4161
4220
  return isDocumentRoot ? "RootNamespaceRegistry" : "NamespaceRegistry";
@@ -4166,7 +4225,7 @@ function getOwnNamespaceObject(node) {
4166
4225
  }
4167
4226
  function getOwnerNamespaceObject(node, forID = false) {
4168
4227
  const window2 = this, { webqit: { oohtml: { configs: { NAMESPACED_HTML: config } } } } = window2;
4169
- const isDocumentRoot = [window2.Document, window2.ShadowRoot].some((x) => node instanceof x);
4228
+ const isDocumentRoot = isDocument(node) || isShadowRoot(node);
4170
4229
  return getOwnNamespaceObject.call(window2, isDocumentRoot ? node : (forID ? node.parentNode : node)?.closest?.(config.namespaceSelector) || node.getRootNode());
4171
4230
  }
4172
4231
  function getNamespaceUUID(namespaceObj) {
@@ -4446,12 +4505,14 @@ function exposeAPIs2(config) {
4446
4505
  throw new Error(`The "Element" class already has a "${config.api.scripts}" property!`);
4447
4506
  }
4448
4507
  [window2.ShadowRoot.prototype, window2.Element.prototype].forEach((proto) => {
4449
- Object.defineProperty(proto, config.api.scripts, { get: function() {
4450
- if (!scriptsMap.has(this)) {
4451
- scriptsMap.set(this, []);
4508
+ Object.defineProperty(proto, config.api.scripts, {
4509
+ get: function() {
4510
+ if (!scriptsMap.has(this)) {
4511
+ scriptsMap.set(this, []);
4512
+ }
4513
+ return scriptsMap.get(this);
4452
4514
  }
4453
- return scriptsMap.get(this);
4454
- } });
4515
+ });
4455
4516
  });
4456
4517
  Object.defineProperties(window2.HTMLScriptElement.prototype, {
4457
4518
  scoped: {
@@ -4501,7 +4562,7 @@ async function execute(config, execHash) {
4501
4562
  if (script.live) {
4502
4563
  liveProgramHandle.abort();
4503
4564
  }
4504
- if (thisContext instanceof window2.Element) {
4565
+ if (isElement(thisContext)) {
4505
4566
  thisContext[config.api.scripts]?.splice(thisContext[config.api.scripts].indexOf(script, 1));
4506
4567
  }
4507
4568
  }, { id: "scoped-js:script-exits", subtree: "cross-roots", timing: "sync", generation: "exits" });
@@ -4805,7 +4866,7 @@ function compileInlineBindings(config, str) {
4805
4866
  $existing__.delete( $key___ );
4806
4867
  $exec__($itemNode__, '${config.BINDINGS_API.api.bind}', $itemBinding__ );
4807
4868
  } else {
4808
- $itemNode__ = ( Array.isArray( $import__.value ) ? $import__.value[ 0 ] : ( $import__.value instanceof window.HTMLTemplateElement ? $import__.value.content.firstElementChild : $import__.value ) ).cloneNode( true );
4869
+ $itemNode__ = ( Array.isArray( $import__.value ) ? $import__.value[ 0 ] : ( $import__.value?.nodeName === 'TEMPLATE' ? $import__.value.content.firstElementChild : $import__.value ) ).cloneNode( true );
4809
4870
  $itemNode__.setAttribute( "${config.attr.itemIndex}", $key___ );
4810
4871
  $exec__($itemNode__, '${config.BINDINGS_API.api.bind}', $itemBinding__ );
4811
4872
  $exec__(this, 'appendChild', $itemNode__ );
@@ -4905,7 +4966,7 @@ function getBindings(config, node) {
4905
4966
  const bindingsObj = /* @__PURE__ */ Object.create(null);
4906
4967
  _wq2(node).set("bindings", bindingsObj);
4907
4968
  Observer2.observe(bindingsObj, (mutations) => {
4908
- if (node instanceof window2.Element) {
4969
+ if (isElement(node)) {
4909
4970
  const bindingsParse = parseBindingsAttr(node.getAttribute(config.attr.bindingsreflection) || "");
4910
4971
  const bindingsParseBefore = new Map(bindingsParse);
4911
4972
  for (const m of mutations) {
@@ -4946,12 +5007,16 @@ function exposeAPIs3(config) {
4946
5007
  if (config.api.bindings in prototype) {
4947
5008
  throw new Error(`The ${type} prototype already has a "${config.api.bindings}" API!`);
4948
5009
  }
4949
- Object.defineProperty(prototype, config.api.bind, { value: function(bindings, options = {}) {
4950
- return applyBindings.call(window2, config, this, bindings, options);
4951
- } });
4952
- Object.defineProperty(prototype, config.api.bindings, { get: function() {
4953
- return Observer2.proxy(getBindings.call(window2, config, this));
4954
- } });
5010
+ Object.defineProperty(prototype, config.api.bind, {
5011
+ value: function(bindings, options = {}) {
5012
+ return applyBindings.call(window2, config, this, bindings, options);
5013
+ }
5014
+ });
5015
+ Object.defineProperty(prototype, config.api.bindings, {
5016
+ get: function() {
5017
+ return Observer2.proxy(getBindings.call(window2, config, this));
5018
+ }
5019
+ });
4955
5020
  });
4956
5021
  }
4957
5022
  function applyBindings(config, target, bindings, { merge, diff, publish, namespace } = {}) {
@@ -5306,7 +5371,7 @@ function HTMLImportElement_default() {
5306
5371
  };
5307
5372
  class HTMLImportElement extends BaseElement {
5308
5373
  static instance(node) {
5309
- if (configs.HTML_IMPORTS.elements.import.includes("-") && node instanceof this)
5374
+ if (configs.HTML_IMPORTS.elements.import.includes("-") && node.nodeName === this.nodeName)
5310
5375
  return node;
5311
5376
  return _wq2(node).get("import::instance") || new this(node);
5312
5377
  }
@@ -5331,7 +5396,7 @@ function HTMLImportElement_default() {
5331
5396
  const moduleRef = priv.moduleRef.includes("#") ? priv.moduleRef : `${priv.moduleRef}#`;
5332
5397
  const request = { ...HTMLImportsContext.createRequest(moduleRef), live: signal && true, signal, diff: !moduleRef.endsWith("#") };
5333
5398
  parentNode[configs.CONTEXT_API.api.contexts].request(request, (response) => {
5334
- callback((response instanceof window2.HTMLTemplateElement ? [...response.content.children] : Array.isArray(response) ? response : response && [response]) || []);
5399
+ callback((isNodeInterface(response, "HTMLTemplateElement") ? [...response.content.children] : Array.isArray(response) ? response : response && [response]) || []);
5335
5400
  });
5336
5401
  }, { live: true, timing: "sync", lifecycleSignals: true });
5337
5402
  priv.autoDestroyRealtime = realdom.realtime(window2.document).track(parentNode, () => {
@@ -5358,6 +5423,7 @@ function HTMLImportElement_default() {
5358
5423
  priv.slottedElements.add(slottedElement);
5359
5424
  });
5360
5425
  priv.originalsRemapped = true;
5426
+ priv.autoRestore();
5361
5427
  });
5362
5428
  };
5363
5429
  priv.autoRestore = (callback = null) => {
@@ -5752,7 +5818,7 @@ function realtime6(config) {
5752
5818
  const scopeSelector = style.scoped && (supportsHAS ? `:has(> style[rand-${sourceHash}])` : `[rand-${sourceHash}]`);
5753
5819
  const supportsScope = style.scoped && window2.CSSScopeRule && false;
5754
5820
  const scopeRoot = style.scoped && style.parentNode || style.getRootNode();
5755
- if (scopeRoot instanceof window2.Element) {
5821
+ if (isElement(scopeRoot)) {
5756
5822
  scopeRoot[config.api.styleSheets].push(style);
5757
5823
  if (!inBrowser)
5758
5824
  return;