mirror of
https://github.com/szymon-jozef/ZUT-notatki.git
synced 2026-09-07 12:10:40 +02:00
193 lines
24 KiB
JavaScript
193 lines
24 KiB
JavaScript
/*
|
||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||
if you want to view the source, please visit the github repository of this plugin
|
||
*/
|
||
|
||
var N=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var pe=Object.prototype.hasOwnProperty;var he=(a,i)=>{for(var t in i)N(a,t,{get:i[t],enumerable:!0})},fe=(a,i,t,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let n of ge(i))!pe.call(a,n)&&n!==t&&N(a,n,{get:()=>i[n],enumerable:!(e=ue(i,n))||e.enumerable});return a};var me=a=>fe(N({},"__esModule",{value:!0}),a);var Ce={};he(Ce,{default:()=>C});module.exports=me(Ce);var w=require("obsidian");var H="insta-toc",X=/^(\s*)(-|\d+(?:\.\d+)*|\d\.)\s+(.*)/,B=/\[\[([^\]]+)\|([^\]]+)\]\]/g,O=/\[\[([^\]\|]+)\]\]/g,F=/\[([^\]]*)\]\([^)]+\)/g,Z=/(#)([/\-_\w][^\s]*)/g;var A=/-{3}\n([\s\S]*)\n-{3}/,U={dash:"dash",number:"number"},D=["*","_","`","==","~~","{","}","#","\\"],ee={onlyCommonKeys:!1,onlyUniversalKeys:!1,skipCommonKeys:!1,skipUniversalKeys:!1,dedupArrays:!0,sortArrays:!0};function te(){return{title:{name:C.getGlobalSetting("tocTitle")??"Table of Contents",level:1,center:!1},exclude:"",style:{listType:C.getGlobalSetting("bulletType")??U.dash},omit:[],levels:{min:1,max:6}}}function G(...a){let i={};return a.forEach(t=>{t.forEach(e=>{i[e]=e in i?++i[e]:1})}),i}function ye(...a){return a.reduce((i,t)=>i.filter(Set.prototype.has,new Set(t)))}function ve(...a){let i=G(...a);return Object.keys(i).filter(t=>i[t]>1)}function Te(...a){let i=G(...a);return Object.keys(i).filter(t=>i[t]<a.length)}function be(...a){let i=G(...a);return Object.keys(i).filter(t=>i[t]===1)}function xe(a,i=!1){let t=Object.getOwnPropertyNames(a);if(i)for(let e in a)!t.includes(e)&&t.push(e);return t}function j(a){return typeof a=="object"&&a!==null&&!Array.isArray(a)}function ie(a){if(!j(a))return!1;let i=["writable","enumerable","configurable"].some(s=>s in a),t=["get","set"].some(s=>typeof a[s]=="function"),e=["get","set"].every(s=>s in a),n="value"in a&&i||t&&(e||i);if(n){let s=["configurable","get","set","enumerable","value","writable"];n=Object.keys(a).some(o=>!(o in s))}return n}var k={onlyKeys:[],skipKeys:[],onlyCommonKeys:!1,onlyUniversalKeys:!1,skipCommonKeys:!1,skipUniversalKeys:!1,invokeGetters:!1,skipSetters:!1,appendArrays:!1,prependArrays:!1,dedupArrays:!1,sortArrays:!1,hoistEnumerable:!1,hoistProto:!1,skipProto:!1,filter:Function.prototype,beforeEach:Function.prototype,afterEach:Function.prototype,onCircular:Function.prototype};function z(a,...i){let t=arguments.length===1?arguments[0]:{},e={...k,...t},n=new Map,s=new Map,o=typeof e.sortArrays=="function"?e.sortArrays:void 0,c=new WeakMap,d=0;function y(f){return xe(f,e.hoistEnumerable)}function T(...f){let h;f.length>1&&(e.onlyCommonKeys?h=ve(...f.map(l=>y(l))):e.onlyUniversalKeys?h=ye(...f.map(l=>y(l))):e.skipCommonKeys?h=be(...f.map(l=>y(l))):e.skipUniversalKeys&&(h=Te(...f.map(l=>y(l))))),!h&&e.onlyKeys.length&&(h=e.onlyKeys),h&&h!==e.onlyKeys&&e.onlyKeys.length&&(h=h.filter(l=>e.onlyKeys.includes(l)));let E=f.reduce((l,u)=>{c.set(u,l);let v=h||y(u);e.skipKeys.length&&(v=v.filter(b=>e.skipKeys.indexOf(b)===-1));for(let b=0;b<v.length;b++){let g=v[b],S=l[g],m={configurable:!0,enumerable:!0};if(!(g in u))continue;let P=!1,r=u[g],L=Object.getOwnPropertyDescriptor(u,g);if(L&&typeof L.set=="function"&&typeof L.get!="function"){e.skipSetters||Object.defineProperty(l,g,L);continue}if(e.filter!==k.filter){let p=e.filter({depth:d,key:g,srcObj:u,srcVal:r,targetObj:l,targetVal:S});if(p!==void 0&&!p)continue}if(e.beforeEach!==k.beforeEach){let p=e.beforeEach({depth:d,key:g,srcObj:u,srcVal:r,targetObj:l,targetVal:S});p!==void 0&&(P=!0,r=p)}if(typeof r=="object"&&r!==null&&c.has(u[g])){let p=e.onCircular({depth:d,key:g,srcObj:u,srcVal:u[g],targetObj:l,targetVal:S});if(p===void 0){r=c.get(u[g]),l[g]=r;continue}P=!0,r=p}if(Array.isArray(r)){if(r=[...r],Array.isArray(S)&&(e.appendArrays?r=[...S,...r]:e.prependArrays&&(r=[...r,...S])),e.dedupArrays)if(e.afterEach!==k.afterEach)r=[...new Set(r)];else{let p=n.get(l);p&&!p.includes(g)?p.push(g):n.set(l,[g])}if(e.sortArrays)if(e.afterEach!==k.afterEach)r=r.sort(o);else{let p=s.get(l);p&&!p.includes(g)?p.push(g):s.set(l,[g])}}else r instanceof Date?r=new Date(r):j(r)&&(!P||!ie(r))&&(d++,j(S)?r=T(S,r):r=T(r),d--);if(e.afterEach!==k.afterEach){let p=e.afterEach({depth:d,key:g,mergeVal:r,srcObj:u,targetObj:l});p!==void 0&&(P=!0,r=p)}if(P){let p=ie(r)?r:{configurable:!0,enumerable:!0,value:r,writable:!0};Object.defineProperty(l,g,p);continue}if(L){let{configurable:p,enumerable:ce,get:J,set:Q,writable:de}=L;Object.assign(m,{configurable:p,enumerable:ce}),typeof J=="function"&&(e.invokeGetters?m.value=r:m.get=J),!e.skipSetters&&typeof Q=="function"&&!Object.hasOwnProperty.call(m,"value")&&(m.set=Q),!m.get&&!m.set&&(m.writable=!!de)}!m.get&&!m.set&&!("value"in m)&&(m.value=r,m.writable=L&&"writable"in L?L.writable:!0),Object.defineProperty(l,g,m)}return l},{});for(let[l,u]of n.entries())for(let v of u){let b=Object.getOwnPropertyDescriptor(l,v),{configurable:g,enumerable:S,writable:m}=b;Object.defineProperty(l,v,{configurable:g,enumerable:S,value:[...new Set(l[v])],writable:m!==void 0?m:!0})}for(let[l,u]of s.entries())for(let v of u)l[v].sort(o);let I=E;if(!e.skipProto){let l=f.reduce((u,v)=>{let b=Object.getPrototypeOf(v);return b&&b!==Object.prototype&&u.push(b),u},[]);if(l.length){let u=T(...l);e.hoistProto?I=T(u,E):I=Object.create(u,Object.getOwnPropertyDescriptors(E))}}return I}return arguments.length===1?function(...f){return arguments.length===1?z({...e,...f[0]}):T(...f)}:T(...arguments)}var _={bulletType:"dash",indentSize:2,updateDelay:2e3,tocTitle:"Table of Contents",excludedHeadingLevels:[],excludedHeadingText:[],excludedChars:D};var x=require("obsidian");var R=class extends x.PluginSettingTab{constructor(i,t){super(i,t),this.plugin=t}display(){let{containerEl:i}=this;i.empty();let t=new x.Setting(i).setHeading().setName("Insta ToC Global Settings");t.nameEl.classList.add("setting-title"),t.controlEl.remove(),new x.Setting(i).setName("List bullet style").setDesc("Select the global list bullet type.").addDropdown(e=>e.addOptions(U).setValue(this.plugin.settings.bulletType).onChange(async n=>{this.plugin.settings.bulletType=n,await this.plugin.saveSettings()})),new x.Setting(i).setName("Indentation width").setDesc("Select the global indentation size.").addSlider(e=>e.setLimits(2,8,2).setDynamicTooltip().setInstant(!0).setValue(this.plugin.settings.indentSize).onChange(async n=>{this.plugin.settings.indentSize=n,await this.plugin.saveSettings()})),new x.Setting(i).setName("Update delay").setDesc("The delay for each ToC update.").addSlider(e=>{e.setLimits(500,1e4,500).setDynamicTooltip().setInstant(!0).setValue(this.plugin.settings.updateDelay).onChange(async n=>{this.plugin.settings.updateDelay=n,await this.plugin.saveSettings(),this.plugin.updateModifyEventListener()})}),new x.Setting(i).setName("ToC Title").setDesc("The global title for the Table of Contents.").addText(e=>{e.setValue(this.plugin.settings.tocTitle).onChange(async n=>{this.plugin.settings.tocTitle=n,await this.plugin.saveSettings()}),e.inputEl.placeholder="Table of Contents"}).infoEl.classList.add("insta-toc-text-info"),new x.Setting(i).setName("Excluded heading text").setDesc("Comma-separated list of headings to exclude globally within the Table of Contents.").addTextArea(e=>{e.setValue(this.plugin.settings.excludedHeadingText.join(",")),e.inputEl.addEventListener("blur",async()=>{let s=e.getValue().trim().replace(/^,/,"").replace(/,$/,"").split(",").map(o=>o.trim()).filter(o=>o.length>0);this.plugin.settings.excludedHeadingText=s,await this.plugin.saveSettings()}),e.inputEl.placeholder="Table of Contents,Introduction,Side Note",e.inputEl.classList.add("insta-toc-text-area")}).infoEl.classList.add("insta-toc-text-info"),new x.Setting(i).setName("Excluded heading levels").setDesc("Comma-separated list of heading levels to exclude globally within the Table of Contents.").setTooltip("Valid values are 1-6.").addTextArea(e=>{e.setValue(this.plugin.settings.excludedHeadingLevels.join(",")).onChange(async n=>{let o=e.getValue().replace(/^,/,"").replace(/,$/,"").split(",").map(c=>parseInt(c.trim())).filter(c=>c>0&&c<7);this.plugin.settings.excludedHeadingLevels=[...o],await this.plugin.saveSettings()}),e.inputEl.classList.add("insta-toc-text-area"),e.inputEl.placeholder="1,2,3,4,5,6"}).infoEl.classList.add("insta-toc-text-info"),new x.Setting(i).setName("Excluded characters").setDesc("Globally excluded heading characters.").addTextArea(e=>{e.setValue([...new Set(this.plugin.settings.excludedChars)].join(",")).onChange(async n=>{let s=e.getValue(),o=new Set([...s.trim().replace(/^,/,"").replace(/,$/,"").split(",").map(c=>c.trim()).filter(c=>c.length>0)]);this.plugin.settings.excludedChars=[...o],await this.plugin.saveSettings()}),e.inputEl.classList.add("exclude-chars"),e.inputEl.placeholder=D.join(",")}).infoEl.classList.add("insta-toc-text-info")}};var W=require("obsidian");var M=class{constructor(i,t,e){this.hasSmartList=!1;this.isNumberedToc=!1;this.app=i,this.plugin=t,this.validator=e,this.headingLevelStack=[],this.updateAutoToc()}getIndentationLevel(i){for(;this.headingLevelStack.length>0&&i<=this.headingLevelStack[this.headingLevelStack.length-1];)this.headingLevelStack.pop();return this.headingLevelStack.push(i),this.headingLevelStack.length-1}generateNumberedToc(){let i=[],t={},e=this.validator.fileHeadings;for(let s of e){let o=s.level,c=s.heading;if(c.length===0)continue;let d=this.getIndentationLevel(o);t[d]||(t[d]=0);for(let h=d+1;h<=6;h++)t[h]=0;t[d]++;let y=" ".repeat(d*4),T=t[d].toString(),f=`${y}${T}. ${c}`;i.push(f)}return`\`\`\`${`${H}
|
||
---
|
||
${(0,W.stringifyYaml)(this.validator.localTocSettings)}---
|
||
|
||
${"#".repeat(this.validator.localTocSettings.title.level)} ${this.validator.localTocSettings.title.center?"<center>"+this.validator.localTocSettings.title.name+"</center>":this.validator.localTocSettings.title.name}
|
||
|
||
${i.join(`
|
||
`)}`}
|
||
\`\`\``}generateNormalToc(){let i=[],t=this.validator.fileHeadings;for(let n of t){let s=n.level,o=n.heading;if(o.length===0)continue;let c=this.getIndentationLevel(s),y=`${" ".repeat(c*4)}- ${o}`;i.push(y)}return`\`\`\`${`${H}
|
||
---
|
||
${(0,W.stringifyYaml)(this.validator.localTocSettings)}---
|
||
|
||
${"#".repeat(this.validator.localTocSettings.title.level)} ${this.validator.localTocSettings.title.center?"<center>"+this.validator.localTocSettings.title.name+"</center>":this.validator.localTocSettings.title.name}
|
||
|
||
${i.join(`
|
||
`)}`}
|
||
\`\`\``}insertTocBlock(i,t){this.validator.editor.replaceRange(i,t.from,t.to)}updateAutoToc(){let i=this.validator.tocInsertPos,t=this.plugin.settings.bulletType!==this.validator.localTocSettings.style.listType?this.validator.localTocSettings.style.listType:this.plugin.settings.bulletType,e;switch(t){case"dash":e=this.generateNormalToc();break;case"number":e=this.generateNumberedToc(),this.isNumberedToc=!0;break;default:e=this.generateNormalToc();break}this.insertTocBlock(e,i)}};var ne=require("obsidian");function se(a,i,t,e,n){let[,s,o,c]=e,{contentText:d,alias:y}=Se(i,c),T=a.fileManager.generateMarkdownLink(t,n,`#${d}`,y);return{indent:s,bullet:o,navLink:T}}function Se(a,i){let[t,e]=[i,i];return t=t.replace(B,(n,s,o)=>`${s} ${o}`),e=e.replace(B,(n,s,o)=>o),t=t.replace(O,(n,s)=>s.split("/").pop()??s),e=e.replace(O,(n,s)=>s.split("/").pop()??s),t=t.replace(F,(n,s)=>n),e=e.replace(F,(n,s)=>s),t=t.replace(Z,(n,s,o)=>o),e=Le(e,a),{contentText:t,alias:e}}function Le(a,i,t){let e=(i?i.settings.excludedChars:t)??[],n=(0,ne.htmlToMarkdown)(a);for(let s of e)n=n.replaceAll(s,"");return n}function ae(a,i,t){a.querySelectorAll("li").forEach((n,s)=>{i[s]>1&&(n.style.marginInlineStart=`${t*10}px`);let c=n.querySelector("ul, ol");if(c){let d=document.createElement("button");d.textContent="\u25BE",d.classList.add("fold-toggle"),d.addEventListener("click",()=>{c.style.display==="none"?(c.style.display="",d.textContent="\u25BE"):(c.style.display="none",d.textContent="\u25B8")}),n.prepend(d)}})}function oe(a){let i=a.workspace.activeEditor?.editor,t=i?.getCursor();return{editor:i,cursorPos:t}}function q(a){return a.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&")}function le(a){return/^\/.*\/$/.test(a)}function V(a){return[1,2,3,4,5,6].includes(a)}function Y(a){return a&&typeof a=="object"&&!Array.isArray(a)}function $(a,i,t=!0){if(Y(a)&&Y(i))for(let e of Object.keys(i)){let n=a[e],s=i[e];Y(s)?(n||(a[e]={}),$(a[e],s)):Array.isArray(n)&&Array.isArray(s)&&t?a[e]=[...new Set(n.concat(s))]:a[e]=s}return a}var re=require("obsidian");var K=class{constructor(i,t,e,n){this.previousHeadings=[];this.plugin=i,this.metadata=t,this.editor=e,this.cursorPos=n,this.localTocSettings=te()}update(i,t,e,n){this.plugin=i,this.metadata=t,this.editor=e,this.cursorPos=n}haveHeadingsChanged(){let i=this.metadata.headings||[],t=this.previousHeadings.length===0,e=i.length!==this.previousHeadings.length;return(t||e?!1:i.every((s,o)=>s.heading===this.previousHeadings[o].heading&&s.level===this.previousHeadings[o].level))?!1:(this.previousHeadings=i,!0)}hasHeadingsAndSections(){return!!this.metadata&&!!this.metadata.headings&&!!this.metadata.sections}hasInstaTocSection(){if(!this.hasHeadingsAndSections())return!1;let i=this.metadata.sections.find(t=>t.type==="code"&&this.editor.getLine(t.position.start.line)===`\`\`\`${H}`);return i?(this.instaTocSection=i,!0):!1}setTocInsertPos(){let i=this.instaTocSection.position.start.line,t=0,e=this.instaTocSection.position.end.line,n=this.instaTocSection.position.end.col,s={line:i,ch:t},o={line:e,ch:n};this.tocInsertPos={from:s,to:o}}configureLocalSettings(){let t=this.editor.getRange(this.tocInsertPos.from,this.tocInsertPos.to).match(A);if(!t)return;let[,e]=t;this.validateLocalSettings(e)}validateLocalSettings(i){let t;try{t=(0,re.parseYaml)(i)}catch(n){this.localTocSettings=this.updatedLocalSettings||this.localTocSettings;let s=`Invalid YAML in insta-toc settings:
|
||
`+n;console.error(s),new Notice(s);return}let e=[];if(t.title!==void 0){let n=t.title;if(typeof n!="object"||n===null)e.push("'title' must be an object.");else{let{name:s,level:o,center:c}=n;s!==void 0&&typeof s!="string"&&e.push("'title.name' must be a string indicating the title to be displayed on the ToC."),o!==void 0&&!V(o)&&e.push("'title.level' must be an integer between 1 and 6 indicating the heading level of the ToC title."),c!==void 0&&typeof c!="boolean"&&e.push("'title.center' must be a boolean indicating whether the title position should be centered.")}}if(t.exclude!==void 0&&typeof t.exclude!="string"&&e.push(`'exclude' must be a string ("...") containing each character to exclude, or a regex pattern (/.../).`),t.style!==void 0){let n=t.style;if(typeof n!="object"||n===null)e.push("'style' must be an object.");else{let{listType:s}=n;s!==void 0&&!["dash","number"].includes(s)&&e.push("'style.listType' must be 'dash' or 'number'.")}}if(t.omit!==void 0){if(!Array.isArray(t.omit))e.push("'omit' must be an array of strings indicating the text of each heading you'd like to omit.");else for(let n of t.omit)if(typeof n!="string"){e.push("'omit' array must contain only strings indicating the text of headings you'd like to omit.");break}}if(t.levels!==void 0){let n=t.levels;if(typeof n!="object"||n===null)e.push("'levels' must be an object.");else{let{min:s,max:o}=n;s!==void 0&&!V(s)&&e.push("'levels.min' must be an integer between 1 and 6 indicating the minimum heading level to include."),o!==void 0&&!V(o)&&e.push("'levels.max' must be an integer between 1 and 6 indicating the maximum heading level to include."),s!==void 0&&o!==void 0&&s>o&&e.push("'levels.min' cannot be greater than 'levels.max'.")}}if(e.length>0){let n=`Invalid properties in insta-toc settings:
|
||
`+e.join(`
|
||
`);console.error(n),new Notice(n),this.updatedLocalSettings=this.localTocSettings}else this.updatedLocalSettings?this.updatedLocalSettings=$(this.updatedLocalSettings,t,!1):this.updatedLocalSettings=$(this.localTocSettings,t,!0);this.localTocSettings=this.updatedLocalSettings}cursorInToc(){return this.cursorPos.line>=this.instaTocSection.position.start.line&&this.cursorPos.line<=this.instaTocSection.position.end.line}setFileHeadings(){this.metadata.headings&&(this.fileHeadings=this.metadata.headings.filter(i=>{let t=i.heading.trim(),e=i.level;return!t.match(/<!--\s*omit\s*-->/)&&!this.localTocSettings.omit.includes(t)&&e>=this.localTocSettings.levels.min&&e<=this.localTocSettings.levels.max&&t.trim().length>0&&!this.plugin.settings.excludedHeadingText.includes(t)&&!this.plugin.settings.excludedHeadingLevels.includes(e)}).map(i=>{let t=i.heading,e=[];if(this.plugin.settings.excludedChars&&this.plugin.settings.excludedChars.length>0){let n=this.plugin.settings.excludedChars.map(s=>q(s)).join("");n.length>0&&e.push(`[${n}]`)}if(this.localTocSettings.exclude&&this.localTocSettings.exclude.length>0){let n=this.localTocSettings.exclude;if(le(n)){let s=n.slice(1,-1);e.push(`(${s})`)}else{let s=q(n);s.length>0&&e.push(`[${s}]`)}}if(e.length>0){let n=new RegExp(e.join("|"),"g");t=t.replace(n,"")}return{...i,heading:t}}))}isValid(){return this.hasInstaTocSection()?this.haveHeadingsChanged()?(this.setTocInsertPos(),this.configureLocalSettings(),this.setFileHeadings(),!this.cursorInToc()):!1:(this.plugin.hasTocBlock=!1,!1)}};var C=class extends w.Plugin{constructor(t,e){super(t,e);this.hasTocBlock=!0;this.getDelay=()=>this.settings.updateDelay;this.app=t}async onload(){console.log("Loading Insta TOC Plugin"),await this.loadSettings(),this.addSettingTab(new R(this.app,this)),this.registerMarkdownCodeBlockProcessor("insta-toc",async(t,e,n)=>{this.hasTocBlock||(this.hasTocBlock=!0);let s=n.sourcePath,o=s.substring(0,s.lastIndexOf(".")),c=this.app.vault.getAbstractFileByPath(s),d=t.replace(A,"").split(`
|
||
`),y=[],T=d.map(f=>{let h=f.match(X);if(!h)return f;let{indent:E,bullet:I,navLink:l}=se(this.app,this,c,h,o),v=Math.floor(E.length/4)+1;return y.push(v),`${E}${I} ${l}`}).join(`
|
||
`);await w.MarkdownRenderer.render(this.app,T,e,s,this),ae(e,y,this.settings.indentSize)}),this.registerEvent(this.app.workspace.on("file-open",()=>this.hasTocBlock=!0)),this.updateModifyEventListener()}onunload(){console.log("Insta TOC Plugin Unloaded.")}async loadSettings(){let t=_,e=await this.loadData();e&&(t=z(ee)(_,e)),this.settings=t}async saveSettings(){await this.saveData(this.settings)}updateModifyEventListener(){this.modifyEventRef&&this.app.metadataCache.offref(this.modifyEventRef),this.setDebouncer(),this.modifyEventRef=this.app.metadataCache.on("changed",(t,e,n)=>{this.hasTocBlock&&this.debouncer(n)}),this.registerEvent(this.modifyEventRef)}setDebouncer(){this.debouncer=(0,w.debounce)(t=>{let{editor:e,cursorPos:n}=oe(this.app);if(!e||!n)return;this.validator?this.validator.update(this,t,e,n):this.validator=new K(this,t,e,n),this.validator.isValid()&&new M(this.app,this,this.validator)},this.settings.updateDelay,!1)}static getGlobalSetting(t){return(window.app.plugins.getPlugin("insta-toc")?.settings)[t]}};
|
||
/*! Bundled license information:
|
||
|
||
mergician/dist/mergician.esm.js:
|
||
(*!
|
||
* mergician
|
||
* v2.0.2
|
||
* https://jhildenbiddle.github.io/mergician/
|
||
* (c) 2022-2024 John Hildenbiddle
|
||
* MIT license
|
||
*)
|
||
(**
|
||
* @typedef {Object} MergicianOptions
|
||
* @property {string[]} [onlyKeys] - Exclusive array of keys to be merged
|
||
* (others are skipped)
|
||
* @property {string[]} [skipKeys] - Array of keys to skip (others are
|
||
* merged)
|
||
* @property {boolean} [onlyCommonKeys=false] - Merge only keys found
|
||
* in multiple objects (ignore single occurrence keys)
|
||
* @property {boolean} [onlyUniversalKeys=false] - Merge only keys
|
||
* found in all objects
|
||
* @property {boolean} [skipCommonKeys=false] - Skip keys found in
|
||
* multiple objects (merge only single occurrence keys)
|
||
* @property {boolean} [skipUniversalKeys=false] - Skip keys found in
|
||
* all objects (merge only common keys)
|
||
* @property {boolean} [invokeGetters=false] - Invoke "getter" methods
|
||
* and merge returned values
|
||
* @property {boolean} [skipSetters=false] - Skip "setter" methods
|
||
* during merge
|
||
* @property {boolean} [appendArrays=false] - Merge array values at
|
||
* the end of existing arrays
|
||
* @property {boolean} [prependArrays=false] - Merge array values at
|
||
* the beginning of existing arrays
|
||
* @property {boolean} [dedupArrays=false] - Remove duplicate array
|
||
* values in new merged object
|
||
* @property {boolean|function} [sortArrays=false] - Sort array values
|
||
* in new merged object
|
||
* @property {boolean} [hoistEnumerable=false] - Merge enumerable
|
||
* prototype properties as direct properties of merged object
|
||
* @property {boolean} [hoistProto=false] - Merge custom prototype
|
||
* properties as direct properties of merged object
|
||
* @property {boolean} [skipProto=false] - Skip merging of custom
|
||
* prototype properties
|
||
* @property {filterCallback} [filter] - Callback used to conditionally merge
|
||
* or skip a property. Return a "truthy" value to merge or a "falsy" value to
|
||
* skip. Return no value to proceed according to other option values.
|
||
* @property {beforeEachCallback} [beforeEach] - Callback used for
|
||
* inspecting/modifying properties before merge. Return value is used as value
|
||
* to merge.
|
||
* @property {afterEachCallback} [afterEach] - Callback used for
|
||
* inspecting/modifying properties after merge. Return value is used as merged
|
||
* value.
|
||
* @property {onCircularCallback} [onCircular] - Callback used for handling
|
||
* circular object references during merge
|
||
* @preserve
|
||
*)
|
||
(**
|
||
* @callback filterCallback
|
||
* @param {callbackData} callbackData
|
||
* @preserve
|
||
*)
|
||
(**
|
||
* @callback beforeEachCallback
|
||
* @param {callbackData} callbackData
|
||
* @preserve
|
||
*)
|
||
(**
|
||
* @callback afterEachCallback
|
||
* @param {afterEachCallbackData} callbackData
|
||
* @preserve
|
||
*)
|
||
(**
|
||
* @callback onCircularCallback
|
||
* @param {callbackData} callbackData
|
||
* @preserve
|
||
*)
|
||
(**
|
||
* @typedef {Object} callbackData
|
||
* @property {number} depth - Nesting level of the key being processed
|
||
* @property {string} key - Object key being processed
|
||
* @property {object} srcObj - Object containing the source value
|
||
* @property {any} srcVal - Source object’s property value
|
||
* @property {object} targetObj - New merged object
|
||
* @property {any} targetVal - New merged object’s current property value
|
||
* @preserve
|
||
*)
|
||
(**
|
||
* @typedef {Object} afterEachCallbackData
|
||
* @property {number} depth - Nesting level of the key being processed
|
||
* @property {string} key - Object key being processed
|
||
* @property {any} mergeVal - New merged value
|
||
* @property {object} srcObj - Object containing the source value
|
||
* @property {object} targetObj - New merged object
|
||
* @preserve
|
||
*)
|
||
(**
|
||
* @description Deep (recursive) object merging with support for descriptor
|
||
* values, accessor functions, custom prototypes, and advanced options for
|
||
* customizing the merge process.
|
||
*
|
||
* @example
|
||
* // Custom merge options
|
||
* const mergedObj = mergician({
|
||
* // Options
|
||
* })(obj1, obj2, obj3);
|
||
*
|
||
* // Custom merge function
|
||
* const customMerge = mergician({
|
||
* // Options
|
||
* });
|
||
* const customMergeObj = customMerge(obj1, obj2, obj3);
|
||
*
|
||
* @overload
|
||
* @param {MergicianOptions} options
|
||
* @returns {function} New merge function with options set as defaults
|
||
* @preserve
|
||
*)
|
||
(**
|
||
* @description Deep (recursive) object merging with support for descriptor
|
||
* values, accessor functions, custom prototypes, and advanced options for
|
||
* customizing the merge process.
|
||
*
|
||
* @example
|
||
* // Clone with default options
|
||
* const clonedObj = mergician({}, obj1);
|
||
*
|
||
* // Merge with default options
|
||
* const mergedObj = mergician(obj1, obj2, obj3);
|
||
*
|
||
* @overload
|
||
* @param {...object} objects
|
||
* @returns {object} New merged object
|
||
* @preserve
|
||
*)
|
||
(**
|
||
* @description Deep (recursive) object merging with support for descriptor
|
||
* values, accessor functions, custom prototypes, and advanced options for
|
||
* customizing the merge process.
|
||
*
|
||
* @example
|
||
* // Clone with default options
|
||
* const clonedObj = mergician({}, obj1);
|
||
*
|
||
* // Merge with default options
|
||
* const mergedObj = mergician(obj1, obj2, obj3);
|
||
*
|
||
* @example
|
||
* // Custom merge options
|
||
* const mergedObj = mergician({
|
||
* // Options
|
||
* })(obj1, obj2, obj3);
|
||
*
|
||
* // Custom merge function
|
||
* const customMerge = mergician({
|
||
* // Options
|
||
* });
|
||
* const customMergeObj = customMerge(obj1, obj2, obj3);
|
||
*
|
||
* @param {MergicianOptions} optionsOrObject
|
||
* @param {...object} [objects]
|
||
* @returns {function|object} New merge function with options set as defaults
|
||
* (single argument) or new merged object (multiple arguments)
|
||
* @preserve
|
||
*)
|
||
*/
|
||
|
||
/* nosourcemap */ |