@webto-id/variant-check 0.1.9 → 0.1.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.
Files changed (3) hide show
  1. package/dist/cli.js +36 -13
  2. package/dist/index.js +36 -13
  3. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -947,9 +947,9 @@ var WV_EFFECT_CSS = `@media (prefers-reduced-motion: no-preference){
947
947
  }`;
948
948
  var WV_EFFECT_JS = `(function(){
949
949
  if(!('IntersectionObserver' in window))return;
950
- var els=document.querySelectorAll('[data-wv-effect]');
951
- if(!els.length)return;
952
950
  if(window.matchMedia('(prefers-reduced-motion: reduce)').matches)return;
951
+ if(window.__wvFx)return;
952
+ window.__wvFx=1;
953
953
  document.documentElement.classList.add('wv-js');
954
954
  function num(el,attr,def){var v=parseInt(el.getAttribute(attr)||'',10);return isFinite(v)?v:def;}
955
955
  function timing(el){
@@ -957,8 +957,8 @@ function timing(el){
957
957
  var ms=num(el,'data-wv-duration',0);if(ms>=100)el.style.transitionDuration=ms+'ms';
958
958
  }
959
959
  function counter(el){
960
- var txt=el.textContent||'';var m=txt.match(/-?\\d[\\d.,]*/);if(!m)return;
961
- var target=parseFloat(m[0].replace(/[.,](?=\\d{3}(\\D|$))/g,''));if(!isFinite(target))return;
960
+ var txt=el.textContent||'';var m=txt.match(/-?d[d.,]*/);if(!m)return;
961
+ var target=parseFloat(m[0].replace(/[.,](?=d{3}(D|$))/g,''));if(!isFinite(target))return;
962
962
  var pre=txt.slice(0,m.index),post=txt.slice(m.index+m[0].length);
963
963
  var dur=Math.min(Math.max(num(el,'data-wv-duration',1200),100),5000),t0=null;
964
964
  function tick(t){
@@ -969,7 +969,7 @@ function counter(el){
969
969
  }
970
970
  requestAnimationFrame(tick);
971
971
  }
972
- var para=[];
972
+ var para=[],paraBound=false;
973
973
  function onScroll(){
974
974
  for(var i=0;i<para.length;i++){
975
975
  var el=para[i],r=el.getBoundingClientRect();
@@ -982,6 +982,11 @@ function onScroll(){
982
982
  }
983
983
  var ticking=false;
984
984
  function onScrollRaf(){if(ticking)return;ticking=true;requestAnimationFrame(function(){ticking=false;onScroll();});}
985
+ function bindParallax(el){
986
+ para.push(el);
987
+ if(!paraBound){paraBound=true;window.addEventListener('scroll',onScrollRaf,{passive:true});window.addEventListener('resize',onScrollRaf,{passive:true});}
988
+ onScroll();
989
+ }
985
990
  var io=new IntersectionObserver(function(entries){
986
991
  for(var i=0;i<entries.length;i++){
987
992
  var en=entries[i];if(!en.isIntersecting)continue;
@@ -996,14 +1001,29 @@ var io=new IntersectionObserver(function(entries){
996
1001
  el.classList.add('wv-in');
997
1002
  }
998
1003
  },{threshold:0.15,rootMargin:'0px 0px -5% 0px'});
999
- for(var i=0;i<els.length;i++){
1000
- var el=els[i],fx=el.getAttribute('data-wv-effect');
1001
- if(fx==='zoom-hover')continue;
1002
- if(fx==='parallax-soft'){para.push(el);continue;}
1003
- timing(el);
1004
- io.observe(el);
1005
- }
1006
- if(para.length){window.addEventListener('scroll',onScrollRaf,{passive:true});window.addEventListener('resize',onScrollRaf,{passive:true});onScroll();}
1004
+ function scan(rootEl){
1005
+ var list=[];
1006
+ if(rootEl.nodeType===1&&rootEl.hasAttribute&&rootEl.hasAttribute('data-wv-effect'))list.push(rootEl);
1007
+ if(rootEl.querySelectorAll){var found=rootEl.querySelectorAll('[data-wv-effect]');for(var j=0;j<found.length;j++)list.push(found[j]);}
1008
+ for(var i=0;i<list.length;i++){
1009
+ var el=list[i];
1010
+ if(el.__wvSeen)continue;
1011
+ el.__wvSeen=1;
1012
+ var fx=el.getAttribute('data-wv-effect');
1013
+ if(fx==='zoom-hover')continue;
1014
+ if(fx==='parallax-soft'){bindParallax(el);continue;}
1015
+ timing(el);
1016
+ io.observe(el);
1017
+ }
1018
+ }
1019
+ scan(document);
1020
+ var mo=new MutationObserver(function(muts){
1021
+ for(var i=0;i<muts.length;i++){
1022
+ var add=muts[i].addedNodes;
1023
+ for(var k=0;k<add.length;k++){var n=add[k];if(n.nodeType===1)scan(n);}
1024
+ }
1025
+ });
1026
+ mo.observe(document.body||document.documentElement,{childList:true,subtree:true});
1007
1027
  })();`;
1008
1028
 
1009
1029
  // ../variant-compiler/src/lint/html.ts
@@ -1243,6 +1263,9 @@ function lintNodes(nodes, ctx, ariaHidden = false) {
1243
1263
  const hidden = ariaHidden || staticValue(n.attrs["aria-hidden"]) === "true";
1244
1264
  for (const [k, v] of Object.entries(n.attrs)) lintAttr(k, v, tag, ctx);
1245
1265
  if (tag === "img" && !("alt" in n.attrs)) push(ctx, "warning", "img-alt", "<img> without alt");
1266
+ if (tag === "img" && n.attrs.src !== void 0 && staticValue(n.attrs.src) === null && !("data-edit-image" in n.attrs)) {
1267
+ push(ctx, "warning", "edit-image-missing", `<img> with a content-driven src has no data-edit-image - the owner cannot swap this image inline; bind the field path (data-edit-image="imageLeft", or "items.\${i}.image" inside a loop)`);
1268
+ }
1246
1269
  if (/^h[1-4]$/.test(tag)) {
1247
1270
  const cls = staticValue(n.attrs.class);
1248
1271
  const style = staticValue(n.attrs.style);
package/dist/index.js CHANGED
@@ -944,9 +944,9 @@ var WV_EFFECT_CSS = `@media (prefers-reduced-motion: no-preference){
944
944
  }`;
945
945
  var WV_EFFECT_JS = `(function(){
946
946
  if(!('IntersectionObserver' in window))return;
947
- var els=document.querySelectorAll('[data-wv-effect]');
948
- if(!els.length)return;
949
947
  if(window.matchMedia('(prefers-reduced-motion: reduce)').matches)return;
948
+ if(window.__wvFx)return;
949
+ window.__wvFx=1;
950
950
  document.documentElement.classList.add('wv-js');
951
951
  function num(el,attr,def){var v=parseInt(el.getAttribute(attr)||'',10);return isFinite(v)?v:def;}
952
952
  function timing(el){
@@ -954,8 +954,8 @@ function timing(el){
954
954
  var ms=num(el,'data-wv-duration',0);if(ms>=100)el.style.transitionDuration=ms+'ms';
955
955
  }
956
956
  function counter(el){
957
- var txt=el.textContent||'';var m=txt.match(/-?\\d[\\d.,]*/);if(!m)return;
958
- var target=parseFloat(m[0].replace(/[.,](?=\\d{3}(\\D|$))/g,''));if(!isFinite(target))return;
957
+ var txt=el.textContent||'';var m=txt.match(/-?d[d.,]*/);if(!m)return;
958
+ var target=parseFloat(m[0].replace(/[.,](?=d{3}(D|$))/g,''));if(!isFinite(target))return;
959
959
  var pre=txt.slice(0,m.index),post=txt.slice(m.index+m[0].length);
960
960
  var dur=Math.min(Math.max(num(el,'data-wv-duration',1200),100),5000),t0=null;
961
961
  function tick(t){
@@ -966,7 +966,7 @@ function counter(el){
966
966
  }
967
967
  requestAnimationFrame(tick);
968
968
  }
969
- var para=[];
969
+ var para=[],paraBound=false;
970
970
  function onScroll(){
971
971
  for(var i=0;i<para.length;i++){
972
972
  var el=para[i],r=el.getBoundingClientRect();
@@ -979,6 +979,11 @@ function onScroll(){
979
979
  }
980
980
  var ticking=false;
981
981
  function onScrollRaf(){if(ticking)return;ticking=true;requestAnimationFrame(function(){ticking=false;onScroll();});}
982
+ function bindParallax(el){
983
+ para.push(el);
984
+ if(!paraBound){paraBound=true;window.addEventListener('scroll',onScrollRaf,{passive:true});window.addEventListener('resize',onScrollRaf,{passive:true});}
985
+ onScroll();
986
+ }
982
987
  var io=new IntersectionObserver(function(entries){
983
988
  for(var i=0;i<entries.length;i++){
984
989
  var en=entries[i];if(!en.isIntersecting)continue;
@@ -993,14 +998,29 @@ var io=new IntersectionObserver(function(entries){
993
998
  el.classList.add('wv-in');
994
999
  }
995
1000
  },{threshold:0.15,rootMargin:'0px 0px -5% 0px'});
996
- for(var i=0;i<els.length;i++){
997
- var el=els[i],fx=el.getAttribute('data-wv-effect');
998
- if(fx==='zoom-hover')continue;
999
- if(fx==='parallax-soft'){para.push(el);continue;}
1000
- timing(el);
1001
- io.observe(el);
1002
- }
1003
- if(para.length){window.addEventListener('scroll',onScrollRaf,{passive:true});window.addEventListener('resize',onScrollRaf,{passive:true});onScroll();}
1001
+ function scan(rootEl){
1002
+ var list=[];
1003
+ if(rootEl.nodeType===1&&rootEl.hasAttribute&&rootEl.hasAttribute('data-wv-effect'))list.push(rootEl);
1004
+ if(rootEl.querySelectorAll){var found=rootEl.querySelectorAll('[data-wv-effect]');for(var j=0;j<found.length;j++)list.push(found[j]);}
1005
+ for(var i=0;i<list.length;i++){
1006
+ var el=list[i];
1007
+ if(el.__wvSeen)continue;
1008
+ el.__wvSeen=1;
1009
+ var fx=el.getAttribute('data-wv-effect');
1010
+ if(fx==='zoom-hover')continue;
1011
+ if(fx==='parallax-soft'){bindParallax(el);continue;}
1012
+ timing(el);
1013
+ io.observe(el);
1014
+ }
1015
+ }
1016
+ scan(document);
1017
+ var mo=new MutationObserver(function(muts){
1018
+ for(var i=0;i<muts.length;i++){
1019
+ var add=muts[i].addedNodes;
1020
+ for(var k=0;k<add.length;k++){var n=add[k];if(n.nodeType===1)scan(n);}
1021
+ }
1022
+ });
1023
+ mo.observe(document.body||document.documentElement,{childList:true,subtree:true});
1004
1024
  })();`;
1005
1025
 
1006
1026
  // ../variant-compiler/src/lint/html.ts
@@ -1240,6 +1260,9 @@ function lintNodes(nodes, ctx, ariaHidden = false) {
1240
1260
  const hidden = ariaHidden || staticValue(n.attrs["aria-hidden"]) === "true";
1241
1261
  for (const [k, v] of Object.entries(n.attrs)) lintAttr(k, v, tag, ctx);
1242
1262
  if (tag === "img" && !("alt" in n.attrs)) push(ctx, "warning", "img-alt", "<img> without alt");
1263
+ if (tag === "img" && n.attrs.src !== void 0 && staticValue(n.attrs.src) === null && !("data-edit-image" in n.attrs)) {
1264
+ push(ctx, "warning", "edit-image-missing", `<img> with a content-driven src has no data-edit-image - the owner cannot swap this image inline; bind the field path (data-edit-image="imageLeft", or "items.\${i}.image" inside a loop)`);
1265
+ }
1243
1266
  if (/^h[1-4]$/.test(tag)) {
1244
1267
  const cls = staticValue(n.attrs.class);
1245
1268
  const style = staticValue(n.attrs.style);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webto-id/variant-check",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Lint, compile and preview a Webto Variant Format (.astro subset) section variant with the exact compiler the webto.id marketplace uses.",
5
5
  "license": "MIT",
6
6
  "type": "module",