eddev 2.0.0-beta.111 → 2.0.0-beta.112

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.
@@ -2,8 +2,9 @@ import { installFieldTypes } from "../lib/admin/installFieldTypes.js";
2
2
  import { runWidgets } from "../lib/admin/runWidgets.js";
3
3
  import { installEDGutenbergHooks } from "../lib/blocks/editor/installGutenbergHooks.js";
4
4
  export default function bootAdmin() {
5
- // console.log("Booting admin")
5
+ console.log("Booting admin");
6
6
  if (window.name === "editor-canvas") {
7
+ console.log("Running in the editor canvas");
7
8
  }
8
9
  else {
9
10
  installEDGutenbergHooks();
@@ -46,9 +46,24 @@ export declare const editorConfigStore: {
46
46
  export declare function configureEditorBlocks(config: EditorConfigItem): void;
47
47
  export declare function transformTemplateToBlocks(template: BlockTemplate, locked?: boolean, isFromTemplate?: boolean): any;
48
48
  type PostInfo = {
49
- template: TemplateName | "default";
50
49
  type: PostTypeName;
50
+ isPattern: false;
51
+ isTemplatePart: false;
52
+ template: TemplateName | "default";
53
+ slug: string;
54
+ } | {
55
+ type: "wp_block";
56
+ isPattern: true;
57
+ isTemplatePart: false;
58
+ title: string;
59
+ } | {
60
+ type: "wp_template_part";
61
+ isPattern: false;
62
+ isTemplatePart: true;
63
+ area: string;
64
+ title: string;
51
65
  slug: string;
66
+ wp_pattern_category?: number[];
52
67
  };
53
68
  type MatcherFunction = (post: PostInfo) => boolean | void;
54
69
  type Matcher = {
@@ -107,10 +107,18 @@ export function getEditingPostInfo() {
107
107
  const postInfo = {
108
108
  ...post,
109
109
  ...edits,
110
+ isTemplatePart: false,
111
+ isPattern: false,
110
112
  };
111
113
  if (!postInfo.template)
112
114
  postInfo.template = "default";
113
115
  postInfo.template = postInfo.template.replace(/(^views\/|\.tsx?$)/g, "");
116
+ if (postInfo.type === "wp_template_part") {
117
+ postInfo.isTemplatePart = true;
118
+ }
119
+ if (postInfo.type === "wp_block") {
120
+ postInfo.isPattern = true;
121
+ }
114
122
  return postInfo;
115
123
  }
116
124
  export function updateTemplateConfig() {
@@ -111,9 +111,13 @@ export function installEDGutenbergHooks() {
111
111
  return {
112
112
  ...item,
113
113
  get parent() {
114
+ if (name === "core/block")
115
+ return undefined;
114
116
  return blocksByTag.expand([...(item.parent ?? []), ...(isRootBlock ? ["core/post-content"] : [])]);
115
117
  },
116
118
  get ancestor() {
119
+ if (name === "core/block")
120
+ return undefined;
117
121
  return item.ancestor ? blocksByTag.expand(item.ancestor) : undefined;
118
122
  },
119
123
  get allowedBlocks() {
@@ -84,11 +84,11 @@ export async function proxyWpAdmin(event) {
84
84
  },
85
85
  children: "",
86
86
  });
87
- const encodeForJSON = (str) => JSON.stringify(str).slice(1, -1).replace(/\"/g, "'");
88
- body = body.replace(/<!---VITE_HEADER--->/g, getViteHeader);
89
- body = body.replace(/<!---VITE_FOOTER--->/g, getViteFooter);
90
- body = body.replace(/<!---VITE_HEADER_ENCODED--->/g, encodeForJSON(getViteHeader()));
91
- body = body.replace(/<!---VITE_FOOTER_ENCODED--->/g, encodeForJSON(getViteFooter()));
87
+ const encodeForJSON = (str) => JSON.stringify(str).slice(1, -1).replaceAll("/", "\\/");
88
+ body = body.replaceAll("<!---VITE_HEADER--->", getViteHeader());
89
+ body = body.replaceAll("<!---VITE_FOOTER--->", getViteFooter());
90
+ body = body.replaceAll("<script id='vite-iframe-header'><\\/script>", encodeForJSON(getViteHeader()));
91
+ body = body.replaceAll("<script id='vite-iframe-footer'><\\/script>", encodeForJSON(getViteFooter()));
92
92
  }
93
93
  }
94
94
  else {
@@ -1 +1 @@
1
- export declare const VERSION = "2.0.0-beta.111";
1
+ export declare const VERSION = "2.0.0-beta.112";
@@ -1 +1 @@
1
- export const VERSION = "2.0.0-beta.111";
1
+ export const VERSION = "2.0.0-beta.112";
@@ -182,9 +182,15 @@ export function getViteConfig(args) {
182
182
  minify: args.mode === "production",
183
183
  modulePreload: false,
184
184
  outDir: args.outDir,
185
- // watch: {},
185
+ lib: {
186
+ entry: [
187
+ `./.eddev/${args.mode === "production" ? "prod" : "dev"}-spa/entry.${args.target === "cms" ? "admin" : "client"}.tsx`,
188
+ ],
189
+ fileName: (format, entryName) => `${entryName}.${format}.js`,
190
+ name: "eddev",
191
+ formats: args.target === "cms" ? ["iife"] : ["es"],
192
+ },
186
193
  rollupOptions: {
187
- input: `./.eddev/${args.mode === "production" ? "prod" : "dev"}-spa/entry.${args.target === "cms" ? "admin" : "client"}.tsx`,
188
194
  external: args.target === "cms" ? ["react", "react-dom"] : [],
189
195
  onwarn(warning, warn) {
190
196
  if (!cliMode.verbose &&
@@ -199,8 +205,8 @@ export function getViteConfig(args) {
199
205
  },
200
206
  output: args.target === "cms"
201
207
  ? {
202
- entryFileNames: "main.admin.js",
203
- format: "iife",
208
+ // entryFileNames: "main.admin.js",
209
+ // format: "iife",
204
210
  globals: {
205
211
  react: "window.React",
206
212
  "react-dom": "window.ReactDOM",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eddev",
3
- "version": "2.0.0-beta.111",
3
+ "version": "2.0.0-beta.112",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",