sldeditor 0.31.0 → 0.31.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/README.md CHANGED
@@ -4,6 +4,17 @@ In-browser editor component for **electrical single-line diagrams (SLD / 一次
4
4
 
5
5
  > The local source directory is named `oneline-editor` (legacy); the npm package is `sldeditor`.
6
6
 
7
+ ## Sponsors
8
+
9
+ <a href="https://www.gridpilotai.co">
10
+ <picture>
11
+ <source media="(prefers-color-scheme: dark)" srcset="docs/sponsors/gridpilot-logo-light.png">
12
+ <img src="docs/sponsors/gridpilot-logo-dark.png" alt="GridPilot AI" height="36">
13
+ </picture>
14
+ </a>
15
+
16
+ Sponsored by [GridPilot](https://www.gridpilotai.co).
17
+
7
18
  ## What's in the box
8
19
 
9
20
  - **47 built-in symbols** — breaker, disconnector, transformer (2W/3W), busbar, CT/PT, generator, motor, PV, inverter, EV charger, battery, meter, arrester, fuse, recloser, VFD, and more. Symbol set lives in `src/element-library/*.json` and is hot-loaded into a typed registry.
@@ -253,5 +253,5 @@ ${this.fmt(this.maxY)}
253
253
  0
254
254
  `),this.out.join("")}g(t,n){this.out.push(`${t}
255
255
  ${this.fmt(n)}
256
- `)}fmt(t){return typeof t=="number"?Number.isFinite(t)?Number.isInteger(t)?String(t):t.toFixed(this.precision):"0":t}header(t){this.g(0,"SECTION"),this.g(2,"HEADER"),this.g(9,"$ACADVER"),this.g(1,"AC1009"),this.g(9,"$INSUNITS"),this.g(70,0),this.extentsSlot=this.out.length,this.out.push(""),t&&(this.g(9,"$PROJECTNAME"),this.g(1,ji(t))),this.g(0,"ENDSEC")}tables(t){this.g(0,"SECTION"),this.g(2,"TABLES"),this.g(0,"TABLE"),this.g(2,"LAYER"),this.g(70,t.length);for(const n of t)this.g(0,"LAYER"),this.g(2,n.name),this.g(70,0),this.g(62,n.color),this.g(6,"CONTINUOUS");this.g(0,"ENDTAB"),this.g(0,"ENDSEC")}beginEntities(){this.g(0,"SECTION"),this.g(2,"ENTITIES")}endEntities(){this.g(0,"ENDSEC"),this.g(0,"EOF")}setColor(t){this.currentColor=t}color(){this.currentColor!==void 0&&this.g(62,this.currentColor)}line(t,n,o){this.g(0,"LINE"),this.g(8,t),this.color(),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(11,o[0]),this.g(21,o[1]),this.g(31,0),this.track(n[0],n[1]),this.track(o[0],o[1])}polyline(t,n,o){if(!(n.length<2)){this.g(0,"POLYLINE"),this.g(8,t),this.color(),this.g(66,1),this.g(70,o?1:0),this.g(10,0),this.g(20,0),this.g(30,0);for(const[r,a]of n)this.g(0,"VERTEX"),this.g(8,t),this.g(10,r),this.g(20,a),this.g(30,0),this.track(r,a);this.g(0,"SEQEND"),this.g(8,t)}}circle(t,n,o){this.g(0,"CIRCLE"),this.g(8,t),this.color(),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(40,o),this.track(n[0]-o,n[1]-o),this.track(n[0]+o,n[1]+o)}text(t,n,o,r,a,s,l="start"){this.g(0,"TEXT"),this.g(8,t),this.color(),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(40,r),this.g(1,ji(o)),this.track(n[0],n[1]),this.track(n[0],n[1]+r),a!==0&&this.g(50,a),s&&this.g(71,2),l!=="start"&&(this.g(72,l==="middle"?1:2),this.g(11,n[0]),this.g(21,n[1]),this.g(31,0))}}function ji(e){return e.replace(/[\r\n]+/g," ").slice(0,250)}function cD(){const e=ie(),[t,n]=$.useState(!1),o=$.useRef(null);$.useEffect(()=>{if(!t)return;const a=l=>{o.current&&!o.current.contains(l.target)&&n(!1)},s=l=>{l.key==="Escape"&&n(!1)};return window.addEventListener("mousedown",a),window.addEventListener("keydown",s),()=>{window.removeEventListener("mousedown",a),window.removeEventListener("keydown",s)}},[t]);const r=a=>()=>{var p,m,f,b,h;n(!1);const{internal:s,diagram:l,fileSession:i}=w.getState(),u=((p=i==null?void 0:i.name)==null?void 0:p.replace(/\.json$/i,""))??((m=l.meta)==null?void 0:m.title)??"diagram",d={title:(f=l.meta)==null?void 0:f.title,labelMode:(b=l.meta)==null?void 0:b.labelMode,labelFontSize:(h=l.meta)==null?void 0:h.labelFontSize,annotations:l.annotations};a==="svg"?uC(s,`${u}.svg`,d):a==="png"?mC(s,`${u}.png`,{...d,scale:2}).catch(y=>{console.error(y),alert(e("topbar.export.pngFailed",{err:y.message}))}):Lj(s,`${u}.dxf`,d).catch(y=>{console.error(y),alert(e("topbar.export.dxfFailed",{err:y.message}))})};return c.jsxs("div",{ref:o,className:"relative",children:[c.jsxs(Qe,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":t,onClick:()=>n(a=>!a),children:[c.jsx(Yj,{}),e("topbar.export.label")]}),t&&c.jsxs("div",{role:"menu",className:"ole-glass absolute left-0 top-full mt-1.5 min-w-40 rounded-md border border-border p-1 shadow-md",children:[c.jsxs("button",{type:"button",role:"menuitem",onClick:r("svg"),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[c.jsx(eA,{}),c.jsx("span",{className:"flex-1",children:"SVG"})]}),c.jsxs("button",{type:"button",role:"menuitem",onClick:r("png"),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[c.jsx(Qj,{}),c.jsx("span",{className:"flex-1",children:"PNG (2×)"})]}),c.jsxs("button",{type:"button",role:"menuitem",onClick:r("dxf"),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[c.jsx(Zj,{}),c.jsx("span",{className:"flex-1",children:"DXF"})]})]})]})}exports.ALLOWED_ATTRS=Ij;exports.ALLOWED_ELEMENTS=Pj;exports.COLOR_ORDER=wa;exports.CUSTOM_KIND_PREFIX=G_;exports.ExportMenu=cD;exports.FileMenu=qM;exports.LIBRARY=Ao;exports.MM_PER_UNIT=Ho;exports.NAMED_COLORS=Go;exports.NICE_SCALES=Pn;exports.OneLineEditor=wM;exports.OneLineViewer=zM;exports.PAPER_LABEL=rl;exports.PAPER_MM=Dr;exports.PAPER_ORDER=ua;exports.PRINT_STROKE_MIN_MM=dl;exports.PRINT_TEXT_MIN_MM=cl;exports.PRINT_TEXT_TARGET_MM=pa;exports.SHEET_OWN_FIELDS=nl;exports.SHEET_SHARED_FIELDS=ol;exports.UNITS_PER_MM=Yt;exports.annotationKind=bt;exports.applyTheme=Nj;exports.bindingsOf=gP;exports.buildExportDxf=Oj;exports.buildExportSvg=_a;exports.checkHealth=QC;exports.clampSheetScale=ut;exports.compile=xt;exports.createEditorStore=SC;exports.createStaticTagSource=RM;exports.downloadDxf=Lj;exports.downloadPng=mC;exports.downloadSvg=uC;exports.dxfColor=an;exports.emptyInternalModel=X_;exports.exportInk=ft;exports.fitScale=Or;exports.fitToContent=Na;exports.fitToContentSoon=Ta;exports.fitToWorldRect=P4;exports.formatSheetScale=sl;exports.getInitialTheme=xM;exports.getLibraryEntry=v6;exports.inkClass=rt;exports.isCustomKind=Wo;exports.isTextAnnotation=C$;exports.labelFontForPrint=ha;exports.mergeCustomKinds=K_;exports.migrateLegacyFrame=jo;exports.newAnnotationId=En;exports.newBusId=Wr;exports.newElementId=Bn;exports.newJunctionId=qr;exports.orientationVec=Br;exports.paperMm=ma;exports.parseRatio=YC;exports.printedMm=ul;exports.removeBindings=yP;exports.resolveBindings=wC;exports.resolvePlacement=U_;exports.sameVoltageLevel=UC;exports.sanitizeSymbolSvg=BM;exports.sheetAroundBox=Lr;exports.sheetContentArea=Fo;exports.sheetExportOptions=F6;exports.sheetExportRegion=aC;exports.sheetFieldLabels=ka;exports.sheetIndexAt=ml;exports.sheetMinStroke=sC;exports.sheetOfText=Sa;exports.sheetPrimitives=fa;exports.sheetRect=yt;exports.soleSelectedAnnotation=yn;exports.toTagValue=So;exports.transformOrientation=In;exports.transformPoint=Ye;exports.upsertBinding=bP;exports.useEditorStore=w;exports.useHostActions=Lt;exports.useLocale=Bt;exports.useOnboarding=Ro;exports.validateCustomKind=HM;exports.wireIdFromEnds=zt;
256
+ `)}fmt(t){return typeof t=="number"?Number.isFinite(t)?Number.isInteger(t)?String(t):t.toFixed(this.precision):"0":t}header(t){this.g(0,"SECTION"),this.g(2,"HEADER"),this.g(9,"$ACADVER"),this.g(1,"AC1009"),this.g(9,"$DWGCODEPAGE"),this.g(3,"ANSI_1252"),this.g(9,"$INSUNITS"),this.g(70,0),this.extentsSlot=this.out.length,this.out.push(""),t&&(this.g(9,"$PROJECTNAME"),this.g(1,ji(t))),this.g(0,"ENDSEC")}tables(t){this.g(0,"SECTION"),this.g(2,"TABLES"),this.g(0,"TABLE"),this.g(2,"LAYER"),this.g(70,t.length);for(const n of t)this.g(0,"LAYER"),this.g(2,n.name),this.g(70,0),this.g(62,n.color),this.g(6,"CONTINUOUS");this.g(0,"ENDTAB"),this.g(0,"ENDSEC")}beginEntities(){this.g(0,"SECTION"),this.g(2,"ENTITIES")}endEntities(){this.g(0,"ENDSEC"),this.g(0,"EOF")}setColor(t){this.currentColor=t}color(){this.currentColor!==void 0&&this.g(62,this.currentColor)}line(t,n,o){this.g(0,"LINE"),this.g(8,t),this.color(),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(11,o[0]),this.g(21,o[1]),this.g(31,0),this.track(n[0],n[1]),this.track(o[0],o[1])}polyline(t,n,o){if(!(n.length<2)){this.g(0,"POLYLINE"),this.g(8,t),this.color(),this.g(66,1),this.g(70,o?1:0),this.g(10,0),this.g(20,0),this.g(30,0);for(const[r,a]of n)this.g(0,"VERTEX"),this.g(8,t),this.g(10,r),this.g(20,a),this.g(30,0),this.track(r,a);this.g(0,"SEQEND"),this.g(8,t)}}circle(t,n,o){this.g(0,"CIRCLE"),this.g(8,t),this.color(),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(40,o),this.track(n[0]-o,n[1]-o),this.track(n[0]+o,n[1]+o)}text(t,n,o,r,a,s,l="start"){this.g(0,"TEXT"),this.g(8,t),this.color(),this.g(10,n[0]),this.g(20,n[1]),this.g(30,0),this.g(40,r),this.g(1,ji(o)),this.track(n[0],n[1]),this.track(n[0],n[1]+r),a!==0&&this.g(50,a),s&&this.g(71,2),l!=="start"&&(this.g(72,l==="middle"?1:2),this.g(11,n[0]),this.g(21,n[1]),this.g(31,0))}}function ji(e){const t=e.replace(/[\r\n]+/g," ");let n="",o=0;for(const r of t){if(o++>=250)break;const a=r.codePointAt(0);a>=32&&a<127?n+=r:a>65535?n+="?":a>=160?n+=`\\U+${a.toString(16).toUpperCase().padStart(4,"0")}`:n+=" "}return n}function cD(){const e=ie(),[t,n]=$.useState(!1),o=$.useRef(null);$.useEffect(()=>{if(!t)return;const a=l=>{o.current&&!o.current.contains(l.target)&&n(!1)},s=l=>{l.key==="Escape"&&n(!1)};return window.addEventListener("mousedown",a),window.addEventListener("keydown",s),()=>{window.removeEventListener("mousedown",a),window.removeEventListener("keydown",s)}},[t]);const r=a=>()=>{var p,m,f,b,h;n(!1);const{internal:s,diagram:l,fileSession:i}=w.getState(),u=((p=i==null?void 0:i.name)==null?void 0:p.replace(/\.json$/i,""))??((m=l.meta)==null?void 0:m.title)??"diagram",d={title:(f=l.meta)==null?void 0:f.title,labelMode:(b=l.meta)==null?void 0:b.labelMode,labelFontSize:(h=l.meta)==null?void 0:h.labelFontSize,annotations:l.annotations};a==="svg"?uC(s,`${u}.svg`,d):a==="png"?mC(s,`${u}.png`,{...d,scale:2}).catch(y=>{console.error(y),alert(e("topbar.export.pngFailed",{err:y.message}))}):Lj(s,`${u}.dxf`,d).catch(y=>{console.error(y),alert(e("topbar.export.dxfFailed",{err:y.message}))})};return c.jsxs("div",{ref:o,className:"relative",children:[c.jsxs(Qe,{variant:"ghost",size:"sm",className:"gap-1.5","aria-haspopup":"menu","aria-expanded":t,onClick:()=>n(a=>!a),children:[c.jsx(Yj,{}),e("topbar.export.label")]}),t&&c.jsxs("div",{role:"menu",className:"ole-glass absolute left-0 top-full mt-1.5 min-w-40 rounded-md border border-border p-1 shadow-md",children:[c.jsxs("button",{type:"button",role:"menuitem",onClick:r("svg"),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[c.jsx(eA,{}),c.jsx("span",{className:"flex-1",children:"SVG"})]}),c.jsxs("button",{type:"button",role:"menuitem",onClick:r("png"),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[c.jsx(Qj,{}),c.jsx("span",{className:"flex-1",children:"PNG (2×)"})]}),c.jsxs("button",{type:"button",role:"menuitem",onClick:r("dxf"),className:"flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm hover:bg-accent hover:text-accent-foreground [&>svg]:size-4",children:[c.jsx(Zj,{}),c.jsx("span",{className:"flex-1",children:"DXF"})]})]})]})}exports.ALLOWED_ATTRS=Ij;exports.ALLOWED_ELEMENTS=Pj;exports.COLOR_ORDER=wa;exports.CUSTOM_KIND_PREFIX=G_;exports.ExportMenu=cD;exports.FileMenu=qM;exports.LIBRARY=Ao;exports.MM_PER_UNIT=Ho;exports.NAMED_COLORS=Go;exports.NICE_SCALES=Pn;exports.OneLineEditor=wM;exports.OneLineViewer=zM;exports.PAPER_LABEL=rl;exports.PAPER_MM=Dr;exports.PAPER_ORDER=ua;exports.PRINT_STROKE_MIN_MM=dl;exports.PRINT_TEXT_MIN_MM=cl;exports.PRINT_TEXT_TARGET_MM=pa;exports.SHEET_OWN_FIELDS=nl;exports.SHEET_SHARED_FIELDS=ol;exports.UNITS_PER_MM=Yt;exports.annotationKind=bt;exports.applyTheme=Nj;exports.bindingsOf=gP;exports.buildExportDxf=Oj;exports.buildExportSvg=_a;exports.checkHealth=QC;exports.clampSheetScale=ut;exports.compile=xt;exports.createEditorStore=SC;exports.createStaticTagSource=RM;exports.downloadDxf=Lj;exports.downloadPng=mC;exports.downloadSvg=uC;exports.dxfColor=an;exports.emptyInternalModel=X_;exports.exportInk=ft;exports.fitScale=Or;exports.fitToContent=Na;exports.fitToContentSoon=Ta;exports.fitToWorldRect=P4;exports.formatSheetScale=sl;exports.getInitialTheme=xM;exports.getLibraryEntry=v6;exports.inkClass=rt;exports.isCustomKind=Wo;exports.isTextAnnotation=C$;exports.labelFontForPrint=ha;exports.mergeCustomKinds=K_;exports.migrateLegacyFrame=jo;exports.newAnnotationId=En;exports.newBusId=Wr;exports.newElementId=Bn;exports.newJunctionId=qr;exports.orientationVec=Br;exports.paperMm=ma;exports.parseRatio=YC;exports.printedMm=ul;exports.removeBindings=yP;exports.resolveBindings=wC;exports.resolvePlacement=U_;exports.sameVoltageLevel=UC;exports.sanitizeSymbolSvg=BM;exports.sheetAroundBox=Lr;exports.sheetContentArea=Fo;exports.sheetExportOptions=F6;exports.sheetExportRegion=aC;exports.sheetFieldLabels=ka;exports.sheetIndexAt=ml;exports.sheetMinStroke=sC;exports.sheetOfText=Sa;exports.sheetPrimitives=fa;exports.sheetRect=yt;exports.soleSelectedAnnotation=yn;exports.toTagValue=So;exports.transformOrientation=In;exports.transformPoint=Ye;exports.upsertBinding=bP;exports.useEditorStore=w;exports.useHostActions=Lt;exports.useLocale=Bt;exports.useOnboarding=Ro;exports.validateCustomKind=HM;exports.wireIdFromEnds=zt;
257
257
  //# sourceMappingURL=sldeditor.cjs.map