@hyebook/vue3-adapter 0.2.2 → 0.2.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"editor-workbench.d.ts","sourceRoot":"","sources":["../../../../../core/src/workbench/editor-workbench.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,QAAQ,EAKR,kBAAkB,EAWnB,MAAM,gBAAgB,CAAC;AA2KxB,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,CAAC,EAAE,QAAQ,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAC5C,kBAAkB,CAAC,EAAE,uCAAuC,CAAC;IAC7D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,4BAA4B,CAAC;IACtC,UAAU,CAAC,EAAE,gCAAgC,CAAC;IAC9C,gBAAgB,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,CAAC;CAC5C;AAED,MAAM,WAAW,uCAAuC;IACtD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,uCAAuC;IACtD,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,wBAAwB,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC;IAClD,iBAAiB,CAAC,EAAE,uCAAuC,CAAC;CAC7D;AAED,MAAM,WAAW,gCAAgC;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,qBAAqB,GAAG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AI,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC9B,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;IACjD,sBAAsB,EAAE,CACtB,WAAW,EAAE,kBAAkB,GAAG,IAAI,GAAG,SAAS,KAC/C,kBAAkB,CAAC;IACxB,WAAW,EAAE,MAAM,uBAAuB,CAAC;IAC3C,WAAW,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,uBAAuB,CAAC,KAAK,IAAI,CAAC;CACnE;AAED,eAAO,MAAM,iCAAiC,EAAE,uBAM/C,CAAC;AAEF,KAAK,IAAI,GAAG,QAAQ,GAAG,SAAS,CAAC;AAoSjC,wBAAgB,8BAA8B,IAAI,QAAQ,CA6GzD;AAED,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,WAAW,EACtB,OAAO,GAAE,sBAA2B,GACnC,qBAAqB,CAohKvB"}
@@ -1,11 +1,14 @@
1
1
  import { addPageCommand } from "../editor/commands";
2
2
  import { EditorEngine } from "../editor/engine";
3
3
  const WORKBENCH_STYLE_ID = "hy-ebook-workbench-style";
4
+ const WORKBENCH_STYLE_VERSION = "0.2.3";
4
5
  const WORKBENCH_CSS = `
5
- .hyewb-root{font-family:"Noto Sans SC","PingFang SC","Microsoft YaHei",sans-serif;color:#0f172a;background:#f8fbff;border:1px solid #d8e0ea;border-radius:12px;padding:12px;display:grid;gap:10px}
6
+ .hyewb-root{font-family:"Noto Sans SC","PingFang SC","Microsoft YaHei",sans-serif;color:#0f172a;background:#f8fbff;border:1px solid #d8e0ea;border-radius:12px;padding:12px;display:grid;gap:10px;position:relative;--hyewb-top-shield-height:0px}
7
+ .hyewb-root::before{content:"";position:absolute;left:0;right:0;top:0;height:var(--hyewb-top-shield-height);background:#f8fbff;z-index:119500;pointer-events:none}
6
8
  .hyewb-header{display:flex;justify-content:space-between;align-items:center;gap:8px;flex-wrap:wrap}
7
9
  .hyewb-title{font-size:14px;font-weight:600}
8
10
  .hyewb-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
11
+ .hyewb-top-control{position:relative;z-index:120000;background:#f8fbff;isolation:isolate}
9
12
  .hyewb-btn{border:1px solid #94a3b8;background:#fff;color:#0f172a;border-radius:8px;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;padding:0;width:34px;height:34px;flex:0 0 auto}
10
13
  .hyewb-btn.active{border-color:#0b7285;background:#0b7285;color:#fff}
11
14
  .hyewb-btn:disabled{cursor:not-allowed;opacity:.55}
@@ -437,14 +440,14 @@ export function mountEditorWorkbench(container, options = {}) {
437
440
  const root = document.createElement("section");
438
441
  root.className = "hyewb-root";
439
442
  const header = document.createElement("header");
440
- header.className = "hyewb-header";
443
+ header.className = "hyewb-header hyewb-top-control";
441
444
  const title = document.createElement("div");
442
445
  title.className = "hyewb-title";
443
446
  title.textContent = options.title ?? "hy-ebook Editor Workbench";
444
447
  const fullscreenBtn = createButton("fullscreen");
445
448
  header.append(title);
446
449
  const toolbar = document.createElement("div");
447
- toolbar.className = "hyewb-row";
450
+ toolbar.className = "hyewb-row hyewb-top-control";
448
451
  const boldBtn = createButton("bold");
449
452
  const italicBtn = createButton("italic");
450
453
  const underlineBtn = createButton("underline");
@@ -705,7 +708,7 @@ export function mountEditorWorkbench(container, options = {}) {
705
708
  const ctxStyleBorder = createTableContextItem("行/列边框样式");
706
709
  tableContextMenu.append(ctxInsertRowUp, ctxInsertRowDown, ctxDeleteRow, ctxInsertColLeft, ctxInsertColRight, ctxDeleteCol, ctxSetRowHeight, ctxSetColWidth, ctxSelectRow, ctxSelectCol, ctxStyleBg, ctxStyleColor, ctxStyleAlign, ctxStyleBoldItalic, ctxStyleBorder);
707
710
  const pageRow = document.createElement("div");
708
- pageRow.className = "hyewb-row";
711
+ pageRow.className = "hyewb-row hyewb-top-control";
709
712
  const prevPageBtn = createButton("prevPage");
710
713
  const nextPageBtn = createButton("nextPage");
711
714
  const addPageBtn = createButton("addPage");
@@ -743,7 +746,7 @@ export function mountEditorWorkbench(container, options = {}) {
743
746
  annotationPanel.className = "hyewb-preview-annotation-panel";
744
747
  const annotationTitle = document.createElement("h3");
745
748
  annotationTitle.className = "hyewb-preview-annotation-title";
746
- annotationTitle.textContent = "预览标注";
749
+ annotationTitle.textContent = "我的笔记";
747
750
  const annotationTabs = document.createElement("div");
748
751
  annotationTabs.className = "hyewb-preview-annotation-tabs";
749
752
  const annotationHighlightTab = document.createElement("button");
@@ -921,6 +924,28 @@ export function mountEditorWorkbench(container, options = {}) {
921
924
  const nextHeight = Math.max(320, Math.floor(viewportHeight - top - bottomPadding));
922
925
  shell.style.maxHeight = `${nextHeight}px`;
923
926
  };
927
+ const updateTopControlShieldHeight = () => {
928
+ const rootRect = root.getBoundingClientRect();
929
+ const controls = [header, toolbar, pageRow];
930
+ let maxBottom = 0;
931
+ controls.forEach((control) => {
932
+ if (control.style.display === "none") {
933
+ return;
934
+ }
935
+ const rect = control.getBoundingClientRect();
936
+ const relativeBottom = rect.bottom - rootRect.top;
937
+ maxBottom = Math.max(maxBottom, relativeBottom);
938
+ });
939
+ root.style.setProperty("--hyewb-top-shield-height", `${Math.max(0, Math.ceil(maxBottom + 6))}px`);
940
+ };
941
+ const clampFloatingTop = (top) => {
942
+ return Math.round(top);
943
+ };
944
+ const clampFloatingTopWithHeight = (top, elementHeight) => {
945
+ const maxTop = Math.round(window.innerHeight - elementHeight - 8);
946
+ const rounded = Math.round(top);
947
+ return Math.min(rounded, maxTop);
948
+ };
924
949
  const requestWorkbenchFullscreen = async () => {
925
950
  const target = root;
926
951
  if (typeof target.requestFullscreen === "function") {
@@ -1639,7 +1664,7 @@ export function mountEditorWorkbench(container, options = {}) {
1639
1664
  text: selection.toString().trim(),
1640
1665
  };
1641
1666
  previewSelectionToolbar.style.left = `${Math.round(rect.left + rect.width / 2)}px`;
1642
- previewSelectionToolbar.style.top = `${Math.round(rect.top - 8)}px`;
1667
+ previewSelectionToolbar.style.top = `${clampFloatingTop(rect.top - 8)}px`;
1643
1668
  previewSelectionToolbar.classList.add("show");
1644
1669
  };
1645
1670
  const hideFloatingToolbar = () => {
@@ -1696,7 +1721,7 @@ export function mountEditorWorkbench(container, options = {}) {
1696
1721
  const nextLeft = Math.max(8, Math.min(buttonRect.left, window.innerWidth - pickerRect.width - 8));
1697
1722
  const nextTop = Math.min(window.innerHeight - pickerRect.height - 8, buttonRect.bottom + 8);
1698
1723
  tablePicker.style.left = `${Math.round(nextLeft)}px`;
1699
- tablePicker.style.top = `${Math.max(8, Math.round(nextTop))}px`;
1724
+ tablePicker.style.top = `${clampFloatingTopWithHeight(Math.max(8, Math.round(nextTop)), pickerRect.height)}px`;
1700
1725
  };
1701
1726
  const hideTableTools = () => {
1702
1727
  if (tableToolsHideTimer !== null) {
@@ -1801,18 +1826,18 @@ export function mountEditorWorkbench(container, options = {}) {
1801
1826
  cancelTableToolsHide();
1802
1827
  const tableRect = activeTableElement.getBoundingClientRect();
1803
1828
  tableMoveHandle.style.left = `${Math.round(tableRect.left - 14)}px`;
1804
- tableMoveHandle.style.top = `${Math.round(tableRect.top - 14)}px`;
1829
+ tableMoveHandle.style.top = `${clampFloatingTop(tableRect.top - 14)}px`;
1805
1830
  tableMoveHandle.classList.add("show");
1806
1831
  tableScaleHandle.style.left = `${Math.round(tableRect.right - 10)}px`;
1807
- tableScaleHandle.style.top = `${Math.round(tableRect.bottom - 10)}px`;
1832
+ tableScaleHandle.style.top = `${clampFloatingTop(tableRect.bottom - 10)}px`;
1808
1833
  tableScaleHandle.classList.add("show");
1809
1834
  tableColEdgeLayer.style.left = `${Math.round(tableRect.left)}px`;
1810
- tableColEdgeLayer.style.top = `${Math.round(tableRect.top - 12)}px`;
1835
+ tableColEdgeLayer.style.top = `${clampFloatingTop(tableRect.top - 12)}px`;
1811
1836
  tableColEdgeLayer.style.width = `${Math.max(0, Math.round(tableRect.width))}px`;
1812
1837
  tableColEdgeLayer.style.height = "14px";
1813
1838
  tableColEdgeLayer.classList.add("show");
1814
1839
  tableRowEdgeLayer.style.left = `${Math.round(tableRect.left - 12)}px`;
1815
- tableRowEdgeLayer.style.top = `${Math.round(tableRect.top)}px`;
1840
+ tableRowEdgeLayer.style.top = `${clampFloatingTop(tableRect.top)}px`;
1816
1841
  tableRowEdgeLayer.style.width = "14px";
1817
1842
  tableRowEdgeLayer.style.height = `${Math.max(0, Math.round(tableRect.height))}px`;
1818
1843
  tableRowEdgeLayer.classList.add("show");
@@ -1820,7 +1845,7 @@ export function mountEditorWorkbench(container, options = {}) {
1820
1845
  if (activeTableRowElement) {
1821
1846
  const rowRect = activeTableRowElement.getBoundingClientRect();
1822
1847
  tableRowDeleteBtn.style.left = `${Math.round(rowRect.right - 2)}px`;
1823
- tableRowDeleteBtn.style.top = `${Math.round(rowRect.top + rowRect.height / 2 - 10)}px`;
1848
+ tableRowDeleteBtn.style.top = `${clampFloatingTop(rowRect.top + rowRect.height / 2 - 10)}px`;
1824
1849
  tableRowDeleteBtn.classList.add("show");
1825
1850
  }
1826
1851
  else {
@@ -2085,7 +2110,7 @@ export function mountEditorWorkbench(container, options = {}) {
2085
2110
  ? Math.round(targetRow.top)
2086
2111
  : Math.round(tableRect.bottom);
2087
2112
  tableDropIndicator.style.left = `${Math.round(tableRect.left)}px`;
2088
- tableDropIndicator.style.top = `${y - 1}px`;
2113
+ tableDropIndicator.style.top = `${clampFloatingTop(y - 1)}px`;
2089
2114
  tableDropIndicator.style.width = `${Math.max(0, Math.round(tableRect.width))}px`;
2090
2115
  tableDropIndicator.style.height = "2px";
2091
2116
  }
@@ -2096,7 +2121,7 @@ export function mountEditorWorkbench(container, options = {}) {
2096
2121
  ? Math.round(targetCol.left)
2097
2122
  : Math.round(tableRect.right);
2098
2123
  tableDropIndicator.style.left = `${x - 1}px`;
2099
- tableDropIndicator.style.top = `${Math.round(tableRect.top)}px`;
2124
+ tableDropIndicator.style.top = `${clampFloatingTop(tableRect.top)}px`;
2100
2125
  tableDropIndicator.style.width = "2px";
2101
2126
  tableDropIndicator.style.height = `${Math.max(0, Math.round(tableRect.height))}px`;
2102
2127
  }
@@ -2179,14 +2204,14 @@ export function mountEditorWorkbench(container, options = {}) {
2179
2204
  tableColGapInsertBtn.classList.remove("show");
2180
2205
  // Row button offset is managed independently.
2181
2206
  tableRowGapInsertBtn.style.left = `${Math.round(hover.x + rowGapOffset.x)}px`;
2182
- tableRowGapInsertBtn.style.top = `${Math.round(hover.y + rowGapOffset.y)}px`;
2207
+ tableRowGapInsertBtn.style.top = `${clampFloatingTop(hover.y + rowGapOffset.y)}px`;
2183
2208
  tableRowGapInsertBtn.classList.add("show");
2184
2209
  return;
2185
2210
  }
2186
2211
  tableRowGapInsertBtn.classList.remove("show");
2187
2212
  // Column button offset is managed independently.
2188
2213
  tableColGapInsertBtn.style.left = `${Math.round(hover.x + colGapOffset.x)}px`;
2189
- tableColGapInsertBtn.style.top = `${Math.round(hover.y + colGapOffset.y)}px`;
2214
+ tableColGapInsertBtn.style.top = `${clampFloatingTop(hover.y + colGapOffset.y)}px`;
2190
2215
  tableColGapInsertBtn.classList.add("show");
2191
2216
  };
2192
2217
  const resolveRowDropIndex = (table, clientY) => {
@@ -2367,7 +2392,7 @@ export function mountEditorWorkbench(container, options = {}) {
2367
2392
  const left = Math.max(8, Math.min(clientX, window.innerWidth - rect.width - 8));
2368
2393
  const top = Math.max(8, Math.min(clientY, window.innerHeight - rect.height - 8));
2369
2394
  tableContextMenu.style.left = `${Math.round(left)}px`;
2370
- tableContextMenu.style.top = `${Math.round(top)}px`;
2395
+ tableContextMenu.style.top = `${clampFloatingTopWithHeight(top, rect.height)}px`;
2371
2396
  };
2372
2397
  const openColorPalette = (anchor, target) => {
2373
2398
  activeColorTarget = target;
@@ -2676,18 +2701,34 @@ export function mountEditorWorkbench(container, options = {}) {
2676
2701
  const updateFloatingToolbarBySelection = () => {
2677
2702
  const activeElement = document.activeElement;
2678
2703
  const isToolbarFocused = Boolean(activeElement && floatingToolbar.contains(activeElement));
2679
- const keepToolbarVisible = keepSelectionOnToolbar || isToolbarFocused;
2704
+ const liveSelection = window.getSelection();
2705
+ if (liveSelection && liveSelection.rangeCount > 0) {
2706
+ const liveRange = liveSelection.getRangeAt(0);
2707
+ const insideEditor = editorArea.contains(liveRange.startContainer) &&
2708
+ editorArea.contains(liveRange.endContainer);
2709
+ if (insideEditor && liveSelection.isCollapsed) {
2710
+ lastSelection = null;
2711
+ }
2712
+ }
2713
+ const hasExpandedSnapshot = () => {
2714
+ const snapshotRange = lastSelection?.range || rememberedRange;
2715
+ return Boolean(snapshotRange && !snapshotRange.collapsed);
2716
+ };
2717
+ const keepToolbarVisible = (keepSelectionOnToolbar || isToolbarFocused) && hasExpandedSnapshot();
2680
2718
  const restoreFloatingToolbarFromSnapshot = () => {
2681
2719
  const snapshotRange = lastSelection?.range || rememberedRange;
2682
2720
  if (!snapshotRange) {
2683
2721
  return false;
2684
2722
  }
2723
+ if (snapshotRange.collapsed) {
2724
+ return false;
2725
+ }
2685
2726
  try {
2686
2727
  const rect = snapshotRange.getBoundingClientRect();
2687
2728
  if (!rect.width && !rect.height) {
2688
2729
  return false;
2689
2730
  }
2690
- const top = Math.max(8, rect.top - 52);
2731
+ const top = clampFloatingTop(rect.top - 52);
2691
2732
  const left = rect.left + rect.width / 2;
2692
2733
  floatingToolbar.style.top = `${top}px`;
2693
2734
  floatingToolbar.style.left = `${left}px`;
@@ -2739,7 +2780,7 @@ export function mountEditorWorkbench(container, options = {}) {
2739
2780
  range: range.cloneRange(),
2740
2781
  rect,
2741
2782
  };
2742
- const top = Math.max(8, rect.top - 52);
2783
+ const top = clampFloatingTop(rect.top - 52);
2743
2784
  const left = rect.left + rect.width / 2;
2744
2785
  floatingToolbar.style.top = `${top}px`;
2745
2786
  floatingToolbar.style.left = `${left}px`;
@@ -2750,7 +2791,9 @@ export function mountEditorWorkbench(container, options = {}) {
2750
2791
  const shouldKeepFloatingToolbarVisible = () => {
2751
2792
  const activeElement = document.activeElement;
2752
2793
  const isToolbarFocused = Boolean(activeElement && floatingToolbar.contains(activeElement));
2753
- return keepSelectionOnToolbar || isToolbarFocused;
2794
+ const snapshotRange = lastSelection?.range || rememberedRange;
2795
+ const hasExpandedSnapshot = Boolean(snapshotRange && !snapshotRange.collapsed);
2796
+ return (keepSelectionOnToolbar || isToolbarFocused) && hasExpandedSnapshot;
2754
2797
  };
2755
2798
  const withSelectionCommand = (action, successMessage) => {
2756
2799
  if (state.mode !== "editor") {
@@ -3358,6 +3401,8 @@ export function mountEditorWorkbench(container, options = {}) {
3358
3401
  toolbar.style.display =
3359
3402
  showEditorControls && state.features.textToolbar ? "flex" : "none";
3360
3403
  pageRow.style.display = state.features.pageNav ? "flex" : "none";
3404
+ addPageBtn.style.display =
3405
+ showEditorControls && state.features.pageNav ? "inline-flex" : "none";
3361
3406
  videoAddBtn.style.display = state.features.video ? "inline-block" : "none";
3362
3407
  imageUploadBtn.style.display = "inline-block";
3363
3408
  status.style.display = showEditorControls ? "block" : "none";
@@ -3372,6 +3417,7 @@ export function mountEditorWorkbench(container, options = {}) {
3372
3417
  hideTablePicker();
3373
3418
  hideTableTools();
3374
3419
  }
3420
+ updateTopControlShieldHeight();
3375
3421
  prevPageBtn.disabled = state.pageIndex <= 0;
3376
3422
  nextPageBtn.disabled = state.pageIndex >= state.doc.pages.length - 1;
3377
3423
  pageInfo.textContent = `当前页 ${state.pageIndex + 1} / ${state.doc.pages.length}`;
@@ -4346,6 +4392,7 @@ export function mountEditorWorkbench(container, options = {}) {
4346
4392
  };
4347
4393
  const handleWindowResize = () => {
4348
4394
  updateShellViewportHeight();
4395
+ updateTopControlShieldHeight();
4349
4396
  updateInlineResizeOverlay();
4350
4397
  syncTableToolsPosition();
4351
4398
  syncFocusedTableControls();
@@ -4356,6 +4403,7 @@ export function mountEditorWorkbench(container, options = {}) {
4356
4403
  };
4357
4404
  const handleWindowScroll = () => {
4358
4405
  updateShellViewportHeight();
4406
+ updateTopControlShieldHeight();
4359
4407
  updateInlineResizeOverlay();
4360
4408
  updateFloatingToolbarBySelection();
4361
4409
  syncTableToolsPosition();
@@ -4380,6 +4428,7 @@ export function mountEditorWorkbench(container, options = {}) {
4380
4428
  window.requestAnimationFrame(() => {
4381
4429
  updateFullscreenButtonState();
4382
4430
  updateShellViewportHeight();
4431
+ updateTopControlShieldHeight();
4383
4432
  updateInlineResizeOverlay();
4384
4433
  syncTableToolsPosition();
4385
4434
  syncFocusedTableControls();
@@ -4578,12 +4627,22 @@ export function mountEditorWorkbench(container, options = {}) {
4578
4627
  };
4579
4628
  }
4580
4629
  function ensureWorkbenchStyles() {
4581
- if (document.getElementById(WORKBENCH_STYLE_ID)) {
4630
+ const existing = document.getElementById(WORKBENCH_STYLE_ID);
4631
+ if (existing instanceof HTMLStyleElement) {
4632
+ if (existing.dataset.hyewbVersion !== WORKBENCH_STYLE_VERSION ||
4633
+ existing.textContent !== WORKBENCH_CSS) {
4634
+ existing.textContent = WORKBENCH_CSS;
4635
+ existing.dataset.hyewbVersion = WORKBENCH_STYLE_VERSION;
4636
+ }
4582
4637
  return;
4583
4638
  }
4639
+ if (existing) {
4640
+ existing.remove();
4641
+ }
4584
4642
  const style = document.createElement("style");
4585
4643
  style.id = WORKBENCH_STYLE_ID;
4586
4644
  style.textContent = WORKBENCH_CSS;
4645
+ style.dataset.hyewbVersion = WORKBENCH_STYLE_VERSION;
4587
4646
  document.head.append(style);
4588
4647
  }
4589
4648
  function resolveFeatures(next, base = DEFAULT_EDITOR_WORKBENCH_FEATURES) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyebook/vue3-adapter",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Vue3 adapter for hy-ebook core",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,7 +17,7 @@
17
17
  "dist"
18
18
  ],
19
19
  "dependencies": {
20
- "@hyebook/core": "^0.2.2"
20
+ "@hyebook/core": "^0.2.4"
21
21
  },
22
22
  "scripts": {
23
23
  "build": "tsc -p tsconfig.json",