vue-wswg-editor 0.0.6 → 0.0.8

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.
@@ -1 +1 @@
1
- export declare const blockModules: Record<string, string> | Record<string, () => Promise<any>> | Record<string, any>;
1
+ export declare const blockModules: Record<string, any> | Record<string, string> | Record<string, () => Promise<any>>;
@@ -3,8 +3,7 @@ import type { EditorFieldConfig } from "./fieldConfig";
3
3
  import type { Block } from "../types/Block";
4
4
  import type { Layout } from "../types/Layout";
5
5
  /**
6
- * Registry of all page builder blocks
7
- * Automatically populated from the /page-builder/blocks directory of your app
6
+ * Registry of all page builder blocks, layouts & fields
8
7
  */
9
8
  export declare const pageBuilderBlocks: Ref<Record<string, Block>>;
10
9
  export declare const pageBuilderLayouts: Ref<Record<string, Layout>>;
@@ -18,4 +17,4 @@ export declare function getLayouts(): Record<string, Layout>;
18
17
  export declare function getBlockThumbnailUrl(directory: string | undefined): string | undefined;
19
18
  export declare function getBlockComponent(blockType: string): Block | undefined;
20
19
  export declare function getLayoutFields(layoutName: string): Record<string, EditorFieldConfig>;
21
- export declare function initialiseRegistry(): void;
20
+ export declare function initialiseRegistry(): Promise<void>;
@@ -0,0 +1,9 @@
1
+ import type { Plugin } from "vite";
2
+ export interface VueWswgEditorPluginOptions {
3
+ /**
4
+ * Root directory in the host project.
5
+ * Example: "@/features/homepage"
6
+ */
7
+ rootDir: string;
8
+ }
9
+ export declare function vueWswgEditorPlugin(options: VueWswgEditorPluginOptions): Plugin;
@@ -0,0 +1,43 @@
1
+ function s(r) {
2
+ const e = {
3
+ blocks: "\0vue-wswg-editor:blocks",
4
+ fields: "\0vue-wswg-editor:fields",
5
+ layouts: "\0vue-wswg-editor:layouts",
6
+ thumbnails: "\0vue-wswg-editor:thumbnails"
7
+ };
8
+ return {
9
+ name: "vue-wswg-editor-glob-plugin",
10
+ enforce: "pre",
11
+ // Run before other plugins to ensure import.meta.glob is processed correctly
12
+ resolveId(t) {
13
+ if (t.startsWith("vue-wswg-editor:")) {
14
+ const u = t.replace("vue-wswg-editor:", "");
15
+ if (u in e)
16
+ return e[u];
17
+ }
18
+ if (Object.values(e).includes(t))
19
+ return t;
20
+ },
21
+ load(t) {
22
+ switch (t) {
23
+ case e.layouts:
24
+ return `export const modules = import.meta.glob("${r.rootDir}/layout/**/*.vue", { eager: true });`;
25
+ case e.blocks:
26
+ return `export const modules = import.meta.glob("${r.rootDir}/blocks/**/*.vue", { eager: true });`;
27
+ case e.fields:
28
+ return `export const modules = import.meta.glob("${r.rootDir}/blocks/**/fields.ts", { eager: true });`;
29
+ case e.thumbnails:
30
+ return `export const modules = import.meta.glob("${r.rootDir}/blocks/**/thumbnail.png", { eager: true });`;
31
+ default:
32
+ return;
33
+ }
34
+ },
35
+ transform(t, o) {
36
+ if (Object.values(e).includes(o))
37
+ return null;
38
+ }
39
+ };
40
+ }
41
+ export {
42
+ s as vueWswgEditorPlugin
43
+ };