@micro-lc/preview 0.4.2 → 0.5.0-rc2
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +3 -4
- package/dist/index.d.ts +24 -3
- package/dist/index.js +23 -20
- package/dist/service-worker.d.ts +28 -0
- package/dist/service-worker.js +1 -0
- package/package.json +7 -6
- package/website/development/index.html +1 -1
- package/website/development/{assets/index-dafdc2d8.js → index.js} +453 -228
- package/website/development/manifest.json +6 -1
- package/website/development/service-worker.js +99 -0
- package/website/index.html +1 -1
- package/website/index.js +13 -0
- package/website/manifest.json +6 -1
- package/website/service-worker.js +1 -0
- package/website/assets/index-de9f10b5.js +0 -13
@@ -3266,6 +3266,13 @@ var observable = function() {
|
|
3266
3266
|
function identity(x2) {
|
3267
3267
|
return x2;
|
3268
3268
|
}
|
3269
|
+
function pipe() {
|
3270
|
+
var fns = [];
|
3271
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
3272
|
+
fns[_i] = arguments[_i];
|
3273
|
+
}
|
3274
|
+
return pipeFromArray(fns);
|
3275
|
+
}
|
3269
3276
|
function pipeFromArray(fns) {
|
3270
3277
|
if (fns.length === 0) {
|
3271
3278
|
return identity;
|
@@ -3869,6 +3876,9 @@ function isScheduler(value) {
|
|
3869
3876
|
function last(arr) {
|
3870
3877
|
return arr[arr.length - 1];
|
3871
3878
|
}
|
3879
|
+
function popResultSelector(args) {
|
3880
|
+
return isFunction(last(args)) ? args.pop() : void 0;
|
3881
|
+
}
|
3872
3882
|
function popScheduler(args) {
|
3873
3883
|
return isScheduler(last(args)) ? args.pop() : void 0;
|
3874
3884
|
}
|
@@ -4276,6 +4286,58 @@ function map(project, thisArg) {
|
|
4276
4286
|
}));
|
4277
4287
|
});
|
4278
4288
|
}
|
4289
|
+
var isArray$1 = Array.isArray;
|
4290
|
+
function callOrApply(fn, args) {
|
4291
|
+
return isArray$1(args) ? fn.apply(void 0, __spreadArray([], __read(args))) : fn(args);
|
4292
|
+
}
|
4293
|
+
function mapOneOrManyArgs(fn) {
|
4294
|
+
return map(function(args) {
|
4295
|
+
return callOrApply(fn, args);
|
4296
|
+
});
|
4297
|
+
}
|
4298
|
+
function combineLatestInit(observables, scheduler, valueTransform) {
|
4299
|
+
if (valueTransform === void 0) {
|
4300
|
+
valueTransform = identity;
|
4301
|
+
}
|
4302
|
+
return function(subscriber) {
|
4303
|
+
maybeSchedule(scheduler, function() {
|
4304
|
+
var length = observables.length;
|
4305
|
+
var values = new Array(length);
|
4306
|
+
var active = length;
|
4307
|
+
var remainingFirstValues = length;
|
4308
|
+
var _loop_1 = function(i3) {
|
4309
|
+
maybeSchedule(scheduler, function() {
|
4310
|
+
var source = from(observables[i3], scheduler);
|
4311
|
+
var hasFirstValue = false;
|
4312
|
+
source.subscribe(createOperatorSubscriber(subscriber, function(value) {
|
4313
|
+
values[i3] = value;
|
4314
|
+
if (!hasFirstValue) {
|
4315
|
+
hasFirstValue = true;
|
4316
|
+
remainingFirstValues--;
|
4317
|
+
}
|
4318
|
+
if (!remainingFirstValues) {
|
4319
|
+
subscriber.next(valueTransform(values.slice()));
|
4320
|
+
}
|
4321
|
+
}, function() {
|
4322
|
+
if (!--active) {
|
4323
|
+
subscriber.complete();
|
4324
|
+
}
|
4325
|
+
}));
|
4326
|
+
}, subscriber);
|
4327
|
+
};
|
4328
|
+
for (var i2 = 0; i2 < length; i2++) {
|
4329
|
+
_loop_1(i2);
|
4330
|
+
}
|
4331
|
+
}, subscriber);
|
4332
|
+
};
|
4333
|
+
}
|
4334
|
+
function maybeSchedule(scheduler, execute, subscription) {
|
4335
|
+
if (scheduler) {
|
4336
|
+
executeSchedule(subscription, scheduler, execute);
|
4337
|
+
} else {
|
4338
|
+
execute();
|
4339
|
+
}
|
4340
|
+
}
|
4279
4341
|
function mergeInternals(source, subscriber, project, concurrent, onBeforeNext, expand, innerSubScheduler, additionalFinalizer) {
|
4280
4342
|
var buffer = [];
|
4281
4343
|
var active = 0;
|
@@ -4384,6 +4446,22 @@ function timer(dueTime, intervalOrScheduler, scheduler) {
|
|
4384
4446
|
}, due);
|
4385
4447
|
});
|
4386
4448
|
}
|
4449
|
+
function interval(period, scheduler) {
|
4450
|
+
if (period === void 0) {
|
4451
|
+
period = 0;
|
4452
|
+
}
|
4453
|
+
if (scheduler === void 0) {
|
4454
|
+
scheduler = asyncScheduler;
|
4455
|
+
}
|
4456
|
+
if (period < 0) {
|
4457
|
+
period = 0;
|
4458
|
+
}
|
4459
|
+
return timer(period, period, scheduler);
|
4460
|
+
}
|
4461
|
+
var isArray = Array.isArray;
|
4462
|
+
function argsOrArgArray(args) {
|
4463
|
+
return args.length === 1 && isArray(args[0]) ? args[0] : args;
|
4464
|
+
}
|
4387
4465
|
function filter(predicate, thisArg) {
|
4388
4466
|
return operate(function(source, subscriber) {
|
4389
4467
|
var index = 0;
|
@@ -4466,6 +4544,23 @@ function bufferTime(bufferTimeSpan) {
|
|
4466
4544
|
source.subscribe(bufferTimeSubscriber);
|
4467
4545
|
});
|
4468
4546
|
}
|
4547
|
+
function combineLatest() {
|
4548
|
+
var args = [];
|
4549
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
4550
|
+
args[_i] = arguments[_i];
|
4551
|
+
}
|
4552
|
+
var resultSelector = popResultSelector(args);
|
4553
|
+
return resultSelector ? pipe(combineLatest.apply(void 0, __spreadArray([], __read(args))), mapOneOrManyArgs(resultSelector)) : operate(function(source, subscriber) {
|
4554
|
+
combineLatestInit(__spreadArray([source], __read(argsOrArgArray(args))))(subscriber);
|
4555
|
+
});
|
4556
|
+
}
|
4557
|
+
function combineLatestWith() {
|
4558
|
+
var otherSources = [];
|
4559
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
4560
|
+
otherSources[_i] = arguments[_i];
|
4561
|
+
}
|
4562
|
+
return combineLatest.apply(void 0, __spreadArray([], __read(otherSources)));
|
4563
|
+
}
|
4469
4564
|
function concatMap(project, resultSelector) {
|
4470
4565
|
return isFunction(resultSelector) ? mergeMap(project, resultSelector, 1) : mergeMap(project, 1);
|
4471
4566
|
}
|
@@ -4525,145 +4620,27 @@ function tap(observerOrNext, error2, complete) {
|
|
4525
4620
|
}));
|
4526
4621
|
}) : identity;
|
4527
4622
|
}
|
4528
|
-
|
4529
|
-
|
4530
|
-
|
4531
|
-
|
4532
|
-
}
|
4533
|
-
return input == null ? void 0 : input[lang];
|
4534
|
-
};
|
4535
|
-
function translateObject(obj) {
|
4536
|
-
return Object.entries(obj).reduce((out, [key, value]) => {
|
4537
|
-
out[key] = localizeText(value);
|
4538
|
-
return out;
|
4539
|
-
}, {});
|
4540
|
-
}
|
4541
|
-
const noop = (..._args) => {
|
4542
|
-
};
|
4543
|
-
const toArray$1 = (input) => Array.isArray(input) ? input : [input];
|
4544
|
-
const urlMakerFactory = ({ document: { baseURI }, location: { href } }) => (input) => new URL(input, new URL(baseURI, href));
|
4545
|
-
const toURL = (urlMaker, info) => {
|
4546
|
-
let url = info;
|
4547
|
-
if (!(info instanceof URL)) {
|
4548
|
-
url = urlMaker(typeof info === "string" ? info : info.url);
|
4549
|
-
}
|
4550
|
-
return url;
|
4551
|
-
};
|
4552
|
-
const trimLocationOrigin = (origin, url) => {
|
4553
|
-
const { href, origin: linkOrigin } = url;
|
4554
|
-
if (origin === linkOrigin) {
|
4555
|
-
return href.substring(origin.length);
|
4556
|
-
}
|
4557
|
-
return href;
|
4558
|
-
};
|
4559
|
-
const getElement = (document2, context, nth = 0) => {
|
4560
|
-
const { selectors } = context;
|
4561
|
-
return document2.querySelector(selectors[nth]);
|
4562
|
-
};
|
4563
|
-
function getElementBySelector(selector) {
|
4564
|
-
return document.querySelector(selector);
|
4565
|
-
}
|
4566
|
-
const unfocus = (element, mapping) => {
|
4567
|
-
const originalStyle = mapping.get(element);
|
4568
|
-
if (originalStyle) {
|
4569
|
-
const { css, rest, subscription } = originalStyle;
|
4570
|
-
rest.forEach((el) => {
|
4571
|
-
var _a2;
|
4572
|
-
return (_a2 = el.__unfocus_handler) == null ? void 0 : _a2.call(el);
|
4573
|
-
});
|
4574
|
-
subscription.unsubscribe();
|
4575
|
-
originalStyle.elementToFocus.forEach((el, idx) => {
|
4576
|
-
Object.assign(el.style, css[idx]);
|
4577
|
-
});
|
4578
|
-
}
|
4579
|
-
mapping.delete(element);
|
4580
|
-
};
|
4581
|
-
const noUndefined = (input) => input !== void 0;
|
4582
|
-
function focus(document2, obs$, mode$) {
|
4583
|
-
const stylesMap = /* @__PURE__ */ new Map();
|
4584
|
-
const getBySelector = getElementBySelector.bind(document2);
|
4585
|
-
const subscription = obs$.pipe(
|
4586
|
-
pairwise(),
|
4587
|
-
tap(([current]) => {
|
4588
|
-
var _a2;
|
4589
|
-
if (current !== void 0) {
|
4590
|
-
const prev = getElement(document2, current);
|
4591
|
-
if (prev !== null) {
|
4592
|
-
(_a2 = prev.__unfocus_handler) == null ? void 0 : _a2.call(prev);
|
4593
|
-
unfocus(prev, stylesMap);
|
4594
|
-
}
|
4595
|
-
}
|
4596
|
-
}),
|
4597
|
-
map(([, next]) => next),
|
4598
|
-
filter(noUndefined),
|
4599
|
-
map((next) => {
|
4600
|
-
const [first, ...rest] = next.selectors;
|
4601
|
-
const otherElements = rest.reduce((arr, selector) => {
|
4602
|
-
var _a2;
|
4603
|
-
const el = getBySelector(selector);
|
4604
|
-
if (el) {
|
4605
|
-
arr.push(el);
|
4606
|
-
const result = (_a2 = el.__focus_handler) == null ? void 0 : _a2.call(el);
|
4607
|
-
if (result && "then" in result) {
|
4608
|
-
result.catch(noop);
|
4609
|
-
}
|
4610
|
-
}
|
4611
|
-
return arr;
|
4612
|
-
}, []);
|
4613
|
-
return { first, next, otherElements };
|
4614
|
-
}),
|
4615
|
-
map((next) => ({ ...next, firstElement: getBySelector(next.first) })),
|
4616
|
-
filter((next) => next.firstElement !== null),
|
4617
|
-
map((next) => {
|
4618
|
-
var _a2, _b;
|
4619
|
-
return { ...next, focus: (_b = (_a2 = next.firstElement).__focus_handler) == null ? void 0 : _b.call(_a2) };
|
4620
|
-
}),
|
4621
|
-
concatMap(({ focus: focusPromise, ...rest }) => {
|
4622
|
-
const promise = focusPromise && "then" in focusPromise ? focusPromise : Promise.resolve(focusPromise != null ? focusPromise : rest.firstElement);
|
4623
|
-
return promise.then((focusElement) => ({ focus: focusElement, ...rest })).catch(() => ({ focus: void 0, ...rest }));
|
4624
|
-
})
|
4625
|
-
).subscribe(({ otherElements, next, firstElement, focus: focusContext }) => {
|
4626
|
-
const cssKeys = Object.keys(next.style);
|
4627
|
-
const stylePendingChanges = new Subscription();
|
4628
|
-
const elementToFocus = toArray$1(focusContext != null ? focusContext : firstElement).filter(Boolean);
|
4629
|
-
const initialStyles = { css: [], elementToFocus, rest: otherElements, subscription: stylePendingChanges };
|
4630
|
-
const styles = cssKeys.reduce((acc, key) => {
|
4631
|
-
elementToFocus.forEach((el, idx) => {
|
4632
|
-
var _a2;
|
4633
|
-
acc.css[idx] = Object.assign((_a2 = acc.css[idx]) != null ? _a2 : {}, { [key]: el.style[key] });
|
4634
|
-
});
|
4635
|
-
return acc;
|
4636
|
-
}, initialStyles);
|
4637
|
-
stylePendingChanges.add(mode$.pipe(filter((val) => val === "select"), take(1)).subscribe(() => {
|
4638
|
-
elementToFocus.forEach((el) => {
|
4639
|
-
Object.assign(el.style, next.style);
|
4640
|
-
});
|
4641
|
-
}));
|
4642
|
-
stylesMap.set(firstElement, styles);
|
4643
|
-
});
|
4644
|
-
return () => subscription.unsubscribe();
|
4645
|
-
}
|
4646
|
-
var __defProp$4 = Object.defineProperty;
|
4647
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4648
|
-
var __publicField$4 = (obj, key, value) => {
|
4649
|
-
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4623
|
+
var __defProp$5 = Object.defineProperty;
|
4624
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4625
|
+
var __publicField$5 = (obj, key, value) => {
|
4626
|
+
__defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4650
4627
|
return value;
|
4651
4628
|
};
|
4652
4629
|
let Lexer$1 = class Lexer {
|
4653
4630
|
constructor(input) {
|
4654
|
-
__publicField$
|
4655
|
-
__publicField$
|
4656
|
-
__publicField$
|
4657
|
-
__publicField$
|
4631
|
+
__publicField$5(this, "_input");
|
4632
|
+
__publicField$5(this, "_length");
|
4633
|
+
__publicField$5(this, "_idx", 0);
|
4634
|
+
__publicField$5(
|
4658
4635
|
this,
|
4659
4636
|
"_mode",
|
4660
4637
|
0
|
4661
4638
|
/* Literal */
|
4662
4639
|
);
|
4663
|
-
__publicField$
|
4664
|
-
__publicField$
|
4665
|
-
__publicField$
|
4666
|
-
__publicField$
|
4640
|
+
__publicField$5(this, "_literals", []);
|
4641
|
+
__publicField$5(this, "_variables", []);
|
4642
|
+
__publicField$5(this, "_braketCount", 0);
|
4643
|
+
__publicField$5(this, "_done", false);
|
4667
4644
|
this._input = input;
|
4668
4645
|
this._length = input.length;
|
4669
4646
|
}
|
@@ -4764,28 +4741,30 @@ function parse(input, context, preserveUnknown = false) {
|
|
4764
4741
|
return acc;
|
4765
4742
|
}
|
4766
4743
|
const compileObject = (obj, context) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, parse(value, context)]));
|
4767
|
-
var __defProp$
|
4768
|
-
var __defNormalProp$
|
4769
|
-
var __publicField$
|
4770
|
-
__defNormalProp$
|
4744
|
+
var __defProp$4 = Object.defineProperty;
|
4745
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4746
|
+
var __publicField$4 = (obj, key, value) => {
|
4747
|
+
__defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4771
4748
|
return value;
|
4772
4749
|
};
|
4773
4750
|
const MIA_PREVIEW_ID = "__mia_preview_id";
|
4774
4751
|
const OVERLAY_Z_INDEX = 1e6;
|
4775
4752
|
const keys = {
|
4776
|
-
"click-element":
|
4777
|
-
"ctrl-space":
|
4753
|
+
"click-element": 1,
|
4754
|
+
"ctrl-space": 1,
|
4778
4755
|
"focus-element": 0,
|
4779
|
-
mousedown:
|
4756
|
+
mousedown: 1,
|
4780
4757
|
mousemove: 1,
|
4781
4758
|
"new-configuration": 0,
|
4782
|
-
notification:
|
4783
|
-
options:
|
4784
|
-
"request-resource":
|
4785
|
-
"
|
4786
|
-
|
4787
|
-
|
4788
|
-
|
4759
|
+
notification: 1,
|
4760
|
+
options: 1,
|
4761
|
+
"request-resource": 1,
|
4762
|
+
"service-worker": 1,
|
4763
|
+
"set-source-map": 0,
|
4764
|
+
"tag-info": 1,
|
4765
|
+
update: 1,
|
4766
|
+
updated: 1
|
4767
|
+
/* Skip */
|
4789
4768
|
};
|
4790
4769
|
const isValidKey = (type) => Object.keys(keys).includes(type);
|
4791
4770
|
function isInstanceMessage(input, signature) {
|
@@ -4825,10 +4804,10 @@ const generateDarkColorHex = () => {
|
|
4825
4804
|
};
|
4826
4805
|
class PostChannel {
|
4827
4806
|
constructor(handler2) {
|
4828
|
-
__publicField$
|
4829
|
-
__publicField$
|
4830
|
-
__publicField$
|
4831
|
-
__publicField$
|
4807
|
+
__publicField$4(this, "__instance");
|
4808
|
+
__publicField$4(this, "__handler");
|
4809
|
+
__publicField$4(this, "__window");
|
4810
|
+
__publicField$4(this, "__randomColor");
|
4832
4811
|
this.__instance = "";
|
4833
4812
|
this.__handler = handler2;
|
4834
4813
|
this.__window = window;
|
@@ -4838,16 +4817,15 @@ class PostChannel {
|
|
4838
4817
|
{
|
4839
4818
|
console.assert(to !== this.__window);
|
4840
4819
|
}
|
4841
|
-
|
4842
|
-
|
4843
|
-
|
4844
|
-
|
4845
|
-
|
4846
|
-
|
4847
|
-
|
4848
|
-
|
4849
|
-
|
4850
|
-
}
|
4820
|
+
const color = this.__randomColor;
|
4821
|
+
const background = `${color}22`;
|
4822
|
+
const style = { background, color };
|
4823
|
+
const hasTop = this.__window.top !== this.__window;
|
4824
|
+
console.groupCollapsed(`%c Msg from ${this.__window.origin} ${hasTop ? "(inner)" : "(top)"} `, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join("; "));
|
4825
|
+
console.info(`window '${this.__window.origin}' is sending a message of type %c ${message.type} `, "background: lightgreen; color: darkgreen");
|
4826
|
+
console.log("to", to);
|
4827
|
+
console.log(message.content);
|
4828
|
+
console.groupEnd();
|
4851
4829
|
to.postMessage(sign(this.__instance, message), origin);
|
4852
4830
|
}
|
4853
4831
|
set instance(str) {
|
@@ -4863,15 +4841,259 @@ class PostChannel {
|
|
4863
4841
|
this.__window !== to && this.postMessage(to, message, origin);
|
4864
4842
|
}
|
4865
4843
|
recv(window2, from2 = null) {
|
4866
|
-
const
|
4844
|
+
const listener = ({ data, source }) => {
|
4867
4845
|
if ((from2 === null || source === from2) && isInstanceMessage(data, this.__instance)) {
|
4868
4846
|
const message = unsign(this.__instance, data);
|
4869
4847
|
this.__handler(message);
|
4870
4848
|
}
|
4871
4849
|
};
|
4872
|
-
window2.addEventListener("message",
|
4873
|
-
return () => window2.removeEventListener("message",
|
4850
|
+
window2.addEventListener("message", listener);
|
4851
|
+
return () => window2.removeEventListener("message", listener);
|
4852
|
+
}
|
4853
|
+
}
|
4854
|
+
var __defProp$3 = Object.defineProperty;
|
4855
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4856
|
+
var __publicField$3 = (obj, key, value) => {
|
4857
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4858
|
+
return value;
|
4859
|
+
};
|
4860
|
+
function registerChannels() {
|
4861
|
+
return {
|
4862
|
+
configuration: new ReplaySubject(),
|
4863
|
+
focus: new BehaviorSubject(void 0),
|
4864
|
+
infos: new ReplaySubject(),
|
4865
|
+
mocks: new ReplaySubject(),
|
4866
|
+
mode: new BehaviorSubject("select"),
|
4867
|
+
notification: new ReplaySubject(),
|
4868
|
+
setSourceMap: new ReplaySubject(),
|
4869
|
+
swReady: new ReplaySubject(1),
|
4870
|
+
updated: new Subject(),
|
4871
|
+
uppercaseTags: /* @__PURE__ */ new Set()
|
4872
|
+
};
|
4873
|
+
}
|
4874
|
+
const nextMode = (mode) => {
|
4875
|
+
let next = 0;
|
4876
|
+
const currentValue = mode.getValue();
|
4877
|
+
if (currentValue === "interact") {
|
4878
|
+
next = "select";
|
4879
|
+
} else if (currentValue === "select") {
|
4880
|
+
next = "interact";
|
4881
|
+
}
|
4882
|
+
mode.next(next);
|
4883
|
+
return next;
|
4884
|
+
};
|
4885
|
+
const subjects = registerChannels();
|
4886
|
+
function parentListener(message) {
|
4887
|
+
switch (message.type) {
|
4888
|
+
case "options": {
|
4889
|
+
const { content: { disableOverlay, redirectTo, timeout } } = message;
|
4890
|
+
if (disableOverlay) {
|
4891
|
+
Object.defineProperty(this.window, "__BACKOFFICE_CONFIGURATOR_DISABLE_OVERLAY__", { value: true });
|
4892
|
+
subjects.mode.next("interact");
|
4893
|
+
}
|
4894
|
+
if (timeout !== void 0) {
|
4895
|
+
Object.defineProperty(this.window, "__BACKOFFICE_CONFIGURATOR_PREVIEW_TIMEOUT__", { value: timeout });
|
4896
|
+
}
|
4897
|
+
const { window: { history } } = this;
|
4898
|
+
this.window.navigator.serviceWorker.ready.then(() => redirectTo && history.pushState(history.state, "", redirectTo)).catch(() => {
|
4899
|
+
});
|
4900
|
+
break;
|
4901
|
+
}
|
4902
|
+
case "ctrl-space":
|
4903
|
+
nextMode(subjects.mode);
|
4904
|
+
break;
|
4905
|
+
case "new-configuration":
|
4906
|
+
subjects.configuration.next({ ...message.content, type: "reset" });
|
4907
|
+
break;
|
4908
|
+
case "update":
|
4909
|
+
subjects.configuration.next({ ...message.content, type: "update" });
|
4910
|
+
break;
|
4911
|
+
case "focus-element":
|
4912
|
+
subjects.focus.next(message.content);
|
4913
|
+
break;
|
4914
|
+
case "set-source-map": {
|
4915
|
+
const { content: { dictionary } } = message;
|
4916
|
+
subjects.setSourceMap.next({
|
4917
|
+
...message.content,
|
4918
|
+
dictionary: Object.entries(dictionary).reduce((acc, [from2, to]) => {
|
4919
|
+
try {
|
4920
|
+
const { href: fromUrl } = new URL(from2, this.window.location.href);
|
4921
|
+
const obj = typeof to === "string" ? { headers: {}, query: {}, to } : to;
|
4922
|
+
acc[fromUrl] = {
|
4923
|
+
originalFrom: from2,
|
4924
|
+
...obj
|
4925
|
+
};
|
4926
|
+
} catch (e2) {
|
4927
|
+
}
|
4928
|
+
return acc;
|
4929
|
+
}, {})
|
4930
|
+
});
|
4931
|
+
break;
|
4932
|
+
}
|
4933
|
+
}
|
4934
|
+
}
|
4935
|
+
class ServiceWorkerChannel {
|
4936
|
+
constructor(handler2) {
|
4937
|
+
__publicField$3(this, "__handler");
|
4938
|
+
__publicField$3(this, "__window");
|
4939
|
+
__publicField$3(this, "__randomColor");
|
4940
|
+
this.__handler = handler2;
|
4941
|
+
this.__window = window;
|
4942
|
+
this.__randomColor = generateDarkColorHex();
|
4943
|
+
}
|
4944
|
+
send(to, message) {
|
4945
|
+
{
|
4946
|
+
const color = this.__randomColor;
|
4947
|
+
const background = `${color}22`;
|
4948
|
+
const style = { background, color };
|
4949
|
+
console.groupCollapsed(`%c Msg to Service Worker `, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join("; "));
|
4950
|
+
console.info(`window '${this.__window.origin}' is sending a message of type %c ${message.type} `, "background: lightgreen; color: darkgreen");
|
4951
|
+
console.log(message.content);
|
4952
|
+
console.groupEnd();
|
4953
|
+
}
|
4954
|
+
to.postMessage(message);
|
4955
|
+
}
|
4956
|
+
get window() {
|
4957
|
+
return this.__window;
|
4958
|
+
}
|
4959
|
+
set window(win) {
|
4960
|
+
this.__window = win;
|
4961
|
+
}
|
4962
|
+
recv() {
|
4963
|
+
const swListener2 = ({ data }) => {
|
4964
|
+
this.__handler(data);
|
4965
|
+
};
|
4966
|
+
const { __window: { navigator: navigator2 } } = this;
|
4967
|
+
navigator2.serviceWorker.addEventListener("message", swListener2);
|
4968
|
+
return () => navigator2.serviceWorker.removeEventListener("message", swListener2);
|
4969
|
+
}
|
4970
|
+
}
|
4971
|
+
const swListener = (message) => {
|
4972
|
+
switch (message.type) {
|
4973
|
+
case "source-map-ack":
|
4974
|
+
subjects.swReady.next(0);
|
4975
|
+
break;
|
4976
|
+
}
|
4977
|
+
};
|
4978
|
+
const postChannel = new PostChannel(parentListener);
|
4979
|
+
const serviceWorkerChannel = new ServiceWorkerChannel(swListener);
|
4980
|
+
const DEFAULT_LANGUAGE = "en";
|
4981
|
+
const localizeText = (input, lang = DEFAULT_LANGUAGE) => {
|
4982
|
+
if (typeof input === "string") {
|
4983
|
+
return input;
|
4984
|
+
}
|
4985
|
+
return input == null ? void 0 : input[lang];
|
4986
|
+
};
|
4987
|
+
function translateObject(obj) {
|
4988
|
+
return Object.entries(obj).reduce((out, [key, value]) => {
|
4989
|
+
out[key] = localizeText(value);
|
4990
|
+
return out;
|
4991
|
+
}, {});
|
4992
|
+
}
|
4993
|
+
const noop = (..._args) => {
|
4994
|
+
};
|
4995
|
+
const toArray$1 = (input) => Array.isArray(input) ? input : [input];
|
4996
|
+
const urlMakerFactory = ({ document: { baseURI }, location: { href } }) => (input) => new URL(input, new URL(baseURI, href));
|
4997
|
+
const toURL = (urlMaker, info) => {
|
4998
|
+
let url = info;
|
4999
|
+
if (!(info instanceof URL)) {
|
5000
|
+
url = urlMaker(typeof info === "string" ? info : info.url);
|
5001
|
+
}
|
5002
|
+
return url;
|
5003
|
+
};
|
5004
|
+
const trimLocationOrigin = (origin, url) => {
|
5005
|
+
const { href, origin: linkOrigin } = url;
|
5006
|
+
if (origin === linkOrigin) {
|
5007
|
+
return href.substring(origin.length);
|
4874
5008
|
}
|
5009
|
+
return href;
|
5010
|
+
};
|
5011
|
+
const getElement = (document2, context, nth = 0) => {
|
5012
|
+
const { selectors } = context;
|
5013
|
+
return document2.querySelector(selectors[nth]);
|
5014
|
+
};
|
5015
|
+
function getElementBySelector(selector) {
|
5016
|
+
return document.querySelector(selector);
|
5017
|
+
}
|
5018
|
+
const unfocus = (element, mapping) => {
|
5019
|
+
const originalStyle = mapping.get(element.getAttribute("__mia_preview_id"));
|
5020
|
+
if (originalStyle) {
|
5021
|
+
const { css, rest, subscription } = originalStyle;
|
5022
|
+
rest.forEach((el) => {
|
5023
|
+
var _a2;
|
5024
|
+
return (_a2 = el.__unfocus_handler) == null ? void 0 : _a2.call(el);
|
5025
|
+
});
|
5026
|
+
subscription.unsubscribe();
|
5027
|
+
originalStyle.elementToFocus.forEach((el, idx) => {
|
5028
|
+
Object.assign(el.style, css[idx]);
|
5029
|
+
});
|
5030
|
+
}
|
5031
|
+
mapping.delete(element.getAttribute("__mia_preview_id"));
|
5032
|
+
};
|
5033
|
+
const noUndefined = (input) => input !== void 0;
|
5034
|
+
function focus(document2, obs$, mode$) {
|
5035
|
+
const stylesMap = /* @__PURE__ */ new Map();
|
5036
|
+
const getBySelector = getElementBySelector.bind(document2);
|
5037
|
+
const subscription = obs$.pipe(
|
5038
|
+
pairwise(),
|
5039
|
+
tap(([current]) => {
|
5040
|
+
var _a2;
|
5041
|
+
if (current !== void 0) {
|
5042
|
+
const prev = getElement(document2, current);
|
5043
|
+
if (prev !== null) {
|
5044
|
+
(_a2 = prev.__unfocus_handler) == null ? void 0 : _a2.call(prev);
|
5045
|
+
unfocus(prev, stylesMap);
|
5046
|
+
}
|
5047
|
+
}
|
5048
|
+
}),
|
5049
|
+
map(([, next]) => next),
|
5050
|
+
filter(noUndefined),
|
5051
|
+
map((next) => {
|
5052
|
+
const [first, ...rest] = next.selectors;
|
5053
|
+
const otherElements = rest.reduce((arr, selector) => {
|
5054
|
+
var _a2;
|
5055
|
+
const el = getBySelector(selector);
|
5056
|
+
if (el) {
|
5057
|
+
arr.push(el);
|
5058
|
+
const result = (_a2 = el.__focus_handler) == null ? void 0 : _a2.call(el);
|
5059
|
+
if (result && "then" in result) {
|
5060
|
+
result.catch(noop);
|
5061
|
+
}
|
5062
|
+
}
|
5063
|
+
return arr;
|
5064
|
+
}, []);
|
5065
|
+
return { first, next, otherElements };
|
5066
|
+
}),
|
5067
|
+
map((next) => ({ ...next, firstElement: getBySelector(next.first) })),
|
5068
|
+
filter((next) => next.firstElement !== null),
|
5069
|
+
map((next) => {
|
5070
|
+
var _a2, _b;
|
5071
|
+
return { ...next, focus: (_b = (_a2 = next.firstElement).__focus_handler) == null ? void 0 : _b.call(_a2) };
|
5072
|
+
}),
|
5073
|
+
concatMap(({ focus: focusPromise, ...rest }) => {
|
5074
|
+
const promise = focusPromise && "then" in focusPromise ? focusPromise : Promise.resolve(focusPromise != null ? focusPromise : rest.firstElement);
|
5075
|
+
return promise.then((focusElement) => ({ focus: focusElement, ...rest })).catch(() => ({ focus: void 0, ...rest }));
|
5076
|
+
})
|
5077
|
+
).subscribe(({ otherElements, next, firstElement, focus: focusContext }) => {
|
5078
|
+
const cssKeys = Object.keys(next.style);
|
5079
|
+
const stylePendingChanges = new Subscription();
|
5080
|
+
const elementToFocus = toArray$1(focusContext != null ? focusContext : firstElement).filter(Boolean);
|
5081
|
+
const initialStyles = { css: [], elementToFocus, rest: otherElements, subscription: stylePendingChanges };
|
5082
|
+
const styles = cssKeys.reduce((acc, key) => {
|
5083
|
+
elementToFocus.forEach((el, idx) => {
|
5084
|
+
var _a2;
|
5085
|
+
acc.css[idx] = Object.assign((_a2 = acc.css[idx]) != null ? _a2 : {}, { [key]: el.style[key] });
|
5086
|
+
});
|
5087
|
+
return acc;
|
5088
|
+
}, initialStyles);
|
5089
|
+
stylePendingChanges.add(mode$.pipe(filter((val) => val === "select"), take(1)).subscribe(() => {
|
5090
|
+
elementToFocus.forEach((el) => {
|
5091
|
+
Object.assign(el.style, next.style);
|
5092
|
+
});
|
5093
|
+
}));
|
5094
|
+
stylesMap.set(firstElement.getAttribute("__mia_preview_id"), styles);
|
5095
|
+
});
|
5096
|
+
return () => subscription.unsubscribe();
|
4875
5097
|
}
|
4876
5098
|
var t;
|
4877
5099
|
const i = window, s = i.trustedTypes, e = s ? s.createPolicy("lit-html", { createHTML: (t2) => t2 }) : void 0, o = "$lit$", n = `lit$${(Math.random() + "").slice(9)}$`, l = "?" + n, h = `<${l}>`, r = document, d = () => r.createComment(""), u = (t2) => null === t2 || "object" != typeof t2 && "function" != typeof t2, c = Array.isArray, v = (t2) => c(t2) || "function" == typeof (null == t2 ? void 0 : t2[Symbol.iterator]), a = "[ \n\f\r]", f = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, _ = /-->/g, m = />/g, p = RegExp(`>|${a}(?:([^\\s"'>=/]+)(${a}*=${a}*(?:[^
|
@@ -5326,7 +5548,7 @@ const __vitePreload = function preload(baseModule, deps, importerUrl) {
|
|
5326
5548
|
})).then(() => baseModule());
|
5327
5549
|
};
|
5328
5550
|
function error(message, ...args) {
|
5329
|
-
__vitePreload(() => import("./errors-5a0ccde7.js"), true ? [] : void 0, import.meta.url).then(({ default: errorMap }) => {
|
5551
|
+
__vitePreload(() => import("./assets/errors-5a0ccde7.js"), true ? [] : void 0, import.meta.url).then(({ default: errorMap }) => {
|
5330
5552
|
const handler2 = errorMap[message];
|
5331
5553
|
handler2 ? console.error(handler2(...args)) : console.error(...args);
|
5332
5554
|
}).catch((err) => {
|
@@ -5340,12 +5562,12 @@ function dynamicImportError(name) {
|
|
5340
5562
|
error("0", name, err.message);
|
5341
5563
|
};
|
5342
5564
|
}
|
5343
|
-
const logger = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
5565
|
+
const logger$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
5344
5566
|
__proto__: null,
|
5345
5567
|
dynamicImportError,
|
5346
5568
|
error
|
5347
5569
|
}, Symbol.toStringTag, { value: "Module" }));
|
5348
|
-
var logger_default = logger;
|
5570
|
+
var logger_default = logger$1;
|
5349
5571
|
var __defProp$2 = Object.defineProperty;
|
5350
5572
|
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
5351
5573
|
var __publicField$2 = (obj, key, value) => {
|
@@ -5571,60 +5793,6 @@ async function render(config2, container, context = {}) {
|
|
5571
5793
|
return null;
|
5572
5794
|
});
|
5573
5795
|
}
|
5574
|
-
function registerChannels() {
|
5575
|
-
return {
|
5576
|
-
configuration: new ReplaySubject(),
|
5577
|
-
focus: new BehaviorSubject(void 0),
|
5578
|
-
infos: new ReplaySubject(),
|
5579
|
-
mocks: new ReplaySubject(),
|
5580
|
-
mode: new BehaviorSubject("select"),
|
5581
|
-
notification: new ReplaySubject(),
|
5582
|
-
updated: new Subject(),
|
5583
|
-
uppercaseTags: /* @__PURE__ */ new Set()
|
5584
|
-
};
|
5585
|
-
}
|
5586
|
-
const nextMode = (mode) => {
|
5587
|
-
let next = 0;
|
5588
|
-
const currentValue = mode.getValue();
|
5589
|
-
if (currentValue === "interact") {
|
5590
|
-
next = "select";
|
5591
|
-
} else if (currentValue === "select") {
|
5592
|
-
next = "interact";
|
5593
|
-
}
|
5594
|
-
mode.next(next);
|
5595
|
-
return next;
|
5596
|
-
};
|
5597
|
-
const subjects = registerChannels();
|
5598
|
-
function listener(message) {
|
5599
|
-
switch (message.type) {
|
5600
|
-
case "options": {
|
5601
|
-
const { content: { disableOverlay, redirectTo, timeout } } = message;
|
5602
|
-
if (disableOverlay) {
|
5603
|
-
Object.defineProperty(this.window, "__BACKOFFICE_CONFIGURATOR_DISABLE_OVERLAY__", { value: true });
|
5604
|
-
subjects.mode.next("interact");
|
5605
|
-
}
|
5606
|
-
if (timeout !== void 0) {
|
5607
|
-
Object.defineProperty(this.window, "__BACKOFFICE_CONFIGURATOR_PREVIEW_TIMEOUT__", { value: timeout });
|
5608
|
-
}
|
5609
|
-
const { window: { history } } = this;
|
5610
|
-
redirectTo && history.pushState(history.state, "", redirectTo);
|
5611
|
-
break;
|
5612
|
-
}
|
5613
|
-
case "ctrl-space":
|
5614
|
-
nextMode(subjects.mode);
|
5615
|
-
break;
|
5616
|
-
case "new-configuration":
|
5617
|
-
subjects.configuration.next({ ...message.content, type: "reset" });
|
5618
|
-
break;
|
5619
|
-
case "update":
|
5620
|
-
subjects.configuration.next({ ...message.content, type: "update" });
|
5621
|
-
break;
|
5622
|
-
case "focus-element":
|
5623
|
-
subjects.focus.next(message.content);
|
5624
|
-
break;
|
5625
|
-
}
|
5626
|
-
}
|
5627
|
-
const postChannel = new PostChannel(listener);
|
5628
5796
|
const fromErrorToNotification = (error2) => {
|
5629
5797
|
var _a2;
|
5630
5798
|
return {
|
@@ -5760,7 +5928,9 @@ const getPreviewContainer = (frame, root) => {
|
|
5760
5928
|
let container = root.firstElementChild;
|
5761
5929
|
if (container === null) {
|
5762
5930
|
container = document2.createElement("div");
|
5763
|
-
container.style.height = "
|
5931
|
+
container.style.height = "100%";
|
5932
|
+
container.style.width = "100%";
|
5933
|
+
container.style.overflow = "auto";
|
5764
5934
|
container.style.display = "flex";
|
5765
5935
|
root.appendChild(container);
|
5766
5936
|
}
|
@@ -6152,9 +6322,8 @@ function appendOverlay(self2, mode$) {
|
|
6152
6322
|
}
|
6153
6323
|
const appendRenderRoot = (document2) => {
|
6154
6324
|
const renderRoot = document2.createElement("div");
|
6155
|
-
renderRoot.style.display = "flex";
|
6156
|
-
renderRoot.style.flexDirection = "column";
|
6157
6325
|
renderRoot.style.height = "inherit";
|
6326
|
+
renderRoot.style.width = "inherit";
|
6158
6327
|
document2.body.appendChild(renderRoot);
|
6159
6328
|
return renderRoot;
|
6160
6329
|
};
|
@@ -6211,7 +6380,10 @@ const addInfoFactory = (channels) => (info) => {
|
|
6211
6380
|
};
|
6212
6381
|
const run = (frame, renderRoot, channels) => {
|
6213
6382
|
const queue = new Queue();
|
6214
|
-
const subscription = channels.configuration.
|
6383
|
+
const subscription = channels.configuration.pipe(
|
6384
|
+
combineLatestWith(subjects.swReady.pipe(take(1))),
|
6385
|
+
map(([next]) => next)
|
6386
|
+
).subscribe((next) => {
|
6215
6387
|
const { configuration } = next;
|
6216
6388
|
const { content } = configuration;
|
6217
6389
|
let done;
|
@@ -6297,11 +6469,51 @@ function createComposerApplication(self2, channels) {
|
|
6297
6469
|
sandboxedWindow
|
6298
6470
|
};
|
6299
6471
|
}
|
6300
|
-
|
6472
|
+
function logger(type, ...args) {
|
6473
|
+
{
|
6474
|
+
const color = generateDarkColorHex();
|
6475
|
+
const background = `${color}22`;
|
6476
|
+
const style = { background, color };
|
6477
|
+
console.groupCollapsed(`%c Preview ${this.location.href}`, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join("; "));
|
6478
|
+
console[type](...args);
|
6479
|
+
console.groupEnd();
|
6480
|
+
}
|
6481
|
+
}
|
6482
|
+
function logServiceWorkerStatus(registration) {
|
6483
|
+
const log = logger.bind(this);
|
6484
|
+
if (registration.installing) {
|
6485
|
+
log("info", "Service worker installing");
|
6486
|
+
} else if (registration.waiting) {
|
6487
|
+
log("info", "Service worker installed");
|
6488
|
+
} else if (registration.active) {
|
6489
|
+
log("info", "Service worker active");
|
6490
|
+
}
|
6491
|
+
}
|
6492
|
+
const registerServiceWorker = async (self2) => {
|
6493
|
+
const { navigator: navigator2 } = self2;
|
6494
|
+
if ("serviceWorker" in navigator2) {
|
6495
|
+
navigator2.serviceWorker.register("./service-worker.js", { scope: "./" }).then((reg) => logServiceWorkerStatus.call(self2, reg)).catch((error2) => console.error(error2));
|
6496
|
+
return navigator2.serviceWorker.ready.then((reg) => {
|
6497
|
+
var _a2;
|
6498
|
+
return (_a2 = reg.active) != null ? _a2 : Promise.reject(new TypeError("serviceWorker not active"));
|
6499
|
+
});
|
6500
|
+
}
|
6501
|
+
logger.call(self2, "error", "serviceWorker is not available");
|
6502
|
+
};
|
6503
|
+
const init = async (self2) => {
|
6301
6504
|
postChannel.window = self2;
|
6505
|
+
serviceWorkerChannel.window = self2;
|
6506
|
+
return registerServiceWorker(self2);
|
6302
6507
|
};
|
6303
|
-
function registerSenders(chs) {
|
6508
|
+
function registerSenders(chs, sw) {
|
6304
6509
|
const subscription = new Subscription();
|
6510
|
+
if (sw) {
|
6511
|
+
subscription.add(
|
6512
|
+
chs.setSourceMap.subscribe(
|
6513
|
+
(next) => serviceWorkerChannel.send(sw, { content: next, type: "set-source-map" })
|
6514
|
+
)
|
6515
|
+
);
|
6516
|
+
}
|
6305
6517
|
subscription.add(
|
6306
6518
|
chs.updated.subscribe(() => {
|
6307
6519
|
postChannel.send(window.parent, {
|
@@ -6357,10 +6569,20 @@ function registerCleanups(window2, fns) {
|
|
6357
6569
|
fns.forEach((fn) => fn());
|
6358
6570
|
});
|
6359
6571
|
}
|
6360
|
-
((self2) => {
|
6361
|
-
init(self2);
|
6572
|
+
(async (self2) => {
|
6573
|
+
const sw = await init(self2);
|
6574
|
+
let serviceWorkerChannelCleanup = noop;
|
6362
6575
|
const postChannelCleanup = postChannel.recv(self2, self2.top);
|
6363
|
-
|
6576
|
+
if (sw) {
|
6577
|
+
const swCleanup = serviceWorkerChannel.recv();
|
6578
|
+
const subscription = interval(100).subscribe(() => postChannel.send(self2.parent, { content: { status: "ready" }, type: "service-worker" }));
|
6579
|
+
serviceWorkerChannelCleanup = () => {
|
6580
|
+
swCleanup();
|
6581
|
+
subscription.unsubscribe();
|
6582
|
+
serviceWorkerChannel.send(sw, { content: {}, type: "unload-client" });
|
6583
|
+
};
|
6584
|
+
}
|
6585
|
+
const senderCleanup = registerSenders(subjects, sw);
|
6364
6586
|
const listenerCleanup = registerEventListeners(
|
6365
6587
|
self2,
|
6366
6588
|
{ handler: ctrlSpaceFactory(subjects), type: "keydown" },
|
@@ -6378,7 +6600,10 @@ function registerCleanups(window2, fns) {
|
|
6378
6600
|
composerApplicationCleanup,
|
6379
6601
|
listenerCleanup,
|
6380
6602
|
senderCleanup,
|
6603
|
+
serviceWorkerChannelCleanup,
|
6381
6604
|
postChannelCleanup
|
6382
6605
|
]
|
6383
6606
|
);
|
6384
|
-
})(window)
|
6607
|
+
})(window).catch((error2) => {
|
6608
|
+
throw error2;
|
6609
|
+
});
|