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