voodoojs 0.4.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.
Files changed (54) hide show
  1. package/README.md +77 -0
  2. package/dist/chunk-234ZLC6W.js +401 -0
  3. package/dist/chunk-4HQEOXTK.js +10271 -0
  4. package/dist/chunk-5777LJVW.js +64 -0
  5. package/dist/chunk-5CKGDARU.js +1845 -0
  6. package/dist/chunk-A2UOVQBP.js +82 -0
  7. package/dist/chunk-E27NRARW.js +16 -0
  8. package/dist/chunk-JZIYRIY6.js +1196 -0
  9. package/dist/chunk-NNU6WOOU.js +641 -0
  10. package/dist/chunk-PQZEVFVZ.js +448 -0
  11. package/dist/chunk-RJUNPXQF.js +946 -0
  12. package/dist/chunk-U76IRJKH.js +72 -0
  13. package/dist/essential.cjs +13889 -0
  14. package/dist/essential.d.cts +24 -0
  15. package/dist/essential.d.ts +24 -0
  16. package/dist/essential.js +51 -0
  17. package/dist/gpu.cjs +2008 -0
  18. package/dist/gpu.d.cts +68 -0
  19. package/dist/gpu.d.ts +68 -0
  20. package/dist/gpu.js +273 -0
  21. package/dist/http.cjs +467 -0
  22. package/dist/http.d.cts +148 -0
  23. package/dist/http.d.ts +148 -0
  24. package/dist/http.js +7 -0
  25. package/dist/index-CaLD-0oh.d.cts +608 -0
  26. package/dist/index-CaLD-0oh.d.ts +608 -0
  27. package/dist/index-DTllqUtj.d.cts +261 -0
  28. package/dist/index-DTllqUtj.d.ts +261 -0
  29. package/dist/index.cjs +23063 -0
  30. package/dist/index.d.cts +1603 -0
  31. package/dist/index.d.ts +1603 -0
  32. package/dist/index.js +6924 -0
  33. package/dist/query-CKJ4oSpG.d.cts +1595 -0
  34. package/dist/query-DQFRmu3u.d.ts +1595 -0
  35. package/dist/reactivity.cjs +676 -0
  36. package/dist/reactivity.d.cts +188 -0
  37. package/dist/reactivity.d.ts +188 -0
  38. package/dist/reactivity.js +4 -0
  39. package/dist/socket.cjs +2685 -0
  40. package/dist/socket.d.cts +167 -0
  41. package/dist/socket.d.ts +167 -0
  42. package/dist/socket.js +238 -0
  43. package/dist/style-XEUAGGJK.js +5 -0
  44. package/dist/utils.cjs +397 -0
  45. package/dist/utils.d.cts +111 -0
  46. package/dist/utils.d.ts +111 -0
  47. package/dist/utils.js +4 -0
  48. package/dist/voodoo.core.js +8213 -0
  49. package/dist/voodoo.core.min.js +146 -0
  50. package/dist/voodoo.full.js +21193 -0
  51. package/dist/voodoo.full.min.js +1784 -0
  52. package/dist/voodoo.js +14185 -0
  53. package/dist/voodoo.min.js +420 -0
  54. package/package.json +127 -0
@@ -0,0 +1,167 @@
1
+ export { R as RoomOptions, a as RoomState, h as Socket, i as SocketDefaults, j as SocketFactory, k as SocketInterceptor, l as SocketListener, S as SocketMessage, b as SocketOptions, c as SocketRoom, d as SocketState, e as SocketTransport, V as VoodooSocket, W as WebSocketCtor, m as WebSocketLike, f as createSocket, r as resolveSocketURL, s as socket, g as socketSupported } from './index-DTllqUtj.cjs';
2
+
3
+ /**
4
+ * @module socket/protocol
5
+ *
6
+ * The Engine.IO/Socket.IO protocol written by hand, without the library.
7
+ *
8
+ * It's worth explaining why this file exists. `socket.io-client` weighs over 30
9
+ * KB compressed, and Voodoo has no runtime dependencies. It happens
10
+ * that the piece of the protocol a page actually uses is small: one
11
+ * handshake, six packet codes and some JSON. This fits in plain text over
12
+ * native WebSocket, and that's exactly what's here.
13
+ *
14
+ * An Engine.IO v4 text frame has the form `<code><body>`:
15
+ *
16
+ * ```text
17
+ * 0{"sid":"abc","pingInterval":25000,"pingTimeout":20000} open
18
+ * 2 server ping
19
+ * 3 client pong
20
+ * 40 enter namespace
21
+ * 42["mensagem",{"texto":"oi"}] event
22
+ * 421["salvar",{...}] event requesting ack 1
23
+ * 431[{"ok":true}] ack 1 response
24
+ * ```
25
+ *
26
+ * The body of a `4` (message) packet is a Socket.IO packet, which in turn has
27
+ * the form `<type>[<namespace>,][<ack>]<JSON>`. The two layers are decoded
28
+ * here, in pure functions, because pure-function protocol is testable protocol.
29
+ *
30
+ * What **is not** implemented is declared in `docs/websocket.md`, and the
31
+ * short list is: binary attachments (`45`/`46`), polling transport and upgrade,
32
+ * and namespaces other than `/`.
33
+ */
34
+ /** Codigos de pacote do Engine.IO v4. */
35
+ declare const ENGINE: {
36
+ readonly OPEN: "0";
37
+ readonly CLOSE: "1";
38
+ readonly PING: "2";
39
+ readonly PONG: "3";
40
+ readonly MESSAGE: "4";
41
+ readonly UPGRADE: "5";
42
+ readonly NOOP: "6";
43
+ };
44
+ /** Tipos de pacote do Socket.IO v5 (protocolo do servidor v4). */
45
+ declare const SIO: {
46
+ readonly CONNECT: 0;
47
+ readonly DISCONNECT: 1;
48
+ readonly EVENT: 2;
49
+ readonly ACK: 3;
50
+ readonly CONNECT_ERROR: 4;
51
+ readonly BINARY_EVENT: 5;
52
+ readonly BINARY_ACK: 6;
53
+ };
54
+ /** Data the server sends in the open packet. */
55
+ interface EngineHandshake {
56
+ sid: string;
57
+ /** Interval between server pings, in ms. */
58
+ pingInterval: number;
59
+ /** How long the server waits for pong before giving up, in ms. */
60
+ pingTimeout: number;
61
+ upgrades?: string[];
62
+ maxPayload?: number;
63
+ }
64
+ /** Socket.IO packet already split into its parts. */
65
+ interface SocketIoPacket {
66
+ /** One of the values of `SIO`. */
67
+ type: number;
68
+ /** Namespace. This implementation only supports `/`. */
69
+ namespace: string;
70
+ /** Ack number, when the packet requests or responds with acknowledgment. */
71
+ ack?: number;
72
+ /** Body already converted from JSON. For events, `[name, ...args]`. */
73
+ data?: unknown;
74
+ }
75
+ /** Engine.IO packet already classified. */
76
+ type EnginePacket = {
77
+ kind: 'open';
78
+ handshake: EngineHandshake;
79
+ } | {
80
+ kind: 'close';
81
+ } | {
82
+ kind: 'ping';
83
+ } | {
84
+ kind: 'pong';
85
+ } | {
86
+ kind: 'message';
87
+ packet: SocketIoPacket;
88
+ } | {
89
+ kind: 'noop';
90
+ }
91
+ /** Frame this client can't read: binary, upgrade or garbage. */
92
+ | {
93
+ kind: 'unknown';
94
+ raw: string;
95
+ };
96
+ /**
97
+ * Reads the body of an Engine.IO `4` (message) packet.
98
+ *
99
+ * The order of parts is fixed and each only appears when it exists, so
100
+ * reading is positional: type, optional namespace ending in comma, optional ack
101
+ * in digits, and the rest is JSON.
102
+ */
103
+ declare function decodeSocketIo(body: string): SocketIoPacket | null;
104
+ /**
105
+ * Classifies a text frame received from the server.
106
+ *
107
+ * Binary frames arrive as `Blob` or `ArrayBuffer` and become `unknown`: they're
108
+ * valid in the protocol, this implementation just doesn't read them.
109
+ */
110
+ declare function decodeEngine(raw: unknown): EnginePacket;
111
+ /**
112
+ * Builds a `4` (message) packet ready for the wire.
113
+ *
114
+ * `encodeSocketIo({ type: SIO.EVENT, data: ['oi', 1] })` returns `42["oi",1]`.
115
+ */
116
+ declare function encodeSocketIo(packet: SocketIoPacket): string;
117
+ /**
118
+ * Builds the Engine.IO endpoint URL.
119
+ *
120
+ * The path becomes `<path>?EIO=4&transport=websocket`, because this implementation
121
+ * opens directly in WebSocket and never uses polling.
122
+ */
123
+ declare function engineURL(base: string, path?: string): string;
124
+
125
+ /**
126
+ * @module socket/plugin
127
+ *
128
+ * Separate entry for the real-time layer.
129
+ *
130
+ * The reason is measured, not aesthetic: with the module in the complete build,
131
+ * the file went from 127.58 KB to 134.22 KB compressed, and the ceiling is 133. Instead
132
+ * of raising the target, which is the same as having no target, the module became its own
133
+ * entry, as the GPU layer already had for the same reason. Those using
134
+ * WebSocket pay for WebSocket; those not using it keep the file the same size as before.
135
+ *
136
+ * ```html
137
+ * <script src="https://cdn.jsdelivr.net/npm/voodoojs/dist/voodoo.min.js" defer></script>
138
+ * <script type="module">
139
+ * import 'https://cdn.jsdelivr.net/npm/voodoojs/dist/socket.js'
140
+ * </script>
141
+ * ```
142
+ *
143
+ * ```js
144
+ * import V from 'voodoojs'
145
+ * import 'voodoojs/dist/socket.js' // registers v-socket, v-room and sets up V.socket
146
+ * ```
147
+ *
148
+ * Importing this file has two effects: registers the `v-socket`,
149
+ * `v-room` and `v-on-socket` directives, and makes `V.socket` available. In ESM builds
150
+ * both sides share the same runtime, because common parts go out in
151
+ * shared chunks.
152
+ */
153
+
154
+ /**
155
+ * Plugin in the format accepted by `V.use()`.
156
+ *
157
+ * ```js
158
+ * import { voodooSocket } from 'voodoojs/dist/socket.js'
159
+ * V.use(voodooSocket)
160
+ * ```
161
+ */
162
+ declare const voodooSocket: {
163
+ name: string;
164
+ install(V: Record<string, unknown>): void;
165
+ };
166
+
167
+ export { ENGINE, type EngineHandshake, type EnginePacket, SIO, type SocketIoPacket, decodeEngine, decodeSocketIo, voodooSocket as default, encodeSocketIo, engineURL, voodooSocket };
@@ -0,0 +1,167 @@
1
+ export { R as RoomOptions, a as RoomState, h as Socket, i as SocketDefaults, j as SocketFactory, k as SocketInterceptor, l as SocketListener, S as SocketMessage, b as SocketOptions, c as SocketRoom, d as SocketState, e as SocketTransport, V as VoodooSocket, W as WebSocketCtor, m as WebSocketLike, f as createSocket, r as resolveSocketURL, s as socket, g as socketSupported } from './index-DTllqUtj.js';
2
+
3
+ /**
4
+ * @module socket/protocol
5
+ *
6
+ * The Engine.IO/Socket.IO protocol written by hand, without the library.
7
+ *
8
+ * It's worth explaining why this file exists. `socket.io-client` weighs over 30
9
+ * KB compressed, and Voodoo has no runtime dependencies. It happens
10
+ * that the piece of the protocol a page actually uses is small: one
11
+ * handshake, six packet codes and some JSON. This fits in plain text over
12
+ * native WebSocket, and that's exactly what's here.
13
+ *
14
+ * An Engine.IO v4 text frame has the form `<code><body>`:
15
+ *
16
+ * ```text
17
+ * 0{"sid":"abc","pingInterval":25000,"pingTimeout":20000} open
18
+ * 2 server ping
19
+ * 3 client pong
20
+ * 40 enter namespace
21
+ * 42["mensagem",{"texto":"oi"}] event
22
+ * 421["salvar",{...}] event requesting ack 1
23
+ * 431[{"ok":true}] ack 1 response
24
+ * ```
25
+ *
26
+ * The body of a `4` (message) packet is a Socket.IO packet, which in turn has
27
+ * the form `<type>[<namespace>,][<ack>]<JSON>`. The two layers are decoded
28
+ * here, in pure functions, because pure-function protocol is testable protocol.
29
+ *
30
+ * What **is not** implemented is declared in `docs/websocket.md`, and the
31
+ * short list is: binary attachments (`45`/`46`), polling transport and upgrade,
32
+ * and namespaces other than `/`.
33
+ */
34
+ /** Codigos de pacote do Engine.IO v4. */
35
+ declare const ENGINE: {
36
+ readonly OPEN: "0";
37
+ readonly CLOSE: "1";
38
+ readonly PING: "2";
39
+ readonly PONG: "3";
40
+ readonly MESSAGE: "4";
41
+ readonly UPGRADE: "5";
42
+ readonly NOOP: "6";
43
+ };
44
+ /** Tipos de pacote do Socket.IO v5 (protocolo do servidor v4). */
45
+ declare const SIO: {
46
+ readonly CONNECT: 0;
47
+ readonly DISCONNECT: 1;
48
+ readonly EVENT: 2;
49
+ readonly ACK: 3;
50
+ readonly CONNECT_ERROR: 4;
51
+ readonly BINARY_EVENT: 5;
52
+ readonly BINARY_ACK: 6;
53
+ };
54
+ /** Data the server sends in the open packet. */
55
+ interface EngineHandshake {
56
+ sid: string;
57
+ /** Interval between server pings, in ms. */
58
+ pingInterval: number;
59
+ /** How long the server waits for pong before giving up, in ms. */
60
+ pingTimeout: number;
61
+ upgrades?: string[];
62
+ maxPayload?: number;
63
+ }
64
+ /** Socket.IO packet already split into its parts. */
65
+ interface SocketIoPacket {
66
+ /** One of the values of `SIO`. */
67
+ type: number;
68
+ /** Namespace. This implementation only supports `/`. */
69
+ namespace: string;
70
+ /** Ack number, when the packet requests or responds with acknowledgment. */
71
+ ack?: number;
72
+ /** Body already converted from JSON. For events, `[name, ...args]`. */
73
+ data?: unknown;
74
+ }
75
+ /** Engine.IO packet already classified. */
76
+ type EnginePacket = {
77
+ kind: 'open';
78
+ handshake: EngineHandshake;
79
+ } | {
80
+ kind: 'close';
81
+ } | {
82
+ kind: 'ping';
83
+ } | {
84
+ kind: 'pong';
85
+ } | {
86
+ kind: 'message';
87
+ packet: SocketIoPacket;
88
+ } | {
89
+ kind: 'noop';
90
+ }
91
+ /** Frame this client can't read: binary, upgrade or garbage. */
92
+ | {
93
+ kind: 'unknown';
94
+ raw: string;
95
+ };
96
+ /**
97
+ * Reads the body of an Engine.IO `4` (message) packet.
98
+ *
99
+ * The order of parts is fixed and each only appears when it exists, so
100
+ * reading is positional: type, optional namespace ending in comma, optional ack
101
+ * in digits, and the rest is JSON.
102
+ */
103
+ declare function decodeSocketIo(body: string): SocketIoPacket | null;
104
+ /**
105
+ * Classifies a text frame received from the server.
106
+ *
107
+ * Binary frames arrive as `Blob` or `ArrayBuffer` and become `unknown`: they're
108
+ * valid in the protocol, this implementation just doesn't read them.
109
+ */
110
+ declare function decodeEngine(raw: unknown): EnginePacket;
111
+ /**
112
+ * Builds a `4` (message) packet ready for the wire.
113
+ *
114
+ * `encodeSocketIo({ type: SIO.EVENT, data: ['oi', 1] })` returns `42["oi",1]`.
115
+ */
116
+ declare function encodeSocketIo(packet: SocketIoPacket): string;
117
+ /**
118
+ * Builds the Engine.IO endpoint URL.
119
+ *
120
+ * The path becomes `<path>?EIO=4&transport=websocket`, because this implementation
121
+ * opens directly in WebSocket and never uses polling.
122
+ */
123
+ declare function engineURL(base: string, path?: string): string;
124
+
125
+ /**
126
+ * @module socket/plugin
127
+ *
128
+ * Separate entry for the real-time layer.
129
+ *
130
+ * The reason is measured, not aesthetic: with the module in the complete build,
131
+ * the file went from 127.58 KB to 134.22 KB compressed, and the ceiling is 133. Instead
132
+ * of raising the target, which is the same as having no target, the module became its own
133
+ * entry, as the GPU layer already had for the same reason. Those using
134
+ * WebSocket pay for WebSocket; those not using it keep the file the same size as before.
135
+ *
136
+ * ```html
137
+ * <script src="https://cdn.jsdelivr.net/npm/voodoojs/dist/voodoo.min.js" defer></script>
138
+ * <script type="module">
139
+ * import 'https://cdn.jsdelivr.net/npm/voodoojs/dist/socket.js'
140
+ * </script>
141
+ * ```
142
+ *
143
+ * ```js
144
+ * import V from 'voodoojs'
145
+ * import 'voodoojs/dist/socket.js' // registers v-socket, v-room and sets up V.socket
146
+ * ```
147
+ *
148
+ * Importing this file has two effects: registers the `v-socket`,
149
+ * `v-room` and `v-on-socket` directives, and makes `V.socket` available. In ESM builds
150
+ * both sides share the same runtime, because common parts go out in
151
+ * shared chunks.
152
+ */
153
+
154
+ /**
155
+ * Plugin in the format accepted by `V.use()`.
156
+ *
157
+ * ```js
158
+ * import { voodooSocket } from 'voodoojs/dist/socket.js'
159
+ * V.use(voodooSocket)
160
+ * ```
161
+ */
162
+ declare const voodooSocket: {
163
+ name: string;
164
+ install(V: Record<string, unknown>): void;
165
+ };
166
+
167
+ export { ENGINE, type EngineHandshake, type EnginePacket, SIO, type SocketIoPacket, decodeEngine, decodeSocketIo, voodooSocket as default, encodeSocketIo, engineURL, voodooSocket };
package/dist/socket.js ADDED
@@ -0,0 +1,238 @@
1
+ import { socketSupported, createSocket, socket } from './chunk-RJUNPXQF.js';
2
+ export { ENGINE, SIO, createSocket, decodeEngine, decodeSocketIo, encodeSocketIo, engineURL, resolveSocketURL, socket, socketSupported } from './chunk-RJUNPXQF.js';
3
+ import { evaluateIn, readAttr } from './chunk-5CKGDARU.js';
4
+ import { reactive } from './chunk-NNU6WOOU.js';
5
+ import { warnAlias } from './chunk-A2UOVQBP.js';
6
+ import { parseDuration } from './chunk-234ZLC6W.js';
7
+ import { defineDirective, PRIORITY, config } from './chunk-5777LJVW.js';
8
+ import './chunk-E27NRARW.js';
9
+
10
+ /**
11
+ * Voodoo.js v0.4.6
12
+ * JavaScript feels like magic.
13
+ * (c) 2026 Voodoo.js contributors. MIT License.
14
+ */
15
+
16
+ // src/directives/socket.ts
17
+ function aliasLegacy(view, pairs) {
18
+ for (const [old, canonical] of pairs) {
19
+ Object.defineProperty(view, old, {
20
+ enumerable: false,
21
+ configurable: true,
22
+ get() {
23
+ warnAlias(old, canonical);
24
+ return view[canonical];
25
+ },
26
+ set(value) {
27
+ warnAlias(old, canonical);
28
+ view[canonical] = value;
29
+ }
30
+ });
31
+ }
32
+ }
33
+ function attr(el, name) {
34
+ return readAttr(el, `${config.prefix}${name}`);
35
+ }
36
+ var connections = /* @__PURE__ */ new WeakMap();
37
+ function closest(el, map) {
38
+ let current = el;
39
+ while (current) {
40
+ const found = map.get(current);
41
+ if (found) return found;
42
+ current = current.parentElement;
43
+ }
44
+ return null;
45
+ }
46
+ function resolveText(expression, scope, context) {
47
+ const text = expression.trim();
48
+ if (!text) return "";
49
+ if (/^[A-Za-z_$][\w$]*$/.test(text)) {
50
+ const value2 = scope.has(text) ? scope.get(text) : void 0;
51
+ return typeof value2 === "string" && value2 ? value2 : text;
52
+ }
53
+ if (/^(wss?|https?):\/\//i.test(text) || /^[\w:.\-/]+$/.test(text)) return text;
54
+ const value = evaluateIn(text, scope, context);
55
+ return typeof value === "string" && value ? value : text;
56
+ }
57
+ function dispatch(el, type, detail) {
58
+ el.dispatchEvent(new CustomEvent(type, { detail, bubbles: true }));
59
+ }
60
+ defineDirective(
61
+ "socket",
62
+ ({ el, scope, expression, modifiers, cleanup, effect }) => {
63
+ const name = attr(el, "socket-as") || "$socket";
64
+ if (!socketSupported()) {
65
+ el.setAttribute("data-socket", "unsupported");
66
+ scope.set(
67
+ name,
68
+ reactive({
69
+ connected: false,
70
+ state: "closed",
71
+ error: "WebSocket unavailable in this environment",
72
+ attempts: 0,
73
+ messages: [],
74
+ send: () => false,
75
+ open: () => void 0,
76
+ close: () => void 0,
77
+ socket: null
78
+ })
79
+ );
80
+ dispatch(el, "voodoo:socket-unsupported", { url: expression });
81
+ return;
82
+ }
83
+ const limit = Number(attr(el, "socket-buffer") ?? 50);
84
+ const transport = attr(el, "socket-transport") || "ws";
85
+ const reconnect = !modifiers["no-reconnect"] && modifiers.reconnect !== "false" && attr(el, "socket-reconnect") !== "false";
86
+ const options = {
87
+ transport: transport === "socket.io" ? "socket.io" : "ws",
88
+ manual: !!modifiers.manual,
89
+ reconnect
90
+ };
91
+ if (modifiers.json) options.json = modifiers.json !== "false";
92
+ const path = attr(el, "socket-path");
93
+ if (path) options.path = path;
94
+ const heartbeat = attr(el, "socket-heartbeat");
95
+ if (heartbeat !== null) options.heartbeat = parseDuration(heartbeat, 25e3);
96
+ const s = createSocket(resolveText(expression, scope, "v-socket") || "/", options);
97
+ connections.set(el, s);
98
+ el.setAttribute("data-socket", "ready");
99
+ function send(event, ...rest) {
100
+ if (typeof event !== "string") return s.send(event);
101
+ return rest.length ? s.emit(event, rest[0]) : s.emit(event);
102
+ }
103
+ const view = reactive({
104
+ connected: s.connected,
105
+ state: s.state,
106
+ error: s.error,
107
+ attempts: s.attempts,
108
+ messages: [],
109
+ send,
110
+ open: () => s.open(),
111
+ close: () => s.close(),
112
+ socket: s
113
+ });
114
+ aliasLegacy(view, [
115
+ ["conectado", "connected"],
116
+ ["estado", "state"],
117
+ ["mensagens", "messages"],
118
+ ["erro", "error"],
119
+ ["tentativas", "attempts"],
120
+ ["enviar", "send"],
121
+ ["abrir", "open"],
122
+ ["fechar", "close"]
123
+ ]);
124
+ scope.set(name, view);
125
+ effect(() => {
126
+ view.connected = s.connected;
127
+ view.state = s.state;
128
+ view.error = s.error;
129
+ view.attempts = s.attempts;
130
+ });
131
+ const unsubscribe = [
132
+ s.on("message", (data) => {
133
+ view.messages.push(data);
134
+ if (view.messages.length > limit) {
135
+ view.messages.splice(0, view.messages.length - limit);
136
+ }
137
+ }),
138
+ s.on("open", () => dispatch(el, "voodoo:socket-open", { url: s.url })),
139
+ s.on("close", (d) => dispatch(el, "voodoo:socket-close", d)),
140
+ s.on("error", (d) => dispatch(el, "voodoo:socket-error", d))
141
+ ];
142
+ cleanup(() => {
143
+ for (const stop of unsubscribe) stop();
144
+ s.off();
145
+ s.close();
146
+ connections.delete(el);
147
+ });
148
+ },
149
+ { priority: PRIORITY.DATA }
150
+ );
151
+ defineDirective(
152
+ "room",
153
+ ({ el, scope, expression, modifiers, cleanup, effect }) => {
154
+ const s = closest(el, connections);
155
+ if (!s) return;
156
+ const roomName = resolveText(expression, scope, "v-room");
157
+ if (!roomName) return;
158
+ const room = s.join(roomName, {
159
+ private: !!modifiers.private || !!modifiers.privada,
160
+ buffer: Number(attr(el, "room-buffer") ?? 50)
161
+ });
162
+ const view = reactive({
163
+ name: roomName,
164
+ private: room.private,
165
+ state: room.state,
166
+ members: room.members,
167
+ messages: room.messages,
168
+ /** Sends to the room. With `to`, only to that recipient. */
169
+ send: (event, data, to) => to ? room.to(to).emit(event, data) : room.emit(event, data),
170
+ leave: () => room.leave(),
171
+ room
172
+ });
173
+ aliasLegacy(view, [
174
+ ["membros", "members"],
175
+ ["mensagens", "messages"],
176
+ ["estado", "state"],
177
+ ["nome", "name"],
178
+ ["privada", "private"],
179
+ ["enviar", "send"],
180
+ ["sair", "leave"]
181
+ ]);
182
+ scope.set(attr(el, "room-as") || "$room", view);
183
+ effect(() => {
184
+ view.state = room.state;
185
+ view.members = room.members;
186
+ view.messages = room.messages;
187
+ });
188
+ const unsubscribe = [
189
+ room.on("joined", (m) => dispatch(el, "voodoo:room-join", m)),
190
+ room.on("left", (m) => dispatch(el, "voodoo:room-leave", m))
191
+ ];
192
+ cleanup(() => {
193
+ for (const stop of unsubscribe) stop();
194
+ room.off();
195
+ room.leave();
196
+ });
197
+ },
198
+ // After `v-socket`, so the connection exists when the room asks to join.
199
+ { priority: PRIORITY.DATA - 1 }
200
+ );
201
+ defineDirective("on-socket", ({ el, scope, arg, expression, cleanup }) => {
202
+ if (!arg) return;
203
+ const target2 = closest(el, connections);
204
+ if (!target2) return;
205
+ const unsubscribe = target2.on(arg, (data, ack) => {
206
+ const local = scope.child({ $event: data, $ack: ack, $el: el });
207
+ const value = evaluateIn(expression, local, `v-on-socket:${arg}`);
208
+ if (typeof value === "function") value.call(scope.data, data);
209
+ });
210
+ cleanup(unsubscribe);
211
+ });
212
+ for (const nome of [
213
+ "socket-transport",
214
+ "socket-as",
215
+ "socket-buffer",
216
+ "socket-path",
217
+ "socket-heartbeat",
218
+ "socket-reconnect",
219
+ "room-as",
220
+ "room-buffer"
221
+ ]) {
222
+ defineDirective(nome, () => void 0, { priority: PRIORITY.TRANSITION });
223
+ }
224
+
225
+ // src/socket/plugin.ts
226
+ var voodooSocket = {
227
+ name: "socket",
228
+ install(V) {
229
+ if (!V.socket) V.socket = socket;
230
+ }
231
+ };
232
+ var target = globalThis.V;
233
+ if (target && typeof target === "object" && !target.socket) target.socket = socket;
234
+ var plugin_default = voodooSocket;
235
+
236
+ export { plugin_default as default, voodooSocket };
237
+ //# sourceMappingURL=socket.js.map
238
+ //# sourceMappingURL=socket.js.map
@@ -0,0 +1,5 @@
1
+ export { BASE_TOKENS, ensureTokens, injectStyle } from './chunk-U76IRJKH.js';
2
+ import './chunk-5777LJVW.js';
3
+ import './chunk-E27NRARW.js';
4
+ //# sourceMappingURL=style-XEUAGGJK.js.map
5
+ //# sourceMappingURL=style-XEUAGGJK.js.map