eddev 0.2.2-beta.4 → 0.2.2-beta.7

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.
@@ -48,7 +48,7 @@ function ContentBlocks(props) {
48
48
  var Component = blocks_1.default[block.blockName];
49
49
  if (!Component)
50
50
  return (0, jsx_runtime_1.jsx)(react_1.Fragment, {}, void 0);
51
- 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,
51
+ blockNode = ((0, jsx_runtime_1.jsx)(blockAttributes_1.InlineEditingContextProvider, __assign({ block: [block.blockName, block.props], values: block.inline, innerBlocks: block.innerBlocks }, { children: (0, jsx_runtime_1.jsx)(Component, __assign({}, block.props, { innerHTML: block.innerHTML,
52
52
  // innerBlocks={block.innerBlocks}
53
53
  children: Array.isArray(block.innerBlocks) && block.innerBlocks.length ? ((0, jsx_runtime_1.jsx)(ContentBlocks, { blocks: block.innerBlocks }, void 0)) : null }), void 0) }), void 0));
54
54
  }
@@ -6,6 +6,7 @@ interface Attributes {
6
6
  declare type ProviderProps = PropsWithChildren<{
7
7
  values: Attributes;
8
8
  innerBlocks: ContentBlock[];
9
+ block: [string, Attributes];
9
10
  onChange?: (attrs: Attributes) => void;
10
11
  insertBlocksAfter?: (block: any) => void;
11
12
  }>;
@@ -13,4 +14,5 @@ export declare function InlineEditingContextProvider(props: ProviderProps): JSX.
13
14
  export declare function useInlineEditableValue<T>(key: string, defaultValue?: T): [T, (value: T) => void];
14
15
  export declare function useBlockAppender(): ((block: any) => void) | undefined;
15
16
  export declare function useInnerBlocks(): ContentBlock[];
17
+ export declare function useBlockParents(): [string, Attributes][];
16
18
  export {};
@@ -10,15 +10,26 @@ var __assign = (this && this.__assign) || function () {
10
10
  };
11
11
  return __assign.apply(this, arguments);
12
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
+ };
13
22
  Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.useInnerBlocks = exports.useBlockAppender = exports.useInlineEditableValue = exports.InlineEditingContextProvider = void 0;
23
+ exports.useBlockParents = exports.useInnerBlocks = exports.useBlockAppender = exports.useInlineEditableValue = exports.InlineEditingContextProvider = void 0;
15
24
  var jsx_runtime_1 = require("react/jsx-runtime");
16
25
  var react_1 = require("react");
17
26
  var InlineEditingContext = (0, react_1.createContext)(undefined);
18
27
  function InlineEditingContextProvider(props) {
28
+ var parentContext = (0, react_1.useContext)(InlineEditingContext);
19
29
  return ((0, jsx_runtime_1.jsx)(InlineEditingContext.Provider, __assign({ value: {
20
30
  values: props.values,
21
31
  innerBlocks: props.innerBlocks,
32
+ parents: __spreadArray(__spreadArray([], ((parentContext === null || parentContext === void 0 ? void 0 : parentContext.parents) || []), true), [props.block], false).filter(Boolean),
22
33
  getValue: function (key) {
23
34
  var _a;
24
35
  return (_a = props.values) === null || _a === void 0 ? void 0 : _a[key];
@@ -52,11 +63,10 @@ exports.useBlockAppender = useBlockAppender;
52
63
  function useInnerBlocks() {
53
64
  var ctx = (0, react_1.useContext)(InlineEditingContext);
54
65
  return (ctx === null || ctx === void 0 ? void 0 : ctx.innerBlocks) || [];
55
- // return [
56
- // attrs?.getValue(key),
57
- // (value: any) => {
58
- // attrs?.setValue(key, value)
59
- // },
60
- // ] as [T, (value: T) => void]
61
66
  }
62
67
  exports.useInnerBlocks = useInnerBlocks;
68
+ function useBlockParents() {
69
+ var ctx = (0, react_1.useContext)(InlineEditingContext);
70
+ return (ctx === null || ctx === void 0 ? void 0 : ctx.parents) || [];
71
+ }
72
+ exports.useBlockParents = useBlockParents;
@@ -1,4 +1,4 @@
1
- import { ElementType } from "react";
1
+ import { ElementType, FunctionComponent } from "react";
2
2
  import { ContentBlocksSettings } from ".";
3
3
  declare type PropTypes<T extends ElementType> = {
4
4
  /** The 'key' of this editable text value */
@@ -14,13 +14,17 @@ declare type PropTypes<T extends ElementType> = {
14
14
  /** Append a new block when the user hits 'Enter' */
15
15
  appendOnEnter?: boolean;
16
16
  } & React.ComponentPropsWithoutRef<T>;
17
- export declare function EditableText<T extends ElementType>({ id, as, ...props }: PropTypes<T>): JSX.Element | null;
17
+ export declare function EditableText<T extends ElementType>({ id, as, appendOnEnter, ...props }: PropTypes<T>): JSX.Element | null;
18
+ declare type AppenderConfig = {
19
+ type: "default" | "button" | FunctionComponent<any>;
20
+ block?: boolean;
21
+ };
18
22
  declare type InnerBlocksProps = {
19
23
  allowedBlocks?: string[];
20
24
  orientation?: "horizontal" | "vertical";
21
25
  templateLock?: any;
22
26
  template?: any;
23
- renderAppender?: any;
27
+ appender?: AppenderConfig;
24
28
  } & ContentBlocksSettings;
25
29
  export declare function InnerBlocks(props: InnerBlocksProps): JSX.Element;
26
30
  export {};
@@ -24,7 +24,6 @@ var __rest = (this && this.__rest) || function (s, e) {
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.InnerBlocks = exports.EditableText = void 0;
26
26
  var jsx_runtime_1 = require("react/jsx-runtime");
27
- // @ts-ignore
28
27
  var block_editor_1 = require("@wordpress/block-editor");
29
28
  // @ts-ignore
30
29
  var blocks_1 = require("@wordpress/blocks");
@@ -35,12 +34,12 @@ var react_2 = require("@stitches/react");
35
34
  var remoteProps_1 = require("../routing/remoteProps");
36
35
  var __1 = require("..");
37
36
  function EditableText(_a) {
38
- var id = _a.id, as = _a.as, props = __rest(_a, ["id", "as"]);
37
+ var id = _a.id, as = _a.as, appendOnEnter = _a.appendOnEnter, props = __rest(_a, ["id", "as", "appendOnEnter"]);
39
38
  if (process.admin) {
40
39
  var _b = (0, blockAttributes_1.useInlineEditableValue)(id), value = _b[0], setValue = _b[1];
41
40
  var appendBlocks_1 = (0, blockAttributes_1.useBlockAppender)();
42
41
  return ((0, jsx_runtime_1.jsx)(block_editor_1.RichText, __assign({}, props, { tagName: as, value: value || "", onChange: setValue, disableLineBreaks: props.disableLineBreaks, onKeyDownCapture: function (e) {
43
- if (e.key === "Enter" && props.appendOnEnter && appendBlocks_1) {
42
+ if (e.key === "Enter" && appendOnEnter && appendBlocks_1) {
44
43
  appendBlocks_1([(0, blocks_1.createBlock)("core/paragraph")]);
45
44
  e.preventDefault();
46
45
  e.stopPropagation();
@@ -75,10 +74,23 @@ function EditableText(_a) {
75
74
  }
76
75
  }
77
76
  exports.EditableText = EditableText;
77
+ var Appender = function (props) {
78
+ if (props.type === "button") {
79
+ return (0, jsx_runtime_1.jsx)(block_editor_1.ButtonBlockAppender, {}, void 0);
80
+ }
81
+ else if (typeof props.type === "function") {
82
+ return props.type({});
83
+ }
84
+ else {
85
+ return (0, jsx_runtime_1.jsx)(block_editor_1.DefaultBlockAppender, {}, void 0);
86
+ }
87
+ };
78
88
  function InnerBlocks(props) {
79
89
  if (process.admin) {
80
90
  var allowedBlocks = props.allowedBlocks;
81
- 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));
91
+ 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,
92
+ // renderAppender={() => <Appender {...props.appender} />}
93
+ templateLock: props.templateLock, template: props.template }, void 0) }), void 0));
82
94
  }
83
95
  else {
84
96
  var blocks = (0, blockAttributes_1.useInnerBlocks)();
@@ -95,6 +107,9 @@ var InnerBlocksAdminWrapper = (0, react_2.styled)("div", {
95
107
  // marginRight: "auto",
96
108
  maxWidth: "var(--grid-inner-width)",
97
109
  },
110
+ ".block-editor-block-list__block .block-list-appender:only-child": {
111
+ alignSelf: "auto !important",
112
+ },
98
113
  variants: {
99
114
  orientation: {
100
115
  vertical: {
@@ -97,7 +97,7 @@ function installEDGutenbergHooks() {
97
97
  });
98
98
  return children;
99
99
  }, []);
100
- return ((0, jsx_runtime_1.jsx)(BlockContext.Provider, __assign({ value: { name: name, props: props } }, { children: (0, jsx_runtime_1.jsx)(blockAttributes_1.InlineEditingContextProvider, __assign({ values: props.attributes.inline || {}, innerBlocks: children, onChange: function (attrs) {
100
+ return ((0, jsx_runtime_1.jsx)(BlockContext.Provider, __assign({ value: { name: name, props: props } }, { children: (0, jsx_runtime_1.jsx)(blockAttributes_1.InlineEditingContextProvider, __assign({ values: props.attributes.inline || {}, innerBlocks: children, block: [name, props], onChange: function (attrs) {
101
101
  props.setAttributes(__assign(__assign({}, props.attributes), { inline: attrs }));
102
102
  }, insertBlocksAfter: props.insertBlocksAfter }, { children: edit_1.call(self, props) }), void 0) }), void 0));
103
103
  };
@@ -181,7 +181,9 @@ function beginWork(opts) {
181
181
  if (!endpoint) {
182
182
  sendSignal({
183
183
  code: "error",
184
- errors: ["Could not find DEBUG_GRAPHQL_URL value in .env"],
184
+ errors: [
185
+ "Could not find DEBUG_GRAPHQL_URL value in .env. This will be automatically populated once you visit WP Admin first the first time!",
186
+ ],
185
187
  });
186
188
  regenerating = false;
187
189
  return [2 /*return*/];
package/cli/preinstall.js CHANGED
@@ -1,14 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = void 0;
4
- var fs_1 = require("fs");
5
- var path_1 = require("path");
4
+ var child_process_1 = require("child_process");
6
5
  function main() {
6
+ var _a, _b;
7
7
  if (process.env.VERCEL) {
8
- var pkgFile = (0, path_1.join)(process.cwd(), "package.json");
9
- var pkg = JSON.parse((0, fs_1.readFileSync)(pkgFile).toString());
10
- pkg.devDependencies["next"] = "^12.1.0";
11
- (0, fs_1.writeFile)(pkgFile, JSON.stringify(pkg, null, " "), function () { });
8
+ // const pkgFile = join(process.cwd(), "package.json")
9
+ // const pkg = JSON.parse(readFileSync(pkgFile).toString()) as any
10
+ // pkg.devDependencies["next"] = "^12.1.0"
11
+ // writeFile(pkgFile, JSON.stringify(pkg, null, " "), () => {})
12
+ var proc = (0, child_process_1.spawn)("yarn", ["add", "--dev", "next@^12.1.0"], {
13
+ cwd: process.cwd(),
14
+ });
15
+ (_a = proc.stdout) === null || _a === void 0 ? void 0 : _a.pipe(process.stdout);
16
+ (_b = proc.stderr) === null || _b === void 0 ? void 0 : _b.pipe(process.stderr);
12
17
  }
13
18
  }
14
19
  exports.main = main;
@@ -22,6 +22,10 @@ function useAppData(selector) {
22
22
  return selector(value);
23
23
  return value;
24
24
  }
25
+ else if (process.admin) {
26
+ // @ts-ignore
27
+ return selector ? selector(__ED_APP_DATA.data) : __ED_APP_DATA.data;
28
+ }
25
29
  else {
26
30
  return useAppDataStore(function (store) {
27
31
  if (selector)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eddev",
3
- "version": "0.2.2-beta.4",
3
+ "version": "0.2.2-beta.7",
4
4
  "main": "./index.js",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -48,8 +48,8 @@
48
48
  "@loadable/webpack-plugin": "^5.15.2",
49
49
  "@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
50
50
  "@soda/friendly-errors-webpack-plugin": "^1.8.0",
51
- "@stitches/core": "^1.2.6",
52
- "@stitches/react": "^1.2.6",
51
+ "@stitches/core": "^1.2.7",
52
+ "@stitches/react": "^1.2.7",
53
53
  "@trpc/client": "^9.19.0",
54
54
  "@trpc/next": "^9.19.0",
55
55
  "@trpc/react": "^9.19.0",
@@ -1,4 +1,5 @@
1
1
  import { Agent } from "https"
2
+ import { fetch } from "cross-fetch"
2
3
 
3
4
  // Used to allow self-signed certificates
4
5
  const agent = new Agent({
@@ -26,7 +26,9 @@ function Root({ Component, pageProps }: AppProps) {
26
26
 
27
27
  if (!appData) return <div />
28
28
 
29
- console.log(`Could not load view named "${pageProps.view}"`)
29
+ if (!View) {
30
+ console.log(`Could not load view named "${pageProps.view}"`)
31
+ }
30
32
 
31
33
  return (
32
34
  <ServerlessAppDataProvider value={appData}>