vue-codemirror6 0.6.0 → 0.6.3

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
@@ -61,6 +61,7 @@ Notice: `lang` and `linter` can also be set together in `extensions`. This is de
61
61
 
62
62
  - [`@codemirror/theme-one-dark`](https://github.com/codemirror/theme-one-dark)
63
63
  - [`upleveled/theme-vs-code-dark-plus`](https://github.com/upleveled/theme-vs-code-dark-plus)
64
+ - ['codemirror6-bootstrap-theme'](https://github.com/logue/codemirror6-bootstrap-theme)
64
65
 
65
66
  ## Example
66
67
 
@@ -133,6 +133,7 @@ declare const _default: import("vue-demi").DefineComponent<{
133
133
  }, {
134
134
  context: SetupContext<import("vue-demi").EmitsOptions>;
135
135
  editor: Ref<Element | undefined>;
136
+ cursor: Ref<number>;
136
137
  selection: () => EditorSelection;
137
138
  getRange: (from?: number, to?: number) => string;
138
139
  getLine: (number: number) => string;
@@ -144,7 +145,7 @@ declare const _default: import("vue-demi").DefineComponent<{
144
145
  somethingSelected: () => boolean;
145
146
  replaceRange: (replacement: string | Text, from: number, to: number) => void;
146
147
  replaceSelection: (replacement: string | Text) => void;
147
- setCursor: (position: number) => void;
148
+ setCursor: (position: number) => number;
148
149
  setSelection: (anchor: number, head?: number) => void;
149
150
  setSelections: (ranges: readonly SelectionRange[], primary?: number) => void;
150
151
  extendSelectionsBy: (f: Function) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"CodeMirror.d.ts","sourceRoot":"","sources":["../../src/components/CodeMirror.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,QAAQ,EACb,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,eAAe,EAA4B,MAAM,mBAAmB,CAAC;AAU9E,OAAO,KAAK,EACV,SAAS,EACT,cAAc,EACd,IAAI,EAEL,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,eAAe,EAA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;;OAIG;;;;;IAKH,kBAAkB;;;;;;;;;qBA6II,eAAe;sBAUZ,MAAM,OAAO,MAAM,KAAG,MAAM;sBAO5B,MAAM,KAAG,MAAM;qBAGlB,MAAM;qBAEN,MAAM;0BAED,SAAS,cAAc,EAAE;wBAE3B,MAAM;yBAML,MAAM,EAAE;6BAGJ,OAAO;gCAWtB,MAAM,GAAG,IAAI,QACpB,MAAM,MACR,MAAM;oCAW2B,MAAM,GAAG,IAAI;0BAOvB,MAAM;2BAOL,MAAM,SAAS,MAAM;4BASzC,SAAS,cAAc,EAAE,YACvB,MAAM;4BAUa,QAAQ;;oBAUlB,OAAO;;IArW5B,kBAAkB;;;;;IAKlB;;;;OAIG;;;;;;;IAOH,gBAAgB;;;;;IAKhB;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAOH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH;;;;OAIG;;;;;IAKH,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;AA3HtB,wBA8ZG"}
@@ -5,6 +5,7 @@ interface Options {
5
5
  props?: Record<any, any>;
6
6
  ref?: string;
7
7
  style?: string;
8
+ 'aria-hidden'?: string;
8
9
  }
9
10
  declare const h: (type: string | Record<any, any>, options?: Options, chidren?: any) => import("vue-demi").VNode<import("vue-demi").RendererNode, import("vue-demi").RendererElement, {
10
11
  [key: string]: any;
@@ -1 +1 @@
1
- {"version":3,"file":"h-demi.d.ts","sourceRoot":"","sources":["../../src/helpers/h-demi.ts"],"names":[],"mappings":"AAEA,UAAU,OAAO;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAWD,QAAA,MAAM,CAAC,SACC,MAAM,GAAG,OAAO,GAAG,EAAE,GAAG,CAAC,YACtB,OAAO,YACN,GAAG;;EAWd,CAAC;AAEF,QAAA,MAAM,IAAI,iBAAkB,GAAG,QACoC,CAAC;AAEpE,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC"}
1
+ {"version":3,"file":"h-demi.d.ts","sourceRoot":"","sources":["../../src/helpers/h-demi.ts"],"names":[],"mappings":"AAEA,UAAU,OAAO;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAC5B,EAAE,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAWD,QAAA,MAAM,CAAC,SACC,MAAM,GAAG,OAAO,GAAG,EAAE,GAAG,CAAC,YACtB,OAAO,YACN,GAAG;;EAWd,CAAC;AAEF,QAAA,MAAM,IAAI,iBAAkB,GAAG,QACoC,CAAC;AAEpE,OAAO,EAAE,IAAI,EAAE,CAAC,IAAI,OAAO,EAAE,CAAC"}
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import { isVue2, h as h$1, defineComponent, ref, toRefs, watch, onMounted, nextTick, onUnmounted, toRaw } from "vue-demi";
2
- import { EditorState, StateEffect, EditorSelection } from "@codemirror/state";
1
+ import { isVue2, h as h$1, defineComponent, ref, computed, watch, onMounted, nextTick, onUnmounted, toRaw } from "vue-demi";
2
+ import { StateEffect, EditorState, EditorSelection } from "@codemirror/state";
3
3
  import { EditorView, keymap } from "@codemirror/view";
4
4
  import { linter, lintGutter } from "@codemirror/lint";
5
5
  import { basicSetup, minimalSetup } from "codemirror";
@@ -41,7 +41,7 @@ var CodeMirror = defineComponent({
41
41
  },
42
42
  dark: {
43
43
  type: Boolean,
44
- default: false
44
+ default: window.matchMedia("(prefers-color-scheme: dark)").matches
45
45
  },
46
46
  basic: {
47
47
  type: Boolean,
@@ -93,27 +93,29 @@ var CodeMirror = defineComponent({
93
93
  emits: ["update:modelValue", "update"],
94
94
  setup(props, context) {
95
95
  const editor = ref();
96
- const { dark } = toRefs(props);
97
96
  const doc = ref(props.modelValue);
97
+ const cursor = computed({
98
+ get: () => view.state.selection.main.head,
99
+ set: (p) => view.dispatch({ selection: { anchor: p } })
100
+ });
98
101
  const emit = context.emit;
99
102
  let view;
100
103
  watch(doc, (value) => {
101
104
  if (view.composing) {
102
105
  return;
103
106
  }
104
- const previous = view.state.selection;
105
- view.setState(EditorState.create({
106
- doc: value,
107
- extensions: getExtensions(),
108
- selection: previous
109
- }));
107
+ view.dispatch({
108
+ changes: { from: 0, to: value.length, insert: value },
109
+ selection: { anchor: cursor.value }
110
+ });
110
111
  });
111
112
  watch(() => props.modelValue, (text) => view.dispatch({
112
- changes: { from: 0, to: view.state.doc.length, insert: text }
113
+ changes: { from: 0, to: view.state.doc.length, insert: text },
114
+ selection: { anchor: cursor.value }
113
115
  }));
114
- watch(dark, () => {
116
+ watch(() => props.dark, () => {
115
117
  view.dispatch({
116
- effects: StateEffect.appendConfig.of(EditorView.theme(props.theme, { dark: dark.value }))
118
+ effects: StateEffect.reconfigure.of(getExtensions())
117
119
  });
118
120
  });
119
121
  onMounted(async () => {
@@ -144,7 +146,7 @@ var CodeMirror = defineComponent({
144
146
  props.basic ? basicSetup : void 0,
145
147
  props.minimal && !props.basic ? minimalSetup : void 0,
146
148
  EditorView.updateListener.of((update) => emit("update", update)),
147
- EditorView.theme(props.theme, { dark: dark.value }),
149
+ EditorView.theme(props.theme, { dark: props.dark }),
148
150
  props.wrap ? EditorView.lineWrapping : void 0,
149
151
  props.tab ? keymap.of([indentWithTab]) : void 0,
150
152
  props.phrases ? EditorState.phrases.of(props.phrases) : void 0,
@@ -161,7 +163,7 @@ var CodeMirror = defineComponent({
161
163
  const getRange = (from, to) => view.state.sliceDoc(from, to);
162
164
  const getLine = (number) => view.state.doc.line(number + 1).text;
163
165
  const lineCount = () => view.state.doc.lines;
164
- const getCursor = () => selection().main.head;
166
+ const getCursor = () => cursor.value;
165
167
  const listSelections = () => selection().ranges;
166
168
  const getSelection = () => view.state.sliceDoc(selection().main.from, selection().main.to);
167
169
  const getSelections = () => selection().ranges.map((r) => view.state.sliceDoc(r.from, r.to));
@@ -170,7 +172,7 @@ var CodeMirror = defineComponent({
170
172
  changes: { from, to, insert: replacement }
171
173
  });
172
174
  const replaceSelection = (replacement) => view.dispatch(view.state.replaceSelection(replacement));
173
- const setCursor = (position) => view.dispatch({ selection: { anchor: position } });
175
+ const setCursor = (position) => cursor.value = position;
174
176
  const setSelection = (anchor, head) => view.dispatch({ selection: { anchor, head } });
175
177
  const setSelections = (ranges, primary) => view.dispatch({
176
178
  selection: EditorSelection.create(ranges, primary)
@@ -183,6 +185,7 @@ var CodeMirror = defineComponent({
183
185
  return {
184
186
  context,
185
187
  editor,
188
+ cursor,
186
189
  selection,
187
190
  getRange,
188
191
  getLine,
@@ -206,7 +209,7 @@ var CodeMirror = defineComponent({
206
209
  return h("div", {
207
210
  ref: "editor",
208
211
  class: "vue-codemirror"
209
- }, this.$slots.default ? h("aside", { style: "display: none;" }, slot(this.$slots.default)) : void 0);
212
+ }, this.$slots.default ? h("aside", { style: "display: none;", "aria-hidden": "true" }, slot(this.$slots.default)) : void 0);
210
213
  }
211
214
  });
212
215
  /**
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(r,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue-demi"),require("@codemirror/state"),require("@codemirror/view"),require("@codemirror/lint"),require("codemirror"),require("@codemirror/commands"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","vue-demi","@codemirror/state","@codemirror/view","@codemirror/lint","codemirror","@codemirror/commands","lodash"],n):(r=typeof globalThis<"u"?globalThis:r||self,n(r.CodeMirror={},r.VueDemi,r.state,r.view,r.lint,r.codemirror,r.commands,r.lodash))})(this,function(r,n,f,d,p,g,V,S){"use strict";const C=e=>e?Object.entries(e).reduce((c,[a,l])=>(a=a.charAt(0).toUpperCase()+a.slice(1),a=`on${a}`,{...c,[a]:l}),{}):null,y=(e,c={},a)=>{if(n.isVue2)return n.h(e,c,a);const{props:l,domProps:u,on:m,...o}=c,h=m?C(m):{};return n.h(e,{...o,...l,...u,...h},a)},w=e=>typeof e=="function"?e():e;var v=n.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},theme:{type:Object,default:()=>({})},dark:{type:Boolean,default:!1},basic:{type:Boolean,default:!1},minimal:{type:Boolean,default:!1},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},editable:{type:Boolean,default:!0},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:()=>{}},lang:{type:Object,default:()=>{}},linter:{type:Function,default:void 0},lintGutter:{type:Boolean,defalt:!1}},emits:["update:modelValue","update"],setup(e,c){const a=n.ref(),{dark:l}=n.toRefs(e),u=n.ref(e.modelValue),m=c.emit;let o;n.watch(u,t=>{if(o.composing)return;const i=o.state.selection;o.setState(f.EditorState.create({doc:t,extensions:h(),selection:i}))}),n.watch(()=>e.modelValue,t=>o.dispatch({changes:{from:0,to:o.state.doc.length,insert:t}})),n.watch(l,()=>{o.dispatch({effects:f.StateEffect.appendConfig.of(d.EditorView.theme(e.theme,{dark:l.value}))})}),n.onMounted(async()=>{let t=u.value;a.value&&a.value.childNodes[0]&&(u.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),t=S.trim(a.value.childNodes[0].innerText)),o=new d.EditorView({doc:t,extensions:h(),parent:a.value,dispatch:i=>{o.update([i]),!i.changes.empty&&(u.value=o.state.doc.toString(),m("update:modelValue",u.value))}}),await n.nextTick()}),n.onUnmounted(()=>o.destroy());const h=()=>S.compact([e.basic?g.basicSetup:void 0,e.minimal&&!e.basic?g.minimalSetup:void 0,d.EditorView.updateListener.of(i=>m("update",i)),d.EditorView.theme(e.theme,{dark:l.value}),e.wrap?d.EditorView.lineWrapping:void 0,e.tab?d.keymap.of([V.indentWithTab]):void 0,e.phrases?f.EditorState.phrases.of(e.phrases):void 0,e.readonly?f.EditorState.readOnly.of(e.readonly):void 0,e.editable?d.EditorView.editable.of(e.editable):void 0,e.lang?n.toRaw(e.lang):void 0,e.linter?p.linter(e.linter):void 0,e.linter&&e.lintGutter?p.lintGutter():void 0,...e.extensions]),s=()=>o.state.selection;return{context:c,editor:a,selection:s,getRange:(t,i)=>o.state.sliceDoc(t,i),getLine:t=>o.state.doc.line(t+1).text,lineCount:()=>o.state.doc.lines,getCursor:()=>s().main.head,listSelections:()=>s().ranges,getSelection:()=>o.state.sliceDoc(s().main.from,s().main.to),getSelections:()=>s().ranges.map(t=>o.state.sliceDoc(t.from,t.to)),somethingSelected:()=>s().ranges.some(t=>!t.empty),replaceRange:(t,i,E)=>o.dispatch({changes:{from:i,to:E,insert:t}}),replaceSelection:t=>o.dispatch(o.state.replaceSelection(t)),setCursor:t=>o.dispatch({selection:{anchor:t}}),setSelection:(t,i)=>o.dispatch({selection:{anchor:t,head:i}}),setSelections:(t,i)=>o.dispatch({selection:f.EditorSelection.create(t,i)}),extendSelectionsBy:t=>o.dispatch({selection:f.EditorSelection.create(s().ranges.map(i=>i.extend(t(i))))}),focus:()=>o.focus(),hasFocus:()=>o.hasFocus}},render(){return y("div",{ref:"editor",class:"vue-codemirror"},this.$slots.default?y("aside",{style:"display: none;"},w(this.$slots.default)):void 0)}});/**
1
+ (function(r,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("vue-demi"),require("@codemirror/state"),require("@codemirror/view"),require("@codemirror/lint"),require("codemirror"),require("@codemirror/commands"),require("lodash")):typeof define=="function"&&define.amd?define(["exports","vue-demi","@codemirror/state","@codemirror/view","@codemirror/lint","codemirror","@codemirror/commands","lodash"],n):(r=typeof globalThis<"u"?globalThis:r||self,n(r.CodeMirror={},r.VueDemi,r.state,r.view,r.lint,r.codemirror,r.commands,r.lodash))})(this,function(r,n,f,u,g,p,w,y){"use strict";const V=e=>e?Object.entries(e).reduce((c,[i,s])=>(i=i.charAt(0).toUpperCase()+i.slice(1),i=`on${i}`,{...c,[i]:s}),{}):null,S=(e,c={},i)=>{if(n.isVue2)return n.h(e,c,i);const{props:s,domProps:d,on:m,...o}=c,h=m?V(m):{};return n.h(e,{...o,...s,...d,...h},i)},C=e=>typeof e=="function"?e():e;var v=n.defineComponent({name:"CodeMirror",model:{prop:"modelValue",event:"update:modelValue"},props:{modelValue:{type:String,default:""},theme:{type:Object,default:()=>({})},dark:{type:Boolean,default:window.matchMedia("(prefers-color-scheme: dark)").matches},basic:{type:Boolean,default:!1},minimal:{type:Boolean,default:!1},wrap:{type:Boolean,default:!1},tab:{type:Boolean,default:!1},readonly:{type:Boolean,default:!1},editable:{type:Boolean,default:!0},extensions:{type:Array,default:()=>[]},phrases:{type:Object,default:()=>{}},lang:{type:Object,default:()=>{}},linter:{type:Function,default:void 0},lintGutter:{type:Boolean,defalt:!1}},emits:["update:modelValue","update"],setup(e,c){const i=n.ref(),s=n.ref(e.modelValue),d=n.computed({get:()=>o.state.selection.main.head,set:t=>o.dispatch({selection:{anchor:t}})}),m=c.emit;let o;n.watch(s,t=>{o.composing||o.dispatch({changes:{from:0,to:t.length,insert:t},selection:{anchor:d.value}})}),n.watch(()=>e.modelValue,t=>o.dispatch({changes:{from:0,to:o.state.doc.length,insert:t},selection:{anchor:d.value}})),n.watch(()=>e.dark,()=>{o.dispatch({effects:f.StateEffect.reconfigure.of(h())})}),n.onMounted(async()=>{let t=s.value;i.value&&i.value.childNodes[0]&&(s.value!==""&&console.warn("[CodeMirror.vue] The <code-mirror> tag contains child elements that overwrite the `v-model` values."),t=y.trim(i.value.childNodes[0].innerText)),o=new u.EditorView({doc:t,extensions:h(),parent:i.value,dispatch:a=>{o.update([a]),!a.changes.empty&&(s.value=o.state.doc.toString(),m("update:modelValue",s.value))}}),await n.nextTick()}),n.onUnmounted(()=>o.destroy());const h=()=>y.compact([e.basic?p.basicSetup:void 0,e.minimal&&!e.basic?p.minimalSetup:void 0,u.EditorView.updateListener.of(a=>m("update",a)),u.EditorView.theme(e.theme,{dark:e.dark}),e.wrap?u.EditorView.lineWrapping:void 0,e.tab?u.keymap.of([w.indentWithTab]):void 0,e.phrases?f.EditorState.phrases.of(e.phrases):void 0,e.readonly?f.EditorState.readOnly.of(e.readonly):void 0,e.editable?u.EditorView.editable.of(e.editable):void 0,e.lang?n.toRaw(e.lang):void 0,e.linter?g.linter(e.linter):void 0,e.linter&&e.lintGutter?g.lintGutter():void 0,...e.extensions]),l=()=>o.state.selection;return{context:c,editor:i,cursor:d,selection:l,getRange:(t,a)=>o.state.sliceDoc(t,a),getLine:t=>o.state.doc.line(t+1).text,lineCount:()=>o.state.doc.lines,getCursor:()=>d.value,listSelections:()=>l().ranges,getSelection:()=>o.state.sliceDoc(l().main.from,l().main.to),getSelections:()=>l().ranges.map(t=>o.state.sliceDoc(t.from,t.to)),somethingSelected:()=>l().ranges.some(t=>!t.empty),replaceRange:(t,a,b)=>o.dispatch({changes:{from:a,to:b,insert:t}}),replaceSelection:t=>o.dispatch(o.state.replaceSelection(t)),setCursor:t=>d.value=t,setSelection:(t,a)=>o.dispatch({selection:{anchor:t,head:a}}),setSelections:(t,a)=>o.dispatch({selection:f.EditorSelection.create(t,a)}),extendSelectionsBy:t=>o.dispatch({selection:f.EditorSelection.create(l().ranges.map(a=>a.extend(t(a))))}),focus:()=>o.focus(),hasFocus:()=>o.hasFocus}},render(){return S("div",{ref:"editor",class:"vue-codemirror"},this.$slots.default?S("aside",{style:"display: none;","aria-hidden":"true"},C(this.$slots.default)):void 0)}});/**
2
2
  * Vue CodeMirror6 Component
3
3
  *
4
4
  * @license MIT
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "vue-codemirror6",
4
- "version": "0.6.0",
4
+ "version": "0.6.3",
5
5
  "description": "CodeMirror6 Component for vue2 and vue3",
6
6
  "keywords": [
7
7
  "vuejs",
@@ -55,7 +55,7 @@
55
55
  "dev": "vite",
56
56
  "clean": "rimraf node_modules/.vite && npx vue-demi-fix",
57
57
  "build": "vite build & vue-tsc --declaration --emitDeclarationOnly",
58
- "build:analyze": "vue-tsc --noEmit && vite build --mode analyze",
58
+ "build:analyze": "vue-tsc --noEmit & vue-tsc --declaration --emitDeclarationOnly & vite build --mode analyze",
59
59
  "build:docs": "vite build --config vite.config.docs.ts",
60
60
  "build:clean": "rimraf dist",
61
61
  "lint": "eslint --fix --cache --cache-location ./node_modules/.vite/vite-plugin-eslint && prettier . -w -u",
@@ -80,36 +80,36 @@
80
80
  "@codemirror/lang-javascript": "^6.0.0",
81
81
  "@codemirror/lang-markdown": "^6.0.0",
82
82
  "@types/lodash": "^4.14.182",
83
- "@types/node": "^17.0.41",
84
- "@typescript-eslint/eslint-plugin": "^5.27.1",
85
- "@typescript-eslint/parser": "^5.27.1",
83
+ "@types/node": "^18.0.0",
84
+ "@typescript-eslint/eslint-plugin": "^5.29.0",
85
+ "@typescript-eslint/parser": "^5.29.0",
86
86
  "@vitejs/plugin-vue": "^2.3.3",
87
87
  "@vue/eslint-config-prettier": "^7.0.0",
88
- "eslint": "^8.17.0",
88
+ "eslint": "^8.18.0",
89
89
  "eslint-config-google": "^0.14.0",
90
90
  "eslint-config-prettier": "^8.5.0",
91
91
  "eslint-import-resolver-alias": "^1.1.2",
92
92
  "eslint-import-resolver-typescript": "^2.7.1",
93
93
  "eslint-plugin-html": "^6.2.0",
94
94
  "eslint-plugin-import": "^2.26.0",
95
- "eslint-plugin-jsdoc": "^39.3.2",
95
+ "eslint-plugin-jsdoc": "^39.3.3",
96
96
  "eslint-plugin-tsdoc": "^0.2.16",
97
- "eslint-plugin-vue": "^9.1.0",
97
+ "eslint-plugin-vue": "^9.1.1",
98
98
  "eslint-plugin-vuejs-accessibility": "^1.2.0",
99
99
  "eslint-plugin-yaml": "^0.5.0",
100
100
  "eslint4b-prebuilt": "^6.7.2",
101
101
  "husky": "^8.0.1",
102
- "lint-staged": "^13.0.1",
102
+ "lint-staged": "^13.0.2",
103
103
  "lodash": "^4.17.21",
104
- "prettier": "^2.6.2",
104
+ "prettier": "^2.7.1",
105
105
  "rimraf": "^3.0.2",
106
106
  "rollup-plugin-visualizer": "^5.6.0",
107
- "typescript": "^4.7.3",
108
- "vite": "^2.9.10",
107
+ "typescript": "^4.7.4",
108
+ "vite": "^2.9.12",
109
109
  "vite-plugin-checker": "^0.4.6",
110
110
  "vue": "^3.2.37",
111
- "vue-eslint-parser": "^9.0.2",
112
- "vue-tsc": "^0.37.3"
111
+ "vue-eslint-parser": "^9.0.3",
112
+ "vue-tsc": "^0.38.1"
113
113
  },
114
114
  "husky": {
115
115
  "hooks": {