@wise/dynamic-flow-client-internal 3.9.0-experimental-90bdf26 → 3.9.1-experimental-152372b
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.
|
@@ -9,17 +9,57 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
12
48
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
49
|
+
import { forwardRef, useCallback } from 'react';
|
|
50
|
+
import { useIntl } from 'react-intl';
|
|
51
|
+
import { DynamicFlow as DynamicFlowCoreLegacy, DynamicFlowRevamp as DynamicFlowCoreRevamp, DynamicFragmentWise, } from '@wise/dynamic-flow-client';
|
|
52
|
+
import { mergeRequestInit } from './utils/mergeRequestInit';
|
|
15
53
|
export function DynamicFlowLegacy(props) {
|
|
16
54
|
var _a = props.customFetch, customFetch = _a === void 0 ? globalThis.fetch : _a;
|
|
17
|
-
var
|
|
55
|
+
var httpClient = useWiseHttpClient(customFetch);
|
|
56
|
+
var coreProps = __assign(__assign({}, props), { httpClient: httpClient });
|
|
18
57
|
return _jsx(DynamicFlowCoreLegacy, __assign({}, coreProps));
|
|
19
58
|
}
|
|
20
59
|
export function DynamicFlowRevamp(props) {
|
|
21
60
|
var _a = props.customFetch, customFetch = _a === void 0 ? globalThis.fetch : _a;
|
|
22
|
-
var
|
|
61
|
+
var httpClient = useWiseHttpClient(customFetch);
|
|
62
|
+
var coreProps = __assign(__assign({}, props), { httpClient: httpClient });
|
|
23
63
|
return _jsx(DynamicFlowCoreRevamp, __assign({}, coreProps));
|
|
24
64
|
}
|
|
25
65
|
/**
|
|
@@ -29,6 +69,18 @@ export function DynamicFlowRevamp(props) {
|
|
|
29
69
|
*/
|
|
30
70
|
export var DynamicFragment = forwardRef(function DynamicFragment(props, ref) {
|
|
31
71
|
var _a = props.customFetch, customFetch = _a === void 0 ? globalThis.fetch : _a;
|
|
32
|
-
var
|
|
72
|
+
var httpClient = useWiseHttpClient(customFetch);
|
|
73
|
+
var coreProps = __assign(__assign({}, props), { httpClient: httpClient });
|
|
33
74
|
return _jsx(DynamicFragmentWise, __assign({}, coreProps, { ref: ref }));
|
|
34
75
|
});
|
|
76
|
+
var useWiseHttpClient = function (httpClient) {
|
|
77
|
+
var locale = useIntl().locale;
|
|
78
|
+
return useCallback(function (input, init) { return __awaiter(void 0, void 0, void 0, function () {
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
return [2 /*return*/, httpClient(input, mergeRequestInit(init, {
|
|
81
|
+
credentials: 'include',
|
|
82
|
+
headers: { 'accept-language': locale },
|
|
83
|
+
}))];
|
|
84
|
+
});
|
|
85
|
+
}); }, [httpClient, locale]);
|
|
86
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
export var mergeRequestInit = function (init, additionalInit) { return (__assign(__assign(__assign({}, init), additionalInit), { headers: mergeHeaders(init === null || init === void 0 ? void 0 : init.headers, additionalInit === null || additionalInit === void 0 ? void 0 : additionalInit.headers) })); };
|
|
13
|
+
var mergeHeaders = function (initHeaders, additionalHeaders) {
|
|
14
|
+
if (!initHeaders && !additionalHeaders) {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
var headers = new Headers(initHeaders);
|
|
18
|
+
for (var _i = 0, _a = Object.entries(additionalHeaders !== null && additionalHeaders !== void 0 ? additionalHeaders : {}); _i < _a.length; _i++) {
|
|
19
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
20
|
+
headers.set(key, value);
|
|
21
|
+
}
|
|
22
|
+
return headers;
|
|
23
|
+
};
|
package/build/main.js
CHANGED
|
@@ -51,24 +51,58 @@ var import_dynamic_flow_client2 = require("@wise/dynamic-flow-client");
|
|
|
51
51
|
var import_dynamic_flow_client3 = require("@wise/dynamic-flow-client");
|
|
52
52
|
|
|
53
53
|
// src/dynamicFlow/DynamicFlow.tsx
|
|
54
|
-
var import_dynamic_flow_client = require("@wise/dynamic-flow-client");
|
|
55
54
|
var import_react = require("react");
|
|
55
|
+
var import_react_intl = require("react-intl");
|
|
56
|
+
var import_dynamic_flow_client = require("@wise/dynamic-flow-client");
|
|
57
|
+
|
|
58
|
+
// src/dynamicFlow/utils/mergeRequestInit.ts
|
|
59
|
+
var mergeRequestInit = (init, additionalInit) => __spreadProps(__spreadValues(__spreadValues({}, init), additionalInit), {
|
|
60
|
+
headers: mergeHeaders(init == null ? void 0 : init.headers, additionalInit == null ? void 0 : additionalInit.headers)
|
|
61
|
+
});
|
|
62
|
+
var mergeHeaders = (initHeaders, additionalHeaders) => {
|
|
63
|
+
if (!initHeaders && !additionalHeaders) {
|
|
64
|
+
return {};
|
|
65
|
+
}
|
|
66
|
+
const headers = new Headers(initHeaders);
|
|
67
|
+
for (const [key, value] of Object.entries(additionalHeaders != null ? additionalHeaders : {})) {
|
|
68
|
+
headers.set(key, value);
|
|
69
|
+
}
|
|
70
|
+
return headers;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// src/dynamicFlow/DynamicFlow.tsx
|
|
56
74
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
57
75
|
function DynamicFlowLegacy(props) {
|
|
58
76
|
const { customFetch = globalThis.fetch } = props;
|
|
59
|
-
const
|
|
77
|
+
const httpClient = useWiseHttpClient(customFetch);
|
|
78
|
+
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient });
|
|
60
79
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dynamic_flow_client.DynamicFlow, __spreadValues({}, coreProps));
|
|
61
80
|
}
|
|
62
81
|
function DynamicFlowRevamp(props) {
|
|
63
82
|
const { customFetch = globalThis.fetch } = props;
|
|
64
|
-
const
|
|
83
|
+
const httpClient = useWiseHttpClient(customFetch);
|
|
84
|
+
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient });
|
|
65
85
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dynamic_flow_client.DynamicFlowRevamp, __spreadValues({}, coreProps));
|
|
66
86
|
}
|
|
67
87
|
var DynamicFragment = (0, import_react.forwardRef)(function DynamicFragment2(props, ref) {
|
|
68
88
|
const { customFetch = globalThis.fetch } = props;
|
|
69
|
-
const
|
|
89
|
+
const httpClient = useWiseHttpClient(customFetch);
|
|
90
|
+
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient });
|
|
70
91
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dynamic_flow_client.DynamicFragmentWise, __spreadProps(__spreadValues({}, coreProps), { ref }));
|
|
71
92
|
});
|
|
93
|
+
var useWiseHttpClient = (httpClient) => {
|
|
94
|
+
const { locale } = (0, import_react_intl.useIntl)();
|
|
95
|
+
return (0, import_react.useCallback)(
|
|
96
|
+
async (input, init) => httpClient(
|
|
97
|
+
input,
|
|
98
|
+
mergeRequestInit(init, {
|
|
99
|
+
credentials: "include",
|
|
100
|
+
headers: { "accept-language": locale }
|
|
101
|
+
})
|
|
102
|
+
),
|
|
103
|
+
[httpClient, locale]
|
|
104
|
+
);
|
|
105
|
+
};
|
|
72
106
|
|
|
73
107
|
// src/index.ts
|
|
74
108
|
var makeCustomFetch = import_dynamic_flow_client2.makeHttpClient;
|
package/build/main.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var s=Object.defineProperty,v=Object.defineProperties,I=Object.getOwnPropertyDescriptor,W=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols;var h=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var D=(t,e,o)=>e in t?s(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,n=(t,e)=>{for(var o in e||(e={}))h.call(e,o)&&D(t,o,e[o]);if(w)for(var o of w(e))L.call(e,o)&&D(t,o,e[o]);return t},r=(t,e)=>v(t,W(e));var b=(t,e)=>{for(var o in e)s(t,o,{get:e[o],enumerable:!0})},S=(t,e,o,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of x(e))!h.call(t,a)&&a!==o&&s(t,a,{get:()=>e[a],enumerable:!(c=I(e,a))||c.enumerable});return t};var q=t=>S(s({},"__esModule",{value:!0}),t);var T={};b(T,{DynamicFlow:()=>y,DynamicFlowLegacy:()=>y,DynamicFlowRevamp:()=>u,DynamicFragment:()=>P,JsonSchemaForm:()=>i.JsonSchemaForm,isValidSchema:()=>i.isValidSchema,makeCustomFetch:()=>O,translations:()=>i.translations});module.exports=q(T);var R=require("@wise/dynamic-flow-client"),i=require("@wise/dynamic-flow-client");var p=require("react"),g=require("react-intl"),m=require("@wise/dynamic-flow-client");var f=(t,e)=>r(n(n({},t),e),{headers:A(t==null?void 0:t.headers,e==null?void 0:e.headers)}),A=(t,e)=>{if(!t&&!e)return{};let o=new Headers(t);for(let[c,a]of Object.entries(e!=null?e:{}))o.set(c,a);return o};var l=require("react/jsx-runtime");function y(t){let{customFetch:e=globalThis.fetch}=t,o=F(e),c=r(n({},t),{httpClient:o});return(0,l.jsx)(m.DynamicFlow,n({},c))}function u(t){let{customFetch:e=globalThis.fetch}=t,o=F(e),c=r(n({},t),{httpClient:o});return(0,l.jsx)(m.DynamicFlowRevamp,n({},c))}var P=(0,p.forwardRef)(function(e,o){let{customFetch:c=globalThis.fetch}=e,a=F(c),C=r(n({},e),{httpClient:a});return(0,l.jsx)(m.DynamicFragmentWise,r(n({},C),{ref:o}))}),F=t=>{let{locale:e}=(0,g.useIntl)();return(0,p.useCallback)(async(o,c)=>t(o,f(c,{credentials:"include",headers:{"accept-language":e}})),[t,e])};var O=R.makeHttpClient;
|
package/build/main.mjs
CHANGED
|
@@ -23,28 +23,62 @@ import { makeHttpClient } from "@wise/dynamic-flow-client";
|
|
|
23
23
|
import { translations, JsonSchemaForm, isValidSchema } from "@wise/dynamic-flow-client";
|
|
24
24
|
|
|
25
25
|
// src/dynamicFlow/DynamicFlow.tsx
|
|
26
|
+
import { forwardRef, useCallback } from "react";
|
|
27
|
+
import { useIntl } from "react-intl";
|
|
26
28
|
import {
|
|
27
|
-
DynamicFlowRevamp as DynamicFlowCoreRevamp,
|
|
28
29
|
DynamicFlow as DynamicFlowCoreLegacy,
|
|
30
|
+
DynamicFlowRevamp as DynamicFlowCoreRevamp,
|
|
29
31
|
DynamicFragmentWise
|
|
30
32
|
} from "@wise/dynamic-flow-client";
|
|
31
|
-
|
|
33
|
+
|
|
34
|
+
// src/dynamicFlow/utils/mergeRequestInit.ts
|
|
35
|
+
var mergeRequestInit = (init, additionalInit) => __spreadProps(__spreadValues(__spreadValues({}, init), additionalInit), {
|
|
36
|
+
headers: mergeHeaders(init == null ? void 0 : init.headers, additionalInit == null ? void 0 : additionalInit.headers)
|
|
37
|
+
});
|
|
38
|
+
var mergeHeaders = (initHeaders, additionalHeaders) => {
|
|
39
|
+
if (!initHeaders && !additionalHeaders) {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
const headers = new Headers(initHeaders);
|
|
43
|
+
for (const [key, value] of Object.entries(additionalHeaders != null ? additionalHeaders : {})) {
|
|
44
|
+
headers.set(key, value);
|
|
45
|
+
}
|
|
46
|
+
return headers;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// src/dynamicFlow/DynamicFlow.tsx
|
|
32
50
|
import { jsx } from "react/jsx-runtime";
|
|
33
51
|
function DynamicFlowLegacy(props) {
|
|
34
52
|
const { customFetch = globalThis.fetch } = props;
|
|
35
|
-
const
|
|
53
|
+
const httpClient = useWiseHttpClient(customFetch);
|
|
54
|
+
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient });
|
|
36
55
|
return /* @__PURE__ */ jsx(DynamicFlowCoreLegacy, __spreadValues({}, coreProps));
|
|
37
56
|
}
|
|
38
57
|
function DynamicFlowRevamp(props) {
|
|
39
58
|
const { customFetch = globalThis.fetch } = props;
|
|
40
|
-
const
|
|
59
|
+
const httpClient = useWiseHttpClient(customFetch);
|
|
60
|
+
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient });
|
|
41
61
|
return /* @__PURE__ */ jsx(DynamicFlowCoreRevamp, __spreadValues({}, coreProps));
|
|
42
62
|
}
|
|
43
63
|
var DynamicFragment = forwardRef(function DynamicFragment2(props, ref) {
|
|
44
64
|
const { customFetch = globalThis.fetch } = props;
|
|
45
|
-
const
|
|
65
|
+
const httpClient = useWiseHttpClient(customFetch);
|
|
66
|
+
const coreProps = __spreadProps(__spreadValues({}, props), { httpClient });
|
|
46
67
|
return /* @__PURE__ */ jsx(DynamicFragmentWise, __spreadProps(__spreadValues({}, coreProps), { ref }));
|
|
47
68
|
});
|
|
69
|
+
var useWiseHttpClient = (httpClient) => {
|
|
70
|
+
const { locale } = useIntl();
|
|
71
|
+
return useCallback(
|
|
72
|
+
async (input, init) => httpClient(
|
|
73
|
+
input,
|
|
74
|
+
mergeRequestInit(init, {
|
|
75
|
+
credentials: "include",
|
|
76
|
+
headers: { "accept-language": locale }
|
|
77
|
+
})
|
|
78
|
+
),
|
|
79
|
+
[httpClient, locale]
|
|
80
|
+
);
|
|
81
|
+
};
|
|
48
82
|
|
|
49
83
|
// src/index.ts
|
|
50
84
|
var makeCustomFetch = makeHttpClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const mergeRequestInit: (init?: RequestInit, additionalInit?: RequestInit) => RequestInit;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/dynamic-flow-client-internal",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.1-experimental-152372b",
|
|
4
4
|
"description": "Dynamic Flow web client for Wise",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./build/main.min.js",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"typescript": "5.1.6",
|
|
74
74
|
"webpack": "5.91.0",
|
|
75
75
|
"@wise/dynamic-flow-fixtures": "0.0.1",
|
|
76
|
-
"@wise/dynamic-flow-types": "2.
|
|
76
|
+
"@wise/dynamic-flow-types": "2.15.0-experimental-152372b"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"react": "^18",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"react-intl": "^6"
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@wise/dynamic-flow-client": "3.9.
|
|
84
|
+
"@wise/dynamic-flow-client": "3.9.1-experimental-152372b"
|
|
85
85
|
},
|
|
86
86
|
"scripts": {
|
|
87
87
|
"dev": "storybook dev -p 3005",
|