@stacksjs/email 0.74.31 → 0.74.33

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 (2) hide show
  1. package/dist/css-inliner.js +1 -1
  2. package/package.json +13 -13
@@ -3,4 +3,4 @@ ${leftover.join(`
3
3
  `)}
4
4
  </style>`;working=/<\/head>/i.test(working)?working.replace(/<\/head>/i,`${styleTag}
5
5
  </head>`):`${styleTag}
6
- ${working}`}return restorePassthroughs(working,passthroughBlocks)}function restorePassthroughs(html,blocks){if(blocks.length===0)return html;return html.replace(/\u0000STX_PASSTHROUGH_(\d+)\u0000/g,(_match,idx)=>{return blocks[Number.parseInt(idx,10)]??""})}function splitRules(body){const cleaned=body.replace(/\/\*[\s\S]*?\*\//g,""),rules=[];let i=0;while(i<cleaned.length){const open=cleaned.indexOf("{",i);if(open===-1)break;const selector=cleaned.slice(i,open).trim();let depth=1,j=open+1;while(j<cleaned.length&&depth>0){const ch=cleaned[j];if(ch==="{")depth++;else if(ch==="}")depth--;j++}const inner=cleaned.slice(open+1,j-1);if(selector.startsWith("@")||inner.includes("{"))rules.push({selector:selector||"@unknown",declarations:parseDeclarationsLoose(inner)});else rules.push({selector,declarations:parseDeclarations(inner)});i=j}return rules}function parseDeclarations(body){return body.split(";").map((decl)=>decl.trim()).filter(Boolean).map((decl)=>{const colon=decl.indexOf(":");if(colon===-1)return null;return{prop:decl.slice(0,colon).trim(),value:decl.slice(colon+1).trim()}}).filter((d)=>d!==null)}function parseDeclarationsLoose(body){return[{prop:"",value:body.trim()}]}function isInlinable(selector){if(!selector)return!1;if(selector.includes(","))return selector.split(",").every((s)=>isInlinable(s.trim()));if(selector.startsWith("@"))return!1;if(/[\s>+~:[]/.test(selector))return!1;return/^[a-z][a-z0-9-]*?$|^([a-z][a-z0-9-]*)?([.#][a-z][\w-]*)+$/i.test(selector)}function applyRule(html,selector,decls,important){if(selector.includes(",")){let acc=html;for(const branch of selector.split(","))acc=applyRule(acc,branch.trim(),decls,important);return acc}const{tag,classes,ids}=parseSimpleSelector(selector),tagRe=new RegExp(`<(${tag??"[a-z][a-z0-9-]*"})\\b([^>]*?)(/?)>`,"gi"),newDeclString=decls.map((d)=>`${d.prop}:${d.value}${important&&!/!important\b/i.test(d.value)?" !important":""};`).join("");return html.replace(tagRe,(match,_tagName,attrs)=>{if(!elementMatches(attrs,classes,ids))return match;return mergeStyleAttr(match,attrs,newDeclString)})}function parseSimpleSelector(selector){let tag=null;const classes=[],ids=[];let i=0;while(i<selector.length&&/[a-z0-9-]/i.test(selector[i])){tag=(tag??"")+selector[i];i++}if(tag==="")tag=null;while(i<selector.length){const ch=selector[i];if(ch!=="."&&ch!=="#")break;let j=i+1;while(j<selector.length&&/[\w-]/.test(selector[j]))j++;const name=selector.slice(i+1,j);if(ch===".")classes.push(name);else ids.push(name);i=j}return{tag,classes,ids}}function elementMatches(attrs,classes,ids){if(classes.length>0){const classMatch=attrs.match(/\bclass\s*=\s*["']([^"']*)["']/i);if(!classMatch)return!1;const present=classMatch[1].split(/\s+/).filter(Boolean);if(!classes.every((c)=>present.includes(c)))return!1}if(ids.length>0){const idMatch=attrs.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!idMatch)return!1;if(!ids.every((id)=>idMatch[1]===id))return!1}return!0}function mergeStyleAttr(originalTag,attrs,newDeclString){const styleMatch=attrs.match(/\bstyle\s*=\s*["']([^"']*)["']/i);if(styleMatch){const existing=styleMatch[1].trim(),merged=`${newDeclString}${existing}${existing.endsWith(";")||existing===""?"":";"}`,replaced=attrs.replace(styleMatch[0],`style="${merged}"`);return originalTag.replace(attrs,replaced)}const extra=` style="${newDeclString}"`;return originalTag.replace(/(\s*\/?)>$/,`${extra}$1>`)}export function shouldInlineByDefault(){return(globalThis.process?.env?.APP_ENV??globalThis.process?.env?.NODE_ENV??"").toLowerCase()==="production"}
6
+ ${working}`}return restorePassthroughs(working,passthroughBlocks)}function restorePassthroughs(html,blocks){if(blocks.length===0)return html;return html.replace(/\0STX_PASSTHROUGH_(\d+)\0/g,(_match,idx)=>{return blocks[Number.parseInt(idx,10)]??""})}function splitRules(body){const cleaned=body.replace(/\/\*[\s\S]*?\*\//g,""),rules=[];let i=0;while(i<cleaned.length){const open=cleaned.indexOf("{",i);if(open===-1)break;const selector=cleaned.slice(i,open).trim();let depth=1,j=open+1;while(j<cleaned.length&&depth>0){const ch=cleaned[j];if(ch==="{")depth++;else if(ch==="}")depth--;j++}const inner=cleaned.slice(open+1,j-1);if(selector.startsWith("@")||inner.includes("{"))rules.push({selector:selector||"@unknown",declarations:parseDeclarationsLoose(inner)});else rules.push({selector,declarations:parseDeclarations(inner)});i=j}return rules}function parseDeclarations(body){return body.split(";").map((decl)=>decl.trim()).filter(Boolean).map((decl)=>{const colon=decl.indexOf(":");if(colon===-1)return null;return{prop:decl.slice(0,colon).trim(),value:decl.slice(colon+1).trim()}}).filter((d)=>d!==null)}function parseDeclarationsLoose(body){return[{prop:"",value:body.trim()}]}function isInlinable(selector){if(!selector)return!1;if(selector.includes(","))return selector.split(",").every((s)=>isInlinable(s.trim()));if(selector.startsWith("@"))return!1;if(/[\s>+~:[]/.test(selector))return!1;return/^[a-z][a-z0-9-]*?$|^([a-z][a-z0-9-]*)?([.#][a-z][\w-]*)+$/i.test(selector)}function applyRule(html,selector,decls,important){if(selector.includes(",")){let acc=html;for(const branch of selector.split(","))acc=applyRule(acc,branch.trim(),decls,important);return acc}const{tag,classes,ids}=parseSimpleSelector(selector),tagRe=new RegExp(`<(${tag??"[a-z][a-z0-9-]*"})\\b([^>]*?)(/?)>`,"gi"),newDeclString=decls.map((d)=>`${d.prop}:${d.value}${important&&!/!important\b/i.test(d.value)?" !important":""};`).join("");return html.replace(tagRe,(match,_tagName,attrs)=>{if(!elementMatches(attrs,classes,ids))return match;return mergeStyleAttr(match,attrs,newDeclString)})}function parseSimpleSelector(selector){let tag=null;const classes=[],ids=[];let i=0;while(i<selector.length&&/[a-z0-9-]/i.test(selector[i])){tag=(tag??"")+selector[i];i++}if(tag==="")tag=null;while(i<selector.length){const ch=selector[i];if(ch!=="."&&ch!=="#")break;let j=i+1;while(j<selector.length&&/[\w-]/.test(selector[j]))j++;const name=selector.slice(i+1,j);if(ch===".")classes.push(name);else ids.push(name);i=j}return{tag,classes,ids}}function elementMatches(attrs,classes,ids){if(classes.length>0){const classMatch=attrs.match(/\bclass\s*=\s*["']([^"']*)["']/i);if(!classMatch)return!1;const present=classMatch[1].split(/\s+/).filter(Boolean);if(!classes.every((c)=>present.includes(c)))return!1}if(ids.length>0){const idMatch=attrs.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!idMatch)return!1;if(!ids.every((id)=>idMatch[1]===id))return!1}return!0}function mergeStyleAttr(originalTag,attrs,newDeclString){const styleMatch=attrs.match(/\bstyle\s*=\s*["']([^"']*)["']/i);if(styleMatch){const existing=styleMatch[1].trim(),merged=`${newDeclString}${existing}${existing.endsWith(";")||existing===""?"":";"}`,replaced=attrs.replace(styleMatch[0],`style="${merged}"`);return originalTag.replace(attrs,replaced)}const extra=` style="${newDeclString}"`;return originalTag.replace(/(\s*\/?)>$/,`${extra}$1>`)}export function shouldInlineByDefault(){return(globalThis.process?.env?.APP_ENV??globalThis.process?.env?.NODE_ENV??"").toLowerCase()==="production"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@stacksjs/email",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "0.74.31",
5
+ "version": "0.74.33",
6
6
  "description": "The Stacks Email integration. Painlessly create & manage your inboxes, templates, and send emails.",
7
7
  "author": "Chris Breuer",
8
8
  "contributors": [
@@ -61,26 +61,26 @@
61
61
  "prepublishOnly": "bun run build"
62
62
  },
63
63
  "dependencies": {
64
- "@stacksjs/config": "0.74.31",
65
- "@stacksjs/database": "0.74.31",
66
- "@stacksjs/events": "0.74.31",
67
- "@stacksjs/logging": "0.74.31",
64
+ "@stacksjs/config": "0.74.33",
65
+ "@stacksjs/database": "0.74.33",
66
+ "@stacksjs/events": "0.74.33",
67
+ "@stacksjs/logging": "0.74.33",
68
68
  "@stacksjs/mail": "^0.3.6",
69
- "@stacksjs/path": "0.74.31",
70
- "@stacksjs/storage": "0.74.31",
71
- "@stacksjs/strings": "0.74.31",
69
+ "@stacksjs/path": "0.74.33",
70
+ "@stacksjs/storage": "0.74.33",
71
+ "@stacksjs/strings": "0.74.33",
72
72
  "@stacksjs/stx": "^0.2.274",
73
73
  "@stacksjs/ts-cloud": "^0.12.15",
74
- "@stacksjs/utils": "0.74.31"
74
+ "@stacksjs/utils": "0.74.33"
75
75
  },
76
76
  "devDependencies": {
77
- "@stacksjs/cli": "0.74.31",
78
- "@stacksjs/error-handling": "0.74.31",
79
- "@stacksjs/types": "0.74.31",
77
+ "@stacksjs/cli": "0.74.33",
78
+ "@stacksjs/error-handling": "0.74.33",
79
+ "@stacksjs/types": "0.74.33",
80
80
  "better-dx": "^0.2.24"
81
81
  },
82
82
  "peerDependencies": {
83
- "@stacksjs/queue": "0.74.31"
83
+ "@stacksjs/queue": "0.74.33"
84
84
  },
85
85
  "peerDependenciesMeta": {
86
86
  "@stacksjs/queue": {