eddev 0.1.28 → 0.1.32
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.d.ts +36 -0
- package/blocks/ContentBlocks.js +89 -0
- package/blocks/blockAttributes.d.ts +1 -1
- package/blocks/index.d.ts +1 -0
- package/blocks/index.js +1 -0
- package/blocks/inlineEditing.js +2 -2
- package/build/workers/codegen-worker-script.js +3 -2
- package/components/BrowserRouter.js +1 -1
- package/components/InlinePage.js +1 -1
- package/components/index.d.ts +0 -2
- package/components/index.js +0 -2
- package/components/routing.d.ts +2 -0
- package/entry/Root.js +4 -4
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +1 -1
- package/routing/index.d.ts +1 -0
- package/routing/index.js +13 -0
- package/routing/routing.d.ts +45 -0
- package/routing/routing.js +373 -0
- package/build/codegen-worker-script.d.ts +0 -5
- package/build/codegen-worker-script.js +0 -543
- package/build/webpack-worker-script.d.ts +0 -2
- package/build/webpack-worker-script.js +0 -160
- package/cli/generate.d.ts +0 -1
- package/cli/generate.js +0 -46
|
@@ -0,0 +1,36 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,89 @@
|
|
|
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("./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), [parentContext === null || parentContext === void 0 ? void 0 : parentContext.current], 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] });
|
|
41
|
+
// Figure out the
|
|
42
|
+
var blockNode;
|
|
43
|
+
if (block.blockName in blocks_1.default) {
|
|
44
|
+
var Component = blocks_1.default[block.blockName];
|
|
45
|
+
if (!Component)
|
|
46
|
+
return (0, jsx_runtime_1.jsx)(react_1.Fragment, {}, void 0);
|
|
47
|
+
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,
|
|
48
|
+
// innerBlocks={block.innerBlocks}
|
|
49
|
+
children: Array.isArray(block.innerBlocks) && block.innerBlocks.length ? ((0, jsx_runtime_1.jsx)(ContentBlocks, { blocks: block.innerBlocks }, void 0)) : null }), void 0) }), void 0));
|
|
50
|
+
}
|
|
51
|
+
else if (block.innerHTML) {
|
|
52
|
+
blockNode = (0, jsx_runtime_1.jsx)("div", { dangerouslySetInnerHTML: { __html: block.innerHTML } }, void 0);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
blockNode = null;
|
|
56
|
+
}
|
|
57
|
+
return [ctx, block, blockNode];
|
|
58
|
+
});
|
|
59
|
+
}, [props.blocks]);
|
|
60
|
+
var layout = (0, react_1.useMemo)(function () {
|
|
61
|
+
return blocks.filter(Boolean).map(function (_a, index) {
|
|
62
|
+
var ctx = _a[0], block = _a[1], blockNode = _a[2];
|
|
63
|
+
// Exit early if the block is null
|
|
64
|
+
if (blockNode === null)
|
|
65
|
+
return (0, jsx_runtime_1.jsx)(react_1.Fragment, {}, index);
|
|
66
|
+
// Custom wrap function?
|
|
67
|
+
if (props.wrapBlock) {
|
|
68
|
+
blockNode = props.wrapBlock(blockNode, ctx);
|
|
69
|
+
}
|
|
70
|
+
// Wrap the block in a context provider
|
|
71
|
+
blockNode = (0, jsx_runtime_1.jsx)(exports.BlocksContext.Provider, __assign({ value: ctx }, { children: blockNode }), void 0);
|
|
72
|
+
// Custom spacer function?
|
|
73
|
+
var spaceBefore = null;
|
|
74
|
+
var spaceAfter = null;
|
|
75
|
+
if (props.spacer) {
|
|
76
|
+
// Before block
|
|
77
|
+
spaceBefore = props.spacer(__assign(__assign({}, ctx), { prev: ctx.prev || null, next: ctx.current || null }));
|
|
78
|
+
// After block (last block only)
|
|
79
|
+
if (index === props.blocks.length - 1) {
|
|
80
|
+
spaceAfter = props.spacer(__assign(__assign({}, ctx), { prev: block, next: null }));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Attempt to wrap the block
|
|
84
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Fragment, { children: [spaceBefore, blockNode, spaceAfter] }, index));
|
|
85
|
+
});
|
|
86
|
+
}, [blocks, props.wrapBlock, props.spacer]);
|
|
87
|
+
return (0, jsx_runtime_1.jsx)(react_1.Fragment, { children: layout }, void 0);
|
|
88
|
+
}
|
|
89
|
+
exports.ContentBlocks = ContentBlocks;
|
package/blocks/index.d.ts
CHANGED
package/blocks/index.js
CHANGED
|
@@ -14,6 +14,7 @@ exports.useInnerBlocks = exports.useInlineEditableValue = void 0;
|
|
|
14
14
|
__exportStar(require("./installGutenbergHooks"), exports);
|
|
15
15
|
__exportStar(require("./defineBlock"), exports);
|
|
16
16
|
__exportStar(require("./inlineEditing"), exports);
|
|
17
|
+
__exportStar(require("./ContentBlocks"), exports);
|
|
17
18
|
var blockAttributes_1 = require("./blockAttributes");
|
|
18
19
|
Object.defineProperty(exports, "useInlineEditableValue", { enumerable: true, get: function () { return blockAttributes_1.useInlineEditableValue; } });
|
|
19
20
|
Object.defineProperty(exports, "useInnerBlocks", { enumerable: true, get: function () { return blockAttributes_1.useInnerBlocks; } });
|
package/blocks/inlineEditing.js
CHANGED
|
@@ -26,7 +26,7 @@ exports.InnerBlocks = exports.EditableText = void 0;
|
|
|
26
26
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
27
|
// @ts-ignore
|
|
28
28
|
var block_editor_1 = require("@wordpress/block-editor");
|
|
29
|
-
var
|
|
29
|
+
var ContentBlocks_1 = require("./ContentBlocks");
|
|
30
30
|
var react_1 = require("react");
|
|
31
31
|
var blockAttributes_1 = require("./blockAttributes");
|
|
32
32
|
var react_2 = require("@stitches/react");
|
|
@@ -84,7 +84,7 @@ function InnerBlocks(props) {
|
|
|
84
84
|
}
|
|
85
85
|
else {
|
|
86
86
|
var blocks = (0, blockAttributes_1.useInnerBlocks)();
|
|
87
|
-
return (0, jsx_runtime_1.jsx)(
|
|
87
|
+
return (0, jsx_runtime_1.jsx)(ContentBlocks_1.ContentBlocks, { blocks: blocks }, void 0);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
exports.InnerBlocks = InnerBlocks;
|
|
@@ -105,6 +105,7 @@ var graphqlPatterns = {
|
|
|
105
105
|
blocks: "./blocks/**/*.graphql",
|
|
106
106
|
views: "./views/**/*.graphql",
|
|
107
107
|
queries: "./queries/**/*.graphql",
|
|
108
|
+
fragments: "./queries/fragments/**/*.graphql",
|
|
108
109
|
};
|
|
109
110
|
var tsxPatterns = {
|
|
110
111
|
blocks: "./blocks/**/*.tsx",
|
|
@@ -291,7 +292,7 @@ function beginWork(opts) {
|
|
|
291
292
|
},
|
|
292
293
|
},
|
|
293
294
|
"types.views.ts": {
|
|
294
|
-
documents: __spreadArray([], documentSets.views, true),
|
|
295
|
+
documents: __spreadArray(__spreadArray([], documentSets.views, true), documentSets.fragments, true),
|
|
295
296
|
plugins: [
|
|
296
297
|
{
|
|
297
298
|
files: {},
|
|
@@ -311,7 +312,7 @@ function beginWork(opts) {
|
|
|
311
312
|
},
|
|
312
313
|
},
|
|
313
314
|
"types.blocks.ts": {
|
|
314
|
-
documents: __spreadArray([], documentSets.blocks, true),
|
|
315
|
+
documents: __spreadArray(__spreadArray([], documentSets.blocks, true), documentSets.fragments, true),
|
|
315
316
|
plugins: [
|
|
316
317
|
{
|
|
317
318
|
files: {},
|
|
@@ -18,7 +18,7 @@ exports.BrowserRouter = void 0;
|
|
|
18
18
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
19
|
var react_1 = require("react");
|
|
20
20
|
var remoteProps_1 = require("../utils/remoteProps");
|
|
21
|
-
var routing_1 = require("
|
|
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");
|
package/components/InlinePage.js
CHANGED
|
@@ -18,7 +18,7 @@ exports.InlinePage = void 0;
|
|
|
18
18
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
19
|
var react_1 = require("react");
|
|
20
20
|
var remoteProps_1 = require("../utils/remoteProps");
|
|
21
|
-
var routing_1 = require("
|
|
21
|
+
var routing_1 = require("../routing");
|
|
22
22
|
// @ts-ignore
|
|
23
23
|
var views_1 = __importDefault(require("@manifest/views"));
|
|
24
24
|
/**
|
package/components/index.d.ts
CHANGED
package/components/index.js
CHANGED
|
@@ -10,7 +10,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./routing"), exports);
|
|
14
|
-
__exportStar(require("./ContentBlocks"), exports);
|
|
15
13
|
__exportStar(require("./AdminBar"), exports);
|
|
16
14
|
__exportStar(require("./InlinePage"), exports);
|
package/components/routing.d.ts
CHANGED
|
@@ -34,6 +34,8 @@ declare type SwitchProps = {
|
|
|
34
34
|
};
|
|
35
35
|
export declare const Link: import("react").ForwardRefExoticComponent<APropsWithoutRef & {
|
|
36
36
|
preload?: boolean | undefined;
|
|
37
|
+
} & {
|
|
38
|
+
className?: string | undefined;
|
|
37
39
|
} & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
38
40
|
export declare function Switch({ children }: SwitchProps): JSX.Element;
|
|
39
41
|
export declare function RouteItemContext(props: PropsWithChildren<{
|
package/entry/Root.js
CHANGED
|
@@ -34,13 +34,13 @@ var jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
34
34
|
// @ts-ignore
|
|
35
35
|
var views_1 = __importStar(require("@manifest/views"));
|
|
36
36
|
var react_1 = require("react");
|
|
37
|
-
var
|
|
37
|
+
var routing_1 = require("../routing");
|
|
38
38
|
function Root() {
|
|
39
|
-
var route = (0,
|
|
40
|
-
return ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: (0, jsx_runtime_1.jsx)(views_1.App, { children: (0, jsx_runtime_1.jsx)(
|
|
39
|
+
var route = (0, routing_1.useRoute)();
|
|
40
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Fragment, { children: (0, jsx_runtime_1.jsx)(views_1.App, { children: (0, jsx_runtime_1.jsx)(routing_1.Switch, { children: Object.entries(views_1.default).map(function (_a) {
|
|
41
41
|
var _b, _c;
|
|
42
42
|
var name = _a[0], Component = _a[1];
|
|
43
|
-
return ((0, jsx_runtime_1.jsx)(
|
|
43
|
+
return ((0, jsx_runtime_1.jsx)(routing_1.Route, __assign({ match: function (route) { var _a; return ((_a = route.data) === null || _a === void 0 ? void 0 : _a.view) === name; } }, { children: (0, jsx_runtime_1.jsx)(Component, __assign({}, (_c = (_b = route.data) === null || _b === void 0 ? void 0 : _b.viewData) === null || _c === void 0 ? void 0 : _c.data), void 0) }), name));
|
|
44
44
|
}) }, void 0) }, void 0) }, void 0));
|
|
45
45
|
}
|
|
46
46
|
exports.default = Root;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -12,3 +12,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./components"), exports);
|
|
14
14
|
__exportStar(require("./hooks"), exports);
|
|
15
|
+
__exportStar(require("./routing"), exports);
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./routing";
|
package/routing/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./routing"), exports);
|
|
@@ -0,0 +1,45 @@
|
|
|
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 isInternalPageLink: (href: string) => boolean;
|
|
36
|
+
export declare const Link: import("react").ForwardRefExoticComponent<APropsWithoutRef & {
|
|
37
|
+
preload?: boolean | undefined;
|
|
38
|
+
} & {
|
|
39
|
+
className?: string | undefined;
|
|
40
|
+
} & import("react").RefAttributes<HTMLAnchorElement>>;
|
|
41
|
+
export declare function Switch({ children }: SwitchProps): JSX.Element;
|
|
42
|
+
export declare function RouteItemContext(props: PropsWithChildren<{
|
|
43
|
+
route: RouteItem;
|
|
44
|
+
}>): JSX.Element;
|
|
45
|
+
export {};
|