@graffy/core 0.15.6-alpha.1 → 0.15.8-alpha.2

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 (2) hide show
  1. package/cjs/Graffy.js +65 -62
  2. package/package.json +4 -4
package/cjs/Graffy.js CHANGED
@@ -40,50 +40,53 @@ var Graffy = /*#__PURE__*/function () {
40
40
  var _proto = Graffy.prototype;
41
41
 
42
42
  _proto.on = function on(type) {
43
+ var _context;
44
+
43
45
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
44
46
  args[_key - 1] = arguments[_key];
45
47
  }
46
48
 
47
49
  var _validateOn = _validate.validateOn.apply(void 0, args),
48
- path = _validateOn[0],
50
+ pathArg = _validateOn[0],
49
51
  handler = _validateOn[1];
50
52
 
53
+ var path = (0, _concat.default)(_context = this.path).call(_context, pathArg);
51
54
  this.core.on(type, path, handler);
52
55
  };
53
56
 
54
57
  _proto.onRead = function onRead() {
55
- var _context;
58
+ var _context2;
56
59
 
57
60
  var _validateOn2 = _validate.validateOn.apply(void 0, arguments),
58
61
  pathArg = _validateOn2[0],
59
62
  handle = _validateOn2[1];
60
63
 
61
- var path = (0, _concat.default)(_context = this.path).call(_context, pathArg);
64
+ var path = (0, _concat.default)(_context2 = this.path).call(_context2, pathArg);
62
65
  this.core.on('read', path, (0, _shift.shiftFn)( /*#__PURE__*/function () {
63
66
  var _porcelainRead = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(query, options) {
64
67
  var decoded, encoded, finalized;
65
- return _regenerator.default.wrap(function _callee$(_context2) {
68
+ return _regenerator.default.wrap(function _callee$(_context3) {
66
69
  while (1) {
67
- switch (_context2.prev = _context2.next) {
70
+ switch (_context3.prev = _context3.next) {
68
71
  case 0:
69
72
  // console.log('onRead', path, query);
70
73
  decoded = (0, _common.decodeQuery)(query); // console.log('decoded', path, decoded);
71
74
 
72
- _context2.t0 = _common.encodeGraph;
73
- _context2.next = 4;
75
+ _context3.t0 = _common.encodeGraph;
76
+ _context3.next = 4;
74
77
  return handle(decoded, options);
75
78
 
76
79
  case 4:
77
- _context2.t1 = _context2.sent;
78
- encoded = (0, _context2.t0)(_context2.t1);
80
+ _context3.t1 = _context3.sent;
81
+ encoded = (0, _context3.t0)(_context3.t1);
79
82
  // console.log({ encoded });
80
83
  finalized = (0, _common.finalize)(encoded, query); // console.log({ finalized });
81
84
 
82
- return _context2.abrupt("return", finalized);
85
+ return _context3.abrupt("return", finalized);
83
86
 
84
87
  case 8:
85
88
  case "end":
86
- return _context2.stop();
89
+ return _context3.stop();
87
90
  }
88
91
  }
89
92
  }, _callee);
@@ -98,42 +101,42 @@ var Graffy = /*#__PURE__*/function () {
98
101
  };
99
102
 
100
103
  _proto.onWatch = function onWatch() {
101
- var _context3;
104
+ var _context4;
102
105
 
103
106
  var _validateOn3 = _validate.validateOn.apply(void 0, arguments),
104
107
  pathArg = _validateOn3[0],
105
108
  handle = _validateOn3[1];
106
109
 
107
- var path = (0, _concat.default)(_context3 = this.path).call(_context3, pathArg);
110
+ var path = (0, _concat.default)(_context4 = this.path).call(_context4, pathArg);
108
111
  this.core.on('watch', path, (0, _shift.shiftGen)(function porcelainWatch(query, options) {
109
112
  return (0, _stream.makeStream)(function (push, end) {
110
113
  var subscription = handle((0, _common.decodeQuery)(query), options);
111
114
  (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
112
115
  var firstValue, _iteratorAbruptCompletion, _didIteratorError, _iteratorError, _iterator, _step, value;
113
116
 
114
- return _regenerator.default.wrap(function _callee2$(_context4) {
117
+ return _regenerator.default.wrap(function _callee2$(_context5) {
115
118
  while (1) {
116
- switch (_context4.prev = _context4.next) {
119
+ switch (_context5.prev = _context5.next) {
117
120
  case 0:
118
- _context4.prev = 0;
119
- _context4.next = 3;
121
+ _context5.prev = 0;
122
+ _context5.next = 3;
120
123
  return subscription.next();
121
124
 
122
125
  case 3:
123
- firstValue = _context4.sent.value;
126
+ firstValue = _context5.sent.value;
124
127
  push(firstValue && (0, _common.finalize)((0, _common.encodeGraph)(firstValue), query));
125
128
  _iteratorAbruptCompletion = false;
126
129
  _didIteratorError = false;
127
- _context4.prev = 7;
130
+ _context5.prev = 7;
128
131
  _iterator = (0, _asyncIterator2.default)(subscription);
129
132
 
130
133
  case 9:
131
- _context4.next = 11;
134
+ _context5.next = 11;
132
135
  return _iterator.next();
133
136
 
134
137
  case 11:
135
- if (!(_iteratorAbruptCompletion = !(_step = _context4.sent).done)) {
136
- _context4.next = 17;
138
+ if (!(_iteratorAbruptCompletion = !(_step = _context5.sent).done)) {
139
+ _context5.next = 17;
137
140
  break;
138
141
  }
139
142
 
@@ -142,59 +145,59 @@ var Graffy = /*#__PURE__*/function () {
142
145
 
143
146
  case 14:
144
147
  _iteratorAbruptCompletion = false;
145
- _context4.next = 9;
148
+ _context5.next = 9;
146
149
  break;
147
150
 
148
151
  case 17:
149
- _context4.next = 23;
152
+ _context5.next = 23;
150
153
  break;
151
154
 
152
155
  case 19:
153
- _context4.prev = 19;
154
- _context4.t0 = _context4["catch"](7);
156
+ _context5.prev = 19;
157
+ _context5.t0 = _context5["catch"](7);
155
158
  _didIteratorError = true;
156
- _iteratorError = _context4.t0;
159
+ _iteratorError = _context5.t0;
157
160
 
158
161
  case 23:
159
- _context4.prev = 23;
160
- _context4.prev = 24;
162
+ _context5.prev = 23;
163
+ _context5.prev = 24;
161
164
 
162
165
  if (!(_iteratorAbruptCompletion && _iterator.return != null)) {
163
- _context4.next = 28;
166
+ _context5.next = 28;
164
167
  break;
165
168
  }
166
169
 
167
- _context4.next = 28;
170
+ _context5.next = 28;
168
171
  return _iterator.return();
169
172
 
170
173
  case 28:
171
- _context4.prev = 28;
174
+ _context5.prev = 28;
172
175
 
173
176
  if (!_didIteratorError) {
174
- _context4.next = 31;
177
+ _context5.next = 31;
175
178
  break;
176
179
  }
177
180
 
178
181
  throw _iteratorError;
179
182
 
180
183
  case 31:
181
- return _context4.finish(28);
184
+ return _context5.finish(28);
182
185
 
183
186
  case 32:
184
- return _context4.finish(23);
187
+ return _context5.finish(23);
185
188
 
186
189
  case 33:
187
- _context4.next = 38;
190
+ _context5.next = 38;
188
191
  break;
189
192
 
190
193
  case 35:
191
- _context4.prev = 35;
192
- _context4.t1 = _context4["catch"](0);
193
- end(_context4.t1);
194
+ _context5.prev = 35;
195
+ _context5.t1 = _context5["catch"](0);
196
+ end(_context5.t1);
194
197
 
195
198
  case 38:
196
199
  case "end":
197
- return _context4.stop();
200
+ return _context5.stop();
198
201
  }
199
202
  }
200
203
  }, _callee2, null, [[0, 35], [7, 19, 23, 33], [24,, 28, 32]]);
@@ -207,30 +210,30 @@ var Graffy = /*#__PURE__*/function () {
207
210
  };
208
211
 
209
212
  _proto.onWrite = function onWrite() {
210
- var _context5;
213
+ var _context6;
211
214
 
212
215
  var _validateOn4 = _validate.validateOn.apply(void 0, arguments),
213
216
  pathArg = _validateOn4[0],
214
217
  handle = _validateOn4[1];
215
218
 
216
- var path = (0, _concat.default)(_context5 = this.path).call(_context5, pathArg);
219
+ var path = (0, _concat.default)(_context6 = this.path).call(_context6, pathArg);
217
220
  this.core.on('write', path, (0, _shift.shiftFn)( /*#__PURE__*/function () {
218
221
  var _porcelainWrite = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(change, options) {
219
- return _regenerator.default.wrap(function _callee3$(_context6) {
222
+ return _regenerator.default.wrap(function _callee3$(_context7) {
220
223
  while (1) {
221
- switch (_context6.prev = _context6.next) {
224
+ switch (_context7.prev = _context7.next) {
222
225
  case 0:
223
- _context6.t0 = _common.encodeGraph;
224
- _context6.next = 3;
226
+ _context7.t0 = _common.encodeGraph;
227
+ _context7.next = 3;
225
228
  return handle((0, _common.decodeGraph)(change), options);
226
229
 
227
230
  case 3:
228
- _context6.t1 = _context6.sent;
229
- return _context6.abrupt("return", (0, _context6.t0)(_context6.t1));
231
+ _context7.t1 = _context7.sent;
232
+ return _context7.abrupt("return", (0, _context7.t0)(_context7.t1));
230
233
 
231
234
  case 5:
232
235
  case "end":
233
- return _context6.stop();
236
+ return _context7.stop();
234
237
  }
235
238
  }
236
239
  }, _callee3);
@@ -271,23 +274,23 @@ var Graffy = /*#__PURE__*/function () {
271
274
  result,
272
275
  _args4 = arguments;
273
276
 
274
- return _regenerator.default.wrap(function _callee4$(_context7) {
277
+ return _regenerator.default.wrap(function _callee4$(_context8) {
275
278
  while (1) {
276
- switch (_context7.prev = _context7.next) {
279
+ switch (_context8.prev = _context8.next) {
277
280
  case 0:
278
281
  _validateCall = _validate.validateCall.apply(void 0, _args4), path = _validateCall[0], porcelainQuery = _validateCall[1], options = _validateCall[2];
279
282
  rootQuery = (0, _common.wrapObject)(porcelainQuery, path);
280
283
  query = (0, _common.encodeQuery)(rootQuery);
281
- _context7.next = 5;
284
+ _context8.next = 5;
282
285
  return this.core.call('read', query, options || {});
283
286
 
284
287
  case 5:
285
- result = _context7.sent;
286
- return _context7.abrupt("return", (0, _common.unwrapObject)((0, _common.decorate)(result, rootQuery), path));
288
+ result = _context8.sent;
289
+ return _context8.abrupt("return", (0, _common.unwrapObject)((0, _common.decorate)(result, rootQuery), (0, _common.decodePath)(path)));
287
290
 
288
291
  case 7:
289
292
  case "end":
290
- return _context7.stop();
293
+ return _context8.stop();
291
294
  }
292
295
  }
293
296
  }, _callee4, this);
@@ -310,7 +313,7 @@ var Graffy = /*#__PURE__*/function () {
310
313
  var query = (0, _common.encodeQuery)(rootQuery);
311
314
  var stream = this.core.call('watch', query, options || {});
312
315
  return (0, _stream.mapStream)(stream, function (value) {
313
- return (0, _common.unwrapObject)((0, _common.decorate)(value, rootQuery), path);
316
+ return (0, _common.unwrapObject)((0, _common.decorate)(value, rootQuery), (0, _common.decodePath)(path));
314
317
  });
315
318
  };
316
319
 
@@ -324,22 +327,22 @@ var Graffy = /*#__PURE__*/function () {
324
327
  writtenChange,
325
328
  _args5 = arguments;
326
329
 
327
- return _regenerator.default.wrap(function _callee5$(_context8) {
330
+ return _regenerator.default.wrap(function _callee5$(_context9) {
328
331
  while (1) {
329
- switch (_context8.prev = _context8.next) {
332
+ switch (_context9.prev = _context9.next) {
330
333
  case 0:
331
334
  _validateCall3 = _validate.validateCall.apply(void 0, _args5), path = _validateCall3[0], porcelainChange = _validateCall3[1], options = _validateCall3[2];
332
335
  change = (0, _common.wrap)((0, _common.encodeGraph)(porcelainChange), path);
333
- _context8.next = 4;
336
+ _context9.next = 4;
334
337
  return this.core.call('write', change, options || {});
335
338
 
336
339
  case 4:
337
- writtenChange = _context8.sent;
338
- return _context8.abrupt("return", (0, _common.unwrapObject)((0, _common.decodeGraph)(writtenChange), path));
340
+ writtenChange = _context9.sent;
341
+ return _context9.abrupt("return", (0, _common.unwrapObject)((0, _common.decodeGraph)(writtenChange), (0, _common.decodePath)(path)));
339
342
 
340
343
  case 6:
341
344
  case "end":
342
- return _context8.stop();
345
+ return _context9.stop();
343
346
  }
344
347
  }
345
348
  }, _callee5, this);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graffy/core",
3
3
  "description": "The main module for Graffy, a library for intuitive real-time data APIs.",
4
4
  "author": "aravind (https://github.com/aravindet)",
5
- "version": "0.15.6-alpha.1",
5
+ "version": "0.15.8-alpha.2",
6
6
  "main": "./cjs/index.js",
7
7
  "types": "./types/index.d.ts",
8
8
  "repository": {
@@ -12,9 +12,9 @@
12
12
  "license": "Apache-2.0",
13
13
  "dependencies": {
14
14
  "@babel/runtime-corejs3": "^7.15.3",
15
- "@graffy/common": "0.15.6-alpha.1",
15
+ "@graffy/common": "0.15.8-alpha.2",
16
16
  "debug": "^4.3.2",
17
- "@graffy/testing": "0.15.6-alpha.1",
18
- "@graffy/stream": "0.15.6-alpha.1"
17
+ "@graffy/testing": "0.15.8-alpha.2",
18
+ "@graffy/stream": "0.15.8-alpha.2"
19
19
  }
20
20
  }