eddev 0.2.1 → 0.2.2-beta.11

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 (60) hide show
  1. package/{fields → admin}/components/ImageWell.d.ts +0 -1
  2. package/{fields → admin}/components/ImageWell.js +0 -0
  3. package/{fields → admin}/defineFIeld.d.ts +0 -0
  4. package/{fields → admin}/defineFIeld.js +0 -0
  5. package/admin/defineWidget.d.ts +10 -0
  6. package/admin/defineWidget.js +10 -0
  7. package/admin/index.d.ts +3 -0
  8. package/{fields → admin}/index.js +2 -1
  9. package/{fields → admin}/installFieldTypes.d.ts +0 -0
  10. package/{fields → admin}/installFieldTypes.js +0 -0
  11. package/admin/runWidgets.d.ts +1 -0
  12. package/admin/runWidgets.js +40 -0
  13. package/{fields → admin}/selectMedia.d.ts +0 -0
  14. package/{fields → admin}/selectMedia.js +0 -0
  15. package/blocks/ContentBlocks.js +4 -1
  16. package/blocks/blockAttributes.d.ts +4 -0
  17. package/blocks/blockAttributes.js +23 -7
  18. package/blocks/inlineEditing.d.ts +9 -3
  19. package/blocks/inlineEditing.js +28 -5
  20. package/blocks/installGutenbergHooks.js +24 -3
  21. package/build/get-webpack-config.js +18 -0
  22. package/build/graphql-codegen/graphql-codegen-blocks.js +0 -1
  23. package/build/manifests/manifest-widgets.d.ts +12 -0
  24. package/build/manifests/manifest-widgets.js +42 -0
  25. package/build/serverless/create-next-app.js +0 -4
  26. package/build/workers/codegen-worker-script.js +3 -1
  27. package/cli/display/components/BundleDisplay.d.ts +0 -1
  28. package/cli/display/components/CodegenDisplay.d.ts +0 -1
  29. package/cli/display/components/DevCLIDisplay.d.ts +0 -1
  30. package/cli/display/components/ServerlessDisplay.d.ts +0 -1
  31. package/cli/display/components/StatusIcon.d.ts +0 -1
  32. package/cli/preinstall.js +11 -6
  33. package/components/AdminBar.d.ts +0 -1
  34. package/dev-ui/components/BreakpointColumnHeader.d.ts +0 -1
  35. package/dev-ui/components/BreakpointIndicator.d.ts +0 -1
  36. package/dev-ui/components/DevUI.d.ts +0 -1
  37. package/dev-ui/components/ResponsiveLerpControl.d.ts +0 -1
  38. package/dev-ui/components/ResponsiveScaleEditor.d.ts +0 -1
  39. package/dev-ui/components/ResponsiveScaleEditor.js +3 -3
  40. package/dev-ui/components/atoms/NumberField.d.ts +0 -1
  41. package/dev-ui/components/panels/PageDataDebugger.d.ts +0 -1
  42. package/dev-ui/components/panels/SpacingEditor.d.ts +0 -1
  43. package/dev-ui/components/panels/TypographyEditor.d.ts +0 -1
  44. package/dev-ui/components/panels/TypographyEditor.js +10 -3
  45. package/dev-ui/icons.d.ts +0 -1
  46. package/dev-ui/loader.d.ts +0 -1
  47. package/entry/Root.d.ts +0 -1
  48. package/entry/entry.admin.dev.js +13 -1
  49. package/entry/entry.admin.prod.js +3 -1
  50. package/hooks/useAppData.js +4 -0
  51. package/package.json +4 -4
  52. package/serverless-template/_utils/fetch-wp.ts +1 -0
  53. package/serverless-template/package.json +2 -2
  54. package/serverless-template/pages/_app.tsx +3 -1
  55. package/style/createStitches.js +30 -29
  56. package/dev-ui/theme.d.ts +0 -151
  57. package/dynamic/dynamic-component.d.ts +0 -10
  58. package/fields/index.d.ts +0 -2
  59. package/hooks/useRPC.d.ts +0 -32
  60. package/style/createStitches.d.ts +0 -1056
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare type Props = {
3
2
  previewSize: string;
4
3
  aspects: string[];
File without changes
File without changes
File without changes
@@ -0,0 +1,10 @@
1
+ import { ComponentType } from "react";
2
+ declare type WidgetProps = {
3
+ element: HTMLElement;
4
+ dataset: DOMStringMap;
5
+ };
6
+ export declare function defineWidget(name: string, component: ComponentType<WidgetProps>): {
7
+ name: string;
8
+ component: ComponentType<WidgetProps>;
9
+ };
10
+ export {};
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defineWidget = void 0;
4
+ function defineWidget(name, component) {
5
+ return {
6
+ name: name,
7
+ component: component,
8
+ };
9
+ }
10
+ exports.defineWidget = defineWidget;
@@ -0,0 +1,3 @@
1
+ export * from "./defineField";
2
+ export * from "./defineWidget";
3
+ export * from "./components/ImageWell";
@@ -10,5 +10,6 @@ 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("./defineFIeld"), exports);
13
+ __exportStar(require("./defineField"), exports);
14
+ __exportStar(require("./defineWidget"), exports);
14
15
  __exportStar(require("./components/ImageWell"), exports);
File without changes
File without changes
@@ -0,0 +1 @@
1
+ export declare function runWidgets(): void;
@@ -0,0 +1,40 @@
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 __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.runWidgets = void 0;
18
+ var jsx_runtime_1 = require("react/jsx-runtime");
19
+ // @ts-ignore
20
+ var widgets_1 = __importDefault(require("@manifest/widgets"));
21
+ var react_dom_1 = __importDefault(require("react-dom"));
22
+ function runWidgets() {
23
+ var elements = document.querySelectorAll("[data-widget]");
24
+ console.log("Running widgets", elements, widgets_1.default);
25
+ elements.forEach(function (el) {
26
+ if (el instanceof HTMLElement) {
27
+ var data = el.dataset;
28
+ var name_1 = data["widget"];
29
+ var type = widgets_1.default.find(function (item) { return item.name === name_1; });
30
+ if (type) {
31
+ var props = {
32
+ element: el,
33
+ dataset: data,
34
+ };
35
+ react_dom_1.default.render((0, jsx_runtime_1.jsx)(type.component, __assign({}, props), void 0), el);
36
+ }
37
+ }
38
+ });
39
+ }
40
+ exports.runWidgets = runWidgets;
File without changes
File without changes
@@ -32,6 +32,9 @@ var react_1 = require("react");
32
32
  var ErrorBoundaryFrontend_1 = require("./ErrorBoundaryFrontend");
33
33
  exports.BlocksContext = (0, react_1.createContext)(undefined);
34
34
  function ContentBlocks(props) {
35
+ if (process.admin) {
36
+ throw new Error("ContentBlocks should only be used on the frontend.");
37
+ }
35
38
  if (!Array.isArray(props.blocks))
36
39
  return null;
37
40
  var parentContext = (0, react_1.useContext)(exports.BlocksContext);
@@ -45,7 +48,7 @@ function ContentBlocks(props) {
45
48
  var Component = blocks_1.default[block.blockName];
46
49
  if (!Component)
47
50
  return (0, jsx_runtime_1.jsx)(react_1.Fragment, {}, void 0);
48
- 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,
49
52
  // innerBlocks={block.innerBlocks}
50
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));
51
54
  }
@@ -6,9 +6,13 @@ 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;
11
+ insertBlocksAfter?: (block: any) => void;
10
12
  }>;
11
13
  export declare function InlineEditingContextProvider(props: ProviderProps): JSX.Element;
12
14
  export declare function useInlineEditableValue<T>(key: string, defaultValue?: T): [T, (value: T) => void];
15
+ export declare function useBlockAppender(): ((block: any) => void) | undefined;
13
16
  export declare function useInnerBlocks(): ContentBlock[];
17
+ export declare function useBlockParents(): [string, Attributes][];
14
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.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];
@@ -29,6 +40,7 @@ function InlineEditingContextProvider(props) {
29
40
  props.onChange(__assign(__assign({}, (props.values || {})), (_a = {}, _a[key] = value, _a)));
30
41
  }
31
42
  },
43
+ insertBlocksAfter: props.insertBlocksAfter,
32
44
  } }, { children: props.children }), void 0));
33
45
  }
34
46
  exports.InlineEditingContextProvider = InlineEditingContextProvider;
@@ -43,14 +55,18 @@ function useInlineEditableValue(key, defaultValue) {
43
55
  ];
44
56
  }
45
57
  exports.useInlineEditableValue = useInlineEditableValue;
58
+ function useBlockAppender() {
59
+ var ctx = (0, react_1.useContext)(InlineEditingContext);
60
+ return ctx === null || ctx === void 0 ? void 0 : ctx.insertBlocksAfter;
61
+ }
62
+ exports.useBlockAppender = useBlockAppender;
46
63
  function useInnerBlocks() {
47
64
  var ctx = (0, react_1.useContext)(InlineEditingContext);
48
65
  return (ctx === null || ctx === void 0 ? void 0 : ctx.innerBlocks) || [];
49
- // return [
50
- // attrs?.getValue(key),
51
- // (value: any) => {
52
- // attrs?.setValue(key, value)
53
- // },
54
- // ] as [T, (value: T) => void]
55
66
  }
56
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 */
@@ -11,14 +11,20 @@ declare type PropTypes<T extends ElementType> = {
11
11
  inlineToolbar?: boolean;
12
12
  /** Specify default content to use on the frontend if nothing has been entered */
13
13
  defaultValue?: string;
14
+ /** Append a new block when the user hits 'Enter' */
15
+ appendOnEnter?: boolean;
14
16
  } & React.ComponentPropsWithoutRef<T>;
15
- 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
+ };
16
22
  declare type InnerBlocksProps = {
17
23
  allowedBlocks?: string[];
18
24
  orientation?: "horizontal" | "vertical";
19
25
  templateLock?: any;
20
26
  template?: any;
21
- renderAppender?: any;
27
+ appender?: AppenderConfig;
22
28
  } & ContentBlocksSettings;
23
29
  export declare function InnerBlocks(props: InnerBlocksProps): JSX.Element;
24
30
  export {};
@@ -24,8 +24,9 @@ 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");
28
+ // @ts-ignore
29
+ var blocks_1 = require("@wordpress/blocks");
29
30
  var ContentBlocks_1 = require("./ContentBlocks");
30
31
  var react_1 = require("react");
31
32
  var blockAttributes_1 = require("./blockAttributes");
@@ -33,10 +34,17 @@ var react_2 = require("@stitches/react");
33
34
  var remoteProps_1 = require("../routing/remoteProps");
34
35
  var __1 = require("..");
35
36
  function EditableText(_a) {
36
- 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"]);
37
38
  if (process.admin) {
38
39
  var _b = (0, blockAttributes_1.useInlineEditableValue)(id), value = _b[0], setValue = _b[1];
39
- return ((0, jsx_runtime_1.jsx)(block_editor_1.RichText, __assign({}, props, { tagName: as, value: value || "", onChange: setValue, disableLineBreaks: props.disableLineBreaks }), void 0));
40
+ var appendBlocks_1 = (0, blockAttributes_1.useBlockAppender)();
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) {
42
+ if (e.key === "Enter" && appendOnEnter && appendBlocks_1) {
43
+ appendBlocks_1([(0, blocks_1.createBlock)("core/paragraph")]);
44
+ e.preventDefault();
45
+ e.stopPropagation();
46
+ }
47
+ } }), void 0));
40
48
  }
41
49
  else {
42
50
  var value = (0, blockAttributes_1.useInlineEditableValue)(id)[0];
@@ -66,11 +74,23 @@ function EditableText(_a) {
66
74
  }
67
75
  }
68
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
+ };
69
88
  function InnerBlocks(props) {
70
89
  if (process.admin) {
71
90
  var allowedBlocks = props.allowedBlocks;
72
- // console.log("ALLOWED BLOCKS", props.allowTaggedBlocks, allowedBlocks)
73
- 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));
74
94
  }
75
95
  else {
76
96
  var blocks = (0, blockAttributes_1.useInnerBlocks)();
@@ -87,6 +107,9 @@ var InnerBlocksAdminWrapper = (0, react_2.styled)("div", {
87
107
  // marginRight: "auto",
88
108
  maxWidth: "var(--grid-inner-width)",
89
109
  },
110
+ ".block-editor-block-list__block .block-list-appender:only-child": {
111
+ alignSelf: "auto !important",
112
+ },
90
113
  variants: {
91
114
  orientation: {
92
115
  vertical: {
@@ -27,6 +27,8 @@ 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
+ // @ts-ignore
31
+ var data_1 = require("@wordpress/data");
30
32
  var react_1 = require("react");
31
33
  // @ts-ignore
32
34
  var blockAttributes_1 = require("./blockAttributes");
@@ -45,6 +47,11 @@ function installEDGutenbergHooks() {
45
47
  if (!window.wp.blockEditor)
46
48
  return;
47
49
  (0, react_2.globalCss)({
50
+ ".edit-post-visual-editor__post-title-wrapper": {
51
+ width: "var(--grid-inner-width)",
52
+ marginLeft: "auto",
53
+ marginRight: "auto",
54
+ },
48
55
  ".block-editor-block-list__block:hover": {
49
56
  outline: "1px solid #e1e1e1",
50
57
  },
@@ -82,9 +89,17 @@ function installEDGutenbergHooks() {
82
89
  // @ts-ignore
83
90
  window.wp.data.dispatch("core/block-editor").setTemplateValidity(true);
84
91
  }, []);
85
- 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: props.innerBlocks, onChange: function (attrs) {
92
+ var children = (0, data_1.useSelect)(function (select) {
93
+ var _a = select("core/block-editor"), getBlock = _a.getBlock, getBlockOrder = _a.getBlockOrder;
94
+ var innerBlockIDs = getBlockOrder(props.clientId);
95
+ var children = innerBlockIDs.map(function (id) {
96
+ return getBlock(id);
97
+ });
98
+ return children;
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, block: [name, props], onChange: function (attrs) {
86
101
  props.setAttributes(__assign(__assign({}, props.attributes), { inline: attrs }));
87
- } }, { children: edit_1.call(self, props) }), void 0) }), void 0));
102
+ }, insertBlocksAfter: props.insertBlocksAfter }, { children: edit_1.call(self, props) }), void 0) }), void 0));
88
103
  };
89
104
  }
90
105
  // Remember the block type name
@@ -154,7 +169,13 @@ function installEDGutenbergHooks() {
154
169
  var parseJSX = acf.parseJSX;
155
170
  // @ts-ignore
156
171
  acf.parseJSX = function (html) {
157
- var payload = JSON.parse(html.replace(/(^[^>]+>|<[^>]+>$)/g, ""));
172
+ var payload;
173
+ try {
174
+ payload = JSON.parse(html.replace(/(^[^>]+>|<[^>]+>$)/g, ""));
175
+ }
176
+ catch (err) {
177
+ throw new Error("eddev: Error parsing block data from: \n" + html);
178
+ }
158
179
  return (0, jsx_runtime_1.jsx)(BlockRenderer, { payload: payload }, void 0);
159
180
  };
160
181
  }
@@ -79,6 +79,7 @@ var manifest_blocks_1 = require("./manifests/manifest-blocks");
79
79
  var manifest_fields_1 = require("./manifests/manifest-fields");
80
80
  var manifest_views_1 = require("./manifests/manifest-views");
81
81
  var get_config_1 = require("../config/get-config");
82
+ var manifest_widgets_1 = require("./manifests/manifest-widgets");
82
83
  function getWebpackConfig(opts) {
83
84
  return __awaiter(this, void 0, void 0, function () {
84
85
  var compiling, config, ALIAS, ENTRY, PLUGINS, RULES, DEFINES, VIRTUAL_MODULES, EXTERNALS, virtualModules, isServerless, isBrowser, isSSR, isDev, entryDir, distSuffix, outputFolder, loadableManifestFile, writeVirtualModule, manifestLoaders, rpcExists, buildID;
@@ -283,6 +284,23 @@ function getWebpackConfig(opts) {
283
284
  else {
284
285
  writeVirtualModule(ALIAS["@manifest/fields"], "\n export default {}\n ");
285
286
  }
287
+ // Field manifest
288
+ ALIAS["@manifest/widgets"] = path_1.default.resolve(opts.baseDirectory, "_widgets_manifest.js");
289
+ if (opts.isAdmin) {
290
+ manifestLoaders.push((0, manifest_widgets_1.createWidgetManifestGenerator)({
291
+ baseDirectory: opts.baseDirectory,
292
+ isAdmin: true,
293
+ isDev: isDev,
294
+ isServerless: isServerless,
295
+ watch: isDev,
296
+ onGenerate: function (manifest) {
297
+ writeVirtualModule(ALIAS["@manifest/widgets"], manifest);
298
+ },
299
+ }));
300
+ }
301
+ else {
302
+ writeVirtualModule(ALIAS["@manifest/widgets"], "\n export default {}\n ");
303
+ }
286
304
  // Block manifest
287
305
  ALIAS["@manifest/blocks"] = path_1.default.resolve(opts.baseDirectory, "_blocks_manifest.js");
288
306
  manifestLoaders.push((0, manifest_blocks_1.createBlockManifestGenerator)({
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.plugin = void 0;
4
4
  function plugin(schema, documents, config) {
5
- console.log(documents);
6
5
  process.exit();
7
6
  }
8
7
  exports.plugin = plugin;
@@ -0,0 +1,12 @@
1
+ declare type Options = {
2
+ baseDirectory: string;
3
+ isAdmin: boolean;
4
+ isDev: boolean;
5
+ isServerless: boolean;
6
+ onGenerate: (value: string) => void;
7
+ watch: boolean;
8
+ };
9
+ export declare function createWidgetManifestGenerator(opts: Options): Promise<{
10
+ close(): void;
11
+ }>;
12
+ export {};
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createWidgetManifestGenerator = void 0;
7
+ var manifest_1 = require("./manifest");
8
+ var path_1 = __importDefault(require("path"));
9
+ var change_case_1 = require("change-case");
10
+ function createWidgetManifestGenerator(opts) {
11
+ return (0, manifest_1.createManifestGenerator)({
12
+ glob: path_1.default.join(opts.baseDirectory, "/backend/widgets/*.tsx"),
13
+ onGenerate: opts.onGenerate,
14
+ watch: opts.watch,
15
+ generate: function (fileNames) {
16
+ if (opts.isAdmin) {
17
+ var files = fileNames
18
+ .filter(function (file) { return !file.includes("/_app"); })
19
+ .map(function (file) {
20
+ var relative = path_1.default.relative(opts.baseDirectory, file);
21
+ var name = path_1.default.basename(file).replace(/\.(jsx|tsx|ts|js)$/i, "");
22
+ var module = JSON.stringify("./" + relative);
23
+ var componentName = "Widget" + (0, change_case_1.pascalCase)(name);
24
+ return { relative: relative, name: name, module: module, componentName: componentName };
25
+ });
26
+ return "\n ".concat(files.map(function (_a) {
27
+ var componentName = _a.componentName, module = _a.module;
28
+ return "import ".concat(componentName, " from ").concat(module);
29
+ }).join("\n"), "\n\n export default [\n ").concat(files
30
+ .map(function (_a) {
31
+ var relative = _a.relative, componentName = _a.componentName, module = _a.module, name = _a.name;
32
+ return componentName;
33
+ })
34
+ .join(",\n"), "\n ]\n ");
35
+ }
36
+ else {
37
+ return "export default {}";
38
+ }
39
+ },
40
+ });
41
+ }
42
+ exports.createWidgetManifestGenerator = createWidgetManifestGenerator;
@@ -185,10 +185,6 @@ function createNextApp(opts) {
185
185
  // Write APIs proxy code
186
186
  _b.sent();
187
187
  // Remove pages/api/trpc directory if no _rpc is found
188
- console.log({
189
- index: (0, path_1.join)(opts.baseDirectory, "apis/_rpc/index.ts"),
190
- rpc: (0, path_1.join)(opts.baseDirectory, "apis/_rpc.ts"),
191
- });
192
188
  if (!(0, fs_1.existsSync)((0, path_1.join)(opts.baseDirectory, "apis/_rpc/index.ts")) &&
193
189
  !(0, fs_1.existsSync)((0, path_1.join)(opts.baseDirectory, "apis/_rpc.ts"))) {
194
190
  // removeSync(join(serverlessDirectory, "pages/api/trpc"))
@@ -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*/];
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { CompilerState } from "../../../build/state/compiler-state";
3
2
  import { Observable } from "../../../utils/Observable";
4
3
  export declare function BundleDisplay(props: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { CodegenState } from "../../../build/state/codegen-state";
3
2
  import { Observable } from "../../../utils/Observable";
4
3
  export declare function CodegenDisplay(props: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { CodegenState } from "../../../build/state/codegen-state";
3
2
  import { CompilerState } from "../../../build/state/compiler-state";
4
3
  import { ServerlessState } from "../../../build/state/serverless-state";
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ServerlessState } from "../../../build/state/serverless-state";
3
2
  import { Observable } from "../../../utils/Observable";
4
3
  export declare function ServerlessDisplay(props: {
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare type Props = {
3
2
  icon: "loading" | "tick" | "error" | "none";
4
3
  };
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;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare function AdminBar(): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare type Props = {
3
2
  lerpStart?: boolean;
4
3
  lerps?: boolean;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare function BreakpointIndicator(): JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export default function DevUI(): JSX.Element;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ResponsiveAtomCalc } from "../../style";
3
2
  declare type Props = {
4
3
  data: ResponsiveAtomCalc[];
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { BreakpointArray } from "../../style";
3
2
  export declare const RESPONSIVE_COLUMN_WIDTH = "110px";
4
3
  export declare const RESPONSIVE_ROW_HEIGHT = "20px";
@@ -69,7 +69,6 @@ function ResponsiveScaleEditor(props) {
69
69
  var nextValue;
70
70
  if (item.type === "px" && nextType === "multiplier") {
71
71
  if (base) {
72
- console.log(item.value, base.concreteValue);
73
72
  nextValue = "x" + item.value / (base === null || base === void 0 ? void 0 : base.concreteValue);
74
73
  }
75
74
  }
@@ -112,8 +111,9 @@ function ResponsiveScaleEditor(props) {
112
111
  }
113
112
  else {
114
113
  props.onChange((0, immer_1.default)(values, function (values) {
114
+ var _a;
115
115
  for (var token in values) {
116
- var original = _theme_1.originalConfig.responsive.space[token]["@" + breakpoint];
116
+ var original = (_a = _theme_1.originalConfig.responsive.space[token]) === null || _a === void 0 ? void 0 : _a["@" + breakpoint];
117
117
  var value = original;
118
118
  if (!value) {
119
119
  value = values[token]["@" + item.baseBreakpoint];
@@ -125,7 +125,7 @@ function ResponsiveScaleEditor(props) {
125
125
  }));
126
126
  }
127
127
  };
128
- return ((0, jsx_runtime_1.jsxs)(Wrapper, __assign({ css: { $$total: props.data.length, $$labelWidth: props.labelWidth } }, { children: [props.showBreakpointName && ((0, jsx_runtime_1.jsx)(Row, __assign({ heading: true }, { children: rows[0].row.map(function (item, i) {
128
+ return ((0, jsx_runtime_1.jsxs)(Wrapper, __assign({ css: { $$total: props.breakpoints.length, $$labelWidth: props.labelWidth } }, { children: [props.showBreakpointName && ((0, jsx_runtime_1.jsx)(Row, __assign({ heading: true }, { children: rows[0].row.map(function (item, i) {
129
129
  var bp = props.breakpoints[i];
130
130
  return ((0, jsx_runtime_1.jsx)(Col, __assign({ css: { textAlign: "center" } }, { children: (0, jsx_runtime_1.jsx)(Tooltip_1.Tooltip, __assign({ label: "".concat(bp.min, " to ").concat(bp.max || "∞"), mono: true, nowrap: true }, { children: (0, jsx_runtime_1.jsx)(ToggleButton_1.ToggleButton, { checked: item.defined, onChange: function (checked) {
131
131
  onToggleBreakpoint === null || onToggleBreakpoint === void 0 ? void 0 : onToggleBreakpoint(item, checked);
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  declare type Props = {
3
2
  prefix?: string;
4
3
  suffix?: string;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare function PageDataDebugger(): JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare function SpacingEditor(): JSX.Element;
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export declare function TypographyEditor(): JSX.Element;