eddev 0.1.33-beta-3 → 0.1.33-beta-4
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/blocks/ContentBlocks.js +2 -1
- package/blocks/{EditorErrorBoundary.d.ts → ErrorBoundaryEditor.d.ts} +1 -1
- package/blocks/{EditorErrorBoundary.js → ErrorBoundaryEditor.js} +9 -9
- package/blocks/ErrorBoundaryFrontend.d.ts +15 -0
- package/blocks/ErrorBoundaryFrontend.js +69 -0
- package/blocks/index.d.ts +0 -1
- package/blocks/index.js +0 -1
- package/blocks/inlineEditing.js +1 -21
- package/blocks/installGutenbergHooks.d.ts +1 -0
- package/blocks/installGutenbergHooks.js +27 -6
- package/build/babel/plugin-name-defined-components.d.ts +7 -0
- package/build/babel/plugin-name-defined-components.js +46 -0
- package/build/create-codegen-worker.d.ts +1 -1
- package/build/create-codegen-worker.js +1 -1
- package/build/create-webpack-worker.d.ts +1 -1
- package/build/create-webpack-worker.js +1 -1
- package/build/get-webpack-config.js +23 -14
- package/build/workers/webpack-worker-script.js +1 -0
- package/cli/display/components/BundleDisplay.d.ts +1 -1
- package/cli/display/components/BundleDisplay.js +1 -1
- package/cli/display/components/CodegenDisplay.d.ts +1 -1
- package/cli/display/components/CodegenDisplay.js +1 -1
- package/cli/display/components/DevCLIDisplay.d.ts +1 -1
- package/components/BrowserRouter.js +11 -2
- package/components/InlinePage.js +1 -1
- package/entry/entry.admin.dev.js +2 -2
- package/entry/entry.admin.prod.js +2 -2
- package/package.json +1 -1
- package/{utils → routing}/remoteProps.d.ts +8 -0
- package/{utils → routing}/remoteProps.js +1 -1
- package/routing/routing.d.ts +1 -1
- package/routing/updateEditLink.d.ts +1 -0
- package/routing/updateEditLink.js +12 -0
- package/routing/updateHeadTags.d.ts +2 -0
- package/routing/updateHeadTags.js +11 -0
- package/{cli/display/lib → utils}/Observable.d.ts +0 -0
- package/{cli/display/lib → utils}/Observable.js +0 -0
- package/{cli/display/lib → utils}/useObservable.d.ts +0 -0
- package/{cli/display/lib → utils}/useObservable.js +0 -0
- package/components/ContentBlocks.d.ts +0 -36
- package/components/ContentBlocks.js +0 -92
- package/components/routing.d.ts +0 -44
- package/components/routing.js +0 -363
package/blocks/ContentBlocks.js
CHANGED
|
@@ -29,6 +29,7 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
29
29
|
var blocks_1 = __importDefault(require("@manifest/blocks"));
|
|
30
30
|
var blockAttributes_1 = require("./blockAttributes");
|
|
31
31
|
var react_1 = require("react");
|
|
32
|
+
var ErrorBoundaryFrontend_1 = require("./ErrorBoundaryFrontend");
|
|
32
33
|
exports.BlocksContext = (0, react_1.createContext)(undefined);
|
|
33
34
|
function ContentBlocks(props) {
|
|
34
35
|
if (!Array.isArray(props.blocks))
|
|
@@ -81,7 +82,7 @@ function ContentBlocks(props) {
|
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
// Attempt to wrap the block
|
|
84
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [spaceBefore, blockNode, spaceAfter] }, index));
|
|
85
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [spaceBefore, (0, jsx_runtime_1.jsx)(ErrorBoundaryFrontend_1.ErrorBoundaryFrontend, { children: blockNode }, void 0), spaceAfter] }, index));
|
|
85
86
|
});
|
|
86
87
|
}, [blocks, props.wrapBlock, props.spacer]);
|
|
87
88
|
return (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: layout }, void 0);
|
|
@@ -6,7 +6,7 @@ interface State {
|
|
|
6
6
|
hasError: boolean;
|
|
7
7
|
error?: Error;
|
|
8
8
|
}
|
|
9
|
-
export declare class
|
|
9
|
+
export declare class ErrorBoundaryEditor extends Component<Props, State> {
|
|
10
10
|
state: State;
|
|
11
11
|
static getDerivedStateFromError(err: Error): State;
|
|
12
12
|
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
@@ -26,26 +26,26 @@ var __assign = (this && this.__assign) || function () {
|
|
|
26
26
|
return __assign.apply(this, arguments);
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.ErrorBoundaryEditor = void 0;
|
|
30
30
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
31
|
var react_1 = require("react");
|
|
32
|
-
var
|
|
33
|
-
__extends(
|
|
34
|
-
function
|
|
32
|
+
var ErrorBoundaryEditor = /** @class */ (function (_super) {
|
|
33
|
+
__extends(ErrorBoundaryEditor, _super);
|
|
34
|
+
function ErrorBoundaryEditor() {
|
|
35
35
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
36
36
|
_this.state = {
|
|
37
37
|
hasError: false,
|
|
38
38
|
};
|
|
39
39
|
return _this;
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
ErrorBoundaryEditor.getDerivedStateFromError = function (err) {
|
|
42
42
|
// Update state so the next render will show the fallback UI.
|
|
43
43
|
return { hasError: true, error: err };
|
|
44
44
|
};
|
|
45
|
-
|
|
45
|
+
ErrorBoundaryEditor.prototype.componentDidCatch = function (error, errorInfo) {
|
|
46
46
|
console.error("Uncaught error:", error, errorInfo);
|
|
47
47
|
};
|
|
48
|
-
|
|
48
|
+
ErrorBoundaryEditor.prototype.render = function () {
|
|
49
49
|
if (this.state.hasError) {
|
|
50
50
|
var err = this.state.error;
|
|
51
51
|
return ((0, jsx_runtime_1.jsx)("pre", __assign({ style: {
|
|
@@ -59,6 +59,6 @@ var EditorErrorBoundary = /** @class */ (function (_super) {
|
|
|
59
59
|
}
|
|
60
60
|
return this.props.children;
|
|
61
61
|
};
|
|
62
|
-
return
|
|
62
|
+
return ErrorBoundaryEditor;
|
|
63
63
|
}(react_1.Component));
|
|
64
|
-
exports.
|
|
64
|
+
exports.ErrorBoundaryEditor = ErrorBoundaryEditor;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React, { Component, ErrorInfo, ReactNode } from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
}
|
|
5
|
+
interface State {
|
|
6
|
+
hasError: boolean;
|
|
7
|
+
error?: Error;
|
|
8
|
+
}
|
|
9
|
+
export declare class ErrorBoundaryFrontend extends Component<Props, State> {
|
|
10
|
+
state: State;
|
|
11
|
+
static getDerivedStateFromError(err: Error): State;
|
|
12
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
13
|
+
render(): React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.ErrorBoundaryFrontend = void 0;
|
|
30
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
31
|
+
var react_1 = require("react");
|
|
32
|
+
var ErrorBoundaryFrontend = /** @class */ (function (_super) {
|
|
33
|
+
__extends(ErrorBoundaryFrontend, _super);
|
|
34
|
+
function ErrorBoundaryFrontend() {
|
|
35
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
36
|
+
_this.state = {
|
|
37
|
+
hasError: false,
|
|
38
|
+
};
|
|
39
|
+
return _this;
|
|
40
|
+
}
|
|
41
|
+
ErrorBoundaryFrontend.getDerivedStateFromError = function (err) {
|
|
42
|
+
// Update state so the next render will show the fallback UI.
|
|
43
|
+
return { hasError: true, error: err };
|
|
44
|
+
};
|
|
45
|
+
ErrorBoundaryFrontend.prototype.componentDidCatch = function (error, errorInfo) {
|
|
46
|
+
console.error("Uncaught error:", error, errorInfo);
|
|
47
|
+
};
|
|
48
|
+
ErrorBoundaryFrontend.prototype.render = function () {
|
|
49
|
+
if (this.state.hasError) {
|
|
50
|
+
var err = this.state.error;
|
|
51
|
+
if (process.dev) {
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)("pre", __assign({ style: {
|
|
53
|
+
fontSize: "12px",
|
|
54
|
+
color: "red",
|
|
55
|
+
border: "1px solid red",
|
|
56
|
+
borderRadius: "4px",
|
|
57
|
+
padding: "4px",
|
|
58
|
+
overflowX: "auto",
|
|
59
|
+
} }, { children: err.stack }), void 0));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return this.props.children;
|
|
66
|
+
};
|
|
67
|
+
return ErrorBoundaryFrontend;
|
|
68
|
+
}(react_1.Component));
|
|
69
|
+
exports.ErrorBoundaryFrontend = ErrorBoundaryFrontend;
|
package/blocks/index.d.ts
CHANGED
package/blocks/index.js
CHANGED
|
@@ -11,7 +11,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.useInnerBlocks = exports.useInlineEditableValue = void 0;
|
|
14
|
-
__exportStar(require("./installGutenbergHooks"), exports);
|
|
15
14
|
__exportStar(require("./defineBlock"), exports);
|
|
16
15
|
__exportStar(require("./inlineEditing"), exports);
|
|
17
16
|
__exportStar(require("./ContentBlocks"), exports);
|
package/blocks/inlineEditing.js
CHANGED
|
@@ -56,31 +56,11 @@ function EditableText(_a) {
|
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
exports.EditableText = EditableText;
|
|
59
|
-
function getTaggedBlocks(tag) {
|
|
60
|
-
// @ts-ignore
|
|
61
|
-
return wp.blocks
|
|
62
|
-
.getBlockTypes()
|
|
63
|
-
.filter(function (block) {
|
|
64
|
-
if (!Array.isArray(block.tags))
|
|
65
|
-
return false;
|
|
66
|
-
if (typeof tag === "string") {
|
|
67
|
-
return block.tags.includes(tag);
|
|
68
|
-
}
|
|
69
|
-
else if (Array.isArray(tag)) {
|
|
70
|
-
return !!block.tags.find(function (t) { return tag.includes(t); });
|
|
71
|
-
}
|
|
72
|
-
})
|
|
73
|
-
.map(function (block) { return block.name; });
|
|
74
|
-
}
|
|
75
59
|
function InnerBlocks(props) {
|
|
76
60
|
if (process.admin) {
|
|
77
61
|
var allowedBlocks = props.allowedBlocks;
|
|
78
62
|
// console.log("ALLOWED BLOCKS", props.allowTaggedBlocks, allowedBlocks)
|
|
79
|
-
return ((0, jsx_runtime_1.jsx)(InnerBlocksAdminWrapper, __assign({ orientation: props.orientation || "vertical" }, { children: (0, jsx_runtime_1.jsx)(block_editor_1.InnerBlocks
|
|
80
|
-
// @ts-ignore
|
|
81
|
-
, {
|
|
82
|
-
// @ts-ignore
|
|
83
|
-
orientation: props.orientation, allowedBlocks: allowedBlocks, renderAppender: props.renderAppender, templateLock: props.templateLock, template: props.template }, void 0) }), void 0));
|
|
63
|
+
return ((0, jsx_runtime_1.jsx)(InnerBlocksAdminWrapper, __assign({ orientation: props.orientation || "vertical" }, { children: (0, jsx_runtime_1.jsx)(block_editor_1.InnerBlocks, { orientation: props.orientation, allowedBlocks: allowedBlocks, renderAppender: props.renderAppender, templateLock: props.templateLock, template: props.template }, void 0) }), void 0));
|
|
84
64
|
}
|
|
85
65
|
else {
|
|
86
66
|
var blocks = (0, blockAttributes_1.useInnerBlocks)();
|
|
@@ -23,18 +23,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.installEDGutenbergHooks = void 0;
|
|
26
|
+
exports.setBlockManifest = exports.installEDGutenbergHooks = void 0;
|
|
27
27
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
28
|
// @ts-ignore
|
|
29
29
|
var hooks_1 = require("@wordpress/hooks");
|
|
30
30
|
var react_1 = require("react");
|
|
31
31
|
// @ts-ignore
|
|
32
|
-
var blocks_1 = __importDefault(require("@manifest/blocks"));
|
|
33
|
-
// @ts-ignore
|
|
34
32
|
var blockAttributes_1 = require("./blockAttributes");
|
|
35
|
-
var
|
|
33
|
+
var ErrorBoundaryEditor_1 = require("./ErrorBoundaryEditor");
|
|
36
34
|
var react_2 = require("@stitches/react");
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
var blocks_1 = __importDefault(require("@manifest/blocks"));
|
|
37
|
+
var Observable_1 = require("../utils/Observable");
|
|
38
|
+
var useObservable_1 = require("../utils/useObservable");
|
|
37
39
|
var BlockContext = (0, react_1.createContext)(undefined);
|
|
40
|
+
// Store the block manifest as a local variable
|
|
41
|
+
var blocksManifest = new Observable_1.Observable(blocks_1.default);
|
|
38
42
|
function installEDGutenbergHooks() {
|
|
39
43
|
(0, react_2.globalCss)({
|
|
40
44
|
".block-editor-block-list__block:hover": {
|
|
@@ -129,8 +133,13 @@ function installEDGutenbergHooks() {
|
|
|
129
133
|
function BlockRenderer(_a) {
|
|
130
134
|
var payload = _a.payload;
|
|
131
135
|
var block = (0, react_1.useContext)(BlockContext);
|
|
132
|
-
|
|
133
|
-
|
|
136
|
+
if (!block)
|
|
137
|
+
return null;
|
|
138
|
+
var manifest = (0, useObservable_1.useObservable)(blocksManifest);
|
|
139
|
+
var BlockComponent = manifest[block.name];
|
|
140
|
+
if (!BlockComponent)
|
|
141
|
+
return (0, jsx_runtime_1.jsx)("div", { children: "Unable to load block component" }, void 0);
|
|
142
|
+
return ((0, jsx_runtime_1.jsx)(ErrorBoundaryEditor_1.ErrorBoundaryEditor, { children: (0, jsx_runtime_1.jsx)(BlockComponent, __assign({}, payload), void 0) }, void 0));
|
|
134
143
|
}
|
|
135
144
|
// @ts-ignore
|
|
136
145
|
var parseJSX = acf.parseJSX;
|
|
@@ -141,3 +150,15 @@ function installEDGutenbergHooks() {
|
|
|
141
150
|
};
|
|
142
151
|
}
|
|
143
152
|
exports.installEDGutenbergHooks = installEDGutenbergHooks;
|
|
153
|
+
function setBlockManifest(manifest) {
|
|
154
|
+
blocksManifest.update(manifest);
|
|
155
|
+
}
|
|
156
|
+
exports.setBlockManifest = setBlockManifest;
|
|
157
|
+
// @ts-ignore
|
|
158
|
+
if (import.meta.webpackHot) {
|
|
159
|
+
// @ts-ignore
|
|
160
|
+
import.meta.webpackHot.accept([require.resolve("@manifest/blocks")], function () {
|
|
161
|
+
var updatedManifest = require("@manifest/blocks").default;
|
|
162
|
+
setBlockManifest(updatedManifest);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var pascal_case_1 = require("pascal-case");
|
|
4
|
+
function default_1(_a) {
|
|
5
|
+
var t = _a.types;
|
|
6
|
+
return {
|
|
7
|
+
visitor: {
|
|
8
|
+
CallExpression: function (path, state) {
|
|
9
|
+
// Does the call expression name match defineBlock or defineView?
|
|
10
|
+
var callee = path.node.callee;
|
|
11
|
+
var args = path.node.arguments;
|
|
12
|
+
if (callee.type === "Identifier" && (callee.name === "defineBlock" || callee.name === "defineView")) {
|
|
13
|
+
// First argument a string literal?
|
|
14
|
+
var name_1 = "";
|
|
15
|
+
if (args.length > 0 && args[0].type === "StringLiteral") {
|
|
16
|
+
name_1 = args[0].value;
|
|
17
|
+
// While we're here, make sure that the name matches the filename
|
|
18
|
+
var filename = state.file.opts.filename;
|
|
19
|
+
var expectedName = filename
|
|
20
|
+
.replace(state.opts.baseDirectory, "")
|
|
21
|
+
.replace(/\.tsx?$/, "")
|
|
22
|
+
.replace(/^\/?(blocks|views)\//, "");
|
|
23
|
+
if (name_1 !== expectedName) {
|
|
24
|
+
throw path.buildCodeFrameError("The name in your ".concat(callee.name, " didn't match the filename!\n\nDid you mean ").concat(callee.name, "(\"").concat(expectedName, "\")?"));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// Second argument an arrow function?
|
|
28
|
+
if (args.length === 2) {
|
|
29
|
+
if (args[1].type === "ArrowFunctionExpression") {
|
|
30
|
+
// Great! Replace the arrow function with a normal function
|
|
31
|
+
var body = args[1].body;
|
|
32
|
+
if (t.isExpression(body)) {
|
|
33
|
+
body = t.blockStatement([t.returnStatement(body)]);
|
|
34
|
+
}
|
|
35
|
+
path.replaceWith(t.callExpression(t.identifier(callee.name), [
|
|
36
|
+
t.stringLiteral(name_1),
|
|
37
|
+
t.functionExpression(t.identifier((0, pascal_case_1.pascalCase)(name_1)), args[1].params, body, args[1].generator, args[1].async),
|
|
38
|
+
]));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
exports.default = default_1;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Observable } from "../
|
|
1
|
+
import { Observable } from "../utils/Observable";
|
|
2
2
|
import { CodegenOptions } from "./workers/codegen-worker-script";
|
|
3
3
|
import { CodegenState } from "./state/codegen-state";
|
|
4
4
|
export declare function createCodegenWorker(opts: CodegenOptions): Observable<CodegenState>;
|
|
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.createCodegenWorker = void 0;
|
|
15
15
|
var worker_threads_1 = require("worker_threads");
|
|
16
16
|
var path_1 = require("path");
|
|
17
|
-
var Observable_1 = require("../
|
|
17
|
+
var Observable_1 = require("../utils/Observable");
|
|
18
18
|
function createCodegenWorker(opts) {
|
|
19
19
|
var worker = new worker_threads_1.Worker((0, path_1.join)(__dirname, "workers/codegen-worker-script.js"), {
|
|
20
20
|
workerData: opts,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { WebpackWorkerOptions } from "./get-webpack-config";
|
|
2
|
-
import { Observable } from "../
|
|
2
|
+
import { Observable } from "../utils/Observable";
|
|
3
3
|
import { CompilerState } from "./state/compiler-state";
|
|
4
4
|
export declare function createWebpackWorker(opts: WebpackWorkerOptions): Observable<CompilerState>;
|
|
@@ -14,7 +14,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.createWebpackWorker = void 0;
|
|
15
15
|
var worker_threads_1 = require("worker_threads");
|
|
16
16
|
var path_1 = require("path");
|
|
17
|
-
var Observable_1 = require("../
|
|
17
|
+
var Observable_1 = require("../utils/Observable");
|
|
18
18
|
function createWebpackWorker(opts) {
|
|
19
19
|
var worker = new worker_threads_1.Worker((0, path_1.join)(__dirname, "workers/webpack-worker-script.js"), {
|
|
20
20
|
workerData: opts,
|
|
@@ -74,6 +74,8 @@ var webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
|
|
|
74
74
|
// @ts-ignore
|
|
75
75
|
var mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
76
76
|
var autoprefixer_1 = __importDefault(require("autoprefixer"));
|
|
77
|
+
// Custom Babel plugins
|
|
78
|
+
var plugin_name_defined_components_1 = __importDefault(require("./babel/plugin-name-defined-components"));
|
|
77
79
|
function getWebpackConfig(opts) {
|
|
78
80
|
return __awaiter(this, void 0, void 0, function () {
|
|
79
81
|
var compiling, ALIAS, ENTRY, PLUGINS, RULES, DEFINES, VIRTUAL_MODULES, EXTERNALS, virtualModules, isServerless, isBrowser, isSSR, isDev, entryDir, distSuffix, outputFolder, loadableManifestFile, writeVirtualModule, updateTemplateRouter, templateLookupPattern, _a, updateBlocksManifest, blockLookupManifest, _b, buildID;
|
|
@@ -150,7 +152,8 @@ function getWebpackConfig(opts) {
|
|
|
150
152
|
require.resolve("@babel/preset-typescript"),
|
|
151
153
|
],
|
|
152
154
|
plugins: [
|
|
153
|
-
|
|
155
|
+
[plugin_name_defined_components_1.default, { baseDirectory: opts.baseDirectory, cool: true }],
|
|
156
|
+
isBrowser && isDev && !opts.isAdmin && [require.resolve("react-refresh/babel"), { skipEnvCheck: true }],
|
|
154
157
|
require.resolve("@loadable/babel-plugin"),
|
|
155
158
|
].filter(Boolean),
|
|
156
159
|
},
|
|
@@ -191,17 +194,6 @@ function getWebpackConfig(opts) {
|
|
|
191
194
|
},
|
|
192
195
|
],
|
|
193
196
|
});
|
|
194
|
-
// Define some values
|
|
195
|
-
DEFINES["process.browser"] = JSON.stringify(isBrowser);
|
|
196
|
-
DEFINES["process.ssr"] = JSON.stringify(isServerless && !isBrowser);
|
|
197
|
-
DEFINES["process.LOADABLE_STATS_FILE"] = JSON.stringify(loadableManifestFile);
|
|
198
|
-
DEFINES["process.dev"] = isDev ? "true" : "false";
|
|
199
|
-
DEFINES["process.admin"] = opts.isAdmin ? "true" : "false";
|
|
200
|
-
DEFINES["process.env.themePath"] = JSON.stringify("/wp-content/themes/".concat(opts.themeName));
|
|
201
|
-
DEFINES["process.themePath"] = JSON.stringify("/wp-content/themes/".concat(opts.themeName));
|
|
202
|
-
if (isBrowser) {
|
|
203
|
-
DEFINES["process.env.themePath"] = "window.THEME_PATH || ".concat(DEFINES["process.env.themePath"]);
|
|
204
|
-
}
|
|
205
197
|
// Bundle analyser
|
|
206
198
|
if (!opts.isAdmin && !isDev) {
|
|
207
199
|
PLUGINS.push(new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
|
|
@@ -211,10 +203,12 @@ function getWebpackConfig(opts) {
|
|
|
211
203
|
}));
|
|
212
204
|
}
|
|
213
205
|
// React Refresh
|
|
214
|
-
if (isBrowser && isDev) {
|
|
206
|
+
if (isBrowser && isDev && !opts.isAdmin) {
|
|
215
207
|
PLUGINS.push(new react_refresh_webpack_plugin_1.default({
|
|
216
208
|
overlay: {
|
|
217
209
|
// module: require.resolve("../utils/refreshOverlayInterop"),
|
|
210
|
+
// @ts-ignore
|
|
211
|
+
// sockProtocol: "http",
|
|
218
212
|
sockHost: "127.0.0.1",
|
|
219
213
|
sockPort: opts.hotPort,
|
|
220
214
|
sockIntegration: "wds",
|
|
@@ -308,7 +302,8 @@ function getWebpackConfig(opts) {
|
|
|
308
302
|
var componentName = (0, change_case_1.pascalCase)(name);
|
|
309
303
|
return { relative: relative, name: name, module: module, componentName: componentName };
|
|
310
304
|
});
|
|
311
|
-
|
|
305
|
+
var useLoadableBlocks = opts.isAdmin && !isDev;
|
|
306
|
+
if (useLoadableBlocks) {
|
|
312
307
|
writeVirtualModule(ALIAS["@manifest/blocks"], "\n import coreBlocks from './blocks/_core.tsx'\n ".concat(!isServerless && "import loadable from '".concat(require.resolve("@loadable/component"), "';"), "\n\n export default {\n ...coreBlocks,\n ").concat(files
|
|
313
308
|
.map(function (_a) {
|
|
314
309
|
var relative = _a.relative, componentName = _a.componentName, module = _a.module;
|
|
@@ -360,6 +355,20 @@ function getWebpackConfig(opts) {
|
|
|
360
355
|
if (opts.isAdmin) {
|
|
361
356
|
EXTERNALS["react"] = "React";
|
|
362
357
|
}
|
|
358
|
+
// Define some values
|
|
359
|
+
DEFINES["process.browser"] = JSON.stringify(isBrowser);
|
|
360
|
+
DEFINES["process.ssr"] = JSON.stringify(isServerless && !isBrowser);
|
|
361
|
+
DEFINES["process.LOADABLE_STATS_FILE"] = JSON.stringify(loadableManifestFile);
|
|
362
|
+
DEFINES["process.dev"] = isDev ? "true" : "false";
|
|
363
|
+
DEFINES["process.admin"] = opts.isAdmin ? "true" : "false";
|
|
364
|
+
DEFINES["process.env.themePath"] = JSON.stringify("/wp-content/themes/".concat(opts.themeName));
|
|
365
|
+
DEFINES["process.themePath"] = JSON.stringify("/wp-content/themes/".concat(opts.themeName));
|
|
366
|
+
if (isDev && opts.isAdmin) {
|
|
367
|
+
DEFINES["process.BLOCK_MANIFEST_FILE"] = JSON.stringify(ALIAS["@manifest/blocks"]);
|
|
368
|
+
}
|
|
369
|
+
if (isBrowser) {
|
|
370
|
+
DEFINES["process.env.themePath"] = "window.THEME_PATH || ".concat(DEFINES["process.env.themePath"]);
|
|
371
|
+
}
|
|
363
372
|
buildID = Date.now();
|
|
364
373
|
return [2 /*return*/, {
|
|
365
374
|
mode: opts.mode,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CompilerState } from "../../../build/state/compiler-state";
|
|
3
|
-
import { Observable } from "
|
|
3
|
+
import { Observable } from "../../../utils/Observable";
|
|
4
4
|
export declare function BundleDisplay(props: {
|
|
5
5
|
bundle: Observable<CompilerState>;
|
|
6
6
|
}): JSX.Element;
|
|
@@ -15,7 +15,7 @@ exports.BundleDisplay = void 0;
|
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
16
|
var ink_1 = require("ink");
|
|
17
17
|
var react_1 = require("react");
|
|
18
|
-
var useObservable_1 = require("
|
|
18
|
+
var useObservable_1 = require("../../../utils/useObservable");
|
|
19
19
|
var StatusIcon_1 = require("./StatusIcon");
|
|
20
20
|
var statusLabels = {
|
|
21
21
|
compiling: "Compiling...",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CodegenState } from "../../../build/state/codegen-state";
|
|
3
|
-
import { Observable } from "
|
|
3
|
+
import { Observable } from "../../../utils/Observable";
|
|
4
4
|
export declare function CodegenDisplay(props: {
|
|
5
5
|
codegen: Observable<CodegenState>;
|
|
6
6
|
}): JSX.Element;
|
|
@@ -15,7 +15,7 @@ exports.CodegenDisplay = void 0;
|
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
16
|
var ink_1 = require("ink");
|
|
17
17
|
var react_1 = require("react");
|
|
18
|
-
var useObservable_1 = require("
|
|
18
|
+
var useObservable_1 = require("../../../utils/useObservable");
|
|
19
19
|
var StatusIcon_1 = require("./StatusIcon");
|
|
20
20
|
var statusLabels = {
|
|
21
21
|
generating: "Generating...",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CodegenState } from "../../../build/state/codegen-state";
|
|
3
3
|
import { CompilerState } from "../../../build/state/compiler-state";
|
|
4
|
-
import { Observable } from "
|
|
4
|
+
import { Observable } from "../../../utils/Observable";
|
|
5
5
|
declare type Props = {
|
|
6
6
|
bundles: Observable<CompilerState>[];
|
|
7
7
|
codegen?: Observable<CodegenState>;
|
|
@@ -17,13 +17,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.BrowserRouter = void 0;
|
|
18
18
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
19
|
var react_1 = require("react");
|
|
20
|
-
var remoteProps_1 = require("../
|
|
20
|
+
var remoteProps_1 = require("../routing/remoteProps");
|
|
21
21
|
var routing_1 = require("../routing");
|
|
22
22
|
// @ts-ignore
|
|
23
23
|
var views_1 = __importDefault(require("@manifest/views"));
|
|
24
24
|
var usePageLoad_1 = require("../hooks/usePageLoad");
|
|
25
25
|
var hooks_1 = require("../hooks");
|
|
26
26
|
var reportErrorStack_1 = require("../utils/reportErrorStack");
|
|
27
|
+
var updateEditLink_1 = require("../routing/updateEditLink");
|
|
28
|
+
var updateHeadTags_1 = require("../routing/updateHeadTags");
|
|
27
29
|
var hasPopulatedCache = false;
|
|
28
30
|
function BrowserRouter(props) {
|
|
29
31
|
var setAppData = (0, hooks_1.useAppDataStore)(function (s) { return s.setAppData; });
|
|
@@ -62,9 +64,16 @@ function BrowserRouter(props) {
|
|
|
62
64
|
(0, remoteProps_1.fetchProps)(pending.url).then(function (data) {
|
|
63
65
|
var view = views_1.default[data.view];
|
|
64
66
|
var finish = function () {
|
|
67
|
+
var _a;
|
|
65
68
|
setUrl(pending.url);
|
|
66
69
|
setData(data);
|
|
67
|
-
|
|
70
|
+
if (data.appData) {
|
|
71
|
+
setAppData(data.appData.data);
|
|
72
|
+
}
|
|
73
|
+
if (data.editLink)
|
|
74
|
+
(0, updateEditLink_1.updateEditLink)(data.editLink);
|
|
75
|
+
if ((_a = data.meta) === null || _a === void 0 ? void 0 : _a.head)
|
|
76
|
+
(0, updateHeadTags_1.updateHeadTags)(data.meta.head);
|
|
68
77
|
setIsLoading(false);
|
|
69
78
|
if (!pending.popped) {
|
|
70
79
|
history.pushState({}, "", pending.url);
|
package/components/InlinePage.js
CHANGED
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.InlinePage = void 0;
|
|
18
18
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
19
|
var react_1 = require("react");
|
|
20
|
-
var remoteProps_1 = require("../
|
|
20
|
+
var remoteProps_1 = require("../routing/remoteProps");
|
|
21
21
|
var routing_1 = require("../routing");
|
|
22
22
|
// @ts-ignore
|
|
23
23
|
var views_1 = __importDefault(require("@manifest/views"));
|
package/entry/entry.admin.dev.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var
|
|
3
|
+
var installGutenbergHooks_1 = require("../blocks/installGutenbergHooks");
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
var _theme_1 = require("@theme");
|
|
6
|
-
(0,
|
|
6
|
+
(0, installGutenbergHooks_1.installEDGutenbergHooks)();
|
|
7
7
|
if (_theme_1.editorGlobalStyles) {
|
|
8
8
|
(0, _theme_1.editorGlobalStyles)();
|
|
9
9
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var
|
|
3
|
+
var installGutenbergHooks_1 = require("../blocks/installGutenbergHooks");
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
var _theme_1 = require("@theme");
|
|
6
|
-
(0,
|
|
6
|
+
(0, installGutenbergHooks_1.installEDGutenbergHooks)();
|
|
7
7
|
if (_theme_1.editorGlobalStyles) {
|
|
8
8
|
(0, _theme_1.editorGlobalStyles)();
|
|
9
9
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import URLParse from "url-parse";
|
|
2
|
+
export declare type ParsedRouteTags = Record<"title" | "meta" | "script" | "style" | "link", {
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
}[]>;
|
|
2
5
|
export interface RouteData {
|
|
3
6
|
view: string;
|
|
7
|
+
editLink?: string;
|
|
4
8
|
viewType: "react" | "html";
|
|
5
9
|
viewData: any;
|
|
6
10
|
appData: any;
|
|
11
|
+
meta?: {
|
|
12
|
+
head: ParsedRouteTags;
|
|
13
|
+
footer: ParsedRouteTags;
|
|
14
|
+
};
|
|
7
15
|
}
|
|
8
16
|
export declare function parseURL(url: string): URLParse<string>;
|
|
9
17
|
export declare function setInitialProps(url: string, data: RouteData): void;
|
|
@@ -58,7 +58,7 @@ function setInitialProps(url, data) {
|
|
|
58
58
|
exports.setInitialProps = setInitialProps;
|
|
59
59
|
function isSameOrigin(url) {
|
|
60
60
|
var parsed = parseURL(url);
|
|
61
|
-
return parsed.origin === document.location.origin;
|
|
61
|
+
return parsed.origin === document.location.origin && !parsed.pathname.match(/\.[a-z0-9]$/i);
|
|
62
62
|
}
|
|
63
63
|
exports.isSameOrigin = isSameOrigin;
|
|
64
64
|
function fetchProps(url) {
|
package/routing/routing.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode, PropsWithChildren } from "react";
|
|
2
2
|
import { APropsWithoutRef } from "react-html-props";
|
|
3
3
|
import URLParse from "url-parse";
|
|
4
|
-
import { RouteData } from "
|
|
4
|
+
import { RouteData } from "./remoteProps";
|
|
5
5
|
declare type RouteItem = URLParse<any> & {
|
|
6
6
|
data?: RouteData;
|
|
7
7
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function updateEditLink(link?: string): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateEditLink = void 0;
|
|
4
|
+
function updateEditLink(link) {
|
|
5
|
+
if (link) {
|
|
6
|
+
var editLink = document.querySelector("#wp-admin-bar-edit a");
|
|
7
|
+
if (editLink) {
|
|
8
|
+
editLink.setAttribute("href", link);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.updateEditLink = updateEditLink;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateHeadTags = void 0;
|
|
4
|
+
function updateHeadTags(tags) {
|
|
5
|
+
// Update the document title
|
|
6
|
+
if (tags.title && tags.title.length > 0 && typeof tags.title[0].__code === "string") {
|
|
7
|
+
document.title = tags.title[0].__code;
|
|
8
|
+
}
|
|
9
|
+
// TODO: Add any missing script/link/style tags too!
|
|
10
|
+
}
|
|
11
|
+
exports.updateHeadTags = updateHeadTags;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from "react";
|
|
2
|
-
export declare type ContentBlock<T extends keyof BlockProps | string = any> = {
|
|
3
|
-
blockName: T;
|
|
4
|
-
props: BlockProps extends keyof BlockProps ? BlockProps[T] : any;
|
|
5
|
-
innerBlocks: ContentBlock[];
|
|
6
|
-
innerHTML?: string;
|
|
7
|
-
innerContent?: string[];
|
|
8
|
-
rule: string;
|
|
9
|
-
inline: any;
|
|
10
|
-
};
|
|
11
|
-
declare type BlocksContext = {
|
|
12
|
-
ancestors: ContentBlock[];
|
|
13
|
-
parent?: ContentBlock;
|
|
14
|
-
prev?: ContentBlock;
|
|
15
|
-
next?: ContentBlock;
|
|
16
|
-
current: ContentBlock;
|
|
17
|
-
};
|
|
18
|
-
export declare const BlocksContext: import("react").Context<BlocksContext | undefined>;
|
|
19
|
-
declare type Props = {
|
|
20
|
-
blocks: ContentBlock[];
|
|
21
|
-
wrapBlock?: (child: ReactElement, ctx: BlocksContext) => ReactElement;
|
|
22
|
-
spacer?: (ctx: {
|
|
23
|
-
ancestors: ContentBlock[];
|
|
24
|
-
parent?: ContentBlock;
|
|
25
|
-
prev: ContentBlock | null;
|
|
26
|
-
next: ContentBlock | null;
|
|
27
|
-
}) => ReactElement | null;
|
|
28
|
-
};
|
|
29
|
-
export declare type GenericBlockProps = {
|
|
30
|
-
innerHTML?: string;
|
|
31
|
-
innerContent?: string[];
|
|
32
|
-
innerBlocks?: ContentBlock[];
|
|
33
|
-
children: ReactElement | null;
|
|
34
|
-
};
|
|
35
|
-
export declare function ContentBlocks(props: Props): JSX.Element | null;
|
|
36
|
-
export {};
|
|
@@ -1,92 +0,0 @@
|
|
|
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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
-
if (ar || !(i in from)) {
|
|
16
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
-
ar[i] = from[i];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
-
};
|
|
22
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.ContentBlocks = exports.BlocksContext = void 0;
|
|
27
|
-
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
var blocks_1 = __importDefault(require("@manifest/blocks"));
|
|
30
|
-
var blockAttributes_1 = require("../blocks/blockAttributes");
|
|
31
|
-
var react_1 = require("react");
|
|
32
|
-
exports.BlocksContext = (0, react_1.createContext)(undefined);
|
|
33
|
-
function ContentBlocks(props) {
|
|
34
|
-
if (!Array.isArray(props.blocks))
|
|
35
|
-
return null;
|
|
36
|
-
var parentContext = (0, react_1.useContext)(exports.BlocksContext);
|
|
37
|
-
var blocks = (0, react_1.useMemo)(function () {
|
|
38
|
-
return props.blocks.map(function (block, index) {
|
|
39
|
-
// Create a context object for the current block
|
|
40
|
-
var ctx = __assign(__assign({}, parentContext), { ancestors: __spreadArray(__spreadArray([], ((parentContext === null || parentContext === void 0 ? void 0 : parentContext.ancestors) || []), true), [
|
|
41
|
-
parentContext === null || parentContext === void 0 ? void 0 : parentContext.current,
|
|
42
|
-
], false).filter(Boolean), parent: parentContext === null || parentContext === void 0 ? void 0 : parentContext.current, current: block, prev: props.blocks[index - 1], next: props.blocks[index + 1] });
|
|
43
|
-
// Figure out the
|
|
44
|
-
var blockNode;
|
|
45
|
-
if (block.blockName in blocks_1.default) {
|
|
46
|
-
var Component = blocks_1.default[block.blockName];
|
|
47
|
-
if (!Component)
|
|
48
|
-
return (0, jsx_runtime_1.jsx)(react_1.Fragment, {}, void 0);
|
|
49
|
-
blockNode = ((0, jsx_runtime_1.jsx)(blockAttributes_1.InlineEditingContextProvider, __assign({ values: block.inline, innerBlocks: block.innerBlocks }, { children: (0, jsx_runtime_1.jsx)(Component, __assign({}, block.props, { innerHTML: block.innerHTML,
|
|
50
|
-
// innerBlocks={block.innerBlocks}
|
|
51
|
-
children: Array.isArray(block.innerBlocks) &&
|
|
52
|
-
block.innerBlocks.length ? ((0, jsx_runtime_1.jsx)(ContentBlocks, { blocks: block.innerBlocks }, void 0)) : null }), void 0) }), void 0));
|
|
53
|
-
}
|
|
54
|
-
else if (block.innerHTML) {
|
|
55
|
-
blockNode = ((0, jsx_runtime_1.jsx)("div", { dangerouslySetInnerHTML: { __html: block.innerHTML } }, void 0));
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
blockNode = null;
|
|
59
|
-
}
|
|
60
|
-
return [ctx, block, blockNode];
|
|
61
|
-
});
|
|
62
|
-
}, [props.blocks]);
|
|
63
|
-
var layout = (0, react_1.useMemo)(function () {
|
|
64
|
-
return blocks.filter(Boolean).map(function (_a, index) {
|
|
65
|
-
var ctx = _a[0], block = _a[1], blockNode = _a[2];
|
|
66
|
-
// Exit early if the block is null
|
|
67
|
-
if (blockNode === null)
|
|
68
|
-
return (0, jsx_runtime_1.jsx)(react_1.Fragment, {}, index);
|
|
69
|
-
// Custom wrap function?
|
|
70
|
-
if (props.wrapBlock) {
|
|
71
|
-
blockNode = props.wrapBlock(blockNode, ctx);
|
|
72
|
-
}
|
|
73
|
-
// Wrap the block in a context provider
|
|
74
|
-
blockNode = ((0, jsx_runtime_1.jsx)(exports.BlocksContext.Provider, __assign({ value: ctx }, { children: blockNode }), void 0));
|
|
75
|
-
// Custom spacer function?
|
|
76
|
-
var spaceBefore = null;
|
|
77
|
-
var spaceAfter = null;
|
|
78
|
-
if (props.spacer) {
|
|
79
|
-
// Before block
|
|
80
|
-
spaceBefore = props.spacer(__assign(__assign({}, ctx), { prev: ctx.prev || null, next: ctx.current || null }));
|
|
81
|
-
// After block (last block only)
|
|
82
|
-
if (index === props.blocks.length - 1) {
|
|
83
|
-
spaceAfter = props.spacer(__assign(__assign({}, ctx), { prev: block, next: null }));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
// Attempt to wrap the block
|
|
87
|
-
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [spaceBefore, blockNode, spaceAfter] }, index));
|
|
88
|
-
});
|
|
89
|
-
}, [blocks, props.wrapBlock, props.spacer]);
|
|
90
|
-
return (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: layout }, void 0);
|
|
91
|
-
}
|
|
92
|
-
exports.ContentBlocks = ContentBlocks;
|
package/components/routing.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ReactNode, PropsWithChildren } from "react";
|
|
2
|
-
import { APropsWithoutRef } from "react-html-props";
|
|
3
|
-
import URLParse from "url-parse";
|
|
4
|
-
import { RouteData } from "../utils/remoteProps";
|
|
5
|
-
declare type RouteItem = URLParse<any> & {
|
|
6
|
-
data?: RouteData;
|
|
7
|
-
};
|
|
8
|
-
declare type AnyPromise = Promise<any>;
|
|
9
|
-
declare type MatchResult = boolean | string;
|
|
10
|
-
declare type RouteStatus = "leaving" | "parent-leaving" | "active" | "inactive";
|
|
11
|
-
declare type RouteContextConfig = {
|
|
12
|
-
debugName?: string;
|
|
13
|
-
match?(next: RouteItem): MatchResult;
|
|
14
|
-
beforeLeave?(current: RouteItem, next: RouteItem, parentIsLeaving: boolean): AnyPromise | undefined;
|
|
15
|
-
onChange?(route: RouteItem, status: RouteStatus): void;
|
|
16
|
-
};
|
|
17
|
-
export declare function useRoute(): RouteItem;
|
|
18
|
-
export declare type RouteProps = RouteContextConfig & {
|
|
19
|
-
children: ReactNode;
|
|
20
|
-
};
|
|
21
|
-
export declare function Route(props: RouteProps): JSX.Element | null;
|
|
22
|
-
export declare function createRouteItem(url: string, data: RouteData): RouteItem;
|
|
23
|
-
declare type RouterRootProps = {
|
|
24
|
-
url: string;
|
|
25
|
-
data: RouteData;
|
|
26
|
-
children: ReactNode;
|
|
27
|
-
onNavigateRequest?: (url: string) => void;
|
|
28
|
-
onPreload?: (url: string) => void;
|
|
29
|
-
onNavigated?: (url: string) => void;
|
|
30
|
-
};
|
|
31
|
-
export declare function RouterRoot(props: RouterRootProps): JSX.Element;
|
|
32
|
-
declare type SwitchProps = {
|
|
33
|
-
children: ReactNode | ReactNode[];
|
|
34
|
-
};
|
|
35
|
-
export declare const Link: import("react").ForwardRefExoticComponent<APropsWithoutRef & {
|
|
36
|
-
preload?: boolean | undefined;
|
|
37
|
-
} & {
|
|
38
|
-
className?: string | undefined;
|
|
39
|
-
} & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
40
|
-
export declare function Switch({ children }: SwitchProps): JSX.Element;
|
|
41
|
-
export declare function RouteItemContext(props: PropsWithChildren<{
|
|
42
|
-
route: RouteItem;
|
|
43
|
-
}>): JSX.Element;
|
|
44
|
-
export {};
|
package/components/routing.js
DELETED
|
@@ -1,363 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.RouteItemContext = exports.Switch = exports.Link = exports.RouterRoot = exports.createRouteItem = exports.Route = 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"));
|
|
58
|
-
// const logger = (...args: any[]) => console.log(...args)
|
|
59
|
-
var logger = function () {
|
|
60
|
-
var args = [];
|
|
61
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
62
|
-
args[_i] = arguments[_i];
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
function createRouteContext(opts) {
|
|
66
|
-
var _a, _b;
|
|
67
|
-
var subscribers = [];
|
|
68
|
-
var notify = function (item, status) {
|
|
69
|
-
subscribers.forEach(function (handler) { return handler(item, status); });
|
|
70
|
-
};
|
|
71
|
-
var parentIsSwitch = opts.parent && opts.parent.isSwitch;
|
|
72
|
-
var ctx = {
|
|
73
|
-
item: opts.initial,
|
|
74
|
-
config: opts.config || {},
|
|
75
|
-
parent: opts.parent,
|
|
76
|
-
children: [],
|
|
77
|
-
status: "inactive",
|
|
78
|
-
currentMatch: false,
|
|
79
|
-
isSwitch: !!opts.isSwitch,
|
|
80
|
-
onNavigate: opts.onNavigate,
|
|
81
|
-
onPreload: opts.onPreload,
|
|
82
|
-
propagateChange: function (item, matches) {
|
|
83
|
-
ctx.item = item;
|
|
84
|
-
ctx.currentMatch = matches;
|
|
85
|
-
ctx.status = matches ? "active" : "inactive";
|
|
86
|
-
ctx.children.forEach(function (child) {
|
|
87
|
-
child.propagateChange(item, child.match(item));
|
|
88
|
-
});
|
|
89
|
-
notify(item, ctx.status);
|
|
90
|
-
},
|
|
91
|
-
propagateCandidate: function (next, prev) {
|
|
92
|
-
// if (ctx.status === "leaving") return Promise.resolve();
|
|
93
|
-
var promises = [Promise.resolve()];
|
|
94
|
-
var matches = ctx.match(next);
|
|
95
|
-
logger(ctx.config.debugName, "was", ctx.status, matches);
|
|
96
|
-
if (ctx.status === "active" && (!matches || matches !== ctx.currentMatch)) {
|
|
97
|
-
logger(ctx.config.debugName, "is leaving because ", matches, "!=", ctx.currentMatch);
|
|
98
|
-
ctx.status = "leaving";
|
|
99
|
-
}
|
|
100
|
-
logger(ctx.config.debugName, "is now", ctx.status);
|
|
101
|
-
if (ctx.status === "leaving") {
|
|
102
|
-
promises.push(this.propagateLeaving(prev, next, false));
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
ctx.children.forEach(function (child) {
|
|
106
|
-
promises.push(child.propagateCandidate(next, prev));
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
notify(prev, ctx.status);
|
|
110
|
-
return Promise.all(promises);
|
|
111
|
-
},
|
|
112
|
-
propagateLeaving: function (current, next, parentIsLeaving) {
|
|
113
|
-
ctx.status = parentIsLeaving ? "parent-leaving" : "leaving";
|
|
114
|
-
logger(ctx.status);
|
|
115
|
-
var promises = [Promise.resolve()];
|
|
116
|
-
if (ctx.config.beforeLeave) {
|
|
117
|
-
var result = ctx.config.beforeLeave(current, next, parentIsLeaving);
|
|
118
|
-
if (result)
|
|
119
|
-
promises.push(result);
|
|
120
|
-
}
|
|
121
|
-
ctx.children.forEach(function (child) {
|
|
122
|
-
var result = child.propagateLeaving(current, next, true);
|
|
123
|
-
if (result) {
|
|
124
|
-
promises.push(result);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
notify(current, ctx.status);
|
|
128
|
-
return Promise.all(promises);
|
|
129
|
-
},
|
|
130
|
-
subscribe: function (handler) {
|
|
131
|
-
subscribers.push(handler);
|
|
132
|
-
handler(ctx.item, ctx.status);
|
|
133
|
-
return function () {
|
|
134
|
-
var i = subscribers.indexOf(handler);
|
|
135
|
-
if (i !== -1) {
|
|
136
|
-
subscribers.splice(i, 1);
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
},
|
|
140
|
-
getFirstMatch: function (item) {
|
|
141
|
-
logger("Checking items", this.children, item);
|
|
142
|
-
for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
|
|
143
|
-
var child = _a[_i];
|
|
144
|
-
if (child.matchSelf(item)) {
|
|
145
|
-
logger("Matched", child.config.debugName);
|
|
146
|
-
return child;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
match: function (item) {
|
|
151
|
-
if (parentIsSwitch) {
|
|
152
|
-
var parent_1 = ctx.parent;
|
|
153
|
-
return parent_1.getFirstMatch(item) === ctx && this.matchSelf(item);
|
|
154
|
-
}
|
|
155
|
-
return this.matchSelf(item);
|
|
156
|
-
},
|
|
157
|
-
matchSelf: function (item) {
|
|
158
|
-
var _a, _b;
|
|
159
|
-
if ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.config) === null || _a === void 0 ? void 0 : _a.match) {
|
|
160
|
-
return (_b = ctx === null || ctx === void 0 ? void 0 : ctx.config) === null || _b === void 0 ? void 0 : _b.match(item);
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
return true;
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
update: function () { },
|
|
167
|
-
dispose: (_a = opts.dispose) !== null && _a !== void 0 ? _a : (function () { }),
|
|
168
|
-
fork: function (config, opts) {
|
|
169
|
-
if (opts === void 0) { opts = {}; }
|
|
170
|
-
var child = createRouteContext({
|
|
171
|
-
initial: ctx.item,
|
|
172
|
-
config: config,
|
|
173
|
-
parent: ctx,
|
|
174
|
-
isSwitch: opts.isSwitch,
|
|
175
|
-
onNavigate: ctx.onNavigate,
|
|
176
|
-
onPreload: ctx.onPreload,
|
|
177
|
-
dispose: function () {
|
|
178
|
-
var i = ctx.children.indexOf(child);
|
|
179
|
-
if (i !== -1)
|
|
180
|
-
ctx.children.splice(i, 1);
|
|
181
|
-
},
|
|
182
|
-
});
|
|
183
|
-
ctx.children.push(child);
|
|
184
|
-
if (ctx.isSwitch) {
|
|
185
|
-
}
|
|
186
|
-
return child;
|
|
187
|
-
},
|
|
188
|
-
};
|
|
189
|
-
logger("Initting", ctx.config.debugName, opts.initial);
|
|
190
|
-
if (parentIsSwitch) {
|
|
191
|
-
logger("Parent is switch");
|
|
192
|
-
if (!((_b = opts.parent) === null || _b === void 0 ? void 0 : _b.getFirstMatch(opts.initial))) {
|
|
193
|
-
logger("FFFF", ctx.config.match, ctx.match(opts.initial));
|
|
194
|
-
ctx.currentMatch = ctx.matchSelf(opts.initial);
|
|
195
|
-
ctx.status = ctx.currentMatch ? "active" : "inactive";
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
else {
|
|
199
|
-
ctx.currentMatch = ctx.matchSelf(opts.initial);
|
|
200
|
-
ctx.status = ctx.currentMatch ? "active" : "inactive";
|
|
201
|
-
}
|
|
202
|
-
subscribers.push(function (item, status) {
|
|
203
|
-
if (ctx.config.onChange) {
|
|
204
|
-
ctx.config.onChange(item, status);
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
// notify(ctx.item, ctx.status);
|
|
208
|
-
return ctx;
|
|
209
|
-
}
|
|
210
|
-
var RouterContext = (0, react_1.createContext)(undefined);
|
|
211
|
-
function useForkedRouter(conf, opts) {
|
|
212
|
-
var parent = (0, react_1.useContext)(RouterContext);
|
|
213
|
-
var ctx = (0, react_1.useMemo)(function () {
|
|
214
|
-
return parent.fork(conf, opts);
|
|
215
|
-
}, [parent]);
|
|
216
|
-
// useEffect(() => {
|
|
217
|
-
// if (onChange) {
|
|
218
|
-
// return ctx.subscribe(onChange);
|
|
219
|
-
// }
|
|
220
|
-
// }, [ctx, onChange]);
|
|
221
|
-
Object.assign(ctx.config, conf);
|
|
222
|
-
// ctx.config.match = conf.match;
|
|
223
|
-
// ctx.config.beforeLeave = conf.beforeLeave;
|
|
224
|
-
// ctx.config.beforeLeave = conf.beforeLeave;
|
|
225
|
-
(0, react_1.useEffect)(function () {
|
|
226
|
-
return function () { return ctx.dispose(); };
|
|
227
|
-
}, [ctx]);
|
|
228
|
-
return ctx;
|
|
229
|
-
}
|
|
230
|
-
function useRoute() {
|
|
231
|
-
var router = (0, react_1.useContext)(RouterContext);
|
|
232
|
-
var _a = (0, react_1.useState)(router.item), route = _a[0], setRoute = _a[1];
|
|
233
|
-
(0, react_1.useEffect)(function () {
|
|
234
|
-
return router.subscribe(function (item, status) {
|
|
235
|
-
setRoute(item);
|
|
236
|
-
});
|
|
237
|
-
}, [router]);
|
|
238
|
-
return route;
|
|
239
|
-
}
|
|
240
|
-
exports.useRoute = useRoute;
|
|
241
|
-
function Route(props) {
|
|
242
|
-
var ctx = useForkedRouter({
|
|
243
|
-
match: props.match,
|
|
244
|
-
beforeLeave: props.beforeLeave,
|
|
245
|
-
debugName: props.debugName,
|
|
246
|
-
onChange: props.onChange,
|
|
247
|
-
});
|
|
248
|
-
logger("Intial route for", props.debugName, ctx.status, ctx.currentMatch);
|
|
249
|
-
var _a = (0, react_1.useState)(ctx.status), status = _a[0], setStatus = _a[1];
|
|
250
|
-
(0, react_1.useEffect)(function () {
|
|
251
|
-
return ctx.subscribe(function (item, status) {
|
|
252
|
-
setStatus(status);
|
|
253
|
-
});
|
|
254
|
-
}, [ctx]);
|
|
255
|
-
if (status === "inactive")
|
|
256
|
-
return null;
|
|
257
|
-
return (0, jsx_runtime_1.jsx)(RouterContext.Provider, __assign({ value: ctx }, { children: props.children }), void 0);
|
|
258
|
-
}
|
|
259
|
-
exports.Route = Route;
|
|
260
|
-
function createRouteItem(url, data) {
|
|
261
|
-
var parsed = (0, url_parse_1.default)(url, true);
|
|
262
|
-
return __assign(__assign({}, parsed), { data: data });
|
|
263
|
-
}
|
|
264
|
-
exports.createRouteItem = createRouteItem;
|
|
265
|
-
function RouterRoot(props) {
|
|
266
|
-
var _this = this;
|
|
267
|
-
var onNavigateRef = (0, react_1.useRef)(props.onNavigateRequest);
|
|
268
|
-
var onPreNavigateRef = (0, react_1.useRef)(props.onPreload);
|
|
269
|
-
var ctx = (0, react_1.useMemo)(function () {
|
|
270
|
-
return createRouteContext({
|
|
271
|
-
initial: createRouteItem(props.url, props.data),
|
|
272
|
-
config: {
|
|
273
|
-
debugName: "ROOT",
|
|
274
|
-
},
|
|
275
|
-
onNavigate: function (path) { return __awaiter(_this, void 0, void 0, function () {
|
|
276
|
-
return __generator(this, function (_a) {
|
|
277
|
-
// User has clicked a link
|
|
278
|
-
if (onNavigateRef.current) {
|
|
279
|
-
onNavigateRef.current(path);
|
|
280
|
-
}
|
|
281
|
-
return [2 /*return*/];
|
|
282
|
-
});
|
|
283
|
-
}); },
|
|
284
|
-
onPreload: function (path) {
|
|
285
|
-
if (onPreNavigateRef.current) {
|
|
286
|
-
onPreNavigateRef.current(path);
|
|
287
|
-
}
|
|
288
|
-
},
|
|
289
|
-
});
|
|
290
|
-
}, []);
|
|
291
|
-
onNavigateRef.current = props.onNavigateRequest;
|
|
292
|
-
onPreNavigateRef.current = props.onPreload;
|
|
293
|
-
(0, react_1.useEffect)(function () {
|
|
294
|
-
var cancelled = false;
|
|
295
|
-
var item = createRouteItem(props.url, props.data);
|
|
296
|
-
if (item.href !== ctx.item.href || item.data !== ctx.item.data) {
|
|
297
|
-
ctx.propagateCandidate(item, ctx.item).then(function () {
|
|
298
|
-
if (!cancelled) {
|
|
299
|
-
ctx.propagateChange(item, true);
|
|
300
|
-
}
|
|
301
|
-
});
|
|
302
|
-
return function () {
|
|
303
|
-
cancelled = true;
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
}, [props.url, props.data]);
|
|
307
|
-
return (0, jsx_runtime_1.jsx)(RouterContext.Provider, __assign({ value: ctx }, { children: props.children }), void 0);
|
|
308
|
-
}
|
|
309
|
-
exports.RouterRoot = RouterRoot;
|
|
310
|
-
exports.Link = (0, react_1.forwardRef)(function (props, ref) {
|
|
311
|
-
var localRef = (0, react_1.useRef)();
|
|
312
|
-
var router = (0, react_1.useContext)(RouterContext);
|
|
313
|
-
(0, react_1.useEffect)(function () {
|
|
314
|
-
if (props.preload && localRef.current) {
|
|
315
|
-
router === null || router === void 0 ? void 0 : router.onPreload(localRef.current.href);
|
|
316
|
-
}
|
|
317
|
-
}, [props.preload]);
|
|
318
|
-
return ((0, jsx_runtime_1.jsx)("a", __assign({ ref: (0, react_merge_refs_1.default)([localRef, ref]) }, props, { onMouseEnter: function (e) {
|
|
319
|
-
if (props.onMouseOver) {
|
|
320
|
-
props.onMouseOver(e);
|
|
321
|
-
}
|
|
322
|
-
router === null || router === void 0 ? void 0 : router.onPreload(e.currentTarget.href);
|
|
323
|
-
}, onClick: function (e) {
|
|
324
|
-
if (process.admin) {
|
|
325
|
-
e.preventDefault();
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
if (props.onClick) {
|
|
329
|
-
props.onClick(e);
|
|
330
|
-
}
|
|
331
|
-
if (!e.isDefaultPrevented() && router && !e.ctrlKey && !e.metaKey) {
|
|
332
|
-
var url = (0, url_parse_1.default)(e.currentTarget.href, true);
|
|
333
|
-
if (url.origin === document.location.origin) {
|
|
334
|
-
router.onNavigate(e.currentTarget.href);
|
|
335
|
-
e.preventDefault();
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
} }), void 0));
|
|
339
|
-
});
|
|
340
|
-
function Switch(_a) {
|
|
341
|
-
var children = _a.children;
|
|
342
|
-
var ctx = useForkedRouter({
|
|
343
|
-
debugName: "SWITCH",
|
|
344
|
-
match: function () {
|
|
345
|
-
return true;
|
|
346
|
-
},
|
|
347
|
-
beforeLeave: function () {
|
|
348
|
-
return undefined;
|
|
349
|
-
},
|
|
350
|
-
}, { isSwitch: true });
|
|
351
|
-
return (0, jsx_runtime_1.jsx)(RouterContext.Provider, __assign({ value: ctx }, { children: children }), void 0);
|
|
352
|
-
}
|
|
353
|
-
exports.Switch = Switch;
|
|
354
|
-
function RouteItemContext(props) {
|
|
355
|
-
var ctx = useForkedRouter({
|
|
356
|
-
match: function () { return true; },
|
|
357
|
-
beforeLeave: undefined,
|
|
358
|
-
debugName: undefined,
|
|
359
|
-
onChange: undefined,
|
|
360
|
-
});
|
|
361
|
-
return (0, jsx_runtime_1.jsx)(RouterContext.Provider, __assign({ value: ctx }, { children: props.children }), void 0);
|
|
362
|
-
}
|
|
363
|
-
exports.RouteItemContext = RouteItemContext;
|