@roomful/vue 1.0.0-beta.6
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/LICENSE +21 -0
- package/README.md +42 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +575 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Roomful Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @roomful/vue
|
|
2
|
+
|
|
3
|
+
Vue 3 bindings for [Roomful](https://github.com/erayates/roomful) — a plugin and composables that integrate real-time collaboration with Vue's reactivity system.
|
|
4
|
+
|
|
5
|
+
> **Public beta** — install with the `@beta` tag; the API is stable but may still change before 1.0.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @roomful/core@beta @roomful/vue@beta
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { createApp } from 'vue';
|
|
17
|
+
import { RoomfulPlugin } from '@roomful/vue';
|
|
18
|
+
import App from './App.vue';
|
|
19
|
+
|
|
20
|
+
createApp(App)
|
|
21
|
+
.use(RoomfulPlugin, { roomId: 'my-room', presence: { name: 'Alice' } })
|
|
22
|
+
.mount('#app');
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```vue
|
|
26
|
+
<script setup>
|
|
27
|
+
import { usePresence, useSharedState } from '@roomful/vue';
|
|
28
|
+
|
|
29
|
+
const { others } = usePresence();
|
|
30
|
+
const [count, setCount] = useSharedState('count', { initialValue: 0 });
|
|
31
|
+
</script>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Composables: `usePresence`, `useCursors`, `useSharedState`, `useAwareness`, `useEvent` (plus the `v-roomful-cursors` directive).
|
|
35
|
+
|
|
36
|
+
## Documentation
|
|
37
|
+
|
|
38
|
+
See the [Roomful repository](https://github.com/erayates/roomful) for the full API reference.
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import type { AwarenessEngine, AwarenessState, CursorData, CursorOptions, CursorPosition, Peer, PresenceData, PresenceEngine, RoomOptions, StateOptions } from '@roomful/core';
|
|
2
|
+
import type { Directive, Plugin, ShallowRef } from 'vue';
|
|
3
|
+
/**
|
|
4
|
+
* Configures the Vue plugin.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam TPresence - The room presence shape inferred from `presence`.
|
|
7
|
+
*/
|
|
8
|
+
export interface RoomfulPluginOptions<TPresence extends PresenceData = PresenceData> extends RoomOptions<TPresence> {
|
|
9
|
+
/**
|
|
10
|
+
* Identifies the room to create or join.
|
|
11
|
+
*/
|
|
12
|
+
roomId: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Wraps a Vue `ShallowRef` in a readonly view for consumers.
|
|
16
|
+
*
|
|
17
|
+
* @typeParam T - The referenced value type.
|
|
18
|
+
*/
|
|
19
|
+
export type ReadonlyRef<T> = Readonly<ShallowRef<T>>;
|
|
20
|
+
/**
|
|
21
|
+
* Describes the return value of `usePresence`.
|
|
22
|
+
*
|
|
23
|
+
* @typeParam TPresence - The room presence shape.
|
|
24
|
+
*/
|
|
25
|
+
export interface UsePresenceResult<TPresence extends PresenceData = PresenceData> {
|
|
26
|
+
/**
|
|
27
|
+
* Exposes the local peer snapshot.
|
|
28
|
+
*/
|
|
29
|
+
self: ReadonlyRef<Peer<TPresence>>;
|
|
30
|
+
/**
|
|
31
|
+
* Exposes remote peers only.
|
|
32
|
+
*/
|
|
33
|
+
others: ReadonlyRef<Peer<TPresence>[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Exposes local and remote peers.
|
|
36
|
+
*/
|
|
37
|
+
all: ReadonlyRef<Peer<TPresence>[]>;
|
|
38
|
+
/**
|
|
39
|
+
* Partially updates the local presence payload.
|
|
40
|
+
*/
|
|
41
|
+
update: PresenceEngine<TPresence>['update'];
|
|
42
|
+
/**
|
|
43
|
+
* Replaces the local presence payload.
|
|
44
|
+
*/
|
|
45
|
+
replace: PresenceEngine<TPresence>['replace'];
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Describes the return value of `useCursors`.
|
|
49
|
+
*
|
|
50
|
+
* @typeParam TCursor - The custom cursor payload shape.
|
|
51
|
+
*/
|
|
52
|
+
export interface UseCursorsResult<TCursor extends CursorData = CursorData> {
|
|
53
|
+
/**
|
|
54
|
+
* Holds the mounted cursor host element.
|
|
55
|
+
*/
|
|
56
|
+
ref: ShallowRef<HTMLElement | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Exposes the latest cursor positions.
|
|
59
|
+
*/
|
|
60
|
+
cursors: ReadonlyRef<CursorPosition<TCursor>[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Mounts cursor tracking on an element.
|
|
63
|
+
*
|
|
64
|
+
* @param element - The element to observe.
|
|
65
|
+
* @returns Nothing.
|
|
66
|
+
*/
|
|
67
|
+
mount(element: HTMLElement): void;
|
|
68
|
+
/**
|
|
69
|
+
* Unmounts cursor tracking.
|
|
70
|
+
*
|
|
71
|
+
* @returns Nothing.
|
|
72
|
+
*/
|
|
73
|
+
unmount(): void;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Describes the return value of `useAwareness`.
|
|
77
|
+
*/
|
|
78
|
+
export interface UseAwarenessResult {
|
|
79
|
+
/**
|
|
80
|
+
* Exposes remote awareness state only.
|
|
81
|
+
*/
|
|
82
|
+
others: ReadonlyRef<AwarenessState[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Merges arbitrary awareness metadata into the local peer.
|
|
85
|
+
*/
|
|
86
|
+
set: AwarenessEngine['set'];
|
|
87
|
+
/**
|
|
88
|
+
* Updates the local focus target.
|
|
89
|
+
*/
|
|
90
|
+
setFocus: AwarenessEngine['setFocus'];
|
|
91
|
+
/**
|
|
92
|
+
* Updates the local selection.
|
|
93
|
+
*/
|
|
94
|
+
setSelection: AwarenessEngine['setSelection'];
|
|
95
|
+
/**
|
|
96
|
+
* Updates the local typing state.
|
|
97
|
+
*/
|
|
98
|
+
setTyping: AwarenessEngine['setTyping'];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Mirrors React-style updater semantics for Vue shared state setters.
|
|
102
|
+
*
|
|
103
|
+
* @typeParam T - The shared state value type.
|
|
104
|
+
*/
|
|
105
|
+
export type SharedStateUpdater<T> = T | ((previous: T) => T);
|
|
106
|
+
/**
|
|
107
|
+
* Updates a shared state binding.
|
|
108
|
+
*
|
|
109
|
+
* @typeParam T - The shared state value type.
|
|
110
|
+
* @param nextValue - The next value or updater function.
|
|
111
|
+
* @returns Nothing.
|
|
112
|
+
*/
|
|
113
|
+
export type SharedStateSetter<T> = (nextValue: SharedStateUpdater<T>) => void;
|
|
114
|
+
/**
|
|
115
|
+
* Vue directive type used by `v-roomful-cursors`.
|
|
116
|
+
*/
|
|
117
|
+
export type RoomfulCursorsDirective = Directive<HTMLElement, CursorOptions | undefined>;
|
|
118
|
+
type EventHandlerRef<TPayload, TPresence extends PresenceData> = {
|
|
119
|
+
bivarianceHack(payload: TPayload, from: Peer<TPresence>): void;
|
|
120
|
+
}['bivarianceHack'];
|
|
121
|
+
/**
|
|
122
|
+
* Installs the Roomful Vue plugin and cursor directive.
|
|
123
|
+
*/
|
|
124
|
+
export declare const RoomfulPlugin: Plugin<RoomfulPluginOptions<PresenceData>>;
|
|
125
|
+
/**
|
|
126
|
+
* Subscribes to room presence snapshots.
|
|
127
|
+
*
|
|
128
|
+
* @typeParam TPresence - The room presence shape.
|
|
129
|
+
* @returns The local peer, remote peers, and presence mutators.
|
|
130
|
+
*/
|
|
131
|
+
export declare function usePresence<TPresence extends PresenceData = PresenceData>(): UsePresenceResult<TPresence>;
|
|
132
|
+
/**
|
|
133
|
+
* Subscribes to cursor snapshots and returns mounting helpers.
|
|
134
|
+
*
|
|
135
|
+
* @typeParam TCursor - The custom cursor payload shape.
|
|
136
|
+
* @typeParam TPresence - The room presence shape.
|
|
137
|
+
* @param options - Optional cursor tracking configuration.
|
|
138
|
+
* @returns The cursor snapshot and mounting helpers.
|
|
139
|
+
*/
|
|
140
|
+
export declare function useCursors<TCursor extends CursorData = CursorData, TPresence extends PresenceData = PresenceData>(options?: CursorOptions): UseCursorsResult<TCursor>;
|
|
141
|
+
/**
|
|
142
|
+
* Binds a shared state value to Vue refs.
|
|
143
|
+
*
|
|
144
|
+
* @typeParam T - The shared state value type.
|
|
145
|
+
* @typeParam TPresence - The room presence shape.
|
|
146
|
+
* @param key - The logical binding key used to enforce a single shared-state binding per room.
|
|
147
|
+
* @param options - The shared-state configuration.
|
|
148
|
+
* @returns A readonly ref for the value and a setter function.
|
|
149
|
+
*/
|
|
150
|
+
export declare function useSharedState<T, TPresence extends PresenceData = PresenceData>(key: string, options: StateOptions<T>): readonly [ReadonlyRef<T>, SharedStateSetter<T>];
|
|
151
|
+
/**
|
|
152
|
+
* Subscribes to awareness snapshots.
|
|
153
|
+
*
|
|
154
|
+
* @typeParam TPresence - The room presence shape.
|
|
155
|
+
* @returns Remote awareness state and local awareness mutators.
|
|
156
|
+
*/
|
|
157
|
+
export declare function useAwareness<TPresence extends PresenceData = PresenceData>(): UseAwarenessResult;
|
|
158
|
+
/**
|
|
159
|
+
* Subscribes to a custom event channel and returns an emitter for that channel.
|
|
160
|
+
*
|
|
161
|
+
* @typeParam TPayload - The payload type for the channel.
|
|
162
|
+
* @typeParam TPresence - The room presence shape.
|
|
163
|
+
* @param name - The custom event channel name.
|
|
164
|
+
* @param handler - The callback invoked for incoming events.
|
|
165
|
+
* @returns A function that emits payloads on the same channel.
|
|
166
|
+
*/
|
|
167
|
+
export declare function useEvent<TPayload = unknown, TPresence extends PresenceData = PresenceData>(name: string, handler: EventHandlerRef<TPayload, TPresence>): (payload: TPayload) => void;
|
|
168
|
+
declare module 'vue' {
|
|
169
|
+
interface GlobalDirectives {
|
|
170
|
+
vRoomfulCursors: RoomfulCursorsDirective;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
export {};
|
|
174
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACd,UAAU,EAEV,aAAa,EACb,cAAc,EACd,IAAI,EACJ,YAA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YAAY,GAAG,YAAY,EAC7C,OAAO,CAAC,EAAE,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAgGpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,SAAS,SAAS,YAAY,GAAG,YAAY,EAC7E,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,GACvB,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAsDjD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,SAAS,SAAS,YAAY,GAAG,YAAY,KAAK,kBAAkB,CA4DhG;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,GAAG,OAAO,EAAE,SAAS,SAAS,YAAY,GAAG,YAAY,EACxF,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,eAAe,CAAC,QAAQ,EAAE,SAAS,CAAC,GAC5C,CAAC,OAAO,EAAE,QAAQ,KAAK,IAAI,CAwB7B;AA0XD,OAAO,QAAQ,KAAK,CAAC;IACnB,UAAU,gBAAgB;QACxB,eAAe,EAAE,uBAAuB,CAAC;KAC1C;CACF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
import { createRoom, RoomfulError } from '@roomful/core';
|
|
2
|
+
import { areAwarenessArraysEqual, areCursorArraysEqual, areCursorPositionsEqual, arePeerArraysEqual, arePeersEqual, areStructuredValuesEqual, assertCompatibleSharedStateBinding, createSharedStateBinding, isObjectLike, readSelfPeer, } from '@roomful/core/adapter-runtime';
|
|
3
|
+
import { getCurrentInstance, inject, markRaw, shallowRef, watch } from 'vue';
|
|
4
|
+
const ROOMFUL_CONTEXT_KEY = Symbol('RoomfulPluginContext');
|
|
5
|
+
const sharedStateBindings = new WeakMap();
|
|
6
|
+
/**
|
|
7
|
+
* Installs the Roomful Vue plugin and cursor directive.
|
|
8
|
+
*/
|
|
9
|
+
export const RoomfulPlugin = {
|
|
10
|
+
install(app, rawOptions) {
|
|
11
|
+
if (!isRoomfulPluginOptions(rawOptions)) {
|
|
12
|
+
throw new RoomfulError('INVALID_STATE', 'RoomfulPlugin requires app.use(RoomfulPlugin, { roomId, ...options }).', false);
|
|
13
|
+
}
|
|
14
|
+
const room = markRaw(createRoom(rawOptions.roomId, createRoomOptions(rawOptions)));
|
|
15
|
+
const context = {
|
|
16
|
+
room: shallowRef(room),
|
|
17
|
+
};
|
|
18
|
+
const directiveStates = new Map();
|
|
19
|
+
app.provide(ROOMFUL_CONTEXT_KEY, context);
|
|
20
|
+
app.directive('roomful-cursors', createRoomfulCursorsDirective(context, directiveStates));
|
|
21
|
+
void room.connect().catch(() => {
|
|
22
|
+
return undefined;
|
|
23
|
+
});
|
|
24
|
+
const originalUnmount = app.unmount.bind(app);
|
|
25
|
+
let isCleanedUp = false;
|
|
26
|
+
const cleanup = () => {
|
|
27
|
+
if (isCleanedUp) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
isCleanedUp = true;
|
|
31
|
+
for (const state of directiveStates.values()) {
|
|
32
|
+
state.engine.unmount();
|
|
33
|
+
}
|
|
34
|
+
directiveStates.clear();
|
|
35
|
+
sharedStateBindings.delete(room);
|
|
36
|
+
void room.disconnect().catch(() => {
|
|
37
|
+
return undefined;
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
app.unmount = (...args) => {
|
|
41
|
+
try {
|
|
42
|
+
return originalUnmount(...args);
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
cleanup();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Subscribes to room presence snapshots.
|
|
52
|
+
*
|
|
53
|
+
* @typeParam TPresence - The room presence shape.
|
|
54
|
+
* @returns The local peer, remote peers, and presence mutators.
|
|
55
|
+
*/
|
|
56
|
+
export function usePresence() {
|
|
57
|
+
const context = useRoomfulContext('usePresence');
|
|
58
|
+
const initialRoom = requireTypedRoom(context.room.value, 'usePresence');
|
|
59
|
+
const cacheRef = {
|
|
60
|
+
current: null,
|
|
61
|
+
};
|
|
62
|
+
const initialSnapshot = readPresenceSnapshot(initialRoom, initialRoom.usePresence(), cacheRef);
|
|
63
|
+
const self = shallowRef(initialSnapshot.self);
|
|
64
|
+
const others = shallowRef(initialSnapshot.others);
|
|
65
|
+
const all = shallowRef(initialSnapshot.all);
|
|
66
|
+
watch(context.room, (room, _previousRoom, onCleanup) => {
|
|
67
|
+
const typedRoom = requireTypedRoom(room, 'usePresence');
|
|
68
|
+
const presence = typedRoom.usePresence();
|
|
69
|
+
const syncSnapshot = () => {
|
|
70
|
+
const nextSnapshot = readPresenceSnapshot(typedRoom, presence, cacheRef);
|
|
71
|
+
if (self.value === nextSnapshot.self &&
|
|
72
|
+
others.value === nextSnapshot.others &&
|
|
73
|
+
all.value === nextSnapshot.all) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
self.value = nextSnapshot.self;
|
|
77
|
+
others.value = nextSnapshot.others;
|
|
78
|
+
all.value = nextSnapshot.all;
|
|
79
|
+
};
|
|
80
|
+
syncSnapshot();
|
|
81
|
+
const unsubscribe = presence.subscribe(() => {
|
|
82
|
+
syncSnapshot();
|
|
83
|
+
});
|
|
84
|
+
onCleanup(() => {
|
|
85
|
+
unsubscribe();
|
|
86
|
+
});
|
|
87
|
+
}, {
|
|
88
|
+
immediate: true,
|
|
89
|
+
});
|
|
90
|
+
return {
|
|
91
|
+
self,
|
|
92
|
+
others,
|
|
93
|
+
all,
|
|
94
|
+
update(data) {
|
|
95
|
+
requireTypedRoom(context.room.value, 'usePresence').usePresence().update(data);
|
|
96
|
+
},
|
|
97
|
+
replace(data) {
|
|
98
|
+
requireTypedRoom(context.room.value, 'usePresence').usePresence().replace(data);
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Subscribes to cursor snapshots and returns mounting helpers.
|
|
104
|
+
*
|
|
105
|
+
* @typeParam TCursor - The custom cursor payload shape.
|
|
106
|
+
* @typeParam TPresence - The room presence shape.
|
|
107
|
+
* @param options - Optional cursor tracking configuration.
|
|
108
|
+
* @returns The cursor snapshot and mounting helpers.
|
|
109
|
+
*/
|
|
110
|
+
export function useCursors(options) {
|
|
111
|
+
const context = useRoomfulContext('useCursors');
|
|
112
|
+
const initialRoom = requireTypedRoom(context.room.value, 'useCursors');
|
|
113
|
+
const initialEngine = initialRoom.useCursors(options);
|
|
114
|
+
const cacheRef = {
|
|
115
|
+
current: null,
|
|
116
|
+
};
|
|
117
|
+
const ref = shallowRef(null);
|
|
118
|
+
const cursors = shallowRef(readCursorSnapshot(initialRoom, initialEngine, cacheRef));
|
|
119
|
+
const engineRef = shallowRef(initialEngine);
|
|
120
|
+
let mountedEngine = null;
|
|
121
|
+
let mountedElement = null;
|
|
122
|
+
const syncMountedCursorEngine = () => {
|
|
123
|
+
const element = ref.value;
|
|
124
|
+
const engine = engineRef.value;
|
|
125
|
+
if (element === null) {
|
|
126
|
+
if (mountedEngine !== null) {
|
|
127
|
+
mountedEngine.unmount();
|
|
128
|
+
mountedEngine = null;
|
|
129
|
+
mountedElement = null;
|
|
130
|
+
}
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (mountedEngine === engine && mountedElement === element) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
mountedEngine === null || mountedEngine === void 0 ? void 0 : mountedEngine.unmount();
|
|
137
|
+
engine.mount(element);
|
|
138
|
+
mountedEngine = engine;
|
|
139
|
+
mountedElement = element;
|
|
140
|
+
};
|
|
141
|
+
watch(ref, () => {
|
|
142
|
+
syncMountedCursorEngine();
|
|
143
|
+
}, {
|
|
144
|
+
flush: 'sync',
|
|
145
|
+
});
|
|
146
|
+
watch(context.room, (room, _previousRoom, onCleanup) => {
|
|
147
|
+
const typedRoom = requireTypedRoom(room, 'useCursors');
|
|
148
|
+
const engine = typedRoom.useCursors(options);
|
|
149
|
+
engineRef.value = engine;
|
|
150
|
+
const syncSnapshot = () => {
|
|
151
|
+
const nextSnapshot = readCursorSnapshot(typedRoom, engine, cacheRef);
|
|
152
|
+
if (cursors.value === nextSnapshot) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
cursors.value = nextSnapshot;
|
|
156
|
+
};
|
|
157
|
+
syncMountedCursorEngine();
|
|
158
|
+
syncSnapshot();
|
|
159
|
+
const unsubscribe = engine.subscribe(() => {
|
|
160
|
+
syncSnapshot();
|
|
161
|
+
});
|
|
162
|
+
onCleanup(() => {
|
|
163
|
+
unsubscribe();
|
|
164
|
+
if (mountedEngine === engine) {
|
|
165
|
+
engine.unmount();
|
|
166
|
+
mountedEngine = null;
|
|
167
|
+
mountedElement = null;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}, {
|
|
171
|
+
immediate: true,
|
|
172
|
+
});
|
|
173
|
+
return {
|
|
174
|
+
ref,
|
|
175
|
+
cursors,
|
|
176
|
+
mount(element) {
|
|
177
|
+
ref.value = element;
|
|
178
|
+
syncMountedCursorEngine();
|
|
179
|
+
},
|
|
180
|
+
unmount() {
|
|
181
|
+
ref.value = null;
|
|
182
|
+
syncMountedCursorEngine();
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Binds a shared state value to Vue refs.
|
|
188
|
+
*
|
|
189
|
+
* @typeParam T - The shared state value type.
|
|
190
|
+
* @typeParam TPresence - The room presence shape.
|
|
191
|
+
* @param key - The logical binding key used to enforce a single shared-state binding per room.
|
|
192
|
+
* @param options - The shared-state configuration.
|
|
193
|
+
* @returns A readonly ref for the value and a setter function.
|
|
194
|
+
*/
|
|
195
|
+
export function useSharedState(key, options) {
|
|
196
|
+
const context = useRoomfulContext('useSharedState');
|
|
197
|
+
const initialRoom = requireTypedRoom(context.room.value, 'useSharedState');
|
|
198
|
+
const initialState = bindSharedState(initialRoom, key, options);
|
|
199
|
+
const cacheRef = {
|
|
200
|
+
current: null,
|
|
201
|
+
};
|
|
202
|
+
const value = shallowRef(readSharedStateSnapshot(initialRoom, initialState, cacheRef));
|
|
203
|
+
const stateRef = shallowRef(initialState);
|
|
204
|
+
watch(context.room, (room, _previousRoom, onCleanup) => {
|
|
205
|
+
const typedRoom = requireTypedRoom(room, 'useSharedState');
|
|
206
|
+
const state = bindSharedState(typedRoom, key, options);
|
|
207
|
+
stateRef.value = state;
|
|
208
|
+
const syncSnapshot = () => {
|
|
209
|
+
const nextSnapshot = readSharedStateSnapshot(typedRoom, state, cacheRef);
|
|
210
|
+
if (value.value === nextSnapshot) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
value.value = nextSnapshot;
|
|
214
|
+
};
|
|
215
|
+
syncSnapshot();
|
|
216
|
+
const unsubscribe = state.subscribe(() => {
|
|
217
|
+
syncSnapshot();
|
|
218
|
+
});
|
|
219
|
+
onCleanup(() => {
|
|
220
|
+
unsubscribe();
|
|
221
|
+
});
|
|
222
|
+
}, {
|
|
223
|
+
immediate: true,
|
|
224
|
+
});
|
|
225
|
+
const setValue = (nextValue) => {
|
|
226
|
+
const state = stateRef.value;
|
|
227
|
+
const previousValue = state.get();
|
|
228
|
+
const resolvedValue = isStateUpdater(nextValue) ? nextValue(previousValue) : nextValue;
|
|
229
|
+
if (areStructuredValuesEqual(previousValue, resolvedValue)) {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
state.set(resolvedValue);
|
|
233
|
+
};
|
|
234
|
+
return [value, setValue];
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Subscribes to awareness snapshots.
|
|
238
|
+
*
|
|
239
|
+
* @typeParam TPresence - The room presence shape.
|
|
240
|
+
* @returns Remote awareness state and local awareness mutators.
|
|
241
|
+
*/
|
|
242
|
+
export function useAwareness() {
|
|
243
|
+
const context = useRoomfulContext('useAwareness');
|
|
244
|
+
const initialRoom = requireTypedRoom(context.room.value, 'useAwareness');
|
|
245
|
+
const cacheRef = {
|
|
246
|
+
current: null,
|
|
247
|
+
};
|
|
248
|
+
const others = shallowRef(readAwarenessSnapshot(initialRoom, initialRoom.useAwareness(), cacheRef));
|
|
249
|
+
watch(context.room, (room, _previousRoom, onCleanup) => {
|
|
250
|
+
const typedRoom = requireTypedRoom(room, 'useAwareness');
|
|
251
|
+
const awareness = typedRoom.useAwareness();
|
|
252
|
+
const syncSnapshot = () => {
|
|
253
|
+
const nextSnapshot = readAwarenessSnapshot(typedRoom, awareness, cacheRef);
|
|
254
|
+
if (others.value === nextSnapshot) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
others.value = nextSnapshot;
|
|
258
|
+
};
|
|
259
|
+
syncSnapshot();
|
|
260
|
+
const unsubscribe = awareness.subscribe(() => {
|
|
261
|
+
syncSnapshot();
|
|
262
|
+
});
|
|
263
|
+
onCleanup(() => {
|
|
264
|
+
unsubscribe();
|
|
265
|
+
});
|
|
266
|
+
}, {
|
|
267
|
+
immediate: true,
|
|
268
|
+
});
|
|
269
|
+
return {
|
|
270
|
+
others,
|
|
271
|
+
set(value) {
|
|
272
|
+
requireTypedRoom(context.room.value, 'useAwareness').useAwareness().set(value);
|
|
273
|
+
},
|
|
274
|
+
setFocus(elementId) {
|
|
275
|
+
requireTypedRoom(context.room.value, 'useAwareness')
|
|
276
|
+
.useAwareness()
|
|
277
|
+
.setFocus(elementId);
|
|
278
|
+
},
|
|
279
|
+
setSelection(selection) {
|
|
280
|
+
requireTypedRoom(context.room.value, 'useAwareness')
|
|
281
|
+
.useAwareness()
|
|
282
|
+
.setSelection(selection);
|
|
283
|
+
},
|
|
284
|
+
setTyping(isTyping) {
|
|
285
|
+
requireTypedRoom(context.room.value, 'useAwareness')
|
|
286
|
+
.useAwareness()
|
|
287
|
+
.setTyping(isTyping);
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Subscribes to a custom event channel and returns an emitter for that channel.
|
|
293
|
+
*
|
|
294
|
+
* @typeParam TPayload - The payload type for the channel.
|
|
295
|
+
* @typeParam TPresence - The room presence shape.
|
|
296
|
+
* @param name - The custom event channel name.
|
|
297
|
+
* @param handler - The callback invoked for incoming events.
|
|
298
|
+
* @returns A function that emits payloads on the same channel.
|
|
299
|
+
*/
|
|
300
|
+
export function useEvent(name, handler) {
|
|
301
|
+
const context = useRoomfulContext('useEvent');
|
|
302
|
+
const handlerRef = shallowRef(handler);
|
|
303
|
+
watch(context.room, (room, _previousRoom, onCleanup) => {
|
|
304
|
+
const typedRoom = requireTypedRoom(room, 'useEvent');
|
|
305
|
+
const unsubscribe = typedRoom.useEvents().on(name, (payload, from) => {
|
|
306
|
+
handlerRef.value(payload, from);
|
|
307
|
+
});
|
|
308
|
+
onCleanup(() => {
|
|
309
|
+
unsubscribe();
|
|
310
|
+
});
|
|
311
|
+
}, {
|
|
312
|
+
immediate: true,
|
|
313
|
+
});
|
|
314
|
+
return (payload) => {
|
|
315
|
+
requireTypedRoom(context.room.value, 'useEvent').useEvents().emit(name, payload);
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
function useRoomfulContext(composableName) {
|
|
319
|
+
if (getCurrentInstance() === null) {
|
|
320
|
+
throw new RoomfulError('INVALID_STATE', `${composableName}() must be called from setup() after app.use(RoomfulPlugin, options).`, false);
|
|
321
|
+
}
|
|
322
|
+
const context = inject(ROOMFUL_CONTEXT_KEY, null);
|
|
323
|
+
if (context === null) {
|
|
324
|
+
throw new RoomfulError('INVALID_STATE', `${composableName}() requires app.use(RoomfulPlugin, options).`, false);
|
|
325
|
+
}
|
|
326
|
+
return context;
|
|
327
|
+
}
|
|
328
|
+
function requireTypedRoom(value, composableName) {
|
|
329
|
+
if (!isRoom(value)) {
|
|
330
|
+
throw new RoomfulError('INVALID_STATE', `${composableName}() requires app.use(RoomfulPlugin, options).`, false);
|
|
331
|
+
}
|
|
332
|
+
return value;
|
|
333
|
+
}
|
|
334
|
+
function createRoomOptions(options) {
|
|
335
|
+
const roomOptions = {};
|
|
336
|
+
if (options.transport !== undefined) {
|
|
337
|
+
roomOptions.transport = options.transport;
|
|
338
|
+
}
|
|
339
|
+
if (options.presence !== undefined) {
|
|
340
|
+
roomOptions.presence = options.presence;
|
|
341
|
+
}
|
|
342
|
+
if (options.maxPeers !== undefined) {
|
|
343
|
+
roomOptions.maxPeers = options.maxPeers;
|
|
344
|
+
}
|
|
345
|
+
if (options.stunUrls !== undefined) {
|
|
346
|
+
roomOptions.stunUrls = options.stunUrls;
|
|
347
|
+
}
|
|
348
|
+
if (options.relayUrl !== undefined) {
|
|
349
|
+
roomOptions.relayUrl = options.relayUrl;
|
|
350
|
+
}
|
|
351
|
+
if (options.relayAuth !== undefined) {
|
|
352
|
+
roomOptions.relayAuth = options.relayAuth;
|
|
353
|
+
}
|
|
354
|
+
if (options.reconnect !== undefined) {
|
|
355
|
+
roomOptions.reconnect = options.reconnect;
|
|
356
|
+
}
|
|
357
|
+
if (options.webrtc !== undefined) {
|
|
358
|
+
roomOptions.webrtc = options.webrtc;
|
|
359
|
+
}
|
|
360
|
+
if (options.encryption !== undefined) {
|
|
361
|
+
roomOptions.encryption = options.encryption;
|
|
362
|
+
}
|
|
363
|
+
if (options.debug !== undefined) {
|
|
364
|
+
roomOptions.debug = options.debug;
|
|
365
|
+
}
|
|
366
|
+
return roomOptions;
|
|
367
|
+
}
|
|
368
|
+
function createRoomfulCursorsDirective(context, states) {
|
|
369
|
+
return {
|
|
370
|
+
mounted(element, binding) {
|
|
371
|
+
bindCursorDirectiveElement(context, states, element, binding.value);
|
|
372
|
+
},
|
|
373
|
+
updated(element, binding) {
|
|
374
|
+
var _a;
|
|
375
|
+
const room = context.room.value;
|
|
376
|
+
const currentState = (_a = states.get(element)) !== null && _a !== void 0 ? _a : null;
|
|
377
|
+
if (currentState !== null &&
|
|
378
|
+
currentState.room === room &&
|
|
379
|
+
areCursorOptionsEqual(currentState.options, binding.value)) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
unbindCursorDirectiveElement(states, element);
|
|
383
|
+
bindCursorDirectiveElement(context, states, element, binding.value);
|
|
384
|
+
},
|
|
385
|
+
unmounted(element) {
|
|
386
|
+
unbindCursorDirectiveElement(states, element);
|
|
387
|
+
},
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
function bindCursorDirectiveElement(context, states, element, options) {
|
|
391
|
+
const room = requireTypedRoom(context.room.value, 'v-roomful-cursors');
|
|
392
|
+
const engine = room.useCursors(options);
|
|
393
|
+
engine.mount(element);
|
|
394
|
+
states.set(element, {
|
|
395
|
+
room,
|
|
396
|
+
engine,
|
|
397
|
+
options,
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
function unbindCursorDirectiveElement(states, element) {
|
|
401
|
+
var _a;
|
|
402
|
+
const state = (_a = states.get(element)) !== null && _a !== void 0 ? _a : null;
|
|
403
|
+
if (state === null) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
state.engine.unmount();
|
|
407
|
+
states.delete(element);
|
|
408
|
+
}
|
|
409
|
+
function bindSharedState(room, key, options) {
|
|
410
|
+
var _a;
|
|
411
|
+
const existingBinding = (_a = sharedStateBindings.get(room)) !== null && _a !== void 0 ? _a : null;
|
|
412
|
+
if (existingBinding !== null) {
|
|
413
|
+
assertCompatibleSharedStateBinding(existingBinding, key, options);
|
|
414
|
+
}
|
|
415
|
+
const state = room.useState(options);
|
|
416
|
+
const binding = existingBinding !== null && existingBinding !== void 0 ? existingBinding : createSharedStateBinding(key, options);
|
|
417
|
+
sharedStateBindings.set(room, binding);
|
|
418
|
+
if (binding.persist !== true && options.persist === true && binding.strategy === 'lww') {
|
|
419
|
+
binding.persist = true;
|
|
420
|
+
}
|
|
421
|
+
return state;
|
|
422
|
+
}
|
|
423
|
+
function readPresenceSnapshot(room, presence, cacheRef) {
|
|
424
|
+
const all = presence.getAll();
|
|
425
|
+
const self = readSelfPeer(room, presence, all);
|
|
426
|
+
const others = all.filter((peer) => {
|
|
427
|
+
return peer.id !== room.peerId;
|
|
428
|
+
});
|
|
429
|
+
const previous = cacheRef.current;
|
|
430
|
+
if (previous !== null && previous.room === room && previous.engine === presence) {
|
|
431
|
+
const previousSnapshot = previous.snapshot;
|
|
432
|
+
const isAllEqual = arePeerArraysEqual(previousSnapshot.all, all);
|
|
433
|
+
const isSelfEqual = arePeersEqual(previousSnapshot.self, self);
|
|
434
|
+
const isOthersEqual = arePeerArraysEqual(previousSnapshot.others, others);
|
|
435
|
+
if (isAllEqual && isSelfEqual && isOthersEqual) {
|
|
436
|
+
return previousSnapshot;
|
|
437
|
+
}
|
|
438
|
+
const nextSnapshot = {
|
|
439
|
+
self: isSelfEqual ? previousSnapshot.self : self,
|
|
440
|
+
others: isOthersEqual ? previousSnapshot.others : others,
|
|
441
|
+
all: isAllEqual ? previousSnapshot.all : all,
|
|
442
|
+
};
|
|
443
|
+
previous.snapshot = nextSnapshot;
|
|
444
|
+
return nextSnapshot;
|
|
445
|
+
}
|
|
446
|
+
const snapshot = {
|
|
447
|
+
self,
|
|
448
|
+
others,
|
|
449
|
+
all,
|
|
450
|
+
};
|
|
451
|
+
cacheRef.current = {
|
|
452
|
+
room,
|
|
453
|
+
engine: presence,
|
|
454
|
+
snapshot,
|
|
455
|
+
};
|
|
456
|
+
return snapshot;
|
|
457
|
+
}
|
|
458
|
+
function readCursorSnapshot(room, cursors, cacheRef) {
|
|
459
|
+
const nextSnapshot = cursors.getPositions();
|
|
460
|
+
const previous = cacheRef.current;
|
|
461
|
+
if (previous !== null && previous.room === room && previous.engine === cursors) {
|
|
462
|
+
const previousSnapshot = previous.snapshot;
|
|
463
|
+
if (areCursorArraysEqual(previousSnapshot, nextSnapshot)) {
|
|
464
|
+
return previousSnapshot;
|
|
465
|
+
}
|
|
466
|
+
previous.snapshot = nextSnapshot.map((position, index) => {
|
|
467
|
+
const previousPosition = previousSnapshot[index];
|
|
468
|
+
if (previousPosition !== undefined && areCursorPositionsEqual(previousPosition, position)) {
|
|
469
|
+
return previousPosition;
|
|
470
|
+
}
|
|
471
|
+
return position;
|
|
472
|
+
});
|
|
473
|
+
return previous.snapshot;
|
|
474
|
+
}
|
|
475
|
+
cacheRef.current = {
|
|
476
|
+
room,
|
|
477
|
+
engine: cursors,
|
|
478
|
+
snapshot: nextSnapshot,
|
|
479
|
+
};
|
|
480
|
+
return nextSnapshot;
|
|
481
|
+
}
|
|
482
|
+
function readAwarenessSnapshot(room, awareness, cacheRef) {
|
|
483
|
+
const nextOthers = awareness.getAll().filter((entry) => {
|
|
484
|
+
return entry.peerId !== room.peerId;
|
|
485
|
+
});
|
|
486
|
+
const previous = cacheRef.current;
|
|
487
|
+
if (previous !== null && previous.room === room && previous.engine === awareness) {
|
|
488
|
+
const previousSnapshot = previous.snapshot;
|
|
489
|
+
if (areAwarenessArraysEqual(previousSnapshot, nextOthers)) {
|
|
490
|
+
return previousSnapshot;
|
|
491
|
+
}
|
|
492
|
+
previous.snapshot = nextOthers.map((entry, index) => {
|
|
493
|
+
const previousEntry = previousSnapshot[index];
|
|
494
|
+
if (previousEntry !== undefined && areStructuredValuesEqual(previousEntry, entry)) {
|
|
495
|
+
return previousEntry;
|
|
496
|
+
}
|
|
497
|
+
return entry;
|
|
498
|
+
});
|
|
499
|
+
return previous.snapshot;
|
|
500
|
+
}
|
|
501
|
+
cacheRef.current = {
|
|
502
|
+
room,
|
|
503
|
+
engine: awareness,
|
|
504
|
+
snapshot: nextOthers,
|
|
505
|
+
};
|
|
506
|
+
return nextOthers;
|
|
507
|
+
}
|
|
508
|
+
function readSharedStateSnapshot(room, state, cacheRef) {
|
|
509
|
+
const nextSnapshot = state.get();
|
|
510
|
+
const previous = cacheRef.current;
|
|
511
|
+
if (previous !== null && previous.room === room && previous.engine === state) {
|
|
512
|
+
if (areStructuredValuesEqual(previous.snapshot, nextSnapshot)) {
|
|
513
|
+
return previous.snapshot;
|
|
514
|
+
}
|
|
515
|
+
previous.snapshot = nextSnapshot;
|
|
516
|
+
return nextSnapshot;
|
|
517
|
+
}
|
|
518
|
+
cacheRef.current = {
|
|
519
|
+
room,
|
|
520
|
+
engine: state,
|
|
521
|
+
snapshot: nextSnapshot,
|
|
522
|
+
};
|
|
523
|
+
return nextSnapshot;
|
|
524
|
+
}
|
|
525
|
+
function areCursorOptionsEqual(previous, next) {
|
|
526
|
+
return areShallowObjectsEqual(previous, next);
|
|
527
|
+
}
|
|
528
|
+
function areShallowObjectsEqual(a, b) {
|
|
529
|
+
if (a === b) {
|
|
530
|
+
return true;
|
|
531
|
+
}
|
|
532
|
+
if (a === undefined || b === undefined) {
|
|
533
|
+
return false;
|
|
534
|
+
}
|
|
535
|
+
const aKeys = Object.keys(a);
|
|
536
|
+
const bKeys = Object.keys(b);
|
|
537
|
+
if (aKeys.length !== bKeys.length) {
|
|
538
|
+
return false;
|
|
539
|
+
}
|
|
540
|
+
for (const key of aKeys) {
|
|
541
|
+
if (!Object.prototype.hasOwnProperty.call(b, key) ||
|
|
542
|
+
Reflect.get(a, key) !== Reflect.get(b, key)) {
|
|
543
|
+
return false;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
return true;
|
|
547
|
+
}
|
|
548
|
+
function isStateUpdater(value) {
|
|
549
|
+
return typeof value === 'function';
|
|
550
|
+
}
|
|
551
|
+
function isRoomfulPluginOptions(value) {
|
|
552
|
+
return isObjectLike(value) && typeof Reflect.get(value, 'roomId') === 'string';
|
|
553
|
+
}
|
|
554
|
+
function isRoom(value) {
|
|
555
|
+
if (!isObjectLike(value)) {
|
|
556
|
+
return false;
|
|
557
|
+
}
|
|
558
|
+
return (typeof Reflect.get(value, 'id') === 'string' &&
|
|
559
|
+
typeof Reflect.get(value, 'peerId') === 'string' &&
|
|
560
|
+
hasFunction(value, 'connect') &&
|
|
561
|
+
hasFunction(value, 'disconnect') &&
|
|
562
|
+
hasFunction(value, 'usePresence') &&
|
|
563
|
+
hasFunction(value, 'useCursors') &&
|
|
564
|
+
hasFunction(value, 'useState') &&
|
|
565
|
+
hasFunction(value, 'useAwareness') &&
|
|
566
|
+
hasFunction(value, 'useEvents') &&
|
|
567
|
+
hasFunction(value, 'getYDoc') &&
|
|
568
|
+
hasFunction(value, 'getYProvider') &&
|
|
569
|
+
hasFunction(value, 'on') &&
|
|
570
|
+
hasFunction(value, 'off'));
|
|
571
|
+
}
|
|
572
|
+
function hasFunction(value, key) {
|
|
573
|
+
return typeof Reflect.get(value, key) === 'function';
|
|
574
|
+
}
|
|
575
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,aAAa,EACb,wBAAwB,EACxB,kCAAkC,EAClC,wBAAwB,EACxB,YAAY,EACZ,YAAY,GAEb,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAoL7E,MAAM,mBAAmB,GAAuC,MAAM,CAAC,sBAAsB,CAAC,CAAC;AAC/F,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAA0C,CAAC;AAElF;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAA+C;IACvE,OAAO,CAAC,GAAG,EAAE,UAAU;QACrB,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC,EAAE,CAAC;YACxC,MAAM,IAAI,YAAY,CACpB,eAAe,EACf,wEAAwE,EACxE,KAAK,CACN,CAAC;QACJ,CAAC;QAED,MAAM,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,EAAE,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAC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AED,SAAS,MAAM,CACb,KAAc;IAEd,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,CACL,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,QAAQ;QAC5C,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,QAAQ;QAChD,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC;QAC7B,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC;QAChC,WAAW,CAAC,KAAK,EAAE,aAAa,CAAC;QACjC,WAAW,CAAC,KAAK,EAAE,YAAY,CAAC;QAChC,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC;QAC9B,WAAW,CAAC,KAAK,EAAE,cAAc,CAAC;QAClC,WAAW,CAAC,KAAK,EAAE,WAAW,CAAC;QAC/B,WAAW,CAAC,KAAK,EAAE,SAAS,CAAC;QAC7B,WAAW,CAAC,KAAK,EAAE,cAAc,CAAC;QAClC,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC;QACxB,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,CAC1B,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,KAAa,EAAE,GAAW;IAC7C,OAAO,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,UAAU,CAAC;AACvD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@roomful/vue",
|
|
3
|
+
"version": "1.0.0-beta.6",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18"
|
|
21
|
+
},
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@roomful/core": "1.0.0-beta.6"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@vue/test-utils": "^2.4.6",
|
|
28
|
+
"jsdom": "^26.0.0",
|
|
29
|
+
"vue": "3.5.29"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"vue": ">=3.2.0"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsc -p tsconfig.json",
|
|
39
|
+
"lint": "eslint src --max-warnings 0",
|
|
40
|
+
"test": "vitest run --config ../../vitest.package.config.ts",
|
|
41
|
+
"test:types": "tsd --files test-d/**/*.test-d.ts",
|
|
42
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
43
|
+
"clean": "rimraf dist coverage",
|
|
44
|
+
"test:watch": "vitest --config ../../vitest.package.config.ts"
|
|
45
|
+
}
|
|
46
|
+
}
|