UNPKG

on-codemerge

Version:

A WYSIWYG editor for on-codemerge is a user-friendly interface that allows users to edit and view their code in real time, exactly as it will appear in the final product

3 lines (2 loc) 2 kB
/*! on-codemerge v1.3.1 @author Pavel Kuzmin @license MIT @homepage https://s00d.github.io/on-codemerge/ @repository git+https://github.com/s00d/on-codemerge.git Copyright (c) 2026 Pavel Kuzmin - Built on 2026-07-02T13:39:17.947Z */ "use strict";var u=Object.defineProperty;var a=(i,e,t)=>e in i?u(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var l=(i,e,t)=>a(i,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("./FormatDebugMap.cjs");let d=0;class c{constructor(){l(this,"enabled",!1);l(this,"current",null);l(this,"lastMap",null)}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e}getLastMap(){return this.lastMap}begin(e,t,r){if(!this.enabled)return;n.buildDomTree(t);const o=r.rangeCount>0?r.getRangeAt(0):null;this.current={id:`trace-${++d}`,command:e,htmlBefore:t.innerHTML,selection:o?n.serializeSelection(r,t):{collapsed:!0,text:"",start:{path:"",offset:0,nodeType:"none"},end:{path:"",offset:0,nodeType:"none"},commonAncestorPath:""},domTree:n.buildDomTree(t),pipeline:[],nodesToModify:[],action:"noop"}}step(e,t,r,o){if(!this.enabled||!this.current)return;const s={step:e};o!==void 0&&(s.input=o),t!==void 0&&(s.output=t),r&&(s.decision=r),this.current.pipeline.push(s)}setNodesToModify(e,t){!this.enabled||!this.current||(this.current.nodesToModify=e.map(r=>n.nodeToRef(r,t)))}setAction(e){!this.enabled||!this.current||(this.current.action=e)}end(e){if(!this.enabled||!this.current)return null;n.buildDomTree(e);const t={id:this.current.id,command:this.current.command,htmlBefore:this.current.htmlBefore,htmlAfter:e.innerHTML,selection:this.current.selection,domTree:n.buildDomTree(e),pipeline:this.current.pipeline??[],nodesToModify:this.current.nodesToModify??[],action:this.current.action??"noop"};return this.lastMap=t,this.current=null,n.publishFormatDebugMap(t),t}logToConsole(e,t){this.enabled&&(typeof process<"u"&&process.env.JEST_WORKER_ID||console.info(t(e)))}}exports.FormatDebugTracer=c;