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.
Files changed (185) hide show
  1. package/admin/components/ImageWell.d.ts +2 -2
  2. package/admin/components/ImageWell.js +51 -39
  3. package/admin/defineField.d.ts +2 -2
  4. package/admin/defineWidget.d.ts +1 -1
  5. package/admin/defineWidget.js +2 -2
  6. package/admin/index.js +1 -5
  7. package/admin/installFieldTypes.js +26 -26
  8. package/admin/runWidgets.js +28 -17
  9. package/admin/selectMedia.d.ts +2 -2
  10. package/admin/selectMedia.js +1 -1
  11. package/blocks/ContentBlocks.d.ts +6 -6
  12. package/blocks/ContentBlocks.js +66 -58
  13. package/blocks/ErrorBoundaryEditor.d.ts +1 -1
  14. package/blocks/ErrorBoundaryEditor.js +45 -16
  15. package/blocks/ErrorBoundaryFrontend.d.ts +1 -1
  16. package/blocks/ErrorBoundaryFrontend.js +45 -16
  17. package/blocks/InspectorControls.d.ts +1 -1
  18. package/blocks/InspectorControls.js +3 -3
  19. package/blocks/blockAttributes.d.ts +2 -2
  20. package/blocks/blockAttributes.js +44 -24
  21. package/blocks/index.js +1 -5
  22. package/blocks/inlineEditing.d.ts +6 -6
  23. package/blocks/inlineEditing.js +55 -36
  24. package/blocks/installGutenbergHooks.js +68 -48
  25. package/build/babel/plugin-name-defined-components.js +16 -15
  26. package/build/build-favicon.js +62 -11
  27. package/build/clean.js +52 -5
  28. package/build/create-codegen-worker.js +33 -78
  29. package/build/create-serverless-dev-worker.js +39 -61
  30. package/build/create-webpack-worker.js +33 -65
  31. package/build/file-tree.d.ts +2 -2
  32. package/build/file-tree.js +12 -12
  33. package/build/get-webpack-config.js +395 -341
  34. package/build/graphql-codegen/graphql-codegen-files.js +25 -31
  35. package/build/graphql-codegen/graphql-codegen-no-duplicates.js +4 -4
  36. package/build/graphql-codegen/graphql-codegen-queries.js +99 -102
  37. package/build/manifests/manifest-blocks.d.ts +1 -1
  38. package/build/manifests/manifest-blocks.js +29 -37
  39. package/build/manifests/manifest-fields.d.ts +1 -1
  40. package/build/manifests/manifest-fields.js +21 -23
  41. package/build/manifests/manifest-views.d.ts +1 -1
  42. package/build/manifests/manifest-views.js +25 -32
  43. package/build/manifests/manifest-widgets.d.ts +1 -1
  44. package/build/manifests/manifest-widgets.js +20 -22
  45. package/build/manifests/manifest.d.ts +2 -2
  46. package/build/manifests/manifest.js +94 -30
  47. package/build/reporter.d.ts +1 -1
  48. package/build/reporter.js +32 -29
  49. package/build/serverless/create-next-app.d.ts +1 -1
  50. package/build/serverless/create-next-app.js +467 -245
  51. package/build/state/codegen-state.d.ts +4 -4
  52. package/build/state/compiler-state.d.ts +5 -5
  53. package/build/state/serverless-state.d.ts +3 -3
  54. package/build/workers/codegen-worker-script.js +519 -393
  55. package/build/workers/serverless-worker-dev-script.js +4 -4
  56. package/build/workers/webpack-worker-script.js +156 -90
  57. package/cli/build.dev.d.ts +1 -1
  58. package/cli/build.dev.js +126 -79
  59. package/cli/build.prod.d.ts +1 -1
  60. package/cli/build.prod.js +98 -42
  61. package/cli/cli.js +28 -19
  62. package/cli/display/components/BundleDisplay.d.ts +1 -1
  63. package/cli/display/components/BundleDisplay.js +24 -13
  64. package/cli/display/components/CodegenDisplay.d.ts +1 -1
  65. package/cli/display/components/CodegenDisplay.js +25 -14
  66. package/cli/display/components/DevCLIDisplay.d.ts +2 -2
  67. package/cli/display/components/DevCLIDisplay.js +25 -14
  68. package/cli/display/components/Fullscreen.js +20 -9
  69. package/cli/display/components/ServerlessDisplay.d.ts +2 -2
  70. package/cli/display/components/ServerlessDisplay.js +26 -15
  71. package/cli/display/components/StatusIcon.d.ts +2 -2
  72. package/cli/display/components/StatusIcon.js +3 -3
  73. package/cli/preinstall.js +5 -4
  74. package/cli/setup.js +73 -25
  75. package/components/AdminBar.d.ts +1 -1
  76. package/components/AdminBar.js +3 -37
  77. package/components/BrowserRouter.d.ts +2 -2
  78. package/components/BrowserRouter.js +54 -41
  79. package/components/InlinePage.d.ts +2 -2
  80. package/components/InlinePage.js +29 -17
  81. package/components/NextRouter.d.ts +2 -2
  82. package/components/NextRouter.js +29 -20
  83. package/components/index.js +1 -5
  84. package/config/config-schema.d.ts +1 -1
  85. package/config/config-schema.js +1 -1
  86. package/config/create-schema-file.js +6 -6
  87. package/config/get-config.js +13 -10
  88. package/config/index.js +1 -5
  89. package/config/parse-config.js +1 -1
  90. package/config/print-zod-errors.js +3 -3
  91. package/dev-ui/components/BreakpointColumnHeader.d.ts +2 -2
  92. package/dev-ui/components/BreakpointColumnHeader.js +18 -7
  93. package/dev-ui/components/BreakpointIndicator.d.ts +1 -1
  94. package/dev-ui/components/BreakpointIndicator.js +32 -25
  95. package/dev-ui/components/DevUI.d.ts +1 -1
  96. package/dev-ui/components/DevUI.js +13 -13
  97. package/dev-ui/components/Launcher.d.ts +2 -2
  98. package/dev-ui/components/Launcher.js +25 -13
  99. package/dev-ui/components/PanelWrapper.d.ts +2 -2
  100. package/dev-ui/components/PanelWrapper.js +8 -8
  101. package/dev-ui/components/ResponsiveLerpControl.d.ts +2 -2
  102. package/dev-ui/components/ResponsiveLerpControl.js +38 -27
  103. package/dev-ui/components/ResponsiveScaleEditor.d.ts +4 -4
  104. package/dev-ui/components/ResponsiveScaleEditor.js +78 -64
  105. package/dev-ui/components/atoms/Button.js +1 -1
  106. package/dev-ui/components/atoms/Dropdown.d.ts +3 -3
  107. package/dev-ui/components/atoms/Dropdown.js +9 -8
  108. package/dev-ui/components/atoms/NumberField.d.ts +2 -2
  109. package/dev-ui/components/atoms/NumberField.js +42 -29
  110. package/dev-ui/components/atoms/Spacer.js +1 -1
  111. package/dev-ui/components/atoms/Text.js +1 -1
  112. package/dev-ui/components/atoms/ToggleButton.d.ts +2 -2
  113. package/dev-ui/components/atoms/ToggleButton.js +16 -5
  114. package/dev-ui/components/atoms/Tooltip.d.ts +2 -2
  115. package/dev-ui/components/atoms/Tooltip.js +20 -8
  116. package/dev-ui/components/panels/AppDataDebugger.d.ts +1 -1
  117. package/dev-ui/components/panels/AppDataDebugger.js +19 -8
  118. package/dev-ui/components/panels/ColorEditor.d.ts +1 -1
  119. package/dev-ui/components/panels/ColorEditor.js +42 -35
  120. package/dev-ui/components/panels/PageDataDebugger.d.ts +1 -1
  121. package/dev-ui/components/panels/PageDataDebugger.js +20 -8
  122. package/dev-ui/components/panels/QueryDebugger.d.ts +1 -1
  123. package/dev-ui/components/panels/QueryDebugger.js +24 -12
  124. package/dev-ui/components/panels/SpacingEditor.d.ts +1 -1
  125. package/dev-ui/components/panels/SpacingEditor.js +48 -34
  126. package/dev-ui/components/panels/TypographyEditor.d.ts +1 -1
  127. package/dev-ui/components/panels/TypographyEditor.js +46 -38
  128. package/dev-ui/hooks/useBreakpoint.d.ts +1 -1
  129. package/dev-ui/hooks/useBreakpoint.js +13 -13
  130. package/dev-ui/hooks/usePersistState.js +7 -6
  131. package/dev-ui/hooks/useStylesheet.js +6 -6
  132. package/dev-ui/icons.d.ts +15 -15
  133. package/dev-ui/icons.js +27 -16
  134. package/dev-ui/index.js +1 -5
  135. package/dev-ui/loader.d.ts +1 -1
  136. package/dev-ui/loader.js +9 -13
  137. package/dev-ui/panels.d.ts +2 -2
  138. package/dev-ui/panels.js +7 -7
  139. package/dev-ui/theme.js +3 -3
  140. package/dynamic/dynamic-component.js +1 -1
  141. package/dynamic/index.js +1 -5
  142. package/entry/Root.d.ts +2 -2
  143. package/entry/Root.js +26 -16
  144. package/entry/entry.admin.dev.js +4 -4
  145. package/entry/entry.admin.prod.js +4 -4
  146. package/entry/entry.monolith.dev.js +5 -5
  147. package/entry/entry.monolith.prod.js +5 -5
  148. package/gravityforms/gravity-forms.d.ts +2 -2
  149. package/gravityforms/index.js +1 -5
  150. package/gravityforms/useGravityForm.d.ts +2 -2
  151. package/gravityforms/useGravityForm.js +130 -126
  152. package/hooks/index.js +1 -5
  153. package/hooks/queryUtils.d.ts +14 -14
  154. package/hooks/queryUtils.js +192 -101
  155. package/hooks/useAppData.d.ts +2 -2
  156. package/hooks/useAppData.js +9 -9
  157. package/hooks/usePageLoad.js +4 -4
  158. package/hooks/useQueryDebug.d.ts +1 -1
  159. package/hooks/useQueryDebug.js +7 -7
  160. package/hooks/useRPC.d.ts +4 -4
  161. package/hooks/useRPC.js +3 -3
  162. package/package.json +11 -11
  163. package/routing/index.js +1 -5
  164. package/routing/remoteProps.d.ts +1 -1
  165. package/routing/remoteProps.js +72 -31
  166. package/routing/routing.d.ts +25 -15
  167. package/routing/routing.js +200 -112
  168. package/routing/updateEditLink.js +1 -1
  169. package/serverless/define-api.d.ts +1 -1
  170. package/serverless/define-rpc-router.js +4 -8
  171. package/serverless/index.js +2 -6
  172. package/style/createStitches.js +142 -164
  173. package/style/index.js +1 -5
  174. package/tsconfig.json +1 -1
  175. package/utils/Observable.d.ts +2 -2
  176. package/utils/Observable.js +15 -12
  177. package/utils/getRepoName.js +3 -3
  178. package/utils/promptIfRepoNameIncorrect.js +64 -18
  179. package/utils/refreshOverlayInterop.js +1 -1
  180. package/utils/reportErrorStack.d.ts +1 -1
  181. package/utils/reportErrorStack.js +1 -1
  182. package/utils/serverlessAppContext.js +1 -1
  183. package/utils/updateEnvFile.js +69 -19
  184. package/utils/useObservable.js +3 -3
  185. package/views/index.js +1 -5
@@ -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
- 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"));
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
- const logger = (...args) => { };
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
- const subscribers = [];
15
- const notify = (item, status) => {
16
- subscribers.forEach((handler) => handler(item, status));
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
- const parentIsSwitch = opts.parent && opts.parent.isSwitch;
19
- const ctx = {
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
- let promises = [Promise.resolve()];
41
- const matches = ctx.match(next);
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
- const promises = [Promise.resolve()];
117
+ var promises = [Promise.resolve()];
63
118
  if (ctx.config.beforeLeave) {
64
- const result = ctx.config.beforeLeave(current, next, parentIsLeaving);
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
- const result = child.propagateLeaving(current, next, true);
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
- const i = subscribers.indexOf(handler);
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 (const child of this.children) {
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
- const parent = ctx.parent;
99
- return parent.getFirstMatch(item) === ctx && this.matchSelf(item);
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
- if (ctx?.config?.match) {
105
- return ctx?.config?.match(item);
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
- const child = createRouteContext({
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.onNavigate,
120
- onPreload: ctx.onPreload,
121
- dispose: () => {
122
- const i = ctx.children.indexOf(child);
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?.getFirstMatch(opts.initial)) {
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
- const RouterContext = (0, react_1.createContext)(undefined);
212
+ var RouterContext = (0, react_1.createContext)(undefined);
155
213
  function useForkedRouter(conf, opts) {
156
- const parent = (0, react_1.useContext)(RouterContext);
157
- const ctx = (0, react_1.useMemo)(() => {
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 () => ctx.dispose();
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
- 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]);
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
- const ctx = useForkedRouter({
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
- const [status, setStatus] = (0, react_1.useState)(ctx.status);
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
- const parsed = (0, url_parse_1.default)(url, true);
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
- 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
- }), []);
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
- let cancelled = false;
230
- const item = createRouteItem(props.url, props.data);
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
- const isInternalPageLink = (href) => {
258
- const url = (0, url_parse_1.default)(href, true);
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
- exports.Link = (0, react_1.forwardRef)((props, ref) => {
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
- 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 }) }));
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
- const localRef = (0, react_1.useRef)();
274
- const router = (0, react_1.useContext)(RouterContext);
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?.onPreload(localRef.current.href);
354
+ router === null || router === void 0 ? void 0 : router.preload(localRef.current.href);
278
355
  }
279
356
  }, [props.preload]);
280
- return ((0, jsx_runtime_1.jsx)("a", { ref: (0, react_merge_refs_1.default)([localRef, ref]), ...props, onMouseEnter: (e) => {
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?.onPreload(e.currentTarget.href);
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
- const href = e.currentTarget.href;
381
+ var href = e.currentTarget.href;
295
382
  if ((0, exports.isInternalPageLink)(href)) {
296
- router.onNavigate(e.currentTarget.href);
383
+ router.navigate(e.currentTarget.href);
297
384
  e.preventDefault();
298
385
  }
299
386
  }
300
- } }));
387
+ } }), void 0));
301
388
  });
302
- function Switch({ children }) {
303
- const ctx = useForkedRouter({
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
- const ctx = useForkedRouter({
317
- match: () => true,
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
- const editLink = document.querySelector("#wp-admin-bar-edit a");
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
- 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);
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
- const trpc = __importStar(require("@trpc/server"));
28
- const z = __importStar(require("zod"));
23
+ var trpc = __importStar(require("@trpc/server"));
24
+ var z = __importStar(require("zod"));
29
25
  // @ts-ignore
30
- const createRouter = () => trpc.router();
26
+ var createRouter = function () { return trpc.router(); };
31
27
  // @ts-ignore
32
28
  function defineRPC(creator) {
33
29
  return creator(trpc.router(), z);
@@ -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
- 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);
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
- const server_1 = require("@trpc/server");
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);