atom.io 0.25.5 → 0.26.0

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/data/dist/index.js +33 -25
  2. package/data/package.json +1 -4
  3. package/data/src/join.ts +0 -1
  4. package/dist/{chunk-HYXKCFVY.js → chunk-IBTHB2PI.js} +59 -60
  5. package/dist/{chunk-MR5NETHW.js → chunk-IW6WYRS7.js} +4 -5
  6. package/dist/chunk-XWL6SNVU.js +7 -0
  7. package/dist/index.js +33 -21
  8. package/ephemeral/dist/index.js +1 -1
  9. package/ephemeral/package.json +1 -4
  10. package/eslint-plugin/dist/index.d.ts +1 -1
  11. package/eslint-plugin/dist/index.js +7 -8
  12. package/eslint-plugin/package.json +1 -4
  13. package/immortal/dist/index.js +1 -1
  14. package/immortal/package.json +1 -4
  15. package/internal/dist/index.js +173 -160
  16. package/internal/package.json +1 -4
  17. package/introspection/dist/index.js +32 -30
  18. package/introspection/package.json +1 -4
  19. package/json/dist/index.js +1 -1
  20. package/json/package.json +1 -4
  21. package/package.json +27 -58
  22. package/react/dist/index.js +2 -2
  23. package/react/package.json +1 -4
  24. package/react-devtools/dist/index.js +75 -68
  25. package/react-devtools/package.json +1 -4
  26. package/realtime/dist/index.js +8 -9
  27. package/realtime/package.json +1 -4
  28. package/realtime-client/dist/index.js +6 -6
  29. package/realtime-client/package.json +1 -4
  30. package/realtime-react/dist/index.js +9 -11
  31. package/realtime-react/package.json +1 -4
  32. package/realtime-server/dist/index.js +59 -54
  33. package/realtime-server/package.json +1 -4
  34. package/realtime-testing/dist/index.js +3 -3
  35. package/realtime-testing/package.json +1 -4
  36. package/transceivers/set-rtx/dist/index.js +11 -11
  37. package/transceivers/set-rtx/package.json +1 -4
  38. package/data/dist/index.cjs +0 -953
  39. package/dist/chunk-S4N6XNPH.js +0 -38
  40. package/dist/index.cjs +0 -215
  41. package/ephemeral/dist/index.cjs +0 -11
  42. package/eslint-plugin/dist/index.cjs +0 -388
  43. package/immortal/dist/index.cjs +0 -14
  44. package/internal/dist/index.cjs +0 -3405
  45. package/introspection/dist/index.cjs +0 -449
  46. package/json/dist/index.cjs +0 -128
  47. package/react/dist/index.cjs +0 -118
  48. package/react-devtools/dist/index.cjs +0 -2191
  49. package/realtime/dist/index.cjs +0 -120
  50. package/realtime-client/dist/index.cjs +0 -569
  51. package/realtime-react/dist/index.cjs +0 -189
  52. package/realtime-server/dist/index.cjs +0 -965
  53. package/realtime-testing/dist/index.cjs +0 -201
  54. package/transceivers/set-rtx/dist/index.cjs +0 -215
@@ -1,201 +0,0 @@
1
- 'use strict';
2
-
3
- var http = require('http');
4
- var react = require('@testing-library/react');
5
- var AtomIO = require('atom.io');
6
- var data = require('atom.io/data');
7
- var internal = require('atom.io/internal');
8
- var AR = require('atom.io/react');
9
- var RT = require('atom.io/realtime');
10
- var realtimeClient = require('atom.io/realtime-client');
11
- var RTR = require('atom.io/realtime-react');
12
- var RTS = require('atom.io/realtime-server');
13
- var Happy = require('happy-dom');
14
- var SocketIO = require('socket.io');
15
- var socket_ioClient = require('socket.io-client');
16
- var jsxRuntime = require('react/jsx-runtime');
17
-
18
- function _interopNamespace(e) {
19
- if (e && e.__esModule) return e;
20
- var n = Object.create(null);
21
- if (e) {
22
- Object.keys(e).forEach(function (k) {
23
- if (k !== 'default') {
24
- var d = Object.getOwnPropertyDescriptor(e, k);
25
- Object.defineProperty(n, k, d.get ? d : {
26
- enumerable: true,
27
- get: function () { return e[k]; }
28
- });
29
- }
30
- });
31
- }
32
- n.default = e;
33
- return Object.freeze(n);
34
- }
35
-
36
- var http__namespace = /*#__PURE__*/_interopNamespace(http);
37
- var AtomIO__namespace = /*#__PURE__*/_interopNamespace(AtomIO);
38
- var AR__namespace = /*#__PURE__*/_interopNamespace(AR);
39
- var RT__namespace = /*#__PURE__*/_interopNamespace(RT);
40
- var RTR__namespace = /*#__PURE__*/_interopNamespace(RTR);
41
- var RTS__namespace = /*#__PURE__*/_interopNamespace(RTS);
42
- var Happy__namespace = /*#__PURE__*/_interopNamespace(Happy);
43
- var SocketIO__namespace = /*#__PURE__*/_interopNamespace(SocketIO);
44
-
45
- var __defProp = Object.defineProperty;
46
- var __defProps = Object.defineProperties;
47
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
48
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
49
- var __hasOwnProp = Object.prototype.hasOwnProperty;
50
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
51
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
52
- var __spreadValues = (a, b) => {
53
- for (var prop in b || (b = {}))
54
- if (__hasOwnProp.call(b, prop))
55
- __defNormalProp(a, prop, b[prop]);
56
- if (__getOwnPropSymbols)
57
- for (var prop of __getOwnPropSymbols(b)) {
58
- if (__propIsEnum.call(b, prop))
59
- __defNormalProp(a, prop, b[prop]);
60
- }
61
- return a;
62
- };
63
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
64
-
65
- // ../anvl/src/object/entries.ts
66
- var recordToEntries = (obj) => Object.entries(obj);
67
- var testNumber = 0;
68
- var setupRealtimeTestServer = (options) => {
69
- ++testNumber;
70
- const silo = new AtomIO__namespace.Silo(
71
- { name: `SERVER-${testNumber}`, lifespan: `ephemeral` },
72
- internal.IMPLICIT.STORE
73
- );
74
- const httpServer = http__namespace.createServer((_, res) => res.end(`Hello World!`));
75
- const address = httpServer.listen(options.port).address();
76
- const port = typeof address === `string` ? null : address === null ? null : address.port;
77
- if (port === null) throw new Error(`Could not determine port for test server`);
78
- const server = new SocketIO__namespace.Server(httpServer).use((socket, next) => {
79
- const { token, username } = socket.handshake.auth;
80
- if (token === `test` && socket.id) {
81
- const socketState = internal.findInStore(RTS__namespace.socketAtoms, socket.id, silo.store);
82
- internal.setIntoStore(socketState, socket, silo.store);
83
- data.editRelationsInStore(
84
- RTS__namespace.usersOfSockets,
85
- (relations) => {
86
- relations.set(socket.id, username);
87
- },
88
- silo.store
89
- );
90
- internal.setIntoStore(RTS__namespace.userIndex, (index) => index.add(username), silo.store);
91
- internal.setIntoStore(RTS__namespace.socketIndex, (index) => index.add(socket.id), silo.store);
92
- console.log(`${username} connected on ${socket.id}`);
93
- next();
94
- } else {
95
- next(new Error(`Authentication error`));
96
- }
97
- });
98
- server.on(`connection`, (socket) => {
99
- options.server({ socket, silo });
100
- });
101
- const dispose = () => {
102
- server.close();
103
- const roomKeys = internal.getFromStore(RT__namespace.roomIndex, silo.store);
104
- for (const roomKey of roomKeys) {
105
- const roomState = internal.findInStore(RTS__namespace.roomSelectors, roomKey, silo.store);
106
- const room = internal.getFromStore(roomState, silo.store);
107
- if (room && !(room instanceof Promise)) {
108
- room.process.kill();
109
- }
110
- }
111
- silo.store.valueMap.clear();
112
- };
113
- return {
114
- name: `SERVER`,
115
- silo,
116
- dispose,
117
- port
118
- };
119
- };
120
- var setupRealtimeTestClient = (options, name, port) => {
121
- const testClient = { dispose: () => {
122
- } };
123
- const init = () => {
124
- const socket = socket_ioClient.io(`http://localhost:${port}/`, {
125
- auth: { token: `test`, username: `${name}-${testNumber}` }
126
- });
127
- const silo = new AtomIO__namespace.Silo({ name, lifespan: `ephemeral` }, internal.IMPLICIT.STORE);
128
- for (const [key, value] of silo.store.valueMap.entries()) {
129
- if (Array.isArray(value)) {
130
- silo.store.valueMap.set(key, [...value]);
131
- }
132
- }
133
- silo.setState(realtimeClient.myUsernameState, `${name}-${testNumber}`);
134
- const { document } = new Happy__namespace.Window();
135
- document.body.innerHTML = `<div id="app"></div>`;
136
- const renderResult = react.render(
137
- /* @__PURE__ */ jsxRuntime.jsx(AR__namespace.StoreProvider, { store: silo.store, children: /* @__PURE__ */ jsxRuntime.jsx(RTR__namespace.RealtimeProvider, { socket, children: /* @__PURE__ */ jsxRuntime.jsx(options.client, {}) }) }),
138
- {
139
- container: document.querySelector(`#app`)
140
- }
141
- );
142
- const prettyPrint = () => {
143
- console.log(react.prettyDOM(renderResult.container));
144
- };
145
- const dispose = () => {
146
- renderResult.unmount();
147
- socket.disconnect();
148
- internal.clearStore(silo.store);
149
- };
150
- testClient.dispose = dispose;
151
- return {
152
- name,
153
- silo,
154
- socket,
155
- renderResult,
156
- prettyPrint
157
- };
158
- };
159
- return Object.assign(testClient, { init });
160
- };
161
- var singleClient = (options) => {
162
- const server = setupRealtimeTestServer(options);
163
- const client = setupRealtimeTestClient(options, `CLIENT`, server.port);
164
- return {
165
- client,
166
- server,
167
- teardown: () => {
168
- server.dispose();
169
- client.dispose();
170
- }
171
- };
172
- };
173
- var multiClient = (options) => {
174
- const server = setupRealtimeTestServer(options);
175
- const clients = recordToEntries(options.clients).reduce(
176
- (clientRecord, [name, client]) => {
177
- clientRecord[name] = setupRealtimeTestClient(
178
- __spreadProps(__spreadValues({}, options), { client }),
179
- name,
180
- server.port
181
- );
182
- return clientRecord;
183
- },
184
- {}
185
- );
186
- return {
187
- clients,
188
- server,
189
- teardown: () => {
190
- server.dispose();
191
- for (const [, client] of recordToEntries(clients)) {
192
- client.dispose();
193
- }
194
- }
195
- };
196
- };
197
-
198
- exports.multiClient = multiClient;
199
- exports.setupRealtimeTestClient = setupRealtimeTestClient;
200
- exports.setupRealtimeTestServer = setupRealtimeTestServer;
201
- exports.singleClient = singleClient;
@@ -1,215 +0,0 @@
1
- 'use strict';
2
-
3
- var internal = require('atom.io/internal');
4
- var json = require('atom.io/json');
5
-
6
- // transceivers/set-rtx/src/set-rtx.ts
7
- var SetRTX = class _SetRTX extends Set {
8
- constructor(values, cacheLimit = 0) {
9
- super(values);
10
- this.mode = `record`;
11
- this.subject = new internal.Subject();
12
- this.cacheLimit = 0;
13
- this.cache = [];
14
- this.cacheIdx = -1;
15
- this.cacheUpdateNumber = -1;
16
- this.child = null;
17
- this.transactionUpdates = null;
18
- if (values instanceof _SetRTX) {
19
- this.parent = values;
20
- this.cacheUpdateNumber = values.cacheUpdateNumber;
21
- }
22
- if (cacheLimit) {
23
- this.cacheLimit = cacheLimit;
24
- this.cache = new Array(cacheLimit);
25
- this.subscribe(`auto cache`, (update) => {
26
- this.cacheIdx++;
27
- this.cacheIdx %= this.cacheLimit;
28
- this.cache[this.cacheIdx] = update;
29
- });
30
- }
31
- }
32
- toJSON() {
33
- return {
34
- members: [...this],
35
- cache: this.cache,
36
- cacheLimit: this.cacheLimit,
37
- cacheIdx: this.cacheIdx,
38
- cacheUpdateNumber: this.cacheUpdateNumber
39
- };
40
- }
41
- static fromJSON(json) {
42
- const set = new _SetRTX(json.members, json.cacheLimit);
43
- set.cache = json.cache;
44
- set.cacheIdx = json.cacheIdx;
45
- set.cacheUpdateNumber = json.cacheUpdateNumber;
46
- return set;
47
- }
48
- add(value) {
49
- const result = super.add(value);
50
- if (this.mode === `record`) {
51
- this.cacheUpdateNumber++;
52
- this.emit(`add:${json.stringifyJson(value)}`);
53
- }
54
- return result;
55
- }
56
- clear() {
57
- const capturedContents = this.mode === `record` ? [...this] : null;
58
- super.clear();
59
- if (capturedContents) {
60
- this.cacheUpdateNumber++;
61
- this.emit(`clear:${JSON.stringify(capturedContents)}`);
62
- }
63
- }
64
- delete(value) {
65
- const result = super.delete(value);
66
- if (this.mode === `record`) {
67
- this.cacheUpdateNumber++;
68
- this.emit(`del:${json.stringifyJson(value)}`);
69
- }
70
- return result;
71
- }
72
- transaction(run) {
73
- this.mode = `transaction`;
74
- this.transactionUpdates = [];
75
- this.child = new _SetRTX(this);
76
- const unsubscribe = this.child._subscribe(`transaction`, (update) => {
77
- var _a;
78
- (_a = this.transactionUpdates) == null ? void 0 : _a.push(update);
79
- });
80
- try {
81
- const shouldCommit = run(this.child);
82
- if (shouldCommit) {
83
- for (const update of this.transactionUpdates) {
84
- this.doStep(update);
85
- }
86
- this.cacheUpdateNumber++;
87
- this.emit(`tx:${this.transactionUpdates.join(`;`)}`);
88
- }
89
- } catch (thrown) {
90
- console.error(`Failed to apply transaction to SetRTX:`, thrown);
91
- throw thrown;
92
- } finally {
93
- unsubscribe();
94
- this.child = null;
95
- this.transactionUpdates = null;
96
- this.mode = `record`;
97
- }
98
- }
99
- _subscribe(key, fn) {
100
- return this.subject.subscribe(key, fn);
101
- }
102
- subscribe(key, fn) {
103
- return this.subject.subscribe(key, (update) => {
104
- fn(`${this.cacheUpdateNumber}=${update}`);
105
- });
106
- }
107
- emit(update) {
108
- this.subject.next(update);
109
- }
110
- doStep(update) {
111
- const typeValueBreak = update.indexOf(`:`);
112
- const type = update.substring(0, typeValueBreak);
113
- const value = update.substring(typeValueBreak + 1);
114
- switch (type) {
115
- case `add`:
116
- this.add(json.parseJson(value));
117
- break;
118
- case `clear`:
119
- this.clear();
120
- break;
121
- case `del`:
122
- this.delete(json.parseJson(value));
123
- break;
124
- case `tx`:
125
- for (const subUpdate of value.split(`;`)) {
126
- this.doStep(subUpdate);
127
- }
128
- }
129
- }
130
- getUpdateNumber(update) {
131
- const breakpoint = update.indexOf(`=`);
132
- return Number(update.substring(0, breakpoint));
133
- }
134
- do(update) {
135
- const breakpoint = update.indexOf(`=`);
136
- const updateNumber = Number(update.substring(0, breakpoint));
137
- const eventOffset = updateNumber - this.cacheUpdateNumber;
138
- const isFuture = eventOffset > 0;
139
- if (isFuture) {
140
- if (eventOffset === 1) {
141
- this.mode = `playback`;
142
- const innerUpdate = update.substring(breakpoint + 1);
143
- this.doStep(innerUpdate);
144
- this.mode = `record`;
145
- this.cacheUpdateNumber = updateNumber;
146
- return null;
147
- }
148
- return this.cacheUpdateNumber + 1;
149
- }
150
- if (Math.abs(eventOffset) < this.cacheLimit) {
151
- const eventIdx = this.cacheIdx + eventOffset;
152
- const cachedUpdate = this.cache[eventIdx];
153
- if (cachedUpdate === update) {
154
- return null;
155
- }
156
- this.mode = `playback`;
157
- let done = false;
158
- while (!done) {
159
- this.cacheIdx %= this.cacheLimit;
160
- const u = this.cache[this.cacheIdx];
161
- this.cacheIdx--;
162
- if (!u) {
163
- return `OUT_OF_RANGE`;
164
- }
165
- this.undo(u);
166
- done = this.cacheIdx === eventIdx - 1;
167
- }
168
- const innerUpdate = update.substring(breakpoint + 1);
169
- this.doStep(innerUpdate);
170
- this.mode = `record`;
171
- this.cacheUpdateNumber = updateNumber;
172
- return null;
173
- }
174
- return `OUT_OF_RANGE`;
175
- }
176
- undoStep(update) {
177
- const breakpoint = update.indexOf(`:`);
178
- const type = update.substring(0, breakpoint);
179
- const value = update.substring(breakpoint + 1);
180
- switch (type) {
181
- case `add`:
182
- this.delete(json.parseJson(value));
183
- break;
184
- case `del`:
185
- this.add(json.parseJson(value));
186
- break;
187
- case `clear`: {
188
- const values = JSON.parse(value);
189
- for (const v of values) this.add(v);
190
- break;
191
- }
192
- case `tx`: {
193
- const updates = value.split(`;`);
194
- for (let i = updates.length - 1; i >= 0; i--) {
195
- this.undoStep(updates[i]);
196
- }
197
- }
198
- }
199
- }
200
- undo(update) {
201
- const breakpoint = update.indexOf(`=`);
202
- const updateNumber = Number(update.substring(0, breakpoint));
203
- if (updateNumber === this.cacheUpdateNumber) {
204
- this.mode = `playback`;
205
- const innerUpdate = update.substring(breakpoint + 1);
206
- this.undoStep(innerUpdate);
207
- this.mode = `record`;
208
- this.cacheUpdateNumber--;
209
- return null;
210
- }
211
- return this.cacheUpdateNumber;
212
- }
213
- };
214
-
215
- exports.SetRTX = SetRTX;