reactive-vscode 0.2.0-beta.3 → 0.2.0-beta.5

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
@@ -5,9 +5,70 @@
5
5
  [![License][license-src]][license-href]
6
6
 
7
7
  ![Header](./docs/public/header.png)
8
+
8
9
  **Develop VSCode extension with Vue Reactivity API**
9
10
 
10
- [**Documentation**](https://kermanx.github.io/reactive-vscode/) | [**Why reactive-vscode**](https://kermanx.github.io/reactive-vscode/guide/why) | [**Functions**](https://kermanx.github.io/reactive-vscode/functions/) | [**Examples**](https://kermanx.github.io/reactive-vscode/examples/)
11
+ - [**Documentation**](https://kermanx.github.io/reactive-vscode/)
12
+ - [**Why reactive-vscode**](https://kermanx.github.io/reactive-vscode/guide/why)
13
+ - [**All Functions**](https://kermanx.github.io/reactive-vscode/functions/)
14
+
15
+ ### Counter Example
16
+
17
+ ```ts
18
+ import { defineExtension, ref, useCommands, useStatusBarItem } from 'reactive-vscode'
19
+ import { StatusBarAlignment } from 'vscode'
20
+
21
+ export = defineExtension(() => {
22
+ const counter = ref(0)
23
+
24
+ useStatusBarItem({
25
+ alignment: StatusBarAlignment.Right,
26
+ priority: 100,
27
+ text: () => `$(megaphone) Hello*${counter.value}`,
28
+ })
29
+
30
+ useCommands({
31
+ 'extension.sayHello': () => counter.value++,
32
+ 'extension.sayGoodbye': () => counter.value--,
33
+ })
34
+ })
35
+ ```
36
+
37
+ <details>
38
+ <summary> Implementation with original VSCode API </summary>
39
+
40
+ ```ts
41
+ import type { ExtensionContext } from 'vscode'
42
+ import { StatusBarAlignment, commands, window } from 'vscode'
43
+
44
+ export function activate(extensionContext: ExtensionContext) {
45
+ let counter = 0
46
+
47
+ const item = window.createStatusBarItem(StatusBarAlignment.Right, 100)
48
+
49
+ function updateStatusBar() {
50
+ item.text = `$(megaphone) Hello*${counter}`
51
+ item.show()
52
+ }
53
+
54
+ updateStatusBar()
55
+
56
+ extensionContext.subscriptions.push(
57
+ commands.registerCommand('extension.sayHello', () => {
58
+ counter++
59
+ updateStatusBar()
60
+ }),
61
+ commands.registerCommand('extension.sayGoodbye', () => {
62
+ counter--
63
+ updateStatusBar()
64
+ }),
65
+ )
66
+ }
67
+ ```
68
+
69
+ </details>
70
+
71
+ [More examples](https://kermanx.github.io/reactive-vscode/examples/).
11
72
 
12
73
  ## License
13
74
 
package/dist/index.d.ts CHANGED
@@ -61,19 +61,41 @@ export declare interface Commands extends Record<string, (...args: any[]) => any
61
61
  'vscode.open': (uri: Uri) => void;
62
62
  }
63
63
 
64
- export declare interface ConfigRef<T> extends ShallowRef<T> {
64
+ export declare type ConfigObject<C extends object> = ShallowReactive<C & {
65
+ /**
66
+ * Write the configuration value to the workspace.
67
+ *
68
+ * @see https://code.visualstudio.com/api/references/vscode-api#WorkspaceConfiguration.update
69
+ */
70
+ $update: (key: keyof C, value: C[keyof C], configurationTarget?: Nullable<ConfigurationTarget>, overrideInLanguage?: boolean) => Promise<void>;
71
+ /**
72
+ * Set the value without updating the workspace.
73
+ */
74
+ $set: (key: keyof C, value: C[keyof C]) => void;
75
+ }>;
76
+
77
+ export declare interface ConfigRef<T> extends WritableComputedRef<T> {
78
+ /**
79
+ * Write the configuration value to the workspace.
80
+ *
81
+ * @see https://code.visualstudio.com/api/references/vscode-api#WorkspaceConfiguration.update
82
+ */
65
83
  update: (value: T, configurationTarget?: ConfigurationTarget | boolean | null, overrideInLanguage?: boolean) => Promise<void>;
84
+ /**
85
+ * Set the value without updating the workspace.
86
+ */
87
+ set: (value: T) => void;
66
88
  }
67
89
 
68
90
  export declare interface ConfigType<T> extends ObjectConstructor {
69
91
  [ConfigTypeSymbol]: T;
70
92
  }
71
93
 
72
- declare type ConfigTypeOptions = Record<string, ConfigTypeRaw<any>>;
94
+ /* Excluded from this release type: ConfigTypeOptions */
73
95
 
74
96
  declare type ConfigTypeRaw<T> = ConfigTypeSingle<T> | ConfigTypeSingle<T>[];
75
97
 
76
- declare type ConfigTypeSingle<T> = string | typeof String | typeof Number | typeof Boolean | typeof Array | typeof Object | null | ConfigType<T>;
98
+ declare type ConfigTypeSingle<T> = typeof String | typeof Number | typeof Boolean | typeof Array | typeof Object | null | ConfigType<T>;
77
99
 
78
100
  declare const ConfigTypeSymbol: unique symbol;
79
101
 
@@ -96,17 +118,32 @@ export declare function createSingletonComposable<T>(fn: () => T): () => T;
96
118
  /**
97
119
  * Define configurations of an extension. See `vscode::workspace.getConfiguration`.
98
120
  *
121
+ * You can use this function with [vscode-ext-gen](https://github.com/antfu/vscode-ext-gen).
122
+ *
99
123
  * @category lifecycle
100
124
  */
101
- export declare function defineConfigs<const C extends ConfigTypeOptions>(section: string, configs: C, scope?: ConfigurationScope | null | undefined): ParseConfigTypeOptions<C>;
125
+ export declare function defineConfigObject<const C extends ConfigTypeOptions>(section: string, configs: C, scope?: Nullable<ConfigurationScope>): ConfigObject<ParseConfigTypeOptions<C>>;
126
+
127
+ export declare function defineConfigObject<C extends object>(section: string, configs: C, scope?: Nullable<ConfigurationScope>): ConfigObject<C>;
128
+
129
+ /**
130
+ * Define configurations of an extension. See `vscode::workspace.getConfiguration`.
131
+ *
132
+ * You can use this function with [vscode-ext-gen](https://github.com/antfu/vscode-ext-gen).
133
+ *
134
+ * @category lifecycle
135
+ */
136
+ export declare function defineConfigs<const C extends ConfigTypeOptions>(section: string, configs: C, scope?: Nullable<ConfigurationScope>): ToConfigRefs<ParseConfigTypeOptions<C>>;
137
+
138
+ export declare function defineConfigs<C extends object>(section: string, configs: C, scope?: Nullable<ConfigurationScope>): ToConfigRefs<C>;
102
139
 
103
140
  /**
104
141
  * Define a new extension.
105
142
  *
106
143
  * @category lifecycle
107
144
  */
108
- export declare function defineExtension(setup: () => void): {
109
- activate: (extCtx: ExtensionContext) => void;
145
+ export declare function defineExtension<T>(setup: () => T): {
146
+ activate: (extCtx: ExtensionContext) => T | undefined;
110
147
  deactivate: () => void;
111
148
  };
112
149
 
@@ -179,14 +216,16 @@ export declare function onDeactivate(fn: OnDeactivateCb): void;
179
216
 
180
217
  declare type OnDeactivateCb = () => void;
181
218
 
182
- declare type ParseConfigType<C extends ConfigTypeRaw<any>> = C extends string ? (C extends 'string' ? string : C extends 'number' ? number : C extends 'boolean' ? boolean : C extends 'null' ? null : C extends 'integer' ? number : C extends 'array' ? any[] : C extends 'object' ? Record<string | number, any> : never) : C extends (infer C1)[] ? (C1 extends ConfigTypeSingle<any> ? ParseConfigType<C1> : never) : C extends ConfigType<infer T> ? T : (C extends typeof String ? string : C extends typeof Number ? number : C extends typeof Boolean ? boolean : C extends typeof Array ? any[] : C extends typeof Object ? Record<string | number, any> : C extends null ? null : never);
219
+ declare type ParseConfigType<C extends ConfigTypeRaw<any>> = C extends (infer C1)[] ? (C1 extends ConfigTypeSingle<any> ? ParseConfigType<C1> : never) : C extends ConfigType<infer T> ? T : (C extends typeof String ? string : C extends typeof Number ? number : C extends typeof Boolean ? boolean : C extends typeof Array ? any[] : C extends typeof Object ? Record<string | number, any> : C extends null ? null : never);
183
220
 
184
- declare type ParseConfigTypeOptions<C extends ConfigTypeOptions> = {
185
- [K in keyof C]: ConfigRef<ParseConfigType<C[K]>>;
186
- };
221
+ /* Excluded from this release type: ParseConfigTypeOptions */
187
222
 
188
223
  export declare type TextEditorCommandCallback = (textEditor: TextEditor, edit: TextEditorEdit, ...args: any[]) => void;
189
224
 
225
+ declare type ToConfigRefs<C extends object> = {
226
+ [K in keyof C]: ConfigRef<C[K]>;
227
+ };
228
+
190
229
  export declare interface TreeViewNode {
191
230
  readonly children?: this[];
192
231
  readonly treeItem: TreeItem | Thenable<TreeItem>;
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import { getCurrentScope as A, onScopeDispose as N, shallowRef as l, effectScope as H, computed as d, toValue as a, watchEffect as h, watch as b, ref as x, shallowReactive as U, toRaw as q, isRef as J } from "@reactive-vscode/reactivity";
1
+ import { getCurrentScope as N, onScopeDispose as F, shallowRef as l, effectScope as q, computed as d, shallowReactive as L, toValue as a, watchEffect as h, watch as C, ref as x, toRaw as J, isRef as K } from "@reactive-vscode/reactivity";
2
2
  export * from "@reactive-vscode/reactivity";
3
- import { workspace as m, commands as E, window as c, debug as y, extensions as p, comments as K, env as w, EventEmitter as F, tasks as T, Uri as z, languages as Y, ColorThemeKind as R, l10n as V } from "vscode";
4
- function G(e) {
5
- return A() ? (N(e), !0) : !1;
3
+ import { workspace as b, commands as E, window as c, debug as y, extensions as k, comments as z, env as T, EventEmitter as O, tasks as D, Uri as Y, languages as G, ColorThemeKind as V, l10n as A } from "vscode";
4
+ function Q(e) {
5
+ return N() ? (F(e), !0) : !1;
6
6
  }
7
- function L(e, t) {
7
+ function W(e, t) {
8
8
  const n = /* @__PURE__ */ new Map();
9
9
  return (...r) => {
10
10
  const i = t(...r);
@@ -12,61 +12,76 @@ function L(e, t) {
12
12
  return o ? o.refCount++ : (o = {
13
13
  data: e(...r),
14
14
  refCount: 1
15
- }, n.set(i, o)), G(() => {
15
+ }, n.set(i, o)), Q(() => {
16
16
  --o.refCount === 0 && n.delete(i);
17
17
  }), o.data;
18
18
  };
19
19
  }
20
- function v(e) {
20
+ function g(e) {
21
21
  let t;
22
22
  return () => t ?? (t = e());
23
23
  }
24
- const W = [];
25
- function le(e) {
26
- W.push(e);
24
+ const $ = [];
25
+ function fe(e) {
26
+ $.push(e);
27
27
  }
28
- const S = l(null), k = H();
29
- function de(e) {
28
+ const p = l(null), R = q();
29
+ function ve(e) {
30
30
  return {
31
- activate: (t) => {
32
- S.value = t, k.run(() => {
33
- I.map((n) => n(t)), e();
34
- });
35
- },
31
+ activate: (t) => (p.value = t, R.run(() => (I.map((n) => n(t)), e()))),
36
32
  deactivate: () => {
37
- W.map((t) => t()), k.stop();
33
+ $.map((t) => t()), R.stop();
38
34
  }
39
35
  };
40
36
  }
41
37
  const I = [];
42
- function O(e) {
43
- S.value ? e(S.value) : I.push(e);
44
- }
45
- function fe(e, t, n) {
46
- const r = m.getConfiguration(e, n);
47
- function i(u, g) {
48
- const f = l(g);
49
- return f.update = async (C, j, B) => {
50
- await r.update(u, C, j, B), f.value = C;
51
- }, f;
38
+ function P(e) {
39
+ p.value ? e(p.value) : I.push(e);
40
+ }
41
+ function X(e, t, n) {
42
+ const r = b.getConfiguration(e, n);
43
+ function i(u, v) {
44
+ const f = l(v), m = d({
45
+ get: () => f.value,
46
+ set: (w) => {
47
+ f.value = w, r.update(u, w);
48
+ }
49
+ });
50
+ return m.update = async (w, H, U) => {
51
+ await r.update(u, w, H, U), m.value = w;
52
+ }, m.set = (w) => {
53
+ f.value = w;
54
+ }, m;
52
55
  }
53
56
  const o = Object.fromEntries(
54
57
  Object.keys(t).map((u) => [u, i(u, r.get(u))])
55
58
  );
56
- return O(() => {
57
- s(m.onDidChangeConfiguration((u) => {
59
+ return P(() => {
60
+ s(b.onDidChangeConfiguration((u) => {
58
61
  if (!u.affectsConfiguration(e))
59
62
  return;
60
- const g = m.getConfiguration(e);
63
+ const v = b.getConfiguration(e);
61
64
  for (const f in t)
62
- u.affectsConfiguration(`${e}.${f}`) && (o[f].value = g.get(f));
65
+ u.affectsConfiguration(`${e}.${f}`) && o[f].set(v.get(f));
63
66
  }));
64
67
  }), o;
65
68
  }
66
- function ve(e, t) {
69
+ function ge(e, t, n) {
70
+ const r = X(e, t, n);
71
+ return L({
72
+ ...r,
73
+ $update(i, o, u, v) {
74
+ return r[i].update(o, u, v);
75
+ },
76
+ $set(i, o) {
77
+ return r[i].set(o);
78
+ }
79
+ });
80
+ }
81
+ function he(e, t) {
67
82
  const n = l(null), r = [], i = (o) => (...u) => n.value ? n.value[o](...u) : (r.push([o, u]), null);
68
- return O(() => {
69
- n.value = ie(e, t);
83
+ return P(() => {
84
+ n.value = oe(e, t);
70
85
  for (const [o, u] of r)
71
86
  n.value[o](...u);
72
87
  }), {
@@ -86,85 +101,85 @@ function ve(e, t) {
86
101
  hide: i("hide")
87
102
  };
88
103
  }
89
- function ge(e, ...t) {
104
+ function me(e, ...t) {
90
105
  return E.executeCommand(e, ...t);
91
106
  }
92
- function Q(e, t = !1) {
93
- const n = S.value;
107
+ function Z(e, t = !1) {
108
+ const n = p.value;
94
109
  if (!n && !t)
95
110
  throw new Error("Cannot get absolute path because the extension is not activated yet");
96
111
  return n == null ? void 0 : n.asAbsolutePath(e);
97
112
  }
98
- function he(e, t = !1) {
99
- return d(() => Q(a(e), t));
113
+ function be(e, t = !1) {
114
+ return d(() => Z(a(e), t));
100
115
  }
101
116
  function s(e) {
102
- return (A() ?? k).cleanups.push(e.dispose.bind(e)), e;
117
+ return (N() ?? R).cleanups.push(e.dispose.bind(e)), e;
103
118
  }
104
- const X = v(() => {
119
+ const _ = g(() => {
105
120
  const e = l(c.activeColorTheme);
106
121
  return s(c.onDidChangeActiveColorTheme((t) => {
107
122
  e.value = t;
108
123
  })), e;
109
- }), me = v(() => {
124
+ }), Ce = g(() => {
110
125
  const e = l(y.activeDebugSession);
111
126
  return s(y.onDidChangeActiveDebugSession((t) => {
112
127
  e.value = t;
113
128
  })), d(() => e.value);
114
- }), Z = v(() => {
129
+ }), ee = g(() => {
115
130
  const e = l(c.activeTextEditor);
116
131
  return s(c.onDidChangeActiveTextEditor((t) => {
117
132
  e.value = t;
118
133
  })), e;
119
134
  });
120
- function _(e, t, n) {
135
+ function te(e, t, n) {
121
136
  const r = "key" in t ? t : c.createTextEditorDecorationType(t);
122
137
  h(() => {
123
138
  var i;
124
139
  (i = a(e)) == null || i.setDecorations(r, a(n));
125
140
  });
126
141
  }
127
- function be(e, t) {
128
- const n = Z();
129
- _(n, e, t);
142
+ function we(e, t) {
143
+ const n = ee();
144
+ te(n, e, t);
130
145
  }
131
- const Ce = v(() => {
146
+ const Te = g(() => {
132
147
  const e = l(c.activeNotebookEditor);
133
148
  return s(c.onDidChangeActiveNotebookEditor((t) => {
134
149
  e.value = t;
135
150
  })), e;
136
- }), we = v(() => {
151
+ }), De = g(() => {
137
152
  const e = l(c.activeTerminal);
138
153
  return s(c.onDidChangeActiveTerminal((t) => {
139
154
  e.value = t;
140
155
  })), e;
141
- }), Te = v(() => {
142
- const e = l(p.all);
143
- return s(p.onDidChange(() => {
144
- e.value = p.all;
156
+ }), Se = g(() => {
157
+ const e = l(k.all);
158
+ return s(k.onDidChange(() => {
159
+ e.value = k.all;
145
160
  })), d(() => e.value);
146
161
  });
147
- function ee(e, t) {
162
+ function ne(e, t) {
148
163
  s(E.registerCommand(e, t));
149
164
  }
150
- function De(e) {
165
+ function pe(e) {
151
166
  for (const [t, n] of Object.entries(e))
152
- n && ee(t, n);
167
+ n && ne(t, n);
153
168
  }
154
- function Se(e, t) {
155
- return s(K.createCommentController(e, t));
169
+ function xe(e, t) {
170
+ return s(z.createCommentController(e, t));
156
171
  }
157
- function P(e) {
172
+ function M(e) {
158
173
  var n;
159
174
  const t = l((n = a(e)) == null ? void 0 : n.state);
160
- return b(e, () => {
175
+ return C(e, () => {
161
176
  var r;
162
177
  t.value = (r = a(e)) == null ? void 0 : r.state;
163
178
  }), s(c.onDidChangeTerminalState((r) => {
164
179
  r === a(e) && (t.value = r.state);
165
180
  })), d(() => t.value);
166
181
  }
167
- function xe(...e) {
182
+ function Ee(...e) {
168
183
  const t = x(null);
169
184
  function n() {
170
185
  return !!t.value && t.value.exitStatus == null;
@@ -172,8 +187,8 @@ function xe(...e) {
172
187
  function r() {
173
188
  return n() ? t.value : t.value = c.createTerminal(...e);
174
189
  }
175
- function i(g) {
176
- r().sendText(g);
190
+ function i(v) {
191
+ r().sendText(v);
177
192
  }
178
193
  function o() {
179
194
  r().show();
@@ -181,39 +196,39 @@ function xe(...e) {
181
196
  function u() {
182
197
  n() && (t.value.sendText(""), t.value.dispose(), t.value = null);
183
198
  }
184
- return N(u), {
199
+ return F(u), {
185
200
  terminal: t,
186
201
  getIsActive: n,
187
202
  show: o,
188
203
  sendText: i,
189
204
  close: u,
190
- state: P(t)
205
+ state: M(t)
191
206
  };
192
207
  }
193
- const Ee = v(() => {
194
- const e = l(w.shell);
195
- return s(w.onDidChangeShell((t) => {
208
+ const ke = g(() => {
209
+ const e = l(T.shell);
210
+ return s(T.onDidChangeShell((t) => {
196
211
  e.value = t;
197
212
  })), d(() => e.value);
198
213
  });
199
- function pe(e) {
214
+ function Re(e) {
200
215
  var n;
201
216
  const t = l((n = a(e)) == null ? void 0 : n.getText());
202
217
  return h(() => {
203
218
  var r;
204
219
  t.value = (r = a(e)) == null ? void 0 : r.getText();
205
- }), s(m.onDidChangeTextDocument((r) => {
220
+ }), s(b.onDidChangeTextDocument((r) => {
206
221
  r.document === a(e) && (t.value = r.document.getText());
207
222
  })), t;
208
223
  }
209
- function D(e, t = []) {
224
+ function S(e, t = []) {
210
225
  const n = (r, i, o) => s(e(r, i, o));
211
226
  for (const r of t)
212
227
  n(r);
213
228
  return n;
214
229
  }
215
- function te(e, t = []) {
216
- const n = Array.isArray(e) ? e : t ?? [], r = s(Array.isArray(e) || e == null ? new F() : e), i = D(r.event, n);
230
+ function re(e, t = []) {
231
+ const n = Array.isArray(e) ? e : t ?? [], r = s(Array.isArray(e) || e == null ? new O() : e), i = S(r.event, n);
217
232
  for (const o of n)
218
233
  i(o);
219
234
  return {
@@ -222,11 +237,11 @@ function te(e, t = []) {
222
237
  addListener: i
223
238
  };
224
239
  }
225
- function ke(e) {
226
- return d(() => T.fetchTasks(a(e)));
240
+ function ye(e) {
241
+ return d(() => D.fetchTasks(a(e)));
227
242
  }
228
- function ne(e) {
229
- return U({
243
+ function ie(e) {
244
+ return L({
230
245
  get scheme() {
231
246
  return a(e).scheme;
232
247
  },
@@ -256,60 +271,60 @@ function ne(e) {
256
271
  }
257
272
  });
258
273
  }
259
- function ye(e) {
260
- return ne(() => z.file(a(e)));
274
+ function Ve(e) {
275
+ return ie(() => Y.file(a(e)));
261
276
  }
262
- function Re(e, t) {
263
- const n = new F(), r = l();
277
+ function Ae(e, t) {
278
+ const n = new O(), r = l();
264
279
  h(() => {
265
280
  r.value && n.fire(), r.value = a(t);
266
- }), s(Y.registerFoldingRangeProvider(
281
+ }), s(G.registerFoldingRangeProvider(
267
282
  e,
268
283
  {
269
284
  onDidChangeFoldingRanges: n.event,
270
285
  provideFoldingRanges(i, o, u) {
271
- var g;
272
- return (g = r.value) == null ? void 0 : g.call(r, i, o, u);
286
+ var v;
287
+ return (v = r.value) == null ? void 0 : v.call(r, i, o, u);
273
288
  }
274
289
  }
275
290
  ));
276
291
  }
277
- function Ve(e, t, n, r) {
278
- const i = s(m.createFileSystemWatcher(e, t, n, r));
292
+ function Ne(e, t, n, r) {
293
+ const i = s(b.createFileSystemWatcher(e, t, n, r));
279
294
  return {
280
295
  ...i,
281
- onDidCreate: D(i.onDidCreate),
282
- onDidChange: D(i.onDidChange),
283
- onDidDelete: D(i.onDidDelete)
296
+ onDidCreate: S(i.onDidCreate),
297
+ onDidChange: S(i.onDidChange),
298
+ onDidDelete: S(i.onDidDelete)
284
299
  };
285
300
  }
286
- const Ae = v(() => {
287
- const e = X();
288
- return d(() => e.value.kind === R.Dark || e.value.kind === R.HighContrast);
289
- }), Ne = v(() => {
290
- const e = l(w.isTelemetryEnabled);
291
- return s(w.onDidChangeTelemetryEnabled((t) => {
301
+ const Fe = g(() => {
302
+ const e = _();
303
+ return d(() => e.value.kind === V.Dark || e.value.kind === V.HighContrast);
304
+ }), Le = g(() => {
305
+ const e = l(T.isTelemetryEnabled);
306
+ return s(T.onDidChangeTelemetryEnabled((t) => {
292
307
  e.value = t;
293
308
  })), d(() => e.value);
294
309
  });
295
- function Fe(e, ...t) {
296
- return d(() => typeof t[0] == "object" ? V.t(a(e), q(t[0])) : V.t(a(e), ...t.map(a)));
310
+ function Oe(e, ...t) {
311
+ return d(() => typeof t[0] == "object" ? A.t(a(e), J(t[0])) : A.t(a(e), ...t.map(a)));
297
312
  }
298
- const Le = v(() => {
299
- const e = l(w.logLevel);
300
- return s(w.onDidChangeLogLevel((t) => {
313
+ const We = g(() => {
314
+ const e = l(T.logLevel);
315
+ return s(T.onDidChangeLogLevel((t) => {
301
316
  e.value = t;
302
317
  })), d(() => e.value);
303
318
  });
304
- function re(e, t) {
319
+ function ae(e, t) {
305
320
  return s(c.createOutputChannel(e, t));
306
321
  }
307
- function We(e) {
308
- const t = /* @__PURE__ */ new Date(), n = String(t.getFullYear()).padStart(4, "0"), r = String(t.getMonth() + 1).padStart(2, "0"), i = String(t.getDate()).padStart(2, "0"), o = String(t.getHours()).padStart(2, "0"), u = String(t.getMinutes()).padStart(2, "0"), g = String(t.getSeconds()).padStart(2, "0"), f = String(t.getMilliseconds()).padStart(3, "0");
309
- return `${n}-${r}-${i} ${o}:${u}:${g}.${f} [${e}] `;
322
+ function $e(e) {
323
+ const t = /* @__PURE__ */ new Date(), n = String(t.getFullYear()).padStart(4, "0"), r = String(t.getMonth() + 1).padStart(2, "0"), i = String(t.getDate()).padStart(2, "0"), o = String(t.getHours()).padStart(2, "0"), u = String(t.getMinutes()).padStart(2, "0"), v = String(t.getSeconds()).padStart(2, "0"), f = String(t.getMilliseconds()).padStart(3, "0");
324
+ return `${n}-${r}-${i} ${o}:${u}:${v}.${f} [${e}] `;
310
325
  }
311
- function ie(e, t = {}) {
312
- const n = t.outputChannel ?? re(e), r = (i) => (...o) => {
326
+ function oe(e, t = {}) {
327
+ const n = t.outputChannel ?? ae(e), r = (i) => (...o) => {
313
328
  var u;
314
329
  n.appendLine((((u = t.getPrefix) == null ? void 0 : u.call(t, i)) ?? "") + o.join(" "));
315
330
  };
@@ -327,10 +342,10 @@ function ie(e, t = {}) {
327
342
  hide: n.hide.bind(n)
328
343
  };
329
344
  }
330
- function ae(e) {
345
+ function ue(e) {
331
346
  var n;
332
347
  const t = l(((n = a(e)) == null ? void 0 : n.selections) ?? []);
333
- return b(e, () => {
348
+ return C(e, () => {
334
349
  var r;
335
350
  t.value = ((r = a(e)) == null ? void 0 : r.selections) ?? [];
336
351
  }), s(c.onDidChangeNotebookEditorSelection((r) => {
@@ -347,7 +362,7 @@ function ae(e) {
347
362
  });
348
363
  }
349
364
  function Ie(e) {
350
- const t = ae(e);
365
+ const t = ue(e);
351
366
  return d({
352
367
  get() {
353
368
  return t.value[0];
@@ -357,24 +372,24 @@ function Ie(e) {
357
372
  }
358
373
  });
359
374
  }
360
- function Oe(e) {
375
+ function Pe(e) {
361
376
  var n;
362
377
  const t = l(((n = a(e)) == null ? void 0 : n.visibleRanges) ?? []);
363
- return b(e, () => {
378
+ return C(e, () => {
364
379
  var r;
365
380
  t.value = ((r = a(e)) == null ? void 0 : r.visibleRanges) ?? [];
366
381
  }), s(c.onDidChangeNotebookEditorVisibleRanges((r) => {
367
382
  r.notebookEditor === a(e) && (t.value = r.visibleRanges);
368
383
  })), d(() => t.value);
369
384
  }
370
- const Pe = v(() => {
385
+ const Me = g(() => {
371
386
  const e = l(c.terminals);
372
387
  function t() {
373
388
  e.value = c.terminals;
374
389
  }
375
390
  return s(c.onDidOpenTerminal(t)), s(c.onDidCloseTerminal(t)), e;
376
391
  });
377
- function $e(e) {
392
+ function je(e) {
378
393
  const t = s(e.id ? c.createStatusBarItem(e.id, e.alignment, e.priority) : c.createStatusBarItem(e.alignment, e.priority));
379
394
  function n(r) {
380
395
  const i = e[r];
@@ -390,14 +405,14 @@ function $e(e) {
390
405
  "accessibilityInformation"
391
406
  ].forEach(n), t;
392
407
  }
393
- const Me = v(() => {
394
- const e = l(T.taskExecutions);
408
+ const Be = g(() => {
409
+ const e = l(D.taskExecutions);
395
410
  function t() {
396
- e.value = T.taskExecutions;
411
+ e.value = D.taskExecutions;
397
412
  }
398
- return s(T.onDidStartTask(t)), s(T.onDidEndTask(t)), d(() => e.value);
413
+ return s(D.onDidStartTask(t)), s(D.onDidEndTask(t)), d(() => e.value);
399
414
  });
400
- function je(...e) {
415
+ function He(...e) {
401
416
  const t = s(c.createTerminal(...e));
402
417
  return {
403
418
  terminal: t,
@@ -416,20 +431,20 @@ function je(...e) {
416
431
  sendText: t.sendText.bind(t),
417
432
  show: t.show.bind(t),
418
433
  hide: t.hide.bind(t),
419
- state: P(t)
434
+ state: M(t)
420
435
  };
421
436
  }
422
- function oe(e, t) {
437
+ function se(e, t) {
423
438
  s(E.registerTextEditorCommand(e, t));
424
439
  }
425
- function Be(e) {
440
+ function Ue(e) {
426
441
  for (const [t, n] of Object.entries(e))
427
- oe(t, n);
442
+ se(t, n);
428
443
  }
429
- function ue(e, t) {
444
+ function ce(e, t) {
430
445
  var r;
431
446
  const n = l(((r = a(e)) == null ? void 0 : r.selections) ?? []);
432
- return b(e, () => {
447
+ return C(e, () => {
433
448
  var i;
434
449
  n.value = ((i = a(e)) == null ? void 0 : i.selections) ?? [];
435
450
  }), s(c.onDidChangeTextEditorSelection((i) => {
@@ -446,8 +461,8 @@ function ue(e, t) {
446
461
  }
447
462
  });
448
463
  }
449
- function He(e, t) {
450
- const n = ue(e, t);
464
+ function qe(e, t) {
465
+ const n = ce(e, t);
451
466
  return d({
452
467
  get() {
453
468
  return n.value[0];
@@ -457,42 +472,42 @@ function He(e, t) {
457
472
  }
458
473
  });
459
474
  }
460
- function Ue(e) {
475
+ function Je(e) {
461
476
  var n;
462
477
  const t = l((n = a(e)) == null ? void 0 : n.viewColumn);
463
- return b(e, () => {
478
+ return C(e, () => {
464
479
  var r;
465
480
  t.value = (r = a(e)) == null ? void 0 : r.viewColumn;
466
481
  }), s(c.onDidChangeTextEditorViewColumn((r) => {
467
482
  r.textEditor === a(e) && (t.value = r.viewColumn);
468
483
  })), d(() => t.value);
469
484
  }
470
- function qe(e) {
485
+ function Ke(e) {
471
486
  var n;
472
487
  const t = l(((n = a(e)) == null ? void 0 : n.visibleRanges) ?? []);
473
- return b(e, () => {
488
+ return C(e, () => {
474
489
  var r;
475
490
  t.value = ((r = a(e)) == null ? void 0 : r.visibleRanges) ?? [];
476
491
  }), s(c.onDidChangeTextEditorVisibleRanges((r) => {
477
492
  r.textEditor === a(e) && (t.value = r.visibleRanges);
478
493
  })), d(() => t.value);
479
494
  }
480
- function $(e, t) {
495
+ function j(e, t) {
481
496
  h(() => {
482
497
  const n = a(e);
483
498
  n && (n.badge = a(t));
484
499
  });
485
500
  }
486
- function M(e, t) {
501
+ function B(e, t) {
487
502
  h(() => {
488
503
  const n = a(e);
489
504
  n && (n.title = a(t));
490
505
  });
491
506
  }
492
- const Je = L(
507
+ const ze = W(
493
508
  (e, t, n) => {
494
- const r = te();
495
- b(t, () => r.fire()), n != null && n.watchSource && b(n.watchSource, () => r.fire());
509
+ const r = re();
510
+ C(t, () => r.fire()), n != null && n.watchSource && C(n.watchSource, () => r.fire());
496
511
  const i = /* @__PURE__ */ new WeakMap(), o = s(c.createTreeView(e, {
497
512
  ...n,
498
513
  treeDataProvider: {
@@ -502,19 +517,19 @@ const Je = L(
502
517
  return u.treeItem;
503
518
  },
504
519
  getChildren(u) {
505
- var g;
506
- return u ? ((g = u.children) == null || g.forEach((f) => i.set(f, u)), u.children) : a(t);
520
+ var v;
521
+ return u ? ((v = u.children) == null || v.forEach((f) => i.set(f, u)), u.children) : a(t);
507
522
  },
508
523
  getParent(u) {
509
524
  return i.get(u);
510
525
  }
511
526
  }
512
527
  }));
513
- return n != null && n.title && M(o, n.title), n != null && n.badge && $(o, n.badge), o;
528
+ return n != null && n.title && B(o, n.title), n != null && n.badge && j(o, n.badge), o;
514
529
  },
515
530
  (e) => e
516
531
  );
517
- function Ke(e) {
532
+ function Ye(e) {
518
533
  var r;
519
534
  const t = x((r = a(e)) == null ? void 0 : r.visible);
520
535
  function n() {
@@ -529,31 +544,31 @@ function Ke(e) {
529
544
  }
530
545
  }), h(n), d(() => !!t.value);
531
546
  }
532
- const ze = v(() => {
547
+ const Ge = g(() => {
533
548
  const e = l(c.visibleNotebookEditors);
534
549
  return s(c.onDidChangeVisibleNotebookEditors((t) => {
535
550
  e.value = t;
536
551
  })), e;
537
- }), Ye = v(() => {
552
+ }), Qe = g(() => {
538
553
  const e = l(c.visibleTextEditors);
539
554
  return s(c.onDidChangeVisibleTextEditors((t) => {
540
555
  e.value = t;
541
556
  })), e;
542
557
  });
543
- function Ge(e, t, n = !0) {
544
- const r = J(t) ? t : typeof t == "function" ? d(t) : x(t);
558
+ function Xe(e, t, n = !0) {
559
+ const r = K(t) ? t : typeof t == "function" ? d(t) : x(t);
545
560
  return h(() => {
546
561
  a(n) && E.executeCommand("setContext", e, r.value);
547
562
  }), r;
548
563
  }
549
- const Qe = L(
564
+ const Ze = W(
550
565
  (e, t, n) => {
551
566
  const r = l(), i = l();
552
567
  s(c.registerWebviewViewProvider(
553
568
  e,
554
569
  {
555
- resolveWebviewView(f, C) {
556
- r.value = f, i.value = C, n != null && n.onDidReceiveMessage && f.webview.onDidReceiveMessage(n.onDidReceiveMessage);
570
+ resolveWebviewView(f, m) {
571
+ r.value = f, i.value = m, n != null && n.onDidReceiveMessage && f.webview.onDidReceiveMessage(n.onDidReceiveMessage);
557
572
  }
558
573
  },
559
574
  {
@@ -574,15 +589,15 @@ const Qe = L(
574
589
  r.value && (r.value.webview.options = a(f));
575
590
  });
576
591
  }
577
- n != null && n.title && M(r, n.title), n != null && n.badge && $(r, n.badge);
578
- function g(f) {
579
- var C;
580
- return (C = r.value) == null ? void 0 : C.webview.postMessage(f);
592
+ n != null && n.title && B(r, n.title), n != null && n.badge && j(r, n.badge);
593
+ function v(f) {
594
+ var m;
595
+ return (m = r.value) == null ? void 0 : m.webview.postMessage(f);
581
596
  }
582
- return { view: r, context: i, postMessage: g, forceRefresh: u };
597
+ return { view: r, context: i, postMessage: v, forceRefresh: u };
583
598
  },
584
599
  (e) => e
585
- ), Xe = v(() => {
600
+ ), _e = g(() => {
586
601
  const e = l(c.state);
587
602
  return s(c.onDidChangeWindowState((t) => {
588
603
  e.value = t;
@@ -590,78 +605,79 @@ const Qe = L(
590
605
  focused: d(() => e.value.focused),
591
606
  active: d(() => e.value.active)
592
607
  };
593
- }), Ze = v(() => {
594
- const e = l(m.workspaceFolders);
595
- return s(m.onDidChangeWorkspaceFolders(() => {
596
- e.value = m.workspaceFolders;
608
+ }), et = g(() => {
609
+ const e = l(b.workspaceFolders);
610
+ return s(b.onDidChangeWorkspaceFolders(() => {
611
+ e.value = b.workspaceFolders;
597
612
  })), d(() => e.value);
598
613
  });
599
614
  export {
600
615
  I as activateCbs,
601
- L as createKeyedComposable,
602
- v as createSingletonComposable,
603
- W as deactivateCbs,
604
- fe as defineConfigs,
605
- de as defineExtension,
606
- ve as defineLogger,
607
- ge as executeCommand,
608
- S as extensionContext,
609
- k as extensionScope,
610
- We as getDefaultLoggerPrefix,
611
- O as onActivate,
612
- le as onDeactivate,
613
- G as tryOnScopeDispose,
614
- he as useAbsolutePath,
615
- X as useActiveColorTheme,
616
- me as useActiveDebugSession,
617
- be as useActiveEditorDecorations,
618
- Ce as useActiveNotebookEditor,
619
- we as useActiveTerminal,
620
- Z as useActiveTextEditor,
621
- Te as useAllExtensions,
622
- ee as useCommand,
623
- De as useCommands,
624
- Se as useCommentController,
625
- xe as useControlledTerminal,
626
- Ee as useDefaultShell,
616
+ W as createKeyedComposable,
617
+ g as createSingletonComposable,
618
+ $ as deactivateCbs,
619
+ ge as defineConfigObject,
620
+ X as defineConfigs,
621
+ ve as defineExtension,
622
+ he as defineLogger,
623
+ me as executeCommand,
624
+ p as extensionContext,
625
+ R as extensionScope,
626
+ $e as getDefaultLoggerPrefix,
627
+ P as onActivate,
628
+ fe as onDeactivate,
629
+ Q as tryOnScopeDispose,
630
+ be as useAbsolutePath,
631
+ _ as useActiveColorTheme,
632
+ Ce as useActiveDebugSession,
633
+ we as useActiveEditorDecorations,
634
+ Te as useActiveNotebookEditor,
635
+ De as useActiveTerminal,
636
+ ee as useActiveTextEditor,
637
+ Se as useAllExtensions,
638
+ ne as useCommand,
639
+ pe as useCommands,
640
+ xe as useCommentController,
641
+ Ee as useControlledTerminal,
642
+ ke as useDefaultShell,
627
643
  s as useDisposable,
628
- pe as useDocumentText,
629
- _ as useEditorDecorations,
630
- D as useEvent,
631
- te as useEventEmitter,
632
- ke as useFetchTasks,
633
- ye as useFileUri,
634
- Re as useFoldingRangeProvider,
635
- Ve as useFsWatcher,
636
- Ae as useIsDarkTheme,
637
- Ne as useIsTelemetryEnabled,
638
- Fe as useL10nText,
639
- Le as useLogLevel,
640
- ie as useLogger,
644
+ Re as useDocumentText,
645
+ te as useEditorDecorations,
646
+ S as useEvent,
647
+ re as useEventEmitter,
648
+ ye as useFetchTasks,
649
+ Ve as useFileUri,
650
+ Ae as useFoldingRangeProvider,
651
+ Ne as useFsWatcher,
652
+ Fe as useIsDarkTheme,
653
+ Le as useIsTelemetryEnabled,
654
+ Oe as useL10nText,
655
+ We as useLogLevel,
656
+ oe as useLogger,
641
657
  Ie as useNotebookEditorSelection,
642
- ae as useNotebookEditorSelections,
643
- Oe as useNotebookEditorVisibleRanges,
644
- Pe as useOpenedTerminals,
645
- re as useOutputChannel,
646
- $e as useStatusBarItem,
647
- Me as useTaskExecutions,
648
- je as useTerminal,
649
- P as useTerminalState,
650
- oe as useTextEditorCommand,
651
- Be as useTextEditorCommands,
652
- He as useTextEditorSelection,
653
- ue as useTextEditorSelections,
654
- Ue as useTextEditorViewColumn,
655
- qe as useTextEditorVisibleRanges,
656
- Je as useTreeView,
657
- ne as useUri,
658
- $ as useViewBadge,
659
- M as useViewTitle,
660
- Ke as useViewVisibility,
661
- ze as useVisibleNotebookEditors,
662
- Ye as useVisibleTextEditors,
663
- Ge as useVscodeContext,
664
- Qe as useWebviewView,
665
- Xe as useWindowState,
666
- Ze as useWorkspaceFolders
658
+ ue as useNotebookEditorSelections,
659
+ Pe as useNotebookEditorVisibleRanges,
660
+ Me as useOpenedTerminals,
661
+ ae as useOutputChannel,
662
+ je as useStatusBarItem,
663
+ Be as useTaskExecutions,
664
+ He as useTerminal,
665
+ M as useTerminalState,
666
+ se as useTextEditorCommand,
667
+ Ue as useTextEditorCommands,
668
+ qe as useTextEditorSelection,
669
+ ce as useTextEditorSelections,
670
+ Je as useTextEditorViewColumn,
671
+ Ke as useTextEditorVisibleRanges,
672
+ ze as useTreeView,
673
+ ie as useUri,
674
+ j as useViewBadge,
675
+ B as useViewTitle,
676
+ Ye as useViewVisibility,
677
+ Ge as useVisibleNotebookEditors,
678
+ Qe as useVisibleTextEditors,
679
+ Xe as useVscodeContext,
680
+ Ze as useWebviewView,
681
+ _e as useWindowState,
682
+ et as useWorkspaceFolders
667
683
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "reactive-vscode",
3
3
  "type": "module",
4
- "version": "0.2.0-beta.3",
4
+ "version": "0.2.0-beta.5",
5
5
  "description": "Develop VSCode extension with Vue Reactivity API",
6
6
  "author": "_Kerman <kermanx@qq.com>",
7
7
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  "@types/vscode": "^1.89.0"
38
38
  },
39
39
  "dependencies": {
40
- "@reactive-vscode/reactivity": "0.2.0-beta.3"
40
+ "@reactive-vscode/reactivity": "0.2.0-beta.5"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "^20.14.2",