Skip to content

Commit 21c13ad

Browse files
committed
feat: @reactive-vscode/vueuse package
1 parent 5c2ff5d commit 21c13ad

File tree

7 files changed

+344
-13
lines changed

7 files changed

+344
-13
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
[MIT](./LICENSE) License © 2024-PRESENT [_Kerman](https://github.com/KermanX)
1515

16-
Source code in [the `./packages/core/src/reactivity` directory](https://github.com/KermanX/reactive-vscode/blob/main/packages/core/src/reactivity) is ported from [`@vue/runtime-core`](https://github.com/vuejs/core/blob/main/packages/runtime-core). Licensed under a [MIT License](https://github.com/vueuse/vueuse/blob/main/LICENSE).
16+
Source code in [the `./packages/reactivity` directory](https://github.com/KermanX/reactive-vscode/blob/main/packages/core/src/reactivity) is ported from [`@vue/runtime-core`](https://github.com/vuejs/core/blob/main/packages/runtime-core). Licensed under a [MIT License](https://github.com/vueuse/vueuse/blob/main/LICENSE).
1717

1818
The logo <img src="https://kermanx.github.io/reactive-vscode/logo.svg" width="14"> is modified from [Vue Reactity Artworks](https://github.com/vue-reactivity/art). Licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-nc-sa/4.0/).
1919

packages/vueuse/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"@reactive-vscode/reactivity": "workspace:*"
4242
},
4343
"devDependencies": {
44+
"@types/node": "^20.14.2",
4445
"@vueuse/core": "^10.10.0",
4546
"typescript": "^5.4.5",
4647
"vite": "^5.2.12",

packages/vueuse/shim.d.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export { }
2+
declare global {
3+
const __DEV__: boolean
4+
const window: typeof window
5+
const HTMLCanvasElement: any
6+
const HTMLImageElement: any
7+
const HTMLTextAreaElement: any
8+
const HTMLElement: any
9+
const Window: any
10+
const WindowEventMap: any
11+
const MediaSource: any
12+
const WebSocket: globalThis.WebSocket
13+
const Worker: globalThis.Worker
14+
const CloseEvent: any
15+
const MessageEvent: any
16+
}

packages/vueuse/src/index.ts

+292
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,296 @@
1+
// From `@vueuse/shared`
12
export {
3+
type AnyFn,
4+
type ArgumentsType,
5+
type Arrayable,
6+
type Awaitable,
7+
type Awaited,
8+
type ComputedRefWithControl,
9+
type ComputedWithControlRefExtra,
10+
type ConfigurableEventFilter,
11+
type ConfigurableFlush,
12+
type ConfigurableFlushSync,
13+
type ControlledRefOptions,
14+
type DateLike,
15+
type DebounceFilterOptions,
16+
type DeepMaybeRef,
17+
type ElementOf,
18+
type EventFilter,
19+
type EventHook,
20+
type EventHookOff,
21+
type EventHookOn,
22+
type EventHookTrigger,
23+
type ExtendRefOptions,
24+
type Fn,
25+
type FunctionArgs,
26+
type FunctionWrapperOptions,
27+
type IfAny,
28+
type IgnoredUpdater,
29+
type IsAny,
30+
type MapOldSources,
31+
type MapSources,
32+
type MultiWatchSources,
33+
type Mutable,
34+
type Pausable,
35+
type Promisify,
36+
type PromisifyFn,
37+
type Reactified,
38+
type ReactifyNested,
39+
type ReactifyObjectOptions,
40+
type ReactifyOptions,
41+
type ReactiveOmitPredicate,
42+
type ReactivePickPredicate,
43+
type ReadonlyRefOrGetter,
44+
type RemovableRef,
45+
type ShallowUnwrapRef,
46+
type SingletonPromiseReturn,
47+
type Stoppable,
48+
type SyncRefOptions,
49+
type SyncRefsOptions,
50+
type ThrottleFilterOptions,
51+
type ToRefsOptions,
52+
type UntilArrayInstance,
53+
type UntilToMatchOptions,
54+
type UntilValueInstance,
55+
type UseArrayIncludesComparatorFn,
56+
type UseArrayIncludesOptions,
57+
type UseArrayReducer,
58+
type UseDateFormatOptions,
59+
type UseDateFormatReturn,
60+
type UseIntervalControls,
61+
type UseIntervalFnOptions,
62+
type UseIntervalOptions,
63+
type UseLastChangedOptions,
64+
type UseTimeoutFnOptions,
65+
type UseTimeoutOptions,
66+
type UseToNumberOptions,
67+
type UseToggleOptions,
68+
type WatchArrayCallback,
69+
type WatchAtMostOptions,
70+
type WatchAtMostReturn,
71+
type WatchDebouncedOptions,
72+
type WatchIgnorableReturn,
73+
type WatchPausableReturn,
74+
type WatchThrottledOptions,
75+
type WatchTriggerableCallback,
76+
type WatchTriggerableReturn,
77+
type WheneverOptions,
78+
type WritableComputedRefWithControl,
79+
assert,
80+
refAutoReset as autoResetRef,
81+
bypassFilter,
82+
camelize,
83+
clamp,
84+
computedWithControl,
85+
containsProp,
86+
computedWithControl as controlledComputed,
87+
controlledRef,
88+
createEventHook,
89+
createFilterWrapper,
90+
createGlobalState,
91+
reactify as createReactiveFn,
92+
createSharedComposable,
93+
createSingletonPromise,
94+
debounceFilter,
95+
refDebounced as debouncedRef,
96+
watchDebounced as debouncedWatch,
97+
extendRef,
98+
formatDate,
99+
get,
100+
getLifeCycleTarget,
101+
hasOwn,
102+
hyphenate,
103+
identity,
104+
watchIgnorable as ignorableWatch,
105+
increaseWithUnit,
106+
invoke,
107+
isDef,
108+
isDefined,
109+
isObject,
110+
makeDestructurable,
111+
noop,
112+
normalizeDate,
113+
notNullish,
114+
now,
115+
objectEntries,
116+
objectOmit,
117+
objectPick,
118+
pausableFilter,
119+
watchPausable as pausableWatch,
120+
promiseTimeout,
121+
rand,
122+
reactify,
123+
reactifyObject,
124+
reactiveComputed,
125+
reactiveOmit,
126+
reactivePick,
127+
refAutoReset,
128+
refDebounced,
129+
refDefault,
130+
refThrottled,
131+
refWithControl,
132+
resolveRef,
133+
resolveUnref,
134+
set,
135+
syncRef,
136+
syncRefs,
137+
throttleFilter,
138+
refThrottled as throttledRef,
139+
watchThrottled as throttledWatch,
140+
toReactive,
141+
toRef,
142+
toRefs,
143+
toValue,
2144
tryOnScopeDispose,
145+
until,
146+
useArrayDifference,
147+
useArrayEvery,
148+
useArrayFilter,
149+
useArrayFind,
150+
useArrayFindIndex,
151+
useArrayFindLast,
152+
useArrayIncludes,
153+
useArrayJoin,
154+
useArrayMap,
155+
useArrayReduce,
156+
useArraySome,
157+
useArrayUnique,
158+
useCounter,
159+
useDateFormat,
160+
refDebounced as useDebounce,
161+
useDebounceFn,
162+
useInterval,
163+
useIntervalFn,
164+
useLastChanged,
165+
refThrottled as useThrottle,
166+
useThrottleFn,
167+
useTimeout,
168+
useTimeoutFn,
169+
useToNumber,
170+
useToString,
171+
useToggle,
172+
watchArray,
173+
watchAtMost,
174+
watchDebounced,
175+
watchDeep,
176+
watchIgnorable,
177+
watchImmediate,
178+
watchOnce,
179+
watchPausable,
180+
watchThrottled,
181+
watchTriggerable,
182+
watchWithFilter,
183+
whenever,
184+
} from '@vueuse/core'
185+
186+
// From `@vueuse/core`
187+
export {
188+
computedAsync as asyncComputed,
189+
cloneFnJSON,
190+
computedAsync,
191+
createFetch,
192+
createUnrefFn,
193+
formatTimeAgo,
194+
useAsyncQueue,
195+
useAsyncState,
196+
useBase64,
197+
useBroadcastChannel,
198+
useCached,
199+
useCloned,
200+
useCycleList,
201+
useDebouncedRefHistory,
202+
useEventBus,
203+
useFetch,
204+
useIdle,
205+
useManualRefHistory,
3206
useNow,
207+
useObjectUrl,
208+
useOffsetPagination,
209+
usePrevious,
210+
useRefHistory,
211+
useSorted,
212+
useStepper,
213+
useThrottledRefHistory,
214+
useTimeAgo,
215+
useTimeoutPoll,
216+
useTimestamp,
217+
useUrlSearchParams,
218+
useWebSocket,
219+
useWebWorkerFn,
220+
type AfterFetchContext,
221+
type AsyncComputedOnCancel,
222+
type AsyncComputedOptions,
223+
type BeforeFetchContext,
224+
type CloneFn,
225+
type CreateFetchOptions,
226+
type EventBusEvents,
227+
type EventBusIdentifier,
228+
type EventBusKey,
229+
type EventBusListener,
230+
type FormatTimeAgoOptions,
231+
type GeneralEventListener,
232+
type OnFetchErrorContext,
233+
type Serializer,
234+
type SerializerAsync,
235+
type ToDataURLOptions,
236+
type UnrefFn,
237+
type UrlParams,
238+
type UseAsyncQueueOptions,
239+
type UseAsyncQueueResult,
240+
type UseAsyncQueueReturn,
241+
type UseAsyncQueueTask,
242+
type UseAsyncStateOptions,
243+
type UseAsyncStateReturn,
244+
type UseAsyncStateReturnBase,
245+
type UseBase64ObjectOptions,
246+
type UseBase64Return,
247+
type UseBroadcastChannelOptions,
248+
type UseBroadcastChannelReturn,
249+
type UseBrowserLocationReturn,
250+
type UseClonedOptions,
251+
type UseClonedReturn,
252+
type UseCycleListOptions,
253+
type UseCycleListReturn,
254+
type UseEventBusReturn,
255+
type UseFetchOptions,
256+
type UseFetchReturn,
257+
type UseManualRefHistoryOptions,
258+
type UseManualRefHistoryReturn,
259+
type UseNowOptions,
260+
type UseNowReturn,
261+
type UseOffsetPaginationInfinityPageReturn,
262+
type UseOffsetPaginationOptions,
263+
type UseOffsetPaginationReturn,
264+
type UseRefHistoryOptions,
265+
type UseRefHistoryRecord,
266+
type UseRefHistoryReturn,
267+
type UseShareOptions,
268+
type UseShareReturn,
269+
type UseSortedCompareFn,
270+
type UseSortedFn,
271+
type UseSortedOptions,
272+
type UseStepperReturn,
273+
type UseTextareaAutosizeOptions,
274+
type UseTextareaAutosizeReturn,
275+
type UseThrottledRefHistoryOptions,
276+
type UseThrottledRefHistoryReturn,
277+
type UseTimeAgoFormatter,
278+
type UseTimeAgoMessages,
279+
type UseTimeAgoMessagesBuiltIn,
280+
type UseTimeAgoOptions,
281+
type UseTimeAgoReturn,
282+
type UseTimeAgoUnit,
283+
type UseTimeAgoUnitNamesDefault,
284+
type UseTimestampOptions,
285+
type UseTimestampReturn,
286+
type UseUrlSearchParamsOptions,
287+
type UseWebSocketOptions,
288+
type UseWebSocketReturn,
289+
type UseWebWorkerFnReturn,
290+
type UseWebWorkerOptions,
291+
type UseWebWorkerReturn,
292+
type WebSocketStatus,
293+
type WebWorkerStatus,
294+
type WritableComputedInjectOptions,
295+
type WritableComputedInjectOptionsWithDefault,
4296
} from '@vueuse/core'

packages/vueuse/src/vue-demi.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export * from '@reactive-vscode/reactivity'
2+
3+
export const isVue2 = false
4+
export const isVue3 = true
5+
6+
export function getCurrentInstance() {
7+
return null
8+
}
9+
export function onMounted() {
10+
}

packages/vueuse/vite.config.ts

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,28 @@
1+
import path from 'node:path'
12
import { defineConfig } from 'vite'
23
import Dts from 'vite-plugin-dts'
34

45
export default defineConfig({
56
plugins: [
7+
{
8+
name: 'replace constants',
9+
enforce: 'pre',
10+
transform: {
11+
order: 'pre',
12+
handler(code, id) {
13+
if (id.endsWith('.mjs')) {
14+
return code
15+
.replaceAll(`getCurrentInstance()`, `null`)
16+
.replaceAll(`getLifeCycleTarget()`, `null`)
17+
}
18+
},
19+
},
20+
},
621
Dts({
722
include: [
823
'./src/**/*.ts',
924
'./tsconfig.json',
25+
'./shim.d.ts',
1026
],
1127
rollupTypes: true,
1228
bundledPackages: ['@vueuse/core', '@vueuse/shared'],
@@ -19,7 +35,7 @@ export default defineConfig({
1935
],
2036
resolve: {
2137
alias: {
22-
'vue-demi': '@reactive-vscode/reactivity',
38+
'vue-demi': path.resolve(__dirname, './src/vue-demi.ts'),
2339
},
2440
},
2541
build: {

0 commit comments

Comments
 (0)