rimelight-components 2.0.78 → 2.0.80
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/dist/module.json +1 -1
- package/dist/module.mjs +21 -51
- package/dist/runtime/utils/blockMapper.js +7 -16
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { readdirSync } from 'node:fs';
|
|
|
4
4
|
import { basename } from 'node:path';
|
|
5
5
|
|
|
6
6
|
const name = "rimelight-components";
|
|
7
|
-
const version = "2.0.
|
|
7
|
+
const version = "2.0.80";
|
|
8
8
|
const homepage = "https://rimelight.com/tools/rimelight-components";
|
|
9
9
|
|
|
10
10
|
const defaultOptions = {
|
|
@@ -49,13 +49,14 @@ const defaultOptions = {
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
function addBlockMapTemplates(blockNames) {
|
|
53
|
-
|
|
52
|
+
function addBlockMapTemplates(blockNames, resolve) {
|
|
53
|
+
return addTemplate({
|
|
54
54
|
filename: "rimelight-block-renderer-map.mjs",
|
|
55
55
|
getContents: () => {
|
|
56
56
|
let content = "export const BLOCK_RENDERER_COMPONENT_MAP = {\n";
|
|
57
57
|
blockNames.forEach((name) => {
|
|
58
|
-
|
|
58
|
+
const path = resolve(`./runtime/components/blocks/renderer/${name}Renderer.vue`);
|
|
59
|
+
content += ` '${name}': () => import('${path}'),
|
|
59
60
|
`;
|
|
60
61
|
});
|
|
61
62
|
content += "}\n";
|
|
@@ -63,26 +64,15 @@ function addBlockMapTemplates(blockNames) {
|
|
|
63
64
|
},
|
|
64
65
|
write: true
|
|
65
66
|
});
|
|
66
|
-
addTemplate({
|
|
67
|
-
filename: "rimelight-block-renderer-map.d.ts",
|
|
68
|
-
getContents: () => {
|
|
69
|
-
let content = `// Generated by rimelight-components
|
|
70
|
-
`;
|
|
71
|
-
content += `export declare const BLOCK_RENDERER_COMPONENT_MAP: Record<string, string>
|
|
72
|
-
`;
|
|
73
|
-
return content;
|
|
74
|
-
},
|
|
75
|
-
write: true
|
|
76
|
-
});
|
|
77
|
-
return template;
|
|
78
67
|
}
|
|
79
|
-
function addEditorBlockMapTemplates(blockNames) {
|
|
80
|
-
|
|
68
|
+
function addEditorBlockMapTemplates(blockNames, resolve) {
|
|
69
|
+
return addTemplate({
|
|
81
70
|
filename: "rimelight-block-editor-map.mjs",
|
|
82
71
|
getContents: () => {
|
|
83
72
|
let content = "export const BLOCK_EDITOR_COMPONENT_MAP = {\n";
|
|
84
73
|
blockNames.forEach((name) => {
|
|
85
|
-
|
|
74
|
+
const path = resolve(`./runtime/components/blocks/editor/${name}Editor.vue`);
|
|
75
|
+
content += ` '${name}': () => import('${path}'),
|
|
86
76
|
`;
|
|
87
77
|
});
|
|
88
78
|
content += "}\n";
|
|
@@ -90,18 +80,6 @@ function addEditorBlockMapTemplates(blockNames) {
|
|
|
90
80
|
},
|
|
91
81
|
write: true
|
|
92
82
|
});
|
|
93
|
-
addTemplate({
|
|
94
|
-
filename: "rimelight-block-editor-map.d.ts",
|
|
95
|
-
getContents: () => {
|
|
96
|
-
let content = `// Generated by rimelight-components
|
|
97
|
-
`;
|
|
98
|
-
content += `export declare const BLOCK_EDITOR_COMPONENT_MAP: Record<string, string>
|
|
99
|
-
`;
|
|
100
|
-
return content;
|
|
101
|
-
},
|
|
102
|
-
write: true
|
|
103
|
-
});
|
|
104
|
-
return template;
|
|
105
83
|
}
|
|
106
84
|
|
|
107
85
|
const module$1 = defineNuxtModule().with({
|
|
@@ -189,28 +167,20 @@ const module$1 = defineNuxtModule().with({
|
|
|
189
167
|
});
|
|
190
168
|
addImportsDir(resolve("./runtime/composables"));
|
|
191
169
|
addImportsDir(resolve("./runtime/utils"));
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
resolve("./runtime/components/blocks/editor")
|
|
203
|
-
).filter((name2) => name2.endsWith(".vue"));
|
|
204
|
-
const blockEditorNames = blockEditorFiles.map((file) => {
|
|
205
|
-
const baseName = basename(file, ".vue");
|
|
206
|
-
return baseName.replace(/Editor$/, "");
|
|
207
|
-
});
|
|
208
|
-
const blockEditorTemplate = addEditorBlockMapTemplates(blockEditorNames);
|
|
209
|
-
nuxt.options.alias["#rimelight-internal/rimelight-block-editor-map"] = blockEditorTemplate.dst;
|
|
170
|
+
const rendererPath = resolve("./runtime/components/blocks/renderer");
|
|
171
|
+
const blockRendererFiles = readdirSync(rendererPath).filter((f) => f.endsWith(".vue"));
|
|
172
|
+
const blockRendererNames = blockRendererFiles.map((f) => basename(f, ".vue").replace(/Renderer$/, ""));
|
|
173
|
+
const blockRendererTemplate = addBlockMapTemplates(blockRendererNames, resolve);
|
|
174
|
+
nuxt.options.alias["#rimelight-internal/block-renderer-map"] = blockRendererTemplate.dst;
|
|
175
|
+
const editorPath = resolve("./runtime/components/blocks/editor");
|
|
176
|
+
const blockEditorFiles = readdirSync(editorPath).filter((f) => f.endsWith(".vue"));
|
|
177
|
+
const blockEditorNames = blockEditorFiles.map((f) => basename(f, ".vue").replace(/Editor$/, ""));
|
|
178
|
+
const blockEditorTemplate = addEditorBlockMapTemplates(blockEditorNames, resolve);
|
|
179
|
+
nuxt.options.alias["#rimelight-internal/block-editor-map"] = blockEditorTemplate.dst;
|
|
210
180
|
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
211
181
|
nitroConfig.alias = nitroConfig.alias || {};
|
|
212
|
-
nitroConfig.alias["#rimelight-internal/
|
|
213
|
-
nitroConfig.alias["#rimelight-internal/
|
|
182
|
+
nitroConfig.alias["#rimelight-internal/block-renderer-map"] = blockRendererTemplate.dst;
|
|
183
|
+
nitroConfig.alias["#rimelight-internal/block-editor-map"] = blockEditorTemplate.dst;
|
|
214
184
|
});
|
|
215
185
|
}
|
|
216
186
|
});
|
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
import { defineAsyncComponent
|
|
1
|
+
import { defineAsyncComponent } from "vue";
|
|
2
2
|
import { BLOCK_RENDERER_COMPONENT_MAP } from "#rimelight-internal/block-renderer-map";
|
|
3
3
|
import { BLOCK_EDITOR_COMPONENT_MAP } from "#rimelight-internal/block-editor-map";
|
|
4
|
-
const createLazyComponent = (componentName) => {
|
|
5
|
-
return defineAsyncComponent(async () => {
|
|
6
|
-
const component = resolveComponent(componentName);
|
|
7
|
-
if (typeof component === "string") {
|
|
8
|
-
throw new Error(`[BlockMapper] Could not resolve component: ${componentName}`);
|
|
9
|
-
}
|
|
10
|
-
return component;
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
4
|
export const getBlockRendererComponent = (type) => {
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
5
|
+
const loader = BLOCK_RENDERER_COMPONENT_MAP[type];
|
|
6
|
+
if (!loader) {
|
|
16
7
|
console.warn(`[BlockMapper] No renderer found for type: ${type}`);
|
|
17
8
|
return void 0;
|
|
18
9
|
}
|
|
19
|
-
return
|
|
10
|
+
return defineAsyncComponent(loader);
|
|
20
11
|
};
|
|
21
12
|
export const getBlockEditorComponent = (type) => {
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
13
|
+
const loader = BLOCK_EDITOR_COMPONENT_MAP[type];
|
|
14
|
+
if (!loader) {
|
|
24
15
|
console.warn(`[EditorBlockMapper] No editor found for type: ${type}`);
|
|
25
16
|
return void 0;
|
|
26
17
|
}
|
|
27
|
-
return
|
|
18
|
+
return defineAsyncComponent(loader);
|
|
28
19
|
};
|