@valbuild/next 0.85.0 → 0.86.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.
- package/README.md +86 -4
- package/client/dist/valbuild-next-client.cjs.dev.js +27 -5
- package/client/dist/valbuild-next-client.cjs.prod.js +27 -5
- package/client/dist/valbuild-next-client.esm.js +26 -4
- package/dist/ValApp-0ded607c.cjs.dev.js +133 -0
- package/dist/ValApp-489d97dc.esm.js +125 -0
- package/dist/ValApp-b10c2084.cjs.js +7 -0
- package/dist/ValApp-b10c2084.cjs.prod.js +133 -0
- package/dist/{ValNextProvider-25f1f5c9.esm.js → ValNextProvider-10c232b6.esm.js} +80 -44
- package/dist/ValNextProvider-7042b86d.cjs.js +7 -0
- package/dist/{ValNextProvider-a618d775.cjs.prod.js → ValNextProvider-7042b86d.cjs.prod.js} +80 -44
- package/dist/{ValNextProvider-c7952bdc.cjs.dev.js → ValNextProvider-726026f9.cjs.dev.js} +80 -44
- package/dist/cssUtils-9c11102f.cjs.dev.js +41 -0
- package/dist/cssUtils-b5651c03.esm.js +32 -0
- package/dist/cssUtils-d97a757c.cjs.prod.js +41 -0
- package/dist/declarations/src/ValApp.d.ts +1 -1
- package/dist/declarations/src/client/initValClient.d.ts +2 -0
- package/dist/declarations/src/rsc/initValRsc.d.ts +9 -0
- package/dist/{initValRouteFromVal-4e6253bf.esm.js → routeFromVal-248c62f1.esm.js} +17 -4
- package/dist/{initValRouteFromVal-0f4f2d39.cjs.prod.js → routeFromVal-a317debc.cjs.prod.js} +17 -3
- package/dist/{initValRouteFromVal-65dd1262.cjs.dev.js → routeFromVal-a3987ae3.cjs.dev.js} +17 -3
- package/dist/valbuild-next.cjs.dev.js +2 -2
- package/dist/valbuild-next.cjs.prod.js +2 -2
- package/dist/valbuild-next.esm.js +2 -2
- package/package.json +6 -6
- package/rsc/dist/valbuild-next-rsc.cjs.dev.js +134 -46
- package/rsc/dist/valbuild-next-rsc.cjs.prod.js +134 -46
- package/rsc/dist/valbuild-next-rsc.esm.js +133 -45
- package/dist/ValApp-0efa0e5d.cjs.dev.js +0 -63
- package/dist/ValApp-3ab62a2b.esm.js +0 -55
- package/dist/ValApp-a808cf89.cjs.js +0 -7
- package/dist/ValApp-a808cf89.cjs.prod.js +0 -63
- package/dist/ValNextProvider-a618d775.cjs.js +0 -7
- package/dist/useRemoteConfigSender-02451801.esm.js +0 -70
- package/dist/useRemoteConfigSender-3ea2fe91.cjs.prod.js +0 -76
- package/dist/useRemoteConfigSender-c78b81c5.cjs.dev.js +0 -76
|
@@ -6,7 +6,7 @@ import { Internal } from '@valbuild/core';
|
|
|
6
6
|
import { VAL_SESSION_COOKIE } from '@valbuild/shared/internal';
|
|
7
7
|
import { createValServer } from '@valbuild/server';
|
|
8
8
|
import { V as VERSION } from '../../dist/version-98ec5c7a.esm.js';
|
|
9
|
-
import { i as initValRouteFromVal } from '../../dist/
|
|
9
|
+
import { i as initValRouteFromVal, g as getValRouteUrlFromVal } from '../../dist/routeFromVal-248c62f1.esm.js';
|
|
10
10
|
import '../../dist/createForOfIteratorHelper-5758a730.esm.js';
|
|
11
11
|
import '../../dist/unsupportedIterableToArray-5baabfdc.esm.js';
|
|
12
12
|
import '../../dist/slicedToArray-aa291011.esm.js';
|
|
@@ -214,6 +214,54 @@ var initFetchValRouteStega = function initFetchValRouteStega(config, valApiEndpo
|
|
|
214
214
|
};
|
|
215
215
|
}();
|
|
216
216
|
};
|
|
217
|
+
var initFetchValRouteUrl = function initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies) {
|
|
218
|
+
return /*#__PURE__*/function () {
|
|
219
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(selector, params) {
|
|
220
|
+
var fetchVal, resolvedParams, path, schema, val, route;
|
|
221
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
222
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
223
|
+
case 0:
|
|
224
|
+
fetchVal = initFetchValStega(config, valApiEndpoints, valServerPromise, isEnabled, getHeaders, getCookies);
|
|
225
|
+
if (!(params === undefined)) {
|
|
226
|
+
_context3.next = 5;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
_context3.t0 = undefined;
|
|
230
|
+
_context3.next = 8;
|
|
231
|
+
break;
|
|
232
|
+
case 5:
|
|
233
|
+
_context3.next = 7;
|
|
234
|
+
return Promise.resolve(params);
|
|
235
|
+
case 7:
|
|
236
|
+
_context3.t0 = _context3.sent;
|
|
237
|
+
case 8:
|
|
238
|
+
resolvedParams = _context3.t0;
|
|
239
|
+
path = selector && Internal.getValPath(selector);
|
|
240
|
+
schema = selector && Internal.getSchema(selector);
|
|
241
|
+
_context3.t1 = selector;
|
|
242
|
+
if (!_context3.t1) {
|
|
243
|
+
_context3.next = 16;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
_context3.next = 15;
|
|
247
|
+
return fetchVal(selector);
|
|
248
|
+
case 15:
|
|
249
|
+
_context3.t1 = _context3.sent;
|
|
250
|
+
case 16:
|
|
251
|
+
val = _context3.t1;
|
|
252
|
+
route = getValRouteUrlFromVal(resolvedParams, "fetchValRouteUrl", path, schema, val);
|
|
253
|
+
return _context3.abrupt("return", route);
|
|
254
|
+
case 19:
|
|
255
|
+
case "end":
|
|
256
|
+
return _context3.stop();
|
|
257
|
+
}
|
|
258
|
+
}, _callee3);
|
|
259
|
+
}));
|
|
260
|
+
return function (_x3, _x4) {
|
|
261
|
+
return _ref3.apply(this, arguments);
|
|
262
|
+
};
|
|
263
|
+
}();
|
|
264
|
+
};
|
|
217
265
|
var valApiEndpoints = "/api/val";
|
|
218
266
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
219
267
|
function initValRsc(config, valModules, rscNextConfig) {
|
|
@@ -232,22 +280,6 @@ function initValRsc(config, valModules, rscNextConfig) {
|
|
|
232
280
|
}
|
|
233
281
|
}, config), config, {
|
|
234
282
|
isEnabled: function isEnabled() {
|
|
235
|
-
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
236
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
237
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
238
|
-
case 0:
|
|
239
|
-
_context3.next = 2;
|
|
240
|
-
return rscNextConfig.draftMode();
|
|
241
|
-
case 2:
|
|
242
|
-
return _context3.abrupt("return", _context3.sent.isEnabled);
|
|
243
|
-
case 3:
|
|
244
|
-
case "end":
|
|
245
|
-
return _context3.stop();
|
|
246
|
-
}
|
|
247
|
-
}, _callee3);
|
|
248
|
-
}))();
|
|
249
|
-
},
|
|
250
|
-
onEnable: function onEnable() {
|
|
251
283
|
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
252
284
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
253
285
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -255,7 +287,7 @@ function initValRsc(config, valModules, rscNextConfig) {
|
|
|
255
287
|
_context4.next = 2;
|
|
256
288
|
return rscNextConfig.draftMode();
|
|
257
289
|
case 2:
|
|
258
|
-
_context4.sent.
|
|
290
|
+
return _context4.abrupt("return", _context4.sent.isEnabled);
|
|
259
291
|
case 3:
|
|
260
292
|
case "end":
|
|
261
293
|
return _context4.stop();
|
|
@@ -263,7 +295,7 @@ function initValRsc(config, valModules, rscNextConfig) {
|
|
|
263
295
|
}, _callee4);
|
|
264
296
|
}))();
|
|
265
297
|
},
|
|
266
|
-
|
|
298
|
+
onEnable: function onEnable() {
|
|
267
299
|
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
268
300
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
269
301
|
while (1) switch (_context5.prev = _context5.next) {
|
|
@@ -271,39 +303,42 @@ function initValRsc(config, valModules, rscNextConfig) {
|
|
|
271
303
|
_context5.next = 2;
|
|
272
304
|
return rscNextConfig.draftMode();
|
|
273
305
|
case 2:
|
|
274
|
-
_context5.sent.
|
|
306
|
+
_context5.sent.enable();
|
|
275
307
|
case 3:
|
|
276
308
|
case "end":
|
|
277
309
|
return _context5.stop();
|
|
278
310
|
}
|
|
279
311
|
}, _callee5);
|
|
280
312
|
}))();
|
|
313
|
+
},
|
|
314
|
+
onDisable: function onDisable() {
|
|
315
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
316
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
317
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
318
|
+
case 0:
|
|
319
|
+
_context6.next = 2;
|
|
320
|
+
return rscNextConfig.draftMode();
|
|
321
|
+
case 2:
|
|
322
|
+
_context6.sent.disable();
|
|
323
|
+
case 3:
|
|
324
|
+
case "end":
|
|
325
|
+
return _context6.stop();
|
|
326
|
+
}
|
|
327
|
+
}, _callee6);
|
|
328
|
+
}))();
|
|
281
329
|
}
|
|
282
330
|
});
|
|
283
331
|
return {
|
|
284
332
|
fetchValStega: initFetchValStega(config, valApiEndpoints,
|
|
285
333
|
// TODO: get from config
|
|
286
|
-
valServerPromise, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
287
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
288
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
289
|
-
case 0:
|
|
290
|
-
_context6.next = 2;
|
|
291
|
-
return rscNextConfig.draftMode();
|
|
292
|
-
case 2:
|
|
293
|
-
return _context6.abrupt("return", _context6.sent.isEnabled);
|
|
294
|
-
case 3:
|
|
295
|
-
case "end":
|
|
296
|
-
return _context6.stop();
|
|
297
|
-
}
|
|
298
|
-
}, _callee6);
|
|
299
|
-
})), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
334
|
+
valServerPromise, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
|
|
300
335
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
301
336
|
while (1) switch (_context7.prev = _context7.next) {
|
|
302
337
|
case 0:
|
|
303
338
|
_context7.next = 2;
|
|
304
|
-
return rscNextConfig.
|
|
339
|
+
return rscNextConfig.draftMode();
|
|
305
340
|
case 2:
|
|
306
|
-
return _context7.abrupt("return", _context7.sent);
|
|
341
|
+
return _context7.abrupt("return", _context7.sent.isEnabled);
|
|
307
342
|
case 3:
|
|
308
343
|
case "end":
|
|
309
344
|
return _context7.stop();
|
|
@@ -314,7 +349,7 @@ function initValRsc(config, valModules, rscNextConfig) {
|
|
|
314
349
|
while (1) switch (_context8.prev = _context8.next) {
|
|
315
350
|
case 0:
|
|
316
351
|
_context8.next = 2;
|
|
317
|
-
return rscNextConfig.
|
|
352
|
+
return rscNextConfig.headers();
|
|
318
353
|
case 2:
|
|
319
354
|
return _context8.abrupt("return", _context8.sent);
|
|
320
355
|
case 3:
|
|
@@ -322,28 +357,28 @@ function initValRsc(config, valModules, rscNextConfig) {
|
|
|
322
357
|
return _context8.stop();
|
|
323
358
|
}
|
|
324
359
|
}, _callee8);
|
|
325
|
-
})))
|
|
326
|
-
fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
360
|
+
})), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
|
|
327
361
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
328
362
|
while (1) switch (_context9.prev = _context9.next) {
|
|
329
363
|
case 0:
|
|
330
364
|
_context9.next = 2;
|
|
331
|
-
return rscNextConfig.
|
|
365
|
+
return rscNextConfig.cookies();
|
|
332
366
|
case 2:
|
|
333
|
-
return _context9.abrupt("return", _context9.sent
|
|
367
|
+
return _context9.abrupt("return", _context9.sent);
|
|
334
368
|
case 3:
|
|
335
369
|
case "end":
|
|
336
370
|
return _context9.stop();
|
|
337
371
|
}
|
|
338
372
|
}, _callee9);
|
|
339
|
-
})),
|
|
373
|
+
}))),
|
|
374
|
+
fetchValRouteStega: initFetchValRouteStega(config, valApiEndpoints, valServerPromise, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
340
375
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
341
376
|
while (1) switch (_context10.prev = _context10.next) {
|
|
342
377
|
case 0:
|
|
343
378
|
_context10.next = 2;
|
|
344
|
-
return rscNextConfig.
|
|
379
|
+
return rscNextConfig.draftMode();
|
|
345
380
|
case 2:
|
|
346
|
-
return _context10.abrupt("return", _context10.sent);
|
|
381
|
+
return _context10.abrupt("return", _context10.sent.isEnabled);
|
|
347
382
|
case 3:
|
|
348
383
|
case "end":
|
|
349
384
|
return _context10.stop();
|
|
@@ -354,7 +389,7 @@ function initValRsc(config, valModules, rscNextConfig) {
|
|
|
354
389
|
while (1) switch (_context11.prev = _context11.next) {
|
|
355
390
|
case 0:
|
|
356
391
|
_context11.next = 2;
|
|
357
|
-
return rscNextConfig.
|
|
392
|
+
return rscNextConfig.headers();
|
|
358
393
|
case 2:
|
|
359
394
|
return _context11.abrupt("return", _context11.sent);
|
|
360
395
|
case 3:
|
|
@@ -362,6 +397,59 @@ function initValRsc(config, valModules, rscNextConfig) {
|
|
|
362
397
|
return _context11.stop();
|
|
363
398
|
}
|
|
364
399
|
}, _callee11);
|
|
400
|
+
})), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
401
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
402
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
403
|
+
case 0:
|
|
404
|
+
_context12.next = 2;
|
|
405
|
+
return rscNextConfig.cookies();
|
|
406
|
+
case 2:
|
|
407
|
+
return _context12.abrupt("return", _context12.sent);
|
|
408
|
+
case 3:
|
|
409
|
+
case "end":
|
|
410
|
+
return _context12.stop();
|
|
411
|
+
}
|
|
412
|
+
}, _callee12);
|
|
413
|
+
}))),
|
|
414
|
+
fetchValRouteUrl: initFetchValRouteUrl(config, valApiEndpoints, valServerPromise, /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
|
|
415
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
416
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
417
|
+
case 0:
|
|
418
|
+
_context13.next = 2;
|
|
419
|
+
return rscNextConfig.draftMode();
|
|
420
|
+
case 2:
|
|
421
|
+
return _context13.abrupt("return", _context13.sent.isEnabled);
|
|
422
|
+
case 3:
|
|
423
|
+
case "end":
|
|
424
|
+
return _context13.stop();
|
|
425
|
+
}
|
|
426
|
+
}, _callee13);
|
|
427
|
+
})), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
428
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
429
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
430
|
+
case 0:
|
|
431
|
+
_context14.next = 2;
|
|
432
|
+
return rscNextConfig.headers();
|
|
433
|
+
case 2:
|
|
434
|
+
return _context14.abrupt("return", _context14.sent);
|
|
435
|
+
case 3:
|
|
436
|
+
case "end":
|
|
437
|
+
return _context14.stop();
|
|
438
|
+
}
|
|
439
|
+
}, _callee14);
|
|
440
|
+
})), /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
441
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
442
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
443
|
+
case 0:
|
|
444
|
+
_context15.next = 2;
|
|
445
|
+
return rscNextConfig.cookies();
|
|
446
|
+
case 2:
|
|
447
|
+
return _context15.abrupt("return", _context15.sent);
|
|
448
|
+
case 3:
|
|
449
|
+
case "end":
|
|
450
|
+
return _context15.stop();
|
|
451
|
+
}
|
|
452
|
+
}, _callee15);
|
|
365
453
|
})))
|
|
366
454
|
};
|
|
367
455
|
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var slicedToArray = require('./slicedToArray-44036a76.cjs.dev.js');
|
|
7
|
-
var ui = require('@valbuild/ui');
|
|
8
|
-
var Script = require('next/script');
|
|
9
|
-
var React = require('react');
|
|
10
|
-
var useRemoteConfigSender = require('./useRemoteConfigSender-c78b81c5.cjs.dev.js');
|
|
11
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
12
|
-
require('./unsupportedIterableToArray-c8ab77c9.cjs.dev.js');
|
|
13
|
-
require('./objectSpread2-792eb2c2.cjs.dev.js');
|
|
14
|
-
require('@valbuild/core');
|
|
15
|
-
require('@valbuild/shared/internal');
|
|
16
|
-
|
|
17
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
18
|
-
|
|
19
|
-
var Script__default = /*#__PURE__*/_interopDefault(Script);
|
|
20
|
-
|
|
21
|
-
var ValApp = function ValApp(_ref) {
|
|
22
|
-
var config = _ref.config;
|
|
23
|
-
var route = "/api/val"; // TODO: make configurable
|
|
24
|
-
var _useState = React.useState(),
|
|
25
|
-
_useState2 = slicedToArray._slicedToArray(_useState, 2),
|
|
26
|
-
inMessageMode = _useState2[0],
|
|
27
|
-
setInMessageMode = _useState2[1];
|
|
28
|
-
useRemoteConfigSender.useRemoteConfigSender(config);
|
|
29
|
-
React.useEffect(function () {
|
|
30
|
-
if (location.search === "?message_onready=true") {
|
|
31
|
-
setInMessageMode(true);
|
|
32
|
-
var interval = setInterval(function () {
|
|
33
|
-
window.parent.postMessage({
|
|
34
|
-
type: "val-ready"
|
|
35
|
-
}, "*");
|
|
36
|
-
});
|
|
37
|
-
return function () {
|
|
38
|
-
clearInterval(interval);
|
|
39
|
-
};
|
|
40
|
-
} else {
|
|
41
|
-
setInMessageMode(false);
|
|
42
|
-
}
|
|
43
|
-
}, []);
|
|
44
|
-
if (inMessageMode === undefined) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
if (inMessageMode === true) {
|
|
48
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
49
|
-
children: "Val Studio is disabled: in message mode"
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
53
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Script__default["default"], {
|
|
54
|
-
type: "module",
|
|
55
|
-
src: "".concat(route, "/static").concat(ui.VERSION ? "/".concat(ui.VERSION) : "").concat(ui.VAL_APP_PATH),
|
|
56
|
-
crossOrigin: "anonymous"
|
|
57
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
58
|
-
id: ui.VAL_APP_ID
|
|
59
|
-
})]
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
exports.ValApp = ValApp;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { _ as _slicedToArray } from './slicedToArray-aa291011.esm.js';
|
|
3
|
-
import { VERSION, VAL_APP_PATH, VAL_APP_ID } from '@valbuild/ui';
|
|
4
|
-
import Script from 'next/script';
|
|
5
|
-
import { useState, useEffect } from 'react';
|
|
6
|
-
import { u as useRemoteConfigSender } from './useRemoteConfigSender-02451801.esm.js';
|
|
7
|
-
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
|
-
import './unsupportedIterableToArray-5baabfdc.esm.js';
|
|
9
|
-
import './objectSpread2-c1340c1c.esm.js';
|
|
10
|
-
import '@valbuild/core';
|
|
11
|
-
import '@valbuild/shared/internal';
|
|
12
|
-
|
|
13
|
-
var ValApp = function ValApp(_ref) {
|
|
14
|
-
var config = _ref.config;
|
|
15
|
-
var route = "/api/val"; // TODO: make configurable
|
|
16
|
-
var _useState = useState(),
|
|
17
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
18
|
-
inMessageMode = _useState2[0],
|
|
19
|
-
setInMessageMode = _useState2[1];
|
|
20
|
-
useRemoteConfigSender(config);
|
|
21
|
-
useEffect(function () {
|
|
22
|
-
if (location.search === "?message_onready=true") {
|
|
23
|
-
setInMessageMode(true);
|
|
24
|
-
var interval = setInterval(function () {
|
|
25
|
-
window.parent.postMessage({
|
|
26
|
-
type: "val-ready"
|
|
27
|
-
}, "*");
|
|
28
|
-
});
|
|
29
|
-
return function () {
|
|
30
|
-
clearInterval(interval);
|
|
31
|
-
};
|
|
32
|
-
} else {
|
|
33
|
-
setInMessageMode(false);
|
|
34
|
-
}
|
|
35
|
-
}, []);
|
|
36
|
-
if (inMessageMode === undefined) {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
if (inMessageMode === true) {
|
|
40
|
-
return /*#__PURE__*/jsx("div", {
|
|
41
|
-
children: "Val Studio is disabled: in message mode"
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
return /*#__PURE__*/jsxs(Fragment, {
|
|
45
|
-
children: [/*#__PURE__*/jsx(Script, {
|
|
46
|
-
type: "module",
|
|
47
|
-
src: "".concat(route, "/static").concat(VERSION ? "/".concat(VERSION) : "").concat(VAL_APP_PATH),
|
|
48
|
-
crossOrigin: "anonymous"
|
|
49
|
-
}), /*#__PURE__*/jsx("div", {
|
|
50
|
-
id: VAL_APP_ID
|
|
51
|
-
})]
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export { ValApp };
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var slicedToArray = require('./slicedToArray-ce613de6.cjs.prod.js');
|
|
7
|
-
var ui = require('@valbuild/ui');
|
|
8
|
-
var Script = require('next/script');
|
|
9
|
-
var React = require('react');
|
|
10
|
-
var useRemoteConfigSender = require('./useRemoteConfigSender-3ea2fe91.cjs.prod.js');
|
|
11
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
12
|
-
require('./unsupportedIterableToArray-0d2087a2.cjs.prod.js');
|
|
13
|
-
require('./objectSpread2-3c87fb4f.cjs.prod.js');
|
|
14
|
-
require('@valbuild/core');
|
|
15
|
-
require('@valbuild/shared/internal');
|
|
16
|
-
|
|
17
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
18
|
-
|
|
19
|
-
var Script__default = /*#__PURE__*/_interopDefault(Script);
|
|
20
|
-
|
|
21
|
-
var ValApp = function ValApp(_ref) {
|
|
22
|
-
var config = _ref.config;
|
|
23
|
-
var route = "/api/val"; // TODO: make configurable
|
|
24
|
-
var _useState = React.useState(),
|
|
25
|
-
_useState2 = slicedToArray._slicedToArray(_useState, 2),
|
|
26
|
-
inMessageMode = _useState2[0],
|
|
27
|
-
setInMessageMode = _useState2[1];
|
|
28
|
-
useRemoteConfigSender.useRemoteConfigSender(config);
|
|
29
|
-
React.useEffect(function () {
|
|
30
|
-
if (location.search === "?message_onready=true") {
|
|
31
|
-
setInMessageMode(true);
|
|
32
|
-
var interval = setInterval(function () {
|
|
33
|
-
window.parent.postMessage({
|
|
34
|
-
type: "val-ready"
|
|
35
|
-
}, "*");
|
|
36
|
-
});
|
|
37
|
-
return function () {
|
|
38
|
-
clearInterval(interval);
|
|
39
|
-
};
|
|
40
|
-
} else {
|
|
41
|
-
setInMessageMode(false);
|
|
42
|
-
}
|
|
43
|
-
}, []);
|
|
44
|
-
if (inMessageMode === undefined) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
if (inMessageMode === true) {
|
|
48
|
-
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
49
|
-
children: "Val Studio is disabled: in message mode"
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
53
|
-
children: [/*#__PURE__*/jsxRuntime.jsx(Script__default["default"], {
|
|
54
|
-
type: "module",
|
|
55
|
-
src: "".concat(route, "/static").concat(ui.VERSION ? "/".concat(ui.VERSION) : "").concat(ui.VAL_APP_PATH),
|
|
56
|
-
crossOrigin: "anonymous"
|
|
57
|
-
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
58
|
-
id: ui.VAL_APP_ID
|
|
59
|
-
})]
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
exports.ValApp = ValApp;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { _ as _objectSpread2 } from './objectSpread2-c1340c1c.esm.js';
|
|
2
|
-
import { _ as _slicedToArray } from './slicedToArray-aa291011.esm.js';
|
|
3
|
-
import { DEFAULT_CONTENT_HOST, Internal } from '@valbuild/core';
|
|
4
|
-
import { VAL_CONFIG_RECEIVED_LISTENER, VAL_CONFIG_LISTENER } from '@valbuild/shared/internal';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
var textEncoder = new TextEncoder();
|
|
8
|
-
/*
|
|
9
|
-
* See the useRemoteConfigReceiver.tsx for the sender
|
|
10
|
-
*/
|
|
11
|
-
function useRemoteConfigSender(config) {
|
|
12
|
-
var _React$useState = React.useState(null),
|
|
13
|
-
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
14
|
-
sentRemoteConfigHash = _React$useState2[0],
|
|
15
|
-
setSentRemoteConfigHash = _React$useState2[1];
|
|
16
|
-
var _React$useState3 = React.useState(null),
|
|
17
|
-
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
18
|
-
receivedRemoteConfigHash = _React$useState4[0],
|
|
19
|
-
setReceivedRemoteConfigHash = _React$useState4[1];
|
|
20
|
-
React.useEffect(function () {
|
|
21
|
-
var sendConfig = function sendConfig() {
|
|
22
|
-
var sharedConfig = _objectSpread2(_objectSpread2({}, config), {}, {
|
|
23
|
-
// We're in NextJS now, so we can get process.env variables
|
|
24
|
-
contentHostUrl: process.env.VAL_CONTENT_URL || DEFAULT_CONTENT_HOST
|
|
25
|
-
});
|
|
26
|
-
var hash = Internal.getSHA256Hash(textEncoder.encode(JSON.stringify(sharedConfig)));
|
|
27
|
-
setSentRemoteConfigHash(hash);
|
|
28
|
-
window.dispatchEvent(new CustomEvent(VAL_CONFIG_LISTENER, {
|
|
29
|
-
detail: {
|
|
30
|
-
type: "val-config",
|
|
31
|
-
config: config,
|
|
32
|
-
hash: hash
|
|
33
|
-
}
|
|
34
|
-
}));
|
|
35
|
-
};
|
|
36
|
-
if (sentRemoteConfigHash === null || sentRemoteConfigHash !== receivedRemoteConfigHash) {
|
|
37
|
-
sendConfig();
|
|
38
|
-
var interval = setInterval(function () {
|
|
39
|
-
sendConfig();
|
|
40
|
-
}, 1000);
|
|
41
|
-
return function () {
|
|
42
|
-
clearInterval(interval);
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
}, [config, receivedRemoteConfigHash, sentRemoteConfigHash]);
|
|
46
|
-
React.useEffect(function () {
|
|
47
|
-
var configListener = function configListener(event) {
|
|
48
|
-
if (!(event instanceof CustomEvent)) {
|
|
49
|
-
console.warn("Received message of type val-config, but it was not a CustomEvent", event);
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (event.detail.type !== "val-config-received") {
|
|
53
|
-
console.warn("Received message of type val-config, but it did not have the expected type", event.detail);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
var hash = event.detail.hash;
|
|
57
|
-
if (!hash) {
|
|
58
|
-
console.warn("Received message of type val-config, but it did not have a hash", event.detail);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
setReceivedRemoteConfigHash(hash);
|
|
62
|
-
};
|
|
63
|
-
window.addEventListener(VAL_CONFIG_RECEIVED_LISTENER, configListener);
|
|
64
|
-
return function () {
|
|
65
|
-
window.removeEventListener(VAL_CONFIG_RECEIVED_LISTENER, configListener);
|
|
66
|
-
};
|
|
67
|
-
}, [config]);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export { useRemoteConfigSender as u };
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var objectSpread2 = require('./objectSpread2-3c87fb4f.cjs.prod.js');
|
|
4
|
-
var slicedToArray = require('./slicedToArray-ce613de6.cjs.prod.js');
|
|
5
|
-
var core = require('@valbuild/core');
|
|
6
|
-
var internal = require('@valbuild/shared/internal');
|
|
7
|
-
var React = require('react');
|
|
8
|
-
|
|
9
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
|
|
10
|
-
|
|
11
|
-
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
12
|
-
|
|
13
|
-
var textEncoder = new TextEncoder();
|
|
14
|
-
/*
|
|
15
|
-
* See the useRemoteConfigReceiver.tsx for the sender
|
|
16
|
-
*/
|
|
17
|
-
function useRemoteConfigSender(config) {
|
|
18
|
-
var _React$useState = React__default["default"].useState(null),
|
|
19
|
-
_React$useState2 = slicedToArray._slicedToArray(_React$useState, 2),
|
|
20
|
-
sentRemoteConfigHash = _React$useState2[0],
|
|
21
|
-
setSentRemoteConfigHash = _React$useState2[1];
|
|
22
|
-
var _React$useState3 = React__default["default"].useState(null),
|
|
23
|
-
_React$useState4 = slicedToArray._slicedToArray(_React$useState3, 2),
|
|
24
|
-
receivedRemoteConfigHash = _React$useState4[0],
|
|
25
|
-
setReceivedRemoteConfigHash = _React$useState4[1];
|
|
26
|
-
React__default["default"].useEffect(function () {
|
|
27
|
-
var sendConfig = function sendConfig() {
|
|
28
|
-
var sharedConfig = objectSpread2._objectSpread2(objectSpread2._objectSpread2({}, config), {}, {
|
|
29
|
-
// We're in NextJS now, so we can get process.env variables
|
|
30
|
-
contentHostUrl: process.env.VAL_CONTENT_URL || core.DEFAULT_CONTENT_HOST
|
|
31
|
-
});
|
|
32
|
-
var hash = core.Internal.getSHA256Hash(textEncoder.encode(JSON.stringify(sharedConfig)));
|
|
33
|
-
setSentRemoteConfigHash(hash);
|
|
34
|
-
window.dispatchEvent(new CustomEvent(internal.VAL_CONFIG_LISTENER, {
|
|
35
|
-
detail: {
|
|
36
|
-
type: "val-config",
|
|
37
|
-
config: config,
|
|
38
|
-
hash: hash
|
|
39
|
-
}
|
|
40
|
-
}));
|
|
41
|
-
};
|
|
42
|
-
if (sentRemoteConfigHash === null || sentRemoteConfigHash !== receivedRemoteConfigHash) {
|
|
43
|
-
sendConfig();
|
|
44
|
-
var interval = setInterval(function () {
|
|
45
|
-
sendConfig();
|
|
46
|
-
}, 1000);
|
|
47
|
-
return function () {
|
|
48
|
-
clearInterval(interval);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
}, [config, receivedRemoteConfigHash, sentRemoteConfigHash]);
|
|
52
|
-
React__default["default"].useEffect(function () {
|
|
53
|
-
var configListener = function configListener(event) {
|
|
54
|
-
if (!(event instanceof CustomEvent)) {
|
|
55
|
-
console.warn("Received message of type val-config, but it was not a CustomEvent", event);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (event.detail.type !== "val-config-received") {
|
|
59
|
-
console.warn("Received message of type val-config, but it did not have the expected type", event.detail);
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
var hash = event.detail.hash;
|
|
63
|
-
if (!hash) {
|
|
64
|
-
console.warn("Received message of type val-config, but it did not have a hash", event.detail);
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
setReceivedRemoteConfigHash(hash);
|
|
68
|
-
};
|
|
69
|
-
window.addEventListener(internal.VAL_CONFIG_RECEIVED_LISTENER, configListener);
|
|
70
|
-
return function () {
|
|
71
|
-
window.removeEventListener(internal.VAL_CONFIG_RECEIVED_LISTENER, configListener);
|
|
72
|
-
};
|
|
73
|
-
}, [config]);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
exports.useRemoteConfigSender = useRemoteConfigSender;
|