eddev 0.2.67-beta1 → 0.3.0-beta1
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/components/ImageWell.d.ts +2 -2
- package/admin/components/ImageWell.js +51 -39
- package/admin/defineField.d.ts +2 -2
- package/admin/defineWidget.d.ts +1 -1
- package/admin/defineWidget.js +2 -2
- package/admin/index.js +1 -5
- package/admin/installFieldTypes.js +26 -26
- package/admin/runWidgets.js +28 -17
- package/admin/selectMedia.d.ts +2 -2
- package/admin/selectMedia.js +1 -1
- package/blocks/ContentBlocks.d.ts +6 -6
- package/blocks/ContentBlocks.js +66 -58
- package/blocks/ErrorBoundaryEditor.d.ts +1 -1
- package/blocks/ErrorBoundaryEditor.js +45 -16
- package/blocks/ErrorBoundaryFrontend.d.ts +1 -1
- package/blocks/ErrorBoundaryFrontend.js +45 -16
- package/blocks/InspectorControls.d.ts +1 -1
- package/blocks/InspectorControls.js +3 -3
- package/blocks/blockAttributes.d.ts +2 -2
- package/blocks/blockAttributes.js +44 -24
- package/blocks/index.js +1 -5
- package/blocks/inlineEditing.d.ts +6 -6
- package/blocks/inlineEditing.js +55 -36
- package/blocks/installGutenbergHooks.js +68 -48
- package/build/babel/plugin-name-defined-components.js +16 -15
- package/build/build-favicon.js +62 -11
- package/build/clean.js +52 -5
- package/build/create-codegen-worker.js +33 -78
- package/build/create-serverless-dev-worker.js +39 -61
- package/build/create-webpack-worker.js +33 -65
- package/build/file-tree.d.ts +2 -2
- package/build/file-tree.js +12 -12
- package/build/get-webpack-config.js +395 -341
- package/build/graphql-codegen/graphql-codegen-files.js +25 -31
- package/build/graphql-codegen/graphql-codegen-no-duplicates.js +4 -4
- package/build/graphql-codegen/graphql-codegen-queries.js +99 -102
- package/build/manifests/manifest-blocks.d.ts +1 -1
- package/build/manifests/manifest-blocks.js +29 -37
- package/build/manifests/manifest-fields.d.ts +1 -1
- package/build/manifests/manifest-fields.js +21 -23
- package/build/manifests/manifest-views.d.ts +1 -1
- package/build/manifests/manifest-views.js +25 -32
- package/build/manifests/manifest-widgets.d.ts +1 -1
- package/build/manifests/manifest-widgets.js +20 -22
- package/build/manifests/manifest.d.ts +2 -2
- package/build/manifests/manifest.js +94 -30
- package/build/reporter.d.ts +1 -1
- package/build/reporter.js +32 -29
- package/build/serverless/create-next-app.d.ts +1 -1
- package/build/serverless/create-next-app.js +467 -245
- package/build/state/codegen-state.d.ts +4 -4
- package/build/state/compiler-state.d.ts +5 -5
- package/build/state/serverless-state.d.ts +3 -3
- package/build/workers/codegen-worker-script.js +519 -393
- package/build/workers/serverless-worker-dev-script.js +4 -4
- package/build/workers/webpack-worker-script.js +156 -90
- package/cli/build.dev.d.ts +1 -1
- package/cli/build.dev.js +126 -79
- package/cli/build.prod.d.ts +1 -1
- package/cli/build.prod.js +98 -42
- package/cli/cli.js +28 -19
- package/cli/display/components/BundleDisplay.d.ts +1 -1
- package/cli/display/components/BundleDisplay.js +24 -13
- package/cli/display/components/CodegenDisplay.d.ts +1 -1
- package/cli/display/components/CodegenDisplay.js +25 -14
- package/cli/display/components/DevCLIDisplay.d.ts +2 -2
- package/cli/display/components/DevCLIDisplay.js +25 -14
- package/cli/display/components/Fullscreen.js +20 -9
- package/cli/display/components/ServerlessDisplay.d.ts +2 -2
- package/cli/display/components/ServerlessDisplay.js +26 -15
- package/cli/display/components/StatusIcon.d.ts +2 -2
- package/cli/display/components/StatusIcon.js +3 -3
- package/cli/preinstall.js +5 -4
- package/cli/setup.js +73 -25
- package/components/AdminBar.d.ts +1 -1
- package/components/AdminBar.js +3 -37
- package/components/BrowserRouter.d.ts +2 -2
- package/components/BrowserRouter.js +54 -41
- package/components/InlinePage.d.ts +2 -2
- package/components/InlinePage.js +29 -17
- package/components/NextRouter.d.ts +2 -2
- package/components/NextRouter.js +29 -20
- package/components/index.js +1 -5
- package/config/config-schema.d.ts +1 -1
- package/config/config-schema.js +1 -1
- package/config/create-schema-file.js +6 -6
- package/config/get-config.js +13 -10
- package/config/index.js +1 -5
- package/config/parse-config.js +1 -1
- package/config/print-zod-errors.js +3 -3
- package/dev-ui/components/BreakpointColumnHeader.d.ts +2 -2
- package/dev-ui/components/BreakpointColumnHeader.js +18 -7
- package/dev-ui/components/BreakpointIndicator.d.ts +1 -1
- package/dev-ui/components/BreakpointIndicator.js +32 -25
- package/dev-ui/components/DevUI.d.ts +1 -1
- package/dev-ui/components/DevUI.js +13 -13
- package/dev-ui/components/Launcher.d.ts +2 -2
- package/dev-ui/components/Launcher.js +25 -13
- package/dev-ui/components/PanelWrapper.d.ts +2 -2
- package/dev-ui/components/PanelWrapper.js +8 -8
- package/dev-ui/components/ResponsiveLerpControl.d.ts +2 -2
- package/dev-ui/components/ResponsiveLerpControl.js +38 -27
- package/dev-ui/components/ResponsiveScaleEditor.d.ts +4 -4
- package/dev-ui/components/ResponsiveScaleEditor.js +78 -64
- package/dev-ui/components/atoms/Button.js +1 -1
- package/dev-ui/components/atoms/Dropdown.d.ts +3 -3
- package/dev-ui/components/atoms/Dropdown.js +9 -8
- package/dev-ui/components/atoms/NumberField.d.ts +2 -2
- package/dev-ui/components/atoms/NumberField.js +42 -29
- package/dev-ui/components/atoms/Spacer.js +1 -1
- package/dev-ui/components/atoms/Text.js +1 -1
- package/dev-ui/components/atoms/ToggleButton.d.ts +2 -2
- package/dev-ui/components/atoms/ToggleButton.js +16 -5
- package/dev-ui/components/atoms/Tooltip.d.ts +2 -2
- package/dev-ui/components/atoms/Tooltip.js +20 -8
- package/dev-ui/components/panels/AppDataDebugger.d.ts +1 -1
- package/dev-ui/components/panels/AppDataDebugger.js +19 -8
- package/dev-ui/components/panels/ColorEditor.d.ts +1 -1
- package/dev-ui/components/panels/ColorEditor.js +42 -35
- package/dev-ui/components/panels/PageDataDebugger.d.ts +1 -1
- package/dev-ui/components/panels/PageDataDebugger.js +20 -8
- package/dev-ui/components/panels/QueryDebugger.d.ts +1 -1
- package/dev-ui/components/panels/QueryDebugger.js +24 -12
- package/dev-ui/components/panels/SpacingEditor.d.ts +1 -1
- package/dev-ui/components/panels/SpacingEditor.js +48 -34
- package/dev-ui/components/panels/TypographyEditor.d.ts +1 -1
- package/dev-ui/components/panels/TypographyEditor.js +46 -38
- package/dev-ui/hooks/useBreakpoint.d.ts +1 -1
- package/dev-ui/hooks/useBreakpoint.js +13 -13
- package/dev-ui/hooks/usePersistState.js +7 -6
- package/dev-ui/hooks/useStylesheet.js +6 -6
- package/dev-ui/icons.d.ts +15 -15
- package/dev-ui/icons.js +27 -16
- package/dev-ui/index.js +1 -5
- package/dev-ui/loader.d.ts +1 -1
- package/dev-ui/loader.js +9 -13
- package/dev-ui/panels.d.ts +2 -2
- package/dev-ui/panels.js +7 -7
- package/dev-ui/theme.js +3 -3
- package/dynamic/dynamic-component.js +1 -1
- package/dynamic/index.js +1 -5
- package/entry/Root.d.ts +2 -2
- package/entry/Root.js +26 -16
- package/entry/entry.admin.dev.js +4 -4
- package/entry/entry.admin.prod.js +4 -4
- package/entry/entry.monolith.dev.js +5 -5
- package/entry/entry.monolith.prod.js +5 -5
- package/gravityforms/gravity-forms.d.ts +2 -2
- package/gravityforms/index.js +1 -5
- package/gravityforms/useGravityForm.d.ts +2 -2
- package/gravityforms/useGravityForm.js +130 -126
- package/hooks/index.js +1 -5
- package/hooks/queryUtils.d.ts +14 -14
- package/hooks/queryUtils.js +192 -101
- package/hooks/useAppData.d.ts +2 -2
- package/hooks/useAppData.js +9 -9
- package/hooks/usePageLoad.js +4 -4
- package/hooks/useQueryDebug.d.ts +1 -1
- package/hooks/useQueryDebug.js +7 -7
- package/hooks/useRPC.d.ts +4 -4
- package/hooks/useRPC.js +3 -3
- package/package.json +11 -11
- package/routing/index.js +1 -5
- package/routing/remoteProps.d.ts +1 -1
- package/routing/remoteProps.js +72 -31
- package/routing/routing.d.ts +25 -15
- package/routing/routing.js +200 -112
- package/routing/updateEditLink.js +1 -1
- package/serverless/define-api.d.ts +1 -1
- package/serverless/define-rpc-router.js +4 -8
- package/serverless/index.js +2 -6
- package/style/createStitches.js +142 -164
- package/style/index.js +1 -5
- package/tsconfig.json +1 -1
- package/utils/Observable.d.ts +2 -2
- package/utils/Observable.js +15 -12
- package/utils/getRepoName.js +3 -3
- package/utils/promptIfRepoNameIncorrect.js +64 -18
- package/utils/refreshOverlayInterop.js +1 -1
- package/utils/reportErrorStack.d.ts +1 -1
- package/utils/reportErrorStack.js +1 -1
- package/utils/serverlessAppContext.js +1 -1
- package/utils/updateEnvFile.js +69 -19
- package/utils/useObservable.js +3 -3
- package/views/index.js +1 -5
package/routing/routing.js
CHANGED
|
@@ -1,22 +1,75 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
2
49
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
51
|
};
|
|
5
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.RouteItemContext = exports.Switch = exports.Link = exports.isInternalPageLink = exports.RouterRoot = exports.createRouteItem = exports.Route = exports.useRouter = exports.useRoute = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
53
|
+
exports.RouteItemContext = exports.Switch = exports.Link = exports.urlDescendentsMatch = exports.urlPathsMatch = exports.isInternalPageLink = exports.RouterRoot = exports.createRouteItem = exports.Route = exports.useRouter = exports.useRoute = void 0;
|
|
54
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
55
|
+
var react_1 = require("react");
|
|
56
|
+
var react_merge_refs_1 = __importDefault(require("react-merge-refs"));
|
|
57
|
+
var url_parse_1 = __importDefault(require("url-parse"));
|
|
11
58
|
// const logger = (...args: any[]) => console.log(...args)
|
|
12
|
-
|
|
59
|
+
var logger = function () {
|
|
60
|
+
var args = [];
|
|
61
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
62
|
+
args[_i] = arguments[_i];
|
|
63
|
+
}
|
|
64
|
+
};
|
|
13
65
|
function createRouteContext(opts) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
66
|
+
var _a, _b;
|
|
67
|
+
var subscribers = [];
|
|
68
|
+
var notify = function (item, status) {
|
|
69
|
+
subscribers.forEach(function (handler) { return handler(item, status); });
|
|
17
70
|
};
|
|
18
|
-
|
|
19
|
-
|
|
71
|
+
var parentIsSwitch = opts.parent && opts.parent.isSwitch;
|
|
72
|
+
var ctx = {
|
|
20
73
|
item: opts.initial,
|
|
21
74
|
config: opts.config || {},
|
|
22
75
|
parent: opts.parent,
|
|
@@ -24,21 +77,23 @@ function createRouteContext(opts) {
|
|
|
24
77
|
status: "inactive",
|
|
25
78
|
currentMatch: false,
|
|
26
79
|
isSwitch: !!opts.isSwitch,
|
|
80
|
+
navigate: opts.onNavigate,
|
|
81
|
+
preload: opts.onPreload,
|
|
27
82
|
onNavigate: opts.onNavigate,
|
|
28
83
|
onPreload: opts.onPreload,
|
|
29
|
-
propagateChange(item, matches) {
|
|
84
|
+
propagateChange: function (item, matches) {
|
|
30
85
|
ctx.item = item;
|
|
31
86
|
ctx.currentMatch = matches;
|
|
32
87
|
ctx.status = matches ? "active" : "inactive";
|
|
33
|
-
ctx.children.forEach((child)
|
|
88
|
+
ctx.children.forEach(function (child) {
|
|
34
89
|
child.propagateChange(item, child.match(item));
|
|
35
90
|
});
|
|
36
91
|
notify(item, ctx.status);
|
|
37
92
|
},
|
|
38
|
-
propagateCandidate(next, prev) {
|
|
93
|
+
propagateCandidate: function (next, prev) {
|
|
39
94
|
// if (ctx.status === "leaving") return Promise.resolve();
|
|
40
|
-
|
|
41
|
-
|
|
95
|
+
var promises = [Promise.resolve()];
|
|
96
|
+
var matches = ctx.match(next);
|
|
42
97
|
logger(ctx.config.debugName, "was", ctx.status, matches);
|
|
43
98
|
if (ctx.status === "active" && (!matches || matches !== ctx.currentMatch)) {
|
|
44
99
|
logger(ctx.config.debugName, "is leaving because ", matches, "!=", ctx.currentMatch);
|
|
@@ -49,24 +104,24 @@ function createRouteContext(opts) {
|
|
|
49
104
|
promises.push(this.propagateLeaving(prev, next, false));
|
|
50
105
|
}
|
|
51
106
|
else {
|
|
52
|
-
ctx.children.forEach((child)
|
|
107
|
+
ctx.children.forEach(function (child) {
|
|
53
108
|
promises.push(child.propagateCandidate(next, prev));
|
|
54
109
|
});
|
|
55
110
|
}
|
|
56
111
|
notify(prev, ctx.status);
|
|
57
112
|
return Promise.all(promises);
|
|
58
113
|
},
|
|
59
|
-
propagateLeaving(current, next, parentIsLeaving) {
|
|
114
|
+
propagateLeaving: function (current, next, parentIsLeaving) {
|
|
60
115
|
ctx.status = parentIsLeaving ? "parent-leaving" : "leaving";
|
|
61
116
|
logger(ctx.status);
|
|
62
|
-
|
|
117
|
+
var promises = [Promise.resolve()];
|
|
63
118
|
if (ctx.config.beforeLeave) {
|
|
64
|
-
|
|
119
|
+
var result = ctx.config.beforeLeave(current, next, parentIsLeaving);
|
|
65
120
|
if (result)
|
|
66
121
|
promises.push(result);
|
|
67
122
|
}
|
|
68
|
-
ctx.children.forEach((child)
|
|
69
|
-
|
|
123
|
+
ctx.children.forEach(function (child) {
|
|
124
|
+
var result = child.propagateLeaving(current, next, true);
|
|
70
125
|
if (result) {
|
|
71
126
|
promises.push(result);
|
|
72
127
|
}
|
|
@@ -74,52 +129,55 @@ function createRouteContext(opts) {
|
|
|
74
129
|
notify(current, ctx.status);
|
|
75
130
|
return Promise.all(promises);
|
|
76
131
|
},
|
|
77
|
-
subscribe(handler) {
|
|
132
|
+
subscribe: function (handler) {
|
|
78
133
|
subscribers.push(handler);
|
|
79
134
|
handler(ctx.item, ctx.status);
|
|
80
|
-
return ()
|
|
81
|
-
|
|
135
|
+
return function () {
|
|
136
|
+
var i = subscribers.indexOf(handler);
|
|
82
137
|
if (i !== -1) {
|
|
83
138
|
subscribers.splice(i, 1);
|
|
84
139
|
}
|
|
85
140
|
};
|
|
86
141
|
},
|
|
87
|
-
getFirstMatch(item) {
|
|
142
|
+
getFirstMatch: function (item) {
|
|
88
143
|
logger("Checking items", this.children, item);
|
|
89
|
-
for (
|
|
144
|
+
for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
|
|
145
|
+
var child = _a[_i];
|
|
90
146
|
if (child.matchSelf(item)) {
|
|
91
147
|
logger("Matched", child.config.debugName);
|
|
92
148
|
return child;
|
|
93
149
|
}
|
|
94
150
|
}
|
|
95
151
|
},
|
|
96
|
-
match(item) {
|
|
152
|
+
match: function (item) {
|
|
97
153
|
if (parentIsSwitch) {
|
|
98
|
-
|
|
99
|
-
return
|
|
154
|
+
var parent_1 = ctx.parent;
|
|
155
|
+
return parent_1.getFirstMatch(item) === ctx && this.matchSelf(item);
|
|
100
156
|
}
|
|
101
157
|
return this.matchSelf(item);
|
|
102
158
|
},
|
|
103
|
-
matchSelf(item) {
|
|
104
|
-
|
|
105
|
-
|
|
159
|
+
matchSelf: function (item) {
|
|
160
|
+
var _a, _b;
|
|
161
|
+
if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.config) === null || _a === void 0 ? void 0 : _a.match) {
|
|
162
|
+
return (_b = ctx === null || ctx === void 0 ? void 0 : ctx.config) === null || _b === void 0 ? void 0 : _b.match(item);
|
|
106
163
|
}
|
|
107
164
|
else {
|
|
108
165
|
return true;
|
|
109
166
|
}
|
|
110
167
|
},
|
|
111
|
-
update: ()
|
|
112
|
-
dispose: opts.dispose
|
|
113
|
-
fork(config, opts
|
|
114
|
-
|
|
168
|
+
update: function () { },
|
|
169
|
+
dispose: (_a = opts.dispose) !== null && _a !== void 0 ? _a : (function () { }),
|
|
170
|
+
fork: function (config, opts) {
|
|
171
|
+
if (opts === void 0) { opts = {}; }
|
|
172
|
+
var child = createRouteContext({
|
|
115
173
|
initial: ctx.item,
|
|
116
|
-
config,
|
|
174
|
+
config: config,
|
|
117
175
|
parent: ctx,
|
|
118
176
|
isSwitch: opts.isSwitch,
|
|
119
|
-
onNavigate: ctx.
|
|
120
|
-
onPreload: ctx.
|
|
121
|
-
dispose: ()
|
|
122
|
-
|
|
177
|
+
onNavigate: ctx.navigate,
|
|
178
|
+
onPreload: ctx.preload,
|
|
179
|
+
dispose: function () {
|
|
180
|
+
var i = ctx.children.indexOf(child);
|
|
123
181
|
if (i !== -1)
|
|
124
182
|
ctx.children.splice(i, 1);
|
|
125
183
|
},
|
|
@@ -133,7 +191,7 @@ function createRouteContext(opts) {
|
|
|
133
191
|
logger("Initting", ctx.config.debugName, opts.initial);
|
|
134
192
|
if (parentIsSwitch) {
|
|
135
193
|
logger("Parent is switch");
|
|
136
|
-
if (!opts.parent
|
|
194
|
+
if (!((_b = opts.parent) === null || _b === void 0 ? void 0 : _b.getFirstMatch(opts.initial))) {
|
|
137
195
|
logger("FFFF", ctx.config.match, ctx.match(opts.initial));
|
|
138
196
|
ctx.currentMatch = ctx.matchSelf(opts.initial);
|
|
139
197
|
ctx.status = ctx.currentMatch ? "active" : "inactive";
|
|
@@ -143,7 +201,7 @@ function createRouteContext(opts) {
|
|
|
143
201
|
ctx.currentMatch = ctx.matchSelf(opts.initial);
|
|
144
202
|
ctx.status = ctx.currentMatch ? "active" : "inactive";
|
|
145
203
|
}
|
|
146
|
-
subscribers.push((item, status)
|
|
204
|
+
subscribers.push(function (item, status) {
|
|
147
205
|
if (ctx.config.onChange) {
|
|
148
206
|
ctx.config.onChange(item, status);
|
|
149
207
|
}
|
|
@@ -151,24 +209,26 @@ function createRouteContext(opts) {
|
|
|
151
209
|
// notify(ctx.item, ctx.status);
|
|
152
210
|
return ctx;
|
|
153
211
|
}
|
|
154
|
-
|
|
212
|
+
var RouterContext = (0, react_1.createContext)(undefined);
|
|
155
213
|
function useForkedRouter(conf, opts) {
|
|
156
|
-
|
|
157
|
-
|
|
214
|
+
var parent = (0, react_1.useContext)(RouterContext);
|
|
215
|
+
var ctx = (0, react_1.useMemo)(function () {
|
|
158
216
|
return parent.fork(conf, opts);
|
|
159
217
|
}, [parent]);
|
|
160
218
|
Object.assign(ctx.config, conf);
|
|
161
|
-
(0, react_1.useEffect)(()
|
|
162
|
-
return ()
|
|
219
|
+
(0, react_1.useEffect)(function () {
|
|
220
|
+
return function () { return ctx.dispose(); };
|
|
163
221
|
}, [ctx]);
|
|
164
222
|
return ctx;
|
|
165
223
|
}
|
|
166
224
|
function useRoute() {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
(0, react_1.useEffect)(
|
|
170
|
-
|
|
171
|
-
|
|
225
|
+
var router = (0, react_1.useContext)(RouterContext);
|
|
226
|
+
var _a = (0, react_1.useState)(router.item), route = _a[0], setRoute = _a[1];
|
|
227
|
+
(0, react_1.useEffect)(function () {
|
|
228
|
+
return router.subscribe(function (item, status) {
|
|
229
|
+
setRoute(item);
|
|
230
|
+
});
|
|
231
|
+
}, [router]);
|
|
172
232
|
return route;
|
|
173
233
|
}
|
|
174
234
|
exports.useRoute = useRoute;
|
|
@@ -177,59 +237,62 @@ function useRouter() {
|
|
|
177
237
|
}
|
|
178
238
|
exports.useRouter = useRouter;
|
|
179
239
|
function Route(props) {
|
|
180
|
-
|
|
240
|
+
var ctx = useForkedRouter({
|
|
181
241
|
match: props.match,
|
|
182
242
|
beforeLeave: props.beforeLeave,
|
|
183
243
|
debugName: props.debugName,
|
|
184
244
|
onChange: props.onChange,
|
|
185
245
|
});
|
|
186
246
|
logger("Intial route for", props.debugName, ctx.status, ctx.currentMatch);
|
|
187
|
-
|
|
188
|
-
(0, react_1.useEffect)(()
|
|
189
|
-
return ctx.subscribe((item, status)
|
|
247
|
+
var _a = (0, react_1.useState)(ctx.status), status = _a[0], setStatus = _a[1];
|
|
248
|
+
(0, react_1.useEffect)(function () {
|
|
249
|
+
return ctx.subscribe(function (item, status) {
|
|
190
250
|
setStatus(status);
|
|
191
251
|
});
|
|
192
252
|
}, [ctx]);
|
|
193
253
|
if (status === "inactive")
|
|
194
254
|
return null;
|
|
195
|
-
return (0, jsx_runtime_1.jsx)(RouterContext.Provider, { value: ctx, children: props.children });
|
|
255
|
+
return (0, jsx_runtime_1.jsx)(RouterContext.Provider, __assign({ value: ctx }, { children: props.children }), void 0);
|
|
196
256
|
}
|
|
197
257
|
exports.Route = Route;
|
|
198
258
|
function createRouteItem(url, data) {
|
|
199
|
-
|
|
200
|
-
return {
|
|
201
|
-
...parsed,
|
|
202
|
-
data,
|
|
203
|
-
};
|
|
259
|
+
var parsed = (0, url_parse_1.default)(url, true);
|
|
260
|
+
return __assign(__assign({}, parsed), { data: data });
|
|
204
261
|
}
|
|
205
262
|
exports.createRouteItem = createRouteItem;
|
|
206
263
|
function RouterRoot(props) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
264
|
+
var _this = this;
|
|
265
|
+
var onNavigateRef = (0, react_1.useRef)(props.onNavigateRequest);
|
|
266
|
+
var onPreNavigateRef = (0, react_1.useRef)(props.onPreload);
|
|
267
|
+
var ctx = (0, react_1.useMemo)(function () {
|
|
268
|
+
return createRouteContext({
|
|
269
|
+
initial: createRouteItem(props.url, props.data),
|
|
270
|
+
config: {
|
|
271
|
+
debugName: "ROOT",
|
|
272
|
+
},
|
|
273
|
+
onNavigate: function (path) { return __awaiter(_this, void 0, void 0, function () {
|
|
274
|
+
return __generator(this, function (_a) {
|
|
275
|
+
// User has clicked a link
|
|
276
|
+
if (onNavigateRef.current) {
|
|
277
|
+
onNavigateRef.current(path);
|
|
278
|
+
}
|
|
279
|
+
return [2 /*return*/];
|
|
280
|
+
});
|
|
281
|
+
}); },
|
|
282
|
+
onPreload: function (path) {
|
|
283
|
+
if (onPreNavigateRef.current) {
|
|
284
|
+
onPreNavigateRef.current(path);
|
|
285
|
+
}
|
|
286
|
+
},
|
|
287
|
+
});
|
|
288
|
+
}, []);
|
|
226
289
|
onNavigateRef.current = props.onNavigateRequest;
|
|
227
290
|
onPreNavigateRef.current = props.onPreload;
|
|
228
|
-
(0, react_1.useEffect)(()
|
|
229
|
-
|
|
230
|
-
|
|
291
|
+
(0, react_1.useEffect)(function () {
|
|
292
|
+
var cancelled = false;
|
|
293
|
+
var item = createRouteItem(props.url, props.data);
|
|
231
294
|
if (item.href !== ctx.item.href || item.data !== ctx.item.data) {
|
|
232
|
-
ctx.propagateCandidate(item, ctx.item).then(()
|
|
295
|
+
ctx.propagateCandidate(item, ctx.item).then(function () {
|
|
233
296
|
if (!cancelled) {
|
|
234
297
|
ctx.propagateChange(item, true);
|
|
235
298
|
if (props.onNavigated) {
|
|
@@ -237,7 +300,7 @@ function RouterRoot(props) {
|
|
|
237
300
|
}
|
|
238
301
|
}
|
|
239
302
|
});
|
|
240
|
-
return ()
|
|
303
|
+
return function () {
|
|
241
304
|
cancelled = true;
|
|
242
305
|
};
|
|
243
306
|
}
|
|
@@ -251,11 +314,11 @@ function RouterRoot(props) {
|
|
|
251
314
|
// }
|
|
252
315
|
// })
|
|
253
316
|
// }, [props.onNavigated])
|
|
254
|
-
return (0, jsx_runtime_1.jsx)(RouterContext.Provider, { value: ctx, children: props.children });
|
|
317
|
+
return (0, jsx_runtime_1.jsx)(RouterContext.Provider, __assign({ value: ctx }, { children: props.children }), void 0);
|
|
255
318
|
}
|
|
256
319
|
exports.RouterRoot = RouterRoot;
|
|
257
|
-
|
|
258
|
-
|
|
320
|
+
var isInternalPageLink = function (href) {
|
|
321
|
+
var url = (0, url_parse_1.default)(href, true);
|
|
259
322
|
if (url && url.origin === document.location.origin && !url.pathname.match(/\./)) {
|
|
260
323
|
return true;
|
|
261
324
|
}
|
|
@@ -264,25 +327,49 @@ const isInternalPageLink = (href) => {
|
|
|
264
327
|
}
|
|
265
328
|
};
|
|
266
329
|
exports.isInternalPageLink = isInternalPageLink;
|
|
267
|
-
|
|
330
|
+
var urlPathsMatch = function (a, b) {
|
|
331
|
+
var urlA = (0, url_parse_1.default)(a, true);
|
|
332
|
+
var urlB = (0, url_parse_1.default)(b, true);
|
|
333
|
+
return urlA.pathname.replace(/\/$/, "") === urlB.pathname.replace(/\/$/, "");
|
|
334
|
+
};
|
|
335
|
+
exports.urlPathsMatch = urlPathsMatch;
|
|
336
|
+
var urlDescendentsMatch = function (a, b) {
|
|
337
|
+
var urlA = (0, url_parse_1.default)(a, true);
|
|
338
|
+
var urlB = (0, url_parse_1.default)(b, true);
|
|
339
|
+
if (urlB.pathname === "/")
|
|
340
|
+
return false;
|
|
341
|
+
return urlA.pathname.replace(/\/$/, "").startsWith(urlB.pathname.replace(/\/$/, ""));
|
|
342
|
+
};
|
|
343
|
+
exports.urlDescendentsMatch = urlDescendentsMatch;
|
|
344
|
+
exports.Link = (0, react_1.forwardRef)(function (props, ref) {
|
|
268
345
|
// @ts-ignore
|
|
269
346
|
if (process.serverless) {
|
|
270
|
-
|
|
271
|
-
return ((0, jsx_runtime_1.jsx)(NextLink, { href: props.href, passHref: true, prefetch: false, children: (0, jsx_runtime_1.jsx)("a", { ref: ref,
|
|
347
|
+
var NextLink = require("next/link").default;
|
|
348
|
+
return ((0, jsx_runtime_1.jsx)(NextLink, __assign({ href: props.href, passHref: true, prefetch: false }, { children: (0, jsx_runtime_1.jsx)("a", __assign({ ref: ref }, props, { href: undefined }), void 0) }), void 0));
|
|
272
349
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
(0, react_1.useEffect)(()
|
|
350
|
+
var localRef = (0, react_1.useRef)();
|
|
351
|
+
var router = (0, react_1.useContext)(RouterContext);
|
|
352
|
+
(0, react_1.useEffect)(function () {
|
|
276
353
|
if (props.preload && localRef.current && (0, exports.isInternalPageLink)(localRef.current.href)) {
|
|
277
|
-
router
|
|
354
|
+
router === null || router === void 0 ? void 0 : router.preload(localRef.current.href);
|
|
278
355
|
}
|
|
279
356
|
}, [props.preload]);
|
|
280
|
-
|
|
357
|
+
var isActive = (0, react_1.useMemo)(function () {
|
|
358
|
+
if (!(router === null || router === void 0 ? void 0 : router.item.pathname) || !props.href)
|
|
359
|
+
return false;
|
|
360
|
+
return (0, exports.urlPathsMatch)(router === null || router === void 0 ? void 0 : router.item.pathname, props.href);
|
|
361
|
+
}, [router === null || router === void 0 ? void 0 : router.item.pathname, props.href]);
|
|
362
|
+
var isDescendentActive = (0, react_1.useMemo)(function () {
|
|
363
|
+
if (!(router === null || router === void 0 ? void 0 : router.item.pathname) || !props.href)
|
|
364
|
+
return false;
|
|
365
|
+
return (0, exports.urlDescendentsMatch)(router === null || router === void 0 ? void 0 : router.item.pathname, props.href);
|
|
366
|
+
}, [router === null || router === void 0 ? void 0 : router.item.pathname, props.href]);
|
|
367
|
+
return ((0, jsx_runtime_1.jsx)("a", __assign({ ref: (0, react_merge_refs_1.default)([localRef, ref]) }, props, { "data-active": isActive ? true : undefined, "data-child-active": isDescendentActive ? true : undefined, onMouseEnter: function (e) {
|
|
281
368
|
if (props.onMouseEnter) {
|
|
282
369
|
props.onMouseEnter(e);
|
|
283
370
|
}
|
|
284
|
-
router
|
|
285
|
-
}, onClick: (e)
|
|
371
|
+
router === null || router === void 0 ? void 0 : router.preload(e.currentTarget.href);
|
|
372
|
+
}, onClick: function (e) {
|
|
286
373
|
if (process.admin) {
|
|
287
374
|
e.preventDefault();
|
|
288
375
|
return;
|
|
@@ -291,34 +378,35 @@ exports.Link = (0, react_1.forwardRef)((props, ref) => {
|
|
|
291
378
|
props.onClick(e);
|
|
292
379
|
}
|
|
293
380
|
if (!e.isDefaultPrevented() && router && !e.ctrlKey && !e.metaKey) {
|
|
294
|
-
|
|
381
|
+
var href = e.currentTarget.href;
|
|
295
382
|
if ((0, exports.isInternalPageLink)(href)) {
|
|
296
|
-
router.
|
|
383
|
+
router.navigate(e.currentTarget.href);
|
|
297
384
|
e.preventDefault();
|
|
298
385
|
}
|
|
299
386
|
}
|
|
300
|
-
} }));
|
|
387
|
+
} }), void 0));
|
|
301
388
|
});
|
|
302
|
-
function Switch(
|
|
303
|
-
|
|
389
|
+
function Switch(_a) {
|
|
390
|
+
var children = _a.children;
|
|
391
|
+
var ctx = useForkedRouter({
|
|
304
392
|
debugName: "SWITCH",
|
|
305
|
-
match: ()
|
|
393
|
+
match: function () {
|
|
306
394
|
return true;
|
|
307
395
|
},
|
|
308
|
-
beforeLeave: ()
|
|
396
|
+
beforeLeave: function () {
|
|
309
397
|
return undefined;
|
|
310
398
|
},
|
|
311
399
|
}, { isSwitch: true });
|
|
312
|
-
return (0, jsx_runtime_1.jsx)(RouterContext.Provider, { value: ctx, children: children });
|
|
400
|
+
return (0, jsx_runtime_1.jsx)(RouterContext.Provider, __assign({ value: ctx }, { children: children }), void 0);
|
|
313
401
|
}
|
|
314
402
|
exports.Switch = Switch;
|
|
315
403
|
function RouteItemContext(props) {
|
|
316
|
-
|
|
317
|
-
match: ()
|
|
404
|
+
var ctx = useForkedRouter({
|
|
405
|
+
match: function () { return true; },
|
|
318
406
|
beforeLeave: undefined,
|
|
319
407
|
debugName: undefined,
|
|
320
408
|
onChange: undefined,
|
|
321
409
|
});
|
|
322
|
-
return (0, jsx_runtime_1.jsx)(RouterContext.Provider, { value: ctx, children: props.children });
|
|
410
|
+
return (0, jsx_runtime_1.jsx)(RouterContext.Provider, __assign({ value: ctx }, { children: props.children }), void 0);
|
|
323
411
|
}
|
|
324
412
|
exports.RouteItemContext = RouteItemContext;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateEditLink = void 0;
|
|
4
4
|
function updateEditLink(link) {
|
|
5
5
|
if (link) {
|
|
6
|
-
|
|
6
|
+
var editLink = document.querySelector("#wp-admin-bar-edit a");
|
|
7
7
|
if (editLink) {
|
|
8
8
|
editLink.setAttribute("href", link);
|
|
9
9
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { NextApiHandler } from "next/types";
|
|
2
|
-
export declare function defineAPI(handler: NextApiHandler): NextApiHandler
|
|
2
|
+
export declare function defineAPI(handler: NextApiHandler): NextApiHandler<any>;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
|
@@ -24,10 +20,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
20
|
};
|
|
25
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
22
|
exports.defineRPCContextCreator = exports.defineRPC = void 0;
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
var trpc = __importStar(require("@trpc/server"));
|
|
24
|
+
var z = __importStar(require("zod"));
|
|
29
25
|
// @ts-ignore
|
|
30
|
-
|
|
26
|
+
var createRouter = function () { return trpc.router(); };
|
|
31
27
|
// @ts-ignore
|
|
32
28
|
function defineRPC(creator) {
|
|
33
29
|
return creator(trpc.router(), z);
|
package/serverless/index.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
9
5
|
}) : (function(o, m, k, k2) {
|
|
10
6
|
if (k2 === undefined) k2 = k;
|
|
11
7
|
o[k2] = m[k];
|
|
@@ -15,7 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
11
|
};
|
|
16
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
13
|
exports.RPCError = void 0;
|
|
18
|
-
|
|
14
|
+
var server_1 = require("@trpc/server");
|
|
19
15
|
__exportStar(require("./define-api"), exports);
|
|
20
16
|
__exportStar(require("./define-rpc-router"), exports);
|
|
21
17
|
__exportStar(require("./error-codes"), exports);
|