Add smart ACK provider for WeChat MP replies

Replace fixed ackText with a rule-based AckProvider that picks
response templates by message type and intent (translate, summary,
rewrite, poster, ppt, mindmap, code, search, schedule). Pure sync,
zero I/O, auto-falls back to config.ackText on any error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
john
2026-06-26 15:19:03 +08:00
parent 9ed4fd48d7
commit 9b4a25799f
162 changed files with 17276 additions and 2054 deletions
+79 -12
View File
@@ -15,6 +15,10 @@ export function publishedPageCspForEmbed(isFullHtml) {
return "default-src 'none'; style-src 'unsafe-inline'; img-src data:; font-src 'none'; base-uri 'none'; form-action 'self'; frame-ancestors *; script-src 'unsafe-inline'";
}
export function allowPlazaEmbedFrame(res) {
res.removeHeader?.('X-Frame-Options');
}
const EMBED_BOOTSTRAP = `<script id="plaza-embed-bootstrap">(function(){
if(window.parent===window)return;
var d=document;
@@ -24,22 +28,40 @@ const EMBED_BOOTSTRAP = `<script id="plaza-embed-bootstrap">(function(){
d.querySelectorAll('.section,.quote-section').forEach(function(el){out.push(el);});
var foot=d.querySelector('.footer');
if(foot)out.push(foot);
return out.length?out:[d.body];
return out.length?out:[d.body||d.documentElement];
}
function fullHeight(){
var body=d.body;
var body=d.body,root=d.documentElement;
var measured=0;
var scrollTop=window.pageYOffset||(root?root.scrollTop:0)||(body?body.scrollTop:0)||0;
function bottomOf(el){
if(!el)return 0;
var rect=el.getBoundingClientRect();
return rect.bottom+scrollTop;
}
var els=blocks();
for(var i=0;i<els.length;i++){
var el=els[i];
measured=Math.max(measured,el.offsetTop+el.offsetHeight);
if(!els[i])continue;
measured=Math.max(measured,bottomOf(els[i]),els[i].offsetTop+els[i].offsetHeight);
}
if(body){
for(var j=0;j<body.children.length;j++){
measured=Math.max(measured,bottomOf(body.children[j]));
}
}
if(body&&body.lastElementChild){
var last=body.lastElementChild;
measured=Math.max(measured,last.offsetTop+last.offsetHeight);
measured=Math.max(measured,bottomOf(last),last.offsetTop+last.offsetHeight);
}
measured=Math.max(measured,d.documentElement.scrollHeight,body?body.scrollHeight:0,420);
return Math.min(measured,16000);
measured=Math.max(
measured,
root?root.scrollHeight:0,
root?root.offsetHeight:0,
body?body.scrollHeight:0,
body?body.offsetHeight:0,
420
);
return Math.ceil(measured);
}
function restoreBlock(block){
if(!block)return;
@@ -57,11 +79,20 @@ const EMBED_BOOTSTRAP = `<script id="plaza-embed-bootstrap">(function(){
}
function reportHeight(){
var b=blocks();
window.parent.postMessage({
var h=fullHeight();
window.name='plaza-height:'+h;
var payload={
type:'plaza:embed-section',
count:b.length,
height:fullHeight(),
height:h,
total:b.length
};
window.parent.postMessage(JSON.stringify(payload),'*');
window.parent.postMessage({
type:'plaza:embed-section',
count:payload.count,
height:h,
total:payload.total
},'*');
}
function showAll(){
@@ -74,7 +105,7 @@ const EMBED_BOOTSTRAP = `<script id="plaza-embed-bootstrap">(function(){
reportHeight();
}
var style=d.createElement('style');
style.textContent='html,body{overflow:hidden!important;margin:0}';
style.textContent='html,body{margin:0;overflow:hidden!important}';
d.head.appendChild(style);
function scheduleReport(){
showAll();
@@ -90,11 +121,47 @@ const EMBED_BOOTSTRAP = `<script id="plaza-embed-bootstrap">(function(){
scheduleReport();
}
window.addEventListener('load',function(){scheduleReport();});
new ResizeObserver(function(){reportHeight();}).observe(d.documentElement);
window.parent&&window.parent.postMessage({
type:'plaza:embed-ready',
count:1,
ready:true,
height:fullHeight(),
total:1
},'*');
window.addEventListener('message',function(event){
var data=event&&event.data;
if(data==='plaza:embed-measure') {
scheduleReport();
return;
}
if(data&&typeof data==='object'&&data.type==='plaza:embed-measure')scheduleReport();
});
if(typeof ResizeObserver!=='undefined'){
var ro=new ResizeObserver(function(){reportHeight();});
ro.observe(d.documentElement);
if(d.body)ro.observe(d.body);
}
if(typeof MutationObserver!=='undefined'){
new MutationObserver(function(){scheduleReport();}).observe(d.documentElement,{childList:true,subtree:true,attributes:true});
}
d.querySelectorAll('img,video,iframe').forEach(function(el){
el.addEventListener('load',scheduleReport);
el.addEventListener('error',scheduleReport);
});
[100,350,700,1400,2600,5200,9200,15000].forEach(function(delay){setTimeout(scheduleReport,delay);});
[120,400,1000,2000,4000,8000,12000].forEach(function(delay){setTimeout(scheduleReport,delay);});
var keepalive=0;
var keepaliveTimer=setInterval(function(){
keepalive+=1;
scheduleReport();
if(keepalive>=30)clearInterval(keepaliveTimer);
},1000);
window.addEventListener('pageshow',scheduleReport);
window.addEventListener('orientationchange',function(){setTimeout(scheduleReport,300);});
})();</script>`;
const EMBED_LAYOUT_OVERRIDES =
'<style id="plaza-embed-overrides">.section,.quote-section,.footer{content-visibility:visible!important;contain-intrinsic-size:auto!important}</style>';
'<style id="plaza-embed-overrides">.section,.quote-section,.footer{content-visibility:visible!important;contain-intrinsic-size:auto!important}.hero{height:auto!important;min-height:0!important;max-height:none!important;overflow:visible!important}</style>';
/** Remove inline CSP meta tags that block plaza-embed-bootstrap (HTTP CSP header applies instead). */
export function stripPublicationHtmlCspMeta(html) {