@micro-lc/preview 0.5.0-rc4 → 0.5.0-rc6
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +5 -0
- package/dist/index.d.ts +23 -42
- package/dist/index.js +10 -97
- package/dist/service-worker.d.ts +4 -16
- package/dist/service-worker.js +146 -1
- package/dist/src/lib/handlebars.d.ts +2 -0
- package/dist/src/lib/handlebars.js +130 -0
- package/dist/src/lib/index.d.ts +110 -0
- package/dist/src/lib/index.js +38 -0
- package/package.json +11 -8
- package/website/assets/index-d6db66eb.js +13 -0
- package/website/assets/index-d846d55b.js +15 -0
- package/website/development/{index.js → assets/index-3ca91186.js} +613 -559
- package/website/development/assets/index-62118151.js +6685 -0
- package/website/development/index.html +1 -1
- package/website/development/manifest.json +1 -6
- package/website/development/service-worker.js +2108 -104
- package/website/index.html +1 -1
- package/website/manifest.json +1 -6
- package/website/service-worker.js +3 -1
- package/website/index.js +0 -13
@@ -1,3 +1,9 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
3
|
+
var __publicField = (obj, key, value) => {
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
5
|
+
return value;
|
6
|
+
};
|
1
7
|
(function polyfill() {
|
2
8
|
const relList = document.createElement("link").relList;
|
3
9
|
if (relList && relList.supports && relList.supports("modulepreload")) {
|
@@ -3379,12 +3385,12 @@ function isSubscriber(value) {
|
|
3379
3385
|
function hasLift(source) {
|
3380
3386
|
return isFunction(source === null || source === void 0 ? void 0 : source.lift);
|
3381
3387
|
}
|
3382
|
-
function operate(
|
3388
|
+
function operate(init) {
|
3383
3389
|
return function(source) {
|
3384
3390
|
if (hasLift(source)) {
|
3385
3391
|
return source.lift(function(liftedSource) {
|
3386
3392
|
try {
|
3387
|
-
return
|
3393
|
+
return init(liftedSource, this);
|
3388
3394
|
} catch (err) {
|
3389
3395
|
this.error(err);
|
3390
3396
|
}
|
@@ -4275,6 +4281,26 @@ function lastValueFrom(source, config2) {
|
|
4275
4281
|
});
|
4276
4282
|
});
|
4277
4283
|
}
|
4284
|
+
function firstValueFrom(source, config2) {
|
4285
|
+
var hasConfig = typeof config2 === "object";
|
4286
|
+
return new Promise(function(resolve, reject) {
|
4287
|
+
var subscriber = new SafeSubscriber({
|
4288
|
+
next: function(value) {
|
4289
|
+
resolve(value);
|
4290
|
+
subscriber.unsubscribe();
|
4291
|
+
},
|
4292
|
+
error: reject,
|
4293
|
+
complete: function() {
|
4294
|
+
if (hasConfig) {
|
4295
|
+
resolve(config2.defaultValue);
|
4296
|
+
} else {
|
4297
|
+
reject(new EmptyError());
|
4298
|
+
}
|
4299
|
+
}
|
4300
|
+
});
|
4301
|
+
source.subscribe(subscriber);
|
4302
|
+
});
|
4303
|
+
}
|
4278
4304
|
function isValidDate(value) {
|
4279
4305
|
return value instanceof Date && !isNaN(value);
|
4280
4306
|
}
|
@@ -4413,6 +4439,62 @@ function mergeMap(project, resultSelector, concurrent) {
|
|
4413
4439
|
return mergeInternals(source, subscriber, project, concurrent);
|
4414
4440
|
});
|
4415
4441
|
}
|
4442
|
+
var nodeEventEmitterMethods = ["addListener", "removeListener"];
|
4443
|
+
var eventTargetMethods = ["addEventListener", "removeEventListener"];
|
4444
|
+
var jqueryMethods = ["on", "off"];
|
4445
|
+
function fromEvent(target, eventName, options, resultSelector) {
|
4446
|
+
if (isFunction(options)) {
|
4447
|
+
resultSelector = options;
|
4448
|
+
options = void 0;
|
4449
|
+
}
|
4450
|
+
if (resultSelector) {
|
4451
|
+
return fromEvent(target, eventName, options).pipe(mapOneOrManyArgs(resultSelector));
|
4452
|
+
}
|
4453
|
+
var _a2 = __read(isEventTarget(target) ? eventTargetMethods.map(function(methodName) {
|
4454
|
+
return function(handler2) {
|
4455
|
+
return target[methodName](eventName, handler2, options);
|
4456
|
+
};
|
4457
|
+
}) : isNodeStyleEventEmitter(target) ? nodeEventEmitterMethods.map(toCommonHandlerRegistry(target, eventName)) : isJQueryStyleEventEmitter(target) ? jqueryMethods.map(toCommonHandlerRegistry(target, eventName)) : [], 2), add = _a2[0], remove = _a2[1];
|
4458
|
+
if (!add) {
|
4459
|
+
if (isArrayLike(target)) {
|
4460
|
+
return mergeMap(function(subTarget) {
|
4461
|
+
return fromEvent(subTarget, eventName, options);
|
4462
|
+
})(innerFrom(target));
|
4463
|
+
}
|
4464
|
+
}
|
4465
|
+
if (!add) {
|
4466
|
+
throw new TypeError("Invalid event target");
|
4467
|
+
}
|
4468
|
+
return new Observable(function(subscriber) {
|
4469
|
+
var handler2 = function() {
|
4470
|
+
var args = [];
|
4471
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
4472
|
+
args[_i] = arguments[_i];
|
4473
|
+
}
|
4474
|
+
return subscriber.next(1 < args.length ? args : args[0]);
|
4475
|
+
};
|
4476
|
+
add(handler2);
|
4477
|
+
return function() {
|
4478
|
+
return remove(handler2);
|
4479
|
+
};
|
4480
|
+
});
|
4481
|
+
}
|
4482
|
+
function toCommonHandlerRegistry(target, eventName) {
|
4483
|
+
return function(methodName) {
|
4484
|
+
return function(handler2) {
|
4485
|
+
return target[methodName](eventName, handler2);
|
4486
|
+
};
|
4487
|
+
};
|
4488
|
+
}
|
4489
|
+
function isNodeStyleEventEmitter(target) {
|
4490
|
+
return isFunction(target.addListener) && isFunction(target.removeListener);
|
4491
|
+
}
|
4492
|
+
function isJQueryStyleEventEmitter(target) {
|
4493
|
+
return isFunction(target.on) && isFunction(target.off);
|
4494
|
+
}
|
4495
|
+
function isEventTarget(target) {
|
4496
|
+
return isFunction(target.addEventListener) && isFunction(target.removeEventListener);
|
4497
|
+
}
|
4416
4498
|
function timer(dueTime, intervalOrScheduler, scheduler) {
|
4417
4499
|
if (dueTime === void 0) {
|
4418
4500
|
dueTime = 0;
|
@@ -4620,368 +4702,6 @@ function tap(observerOrNext, error2, complete) {
|
|
4620
4702
|
}));
|
4621
4703
|
}) : identity;
|
4622
4704
|
}
|
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);
|
4627
|
-
return value;
|
4628
|
-
};
|
4629
|
-
let Lexer$1 = class Lexer {
|
4630
|
-
constructor(input) {
|
4631
|
-
__publicField$5(this, "_input");
|
4632
|
-
__publicField$5(this, "_length");
|
4633
|
-
__publicField$5(this, "_idx", 0);
|
4634
|
-
__publicField$5(
|
4635
|
-
this,
|
4636
|
-
"_mode",
|
4637
|
-
0
|
4638
|
-
/* Literal */
|
4639
|
-
);
|
4640
|
-
__publicField$5(this, "_literals", []);
|
4641
|
-
__publicField$5(this, "_variables", []);
|
4642
|
-
__publicField$5(this, "_braketCount", 0);
|
4643
|
-
__publicField$5(this, "_done", false);
|
4644
|
-
this._input = input;
|
4645
|
-
this._length = input.length;
|
4646
|
-
}
|
4647
|
-
concatToLastLiteral(concat) {
|
4648
|
-
this._literals.push(this._literals.pop().concat(concat));
|
4649
|
-
}
|
4650
|
-
concatToLastVariable(concat) {
|
4651
|
-
this._variables.push(this._variables.pop().concat(concat));
|
4652
|
-
}
|
4653
|
-
get() {
|
4654
|
-
const rawLiterals = [...this._literals];
|
4655
|
-
const literals = Object.assign([], rawLiterals);
|
4656
|
-
Object.defineProperty(literals, "raw", { value: rawLiterals, writable: false });
|
4657
|
-
return {
|
4658
|
-
literals,
|
4659
|
-
variables: this._variables
|
4660
|
-
};
|
4661
|
-
}
|
4662
|
-
run() {
|
4663
|
-
if (this._length === 0) {
|
4664
|
-
this._literals.push("");
|
4665
|
-
}
|
4666
|
-
while (this._idx < this._length) {
|
4667
|
-
const char = this._input.charAt(this._idx);
|
4668
|
-
switch (this._mode) {
|
4669
|
-
case 0: {
|
4670
|
-
if (this._literals.length === 0) {
|
4671
|
-
this._literals.push("");
|
4672
|
-
}
|
4673
|
-
if (char === "{" && this._idx + 1 !== this._length && this._input.charAt(this._idx + 1) === "{") {
|
4674
|
-
this._literals.push("");
|
4675
|
-
this._variables.push("");
|
4676
|
-
this._mode = 1;
|
4677
|
-
this._idx += 1;
|
4678
|
-
} else {
|
4679
|
-
this.concatToLastLiteral(char);
|
4680
|
-
}
|
4681
|
-
break;
|
4682
|
-
}
|
4683
|
-
case 1:
|
4684
|
-
if (char === "}" && this._input.charAt(this._idx + 1) === "}") {
|
4685
|
-
this._mode = 0;
|
4686
|
-
this._idx += 1;
|
4687
|
-
} else {
|
4688
|
-
this.concatToLastVariable(char);
|
4689
|
-
}
|
4690
|
-
break;
|
4691
|
-
}
|
4692
|
-
this._idx += 1;
|
4693
|
-
}
|
4694
|
-
if (this._mode === 1) {
|
4695
|
-
this._literals.pop();
|
4696
|
-
this.concatToLastLiteral(`{{${this._variables.pop()}`);
|
4697
|
-
}
|
4698
|
-
this._done = true;
|
4699
|
-
}
|
4700
|
-
};
|
4701
|
-
const isSquareBrakets = (field) => {
|
4702
|
-
const trimmed = field.trim();
|
4703
|
-
if (!(trimmed.startsWith("[") && trimmed.endsWith("]"))) {
|
4704
|
-
return false;
|
4705
|
-
}
|
4706
|
-
const inner = trimmed.slice(1).slice(0, -1).trim();
|
4707
|
-
if (Number.parseInt(inner).toString(10) !== inner) {
|
4708
|
-
return false;
|
4709
|
-
}
|
4710
|
-
return true;
|
4711
|
-
};
|
4712
|
-
const getNumber = (field) => {
|
4713
|
-
return Number.parseInt(field.trim().slice(1).slice(0, -1).trim());
|
4714
|
-
};
|
4715
|
-
function interpolate$1(context, path, preserveUnknown) {
|
4716
|
-
if (!path.trim()) {
|
4717
|
-
return preserveUnknown ? `{{${path}}}` : "";
|
4718
|
-
}
|
4719
|
-
const result = path.trim().split(".").reduce((superctx, field) => {
|
4720
|
-
if (Array.isArray(superctx) && isSquareBrakets(field)) {
|
4721
|
-
return superctx[getNumber(field)];
|
4722
|
-
}
|
4723
|
-
if (typeof superctx === "object" && superctx !== null && field in superctx) {
|
4724
|
-
return superctx[field];
|
4725
|
-
}
|
4726
|
-
return void 0;
|
4727
|
-
}, { ...context });
|
4728
|
-
if (typeof result === "string") {
|
4729
|
-
return result;
|
4730
|
-
}
|
4731
|
-
return preserveUnknown ? `{{${path}}}` : "";
|
4732
|
-
}
|
4733
|
-
function parse(input, context, preserveUnknown = false) {
|
4734
|
-
const lexer2 = new Lexer$1(input);
|
4735
|
-
lexer2.run();
|
4736
|
-
const template = lexer2.get();
|
4737
|
-
let [acc] = template.literals;
|
4738
|
-
for (let i2 = 0; i2 < template.variables.length; i2++) {
|
4739
|
-
acc = acc.concat(interpolate$1(context, template.variables[i2], preserveUnknown)).concat(template.literals[i2 + 1]);
|
4740
|
-
}
|
4741
|
-
return acc;
|
4742
|
-
}
|
4743
|
-
const compileObject = (obj, context) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, parse(value, context)]));
|
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);
|
4748
|
-
return value;
|
4749
|
-
};
|
4750
|
-
const MIA_PREVIEW_ID = "__mia_preview_id";
|
4751
|
-
const OVERLAY_Z_INDEX = 1e6;
|
4752
|
-
const keys = {
|
4753
|
-
"click-element": 1,
|
4754
|
-
"ctrl-space": 1,
|
4755
|
-
"focus-element": 0,
|
4756
|
-
mousedown: 1,
|
4757
|
-
mousemove: 1,
|
4758
|
-
"new-configuration": 0,
|
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 */
|
4768
|
-
};
|
4769
|
-
const isValidKey = (type) => Object.keys(keys).includes(type);
|
4770
|
-
function isInstanceMessage(input, signature) {
|
4771
|
-
if (input === null) {
|
4772
|
-
return false;
|
4773
|
-
}
|
4774
|
-
if (typeof input !== "object") {
|
4775
|
-
return false;
|
4776
|
-
}
|
4777
|
-
if (!("type" in input) || typeof input.type !== "string") {
|
4778
|
-
return false;
|
4779
|
-
}
|
4780
|
-
const { type: signedType } = input;
|
4781
|
-
if (!signedType.startsWith(signature)) {
|
4782
|
-
return false;
|
4783
|
-
}
|
4784
|
-
const type = signedType.substring(signature.length);
|
4785
|
-
if (!isValidKey(type)) {
|
4786
|
-
return false;
|
4787
|
-
}
|
4788
|
-
return true;
|
4789
|
-
}
|
4790
|
-
const sign = (signature, message) => ({ ...message, type: `${signature}${message.type}` });
|
4791
|
-
const unsign = (signature, message) => {
|
4792
|
-
let { type } = message;
|
4793
|
-
if (type.startsWith(signature)) {
|
4794
|
-
type = type.substring(signature.length);
|
4795
|
-
}
|
4796
|
-
return { ...message, type };
|
4797
|
-
};
|
4798
|
-
const generateDarkColorHex = () => {
|
4799
|
-
let color = "#";
|
4800
|
-
for (let i2 = 0; i2 < 3; i2++) {
|
4801
|
-
color += `0${Math.floor(Math.random() * Math.pow(16, 2) / 2).toString(16)}`.slice(-2);
|
4802
|
-
}
|
4803
|
-
return color;
|
4804
|
-
};
|
4805
|
-
class PostChannel {
|
4806
|
-
constructor(handler2) {
|
4807
|
-
__publicField$4(this, "__instance");
|
4808
|
-
__publicField$4(this, "__handler");
|
4809
|
-
__publicField$4(this, "__window");
|
4810
|
-
__publicField$4(this, "__randomColor");
|
4811
|
-
this.__instance = "";
|
4812
|
-
this.__handler = handler2;
|
4813
|
-
this.__window = window;
|
4814
|
-
this.__randomColor = generateDarkColorHex();
|
4815
|
-
}
|
4816
|
-
postMessage(to, message, origin) {
|
4817
|
-
{
|
4818
|
-
console.assert(to !== this.__window);
|
4819
|
-
}
|
4820
|
-
if (
|
4821
|
-
/* ("development" !== 'production' || this.__window.__BACKOFFICE_CONFIGURATOR_LOG_LEVEL__ === 'debug') && */
|
4822
|
-
keys[message.type] !== 1
|
4823
|
-
) {
|
4824
|
-
const color = this.__randomColor;
|
4825
|
-
const background = `${color}22`;
|
4826
|
-
const style = { background, color };
|
4827
|
-
const hasTop = this.__window.top !== this.__window;
|
4828
|
-
console.groupCollapsed(`%c Msg from ${this.__window.origin} ${hasTop ? "(inner)" : "(top)"} `, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join("; "));
|
4829
|
-
console.info(`window '${this.__window.origin}' is sending a message of type %c ${message.type} `, "background: lightgreen; color: darkgreen");
|
4830
|
-
console.log("to", to);
|
4831
|
-
console.log(message.content);
|
4832
|
-
console.groupEnd();
|
4833
|
-
}
|
4834
|
-
to.postMessage(sign(this.__instance, message), origin);
|
4835
|
-
}
|
4836
|
-
set instance(str) {
|
4837
|
-
this.__instance = str;
|
4838
|
-
}
|
4839
|
-
get window() {
|
4840
|
-
return this.__window;
|
4841
|
-
}
|
4842
|
-
set window(win) {
|
4843
|
-
this.__window = win;
|
4844
|
-
}
|
4845
|
-
send(to, message, origin = "*") {
|
4846
|
-
this.__window !== to && this.postMessage(to, message, origin);
|
4847
|
-
}
|
4848
|
-
recv(window2, from2 = null) {
|
4849
|
-
const listener = ({ data, source }) => {
|
4850
|
-
if ((from2 === null || source === from2) && isInstanceMessage(data, this.__instance)) {
|
4851
|
-
const message = unsign(this.__instance, data);
|
4852
|
-
this.__handler(message);
|
4853
|
-
}
|
4854
|
-
};
|
4855
|
-
window2.addEventListener("message", listener);
|
4856
|
-
return () => window2.removeEventListener("message", listener);
|
4857
|
-
}
|
4858
|
-
}
|
4859
|
-
var __defProp$3 = Object.defineProperty;
|
4860
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4861
|
-
var __publicField$3 = (obj, key, value) => {
|
4862
|
-
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4863
|
-
return value;
|
4864
|
-
};
|
4865
|
-
function registerChannels() {
|
4866
|
-
return {
|
4867
|
-
configuration: new ReplaySubject(),
|
4868
|
-
focus: new BehaviorSubject(void 0),
|
4869
|
-
infos: new ReplaySubject(),
|
4870
|
-
mocks: new ReplaySubject(),
|
4871
|
-
mode: new BehaviorSubject("select"),
|
4872
|
-
notification: new ReplaySubject(),
|
4873
|
-
setSourceMap: new ReplaySubject(),
|
4874
|
-
swReady: new ReplaySubject(1),
|
4875
|
-
updated: new Subject(),
|
4876
|
-
uppercaseTags: /* @__PURE__ */ new Set()
|
4877
|
-
};
|
4878
|
-
}
|
4879
|
-
const nextMode = (mode) => {
|
4880
|
-
let next = 0;
|
4881
|
-
const currentValue = mode.getValue();
|
4882
|
-
if (currentValue === "interact") {
|
4883
|
-
next = "select";
|
4884
|
-
} else if (currentValue === "select") {
|
4885
|
-
next = "interact";
|
4886
|
-
}
|
4887
|
-
mode.next(next);
|
4888
|
-
return next;
|
4889
|
-
};
|
4890
|
-
const subjects = registerChannels();
|
4891
|
-
function parentListener(message) {
|
4892
|
-
switch (message.type) {
|
4893
|
-
case "options": {
|
4894
|
-
const { content: { disableOverlay, redirectTo, timeout } } = message;
|
4895
|
-
if (disableOverlay) {
|
4896
|
-
Object.defineProperty(this.window, "__BACKOFFICE_CONFIGURATOR_DISABLE_OVERLAY__", { value: true });
|
4897
|
-
subjects.mode.next("interact");
|
4898
|
-
}
|
4899
|
-
if (timeout !== void 0) {
|
4900
|
-
Object.defineProperty(this.window, "__BACKOFFICE_CONFIGURATOR_PREVIEW_TIMEOUT__", { value: timeout });
|
4901
|
-
}
|
4902
|
-
const { window: { history } } = this;
|
4903
|
-
this.window.navigator.serviceWorker.ready.then(() => redirectTo && history.pushState(history.state, "", redirectTo)).catch(() => {
|
4904
|
-
});
|
4905
|
-
break;
|
4906
|
-
}
|
4907
|
-
case "ctrl-space":
|
4908
|
-
nextMode(subjects.mode);
|
4909
|
-
break;
|
4910
|
-
case "new-configuration":
|
4911
|
-
subjects.configuration.next({ ...message.content, type: "reset" });
|
4912
|
-
break;
|
4913
|
-
case "update":
|
4914
|
-
subjects.configuration.next({ ...message.content, type: "update" });
|
4915
|
-
break;
|
4916
|
-
case "focus-element":
|
4917
|
-
subjects.focus.next(message.content);
|
4918
|
-
break;
|
4919
|
-
case "set-source-map": {
|
4920
|
-
const { content: { dictionary } } = message;
|
4921
|
-
subjects.setSourceMap.next({
|
4922
|
-
...message.content,
|
4923
|
-
dictionary: Object.entries(dictionary).reduce((acc, [from2, to]) => {
|
4924
|
-
try {
|
4925
|
-
const { href: fromUrl } = new URL(from2, this.window.location.href);
|
4926
|
-
const obj = typeof to === "string" ? { headers: {}, query: {}, to } : to;
|
4927
|
-
acc[fromUrl] = {
|
4928
|
-
originalFrom: from2,
|
4929
|
-
...obj
|
4930
|
-
};
|
4931
|
-
} catch (e2) {
|
4932
|
-
}
|
4933
|
-
return acc;
|
4934
|
-
}, {})
|
4935
|
-
});
|
4936
|
-
break;
|
4937
|
-
}
|
4938
|
-
}
|
4939
|
-
}
|
4940
|
-
class ServiceWorkerChannel {
|
4941
|
-
constructor(handler2) {
|
4942
|
-
__publicField$3(this, "__handler");
|
4943
|
-
__publicField$3(this, "__window");
|
4944
|
-
__publicField$3(this, "__randomColor");
|
4945
|
-
this.__handler = handler2;
|
4946
|
-
this.__window = window;
|
4947
|
-
this.__randomColor = generateDarkColorHex();
|
4948
|
-
}
|
4949
|
-
send(to, message) {
|
4950
|
-
{
|
4951
|
-
const color = this.__randomColor;
|
4952
|
-
const background = `${color}22`;
|
4953
|
-
const style = { background, color };
|
4954
|
-
console.groupCollapsed(`%c Msg to Service Worker `, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join("; "));
|
4955
|
-
console.info(`window '${this.__window.origin}' is sending a message of type %c ${message.type} `, "background: lightgreen; color: darkgreen");
|
4956
|
-
console.log(message.content);
|
4957
|
-
console.groupEnd();
|
4958
|
-
}
|
4959
|
-
to.postMessage(message);
|
4960
|
-
}
|
4961
|
-
get window() {
|
4962
|
-
return this.__window;
|
4963
|
-
}
|
4964
|
-
set window(win) {
|
4965
|
-
this.__window = win;
|
4966
|
-
}
|
4967
|
-
recv() {
|
4968
|
-
const swListener2 = ({ data }) => {
|
4969
|
-
this.__handler(data);
|
4970
|
-
};
|
4971
|
-
const { __window: { navigator: navigator2 } } = this;
|
4972
|
-
navigator2.serviceWorker.addEventListener("message", swListener2);
|
4973
|
-
return () => navigator2.serviceWorker.removeEventListener("message", swListener2);
|
4974
|
-
}
|
4975
|
-
}
|
4976
|
-
const swListener = (message) => {
|
4977
|
-
switch (message.type) {
|
4978
|
-
case "source-map-ack":
|
4979
|
-
subjects.swReady.next(0);
|
4980
|
-
break;
|
4981
|
-
}
|
4982
|
-
};
|
4983
|
-
const postChannel = new PostChannel(parentListener);
|
4984
|
-
const serviceWorkerChannel = new ServiceWorkerChannel(swListener);
|
4985
4705
|
const DEFAULT_LANGUAGE = "en";
|
4986
4706
|
const localizeText = (input, lang = DEFAULT_LANGUAGE) => {
|
4987
4707
|
if (typeof input === "string") {
|
@@ -5021,7 +4741,7 @@ function getElementBySelector(selector) {
|
|
5021
4741
|
return document.querySelector(selector);
|
5022
4742
|
}
|
5023
4743
|
const unfocus = (element, mapping) => {
|
5024
|
-
const originalStyle = mapping.get(element
|
4744
|
+
const originalStyle = mapping.get(element);
|
5025
4745
|
if (originalStyle) {
|
5026
4746
|
const { css, rest, subscription } = originalStyle;
|
5027
4747
|
rest.forEach((el) => {
|
@@ -5033,7 +4753,7 @@ const unfocus = (element, mapping) => {
|
|
5033
4753
|
Object.assign(el.style, css[idx]);
|
5034
4754
|
});
|
5035
4755
|
}
|
5036
|
-
mapping.delete(element
|
4756
|
+
mapping.delete(element);
|
5037
4757
|
};
|
5038
4758
|
const noUndefined = (input) => input !== void 0;
|
5039
4759
|
function focus(document2, obs$, mode$) {
|
@@ -5096,10 +4816,133 @@ function focus(document2, obs$, mode$) {
|
|
5096
4816
|
Object.assign(el.style, next.style);
|
5097
4817
|
});
|
5098
4818
|
}));
|
5099
|
-
stylesMap.set(firstElement
|
4819
|
+
stylesMap.set(firstElement, styles);
|
5100
4820
|
});
|
5101
4821
|
return () => subscription.unsubscribe();
|
5102
4822
|
}
|
4823
|
+
var __defProp$3 = Object.defineProperty;
|
4824
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
4825
|
+
var __publicField$3 = (obj, key, value) => {
|
4826
|
+
__defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
|
4827
|
+
return value;
|
4828
|
+
};
|
4829
|
+
let Lexer$1 = class Lexer {
|
4830
|
+
constructor(input) {
|
4831
|
+
__publicField$3(this, "_input");
|
4832
|
+
__publicField$3(this, "_length");
|
4833
|
+
__publicField$3(this, "_idx", 0);
|
4834
|
+
__publicField$3(
|
4835
|
+
this,
|
4836
|
+
"_mode",
|
4837
|
+
0
|
4838
|
+
/* Literal */
|
4839
|
+
);
|
4840
|
+
__publicField$3(this, "_literals", []);
|
4841
|
+
__publicField$3(this, "_variables", []);
|
4842
|
+
__publicField$3(this, "_braketCount", 0);
|
4843
|
+
__publicField$3(this, "_done", false);
|
4844
|
+
this._input = input;
|
4845
|
+
this._length = input.length;
|
4846
|
+
}
|
4847
|
+
concatToLastLiteral(concat) {
|
4848
|
+
this._literals.push(this._literals.pop().concat(concat));
|
4849
|
+
}
|
4850
|
+
concatToLastVariable(concat) {
|
4851
|
+
this._variables.push(this._variables.pop().concat(concat));
|
4852
|
+
}
|
4853
|
+
get() {
|
4854
|
+
const rawLiterals = [...this._literals];
|
4855
|
+
const literals = Object.assign([], rawLiterals);
|
4856
|
+
Object.defineProperty(literals, "raw", { value: rawLiterals, writable: false });
|
4857
|
+
return {
|
4858
|
+
literals,
|
4859
|
+
variables: this._variables
|
4860
|
+
};
|
4861
|
+
}
|
4862
|
+
run() {
|
4863
|
+
if (this._length === 0) {
|
4864
|
+
this._literals.push("");
|
4865
|
+
}
|
4866
|
+
while (this._idx < this._length) {
|
4867
|
+
const char = this._input.charAt(this._idx);
|
4868
|
+
switch (this._mode) {
|
4869
|
+
case 0: {
|
4870
|
+
if (this._literals.length === 0) {
|
4871
|
+
this._literals.push("");
|
4872
|
+
}
|
4873
|
+
if (char === "{" && this._idx + 1 !== this._length && this._input.charAt(this._idx + 1) === "{") {
|
4874
|
+
this._literals.push("");
|
4875
|
+
this._variables.push("");
|
4876
|
+
this._mode = 1;
|
4877
|
+
this._idx += 1;
|
4878
|
+
} else {
|
4879
|
+
this.concatToLastLiteral(char);
|
4880
|
+
}
|
4881
|
+
break;
|
4882
|
+
}
|
4883
|
+
case 1:
|
4884
|
+
if (char === "}" && this._input.charAt(this._idx + 1) === "}") {
|
4885
|
+
this._mode = 0;
|
4886
|
+
this._idx += 1;
|
4887
|
+
} else {
|
4888
|
+
this.concatToLastVariable(char);
|
4889
|
+
}
|
4890
|
+
break;
|
4891
|
+
}
|
4892
|
+
this._idx += 1;
|
4893
|
+
}
|
4894
|
+
if (this._mode === 1) {
|
4895
|
+
this._literals.pop();
|
4896
|
+
this.concatToLastLiteral(`{{${this._variables.pop()}`);
|
4897
|
+
}
|
4898
|
+
this._done = true;
|
4899
|
+
}
|
4900
|
+
};
|
4901
|
+
const isSquareBrakets = (field) => {
|
4902
|
+
const trimmed = field.trim();
|
4903
|
+
if (!(trimmed.startsWith("[") && trimmed.endsWith("]"))) {
|
4904
|
+
return false;
|
4905
|
+
}
|
4906
|
+
const inner = trimmed.slice(1).slice(0, -1).trim();
|
4907
|
+
if (Number.parseInt(inner).toString(10) !== inner) {
|
4908
|
+
return false;
|
4909
|
+
}
|
4910
|
+
return true;
|
4911
|
+
};
|
4912
|
+
const getNumber = (field) => {
|
4913
|
+
return Number.parseInt(field.trim().slice(1).slice(0, -1).trim());
|
4914
|
+
};
|
4915
|
+
function interpolate$1(context, path, preserveUnknown) {
|
4916
|
+
if (!path.trim()) {
|
4917
|
+
return preserveUnknown ? `{{${path}}}` : "";
|
4918
|
+
}
|
4919
|
+
const result = path.trim().split(".").reduce((superctx, field) => {
|
4920
|
+
if (Array.isArray(superctx) && isSquareBrakets(field)) {
|
4921
|
+
return superctx[getNumber(field)];
|
4922
|
+
}
|
4923
|
+
if (typeof superctx === "object" && superctx !== null && field in superctx) {
|
4924
|
+
return superctx[field];
|
4925
|
+
}
|
4926
|
+
return void 0;
|
4927
|
+
}, { ...context });
|
4928
|
+
if (typeof result === "string") {
|
4929
|
+
return result;
|
4930
|
+
}
|
4931
|
+
return preserveUnknown ? `{{${path}}}` : "";
|
4932
|
+
}
|
4933
|
+
function parse(input, context, preserveUnknown = false) {
|
4934
|
+
const lexer2 = new Lexer$1(input);
|
4935
|
+
lexer2.run();
|
4936
|
+
const template = lexer2.get();
|
4937
|
+
let [acc] = template.literals;
|
4938
|
+
for (let i2 = 0; i2 < template.variables.length; i2++) {
|
4939
|
+
acc = acc.concat(interpolate$1(context, template.variables[i2], preserveUnknown)).concat(template.literals[i2 + 1]);
|
4940
|
+
}
|
4941
|
+
return acc;
|
4942
|
+
}
|
4943
|
+
const compileObject = (obj, context) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, parse(value, context)]));
|
4944
|
+
const MIA_PREVIEW_ID = "__mia_preview_id";
|
4945
|
+
const OVERLAY_Z_INDEX = 1e6;
|
5103
4946
|
var t;
|
5104
4947
|
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}*(?:[^
|
5105
4948
|
\f\r"'\`<>=]|("|')|))|$)`, "g"), g = /'/g, $ = /"/g, y = /^(?:script|style|textarea|title)$/i, w = (t2) => (i2, ...s2) => ({ _$litType$: t2, strings: i2, values: s2 }), x = w(1), T = Symbol.for("lit-noChange"), A = Symbol.for("lit-nothing"), E = /* @__PURE__ */ new WeakMap(), C = r.createTreeWalker(r, 129, null, false), P = (t2, i2) => {
|
@@ -5179,7 +5022,7 @@ function N(t2, i2, s2 = t2, e2) {
|
|
5179
5022
|
}
|
5180
5023
|
class S {
|
5181
5024
|
constructor(t2, i2) {
|
5182
|
-
this.
|
5025
|
+
this._$AV = [], this._$AN = void 0, this._$AD = t2, this._$AM = i2;
|
5183
5026
|
}
|
5184
5027
|
get parentNode() {
|
5185
5028
|
return this._$AM.parentNode;
|
@@ -5187,7 +5030,7 @@ class S {
|
|
5187
5030
|
get _$AU() {
|
5188
5031
|
return this._$AM._$AU;
|
5189
5032
|
}
|
5190
|
-
|
5033
|
+
u(t2) {
|
5191
5034
|
var i2;
|
5192
5035
|
const { el: { content: s2 }, parts: e2 } = this._$AD, o2 = (null !== (i2 = null == t2 ? void 0 : t2.creationScope) && void 0 !== i2 ? i2 : r).importNode(s2, true);
|
5193
5036
|
C.currentNode = o2;
|
@@ -5195,26 +5038,26 @@ class S {
|
|
5195
5038
|
for (; void 0 !== d2; ) {
|
5196
5039
|
if (l2 === d2.index) {
|
5197
5040
|
let i3;
|
5198
|
-
2 === d2.type ? i3 = new M(n2, n2.nextSibling, this, t2) : 1 === d2.type ? i3 = new d2.ctor(n2, d2.name, d2.strings, this, t2) : 6 === d2.type && (i3 = new z(n2, this, t2)), this.
|
5041
|
+
2 === d2.type ? i3 = new M(n2, n2.nextSibling, this, t2) : 1 === d2.type ? i3 = new d2.ctor(n2, d2.name, d2.strings, this, t2) : 6 === d2.type && (i3 = new z(n2, this, t2)), this._$AV.push(i3), d2 = e2[++h2];
|
5199
5042
|
}
|
5200
5043
|
l2 !== (null == d2 ? void 0 : d2.index) && (n2 = C.nextNode(), l2++);
|
5201
5044
|
}
|
5202
|
-
return o2;
|
5045
|
+
return C.currentNode = r, o2;
|
5203
5046
|
}
|
5204
|
-
|
5047
|
+
v(t2) {
|
5205
5048
|
let i2 = 0;
|
5206
|
-
for (const s2 of this.
|
5049
|
+
for (const s2 of this._$AV)
|
5207
5050
|
void 0 !== s2 && (void 0 !== s2.strings ? (s2._$AI(t2, s2, i2), i2 += s2.strings.length - 2) : s2._$AI(t2[i2])), i2++;
|
5208
5051
|
}
|
5209
5052
|
}
|
5210
5053
|
class M {
|
5211
5054
|
constructor(t2, i2, s2, e2) {
|
5212
5055
|
var o2;
|
5213
|
-
this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s2, this.options = e2, this._$
|
5056
|
+
this.type = 2, this._$AH = A, this._$AN = void 0, this._$AA = t2, this._$AB = i2, this._$AM = s2, this.options = e2, this._$Cp = null === (o2 = null == e2 ? void 0 : e2.isConnected) || void 0 === o2 || o2;
|
5214
5057
|
}
|
5215
5058
|
get _$AU() {
|
5216
5059
|
var t2, i2;
|
5217
|
-
return null !== (i2 = null === (t2 = this._$AM) || void 0 === t2 ? void 0 : t2._$AU) && void 0 !== i2 ? i2 : this._$
|
5060
|
+
return null !== (i2 = null === (t2 = this._$AM) || void 0 === t2 ? void 0 : t2._$AU) && void 0 !== i2 ? i2 : this._$Cp;
|
5218
5061
|
}
|
5219
5062
|
get parentNode() {
|
5220
5063
|
let t2 = this._$AA.parentNode;
|
@@ -5228,37 +5071,37 @@ class M {
|
|
5228
5071
|
return this._$AB;
|
5229
5072
|
}
|
5230
5073
|
_$AI(t2, i2 = this) {
|
5231
|
-
t2 = N(this, t2, i2), u(t2) ? t2 === A || null == t2 || "" === t2 ? (this._$AH !== A && this._$AR(), this._$AH = A) : t2 !== this._$AH && t2 !== T && this.
|
5074
|
+
t2 = N(this, t2, i2), u(t2) ? t2 === A || null == t2 || "" === t2 ? (this._$AH !== A && this._$AR(), this._$AH = A) : t2 !== this._$AH && t2 !== T && this._(t2) : void 0 !== t2._$litType$ ? this.g(t2) : void 0 !== t2.nodeType ? this.$(t2) : v(t2) ? this.T(t2) : this._(t2);
|
5232
5075
|
}
|
5233
|
-
|
5076
|
+
k(t2) {
|
5234
5077
|
return this._$AA.parentNode.insertBefore(t2, this._$AB);
|
5235
5078
|
}
|
5236
|
-
|
5237
|
-
this._$AH !== t2 && (this._$AR(), this._$AH = this.
|
5079
|
+
$(t2) {
|
5080
|
+
this._$AH !== t2 && (this._$AR(), this._$AH = this.k(t2));
|
5238
5081
|
}
|
5239
|
-
|
5240
|
-
this._$AH !== A && u(this._$AH) ? this._$AA.nextSibling.data = t2 : this
|
5082
|
+
_(t2) {
|
5083
|
+
this._$AH !== A && u(this._$AH) ? this._$AA.nextSibling.data = t2 : this.$(r.createTextNode(t2)), this._$AH = t2;
|
5241
5084
|
}
|
5242
|
-
|
5085
|
+
g(t2) {
|
5243
5086
|
var i2;
|
5244
5087
|
const { values: s2, _$litType$: e2 } = t2, o2 = "number" == typeof e2 ? this._$AC(t2) : (void 0 === e2.el && (e2.el = V.createElement(e2.h, this.options)), e2);
|
5245
5088
|
if ((null === (i2 = this._$AH) || void 0 === i2 ? void 0 : i2._$AD) === o2)
|
5246
|
-
this._$AH.
|
5089
|
+
this._$AH.v(s2);
|
5247
5090
|
else {
|
5248
|
-
const t3 = new S(o2, this), i3 = t3.
|
5249
|
-
t3.
|
5091
|
+
const t3 = new S(o2, this), i3 = t3.u(this.options);
|
5092
|
+
t3.v(s2), this.$(i3), this._$AH = t3;
|
5250
5093
|
}
|
5251
5094
|
}
|
5252
5095
|
_$AC(t2) {
|
5253
5096
|
let i2 = E.get(t2.strings);
|
5254
5097
|
return void 0 === i2 && E.set(t2.strings, i2 = new V(t2)), i2;
|
5255
5098
|
}
|
5256
|
-
|
5099
|
+
T(t2) {
|
5257
5100
|
c(this._$AH) || (this._$AH = [], this._$AR());
|
5258
5101
|
const i2 = this._$AH;
|
5259
5102
|
let s2, e2 = 0;
|
5260
5103
|
for (const o2 of t2)
|
5261
|
-
e2 === i2.length ? i2.push(s2 = new M(this.
|
5104
|
+
e2 === i2.length ? i2.push(s2 = new M(this.k(d()), this.k(d()), this, this.options)) : s2 = i2[e2], s2._$AI(o2), e2++;
|
5262
5105
|
e2 < i2.length && (this._$AR(s2 && s2._$AB.nextSibling, e2), i2.length = e2);
|
5263
5106
|
}
|
5264
5107
|
_$AR(t2 = this._$AA.nextSibling, i2) {
|
@@ -5270,7 +5113,7 @@ class M {
|
|
5270
5113
|
}
|
5271
5114
|
setConnected(t2) {
|
5272
5115
|
var i2;
|
5273
|
-
void 0 === this._$AM && (this._$
|
5116
|
+
void 0 === this._$AM && (this._$Cp = t2, null === (i2 = this._$AP) || void 0 === i2 || i2.call(this, t2));
|
5274
5117
|
}
|
5275
5118
|
}
|
5276
5119
|
class R {
|
@@ -5345,7 +5188,7 @@ class z {
|
|
5345
5188
|
}
|
5346
5189
|
}
|
5347
5190
|
const j = i.litHtmlPolyfillSupport;
|
5348
|
-
null == j || j(V, M), (null !== (t = i.litHtmlVersions) && void 0 !== t ? t : i.litHtmlVersions = []).push("2.7.
|
5191
|
+
null == j || j(V, M), (null !== (t = i.litHtmlVersions) && void 0 !== t ? t : i.litHtmlVersions = []).push("2.7.4");
|
5349
5192
|
const B = (t2, i2, s2) => {
|
5350
5193
|
var e2, o2;
|
5351
5194
|
const n2 = null !== (e2 = null == s2 ? void 0 : s2.renderBefore) && void 0 !== e2 ? e2 : i2;
|
@@ -5553,7 +5396,7 @@ const __vitePreload = function preload(baseModule, deps, importerUrl) {
|
|
5553
5396
|
})).then(() => baseModule());
|
5554
5397
|
};
|
5555
5398
|
function error(message, ...args) {
|
5556
|
-
__vitePreload(() => import("./
|
5399
|
+
__vitePreload(() => import("./errors-5a0ccde7.js"), true ? [] : void 0, import.meta.url).then(({ default: errorMap }) => {
|
5557
5400
|
const handler2 = errorMap[message];
|
5558
5401
|
handler2 ? console.error(handler2(...args)) : console.error(...args);
|
5559
5402
|
}).catch((err) => {
|
@@ -5567,12 +5410,12 @@ function dynamicImportError(name) {
|
|
5567
5410
|
error("0", name, err.message);
|
5568
5411
|
};
|
5569
5412
|
}
|
5570
|
-
const logger
|
5413
|
+
const logger = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
5571
5414
|
__proto__: null,
|
5572
5415
|
dynamicImportError,
|
5573
5416
|
error
|
5574
5417
|
}, Symbol.toStringTag, { value: "Module" }));
|
5575
|
-
var logger_default = logger
|
5418
|
+
var logger_default = logger;
|
5576
5419
|
var __defProp$2 = Object.defineProperty;
|
5577
5420
|
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
5578
5421
|
var __publicField$2 = (obj, key, value) => {
|
@@ -5807,17 +5650,17 @@ const fromErrorToNotification = (error2) => {
|
|
5807
5650
|
status: "error"
|
5808
5651
|
};
|
5809
5652
|
};
|
5810
|
-
const errorHandler = (
|
5653
|
+
const errorHandler = (channel, error2) => channel.send({
|
5811
5654
|
content: fromErrorToNotification(error2),
|
5812
5655
|
type: "notification"
|
5813
5656
|
});
|
5814
5657
|
const isRealMouseEvent = (event) => "clientX" in event && "clientY" in event;
|
5815
|
-
function mouseEventFactory(
|
5658
|
+
function mouseEventFactory(channel, type) {
|
5816
5659
|
return (event) => {
|
5817
5660
|
if (!isRealMouseEvent(event)) {
|
5818
5661
|
return;
|
5819
5662
|
}
|
5820
|
-
|
5663
|
+
channel.send({
|
5821
5664
|
content: {
|
5822
5665
|
bubbles: true,
|
5823
5666
|
cancelable: false,
|
@@ -5829,7 +5672,7 @@ function mouseEventFactory(self2, type) {
|
|
5829
5672
|
};
|
5830
5673
|
}
|
5831
5674
|
const isControlledElement = (tags, element) => tags.has(element.tagName) && element.hasAttribute(MIA_PREVIEW_ID);
|
5832
|
-
const mouseOnElementFactory = (self2, channels) => {
|
5675
|
+
const mouseOnElementFactory = (self2, postChannel, channels) => {
|
5833
5676
|
const { document: document2 } = self2;
|
5834
5677
|
return (event) => {
|
5835
5678
|
let content;
|
@@ -5845,13 +5688,287 @@ const mouseOnElementFactory = (self2, channels) => {
|
|
5845
5688
|
}, { ids: [], selectors: [] });
|
5846
5689
|
}
|
5847
5690
|
if (channels.mode.getValue() === "select" || content === void 0) {
|
5848
|
-
postChannel.send(
|
5691
|
+
postChannel.send({
|
5849
5692
|
content: content && (content.ids.length > 0 ? content : void 0),
|
5850
5693
|
type: "click-element"
|
5851
5694
|
});
|
5852
5695
|
}
|
5853
5696
|
};
|
5854
5697
|
};
|
5698
|
+
var fromWindowToReceiver = (self2, options) => {
|
5699
|
+
return {
|
5700
|
+
postMessage: (message) => {
|
5701
|
+
self2.postMessage(message, (options == null ? void 0 : options.targetOrigin) ?? "*", options == null ? void 0 : options.transfer);
|
5702
|
+
}
|
5703
|
+
};
|
5704
|
+
};
|
5705
|
+
var SynAck = /* @__PURE__ */ ((SynAck2) => {
|
5706
|
+
SynAck2["Ack"] = "ack";
|
5707
|
+
SynAck2["Syn"] = "syn";
|
5708
|
+
return SynAck2;
|
5709
|
+
})(SynAck || {});
|
5710
|
+
var synackKeys = Object.values(SynAck);
|
5711
|
+
var getData = (message) => message.data;
|
5712
|
+
var synackFilter = (type) => (data) => data.type === type.toString();
|
5713
|
+
var isPostChannelMessage = (message) => {
|
5714
|
+
const data = message.data;
|
5715
|
+
return typeof data === "object" && data !== null && "type" in data && typeof data.type === "string" && "instance" in data && typeof data.instance === "string" && "content" in data;
|
5716
|
+
};
|
5717
|
+
var generateDarkColorHex = () => {
|
5718
|
+
let color = "#";
|
5719
|
+
for (let i2 = 0; i2 < 3; i2++) {
|
5720
|
+
color += `0${Math.floor(Math.random() * Math.pow(16, 2) / 2).toString(16)}`.slice(-2);
|
5721
|
+
}
|
5722
|
+
return color;
|
5723
|
+
};
|
5724
|
+
var PostChannel = class {
|
5725
|
+
constructor(listener, from2, to, opts) {
|
5726
|
+
__publicField(this, "__generateId");
|
5727
|
+
__publicField(this, "__instance");
|
5728
|
+
__publicField(this, "__colors");
|
5729
|
+
__publicField(this, "__listener");
|
5730
|
+
__publicField(this, "__log");
|
5731
|
+
__publicField(this, "__receiver");
|
5732
|
+
__publicField(this, "__subscription");
|
5733
|
+
__publicField(this, "__okToWrite");
|
5734
|
+
__publicField(this, "__write$");
|
5735
|
+
__publicField(this, "__recv$");
|
5736
|
+
this.__generateId = () => globalThis.crypto.randomUUID();
|
5737
|
+
const instance = this.__generateId();
|
5738
|
+
const messages = new ReplaySubject();
|
5739
|
+
const fromSubscription = fromEvent(from2, "message").pipe(filter(isPostChannelMessage)).subscribe(messages);
|
5740
|
+
this.__subscription = new Subscription();
|
5741
|
+
this.__subscription.add(fromSubscription);
|
5742
|
+
this.__okToWrite = new ReplaySubject(1);
|
5743
|
+
this.__write$ = this.__okToWrite.pipe(take(1));
|
5744
|
+
this.__recv$ = messages.asObservable();
|
5745
|
+
this.__listener = listener;
|
5746
|
+
this.__log = (opts == null ? void 0 : opts.log) && opts.log.bind(this);
|
5747
|
+
this.__instance = instance;
|
5748
|
+
const color = generateDarkColorHex();
|
5749
|
+
this.__colors = {
|
5750
|
+
bg: color,
|
5751
|
+
fg: `${color}22`
|
5752
|
+
};
|
5753
|
+
this.__receiver = to;
|
5754
|
+
this.__connect(
|
5755
|
+
instance,
|
5756
|
+
(opts == null ? void 0 : opts.period) ? opts.period : 10
|
5757
|
+
);
|
5758
|
+
}
|
5759
|
+
__connect(instance, period) {
|
5760
|
+
const synSubscription = interval(period).subscribe(() => this.__receiver.postMessage({
|
5761
|
+
content: instance,
|
5762
|
+
instance,
|
5763
|
+
type: "syn".toString()
|
5764
|
+
}));
|
5765
|
+
this.__subscription.add(synSubscription);
|
5766
|
+
this.__subscription.add(
|
5767
|
+
this.__recv$.pipe(
|
5768
|
+
map(getData),
|
5769
|
+
filter(synackFilter(
|
5770
|
+
"ack"
|
5771
|
+
/* Ack */
|
5772
|
+
)),
|
5773
|
+
filter(({ content }) => content === instance),
|
5774
|
+
take(1)
|
5775
|
+
).subscribe(({ instance: foreignInstance }) => {
|
5776
|
+
this.__okToWrite.next(0);
|
5777
|
+
this.__subscription.add(
|
5778
|
+
this.__recv$.pipe(
|
5779
|
+
filter(
|
5780
|
+
({ data: { type, instance: incomingInstance } }) => !synackKeys.includes(type) && incomingInstance === foreignInstance
|
5781
|
+
)
|
5782
|
+
).subscribe((message) => {
|
5783
|
+
this.__listener(message);
|
5784
|
+
const { data } = message;
|
5785
|
+
if (data._id !== void 0) {
|
5786
|
+
this.__receiver.postMessage({
|
5787
|
+
...data,
|
5788
|
+
content: data,
|
5789
|
+
instance,
|
5790
|
+
type: "ack"
|
5791
|
+
/* Ack */
|
5792
|
+
});
|
5793
|
+
}
|
5794
|
+
})
|
5795
|
+
);
|
5796
|
+
synSubscription.unsubscribe();
|
5797
|
+
})
|
5798
|
+
);
|
5799
|
+
this.__subscription.add(
|
5800
|
+
this.__recv$.pipe(
|
5801
|
+
map(getData),
|
5802
|
+
filter(synackFilter(
|
5803
|
+
"syn"
|
5804
|
+
/* Syn */
|
5805
|
+
)),
|
5806
|
+
// must check whether is not short-circuiting
|
5807
|
+
// in an infinite loop by syncing with itself
|
5808
|
+
filter(({ instance: foreignInstance }) => foreignInstance !== instance),
|
5809
|
+
take(1)
|
5810
|
+
).subscribe(({ content }) => {
|
5811
|
+
this.__receiver.postMessage({
|
5812
|
+
content,
|
5813
|
+
instance,
|
5814
|
+
type: "ack"
|
5815
|
+
/* Ack */
|
5816
|
+
});
|
5817
|
+
})
|
5818
|
+
);
|
5819
|
+
}
|
5820
|
+
__write(message, messageId) {
|
5821
|
+
const extra = {};
|
5822
|
+
if (messageId !== void 0) {
|
5823
|
+
extra._id = messageId;
|
5824
|
+
}
|
5825
|
+
this.__subscription.add(
|
5826
|
+
this.__write$.subscribe(() => {
|
5827
|
+
var _a2;
|
5828
|
+
const outgoingMessage = Object.assign(
|
5829
|
+
message,
|
5830
|
+
{
|
5831
|
+
instance: this.__instance,
|
5832
|
+
...extra
|
5833
|
+
}
|
5834
|
+
);
|
5835
|
+
this.__receiver.postMessage(outgoingMessage);
|
5836
|
+
(_a2 = this.__log) == null ? void 0 : _a2.call(this, outgoingMessage);
|
5837
|
+
})
|
5838
|
+
);
|
5839
|
+
}
|
5840
|
+
disconnect() {
|
5841
|
+
this.__subscription.unsubscribe();
|
5842
|
+
}
|
5843
|
+
send(message) {
|
5844
|
+
this.__write(message);
|
5845
|
+
}
|
5846
|
+
ackSend(message) {
|
5847
|
+
let done;
|
5848
|
+
const promise = new Promise((resolve) => {
|
5849
|
+
done = resolve;
|
5850
|
+
});
|
5851
|
+
const messageId = this.__generateId();
|
5852
|
+
this.__subscription.add(
|
5853
|
+
this.__recv$.pipe(
|
5854
|
+
map(getData),
|
5855
|
+
filter(synackFilter(
|
5856
|
+
"ack"
|
5857
|
+
/* Ack */
|
5858
|
+
)),
|
5859
|
+
filter(({ _id }) => _id === messageId),
|
5860
|
+
take(1)
|
5861
|
+
).subscribe(() => done())
|
5862
|
+
);
|
5863
|
+
this.__write(message, messageId);
|
5864
|
+
return promise;
|
5865
|
+
}
|
5866
|
+
get instance() {
|
5867
|
+
return this.__instance;
|
5868
|
+
}
|
5869
|
+
get colors() {
|
5870
|
+
return this.__colors;
|
5871
|
+
}
|
5872
|
+
/**
|
5873
|
+
* signals readiness on listening and cannot fail but keeps hanging
|
5874
|
+
* if not resolved
|
5875
|
+
*/
|
5876
|
+
get ready() {
|
5877
|
+
return firstValueFrom(this.__write$).then(() => {
|
5878
|
+
});
|
5879
|
+
}
|
5880
|
+
};
|
5881
|
+
var src_default = PostChannel;
|
5882
|
+
const registerChannels = () => ({
|
5883
|
+
configuration: new ReplaySubject(),
|
5884
|
+
focus: new BehaviorSubject(void 0),
|
5885
|
+
infos: new ReplaySubject(),
|
5886
|
+
mocks: new ReplaySubject(),
|
5887
|
+
mode: new BehaviorSubject("select"),
|
5888
|
+
notification: new ReplaySubject(),
|
5889
|
+
setSourceMap: new ReplaySubject(1),
|
5890
|
+
swSourceMapAck: new ReplaySubject(1),
|
5891
|
+
updated: new Subject(),
|
5892
|
+
uppercaseTags: /* @__PURE__ */ new Set()
|
5893
|
+
});
|
5894
|
+
const nextMode = (mode) => {
|
5895
|
+
let next = 0;
|
5896
|
+
const currentValue = mode.getValue();
|
5897
|
+
if (currentValue === "interact") {
|
5898
|
+
next = "select";
|
5899
|
+
} else if (currentValue === "select") {
|
5900
|
+
next = "interact";
|
5901
|
+
}
|
5902
|
+
mode.next(next);
|
5903
|
+
return next;
|
5904
|
+
};
|
5905
|
+
const swMakeListener = (_2) => (message) => {
|
5906
|
+
const { data } = message;
|
5907
|
+
switch (data.type) {
|
5908
|
+
}
|
5909
|
+
};
|
5910
|
+
const registerServiceWorker = async (self2, channels) => {
|
5911
|
+
const { navigator: { serviceWorker: sw } } = self2;
|
5912
|
+
return Promise.all([
|
5913
|
+
sw.register("./service-worker.js"),
|
5914
|
+
sw.ready.then((registration) => {
|
5915
|
+
if (!registration.active) {
|
5916
|
+
throw new TypeError("smth went wrong on sw activation");
|
5917
|
+
}
|
5918
|
+
return new src_default(swMakeListener(), window.navigator.serviceWorker, registration.active);
|
5919
|
+
})
|
5920
|
+
]).then(([, channel]) => channel);
|
5921
|
+
};
|
5922
|
+
const parentMakeListener = (self2, channels) => (message) => {
|
5923
|
+
const { data } = message;
|
5924
|
+
switch (data.type) {
|
5925
|
+
case "options": {
|
5926
|
+
const { content: { disableOverlay, redirectTo, timeout, run: run2 } } = data;
|
5927
|
+
if (run2) {
|
5928
|
+
channels.swSourceMapAck.next(0);
|
5929
|
+
}
|
5930
|
+
if (disableOverlay) {
|
5931
|
+
Object.defineProperty(self2, "__BACKOFFICE_CONFIGURATOR_DISABLE_OVERLAY__", { value: true });
|
5932
|
+
channels.mode.next("interact");
|
5933
|
+
}
|
5934
|
+
if (timeout !== void 0) {
|
5935
|
+
Object.defineProperty(self2, "__BACKOFFICE_CONFIGURATOR_PREVIEW_TIMEOUT__", { value: timeout });
|
5936
|
+
}
|
5937
|
+
const { history } = self2;
|
5938
|
+
redirectTo && history.pushState(history.state, "", redirectTo);
|
5939
|
+
break;
|
5940
|
+
}
|
5941
|
+
case "ctrl-space":
|
5942
|
+
nextMode(channels.mode);
|
5943
|
+
break;
|
5944
|
+
case "new-configuration":
|
5945
|
+
channels.configuration.next({ ...data.content, type: "reset" });
|
5946
|
+
break;
|
5947
|
+
case "update":
|
5948
|
+
channels.configuration.next({ ...data.content, type: "update" });
|
5949
|
+
break;
|
5950
|
+
case "focus-element":
|
5951
|
+
channels.focus.next(data.content);
|
5952
|
+
break;
|
5953
|
+
case "set-source-map": {
|
5954
|
+
const { content } = data;
|
5955
|
+
channels.setSourceMap.next(Object.entries(content).reduce((acc, [from2, to]) => {
|
5956
|
+
try {
|
5957
|
+
const { href: fromUrl } = new URL(from2, self2.location.href);
|
5958
|
+
const obj = typeof to === "string" ? { headers: {}, query: {}, to } : to;
|
5959
|
+
acc[fromUrl] = {
|
5960
|
+
originalFrom: from2,
|
5961
|
+
...obj
|
5962
|
+
};
|
5963
|
+
} catch (e2) {
|
5964
|
+
}
|
5965
|
+
return acc;
|
5966
|
+
}, {}));
|
5967
|
+
break;
|
5968
|
+
}
|
5969
|
+
}
|
5970
|
+
};
|
5971
|
+
const registerParent = (self2, channels) => new src_default(parentMakeListener(self2, channels), self2, fromWindowToReceiver(self2.parent));
|
5855
5972
|
const ctrlSpaceFactory = (channels) => {
|
5856
5973
|
return (evt) => {
|
5857
5974
|
if (evt.ctrlKey && evt.key === " ") {
|
@@ -5882,49 +5999,42 @@ const requireInfo = (registry, tags) => from(tags.map((tag) => [tag, registry.wh
|
|
5882
5999
|
mergeMap(extractManifest)
|
5883
6000
|
);
|
5884
6001
|
const BUFFER_TIME = 500;
|
5885
|
-
|
6002
|
+
const reporter = (postChannel, err) => {
|
5886
6003
|
if (err instanceof Error) {
|
5887
|
-
errorHandler(
|
6004
|
+
errorHandler(postChannel, err);
|
5888
6005
|
}
|
5889
|
-
}
|
5890
|
-
|
5891
|
-
|
5892
|
-
|
5893
|
-
|
5894
|
-
|
5895
|
-
|
5896
|
-
|
5897
|
-
|
5898
|
-
|
5899
|
-
)
|
5900
|
-
|
5901
|
-
|
5902
|
-
|
5903
|
-
}
|
5904
|
-
|
5905
|
-
|
5906
|
-
|
5907
|
-
|
5908
|
-
|
5909
|
-
|
5910
|
-
|
5911
|
-
|
5912
|
-
next: (mockPair) => {
|
5913
|
-
subjects.mocks.next(mockPair);
|
5914
|
-
}
|
5915
|
-
});
|
5916
|
-
}
|
5917
|
-
async function bootstrap(config2, {
|
6006
|
+
};
|
6007
|
+
const collectInfos = (postChannel, info$, addInfo) => info$.pipe(
|
6008
|
+
mergeMap(([, { __manifest: { label, description, ...rest }, tag }]) => {
|
6009
|
+
delete rest.mocks;
|
6010
|
+
return of({ info: { ...translateObject({ description, label }), ...rest }, tag });
|
6011
|
+
}),
|
6012
|
+
bufferTime(BUFFER_TIME),
|
6013
|
+
filter((newInfos) => newInfos.length > 0)
|
6014
|
+
).subscribe({
|
6015
|
+
error: (error2) => reporter(postChannel, error2),
|
6016
|
+
next: (extras) => addInfo(extras)
|
6017
|
+
});
|
6018
|
+
const collectMocks = (postChannel, subjects, info$) => info$.pipe(
|
6019
|
+
map(
|
6020
|
+
([, { __manifest: { mocks = {} }, tag }]) => [tag, mocks]
|
6021
|
+
)
|
6022
|
+
).subscribe({
|
6023
|
+
error: (error2) => reporter(postChannel, error2),
|
6024
|
+
next: (mockPair) => {
|
6025
|
+
subjects.mocks.next(mockPair);
|
6026
|
+
}
|
6027
|
+
});
|
6028
|
+
async function bootstrap(postChannel, channels, config2, {
|
5918
6029
|
addInfo,
|
5919
6030
|
tags
|
5920
6031
|
}) {
|
5921
6032
|
const { subscription } = this;
|
5922
|
-
const boundReporter = reporter.bind(this);
|
5923
6033
|
if (config2) {
|
5924
6034
|
const info$ = requireInfo(this.customElements, tags);
|
5925
|
-
return premount(config2, this,
|
5926
|
-
subscription.add(collectInfos
|
5927
|
-
subscription.add(collectMocks
|
6035
|
+
return premount(config2, this, (err) => reporter(postChannel, err)).then(() => {
|
6036
|
+
subscription.add(collectInfos(postChannel, info$, addInfo));
|
6037
|
+
subscription.add(collectMocks(postChannel, channels, info$));
|
5928
6038
|
});
|
5929
6039
|
}
|
5930
6040
|
}
|
@@ -5933,9 +6043,7 @@ const getPreviewContainer = (frame, root) => {
|
|
5933
6043
|
let container = root.firstElementChild;
|
5934
6044
|
if (container === null) {
|
5935
6045
|
container = document2.createElement("div");
|
5936
|
-
container.style.height = "
|
5937
|
-
container.style.width = "100%";
|
5938
|
-
container.style.overflow = "auto";
|
6046
|
+
container.style.height = "inherit";
|
5939
6047
|
container.style.display = "flex";
|
5940
6048
|
root.appendChild(container);
|
5941
6049
|
}
|
@@ -5966,7 +6074,7 @@ function fetchMockFactory(instance, fetchFactory, windowHref) {
|
|
5966
6074
|
var _a2;
|
5967
6075
|
const info = compileObject({ ...url, method }, context);
|
5968
6076
|
const matcher = new URL(info.pathname, (_a2 = info.origin) != null ? _a2 : windowHref);
|
5969
|
-
return [matcher.href, method, (injectedInfo,
|
6077
|
+
return [matcher.href, method, (injectedInfo, init) => fetchHandler(injectedInfo, init).finally(() => {
|
5970
6078
|
if (notify) {
|
5971
6079
|
this.notify(fetchNotification(method, matcher));
|
5972
6080
|
}
|
@@ -6043,12 +6151,12 @@ const printHeaders = (headers) => {
|
|
6043
6151
|
});
|
6044
6152
|
return JSON.stringify(obj);
|
6045
6153
|
};
|
6046
|
-
const fetchPrint = (window2, url,
|
6154
|
+
const fetchPrint = (window2, url, init, resHeaders = new Headers()) => {
|
6047
6155
|
var _a2;
|
6048
6156
|
const style = window2.origin === "null" ? { background: "antiquewhite", color: "brown" } : { background: "cyan", color: "blue" };
|
6049
6157
|
console.groupCollapsed(`%c Fetching from ${window2.origin} `, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join("; "));
|
6050
6158
|
console.info(
|
6051
|
-
`a component fetched with method ${(_a2 =
|
6159
|
+
`a component fetched with method ${(_a2 = init == null ? void 0 : init.method) != null ? _a2 : "GET"} resource at %c ${url.href} got a response with headers ${printHeaders(resHeaders)}`,
|
6052
6160
|
"background: lightgreen; color: darkgreen"
|
6053
6161
|
);
|
6054
6162
|
console.groupEnd();
|
@@ -6060,7 +6168,7 @@ const notFoundTagNotification = (tag) => ({
|
|
6060
6168
|
message: "preview.notifications.no-webcomponent-definition.message",
|
6061
6169
|
status: "warning"
|
6062
6170
|
});
|
6063
|
-
async function mock(contexts, tags = []) {
|
6171
|
+
async function mock(postChannel, subjects, contexts, tags = []) {
|
6064
6172
|
const { location: { href }, fetch: originalFetch } = this;
|
6065
6173
|
const urlMaker = urlMakerFactory(this);
|
6066
6174
|
const store = new FetchMockStore(this.notify.bind(this));
|
@@ -6084,21 +6192,21 @@ async function mock(contexts, tags = []) {
|
|
6084
6192
|
const instancesCarryingMocks = (_a2 = contexts.get(tag)) != null ? _a2 : [];
|
6085
6193
|
return handler(store, instancesCarryingMocks, fetchFactory, href);
|
6086
6194
|
})).catch(
|
6087
|
-
(error2) => error2 instanceof Error && errorHandler(
|
6195
|
+
(error2) => error2 instanceof Error && errorHandler(postChannel, error2)
|
6088
6196
|
);
|
6089
|
-
const mockedFetch = async (info,
|
6197
|
+
const mockedFetch = async (info, init) => {
|
6090
6198
|
var _a2;
|
6091
6199
|
const url = toURL(urlMaker, info);
|
6092
|
-
const mockImplementation = store.match({ method: (_a2 =
|
6200
|
+
const mockImplementation = store.match({ method: (_a2 = init == null ? void 0 : init.method) != null ? _a2 : "GET", url });
|
6093
6201
|
if (mockImplementation !== void 0) {
|
6094
|
-
return mockImplementation(url,
|
6202
|
+
return mockImplementation(url, init).then((res) => {
|
6095
6203
|
{
|
6096
|
-
fetchPrint(this, url,
|
6204
|
+
fetchPrint(this, url, init, res.headers);
|
6097
6205
|
}
|
6098
6206
|
return res;
|
6099
6207
|
});
|
6100
6208
|
}
|
6101
|
-
return originalFetch(info,
|
6209
|
+
return originalFetch(info, init);
|
6102
6210
|
};
|
6103
6211
|
if (this.proxyWindow) {
|
6104
6212
|
const newFetch = Object.assign(
|
@@ -6282,10 +6390,10 @@ function wrap(frame, notification) {
|
|
6282
6390
|
const unpatch = domPatch(sandbox);
|
6283
6391
|
return { sandbox, unpatch };
|
6284
6392
|
}
|
6285
|
-
var
|
6286
|
-
var
|
6287
|
-
var
|
6288
|
-
|
6393
|
+
var __defProp2 = Object.defineProperty;
|
6394
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
6395
|
+
var __publicField2 = (obj, key, value) => {
|
6396
|
+
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
6289
6397
|
return value;
|
6290
6398
|
};
|
6291
6399
|
function appendOverlay(self2, mode$) {
|
@@ -6327,8 +6435,9 @@ function appendOverlay(self2, mode$) {
|
|
6327
6435
|
}
|
6328
6436
|
const appendRenderRoot = (document2) => {
|
6329
6437
|
const renderRoot = document2.createElement("div");
|
6438
|
+
renderRoot.style.display = "flex";
|
6439
|
+
renderRoot.style.flexDirection = "column";
|
6330
6440
|
renderRoot.style.height = "inherit";
|
6331
|
-
renderRoot.style.width = "inherit";
|
6332
6441
|
document2.body.appendChild(renderRoot);
|
6333
6442
|
return renderRoot;
|
6334
6443
|
};
|
@@ -6344,8 +6453,8 @@ function createLifecycle(frame) {
|
|
6344
6453
|
}
|
6345
6454
|
class Queue {
|
6346
6455
|
constructor() {
|
6347
|
-
|
6348
|
-
|
6456
|
+
__publicField2(this, "_results", /* @__PURE__ */ new Map());
|
6457
|
+
__publicField2(this, "_queue", Promise.resolve());
|
6349
6458
|
}
|
6350
6459
|
add(args) {
|
6351
6460
|
const fns = [...args];
|
@@ -6383,12 +6492,9 @@ const addInfoFactory = (channels) => (info) => {
|
|
6383
6492
|
channels.infos.next(info);
|
6384
6493
|
info.forEach(({ tag }) => channels.uppercaseTags.add(tag.toUpperCase()));
|
6385
6494
|
};
|
6386
|
-
const run = (frame, renderRoot, channels) => {
|
6495
|
+
const run = (frame, renderRoot, postChannel, channels) => {
|
6387
6496
|
const queue = new Queue();
|
6388
|
-
const subscription = channels.configuration.pipe(
|
6389
|
-
combineLatestWith(subjects.swReady.pipe(take(1))),
|
6390
|
-
map(([next]) => next)
|
6391
|
-
).subscribe((next) => {
|
6497
|
+
const subscription = channels.configuration.pipe(combineLatestWith(channels.swSourceMapAck)).subscribe(([next]) => {
|
6392
6498
|
const { configuration } = next;
|
6393
6499
|
const { content } = configuration;
|
6394
6500
|
let done;
|
@@ -6396,8 +6502,8 @@ const run = (frame, renderRoot, channels) => {
|
|
6396
6502
|
const { contexts, tags } = next;
|
6397
6503
|
done = queue.add([
|
6398
6504
|
() => unmount.call(frame, renderRoot),
|
6399
|
-
() => bootstrap.call(frame, configuration, { addInfo: addInfoFactory(channels), tags }),
|
6400
|
-
() => mock.call(frame, contexts, next.tags),
|
6505
|
+
() => bootstrap.call(frame, postChannel, channels, configuration, { addInfo: addInfoFactory(channels), tags }),
|
6506
|
+
() => mock.call(frame, postChannel, channels, contexts, next.tags),
|
6401
6507
|
() => update.call(frame, content, renderRoot).finally(() => channels.updated.next(0))
|
6402
6508
|
]);
|
6403
6509
|
} else {
|
@@ -6446,16 +6552,16 @@ const interceptCORSFetch = (self2, notification) => {
|
|
6446
6552
|
return;
|
6447
6553
|
}
|
6448
6554
|
const originalFetch = self2.fetch.bind(self2);
|
6449
|
-
self2.fetch = (input,
|
6555
|
+
self2.fetch = (input, init) => {
|
6450
6556
|
var _a2;
|
6451
6557
|
const url = toURL(urlMaker, input);
|
6452
6558
|
if (isSameDocumentOriginRequest(document2, url)) {
|
6453
|
-
notification.next(fetchNotification((_a2 =
|
6559
|
+
notification.next(fetchNotification((_a2 = init == null ? void 0 : init.method) != null ? _a2 : "GET", url));
|
6454
6560
|
}
|
6455
|
-
return originalFetch(input,
|
6561
|
+
return originalFetch(input, init);
|
6456
6562
|
};
|
6457
6563
|
};
|
6458
|
-
|
6564
|
+
const createComposerApplication = (self2, postChannel, channels) => {
|
6459
6565
|
applyBodyStyle(self2.document);
|
6460
6566
|
interceptCORSFetch(self2, channels.notification);
|
6461
6567
|
const { cleanup: overlayDisplaySubscriptionCleanup } = appendOverlay(self2, channels.mode.asObservable());
|
@@ -6463,7 +6569,7 @@ function createComposerApplication(self2, channels) {
|
|
6463
6569
|
const renderRoot = appendRenderRoot(self2.document);
|
6464
6570
|
const frame = createLifecycle(self2);
|
6465
6571
|
const { sandbox: sandboxedWindow, unpatch } = wrap(frame, channels.notification);
|
6466
|
-
const updateSubscriptionsCleanup = run(sandboxedWindow, renderRoot, channels);
|
6572
|
+
const updateSubscriptionsCleanup = run(sandboxedWindow, renderRoot, postChannel, channels);
|
6467
6573
|
return {
|
6468
6574
|
cleanup: () => {
|
6469
6575
|
updateSubscriptionsCleanup();
|
@@ -6473,87 +6579,41 @@ function createComposerApplication(self2, channels) {
|
|
6473
6579
|
},
|
6474
6580
|
sandboxedWindow
|
6475
6581
|
};
|
6476
|
-
}
|
6477
|
-
function logger(type, ...args) {
|
6478
|
-
{
|
6479
|
-
const color = generateDarkColorHex();
|
6480
|
-
const background = `${color}22`;
|
6481
|
-
const style = { background, color };
|
6482
|
-
console.groupCollapsed(`%c Preview ${this.location.href}`, Object.entries(style).map(([key, val]) => `${key}: ${val}`).join("; "));
|
6483
|
-
console[type](...args);
|
6484
|
-
console.groupEnd();
|
6485
|
-
}
|
6486
|
-
}
|
6487
|
-
function logServiceWorkerStatus(registration) {
|
6488
|
-
const log = logger.bind(this);
|
6489
|
-
if (registration.installing) {
|
6490
|
-
log("info", "Service worker installing");
|
6491
|
-
} else if (registration.waiting) {
|
6492
|
-
log("info", "Service worker installed");
|
6493
|
-
} else if (registration.active) {
|
6494
|
-
log("info", "Service worker active");
|
6495
|
-
}
|
6496
|
-
}
|
6497
|
-
const registerServiceWorker = async (self2) => {
|
6498
|
-
const { navigator: navigator2 } = self2;
|
6499
|
-
if ("serviceWorker" in navigator2) {
|
6500
|
-
navigator2.serviceWorker.register("./service-worker.js", { scope: "./" }).then((reg) => logServiceWorkerStatus.call(self2, reg)).catch((error2) => console.error(error2));
|
6501
|
-
return navigator2.serviceWorker.ready.then((reg) => {
|
6502
|
-
var _a2;
|
6503
|
-
return (_a2 = reg.active) != null ? _a2 : Promise.reject(new TypeError("serviceWorker not active"));
|
6504
|
-
});
|
6505
|
-
}
|
6506
|
-
logger.call(self2, "error", "serviceWorker is not available");
|
6507
6582
|
};
|
6508
|
-
|
6509
|
-
postChannel.window = self2;
|
6510
|
-
serviceWorkerChannel.window = self2;
|
6511
|
-
return registerServiceWorker(self2);
|
6512
|
-
};
|
6513
|
-
function registerSenders(chs, sw) {
|
6583
|
+
function registerParentWindowSenders(chs) {
|
6514
6584
|
const subscription = new Subscription();
|
6515
|
-
if (sw) {
|
6516
|
-
subscription.add(
|
6517
|
-
chs.setSourceMap.subscribe(
|
6518
|
-
(next) => serviceWorkerChannel.send(sw, { content: next, type: "set-source-map" })
|
6519
|
-
)
|
6520
|
-
);
|
6521
|
-
}
|
6522
6585
|
subscription.add(
|
6523
|
-
chs.updated.subscribe(() => {
|
6524
|
-
|
6525
|
-
|
6526
|
-
|
6527
|
-
});
|
6528
|
-
})
|
6586
|
+
chs.updated.subscribe(() => this.send({
|
6587
|
+
content: {},
|
6588
|
+
type: "updated"
|
6589
|
+
}))
|
6529
6590
|
);
|
6530
6591
|
subscription.add(
|
6531
|
-
chs.infos.subscribe(
|
6532
|
-
|
6533
|
-
|
6534
|
-
|
6535
|
-
type: "tag-info"
|
6536
|
-
});
|
6537
|
-
}
|
6538
|
-
)
|
6592
|
+
chs.infos.subscribe((entries) => this.send({
|
6593
|
+
content: entries,
|
6594
|
+
type: "tag-info"
|
6595
|
+
}))
|
6539
6596
|
);
|
6540
6597
|
subscription.add(
|
6541
|
-
chs.notification.subscribe(
|
6542
|
-
|
6543
|
-
|
6544
|
-
|
6545
|
-
type: "notification"
|
6546
|
-
});
|
6547
|
-
}
|
6548
|
-
)
|
6598
|
+
chs.notification.subscribe((content) => this.send({
|
6599
|
+
content,
|
6600
|
+
type: "notification"
|
6601
|
+
}))
|
6549
6602
|
);
|
6550
6603
|
subscription.add(
|
6551
|
-
chs.mode.subscribe(
|
6552
|
-
|
6553
|
-
|
6554
|
-
|
6555
|
-
|
6556
|
-
|
6604
|
+
chs.mode.subscribe((mode) => this.send({
|
6605
|
+
content: { mode },
|
6606
|
+
type: "ctrl-space"
|
6607
|
+
}))
|
6608
|
+
);
|
6609
|
+
return () => subscription.unsubscribe();
|
6610
|
+
}
|
6611
|
+
function registerServiceWorkerSenders(channels) {
|
6612
|
+
const subscription = new Subscription();
|
6613
|
+
subscription.add(
|
6614
|
+
channels.setSourceMap.subscribe(
|
6615
|
+
(message) => {
|
6616
|
+
this.ackSend({ content: message, type: "set-source-map" }).then(() => channels.swSourceMapAck.next(0)).catch(noop);
|
6557
6617
|
}
|
6558
6618
|
)
|
6559
6619
|
);
|
@@ -6575,40 +6635,34 @@ function registerCleanups(window2, fns) {
|
|
6575
6635
|
});
|
6576
6636
|
}
|
6577
6637
|
(async (self2) => {
|
6578
|
-
const
|
6579
|
-
|
6580
|
-
const
|
6581
|
-
|
6582
|
-
|
6583
|
-
const subscription = interval(100).subscribe(() => postChannel.send(self2.parent, { content: { status: "ready" }, type: "service-worker" }));
|
6584
|
-
serviceWorkerChannelCleanup = () => {
|
6585
|
-
swCleanup();
|
6586
|
-
subscription.unsubscribe();
|
6587
|
-
serviceWorkerChannel.send(sw, { content: {}, type: "unload-client" });
|
6588
|
-
};
|
6589
|
-
}
|
6590
|
-
const senderCleanup = registerSenders(subjects, sw);
|
6638
|
+
const channels = registerChannels();
|
6639
|
+
const swRegistration = await registerServiceWorker(self2);
|
6640
|
+
const parentWindowRegistration = registerParent(self2, channels);
|
6641
|
+
const serviceWorkerSenderCleanup = registerServiceWorkerSenders.call(swRegistration, channels);
|
6642
|
+
const parentWindowSenderCleanup = registerParentWindowSenders.call(parentWindowRegistration, channels);
|
6591
6643
|
const listenerCleanup = registerEventListeners(
|
6592
6644
|
self2,
|
6593
|
-
{ handler: ctrlSpaceFactory(
|
6594
|
-
{ handler: mouseEventFactory(
|
6595
|
-
{ handler: mouseEventFactory(
|
6596
|
-
{ handler: mouseOnElementFactory(self2,
|
6645
|
+
{ handler: ctrlSpaceFactory(channels), type: "keydown" },
|
6646
|
+
{ handler: mouseEventFactory(parentWindowRegistration, "mousemove"), type: "mousemove" },
|
6647
|
+
{ handler: mouseEventFactory(parentWindowRegistration, "mousedown"), type: "mousedown" },
|
6648
|
+
{ handler: mouseOnElementFactory(self2, parentWindowRegistration, channels), type: "mousedown" }
|
6597
6649
|
);
|
6598
6650
|
const {
|
6599
6651
|
cleanup: composerApplicationCleanup,
|
6600
6652
|
sandboxedWindow
|
6601
|
-
} = createComposerApplication(self2,
|
6653
|
+
} = createComposerApplication(self2, parentWindowRegistration, channels);
|
6602
6654
|
registerCleanups(
|
6603
6655
|
sandboxedWindow,
|
6604
6656
|
[
|
6605
6657
|
composerApplicationCleanup,
|
6606
6658
|
listenerCleanup,
|
6607
|
-
|
6608
|
-
|
6609
|
-
|
6659
|
+
parentWindowSenderCleanup,
|
6660
|
+
serviceWorkerSenderCleanup,
|
6661
|
+
() => parentWindowRegistration.disconnect(),
|
6662
|
+
() => swRegistration.disconnect()
|
6610
6663
|
]
|
6611
6664
|
);
|
6612
|
-
})(window).catch((
|
6613
|
-
|
6665
|
+
})(window).catch((err) => {
|
6666
|
+
console.error(`[preview] Error Boundary: ${String(err)}`);
|
6667
|
+
throw err;
|
6614
6668
|
});
|