eddev 0.2.60 → 0.2.62
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/admin/runWidgets.js
CHANGED
|
@@ -18,7 +18,7 @@ exports.runWidgets = void 0;
|
|
|
18
18
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
19
|
// @ts-ignore
|
|
20
20
|
var widgets_1 = __importDefault(require("@manifest/widgets"));
|
|
21
|
-
var
|
|
21
|
+
var client_1 = require("react-dom/client");
|
|
22
22
|
function runWidgets() {
|
|
23
23
|
var elements = document.querySelectorAll("[data-widget]");
|
|
24
24
|
console.log("Running widgets", elements, widgets_1.default);
|
|
@@ -28,11 +28,27 @@ function runWidgets() {
|
|
|
28
28
|
var name_1 = data["widget"];
|
|
29
29
|
var type = widgets_1.default.find(function (item) { return item.name === name_1; });
|
|
30
30
|
if (type) {
|
|
31
|
-
var
|
|
31
|
+
var props_1 = {
|
|
32
32
|
element: el,
|
|
33
33
|
dataset: data,
|
|
34
34
|
};
|
|
35
|
-
|
|
35
|
+
var root_1 = (0, client_1.createRoot)(el);
|
|
36
|
+
var renderWithComponent_1 = function (Component) {
|
|
37
|
+
root_1.render((0, jsx_runtime_1.jsx)(Component, __assign({}, props_1), void 0));
|
|
38
|
+
};
|
|
39
|
+
renderWithComponent_1(type.component);
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
if (import.meta.webpackHot) {
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
import.meta.webpackHot.accept([require.resolve("@manifest/widgets")], function () {
|
|
44
|
+
console.log("Widgets mani");
|
|
45
|
+
var updateWidgets = require("@manifest/widgets").default;
|
|
46
|
+
var type = updateWidgets.find(function (item) { return item.name === name_1; });
|
|
47
|
+
if (type) {
|
|
48
|
+
renderWithComponent_1(type.component);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
36
52
|
}
|
|
37
53
|
}
|
|
38
54
|
});
|
package/hooks/queryUtils.d.ts
CHANGED
|
@@ -20,7 +20,10 @@ declare type QueryHookReturn<TReturn, TVars> = {
|
|
|
20
20
|
refresh: (vars?: TVars) => void;
|
|
21
21
|
};
|
|
22
22
|
declare type QueryHook<TReturn, TVars> = TVars extends undefined ? (vars?: TVars, opts?: QueryOptions) => QueryHookReturn<TReturn, TVars> : (vars: TVars, opts?: QueryOptions) => QueryHookReturn<TReturn, TVars>;
|
|
23
|
-
|
|
23
|
+
declare type QueryFetcher<TReturn, TVars> = {
|
|
24
|
+
fetch: TVars extends undefined ? (vars?: TVars) => Promise<TReturn> : (vars: TVars) => Promise<TReturn>;
|
|
25
|
+
};
|
|
26
|
+
export declare function createUseQuery<TReturn extends any, TVars extends MaybeVars>(init: CreateUseQueryOptions): QueryHook<TReturn, TVars> & QueryFetcher<TReturn, TVars>;
|
|
24
27
|
/** Infinite queries */
|
|
25
28
|
declare type CreateUseInfiniteQueryOptions = {
|
|
26
29
|
name: string;
|
|
@@ -53,5 +56,8 @@ declare type MutationHookReturn<TReturn, TVars> = {
|
|
|
53
56
|
submit: (vars: TVars) => void;
|
|
54
57
|
};
|
|
55
58
|
declare type MutationHook<TReturn, TVars> = (opts?: QueryOptions) => MutationHookReturn<TReturn, TVars>;
|
|
56
|
-
|
|
59
|
+
declare type MutationFetcher<TReturn, TVars> = {
|
|
60
|
+
mutate: (vars: TVars) => Promise<TReturn>;
|
|
61
|
+
};
|
|
62
|
+
export declare function createUseMutation<TReturn extends any, TVars extends MaybeVars>(init: CreateUseQueryOptions): MutationHook<TReturn, TVars> & MutationFetcher<TReturn, TVars>;
|
|
57
63
|
export {};
|
package/hooks/queryUtils.js
CHANGED
|
@@ -95,6 +95,9 @@ function createUseQuery(init) {
|
|
|
95
95
|
refresh: mutate,
|
|
96
96
|
};
|
|
97
97
|
};
|
|
98
|
+
hook.fetch = function (vars) {
|
|
99
|
+
return fetcherGET(init.name, JSON.stringify(vars)).then(function (payload) { return payload.data; });
|
|
100
|
+
};
|
|
98
101
|
return hook;
|
|
99
102
|
}
|
|
100
103
|
exports.createUseQuery = createUseQuery;
|
|
@@ -233,6 +236,35 @@ function createUseMutation(init) {
|
|
|
233
236
|
submit: submit,
|
|
234
237
|
};
|
|
235
238
|
};
|
|
239
|
+
hook.mutate = function (vars) { return __awaiter(_this, void 0, void 0, function () {
|
|
240
|
+
var url, result, payload;
|
|
241
|
+
return __generator(this, function (_a) {
|
|
242
|
+
switch (_a.label) {
|
|
243
|
+
case 0:
|
|
244
|
+
url = process.serverless ? "/api/rest/mutation/".concat(init.name) : "/wp-json/ed/v1/mutation/".concat(init.name);
|
|
245
|
+
return [4 /*yield*/, fetch(url, {
|
|
246
|
+
method: "POST",
|
|
247
|
+
headers: {
|
|
248
|
+
"Content-type": "application/json",
|
|
249
|
+
},
|
|
250
|
+
credentials: "include",
|
|
251
|
+
body: JSON.stringify(vars),
|
|
252
|
+
})];
|
|
253
|
+
case 1:
|
|
254
|
+
result = _a.sent();
|
|
255
|
+
return [4 /*yield*/, result.json()];
|
|
256
|
+
case 2:
|
|
257
|
+
payload = _a.sent();
|
|
258
|
+
if (payload.errors) {
|
|
259
|
+
throw payload.errors;
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
return [2 /*return*/, payload.data];
|
|
263
|
+
}
|
|
264
|
+
return [2 /*return*/];
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
}); };
|
|
236
268
|
return hook;
|
|
237
269
|
}
|
|
238
270
|
exports.createUseMutation = createUseMutation;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eddev",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.62",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"@types/inquirer": "^8.1.1",
|
|
21
21
|
"@types/loadable__component": "^5.13.4",
|
|
22
22
|
"@types/node": "^16.7.10",
|
|
23
|
-
"@types/react": "^
|
|
24
|
-
"@types/react-dom": "^18.0.
|
|
23
|
+
"@types/react": "^18.0.34",
|
|
24
|
+
"@types/react-dom": "^18.0.11",
|
|
25
25
|
"@types/react-inspector": "^4.0.2",
|
|
26
26
|
"@types/rimraf": "^3.0.2",
|
|
27
27
|
"@types/url-parse": "^1.4.4",
|
|
@@ -9,9 +9,8 @@ const gtmID =
|
|
|
9
9
|
settings?.tracking?.tagManagerID === "env" ? process.env.NEXT_PUBLIC_GTM_ID : settings?.tracking?.tagManagerID
|
|
10
10
|
|
|
11
11
|
let analyticsID = settings?.tracking?.ga?.trackingID! || settings?.tracking?.analyticsID!
|
|
12
|
-
|
|
13
12
|
if (analyticsID === "env") {
|
|
14
|
-
analyticsID = process.env.NEXT_PUBLIC_GA_ID!
|
|
13
|
+
analyticsID = process.env.NEXT_PUBLIC_GA_ID!
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
export default class Document extends NextDocument {
|
|
@@ -20,7 +19,7 @@ export default class Document extends NextDocument {
|
|
|
20
19
|
<Html lang="en">
|
|
21
20
|
<Head>
|
|
22
21
|
<style id="stitches" dangerouslySetInnerHTML={{ __html: getCssText() }} />
|
|
23
|
-
{
|
|
22
|
+
{gtmID ? (
|
|
24
23
|
<script
|
|
25
24
|
dangerouslySetInnerHTML={{
|
|
26
25
|
__html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|