@hyperfixi/engine 3.3.0 → 4.0.1
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/CHANGELOG.md +199 -1
- package/README.md +66 -40
- package/dist/common.js +1 -1
- package/dist/common.min.js +1 -1
- package/dist/core.js +1 -1
- package/dist/core.min.js +1 -1
- package/dist/expressions-extra.d.ts +15 -0
- package/dist/full.js +29 -10
- package/dist/full.min.js +14 -14
- package/dist/hyperfixi-hs.dev.js +29 -10
- package/dist/hyperfixi-hs.js +14 -14
- package/dist/index.d.ts +1 -0
- package/dist/index.js +30 -10
- package/dist/minimal.js +1 -1
- package/dist/minimal.min.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2024,7 +2024,7 @@ var api = Object.assign(evaluate, {
|
|
|
2024
2024
|
cleanup,
|
|
2025
2025
|
/** The part of upstream's `internals` that pages and tests reach for. */
|
|
2026
2026
|
internals: { runtime: { cleanup, processNode } },
|
|
2027
|
-
version: false ? "dev" : "
|
|
2027
|
+
version: false ? "dev" : "4.0.1"
|
|
2028
2028
|
});
|
|
2029
2029
|
function boot() {
|
|
2030
2030
|
Object.assign(globalThis, { _hyperscript: api });
|
|
@@ -4510,6 +4510,17 @@ function typeCheckPostfix(p, root) {
|
|
|
4510
4510
|
};
|
|
4511
4511
|
return node;
|
|
4512
4512
|
}
|
|
4513
|
+
function beepValue(ctx, expression, source, value) {
|
|
4514
|
+
if (triggerEvent(ctx.me, "hyperscript:beep", { element: ctx.me, expression, value })) {
|
|
4515
|
+
const typeName = value == null ? "object (null)" : get(get(value, "constructor"), "name") ?? "unknown";
|
|
4516
|
+
const shown = typeof value === "string" ? `"${value}"` : shouldAutoIterate(value) ? Array.from(value) : value;
|
|
4517
|
+
console.log(
|
|
4518
|
+
`///_ BEEP! The expression (${source}) evaluates to:`,
|
|
4519
|
+
shown,
|
|
4520
|
+
"of type " + typeName
|
|
4521
|
+
);
|
|
4522
|
+
}
|
|
4523
|
+
}
|
|
4513
4524
|
function beep(p) {
|
|
4514
4525
|
const start = p.pos();
|
|
4515
4526
|
if (!p.match("beep!")) return;
|
|
@@ -4521,23 +4532,31 @@ function beep(p) {
|
|
|
4521
4532
|
start,
|
|
4522
4533
|
root,
|
|
4523
4534
|
(value, ctx) => {
|
|
4524
|
-
|
|
4525
|
-
const typeName = value == null ? "object (null)" : get(get(value, "constructor"), "name") ?? "unknown";
|
|
4526
|
-
const shown = typeof value === "string" ? `"${value}"` : shouldAutoIterate(value) ? Array.from(value) : value;
|
|
4527
|
-
console.log(
|
|
4528
|
-
`///_ BEEP! The expression (${source}) evaluates to:`,
|
|
4529
|
-
shown,
|
|
4530
|
-
"of type " + typeName
|
|
4531
|
-
);
|
|
4532
|
-
}
|
|
4535
|
+
beepValue(ctx, root, source, value);
|
|
4533
4536
|
return value;
|
|
4534
4537
|
},
|
|
4535
4538
|
false
|
|
4536
4539
|
);
|
|
4537
4540
|
}
|
|
4541
|
+
function beepCommand(p, _keyword, start) {
|
|
4542
|
+
const values2 = [expr(p)];
|
|
4543
|
+
while (p.matchOp(",")) values2.push(expr(p));
|
|
4544
|
+
const sources = values2.map((v) => p.text(v));
|
|
4545
|
+
return {
|
|
4546
|
+
type: "beepCommand",
|
|
4547
|
+
values: values2,
|
|
4548
|
+
start,
|
|
4549
|
+
end: p.endPos(),
|
|
4550
|
+
run: (ctx) => all(
|
|
4551
|
+
values2.map((v) => v.ev(ctx)),
|
|
4552
|
+
(vals) => vals.forEach((value, i) => beepValue(ctx, values2[i], sources[i], value))
|
|
4553
|
+
)
|
|
4554
|
+
};
|
|
4555
|
+
}
|
|
4538
4556
|
function expressionsExtra(g) {
|
|
4539
4557
|
g.leaves.push(closest, some, blockLiteral);
|
|
4540
4558
|
g.unaries.push(beep, relative, positional);
|
|
4559
|
+
g.commands["beep!"] = beepCommand;
|
|
4541
4560
|
g.postfixes.push(typeCheckPostfix);
|
|
4542
4561
|
g.collections.push(collectionOp);
|
|
4543
4562
|
}
|
|
@@ -5685,6 +5704,7 @@ export {
|
|
|
5685
5704
|
defaultCommand,
|
|
5686
5705
|
evaluate,
|
|
5687
5706
|
everything,
|
|
5707
|
+
expr,
|
|
5688
5708
|
expressionsExtra,
|
|
5689
5709
|
fetchCommand,
|
|
5690
5710
|
formatError,
|
package/dist/minimal.js
CHANGED
|
@@ -2293,7 +2293,7 @@
|
|
|
2293
2293
|
cleanup,
|
|
2294
2294
|
/** The part of upstream's `internals` that pages and tests reach for. */
|
|
2295
2295
|
internals: { runtime: { cleanup, processNode } },
|
|
2296
|
-
version: false ? "dev" : "
|
|
2296
|
+
version: false ? "dev" : "4.0.1"
|
|
2297
2297
|
});
|
|
2298
2298
|
function boot() {
|
|
2299
2299
|
Object.assign(globalThis, { _hyperscript: api });
|
package/dist/minimal.min.js
CHANGED
|
@@ -14,4 +14,4 @@
|
|
|
14
14
|
|
|
15
15
|
`+Ve(i)+s)}else L(e,"exception",{error:i}),console.error("hyperscript errors were found on the following element:",e,`
|
|
16
16
|
|
|
17
|
-
`,i)}}var Bt=[],Qt=[];function pe(e){if(!(e instanceof Element||e instanceof Document||e instanceof DocumentFragment))return;for(let n of Bt)n(e);let t=Wt().map(n=>`[${n}]`).join(", ")+", [type='text/hyperscript']";e instanceof Element&&e.matches(t)&&jt(e),e.querySelectorAll(t).forEach(jt);for(let n of Qt)n(e)}function Pe(e){let t=ee(e);if(t){L(e,"hyperscript:before:cleanup");for(let{target:n,event:r,handler:o}of t.listeners??[])n.removeEventListener(r,o);for(let n of t.observers??[])n.disconnect();for(let n of t.timers??[])clearTimeout(n);x.stop(e),e.querySelectorAll("[data-hyperscript-powered]").forEach(Pe),L(e,"hyperscript:after:cleanup"),e.removeAttribute("data-hyperscript-powered"),Ye(e)}}se.process=pe;function Dn(e){try{let t=Gt(e);return t.kind==="features"?{...t.program,errors:[]}:{...t.kind==="commands"?t.commands[0]:t.expression,errors:[]}}catch(t){if(t instanceof Y)return{errors:[t]};throw t}}var Yt=Object.assign(Mt,{config:Object.assign(B,{conversions:Object.assign(Se,{dynamicResolvers:Ce})}),use(e){e(Yt)},addBeforeProcessHook:e=>void Bt.push(e),addAfterProcessHook:e=>void Qt.push(e),addSourceTransform:e=>void zt.push(e),evaluate:Mt,parse:Dn,process:pe,processNode:pe,cleanup:Pe,internals:{runtime:{cleanup:Pe,processNode:pe}},version:"
|
|
17
|
+
`,i)}}var Bt=[],Qt=[];function pe(e){if(!(e instanceof Element||e instanceof Document||e instanceof DocumentFragment))return;for(let n of Bt)n(e);let t=Wt().map(n=>`[${n}]`).join(", ")+", [type='text/hyperscript']";e instanceof Element&&e.matches(t)&&jt(e),e.querySelectorAll(t).forEach(jt);for(let n of Qt)n(e)}function Pe(e){let t=ee(e);if(t){L(e,"hyperscript:before:cleanup");for(let{target:n,event:r,handler:o}of t.listeners??[])n.removeEventListener(r,o);for(let n of t.observers??[])n.disconnect();for(let n of t.timers??[])clearTimeout(n);x.stop(e),e.querySelectorAll("[data-hyperscript-powered]").forEach(Pe),L(e,"hyperscript:after:cleanup"),e.removeAttribute("data-hyperscript-powered"),Ye(e)}}se.process=pe;function Dn(e){try{let t=Gt(e);return t.kind==="features"?{...t.program,errors:[]}:{...t.kind==="commands"?t.commands[0]:t.expression,errors:[]}}catch(t){if(t instanceof Y)return{errors:[t]};throw t}}var Yt=Object.assign(Mt,{config:Object.assign(B,{conversions:Object.assign(Se,{dynamicResolvers:Ce})}),use(e){e(Yt)},addBeforeProcessHook:e=>void Bt.push(e),addAfterProcessHook:e=>void Qt.push(e),addSourceTransform:e=>void zt.push(e),evaluate:Mt,parse:Dn,process:pe,processNode:pe,cleanup:Pe,internals:{runtime:{cleanup:Pe,processNode:pe}},version:"4.0.1"});function Zt(){if(Object.assign(globalThis,{_hyperscript:Yt}),typeof document>"u")return;let e=()=>{pe(document.documentElement),document.dispatchEvent(new Event("hyperscript:ready"))};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e):setTimeout(e)}function Mn(e,t){if(typeof e!="object"||e===null)return{queue:[],executing:!1};let n=W(e).eventQueues??=new Map,r=n.get(t);return r||n.set(t,r={queue:[],executing:!1}),r}function Be(e,t){let n=Mn(e.me,t);if(n.executing&&!t.every){if(t.queue==="none"||t.queue==="first"&&n.queue.length>0)return;t.queue!=="all"&&(n.queue.length=0),n.queue.push(e);return}n.executing=!0;let r=o=>{n.executing=!1;let i=n.queue.shift();if(i&&setTimeout(()=>Be(i,t),1),o){let{error:s}=o;console.error(v(s,"message")??s),console.error(v(s,"stack")),L(e.me,"exception",{error:s})}};oe(()=>T(st(e,t.body,t),()=>r()),o=>r({error:o}))}function jn(e,t){if(!z(t))return;let n=W(t),r=n.listeners??=[],o=n.observers??=[],i=n.timers??=new Set;for(let s of e.events){let u={execCount:0},a=s.elsewhere?[document]:s.from?s.from.ev(le(t,e,t,null)):[t];S(a,l=>{if(!z(l)){console.warn("'%s' feature ignored because target does not exists:",e.displayName,t);return}let c=s.on;if(s.mutationSpec&&l instanceof Node){c="hyperscript:mutation";let m=new MutationObserver(f=>L(l,c,{mutationList:f,observer:m}));m.observe(l,s.mutationSpec),o.push(m)}if(s.intersectionSpec&&l instanceof Element){c="hyperscript:intersection";let m=new IntersectionObserver(f=>{for(let p of f)L(l,c,{observer:m,entry:p,intersecting:p.isIntersecting,isIntersecting:p.isIntersecting,intersectionRatio:p.intersectionRatio})},s.intersectionSpec);m.observe(l),o.push(m)}if(s.resizeSpec&&l instanceof Element){c="hyperscript:resize";let m=new ResizeObserver(f=>{for(let p of f){let{width:g,height:w}=p.contentRect;L(l,c,{width:g,height:w,contentRect:p.contentRect,entry:p})}});m.observe(l),o.push(m)}let d=m=>{if(t instanceof Node&&l!==t&&!t.isConnected){l.removeEventListener(c,d);return}let f=le(t,e,t,m);if(!(s.elsewhere&&t instanceof Node&&m.target instanceof Node&&t.contains(m.target))){s.from&&(f.result=l);for(let p of s.args){let g=v(m,p);g!==void 0?f.locals[p]=g:f.detail!=null&&(f.locals[p]=v(f.detail,p))}if(s.filter){f.meta.context=m;try{if(!s.filter.ev(f))return}finally{f.meta.context=void 0}}if(s.inExpr?.css){let p=m.target instanceof Element?m.target:null;for(;p&&!p.matches(s.inExpr.css);)p=p.parentElement;if(!p)return;f.result=p}if(u.execCount++,s.startCount){let p=u.execCount;if(s.endCount?p<s.startCount||p>s.endCount:s.unbounded?p<s.startCount:p!==s.startCount)return}if(s.debounceTime){u.debounced&&(clearTimeout(u.debounced),i.delete(u.debounced)),i.add(u.debounced=setTimeout(()=>Be(f,e),s.debounceTime));return}if(s.throttleTime){if(u.lastExec&&Date.now()<u.lastExec+s.throttleTime)return;u.lastExec=Date.now()}Be(f,e)}};l.addEventListener(c,d),r.push({target:l,event:c,handler:d})})}}function Hn(e){if(!e.match("of"))return{attributes:!0,characterData:!0,childList:!0,attributeOldValue:!0,characterDataOldValue:!0};let t={};do if(e.match("anything"))Object.assign(t,{attributes:!0,subtree:!0,characterData:!0,childList:!0});else if(e.match("childList"))t.childList=!0;else if(e.match("attributes"))t.attributes=!0;else if(e.match("subtree"))t.subtree=!0;else if(e.match("characterData"))t.characterData=!0;else if(e.cur().type==="ATTRIBUTE_REF"){let n=e.consume().value;n.startsWith("@")||e.err("Only shorthand attribute references are allowed here"),(t.attributeFilter??=[]).push(n.substring(1))}else e.err("Unknown mutation config specification");while(e.match("or"));return(t.attributes||t.attributeFilter)&&(t.attributeOldValue=!0),t.characterData&&(t.characterDataOldValue=!0),t}function $n(e){let t={};if(e.match("with")){let n=de(E(e));n instanceof Element&&(t.root=n)}if(e.match("having"))do e.match("margin")?t.rootMargin=vt(e):e.match("threshold")?t.threshold=Number(de(E(e))):e.err("Unknown intersection config specification");while(e.match("and"));return t}function Un(e,t){let n=Te(e),r=Dt(e),o;e.matchOp("[")&&(o=E(e),e.reqOp("]"));let i,s,u=!1;t?i=1:e.cur().type==="NUMBER"&&(i=parseInt(e.consume().value),e.match("to")?s=parseInt(e.consume().value):e.match("and")&&(u=!0,e.req("on")));let a={on:n,args:r,filter:o,startCount:i,endCount:s,unbounded:u,elsewhere:!1,resizeSpec:n==="resize"};n==="intersection"?a.intersectionSpec=$n(e):n==="mutation"&&(a.mutationSpec=Hn(e)),e.match("from")&&(e.match("elsewhere")?a.elsewhere=!0:a.from=e.withFollow(["or"],()=>E(e))),!a.from&&!a.elsewhere&&e.match("elsewhere")&&(a.elsewhere=!0),e.match("in")&&(a.inExpr=G(e));let l=()=>(e.req("at"),Number(de(G(e))));return e.match("debounced")?a.debounceTime=l():e.match("throttled")&&(a.throttleTime=l()),a}function Jt(e){e.features.on=(t,n)=>{let r=!!t.match("every"),o=!r&&!!t.match("first"),i=[];do i.push(Un(t,o));while(t.match("or"));let s="last";!r&&t.match("queue")&&(t.match("all")?s="all":t.match("first")?s="first":t.match("none")?s="none":t.req("last"));let u=te(t),a={type:"onFeature",displayName:"on "+i.map(l=>l.on).join(" or "),events:i,body:u,every:r,queue:s,..._t(t),start:n,end:t.endPos(),install:l=>jn(a,l)};return a}}$t(Jt,Ct,Ot,At);Zt();})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperfixi/engine",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "A small, typed hyperscript engine, faithful to upstream _hyperscript: its test suite is the acceptance oracle. Ships hyperfixi-hs.js, the script-tag bundle",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/index.js",
|