@monei-js/components 2.1.2 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +86 -60
- package/dist/index.js +86 -60
- package/dist/monei.umd.production.min.js +4 -4
- package/dist/monei.umd.production.min.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -111,7 +111,8 @@ const getLanguage = () => {
|
|
|
111
111
|
};
|
|
112
112
|
const safe = (fn) => {
|
|
113
113
|
try {
|
|
114
|
-
|
|
114
|
+
var _fn;
|
|
115
|
+
return String((_fn = fn()) !== null && _fn !== void 0 ? _fn : "");
|
|
115
116
|
} catch {
|
|
116
117
|
return "";
|
|
117
118
|
}
|
|
@@ -129,7 +130,10 @@ const getClientEnv = () => {
|
|
|
129
130
|
safe(() => navigator.deviceMemory),
|
|
130
131
|
safe(() => navigator.maxTouchPoints),
|
|
131
132
|
safe(() => navigator.platform),
|
|
132
|
-
safe(() =>
|
|
133
|
+
safe(() => {
|
|
134
|
+
var _navigator$languages;
|
|
135
|
+
return (_navigator$languages = navigator.languages) === null || _navigator$languages === void 0 ? void 0 : _navigator$languages.join(",");
|
|
136
|
+
})
|
|
133
137
|
].join("|");
|
|
134
138
|
return window.btoa(env);
|
|
135
139
|
};
|
|
@@ -162,8 +166,9 @@ const getPersistentSeed = async () => {
|
|
|
162
166
|
const thumbmark = new _thumbmarkjs_thumbmarkjs.Thumbmark({ logging: false });
|
|
163
167
|
thumbmark.includeComponent("persistent_seed", getPersistentSeed);
|
|
164
168
|
const getClientFingerprint = async () => {
|
|
169
|
+
var _result$thumbmark;
|
|
165
170
|
const [, result] = await withError(thumbmark.get());
|
|
166
|
-
return result
|
|
171
|
+
return (_result$thumbmark = result === null || result === void 0 ? void 0 : result.thumbmark) !== null && _result$thumbmark !== void 0 ? _result$thumbmark : "";
|
|
167
172
|
};
|
|
168
173
|
const withError = async (p) => {
|
|
169
174
|
try {
|
|
@@ -183,7 +188,7 @@ const validateComponentProps = ({ props }) => {
|
|
|
183
188
|
//#endregion
|
|
184
189
|
//#region src/config.ts
|
|
185
190
|
const stage = "prod";
|
|
186
|
-
const version = "
|
|
191
|
+
const version = "v3";
|
|
187
192
|
const sc = {
|
|
188
193
|
local: {
|
|
189
194
|
domain: "http://card-input.localhost:1355",
|
|
@@ -513,6 +518,7 @@ function createVue3Driver(ComponentClass) {
|
|
|
513
518
|
*/
|
|
514
519
|
function createAngularDriver(ComponentClass) {
|
|
515
520
|
return ({ Component: AngularComponent, NgModule, ElementRef, NgZone, Inject }) => {
|
|
521
|
+
var _options;
|
|
516
522
|
class ComponentInstance {
|
|
517
523
|
constructor(elementRef, zone) {
|
|
518
524
|
this.props = {};
|
|
@@ -549,7 +555,7 @@ function createAngularDriver(ComponentClass) {
|
|
|
549
555
|
}
|
|
550
556
|
ComponentInstance.parameters = [[new Inject(ElementRef)], [new Inject(NgZone)]];
|
|
551
557
|
ComponentInstance.annotations = [new AngularComponent({
|
|
552
|
-
selector: ComponentClass.prototype.__options
|
|
558
|
+
selector: ((_options = ComponentClass.prototype.__options) === null || _options === void 0 ? void 0 : _options.tag) || "bridge-component",
|
|
553
559
|
template: "<div></div>",
|
|
554
560
|
inputs: ["props"]
|
|
555
561
|
})];
|
|
@@ -585,10 +591,6 @@ function resolveDriver(name, ComponentClass, deps) {
|
|
|
585
591
|
return factory(ComponentClass)(deps);
|
|
586
592
|
}
|
|
587
593
|
//#endregion
|
|
588
|
-
//#region ../shared/lib/bridge-constants.ts
|
|
589
|
-
/** Protocol identifier for sync bootstrap messages between parent and child bridges */
|
|
590
|
-
const BRIDGE_INIT_MSG = "__monei_bridge_init__";
|
|
591
|
-
//#endregion
|
|
592
594
|
//#region src/bridge/constants.ts
|
|
593
595
|
/** Bridge lifecycle events (replaces zoid.EVENT) */
|
|
594
596
|
const EVENT = {
|
|
@@ -770,6 +772,7 @@ function attachRenderMethods(instance, options) {
|
|
|
770
772
|
* 8. createConnection — establish Penpal async RPC channel, deliver props via updateProps
|
|
771
773
|
*/
|
|
772
774
|
instance.render = async (container) => {
|
|
775
|
+
var _SANDBOX$options$tag;
|
|
773
776
|
if (renderState.destroyed) throw new Error("Component is destroyed");
|
|
774
777
|
if (renderState.frame) throw new Error("Component already rendered");
|
|
775
778
|
const targetEl = resolveContainer(container);
|
|
@@ -781,7 +784,7 @@ function attachRenderMethods(instance, options) {
|
|
|
781
784
|
frame.setAttribute("allowpaymentrequest", "true");
|
|
782
785
|
frame.setAttribute("allow", "payment");
|
|
783
786
|
frame.style.border = "none";
|
|
784
|
-
const sandbox = SANDBOX[options.tag]
|
|
787
|
+
const sandbox = (_SANDBOX$options$tag = SANDBOX[options.tag]) !== null && _SANDBOX$options$tag !== void 0 ? _SANDBOX$options$tag : "allow-scripts allow-forms allow-same-origin";
|
|
785
788
|
frame.setAttribute("sandbox", sandbox);
|
|
786
789
|
if (!lifecycleWired) {
|
|
787
790
|
wireLifecycleProps(instance.props, instance.event);
|
|
@@ -814,34 +817,40 @@ function attachRenderMethods(instance, options) {
|
|
|
814
817
|
let dataProps = {};
|
|
815
818
|
let functionNames = [];
|
|
816
819
|
try {
|
|
817
|
-
if (options.prerenderTemplate)
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
820
|
+
if (options.prerenderTemplate) {
|
|
821
|
+
var _options$dimensions;
|
|
822
|
+
placeholder = options.prerenderTemplate({
|
|
823
|
+
uid,
|
|
824
|
+
frame,
|
|
825
|
+
placeholder: void 0,
|
|
826
|
+
doc,
|
|
827
|
+
props: instance.props,
|
|
828
|
+
event: trackedEvent,
|
|
829
|
+
dimensions: (_options$dimensions = options.dimensions) !== null && _options$dimensions !== void 0 ? _options$dimensions : {
|
|
830
|
+
width: "100%",
|
|
831
|
+
height: "auto"
|
|
832
|
+
},
|
|
833
|
+
state: instance.state,
|
|
834
|
+
container: targetEl
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
if (options.containerTemplate) {
|
|
838
|
+
var _options$dimensions2;
|
|
839
|
+
containerNode = options.containerTemplate({
|
|
840
|
+
uid,
|
|
841
|
+
frame,
|
|
842
|
+
placeholder,
|
|
843
|
+
doc,
|
|
844
|
+
props: instance.props,
|
|
845
|
+
event: trackedEvent,
|
|
846
|
+
dimensions: (_options$dimensions2 = options.dimensions) !== null && _options$dimensions2 !== void 0 ? _options$dimensions2 : {
|
|
847
|
+
width: "100%",
|
|
848
|
+
height: "auto"
|
|
849
|
+
},
|
|
850
|
+
state: instance.state,
|
|
851
|
+
container: targetEl
|
|
852
|
+
});
|
|
853
|
+
}
|
|
845
854
|
({dataProps, functionNames} = buildDataPayload({
|
|
846
855
|
props: instance.props,
|
|
847
856
|
options,
|
|
@@ -862,12 +871,16 @@ function attachRenderMethods(instance, options) {
|
|
|
862
871
|
throw err;
|
|
863
872
|
}
|
|
864
873
|
renderState.frame = frame;
|
|
874
|
+
const targetOrigin = new URL(options.url).origin;
|
|
865
875
|
const sendInitialProps = () => {
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
876
|
+
try {
|
|
877
|
+
var _frame$contentWindow;
|
|
878
|
+
(_frame$contentWindow = frame.contentWindow) === null || _frame$contentWindow === void 0 || _frame$contentWindow.postMessage({
|
|
879
|
+
type: "__monei_bridge_init__",
|
|
880
|
+
props: dataProps,
|
|
881
|
+
functionNames
|
|
882
|
+
}, targetOrigin);
|
|
883
|
+
} catch {}
|
|
871
884
|
};
|
|
872
885
|
try {
|
|
873
886
|
if (containerNode) {
|
|
@@ -907,9 +920,10 @@ function attachRenderMethods(instance, options) {
|
|
|
907
920
|
await remote.updateProps(dataProps, functionNames);
|
|
908
921
|
if (renderState.destroyed) return;
|
|
909
922
|
if (renderState.pendingPropsUpdate) {
|
|
923
|
+
var _pending$functionName;
|
|
910
924
|
const pending = renderState.pendingPropsUpdate;
|
|
911
925
|
renderState.pendingPropsUpdate = null;
|
|
912
|
-
const retainedFns = new Set(pending.functionNames
|
|
926
|
+
const retainedFns = new Set((_pending$functionName = pending.functionNames) !== null && _pending$functionName !== void 0 ? _pending$functionName : []);
|
|
913
927
|
const flushRemovals = /* @__PURE__ */ new Map();
|
|
914
928
|
for (const key of Object.keys(pending.dataProps)) if (renderState.dispatchMap.has(key) && !retainedFns.has(key)) {
|
|
915
929
|
flushRemovals.set(key, renderState.dispatchMap.get(key));
|
|
@@ -1004,8 +1018,9 @@ function attachRenderMethods(instance, options) {
|
|
|
1004
1018
|
}
|
|
1005
1019
|
}
|
|
1006
1020
|
if (resolvedFunctionNames) {
|
|
1021
|
+
var _renderState$pendingP;
|
|
1007
1022
|
for (const name of resolvedFunctionNames) delete renderState.pendingPropsUpdate.dataProps[name];
|
|
1008
|
-
renderState.pendingPropsUpdate.functionNames = [...renderState.pendingPropsUpdate.functionNames
|
|
1023
|
+
renderState.pendingPropsUpdate.functionNames = [...(_renderState$pendingP = renderState.pendingPropsUpdate.functionNames) !== null && _renderState$pendingP !== void 0 ? _renderState$pendingP : [], ...resolvedFunctionNames];
|
|
1009
1024
|
}
|
|
1010
1025
|
}
|
|
1011
1026
|
};
|
|
@@ -1058,7 +1073,8 @@ function normalizeAliases(props, aliases) {
|
|
|
1058
1073
|
for (const [canonical, alias] of Object.entries(aliases)) reverseMap.set(alias, canonical);
|
|
1059
1074
|
const result = {};
|
|
1060
1075
|
for (const [key, value] of Object.entries(props)) {
|
|
1061
|
-
|
|
1076
|
+
var _reverseMap$get;
|
|
1077
|
+
const canonicalKey = (_reverseMap$get = reverseMap.get(key)) !== null && _reverseMap$get !== void 0 ? _reverseMap$get : key;
|
|
1062
1078
|
result[canonicalKey] = value;
|
|
1063
1079
|
}
|
|
1064
1080
|
return result;
|
|
@@ -1133,7 +1149,7 @@ function createContainerTemplate(config = {}) {
|
|
|
1133
1149
|
const div = doc.createElement("div");
|
|
1134
1150
|
div.setAttribute("id", uid);
|
|
1135
1151
|
const style = doc.createElement("style");
|
|
1136
|
-
if (props
|
|
1152
|
+
if (props === null || props === void 0 ? void 0 : props.cspNonce) style.setAttribute("nonce", props.cspNonce);
|
|
1137
1153
|
if (modal) {
|
|
1138
1154
|
const backdrop = doc.createElement("div");
|
|
1139
1155
|
backdrop.classList.add("backdrop");
|
|
@@ -1200,8 +1216,9 @@ function createContainerTemplate(config = {}) {
|
|
|
1200
1216
|
}
|
|
1201
1217
|
});
|
|
1202
1218
|
} else {
|
|
1203
|
-
|
|
1204
|
-
const
|
|
1219
|
+
var _innerStyle$base;
|
|
1220
|
+
const innerStyle = (props === null || props === void 0 ? void 0 : props.style) || (props === null || props === void 0 ? void 0 : props.innerStyle);
|
|
1221
|
+
const initialHeight = height === "0" ? "0" : toCSS((innerStyle === null || innerStyle === void 0 || (_innerStyle$base = innerStyle.base) === null || _innerStyle$base === void 0 ? void 0 : _innerStyle$base.height) || (innerStyle === null || innerStyle === void 0 ? void 0 : innerStyle.height) || (height === "auto" ? 45 : height));
|
|
1205
1222
|
const containerStyles = [
|
|
1206
1223
|
"display: block",
|
|
1207
1224
|
"position: relative",
|
|
@@ -1268,7 +1285,8 @@ const modalContainerTemplate = createContainerTemplate({ modal: true });
|
|
|
1268
1285
|
//#endregion
|
|
1269
1286
|
//#region src/card-input/index.ts
|
|
1270
1287
|
const getCreateTokenFunction = (ref) => {
|
|
1271
|
-
|
|
1288
|
+
var _ref$state;
|
|
1289
|
+
if ((_ref$state = ref.state) === null || _ref$state === void 0 ? void 0 : _ref$state.__createToken) return ref.state.__createToken;
|
|
1272
1290
|
throw new Error("Index is not registered");
|
|
1273
1291
|
};
|
|
1274
1292
|
const createToken = async (component, options) => {
|
|
@@ -1297,7 +1315,8 @@ const CardInput = createComponent({
|
|
|
1297
1315
|
} },
|
|
1298
1316
|
validate: validateComponentProps,
|
|
1299
1317
|
submit: (instance) => async (opts) => {
|
|
1300
|
-
|
|
1318
|
+
var _instance$state;
|
|
1319
|
+
const createTokenFn = (_instance$state = instance.state) === null || _instance$state === void 0 ? void 0 : _instance$state.__createToken;
|
|
1301
1320
|
if (!createTokenFn) throw new Error("CardInput is not rendered or connection is pending — call render() first");
|
|
1302
1321
|
const { data } = await createTokenFn(opts);
|
|
1303
1322
|
return data;
|
|
@@ -1319,8 +1338,8 @@ const CardInput = createComponent({
|
|
|
1319
1338
|
div.style.height = "45px";
|
|
1320
1339
|
div.style.boxSizing = "border-box";
|
|
1321
1340
|
const style = props.style || props.innerStyle;
|
|
1322
|
-
if (style
|
|
1323
|
-
if (style
|
|
1341
|
+
if (style === null || style === void 0 ? void 0 : style.base) Object.assign(div.style, transformStyle(style.base));
|
|
1342
|
+
if (style === null || style === void 0 ? void 0 : style.loading) Object.assign(div.style, transformStyle(style.loading));
|
|
1324
1343
|
body.appendChild(div);
|
|
1325
1344
|
html.appendChild(body);
|
|
1326
1345
|
return html;
|
|
@@ -1363,7 +1382,7 @@ const confirmPayment = (params) => {
|
|
|
1363
1382
|
document.body.appendChild(rootNode);
|
|
1364
1383
|
let modal = null;
|
|
1365
1384
|
const cleanup = () => {
|
|
1366
|
-
modal
|
|
1385
|
+
modal === null || modal === void 0 || modal.destroy();
|
|
1367
1386
|
modal = null;
|
|
1368
1387
|
Object.assign(document.body.style, { overflow: bodyOverflow });
|
|
1369
1388
|
if (rootNode.parentNode) rootNode.parentNode.removeChild(rootNode);
|
|
@@ -1391,6 +1410,7 @@ const confirmPayment = (params) => {
|
|
|
1391
1410
|
//#region src/paypal/index.ts
|
|
1392
1411
|
const namespace = "monei-paypal";
|
|
1393
1412
|
const onLoadPaypal = async (props, state, src) => {
|
|
1413
|
+
var _props$style$borderRa, _props$style, _props$onLoad;
|
|
1394
1414
|
state.__scriptId = (await loadScript(src, props.cspNonce, {
|
|
1395
1415
|
namespace,
|
|
1396
1416
|
cspNonce: props.cspNonce
|
|
@@ -1400,18 +1420,19 @@ const onLoadPaypal = async (props, state, src) => {
|
|
|
1400
1420
|
tagline: false,
|
|
1401
1421
|
height: 45
|
|
1402
1422
|
};
|
|
1403
|
-
const radius = parsePx(props.style
|
|
1423
|
+
const radius = parsePx((_props$style$borderRa = (_props$style = props.style) === null || _props$style === void 0 ? void 0 : _props$style.borderRadius) !== null && _props$style$borderRa !== void 0 ? _props$style$borderRa : props.borderRadius);
|
|
1404
1424
|
if (radius) defaultStyle.borderRadius = radius;
|
|
1405
1425
|
const style = {
|
|
1406
1426
|
...defaultStyle,
|
|
1407
1427
|
...props.style
|
|
1408
1428
|
};
|
|
1409
1429
|
style.height = parsePx(style.height, 45);
|
|
1410
|
-
props.onLoad
|
|
1430
|
+
(_props$onLoad = props.onLoad) === null || _props$onLoad === void 0 || _props$onLoad.call(props, true);
|
|
1411
1431
|
let token;
|
|
1412
1432
|
await window[namespace].Buttons({
|
|
1413
1433
|
createOrder: async () => {
|
|
1414
1434
|
try {
|
|
1435
|
+
var _result$paypal;
|
|
1415
1436
|
const result = await createToken$1({
|
|
1416
1437
|
paymentId: props.paymentId,
|
|
1417
1438
|
accountId: props.accountId,
|
|
@@ -1422,15 +1443,19 @@ const onLoadPaypal = async (props, state, src) => {
|
|
|
1422
1443
|
paymentMethod: { paypal: {} }
|
|
1423
1444
|
});
|
|
1424
1445
|
({token} = result);
|
|
1425
|
-
return result.paypal
|
|
1446
|
+
return (_result$paypal = result.paypal) === null || _result$paypal === void 0 ? void 0 : _result$paypal.orderId;
|
|
1426
1447
|
} catch (error) {
|
|
1427
|
-
|
|
1448
|
+
var _props$onError;
|
|
1449
|
+
(_props$onError = props.onError) === null || _props$onError === void 0 || _props$onError.call(props, error);
|
|
1428
1450
|
return;
|
|
1429
1451
|
}
|
|
1430
1452
|
},
|
|
1431
1453
|
onApprove: function(data) {
|
|
1432
1454
|
if (data.orderID) props.onSubmit({ token });
|
|
1433
|
-
else
|
|
1455
|
+
else {
|
|
1456
|
+
var _props$onError2;
|
|
1457
|
+
(_props$onError2 = props.onError) === null || _props$onError2 === void 0 || _props$onError2.call(props, data);
|
|
1458
|
+
}
|
|
1434
1459
|
},
|
|
1435
1460
|
onClick: function(_data, actions) {
|
|
1436
1461
|
let shouldOpen = true;
|
|
@@ -1467,7 +1492,8 @@ const PayPal = createComponent({
|
|
|
1467
1492
|
if (!params.props.accountId && !params.props.paymentId) throw new Error("You need to provide paymentId or accountId");
|
|
1468
1493
|
const container = containerTemplate(params);
|
|
1469
1494
|
params.event.on(EVENT.DESTROY, () => {
|
|
1470
|
-
|
|
1495
|
+
var _namespace;
|
|
1496
|
+
(_namespace = window[namespace]) === null || _namespace === void 0 || (_namespace = _namespace.Buttons) === null || _namespace === void 0 || (_namespace = _namespace.instances) === null || _namespace === void 0 || _namespace.forEach((instance) => {
|
|
1471
1497
|
instance.close();
|
|
1472
1498
|
});
|
|
1473
1499
|
const scriptId = params.state.__scriptId;
|
package/dist/index.js
CHANGED
|
@@ -99,7 +99,8 @@ const getLanguage = () => {
|
|
|
99
99
|
};
|
|
100
100
|
const safe = (fn) => {
|
|
101
101
|
try {
|
|
102
|
-
|
|
102
|
+
var _fn;
|
|
103
|
+
return String((_fn = fn()) !== null && _fn !== void 0 ? _fn : "");
|
|
103
104
|
} catch {
|
|
104
105
|
return "";
|
|
105
106
|
}
|
|
@@ -117,7 +118,10 @@ const getClientEnv = () => {
|
|
|
117
118
|
safe(() => navigator.deviceMemory),
|
|
118
119
|
safe(() => navigator.maxTouchPoints),
|
|
119
120
|
safe(() => navigator.platform),
|
|
120
|
-
safe(() =>
|
|
121
|
+
safe(() => {
|
|
122
|
+
var _navigator$languages;
|
|
123
|
+
return (_navigator$languages = navigator.languages) === null || _navigator$languages === void 0 ? void 0 : _navigator$languages.join(",");
|
|
124
|
+
})
|
|
121
125
|
].join("|");
|
|
122
126
|
return window.btoa(env);
|
|
123
127
|
};
|
|
@@ -150,8 +154,9 @@ const getPersistentSeed = async () => {
|
|
|
150
154
|
const thumbmark = new Thumbmark({ logging: false });
|
|
151
155
|
thumbmark.includeComponent("persistent_seed", getPersistentSeed);
|
|
152
156
|
const getClientFingerprint = async () => {
|
|
157
|
+
var _result$thumbmark;
|
|
153
158
|
const [, result] = await withError(thumbmark.get());
|
|
154
|
-
return result
|
|
159
|
+
return (_result$thumbmark = result === null || result === void 0 ? void 0 : result.thumbmark) !== null && _result$thumbmark !== void 0 ? _result$thumbmark : "";
|
|
155
160
|
};
|
|
156
161
|
const withError = async (p) => {
|
|
157
162
|
try {
|
|
@@ -171,7 +176,7 @@ const validateComponentProps = ({ props }) => {
|
|
|
171
176
|
//#endregion
|
|
172
177
|
//#region src/config.ts
|
|
173
178
|
const stage = "prod";
|
|
174
|
-
const version = "
|
|
179
|
+
const version = "v3";
|
|
175
180
|
const sc = {
|
|
176
181
|
local: {
|
|
177
182
|
domain: "http://card-input.localhost:1355",
|
|
@@ -501,6 +506,7 @@ function createVue3Driver(ComponentClass) {
|
|
|
501
506
|
*/
|
|
502
507
|
function createAngularDriver(ComponentClass) {
|
|
503
508
|
return ({ Component: AngularComponent, NgModule, ElementRef, NgZone, Inject }) => {
|
|
509
|
+
var _options;
|
|
504
510
|
class ComponentInstance {
|
|
505
511
|
constructor(elementRef, zone) {
|
|
506
512
|
this.props = {};
|
|
@@ -537,7 +543,7 @@ function createAngularDriver(ComponentClass) {
|
|
|
537
543
|
}
|
|
538
544
|
ComponentInstance.parameters = [[new Inject(ElementRef)], [new Inject(NgZone)]];
|
|
539
545
|
ComponentInstance.annotations = [new AngularComponent({
|
|
540
|
-
selector: ComponentClass.prototype.__options
|
|
546
|
+
selector: ((_options = ComponentClass.prototype.__options) === null || _options === void 0 ? void 0 : _options.tag) || "bridge-component",
|
|
541
547
|
template: "<div></div>",
|
|
542
548
|
inputs: ["props"]
|
|
543
549
|
})];
|
|
@@ -573,10 +579,6 @@ function resolveDriver(name, ComponentClass, deps) {
|
|
|
573
579
|
return factory(ComponentClass)(deps);
|
|
574
580
|
}
|
|
575
581
|
//#endregion
|
|
576
|
-
//#region ../shared/lib/bridge-constants.ts
|
|
577
|
-
/** Protocol identifier for sync bootstrap messages between parent and child bridges */
|
|
578
|
-
const BRIDGE_INIT_MSG = "__monei_bridge_init__";
|
|
579
|
-
//#endregion
|
|
580
582
|
//#region src/bridge/constants.ts
|
|
581
583
|
/** Bridge lifecycle events (replaces zoid.EVENT) */
|
|
582
584
|
const EVENT = {
|
|
@@ -758,6 +760,7 @@ function attachRenderMethods(instance, options) {
|
|
|
758
760
|
* 8. createConnection — establish Penpal async RPC channel, deliver props via updateProps
|
|
759
761
|
*/
|
|
760
762
|
instance.render = async (container) => {
|
|
763
|
+
var _SANDBOX$options$tag;
|
|
761
764
|
if (renderState.destroyed) throw new Error("Component is destroyed");
|
|
762
765
|
if (renderState.frame) throw new Error("Component already rendered");
|
|
763
766
|
const targetEl = resolveContainer(container);
|
|
@@ -769,7 +772,7 @@ function attachRenderMethods(instance, options) {
|
|
|
769
772
|
frame.setAttribute("allowpaymentrequest", "true");
|
|
770
773
|
frame.setAttribute("allow", "payment");
|
|
771
774
|
frame.style.border = "none";
|
|
772
|
-
const sandbox = SANDBOX[options.tag]
|
|
775
|
+
const sandbox = (_SANDBOX$options$tag = SANDBOX[options.tag]) !== null && _SANDBOX$options$tag !== void 0 ? _SANDBOX$options$tag : "allow-scripts allow-forms allow-same-origin";
|
|
773
776
|
frame.setAttribute("sandbox", sandbox);
|
|
774
777
|
if (!lifecycleWired) {
|
|
775
778
|
wireLifecycleProps(instance.props, instance.event);
|
|
@@ -802,34 +805,40 @@ function attachRenderMethods(instance, options) {
|
|
|
802
805
|
let dataProps = {};
|
|
803
806
|
let functionNames = [];
|
|
804
807
|
try {
|
|
805
|
-
if (options.prerenderTemplate)
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
808
|
+
if (options.prerenderTemplate) {
|
|
809
|
+
var _options$dimensions;
|
|
810
|
+
placeholder = options.prerenderTemplate({
|
|
811
|
+
uid,
|
|
812
|
+
frame,
|
|
813
|
+
placeholder: void 0,
|
|
814
|
+
doc,
|
|
815
|
+
props: instance.props,
|
|
816
|
+
event: trackedEvent,
|
|
817
|
+
dimensions: (_options$dimensions = options.dimensions) !== null && _options$dimensions !== void 0 ? _options$dimensions : {
|
|
818
|
+
width: "100%",
|
|
819
|
+
height: "auto"
|
|
820
|
+
},
|
|
821
|
+
state: instance.state,
|
|
822
|
+
container: targetEl
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
if (options.containerTemplate) {
|
|
826
|
+
var _options$dimensions2;
|
|
827
|
+
containerNode = options.containerTemplate({
|
|
828
|
+
uid,
|
|
829
|
+
frame,
|
|
830
|
+
placeholder,
|
|
831
|
+
doc,
|
|
832
|
+
props: instance.props,
|
|
833
|
+
event: trackedEvent,
|
|
834
|
+
dimensions: (_options$dimensions2 = options.dimensions) !== null && _options$dimensions2 !== void 0 ? _options$dimensions2 : {
|
|
835
|
+
width: "100%",
|
|
836
|
+
height: "auto"
|
|
837
|
+
},
|
|
838
|
+
state: instance.state,
|
|
839
|
+
container: targetEl
|
|
840
|
+
});
|
|
841
|
+
}
|
|
833
842
|
({dataProps, functionNames} = buildDataPayload({
|
|
834
843
|
props: instance.props,
|
|
835
844
|
options,
|
|
@@ -850,12 +859,16 @@ function attachRenderMethods(instance, options) {
|
|
|
850
859
|
throw err;
|
|
851
860
|
}
|
|
852
861
|
renderState.frame = frame;
|
|
862
|
+
const targetOrigin = new URL(options.url).origin;
|
|
853
863
|
const sendInitialProps = () => {
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
864
|
+
try {
|
|
865
|
+
var _frame$contentWindow;
|
|
866
|
+
(_frame$contentWindow = frame.contentWindow) === null || _frame$contentWindow === void 0 || _frame$contentWindow.postMessage({
|
|
867
|
+
type: "__monei_bridge_init__",
|
|
868
|
+
props: dataProps,
|
|
869
|
+
functionNames
|
|
870
|
+
}, targetOrigin);
|
|
871
|
+
} catch {}
|
|
859
872
|
};
|
|
860
873
|
try {
|
|
861
874
|
if (containerNode) {
|
|
@@ -895,9 +908,10 @@ function attachRenderMethods(instance, options) {
|
|
|
895
908
|
await remote.updateProps(dataProps, functionNames);
|
|
896
909
|
if (renderState.destroyed) return;
|
|
897
910
|
if (renderState.pendingPropsUpdate) {
|
|
911
|
+
var _pending$functionName;
|
|
898
912
|
const pending = renderState.pendingPropsUpdate;
|
|
899
913
|
renderState.pendingPropsUpdate = null;
|
|
900
|
-
const retainedFns = new Set(pending.functionNames
|
|
914
|
+
const retainedFns = new Set((_pending$functionName = pending.functionNames) !== null && _pending$functionName !== void 0 ? _pending$functionName : []);
|
|
901
915
|
const flushRemovals = /* @__PURE__ */ new Map();
|
|
902
916
|
for (const key of Object.keys(pending.dataProps)) if (renderState.dispatchMap.has(key) && !retainedFns.has(key)) {
|
|
903
917
|
flushRemovals.set(key, renderState.dispatchMap.get(key));
|
|
@@ -992,8 +1006,9 @@ function attachRenderMethods(instance, options) {
|
|
|
992
1006
|
}
|
|
993
1007
|
}
|
|
994
1008
|
if (resolvedFunctionNames) {
|
|
1009
|
+
var _renderState$pendingP;
|
|
995
1010
|
for (const name of resolvedFunctionNames) delete renderState.pendingPropsUpdate.dataProps[name];
|
|
996
|
-
renderState.pendingPropsUpdate.functionNames = [...renderState.pendingPropsUpdate.functionNames
|
|
1011
|
+
renderState.pendingPropsUpdate.functionNames = [...(_renderState$pendingP = renderState.pendingPropsUpdate.functionNames) !== null && _renderState$pendingP !== void 0 ? _renderState$pendingP : [], ...resolvedFunctionNames];
|
|
997
1012
|
}
|
|
998
1013
|
}
|
|
999
1014
|
};
|
|
@@ -1046,7 +1061,8 @@ function normalizeAliases(props, aliases) {
|
|
|
1046
1061
|
for (const [canonical, alias] of Object.entries(aliases)) reverseMap.set(alias, canonical);
|
|
1047
1062
|
const result = {};
|
|
1048
1063
|
for (const [key, value] of Object.entries(props)) {
|
|
1049
|
-
|
|
1064
|
+
var _reverseMap$get;
|
|
1065
|
+
const canonicalKey = (_reverseMap$get = reverseMap.get(key)) !== null && _reverseMap$get !== void 0 ? _reverseMap$get : key;
|
|
1050
1066
|
result[canonicalKey] = value;
|
|
1051
1067
|
}
|
|
1052
1068
|
return result;
|
|
@@ -1121,7 +1137,7 @@ function createContainerTemplate(config = {}) {
|
|
|
1121
1137
|
const div = doc.createElement("div");
|
|
1122
1138
|
div.setAttribute("id", uid);
|
|
1123
1139
|
const style = doc.createElement("style");
|
|
1124
|
-
if (props
|
|
1140
|
+
if (props === null || props === void 0 ? void 0 : props.cspNonce) style.setAttribute("nonce", props.cspNonce);
|
|
1125
1141
|
if (modal) {
|
|
1126
1142
|
const backdrop = doc.createElement("div");
|
|
1127
1143
|
backdrop.classList.add("backdrop");
|
|
@@ -1188,8 +1204,9 @@ function createContainerTemplate(config = {}) {
|
|
|
1188
1204
|
}
|
|
1189
1205
|
});
|
|
1190
1206
|
} else {
|
|
1191
|
-
|
|
1192
|
-
const
|
|
1207
|
+
var _innerStyle$base;
|
|
1208
|
+
const innerStyle = (props === null || props === void 0 ? void 0 : props.style) || (props === null || props === void 0 ? void 0 : props.innerStyle);
|
|
1209
|
+
const initialHeight = height === "0" ? "0" : toCSS((innerStyle === null || innerStyle === void 0 || (_innerStyle$base = innerStyle.base) === null || _innerStyle$base === void 0 ? void 0 : _innerStyle$base.height) || (innerStyle === null || innerStyle === void 0 ? void 0 : innerStyle.height) || (height === "auto" ? 45 : height));
|
|
1193
1210
|
const containerStyles = [
|
|
1194
1211
|
"display: block",
|
|
1195
1212
|
"position: relative",
|
|
@@ -1256,7 +1273,8 @@ const modalContainerTemplate = createContainerTemplate({ modal: true });
|
|
|
1256
1273
|
//#endregion
|
|
1257
1274
|
//#region src/card-input/index.ts
|
|
1258
1275
|
const getCreateTokenFunction = (ref) => {
|
|
1259
|
-
|
|
1276
|
+
var _ref$state;
|
|
1277
|
+
if ((_ref$state = ref.state) === null || _ref$state === void 0 ? void 0 : _ref$state.__createToken) return ref.state.__createToken;
|
|
1260
1278
|
throw new Error("Index is not registered");
|
|
1261
1279
|
};
|
|
1262
1280
|
const createToken = async (component, options) => {
|
|
@@ -1285,7 +1303,8 @@ const CardInput = createComponent({
|
|
|
1285
1303
|
} },
|
|
1286
1304
|
validate: validateComponentProps,
|
|
1287
1305
|
submit: (instance) => async (opts) => {
|
|
1288
|
-
|
|
1306
|
+
var _instance$state;
|
|
1307
|
+
const createTokenFn = (_instance$state = instance.state) === null || _instance$state === void 0 ? void 0 : _instance$state.__createToken;
|
|
1289
1308
|
if (!createTokenFn) throw new Error("CardInput is not rendered or connection is pending — call render() first");
|
|
1290
1309
|
const { data } = await createTokenFn(opts);
|
|
1291
1310
|
return data;
|
|
@@ -1307,8 +1326,8 @@ const CardInput = createComponent({
|
|
|
1307
1326
|
div.style.height = "45px";
|
|
1308
1327
|
div.style.boxSizing = "border-box";
|
|
1309
1328
|
const style = props.style || props.innerStyle;
|
|
1310
|
-
if (style
|
|
1311
|
-
if (style
|
|
1329
|
+
if (style === null || style === void 0 ? void 0 : style.base) Object.assign(div.style, transformStyle(style.base));
|
|
1330
|
+
if (style === null || style === void 0 ? void 0 : style.loading) Object.assign(div.style, transformStyle(style.loading));
|
|
1312
1331
|
body.appendChild(div);
|
|
1313
1332
|
html.appendChild(body);
|
|
1314
1333
|
return html;
|
|
@@ -1351,7 +1370,7 @@ const confirmPayment = (params) => {
|
|
|
1351
1370
|
document.body.appendChild(rootNode);
|
|
1352
1371
|
let modal = null;
|
|
1353
1372
|
const cleanup = () => {
|
|
1354
|
-
modal
|
|
1373
|
+
modal === null || modal === void 0 || modal.destroy();
|
|
1355
1374
|
modal = null;
|
|
1356
1375
|
Object.assign(document.body.style, { overflow: bodyOverflow });
|
|
1357
1376
|
if (rootNode.parentNode) rootNode.parentNode.removeChild(rootNode);
|
|
@@ -1379,6 +1398,7 @@ const confirmPayment = (params) => {
|
|
|
1379
1398
|
//#region src/paypal/index.ts
|
|
1380
1399
|
const namespace = "monei-paypal";
|
|
1381
1400
|
const onLoadPaypal = async (props, state, src) => {
|
|
1401
|
+
var _props$style$borderRa, _props$style, _props$onLoad;
|
|
1382
1402
|
state.__scriptId = (await loadScript(src, props.cspNonce, {
|
|
1383
1403
|
namespace,
|
|
1384
1404
|
cspNonce: props.cspNonce
|
|
@@ -1388,18 +1408,19 @@ const onLoadPaypal = async (props, state, src) => {
|
|
|
1388
1408
|
tagline: false,
|
|
1389
1409
|
height: 45
|
|
1390
1410
|
};
|
|
1391
|
-
const radius = parsePx(props.style
|
|
1411
|
+
const radius = parsePx((_props$style$borderRa = (_props$style = props.style) === null || _props$style === void 0 ? void 0 : _props$style.borderRadius) !== null && _props$style$borderRa !== void 0 ? _props$style$borderRa : props.borderRadius);
|
|
1392
1412
|
if (radius) defaultStyle.borderRadius = radius;
|
|
1393
1413
|
const style = {
|
|
1394
1414
|
...defaultStyle,
|
|
1395
1415
|
...props.style
|
|
1396
1416
|
};
|
|
1397
1417
|
style.height = parsePx(style.height, 45);
|
|
1398
|
-
props.onLoad
|
|
1418
|
+
(_props$onLoad = props.onLoad) === null || _props$onLoad === void 0 || _props$onLoad.call(props, true);
|
|
1399
1419
|
let token;
|
|
1400
1420
|
await window[namespace].Buttons({
|
|
1401
1421
|
createOrder: async () => {
|
|
1402
1422
|
try {
|
|
1423
|
+
var _result$paypal;
|
|
1403
1424
|
const result = await createToken$1({
|
|
1404
1425
|
paymentId: props.paymentId,
|
|
1405
1426
|
accountId: props.accountId,
|
|
@@ -1410,15 +1431,19 @@ const onLoadPaypal = async (props, state, src) => {
|
|
|
1410
1431
|
paymentMethod: { paypal: {} }
|
|
1411
1432
|
});
|
|
1412
1433
|
({token} = result);
|
|
1413
|
-
return result.paypal
|
|
1434
|
+
return (_result$paypal = result.paypal) === null || _result$paypal === void 0 ? void 0 : _result$paypal.orderId;
|
|
1414
1435
|
} catch (error) {
|
|
1415
|
-
|
|
1436
|
+
var _props$onError;
|
|
1437
|
+
(_props$onError = props.onError) === null || _props$onError === void 0 || _props$onError.call(props, error);
|
|
1416
1438
|
return;
|
|
1417
1439
|
}
|
|
1418
1440
|
},
|
|
1419
1441
|
onApprove: function(data) {
|
|
1420
1442
|
if (data.orderID) props.onSubmit({ token });
|
|
1421
|
-
else
|
|
1443
|
+
else {
|
|
1444
|
+
var _props$onError2;
|
|
1445
|
+
(_props$onError2 = props.onError) === null || _props$onError2 === void 0 || _props$onError2.call(props, data);
|
|
1446
|
+
}
|
|
1422
1447
|
},
|
|
1423
1448
|
onClick: function(_data, actions) {
|
|
1424
1449
|
let shouldOpen = true;
|
|
@@ -1455,7 +1480,8 @@ const PayPal = createComponent({
|
|
|
1455
1480
|
if (!params.props.accountId && !params.props.paymentId) throw new Error("You need to provide paymentId or accountId");
|
|
1456
1481
|
const container = containerTemplate(params);
|
|
1457
1482
|
params.event.on(EVENT.DESTROY, () => {
|
|
1458
|
-
|
|
1483
|
+
var _namespace;
|
|
1484
|
+
(_namespace = window[namespace]) === null || _namespace === void 0 || (_namespace = _namespace.Buttons) === null || _namespace === void 0 || (_namespace = _namespace.instances) === null || _namespace === void 0 || _namespace.forEach((instance) => {
|
|
1459
1485
|
instance.close();
|
|
1460
1486
|
});
|
|
1461
1487
|
const scriptId = params.state.__scriptId;
|