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