Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@syndicate-lang/html2

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@syndicate-lang/html2 - npm Package Compare versions

Comparing version 0.35.5 to 0.35.6

6

dist/syndicate-html2.es6.js

@@ -432,4 +432,4 @@ import * as __SYNDICATE__ from '@syndicate-lang/core';

loadHash();
__SYNDICATE__.Turn.active.assertDataflow(() => ({ target: currentSyndicateTarget, assertion: LocationHash(hashValue.value) }));
__SYNDICATE__.Turn.active.assertDataflow(() => ({ target: currentSyndicateTarget, assertion: __SYNDICATE__.Observe({
__SYNDICATE__.Turn.active.assertDataflow(() => ({ target: currentSyndicateTarget(), assertion: LocationHash(hashValue.value) }));
__SYNDICATE__.Turn.active.assertDataflow(() => ({ target: currentSyndicateTarget(), assertion: __SYNDICATE__.Observe({
pattern: __SYNDICATE__.QuasiValue.finish((__SYNDICATE__.QuasiValue.ctor(LocationHash, (__SYNDICATE__.QuasiValue.bind((__SYNDICATE__.QuasiValue._)))))),

@@ -447,3 +447,3 @@ observer: __SYNDICATE__.Turn.ref({

}) }));
})(ds));
})(() => (ds)));
});

@@ -450,0 +450,0 @@ }

@@ -1,2 +0,2 @@

import*as e from"@syndicate-lang/core";import{randomId as t,Dataspace as n,Turn as r}from"@syndicate-lang/core";const a=t(8,!0),s=new RegExp(`x-${a}-(\\d+)-${a}-x`),o=new RegExp(`x-${a}-(\\d+)-${a}-x`,"g");function i(e){let t=null,n=0;const r=[],a=[];for(;null!==(t=o.exec(e));)r.push(e.substring(n,t.index)),a.push(parseInt(t[1],10)),n=o.lastIndex;return r.push(e.substring(n)),{constantParts:r,placeholders:a}}function l(e,t){const n=[];return function e(r){if(Array.isArray(r))r.forEach(e);else switch(typeof r){case"string":n.push(t?r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"):r);break;case"number":n.push(""+r);break;default:throw new Error("Cannot render Node in attribute context")}}(e),n}function c(e){return(t,n)=>{var r;!function e(t){var r;if(Array.isArray(t))t.forEach(e);else{let e;switch(typeof t){case"string":e=document.createTextNode(t);break;case"number":e=document.createTextNode(""+t);break;case"object":if(null!==t&&"nodeType"in t){e=t;break}default:{let n;try{n=""+t}catch(e){n=t.toString()}e=document.createTextNode(`<ERROR: invalid HtmlFragment: ${n}>`);break}}null===(r=n.parentNode)||void 0===r||r.insertBefore(e,n)}}(t[e]),null===(r=n.parentNode)||void 0===r||r.removeChild(n)}}function u(e){return(t,n)=>{const r=document.createElement("template");r.innerHTML=`<x-dummy ${l(t[e],!1).join("")}></x-dummy>`,Array.from(r.content.firstElementChild.attributes).forEach((e=>n.setAttribute(e.name,e.value)))}}function h(e,t,n){return(r,a)=>{const s=[t[0]];n.forEach(((e,n)=>{s.push(...l(r[e],!1)),s.push(t[n+1])})),a.setAttribute(e,s.join(""))}}class d{constructor(e){this.template=document.createElement("template"),this.placeholderActions=[];const t=[];e.raw.forEach(((e,n)=>{n>0&&t.push(`x-${a}-${n-1}-${a}-x`),t.push(e)})),this.template.innerHTML=t.join(""),this.indexPlaceholders()}indexTextNode(e,t){var n,r;const{constantParts:a,placeholders:s}=i(null!==(n=e.textContent)&&void 0!==n?n:"");a.forEach(((t,n)=>{var r,a;if(n>0){const t=document.createElement("x-placeholder");null===(r=e.parentNode)||void 0===r||r.insertBefore(t,e)}null===(a=e.parentNode)||void 0===a||a.insertBefore(document.createTextNode(t),e)}));const o=e.nextSibling;return null===(r=e.parentNode)||void 0===r||r.removeChild(e),s.forEach(((e,n)=>{const r=t.slice();r[r.length-1]=2*n+1,this.placeholderActions.push({path:r,action:c(e)})})),t[t.length-1]+=a.length+s.length,o}indexElement(e,t){const n=[];for(let t=0;t<e.attributes.length;t++){const r=e.attributes[t],a=r.name,o=a.match(s);if(null!==o){e.removeAttributeNode(r),t--;const a=parseInt(o[1],10);n.push(u(a))}else{const{constantParts:e,placeholders:t}=i(r.value);1!==e.length&&n.push(h(a,e,t))}}n.length&&this.placeholderActions.push({path:t.slice(),action:(e,t)=>n.forEach((n=>n(e,t)))})}indexPlaceholders(){const e=[],t=n=>{e.push(0);let r=n.firstChild;for(;null!==r;){const n=r;switch(n.nodeType){case Node.TEXT_NODE:r=this.indexTextNode(n,e);break;case Node.ELEMENT_NODE:{const a=n;this.indexElement(a,e),t(a),r=a.nextSibling,e[e.length-1]++;break}default:r=n.nextSibling,e[e.length-1]++}}e.pop()};t(this.template.content)}clone(){return Array.from(this.template.cloneNode(!0).content.childNodes)}update(e,t){this.placeholderActions.forEach((({path:n,action:r})=>{r(t,function(e,t){let n=e[t[0]];for(let e=1;e<t.length;e++)n=n.childNodes[t[e]];return n}(e,n))}))}}const p=new WeakMap;function v(){let e=null;return(t,...n)=>{let r=p.get(t);return void 0===r&&(r=new d(t),p.set(t,r)),null===e&&(e=r.clone()),r.update(e,n),e}}const f=e.Record.makeConstructor()(Symbol.for("LocationHash"),["hash"]);function m(t=n.local){!function(t){e.Dataspace._spawn((()=>{e.Turn.activeFacet.actor.name="LocationHashTracker",(t=>{const n=e.Turn.active.field("/","hashValue"),a=()=>{var e=decodeURIComponent(window.location.hash);e.length&&"#"===e[0]&&(e=e.slice(1)),n.value=e||"/"},s=r.activeFacet,o=()=>s.turn(a);window.addEventListener("hashchange",o),e.Turn.activeFacet.onStop((()=>{window.removeEventListener("hashchange",o)})),a(),e.Turn.active.assertDataflow((()=>({target:t,assertion:f(n.value)}))),e.Turn.active.assertDataflow((()=>({target:t,assertion:e.Observe({pattern:e.QuasiValue.finish(e.QuasiValue.ctor(f,e.QuasiValue.bind(e.QuasiValue._))),observer:e.Turn.ref({message:e=>{if(Array.isArray(e)){if("string"!=typeof e[0])return;const t=e[0];window.location.hash=t}}})})})))})(t)}))}(t)}class g{get node(){return this._node}constructor(t,n){let a;this._node=null,this.callbacks=new Map,a=void 0===n?"function"==typeof t?t:()=>[t]:E(t,n),this.facet=r.activeFacet;const s=this.facet.actor.atExit((()=>this.node.remove()));e.Turn.activeFacet.onStop((()=>{this.node.remove(),s()}));const o=v();e.Turn.active._dataflow((()=>{const e=a(o);if(1!==e.length)throw new Error("@syndicate-lang/html2: Expected exactly one node from template");if(null===this._node)this._node=e[0];else if(this._node!==e[0])throw new Error("@syndicate-lang/html2: Node generator is not stable")}))}get _nodeAsParent(){return this._node&&"querySelector"in this._node?this._node:null}get parent(){return this.node.parentNode}set parent(e){this.setParent(e)}setParent(e,t=document){return"string"==typeof e&&(e=t.querySelector(e)),this.node.parentNode!==e&&(null===e?this.node.remove():e.appendChild(this.node)),this}querySelector(e,t){var n;const r=null===(n=this._nodeAsParent)||void 0===n?void 0:n.querySelector(e);return r?new(null!=t?t:g)(r):null}querySelectorAll(e,t){var n;const r=null===(n=this._nodeAsParent)||void 0===n?void 0:n.querySelectorAll(e),a=[];return r&&r.forEach((e=>a.push(new(null!=t?t:g)(e)))),a}on(e,t){return this.addEventListener(e,t),this}once(e,t){return this.addEventListener(e,t,{once:!0}),this}off(e,t){return this.removeEventListener(e,t),this}addEventListener(e,t,n){if(null===t)return;let r=this.callbacks.get(e);if(void 0===r)r=new Map,this.callbacks.set(e,r);else if(r.has(t))return;const a={wrapped:"function"==typeof t?e=>this.facet.turn((()=>t(e))):e=>this.facet.turn((()=>t.handleEvent(e))),options:n};r.set(t,a),this.node.addEventListener(e,a.wrapped,n)}dispatchEvent(e){return this.node.dispatchEvent(e)}removeEventListener(e,t,n){if(null===t)return;const r=this.callbacks.get(e);if(void 0===r)return;const a=r.get(t);void 0!==a&&(this.node.removeEventListener(e,a.wrapped,n),r.delete(t),0===r.size&&this.callbacks.delete(e))}}class b extends g{constructor(t,n,r){super(t,n);const a="string"==typeof n?n:"string"==typeof r?r:"change",s=e.Turn.active.field("","value");this._value=s;const o=e.Turn.active.field(NaN,"valueAsNumber");this._valueAsNumber=o,"value"in this.node&&(this.on(a,(()=>this.readValues())),this.readValues(),e.Turn.active._dataflow((()=>{this.valueAsNumber=this._valueAsNumber.value})),e.Turn.active._dataflow((()=>{this.value=this._value.value})))}readValues(){var e,t;const n=this.node;this.suppressCycleWarning(),this._value.value=null!==(e=n.value)&&void 0!==e?e:"",this._valueAsNumber.value=null!==(t=n.valueAsNumber)&&void 0!==t?t:NaN}get value(){return this._value.value}set value(e){this.node.value=e,this._value.value=e}get valueAsNumber(){return this._valueAsNumber.value}set valueAsNumber(e){this.node.value=Number.isNaN(e)?"":""+e,this._valueAsNumber.value=e}suppressCycleWarning(){this._value.suppressCycleWarning(),this._valueAsNumber.suppressCycleWarning()}}function E(e,t){const n="string"==typeof e?document.querySelector(e):e;if(null===n)throw new Error("Cannot find template: "+e);const r=`return t => t\`${n.innerHTML.trim().split("`").join("\\`")}\``,a=Object.entries(t),s=a.map((e=>e[0])),o=a.map((e=>e[1]));return new Function(...s,r)(...o)}export{f as LocationHash,b as ValueWidget,g as Widget,m as boot,v as template,E as templateGenerator};
import*as e from"@syndicate-lang/core";import{randomId as t,Dataspace as n,Turn as r}from"@syndicate-lang/core";const a=t(8,!0),s=new RegExp(`x-${a}-(\\d+)-${a}-x`),o=new RegExp(`x-${a}-(\\d+)-${a}-x`,"g");function i(e){let t=null,n=0;const r=[],a=[];for(;null!==(t=o.exec(e));)r.push(e.substring(n,t.index)),a.push(parseInt(t[1],10)),n=o.lastIndex;return r.push(e.substring(n)),{constantParts:r,placeholders:a}}function l(e,t){const n=[];return function e(r){if(Array.isArray(r))r.forEach(e);else switch(typeof r){case"string":n.push(t?r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"):r);break;case"number":n.push(""+r);break;default:throw new Error("Cannot render Node in attribute context")}}(e),n}function c(e){return(t,n)=>{var r;!function e(t){var r;if(Array.isArray(t))t.forEach(e);else{let e;switch(typeof t){case"string":e=document.createTextNode(t);break;case"number":e=document.createTextNode(""+t);break;case"object":if(null!==t&&"nodeType"in t){e=t;break}default:{let n;try{n=""+t}catch(e){n=t.toString()}e=document.createTextNode(`<ERROR: invalid HtmlFragment: ${n}>`);break}}null===(r=n.parentNode)||void 0===r||r.insertBefore(e,n)}}(t[e]),null===(r=n.parentNode)||void 0===r||r.removeChild(n)}}function u(e){return(t,n)=>{const r=document.createElement("template");r.innerHTML=`<x-dummy ${l(t[e],!1).join("")}></x-dummy>`,Array.from(r.content.firstElementChild.attributes).forEach((e=>n.setAttribute(e.name,e.value)))}}function h(e,t,n){return(r,a)=>{const s=[t[0]];n.forEach(((e,n)=>{s.push(...l(r[e],!1)),s.push(t[n+1])})),a.setAttribute(e,s.join(""))}}class d{constructor(e){this.template=document.createElement("template"),this.placeholderActions=[];const t=[];e.raw.forEach(((e,n)=>{n>0&&t.push(`x-${a}-${n-1}-${a}-x`),t.push(e)})),this.template.innerHTML=t.join(""),this.indexPlaceholders()}indexTextNode(e,t){var n,r;const{constantParts:a,placeholders:s}=i(null!==(n=e.textContent)&&void 0!==n?n:"");a.forEach(((t,n)=>{var r,a;if(n>0){const t=document.createElement("x-placeholder");null===(r=e.parentNode)||void 0===r||r.insertBefore(t,e)}null===(a=e.parentNode)||void 0===a||a.insertBefore(document.createTextNode(t),e)}));const o=e.nextSibling;return null===(r=e.parentNode)||void 0===r||r.removeChild(e),s.forEach(((e,n)=>{const r=t.slice();r[r.length-1]=2*n+1,this.placeholderActions.push({path:r,action:c(e)})})),t[t.length-1]+=a.length+s.length,o}indexElement(e,t){const n=[];for(let t=0;t<e.attributes.length;t++){const r=e.attributes[t],a=r.name,o=a.match(s);if(null!==o){e.removeAttributeNode(r),t--;const a=parseInt(o[1],10);n.push(u(a))}else{const{constantParts:e,placeholders:t}=i(r.value);1!==e.length&&n.push(h(a,e,t))}}n.length&&this.placeholderActions.push({path:t.slice(),action:(e,t)=>n.forEach((n=>n(e,t)))})}indexPlaceholders(){const e=[],t=n=>{e.push(0);let r=n.firstChild;for(;null!==r;){const n=r;switch(n.nodeType){case Node.TEXT_NODE:r=this.indexTextNode(n,e);break;case Node.ELEMENT_NODE:{const a=n;this.indexElement(a,e),t(a),r=a.nextSibling,e[e.length-1]++;break}default:r=n.nextSibling,e[e.length-1]++}}e.pop()};t(this.template.content)}clone(){return Array.from(this.template.cloneNode(!0).content.childNodes)}update(e,t){this.placeholderActions.forEach((({path:n,action:r})=>{r(t,function(e,t){let n=e[t[0]];for(let e=1;e<t.length;e++)n=n.childNodes[t[e]];return n}(e,n))}))}}const p=new WeakMap;function v(){let e=null;return(t,...n)=>{let r=p.get(t);return void 0===r&&(r=new d(t),p.set(t,r)),null===e&&(e=r.clone()),r.update(e,n),e}}const f=e.Record.makeConstructor()(Symbol.for("LocationHash"),["hash"]);function m(t=n.local){!function(t){e.Dataspace._spawn((()=>{e.Turn.activeFacet.actor.name="LocationHashTracker",(t=>{const n=e.Turn.active.field("/","hashValue"),a=()=>{var e=decodeURIComponent(window.location.hash);e.length&&"#"===e[0]&&(e=e.slice(1)),n.value=e||"/"},s=r.activeFacet,o=()=>s.turn(a);window.addEventListener("hashchange",o),e.Turn.activeFacet.onStop((()=>{window.removeEventListener("hashchange",o)})),a(),e.Turn.active.assertDataflow((()=>({target:t(),assertion:f(n.value)}))),e.Turn.active.assertDataflow((()=>({target:t(),assertion:e.Observe({pattern:e.QuasiValue.finish(e.QuasiValue.ctor(f,e.QuasiValue.bind(e.QuasiValue._))),observer:e.Turn.ref({message:e=>{if(Array.isArray(e)){if("string"!=typeof e[0])return;const t=e[0];window.location.hash=t}}})})})))})((()=>t))}))}(t)}class g{get node(){return this._node}constructor(t,n){let a;this._node=null,this.callbacks=new Map,a=void 0===n?"function"==typeof t?t:()=>[t]:E(t,n),this.facet=r.activeFacet;const s=this.facet.actor.atExit((()=>this.node.remove()));e.Turn.activeFacet.onStop((()=>{this.node.remove(),s()}));const o=v();e.Turn.active._dataflow((()=>{const e=a(o);if(1!==e.length)throw new Error("@syndicate-lang/html2: Expected exactly one node from template");if(null===this._node)this._node=e[0];else if(this._node!==e[0])throw new Error("@syndicate-lang/html2: Node generator is not stable")}))}get _nodeAsParent(){return this._node&&"querySelector"in this._node?this._node:null}get parent(){return this.node.parentNode}set parent(e){this.setParent(e)}setParent(e,t=document){return"string"==typeof e&&(e=t.querySelector(e)),this.node.parentNode!==e&&(null===e?this.node.remove():e.appendChild(this.node)),this}querySelector(e,t){var n;const r=null===(n=this._nodeAsParent)||void 0===n?void 0:n.querySelector(e);return r?new(null!=t?t:g)(r):null}querySelectorAll(e,t){var n;const r=null===(n=this._nodeAsParent)||void 0===n?void 0:n.querySelectorAll(e),a=[];return r&&r.forEach((e=>a.push(new(null!=t?t:g)(e)))),a}on(e,t){return this.addEventListener(e,t),this}once(e,t){return this.addEventListener(e,t,{once:!0}),this}off(e,t){return this.removeEventListener(e,t),this}addEventListener(e,t,n){if(null===t)return;let r=this.callbacks.get(e);if(void 0===r)r=new Map,this.callbacks.set(e,r);else if(r.has(t))return;const a={wrapped:"function"==typeof t?e=>this.facet.turn((()=>t(e))):e=>this.facet.turn((()=>t.handleEvent(e))),options:n};r.set(t,a),this.node.addEventListener(e,a.wrapped,n)}dispatchEvent(e){return this.node.dispatchEvent(e)}removeEventListener(e,t,n){if(null===t)return;const r=this.callbacks.get(e);if(void 0===r)return;const a=r.get(t);void 0!==a&&(this.node.removeEventListener(e,a.wrapped,n),r.delete(t),0===r.size&&this.callbacks.delete(e))}}class b extends g{constructor(t,n,r){super(t,n);const a="string"==typeof n?n:"string"==typeof r?r:"change",s=e.Turn.active.field("","value");this._value=s;const o=e.Turn.active.field(NaN,"valueAsNumber");this._valueAsNumber=o,"value"in this.node&&(this.on(a,(()=>this.readValues())),this.readValues(),e.Turn.active._dataflow((()=>{this.valueAsNumber=this._valueAsNumber.value})),e.Turn.active._dataflow((()=>{this.value=this._value.value})))}readValues(){var e,t;const n=this.node;this.suppressCycleWarning(),this._value.value=null!==(e=n.value)&&void 0!==e?e:"",this._valueAsNumber.value=null!==(t=n.valueAsNumber)&&void 0!==t?t:NaN}get value(){return this._value.value}set value(e){this.node.value=e,this._value.value=e}get valueAsNumber(){return this._valueAsNumber.value}set valueAsNumber(e){this.node.value=Number.isNaN(e)?"":""+e,this._valueAsNumber.value=e}suppressCycleWarning(){this._value.suppressCycleWarning(),this._valueAsNumber.suppressCycleWarning()}}function E(e,t){const n="string"==typeof e?document.querySelector(e):e;if(null===n)throw new Error("Cannot find template: "+e);const r=`return t => t\`${n.innerHTML.trim().split("`").join("\\`")}\``,a=Object.entries(t),s=a.map((e=>e[0])),o=a.map((e=>e[1]));return new Function(...s,r)(...o)}export{f as LocationHash,b as ValueWidget,g as Widget,m as boot,v as template,E as templateGenerator};
//# sourceMappingURL=syndicate-html2.es6.min.js.map

@@ -455,4 +455,4 @@ (function (global, factory) {

loadHash();
__SYNDICATE____namespace.Turn.active.assertDataflow(() => ({ target: currentSyndicateTarget, assertion: LocationHash(hashValue.value) }));
__SYNDICATE____namespace.Turn.active.assertDataflow(() => ({ target: currentSyndicateTarget, assertion: __SYNDICATE____namespace.Observe({
__SYNDICATE____namespace.Turn.active.assertDataflow(() => ({ target: currentSyndicateTarget(), assertion: LocationHash(hashValue.value) }));
__SYNDICATE____namespace.Turn.active.assertDataflow(() => ({ target: currentSyndicateTarget(), assertion: __SYNDICATE____namespace.Observe({
pattern: __SYNDICATE____namespace.QuasiValue.finish((__SYNDICATE____namespace.QuasiValue.ctor(LocationHash, (__SYNDICATE____namespace.QuasiValue.bind((__SYNDICATE____namespace.QuasiValue._)))))),

@@ -470,3 +470,3 @@ observer: __SYNDICATE____namespace.Turn.ref({

}) }));
})(ds));
})(() => (ds)));
});

@@ -473,0 +473,0 @@ }

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@syndicate-lang/core")):"function"==typeof define&&define.amd?define(["exports","@syndicate-lang/core"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SyndicateHtml2={},e.Syndicate)}(this,(function(e,t){"use strict";function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var r=n(t);const a=t.randomId(8,!0),o=new RegExp(`x-${a}-(\\d+)-${a}-x`),s=new RegExp(`x-${a}-(\\d+)-${a}-x`,"g");function i(e){let t=null,n=0;const r=[],a=[];for(;null!==(t=s.exec(e));)r.push(e.substring(n,t.index)),a.push(parseInt(t[1],10)),n=s.lastIndex;return r.push(e.substring(n)),{constantParts:r,placeholders:a}}function l(e,t){const n=[];return function e(r){if(Array.isArray(r))r.forEach(e);else switch(typeof r){case"string":n.push(t?r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"):r);break;case"number":n.push(""+r);break;default:throw new Error("Cannot render Node in attribute context")}}(e),n}function u(e){return(t,n)=>{var r;!function e(t){var r;if(Array.isArray(t))t.forEach(e);else{let e;switch(typeof t){case"string":e=document.createTextNode(t);break;case"number":e=document.createTextNode(""+t);break;case"object":if(null!==t&&"nodeType"in t){e=t;break}default:{let n;try{n=""+t}catch(e){n=t.toString()}e=document.createTextNode(`<ERROR: invalid HtmlFragment: ${n}>`);break}}null===(r=n.parentNode)||void 0===r||r.insertBefore(e,n)}}(t[e]),null===(r=n.parentNode)||void 0===r||r.removeChild(n)}}function c(e){return(t,n)=>{const r=document.createElement("template");r.innerHTML=`<x-dummy ${l(t[e],!1).join("")}></x-dummy>`,Array.from(r.content.firstElementChild.attributes).forEach((e=>n.setAttribute(e.name,e.value)))}}function d(e,t,n){return(r,a)=>{const o=[t[0]];n.forEach(((e,n)=>{o.push(...l(r[e],!1)),o.push(t[n+1])})),a.setAttribute(e,o.join(""))}}class h{constructor(e){this.template=document.createElement("template"),this.placeholderActions=[];const t=[];e.raw.forEach(((e,n)=>{n>0&&t.push(`x-${a}-${n-1}-${a}-x`),t.push(e)})),this.template.innerHTML=t.join(""),this.indexPlaceholders()}indexTextNode(e,t){var n,r;const{constantParts:a,placeholders:o}=i(null!==(n=e.textContent)&&void 0!==n?n:"");a.forEach(((t,n)=>{var r,a;if(n>0){const t=document.createElement("x-placeholder");null===(r=e.parentNode)||void 0===r||r.insertBefore(t,e)}null===(a=e.parentNode)||void 0===a||a.insertBefore(document.createTextNode(t),e)}));const s=e.nextSibling;return null===(r=e.parentNode)||void 0===r||r.removeChild(e),o.forEach(((e,n)=>{const r=t.slice();r[r.length-1]=2*n+1,this.placeholderActions.push({path:r,action:u(e)})})),t[t.length-1]+=a.length+o.length,s}indexElement(e,t){const n=[];for(let t=0;t<e.attributes.length;t++){const r=e.attributes[t],a=r.name,s=a.match(o);if(null!==s){e.removeAttributeNode(r),t--;const a=parseInt(s[1],10);n.push(c(a))}else{const{constantParts:e,placeholders:t}=i(r.value);1!==e.length&&n.push(d(a,e,t))}}n.length&&this.placeholderActions.push({path:t.slice(),action:(e,t)=>n.forEach((n=>n(e,t)))})}indexPlaceholders(){const e=[],t=n=>{e.push(0);let r=n.firstChild;for(;null!==r;){const n=r;switch(n.nodeType){case Node.TEXT_NODE:r=this.indexTextNode(n,e);break;case Node.ELEMENT_NODE:{const a=n;this.indexElement(a,e),t(a),r=a.nextSibling,e[e.length-1]++;break}default:r=n.nextSibling,e[e.length-1]++}}e.pop()};t(this.template.content)}clone(){return Array.from(this.template.cloneNode(!0).content.childNodes)}update(e,t){this.placeholderActions.forEach((({path:n,action:r})=>{r(t,function(e,t){let n=e[t[0]];for(let e=1;e<t.length;e++)n=n.childNodes[t[e]];return n}(e,n))}))}}const p=new WeakMap;function f(){let e=null;return(t,...n)=>{let r=p.get(t);return void 0===r&&(r=new h(t),p.set(t,r)),null===e&&(e=r.clone()),r.update(e,n),e}}const v=r.Record.makeConstructor()(Symbol.for("LocationHash"),["hash"]);class m{get node(){return this._node}constructor(e,n){let a;this._node=null,this.callbacks=new Map,a=void 0===n?"function"==typeof e?e:()=>[e]:g(e,n),this.facet=t.Turn.activeFacet;const o=this.facet.actor.atExit((()=>this.node.remove()));r.Turn.activeFacet.onStop((()=>{this.node.remove(),o()}));const s=f();r.Turn.active._dataflow((()=>{const e=a(s);if(1!==e.length)throw new Error("@syndicate-lang/html2: Expected exactly one node from template");if(null===this._node)this._node=e[0];else if(this._node!==e[0])throw new Error("@syndicate-lang/html2: Node generator is not stable")}))}get _nodeAsParent(){return this._node&&"querySelector"in this._node?this._node:null}get parent(){return this.node.parentNode}set parent(e){this.setParent(e)}setParent(e,t=document){return"string"==typeof e&&(e=t.querySelector(e)),this.node.parentNode!==e&&(null===e?this.node.remove():e.appendChild(this.node)),this}querySelector(e,t){var n;const r=null===(n=this._nodeAsParent)||void 0===n?void 0:n.querySelector(e);return r?new(null!=t?t:m)(r):null}querySelectorAll(e,t){var n;const r=null===(n=this._nodeAsParent)||void 0===n?void 0:n.querySelectorAll(e),a=[];return r&&r.forEach((e=>a.push(new(null!=t?t:m)(e)))),a}on(e,t){return this.addEventListener(e,t),this}once(e,t){return this.addEventListener(e,t,{once:!0}),this}off(e,t){return this.removeEventListener(e,t),this}addEventListener(e,t,n){if(null===t)return;let r=this.callbacks.get(e);if(void 0===r)r=new Map,this.callbacks.set(e,r);else if(r.has(t))return;const a={wrapped:"function"==typeof t?e=>this.facet.turn((()=>t(e))):e=>this.facet.turn((()=>t.handleEvent(e))),options:n};r.set(t,a),this.node.addEventListener(e,a.wrapped,n)}dispatchEvent(e){return this.node.dispatchEvent(e)}removeEventListener(e,t,n){if(null===t)return;const r=this.callbacks.get(e);if(void 0===r)return;const a=r.get(t);void 0!==a&&(this.node.removeEventListener(e,a.wrapped,n),r.delete(t),0===r.size&&this.callbacks.delete(e))}}function g(e,t){const n="string"==typeof e?document.querySelector(e):e;if(null===n)throw new Error("Cannot find template: "+e);const r=`return t => t\`${n.innerHTML.trim().split("`").join("\\`")}\``,a=Object.entries(t),o=a.map((e=>e[0])),s=a.map((e=>e[1]));return new Function(...o,r)(...s)}e.LocationHash=v,e.ValueWidget=class extends m{constructor(e,t,n){super(e,t);const a="string"==typeof t?t:"string"==typeof n?n:"change",o=r.Turn.active.field("","value");this._value=o;const s=r.Turn.active.field(NaN,"valueAsNumber");this._valueAsNumber=s,"value"in this.node&&(this.on(a,(()=>this.readValues())),this.readValues(),r.Turn.active._dataflow((()=>{this.valueAsNumber=this._valueAsNumber.value})),r.Turn.active._dataflow((()=>{this.value=this._value.value})))}readValues(){var e,t;const n=this.node;this.suppressCycleWarning(),this._value.value=null!==(e=n.value)&&void 0!==e?e:"",this._valueAsNumber.value=null!==(t=n.valueAsNumber)&&void 0!==t?t:NaN}get value(){return this._value.value}set value(e){this.node.value=e,this._value.value=e}get valueAsNumber(){return this._valueAsNumber.value}set valueAsNumber(e){this.node.value=Number.isNaN(e)?"":""+e,this._valueAsNumber.value=e}suppressCycleWarning(){this._value.suppressCycleWarning(),this._valueAsNumber.suppressCycleWarning()}},e.Widget=m,e.boot=function(e=t.Dataspace.local){!function(e){r.Dataspace._spawn((()=>{r.Turn.activeFacet.actor.name="LocationHashTracker",(e=>{const n=r.Turn.active.field("/","hashValue"),a=()=>{var e=decodeURIComponent(window.location.hash);e.length&&"#"===e[0]&&(e=e.slice(1)),n.value=e||"/"},o=t.Turn.activeFacet,s=()=>o.turn(a);window.addEventListener("hashchange",s),r.Turn.activeFacet.onStop((()=>{window.removeEventListener("hashchange",s)})),a(),r.Turn.active.assertDataflow((()=>({target:e,assertion:v(n.value)}))),r.Turn.active.assertDataflow((()=>({target:e,assertion:r.Observe({pattern:r.QuasiValue.finish(r.QuasiValue.ctor(v,r.QuasiValue.bind(r.QuasiValue._))),observer:r.Turn.ref({message:e=>{if(Array.isArray(e)){if("string"!=typeof e[0])return;const t=e[0];window.location.hash=t}}})})})))})(e)}))}(e)},e.template=f,e.templateGenerator=g,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@syndicate-lang/core")):"function"==typeof define&&define.amd?define(["exports","@syndicate-lang/core"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SyndicateHtml2={},e.Syndicate)}(this,(function(e,t){"use strict";function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var r=n(t);const a=t.randomId(8,!0),o=new RegExp(`x-${a}-(\\d+)-${a}-x`),s=new RegExp(`x-${a}-(\\d+)-${a}-x`,"g");function i(e){let t=null,n=0;const r=[],a=[];for(;null!==(t=s.exec(e));)r.push(e.substring(n,t.index)),a.push(parseInt(t[1],10)),n=s.lastIndex;return r.push(e.substring(n)),{constantParts:r,placeholders:a}}function l(e,t){const n=[];return function e(r){if(Array.isArray(r))r.forEach(e);else switch(typeof r){case"string":n.push(t?r.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"):r);break;case"number":n.push(""+r);break;default:throw new Error("Cannot render Node in attribute context")}}(e),n}function u(e){return(t,n)=>{var r;!function e(t){var r;if(Array.isArray(t))t.forEach(e);else{let e;switch(typeof t){case"string":e=document.createTextNode(t);break;case"number":e=document.createTextNode(""+t);break;case"object":if(null!==t&&"nodeType"in t){e=t;break}default:{let n;try{n=""+t}catch(e){n=t.toString()}e=document.createTextNode(`<ERROR: invalid HtmlFragment: ${n}>`);break}}null===(r=n.parentNode)||void 0===r||r.insertBefore(e,n)}}(t[e]),null===(r=n.parentNode)||void 0===r||r.removeChild(n)}}function c(e){return(t,n)=>{const r=document.createElement("template");r.innerHTML=`<x-dummy ${l(t[e],!1).join("")}></x-dummy>`,Array.from(r.content.firstElementChild.attributes).forEach((e=>n.setAttribute(e.name,e.value)))}}function d(e,t,n){return(r,a)=>{const o=[t[0]];n.forEach(((e,n)=>{o.push(...l(r[e],!1)),o.push(t[n+1])})),a.setAttribute(e,o.join(""))}}class h{constructor(e){this.template=document.createElement("template"),this.placeholderActions=[];const t=[];e.raw.forEach(((e,n)=>{n>0&&t.push(`x-${a}-${n-1}-${a}-x`),t.push(e)})),this.template.innerHTML=t.join(""),this.indexPlaceholders()}indexTextNode(e,t){var n,r;const{constantParts:a,placeholders:o}=i(null!==(n=e.textContent)&&void 0!==n?n:"");a.forEach(((t,n)=>{var r,a;if(n>0){const t=document.createElement("x-placeholder");null===(r=e.parentNode)||void 0===r||r.insertBefore(t,e)}null===(a=e.parentNode)||void 0===a||a.insertBefore(document.createTextNode(t),e)}));const s=e.nextSibling;return null===(r=e.parentNode)||void 0===r||r.removeChild(e),o.forEach(((e,n)=>{const r=t.slice();r[r.length-1]=2*n+1,this.placeholderActions.push({path:r,action:u(e)})})),t[t.length-1]+=a.length+o.length,s}indexElement(e,t){const n=[];for(let t=0;t<e.attributes.length;t++){const r=e.attributes[t],a=r.name,s=a.match(o);if(null!==s){e.removeAttributeNode(r),t--;const a=parseInt(s[1],10);n.push(c(a))}else{const{constantParts:e,placeholders:t}=i(r.value);1!==e.length&&n.push(d(a,e,t))}}n.length&&this.placeholderActions.push({path:t.slice(),action:(e,t)=>n.forEach((n=>n(e,t)))})}indexPlaceholders(){const e=[],t=n=>{e.push(0);let r=n.firstChild;for(;null!==r;){const n=r;switch(n.nodeType){case Node.TEXT_NODE:r=this.indexTextNode(n,e);break;case Node.ELEMENT_NODE:{const a=n;this.indexElement(a,e),t(a),r=a.nextSibling,e[e.length-1]++;break}default:r=n.nextSibling,e[e.length-1]++}}e.pop()};t(this.template.content)}clone(){return Array.from(this.template.cloneNode(!0).content.childNodes)}update(e,t){this.placeholderActions.forEach((({path:n,action:r})=>{r(t,function(e,t){let n=e[t[0]];for(let e=1;e<t.length;e++)n=n.childNodes[t[e]];return n}(e,n))}))}}const p=new WeakMap;function f(){let e=null;return(t,...n)=>{let r=p.get(t);return void 0===r&&(r=new h(t),p.set(t,r)),null===e&&(e=r.clone()),r.update(e,n),e}}const v=r.Record.makeConstructor()(Symbol.for("LocationHash"),["hash"]);class m{get node(){return this._node}constructor(e,n){let a;this._node=null,this.callbacks=new Map,a=void 0===n?"function"==typeof e?e:()=>[e]:g(e,n),this.facet=t.Turn.activeFacet;const o=this.facet.actor.atExit((()=>this.node.remove()));r.Turn.activeFacet.onStop((()=>{this.node.remove(),o()}));const s=f();r.Turn.active._dataflow((()=>{const e=a(s);if(1!==e.length)throw new Error("@syndicate-lang/html2: Expected exactly one node from template");if(null===this._node)this._node=e[0];else if(this._node!==e[0])throw new Error("@syndicate-lang/html2: Node generator is not stable")}))}get _nodeAsParent(){return this._node&&"querySelector"in this._node?this._node:null}get parent(){return this.node.parentNode}set parent(e){this.setParent(e)}setParent(e,t=document){return"string"==typeof e&&(e=t.querySelector(e)),this.node.parentNode!==e&&(null===e?this.node.remove():e.appendChild(this.node)),this}querySelector(e,t){var n;const r=null===(n=this._nodeAsParent)||void 0===n?void 0:n.querySelector(e);return r?new(null!=t?t:m)(r):null}querySelectorAll(e,t){var n;const r=null===(n=this._nodeAsParent)||void 0===n?void 0:n.querySelectorAll(e),a=[];return r&&r.forEach((e=>a.push(new(null!=t?t:m)(e)))),a}on(e,t){return this.addEventListener(e,t),this}once(e,t){return this.addEventListener(e,t,{once:!0}),this}off(e,t){return this.removeEventListener(e,t),this}addEventListener(e,t,n){if(null===t)return;let r=this.callbacks.get(e);if(void 0===r)r=new Map,this.callbacks.set(e,r);else if(r.has(t))return;const a={wrapped:"function"==typeof t?e=>this.facet.turn((()=>t(e))):e=>this.facet.turn((()=>t.handleEvent(e))),options:n};r.set(t,a),this.node.addEventListener(e,a.wrapped,n)}dispatchEvent(e){return this.node.dispatchEvent(e)}removeEventListener(e,t,n){if(null===t)return;const r=this.callbacks.get(e);if(void 0===r)return;const a=r.get(t);void 0!==a&&(this.node.removeEventListener(e,a.wrapped,n),r.delete(t),0===r.size&&this.callbacks.delete(e))}}function g(e,t){const n="string"==typeof e?document.querySelector(e):e;if(null===n)throw new Error("Cannot find template: "+e);const r=`return t => t\`${n.innerHTML.trim().split("`").join("\\`")}\``,a=Object.entries(t),o=a.map((e=>e[0])),s=a.map((e=>e[1]));return new Function(...o,r)(...s)}e.LocationHash=v,e.ValueWidget=class extends m{constructor(e,t,n){super(e,t);const a="string"==typeof t?t:"string"==typeof n?n:"change",o=r.Turn.active.field("","value");this._value=o;const s=r.Turn.active.field(NaN,"valueAsNumber");this._valueAsNumber=s,"value"in this.node&&(this.on(a,(()=>this.readValues())),this.readValues(),r.Turn.active._dataflow((()=>{this.valueAsNumber=this._valueAsNumber.value})),r.Turn.active._dataflow((()=>{this.value=this._value.value})))}readValues(){var e,t;const n=this.node;this.suppressCycleWarning(),this._value.value=null!==(e=n.value)&&void 0!==e?e:"",this._valueAsNumber.value=null!==(t=n.valueAsNumber)&&void 0!==t?t:NaN}get value(){return this._value.value}set value(e){this.node.value=e,this._value.value=e}get valueAsNumber(){return this._valueAsNumber.value}set valueAsNumber(e){this.node.value=Number.isNaN(e)?"":""+e,this._valueAsNumber.value=e}suppressCycleWarning(){this._value.suppressCycleWarning(),this._valueAsNumber.suppressCycleWarning()}},e.Widget=m,e.boot=function(e=t.Dataspace.local){!function(e){r.Dataspace._spawn((()=>{r.Turn.activeFacet.actor.name="LocationHashTracker",(e=>{const n=r.Turn.active.field("/","hashValue"),a=()=>{var e=decodeURIComponent(window.location.hash);e.length&&"#"===e[0]&&(e=e.slice(1)),n.value=e||"/"},o=t.Turn.activeFacet,s=()=>o.turn(a);window.addEventListener("hashchange",s),r.Turn.activeFacet.onStop((()=>{window.removeEventListener("hashchange",s)})),a(),r.Turn.active.assertDataflow((()=>({target:e(),assertion:v(n.value)}))),r.Turn.active.assertDataflow((()=>({target:e(),assertion:r.Observe({pattern:r.QuasiValue.finish(r.QuasiValue.ctor(v,r.QuasiValue.bind(r.QuasiValue._))),observer:r.Turn.ref({message:e=>{if(Array.isArray(e)){if("string"!=typeof e[0])return;const t=e[0];window.location.hash=t}}})})})))})((()=>e))}))}(e)},e.template=f,e.templateGenerator=g,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=syndicate-html2.min.js.map

@@ -201,4 +201,4 @@ import * as __SYNDICATE__ from "@syndicate-lang/core";

loadHash();
__SYNDICATE__.Turn.active.assertDataflow(() => ({ target: currentSyndicateTarget, assertion: LocationHash(hashValue.value) }));
__SYNDICATE__.Turn.active.assertDataflow(() => ({ target: currentSyndicateTarget, assertion: __SYNDICATE__.Observe({
__SYNDICATE__.Turn.active.assertDataflow(() => ({ target: currentSyndicateTarget(), assertion: LocationHash(hashValue.value) }));
__SYNDICATE__.Turn.active.assertDataflow(() => ({ target: currentSyndicateTarget(), assertion: __SYNDICATE__.Observe({
pattern: __SYNDICATE__.QuasiValue.finish((__SYNDICATE__.QuasiValue.ctor(LocationHash, (__SYNDICATE__.QuasiValue.bind((__SYNDICATE__.QuasiValue._)))))),

@@ -216,3 +216,3 @@ observer: __SYNDICATE__.Turn.ref({

}) }));
})(ds));
})(() => (ds)));
});

@@ -219,0 +219,0 @@ }

{
"name": "@syndicate-lang/html2",
"version": "0.35.5",
"version": "0.35.6",
"description": "DOM/HTML UI for Syndicate/JS",

@@ -28,9 +28,9 @@ "homepage": "https://github.com/syndicate-lang/syndicate-js/tree/main/packages/html2",

"dependencies": {
"@syndicate-lang/core": "^0.34.5"
"@syndicate-lang/core": "^0.34.6"
},
"devDependencies": {
"@syndicate-lang/ts-plugin": "^0.36.5",
"@syndicate-lang/tsc": "^0.36.5"
"@syndicate-lang/ts-plugin": "^0.36.6",
"@syndicate-lang/tsc": "^0.36.6"
},
"gitHead": "7a34dc9716e898b217029485a6dda3e0799ade64"
"gitHead": "d008cc3f948bb26856c9ba987d86cd363019f6f2"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc