@valbuild/next 0.144.11 → 0.145.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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  require('server-only');
6
- var routeFromVal = require('../../dist/routeFromVal-e0995830.cjs.prod.js');
6
+ var routeFromVal = require('../../dist/routeFromVal-6fc9f240.cjs.prod.js');
7
7
  var defineProperty = require('../../dist/defineProperty-8951f469.cjs.prod.js');
8
8
  var objectSpread2 = require('../../dist/objectSpread2-13f847a9.cjs.prod.js');
9
9
  var asyncToGenerator = require('../../dist/asyncToGenerator-8e5c36c8.cjs.prod.js');
@@ -12,7 +12,7 @@ var core = require('@valbuild/core');
12
12
  var React = require('react');
13
13
  var internal = require('@valbuild/shared/internal');
14
14
  var server = require('@valbuild/server');
15
- var version = require('../../dist/version-4bc7cf5e.cjs.prod.js');
15
+ var version = require('../../dist/version-6f4b9d74.cjs.prod.js');
16
16
  require('../../dist/createForOfIteratorHelper-d4afcad8.cjs.prod.js');
17
17
  require('../../dist/unsupportedIterableToArray-0d2087a2.cjs.prod.js');
18
18
  require('../../dist/slicedToArray-ce613de6.cjs.prod.js');
@@ -99,16 +99,16 @@ function loadDraftSources(_x, _x2) {
99
99
  return _loadDraftSources.apply(this, arguments);
100
100
  }
101
101
  function _loadDraftSources() {
102
- _loadDraftSources = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee18(valServerPromise, sessionCookie) {
102
+ _loadDraftSources = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee19(valServerPromise, sessionCookie) {
103
103
  var valServer, treeRes;
104
- return asyncToGenerator._regenerator().w(function (_context18) {
105
- while (1) switch (_context18.n) {
104
+ return asyncToGenerator._regenerator().w(function (_context19) {
105
+ while (1) switch (_context19.n) {
106
106
  case 0:
107
- _context18.n = 1;
107
+ _context19.n = 1;
108
108
  return valServerPromise;
109
109
  case 1:
110
- valServer = _context18.v;
111
- _context18.n = 2;
110
+ valServer = _context19.v;
111
+ _context19.n = 2;
112
112
  return valServer["/sources/~"]["PUT"]({
113
113
  path: "/",
114
114
  query: {
@@ -136,25 +136,25 @@ function _loadDraftSources() {
136
136
  cookies: defineProperty._defineProperty({}, internal.VAL_SESSION_COOKIE, sessionCookie)
137
137
  });
138
138
  case 2:
139
- treeRes = _context18.v;
139
+ treeRes = _context19.v;
140
140
  if (!(treeRes.status === 200)) {
141
- _context18.n = 3;
141
+ _context19.n = 3;
142
142
  break;
143
143
  }
144
- return _context18.a(2, treeRes.json.modules);
144
+ return _context19.a(2, treeRes.json.modules);
145
145
  case 3:
146
146
  if (!(treeRes.status === 401)) {
147
- _context18.n = 4;
147
+ _context19.n = 4;
148
148
  break;
149
149
  }
150
150
  console.warn("Val: authentication error: ", treeRes.json.message);
151
- return _context18.a(2, null);
151
+ return _context19.a(2, null);
152
152
  case 4:
153
153
  throw Error(JSON.stringify(treeRes.json, null, 2));
154
154
  case 5:
155
- return _context18.a(2);
155
+ return _context19.a(2);
156
156
  }
157
- }, _callee18);
157
+ }, _callee19);
158
158
  }));
159
159
  return _loadDraftSources.apply(this, arguments);
160
160
  }
@@ -162,7 +162,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
162
162
  return function (selector) {
163
163
  var exec = /*#__PURE__*/function () {
164
164
  var _ref2 = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee2() {
165
- var enabled, headers, cookies, host, _cookies, sessionCookie, modules, _t, _t2, _t3, _t4;
165
+ var enabled, headers, cookies, host, _cookies, sessionCookie, modules, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1, _t10;
166
166
  return asyncToGenerator._regenerator().w(function (_context2) {
167
167
  while (1) switch (_context2.p = _context2.n) {
168
168
  case 0:
@@ -180,7 +180,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
180
180
  console.error("Val: could not check if Val is enabled! This might be due to an error to check draftMode. fetchVal can only be used server-side. Use useVal on clients.", _t);
181
181
  case 4:
182
182
  if (!enabled) {
183
- _context2.n = 15;
183
+ _context2.n = 16;
184
184
  break;
185
185
  }
186
186
  stega.SET_AUTO_TAG_JSX_ENABLED(true);
@@ -218,7 +218,7 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
218
218
  case 12:
219
219
  host = headers && getHost(headers);
220
220
  if (!(host && cookies)) {
221
- _context2.n = 15;
221
+ _context2.n = 16;
222
222
  break;
223
223
  }
224
224
  sessionCookie = (_cookies = cookies) === null || _cookies === void 0 || (_cookies = _cookies.get(internal.VAL_SESSION_COOKIE)) === null || _cookies === void 0 ? void 0 : _cookies.value;
@@ -245,21 +245,36 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
245
245
  case 14:
246
246
  modules = _context2.v;
247
247
  if (!modules) {
248
- _context2.n = 15;
248
+ _context2.n = 16;
249
249
  break;
250
250
  }
251
- return _context2.a(2, stega.stegaEncode(selector, {
252
- disabled: !enabled,
253
- getModule: function getModule(path) {
254
- var module = modules[path];
255
- if (module) {
256
- return module.source;
257
- }
258
- }
259
- }));
251
+ _t5 = stega.stegaEncode;
252
+ _t6 = selector;
253
+ _t7 = !enabled;
254
+ _context2.n = 15;
255
+ return withJsonValuesEntries(selector, function (path) {
256
+ var _modules$path;
257
+ return [(_modules$path = modules[path]) === null || _modules$path === void 0 ? void 0 : _modules$path.source];
258
+ });
260
259
  case 15:
261
- return _context2.a(2, stega.stegaEncode(selector, {
262
- disabled: !enabled
260
+ _t8 = _context2.v;
261
+ return _context2.a(2, _t5(_t6, {
262
+ disabled: _t7,
263
+ getModule: _t8
264
+ }));
265
+ case 16:
266
+ _t9 = stega.stegaEncode;
267
+ _t0 = selector;
268
+ _t1 = !enabled;
269
+ _context2.n = 17;
270
+ return withJsonValuesEntries(selector, function () {
271
+ return [];
272
+ });
273
+ case 17:
274
+ _t10 = _context2.v;
275
+ return _context2.a(2, _t9(_t0, {
276
+ disabled: _t1,
277
+ getModule: _t10
263
278
  }));
264
279
  }
265
280
  }, _callee2, null, [[9, 11], [5, 8], [1, 3]]);
@@ -268,12 +283,111 @@ var initFetchValStega = function initFetchValStega(config, valApiEndpoints, valS
268
283
  return _ref2.apply(this, arguments);
269
284
  };
270
285
  }();
271
- return exec()["catch"](function (err) {
272
- console.error("Val: failed to fetch ", err);
273
- return stega.stegaEncode(selector, {});
274
- });
286
+ return exec()["catch"](/*#__PURE__*/function () {
287
+ var _ref3 = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee3(err) {
288
+ var _t11, _t12, _t13;
289
+ return asyncToGenerator._regenerator().w(function (_context3) {
290
+ while (1) switch (_context3.n) {
291
+ case 0:
292
+ console.error("Val: failed to fetch ", err);
293
+ _t11 = stega.stegaEncode;
294
+ _t12 = selector;
295
+ _context3.n = 1;
296
+ return withJsonValuesEntries(selector, function () {
297
+ return [];
298
+ })["catch"](function () {
299
+ return function () {
300
+ return undefined;
301
+ };
302
+ });
303
+ case 1:
304
+ _t13 = _context3.v;
305
+ return _context3.a(2, _t11(_t12, {
306
+ getModule: _t13
307
+ }));
308
+ }
309
+ }, _callee3);
310
+ }));
311
+ return function (_x3) {
312
+ return _ref3.apply(this, arguments);
313
+ };
314
+ }());
275
315
  };
276
316
  };
317
+
318
+ /**
319
+ * `getModule` for `stegaEncode`, with a whole `.jsonValues()` record's entries
320
+ * filled in: its own source holds only lazy markers, so the entries the draft
321
+ * does not have are imported from the bundle, together. Every other module,
322
+ * and a selector that is not such a record, reads the first of `sourcesOf`
323
+ * that has it, as before. `fetchValKey` is the reader for one entry.
324
+ */
325
+ function withJsonValuesEntries(_x4, _x5) {
326
+ return _withJsonValuesEntries.apply(this, arguments);
327
+ }
328
+ function _withJsonValuesEntries() {
329
+ _withJsonValuesEntries = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee21(
330
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
331
+ selector, sourcesOf) {
332
+ var first, plan, loaded, filled, _t22;
333
+ return asyncToGenerator._regenerator().w(function (_context21) {
334
+ while (1) switch (_context21.n) {
335
+ case 0:
336
+ first = function first(path) {
337
+ return sourcesOf(path).find(function (source) {
338
+ return source !== undefined;
339
+ });
340
+ };
341
+ plan = routeFromVal.jsonValuesRecordToFill(selector, sourcesOf);
342
+ if (!(plan === null)) {
343
+ _context21.n = 1;
344
+ break;
345
+ }
346
+ return _context21.a(2, first);
347
+ case 1:
348
+ _t22 = Object;
349
+ _context21.n = 2;
350
+ return Promise.all(plan.load.map(/*#__PURE__*/function () {
351
+ var _ref16 = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee20(key) {
352
+ var thunk, _t19, _t20, _t21;
353
+ return asyncToGenerator._regenerator().w(function (_context20) {
354
+ while (1) switch (_context20.n) {
355
+ case 0:
356
+ thunk = routeFromVal.bundledJsonEntryImport(plan.module, key);
357
+ _t19 = key;
358
+ if (!thunk) {
359
+ _context20.n = 2;
360
+ break;
361
+ }
362
+ _context20.n = 1;
363
+ return thunk();
364
+ case 1:
365
+ _t20 = _context20.v["default"];
366
+ _context20.n = 3;
367
+ break;
368
+ case 2:
369
+ _t20 = undefined;
370
+ case 3:
371
+ _t21 = _t20;
372
+ return _context20.a(2, [_t19, _t21]);
373
+ }
374
+ }, _callee20);
375
+ }));
376
+ return function (_x18) {
377
+ return _ref16.apply(this, arguments);
378
+ };
379
+ }()));
380
+ case 2:
381
+ loaded = _t22.fromEntries.call(_t22, _context21.v);
382
+ filled = routeFromVal.fillJsonValuesRecord(plan.record, loaded);
383
+ return _context21.a(2, function (path) {
384
+ return path === plan.modulePath ? filled : first(path);
385
+ });
386
+ }
387
+ }, _callee21);
388
+ }));
389
+ return _withJsonValuesEntries.apply(this, arguments);
390
+ }
277
391
  function getHost(headers) {
278
392
  var _headers$get;
279
393
  // TODO: does NextJs have a way to determine this?
@@ -317,15 +431,15 @@ function getHost(headers) {
317
431
 
318
432
  var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope) {
319
433
  return /*#__PURE__*/function () {
320
- var _ref3 = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee3(selector, params) {
321
- var resolvedParams, valModule, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t6;
322
- return asyncToGenerator._regenerator().w(function (_context3) {
323
- while (1) switch (_context3.p = _context3.n) {
434
+ var _ref4 = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee4(selector, params) {
435
+ var resolvedParams, valModule, path, schema, source, url, enabled, draft, content, fetchVal, val, route, _t15;
436
+ return asyncToGenerator._regenerator().w(function (_context4) {
437
+ while (1) switch (_context4.p = _context4.n) {
324
438
  case 0:
325
- _context3.n = 1;
439
+ _context4.n = 1;
326
440
  return Promise.resolve(params);
327
441
  case 1:
328
- resolvedParams = _context3.v;
442
+ resolvedParams = _context4.v;
329
443
  // A view is a pointer: everything below reads a path, a schema and a source
330
444
  // off this, and a pointer has none of them. See `resolveViewedModule`.
331
445
  valModule = core.Internal.resolveViewedModule(selector);
@@ -334,78 +448,78 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
334
448
  // entry's backing `*.val.json`, instead of eagerly resolving the whole
335
449
  // record via `fetchVal`.
336
450
  if (!routeFromVal.isJsonValuesRecordSchema(schema)) {
337
- _context3.n = 11;
451
+ _context4.n = 11;
338
452
  break;
339
453
  }
340
454
  source = valModule && core.Internal.getSource(valModule);
341
455
  url = routeFromVal.getValRouteUrlFromVal(resolvedParams, "fetchValRoute", path, schema, source);
342
456
  if (url) {
343
- _context3.n = 2;
457
+ _context4.n = 2;
344
458
  break;
345
459
  }
346
- return _context3.a(2, null);
460
+ return _context4.a(2, null);
347
461
  case 2:
348
462
  enabled = false;
349
- _context3.p = 3;
350
- _context3.n = 4;
463
+ _context4.p = 3;
464
+ _context4.n = 4;
351
465
  return isEnabled();
352
466
  case 4:
353
- enabled = _context3.v;
354
- _context3.n = 6;
467
+ enabled = _context4.v;
468
+ _context4.n = 6;
355
469
  break;
356
470
  case 5:
357
- _context3.p = 5;
358
- _context3.v;
471
+ _context4.p = 5;
472
+ _context4.v;
359
473
  case 6:
360
474
  draft = {
361
475
  status: "unavailable"
362
476
  };
363
477
  if (!(enabled && path)) {
364
- _context3.n = 8;
478
+ _context4.n = 8;
365
479
  break;
366
480
  }
367
481
  stega.SET_AUTO_TAG_JSX_ENABLED(true);
368
- _context3.n = 7;
482
+ _context4.n = 7;
369
483
  return loadDraftJsonEntry(valServerPromise, getCookies, path, url);
370
484
  case 7:
371
- draft = _context3.v;
485
+ draft = _context4.v;
372
486
  case 8:
373
- _context3.n = 9;
487
+ _context4.n = 9;
374
488
  return resolveDraftOrCommittedEntry(draft, function () {
375
489
  return loadJsonEntryContent(source, url);
376
490
  });
377
491
  case 9:
378
- content = _context3.v;
492
+ content = _context4.v;
379
493
  if (!(content === undefined)) {
380
- _context3.n = 10;
494
+ _context4.n = 10;
381
495
  break;
382
496
  }
383
- return _context3.a(2, null);
497
+ return _context4.a(2, null);
384
498
  case 10:
385
- return _context3.a(2, stega.stegaEncode(content, {
499
+ return _context4.a(2, stega.stegaEncode(content, {
386
500
  disabled: !enabled,
387
501
  root: routeFromVal.getJsonEntryStegaRoot(valModule, url)
388
502
  }));
389
503
  case 11:
390
504
  fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope);
391
- _t6 = valModule;
392
- if (!_t6) {
393
- _context3.n = 13;
505
+ _t15 = valModule;
506
+ if (!_t15) {
507
+ _context4.n = 13;
394
508
  break;
395
509
  }
396
- _context3.n = 12;
510
+ _context4.n = 12;
397
511
  return fetchVal(valModule);
398
512
  case 12:
399
- _t6 = _context3.v;
513
+ _t15 = _context4.v;
400
514
  case 13:
401
- val = _t6;
515
+ val = _t15;
402
516
  route = routeFromVal.initValRouteFromVal(resolvedParams, "fetchValRoute", path, schema, val);
403
- return _context3.a(2, route);
517
+ return _context4.a(2, route);
404
518
  }
405
- }, _callee3, null, [[3, 5]]);
519
+ }, _callee4, null, [[3, 5]]);
406
520
  }));
407
- return function (_x3, _x4) {
408
- return _ref3.apply(this, arguments);
521
+ return function (_x6, _x7) {
522
+ return _ref4.apply(this, arguments);
409
523
  };
410
524
  }();
411
525
  };
@@ -415,7 +529,7 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
415
529
  * source markers (one dynamic import). Returns `undefined` when the key is
416
530
  * missing or its marker has no runtime thunk (transport marker / draft entry).
417
531
  */
418
- function loadJsonEntryContent(_x5, _x6) {
532
+ function loadJsonEntryContent(_x8, _x9) {
419
533
  return _loadJsonEntryContent.apply(this, arguments);
420
534
  }
421
535
  /**
@@ -440,37 +554,37 @@ function loadJsonEntryContent(_x5, _x6) {
440
554
  * to the whole server type.
441
555
  */
442
556
  function _loadJsonEntryContent() {
443
- _loadJsonEntryContent = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee19(source, key) {
557
+ _loadJsonEntryContent = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee22(source, key) {
444
558
  var marker, thunk;
445
- return asyncToGenerator._regenerator().w(function (_context19) {
446
- while (1) switch (_context19.n) {
559
+ return asyncToGenerator._regenerator().w(function (_context22) {
560
+ while (1) switch (_context22.n) {
447
561
  case 0:
448
562
  if (!(!source || routeFromVal._typeof(source) !== "object")) {
449
- _context19.n = 1;
563
+ _context22.n = 1;
450
564
  break;
451
565
  }
452
- return _context19.a(2, undefined);
566
+ return _context22.a(2, undefined);
453
567
  case 1:
454
568
  marker = source[key];
455
569
  if (core.Internal.isJson(marker)) {
456
- _context19.n = 2;
570
+ _context22.n = 2;
457
571
  break;
458
572
  }
459
- return _context19.a(2, undefined);
573
+ return _context22.a(2, undefined);
460
574
  case 2:
461
575
  thunk = core.Internal.getJsonImport(marker);
462
576
  if (thunk) {
463
- _context19.n = 3;
577
+ _context22.n = 3;
464
578
  break;
465
579
  }
466
- return _context19.a(2, undefined);
580
+ return _context22.a(2, undefined);
467
581
  case 3:
468
- _context19.n = 4;
582
+ _context22.n = 4;
469
583
  return thunk();
470
584
  case 4:
471
- return _context19.a(2, _context19.v["default"]);
585
+ return _context22.a(2, _context22.v["default"]);
472
586
  }
473
- }, _callee19);
587
+ }, _callee22);
474
588
  }));
475
589
  return _loadJsonEntryContent.apply(this, arguments);
476
590
  }
@@ -483,33 +597,33 @@ function _loadJsonEntryContent() {
483
597
  * ask). Returning `undefined` means "render nothing"; both callers turn that into
484
598
  * a null/undefined result.
485
599
  */
486
- function resolveDraftOrCommittedEntry(_x7, _x8) {
600
+ function resolveDraftOrCommittedEntry(_x0, _x1) {
487
601
  return _resolveDraftOrCommittedEntry.apply(this, arguments);
488
602
  }
489
603
  function _resolveDraftOrCommittedEntry() {
490
- _resolveDraftOrCommittedEntry = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee20(draft, loadCommitted) {
491
- return asyncToGenerator._regenerator().w(function (_context20) {
492
- while (1) switch (_context20.n) {
604
+ _resolveDraftOrCommittedEntry = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee23(draft, loadCommitted) {
605
+ return asyncToGenerator._regenerator().w(function (_context23) {
606
+ while (1) switch (_context23.n) {
493
607
  case 0:
494
608
  if (!(draft.status === "content")) {
495
- _context20.n = 1;
609
+ _context23.n = 1;
496
610
  break;
497
611
  }
498
- return _context20.a(2, draft.content);
612
+ return _context23.a(2, draft.content);
499
613
  case 1:
500
614
  if (!(draft.status === "absent")) {
501
- _context20.n = 2;
615
+ _context23.n = 2;
502
616
  break;
503
617
  }
504
- return _context20.a(2, undefined);
618
+ return _context23.a(2, undefined);
505
619
  case 2:
506
- return _context20.a(2, loadCommitted());
620
+ return _context23.a(2, loadCommitted());
507
621
  }
508
- }, _callee20);
622
+ }, _callee23);
509
623
  }));
510
624
  return _resolveDraftOrCommittedEntry.apply(this, arguments);
511
625
  }
512
- function loadDraftJsonEntry(_x9, _x0, _x1, _x10) {
626
+ function loadDraftJsonEntry(_x10, _x11, _x12, _x13) {
513
627
  return _loadDraftJsonEntry.apply(this, arguments);
514
628
  }
515
629
  /**
@@ -524,31 +638,31 @@ function loadDraftJsonEntry(_x9, _x0, _x1, _x10) {
524
638
  * the draft read yields nothing.
525
639
  */
526
640
  function _loadDraftJsonEntry() {
527
- _loadDraftJsonEntry = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee21(valServerPromise, getCookies, moduleFilePath, key) {
641
+ _loadDraftJsonEntry = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee24(valServerPromise, getCookies, moduleFilePath, key) {
528
642
  var _cookies3;
529
643
  var cookies, valServer, res;
530
- return asyncToGenerator._regenerator().w(function (_context21) {
531
- while (1) switch (_context21.p = _context21.n) {
644
+ return asyncToGenerator._regenerator().w(function (_context24) {
645
+ while (1) switch (_context24.p = _context24.n) {
532
646
  case 0:
533
- _context21.p = 0;
534
- _context21.n = 1;
647
+ _context24.p = 0;
648
+ _context24.n = 1;
535
649
  return getCookies();
536
650
  case 1:
537
- cookies = _context21.v;
538
- _context21.n = 3;
651
+ cookies = _context24.v;
652
+ _context24.n = 3;
539
653
  break;
540
654
  case 2:
541
- _context21.p = 2;
542
- _context21.v;
543
- return _context21.a(2, {
655
+ _context24.p = 2;
656
+ _context24.v;
657
+ return _context24.a(2, {
544
658
  status: "unavailable"
545
659
  });
546
660
  case 3:
547
- _context21.n = 4;
661
+ _context24.n = 4;
548
662
  return valServerPromise;
549
663
  case 4:
550
- valServer = _context21.v;
551
- _context21.n = 5;
664
+ valServer = _context24.v;
665
+ _context24.n = 5;
552
666
  return valServer["/json"]["GET"]({
553
667
  query: {
554
668
  path: moduleFilePath,
@@ -571,60 +685,60 @@ function _loadDraftJsonEntry() {
571
685
  cookies: defineProperty._defineProperty({}, internal.VAL_SESSION_COOKIE, (_cookies3 = cookies) === null || _cookies3 === void 0 || (_cookies3 = _cookies3.get(internal.VAL_SESSION_COOKIE)) === null || _cookies3 === void 0 ? void 0 : _cookies3.value)
572
686
  });
573
687
  case 5:
574
- res = _context21.v;
688
+ res = _context24.v;
575
689
  if (!(res.status === 200 && "content" in res.json)) {
576
- _context21.n = 6;
690
+ _context24.n = 6;
577
691
  break;
578
692
  }
579
- return _context21.a(2, {
693
+ return _context24.a(2, {
580
694
  status: "content",
581
695
  content: res.json.content
582
696
  });
583
697
  case 6:
584
698
  if (!(res.status === 401)) {
585
- _context21.n = 7;
699
+ _context24.n = 7;
586
700
  break;
587
701
  }
588
702
  console.warn("Val: authentication error: ", res.json.message);
589
- return _context21.a(2, {
703
+ return _context24.a(2, {
590
704
  status: "unavailable"
591
705
  });
592
706
  case 7:
593
707
  if (!(res.status === 404)) {
594
- _context21.n = 8;
708
+ _context24.n = 8;
595
709
  break;
596
710
  }
597
- return _context21.a(2, {
711
+ return _context24.a(2, {
598
712
  status: "absent"
599
713
  });
600
714
  case 8:
601
715
  console.error("Val: could not load draft JSON entry: ", "message" in res.json ? res.json.message : "status ".concat(res.status));
602
- return _context21.a(2, {
716
+ return _context24.a(2, {
603
717
  status: "unavailable"
604
718
  });
605
719
  }
606
- }, _callee21, null, [[0, 2]]);
720
+ }, _callee24, null, [[0, 2]]);
607
721
  }));
608
722
  return _loadDraftJsonEntry.apply(this, arguments);
609
723
  }
610
724
  var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEnabled, getCookies) {
611
725
  return /*#__PURE__*/function () {
612
- var _ref4 = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee4(selector, key) {
726
+ var _ref5 = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee5(selector, key) {
613
727
  var enabled, valModule, source, moduleFilePath, draft, content;
614
- return asyncToGenerator._regenerator().w(function (_context4) {
615
- while (1) switch (_context4.p = _context4.n) {
728
+ return asyncToGenerator._regenerator().w(function (_context5) {
729
+ while (1) switch (_context5.p = _context5.n) {
616
730
  case 0:
617
731
  enabled = false;
618
- _context4.p = 1;
619
- _context4.n = 2;
732
+ _context5.p = 1;
733
+ _context5.n = 2;
620
734
  return isEnabled();
621
735
  case 2:
622
- enabled = _context4.v;
623
- _context4.n = 4;
736
+ enabled = _context5.v;
737
+ _context5.n = 4;
624
738
  break;
625
739
  case 3:
626
- _context4.p = 3;
627
- _context4.v;
740
+ _context5.p = 3;
741
+ _context5.v;
628
742
  case 4:
629
743
  // A view is a pointer: everything below reads a path and a source off this,
630
744
  // and a pointer has neither. See `resolveViewedModule`.
@@ -635,84 +749,84 @@ var initFetchValKeyStega = function initFetchValKeyStega(valServerPromise, isEna
635
749
  status: "unavailable"
636
750
  };
637
751
  if (!(enabled && moduleFilePath)) {
638
- _context4.n = 6;
752
+ _context5.n = 6;
639
753
  break;
640
754
  }
641
755
  stega.SET_AUTO_TAG_JSX_ENABLED(true);
642
- _context4.n = 5;
756
+ _context5.n = 5;
643
757
  return loadDraftJsonEntry(valServerPromise, getCookies, moduleFilePath, key);
644
758
  case 5:
645
- draft = _context4.v;
759
+ draft = _context5.v;
646
760
  case 6:
647
- _context4.n = 7;
761
+ _context5.n = 7;
648
762
  return resolveDraftOrCommittedEntry(draft, function () {
649
763
  return loadJsonEntryContent(source, key);
650
764
  });
651
765
  case 7:
652
- content = _context4.v;
766
+ content = _context5.v;
653
767
  if (!(content === undefined)) {
654
- _context4.n = 8;
768
+ _context5.n = 8;
655
769
  break;
656
770
  }
657
- return _context4.a(2, undefined);
771
+ return _context5.a(2, undefined);
658
772
  case 8:
659
- return _context4.a(2, stega.stegaEncode(content, {
773
+ return _context5.a(2, stega.stegaEncode(content, {
660
774
  disabled: !enabled,
661
775
  root: routeFromVal.getJsonEntryStegaRoot(valModule, key)
662
776
  }));
663
777
  }
664
- }, _callee4, null, [[1, 3]]);
778
+ }, _callee5, null, [[1, 3]]);
665
779
  }));
666
- return function (_x11, _x12) {
667
- return _ref4.apply(this, arguments);
780
+ return function (_x14, _x15) {
781
+ return _ref5.apply(this, arguments);
668
782
  };
669
783
  }();
670
784
  };
671
785
  var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope) {
672
786
  return /*#__PURE__*/function () {
673
- var _ref5 = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee5(selector, params) {
674
- var fetchVal, resolvedParams, valModule, path, schema, val, route, _t8, _t9;
675
- return asyncToGenerator._regenerator().w(function (_context5) {
676
- while (1) switch (_context5.n) {
787
+ var _ref6 = asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee6(selector, params) {
788
+ var fetchVal, resolvedParams, valModule, path, schema, val, route, _t17, _t18;
789
+ return asyncToGenerator._regenerator().w(function (_context6) {
790
+ while (1) switch (_context6.n) {
677
791
  case 0:
678
792
  fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies, getDraftSourcesScope);
679
793
  if (!(params === undefined)) {
680
- _context5.n = 1;
794
+ _context6.n = 1;
681
795
  break;
682
796
  }
683
- _t8 = undefined;
684
- _context5.n = 3;
797
+ _t17 = undefined;
798
+ _context6.n = 3;
685
799
  break;
686
800
  case 1:
687
- _context5.n = 2;
801
+ _context6.n = 2;
688
802
  return Promise.resolve(params);
689
803
  case 2:
690
- _t8 = _context5.v;
804
+ _t17 = _context6.v;
691
805
  case 3:
692
- resolvedParams = _t8;
806
+ resolvedParams = _t17;
693
807
  // A view is a pointer: everything below reads a path, a schema and a source
694
808
  // off this, and a pointer has none of them. See `resolveViewedModule`.
695
809
  valModule = core.Internal.resolveViewedModule(selector);
696
810
  path = valModule && core.Internal.getValPath(valModule);
697
811
  schema = valModule && core.Internal.getSchema(valModule);
698
- _t9 = valModule;
699
- if (!_t9) {
700
- _context5.n = 5;
812
+ _t18 = valModule;
813
+ if (!_t18) {
814
+ _context6.n = 5;
701
815
  break;
702
816
  }
703
- _context5.n = 4;
817
+ _context6.n = 4;
704
818
  return fetchVal(valModule);
705
819
  case 4:
706
- _t9 = _context5.v;
820
+ _t18 = _context6.v;
707
821
  case 5:
708
- val = _t9;
822
+ val = _t18;
709
823
  route = routeFromVal.getValRouteUrlFromVal(resolvedParams, "fetchValRouteUrl", path, schema, val);
710
- return _context5.a(2, route);
824
+ return _context6.a(2, route);
711
825
  }
712
- }, _callee5);
826
+ }, _callee6);
713
827
  }));
714
- return function (_x13, _x14) {
715
- return _ref5.apply(this, arguments);
828
+ return function (_x16, _x17) {
829
+ return _ref6.apply(this, arguments);
716
830
  };
717
831
  }();
718
832
  };
@@ -734,19 +848,6 @@ function initValRsc(config, valModules, rscNextConfig) {
734
848
  }
735
849
  }, config), config, {
736
850
  isEnabled: function isEnabled() {
737
- return asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee6() {
738
- return asyncToGenerator._regenerator().w(function (_context6) {
739
- while (1) switch (_context6.n) {
740
- case 0:
741
- _context6.n = 1;
742
- return rscNextConfig.draftMode();
743
- case 1:
744
- return _context6.a(2, _context6.v.isEnabled);
745
- }
746
- }, _callee6);
747
- }))();
748
- },
749
- onEnable: function onEnable() {
750
851
  return asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee7() {
751
852
  return asyncToGenerator._regenerator().w(function (_context7) {
752
853
  while (1) switch (_context7.n) {
@@ -754,14 +855,12 @@ function initValRsc(config, valModules, rscNextConfig) {
754
855
  _context7.n = 1;
755
856
  return rscNextConfig.draftMode();
756
857
  case 1:
757
- _context7.v.enable();
758
- case 2:
759
- return _context7.a(2);
858
+ return _context7.a(2, _context7.v.isEnabled);
760
859
  }
761
860
  }, _callee7);
762
861
  }))();
763
862
  },
764
- onDisable: function onDisable() {
863
+ onEnable: function onEnable() {
765
864
  return asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee8() {
766
865
  return asyncToGenerator._regenerator().w(function (_context8) {
767
866
  while (1) switch (_context8.n) {
@@ -769,35 +868,40 @@ function initValRsc(config, valModules, rscNextConfig) {
769
868
  _context8.n = 1;
770
869
  return rscNextConfig.draftMode();
771
870
  case 1:
772
- _context8.v.disable();
871
+ _context8.v.enable();
773
872
  case 2:
774
873
  return _context8.a(2);
775
874
  }
776
875
  }, _callee8);
777
876
  }))();
877
+ },
878
+ onDisable: function onDisable() {
879
+ return asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee9() {
880
+ return asyncToGenerator._regenerator().w(function (_context9) {
881
+ while (1) switch (_context9.n) {
882
+ case 0:
883
+ _context9.n = 1;
884
+ return rscNextConfig.draftMode();
885
+ case 1:
886
+ _context9.v.disable();
887
+ case 2:
888
+ return _context9.a(2);
889
+ }
890
+ }, _callee9);
891
+ }))();
778
892
  }
779
893
  });
780
894
  return {
781
895
  fetchValStega: initFetchValStega(config, valApiEndpoints,
782
896
  // TODO: get from config
783
- valServerPromise, /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee9() {
784
- return asyncToGenerator._regenerator().w(function (_context9) {
785
- while (1) switch (_context9.n) {
786
- case 0:
787
- _context9.n = 1;
788
- return rscNextConfig.draftMode();
789
- case 1:
790
- return _context9.a(2, _context9.v.isEnabled);
791
- }
792
- }, _callee9);
793
- })), /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee0() {
897
+ valServerPromise, /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee0() {
794
898
  return asyncToGenerator._regenerator().w(function (_context0) {
795
899
  while (1) switch (_context0.n) {
796
900
  case 0:
797
901
  _context0.n = 1;
798
- return rscNextConfig.headers();
902
+ return rscNextConfig.draftMode();
799
903
  case 1:
800
- return _context0.a(2, _context0.v);
904
+ return _context0.a(2, _context0.v.isEnabled);
801
905
  }
802
906
  }, _callee0);
803
907
  })), /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee1() {
@@ -805,51 +909,51 @@ function initValRsc(config, valModules, rscNextConfig) {
805
909
  while (1) switch (_context1.n) {
806
910
  case 0:
807
911
  _context1.n = 1;
808
- return rscNextConfig.cookies();
912
+ return rscNextConfig.headers();
809
913
  case 1:
810
914
  return _context1.a(2, _context1.v);
811
915
  }
812
916
  }, _callee1);
813
- })), draftSourcesScope),
814
- fetchValKeyStega: initFetchValKeyStega(valServerPromise, /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee10() {
917
+ })), /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee10() {
815
918
  return asyncToGenerator._regenerator().w(function (_context10) {
816
919
  while (1) switch (_context10.n) {
817
920
  case 0:
818
921
  _context10.n = 1;
819
- return rscNextConfig.draftMode();
922
+ return rscNextConfig.cookies();
820
923
  case 1:
821
- return _context10.a(2, _context10.v.isEnabled);
924
+ return _context10.a(2, _context10.v);
822
925
  }
823
926
  }, _callee10);
824
- })), /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee11() {
927
+ })), draftSourcesScope),
928
+ fetchValKeyStega: initFetchValKeyStega(valServerPromise, /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee11() {
825
929
  return asyncToGenerator._regenerator().w(function (_context11) {
826
930
  while (1) switch (_context11.n) {
827
931
  case 0:
828
932
  _context11.n = 1;
829
- return rscNextConfig.cookies();
933
+ return rscNextConfig.draftMode();
830
934
  case 1:
831
- return _context11.a(2, _context11.v);
935
+ return _context11.a(2, _context11.v.isEnabled);
832
936
  }
833
937
  }, _callee11);
834
- }))),
835
- fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee12() {
938
+ })), /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee12() {
836
939
  return asyncToGenerator._regenerator().w(function (_context12) {
837
940
  while (1) switch (_context12.n) {
838
941
  case 0:
839
942
  _context12.n = 1;
840
- return rscNextConfig.draftMode();
943
+ return rscNextConfig.cookies();
841
944
  case 1:
842
- return _context12.a(2, _context12.v.isEnabled);
945
+ return _context12.a(2, _context12.v);
843
946
  }
844
947
  }, _callee12);
845
- })), /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee13() {
948
+ }))),
949
+ fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee13() {
846
950
  return asyncToGenerator._regenerator().w(function (_context13) {
847
951
  while (1) switch (_context13.n) {
848
952
  case 0:
849
953
  _context13.n = 1;
850
- return rscNextConfig.headers();
954
+ return rscNextConfig.draftMode();
851
955
  case 1:
852
- return _context13.a(2, _context13.v);
956
+ return _context13.a(2, _context13.v.isEnabled);
853
957
  }
854
958
  }, _callee13);
855
959
  })), /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee14() {
@@ -857,30 +961,30 @@ function initValRsc(config, valModules, rscNextConfig) {
857
961
  while (1) switch (_context14.n) {
858
962
  case 0:
859
963
  _context14.n = 1;
860
- return rscNextConfig.cookies();
964
+ return rscNextConfig.headers();
861
965
  case 1:
862
966
  return _context14.a(2, _context14.v);
863
967
  }
864
968
  }, _callee14);
865
- })), draftSourcesScope),
866
- fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee15() {
969
+ })), /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee15() {
867
970
  return asyncToGenerator._regenerator().w(function (_context15) {
868
971
  while (1) switch (_context15.n) {
869
972
  case 0:
870
973
  _context15.n = 1;
871
- return rscNextConfig.draftMode();
974
+ return rscNextConfig.cookies();
872
975
  case 1:
873
- return _context15.a(2, _context15.v.isEnabled);
976
+ return _context15.a(2, _context15.v);
874
977
  }
875
978
  }, _callee15);
876
- })), /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee16() {
979
+ })), draftSourcesScope),
980
+ fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee16() {
877
981
  return asyncToGenerator._regenerator().w(function (_context16) {
878
982
  while (1) switch (_context16.n) {
879
983
  case 0:
880
984
  _context16.n = 1;
881
- return rscNextConfig.headers();
985
+ return rscNextConfig.draftMode();
882
986
  case 1:
883
- return _context16.a(2, _context16.v);
987
+ return _context16.a(2, _context16.v.isEnabled);
884
988
  }
885
989
  }, _callee16);
886
990
  })), /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee17() {
@@ -888,11 +992,21 @@ function initValRsc(config, valModules, rscNextConfig) {
888
992
  while (1) switch (_context17.n) {
889
993
  case 0:
890
994
  _context17.n = 1;
891
- return rscNextConfig.cookies();
995
+ return rscNextConfig.headers();
892
996
  case 1:
893
997
  return _context17.a(2, _context17.v);
894
998
  }
895
999
  }, _callee17);
1000
+ })), /*#__PURE__*/asyncToGenerator._asyncToGenerator(/*#__PURE__*/asyncToGenerator._regenerator().m(function _callee18() {
1001
+ return asyncToGenerator._regenerator().w(function (_context18) {
1002
+ while (1) switch (_context18.n) {
1003
+ case 0:
1004
+ _context18.n = 1;
1005
+ return rscNextConfig.cookies();
1006
+ case 1:
1007
+ return _context18.a(2, _context18.v);
1008
+ }
1009
+ }, _callee18);
896
1010
  })), draftSourcesScope)
897
1011
  };
898
1012
  }