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