rimelight-components 2.0.74 → 2.0.76
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
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.76";
|
|
8
8
|
const homepage = "https://rimelight.com/tools/rimelight-components";
|
|
9
9
|
|
|
10
10
|
const defaultOptions = {
|
|
@@ -56,7 +56,7 @@ function addBlockMapTemplates(blockNames) {
|
|
|
56
56
|
let content = "export const BLOCK_RENDERER_COMPONENT_MAP = {\n";
|
|
57
57
|
blockNames.forEach((name) => {
|
|
58
58
|
const fullComponentName = `${name}Renderer`;
|
|
59
|
-
const componentPath = `rimelight-components/
|
|
59
|
+
const componentPath = `rimelight-components/components/blocks/renderer/${fullComponentName}.vue`;
|
|
60
60
|
content += ` '${name}': () => import('${componentPath}'),
|
|
61
61
|
`;
|
|
62
62
|
});
|
|
@@ -68,22 +68,32 @@ function addBlockMapTemplates(blockNames) {
|
|
|
68
68
|
addTemplate({
|
|
69
69
|
filename: "rimelight-block-renderer-map.d.ts",
|
|
70
70
|
getContents: () => {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
const componentImporterType = '() => Promise<{ default: import("vue").Component }>';
|
|
72
|
+
let content = `// Generated by rimelight-components Nuxt Module
|
|
73
|
+
`;
|
|
74
|
+
content += `import { Component } from 'vue'
|
|
75
|
+
`;
|
|
76
|
+
content += `export declare const BLOCK_RENDERER_COMPONENT_MAP: { [key: string]: ${componentImporterType} | undefined }
|
|
77
|
+
`;
|
|
78
|
+
blockNames.forEach((name) => {
|
|
79
|
+
content += `export declare const ${name}: ${componentImporterType}
|
|
80
|
+
`;
|
|
81
|
+
});
|
|
82
|
+
return content;
|
|
74
83
|
},
|
|
75
84
|
write: true
|
|
76
85
|
});
|
|
77
86
|
return template;
|
|
78
87
|
}
|
|
79
88
|
function addEditorBlockMapTemplates(blockNames) {
|
|
89
|
+
const componentImporterType = '() => Promise<{ default: import("vue").Component }>';
|
|
80
90
|
const template = addTemplate({
|
|
81
91
|
filename: "rimelight-block-editor-map.mjs",
|
|
82
92
|
getContents: () => {
|
|
83
93
|
let content = "export const BLOCK_EDITOR_COMPONENT_MAP = {\n";
|
|
84
94
|
blockNames.forEach((name) => {
|
|
85
95
|
const fullComponentName = `${name}Editor`;
|
|
86
|
-
const componentPath = `rimelight-components/
|
|
96
|
+
const componentPath = `rimelight-components/components/blocks/editor/${fullComponentName}.vue`;
|
|
87
97
|
content += ` '${name}': () => import('${componentPath}'),
|
|
88
98
|
`;
|
|
89
99
|
});
|
|
@@ -95,9 +105,17 @@ function addEditorBlockMapTemplates(blockNames) {
|
|
|
95
105
|
addTemplate({
|
|
96
106
|
filename: "rimelight-block-editor-map.d.ts",
|
|
97
107
|
getContents: () => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
108
|
+
let content = `// Generated by rimelight-components Nuxt Module
|
|
109
|
+
`;
|
|
110
|
+
content += `import { Component } from 'vue'
|
|
111
|
+
`;
|
|
112
|
+
content += `export declare const BLOCK_EDITOR_COMPONENT_MAP: { [key: string]: ${componentImporterType} | undefined }
|
|
113
|
+
`;
|
|
114
|
+
blockNames.forEach((name) => {
|
|
115
|
+
content += `export declare const ${name}: ${componentImporterType}
|
|
116
|
+
`;
|
|
117
|
+
});
|
|
118
|
+
return content;
|
|
101
119
|
},
|
|
102
120
|
write: true
|
|
103
121
|
});
|
|
@@ -175,40 +193,42 @@ const module$1 = defineNuxtModule().with({
|
|
|
175
193
|
},
|
|
176
194
|
setup(options, nuxt) {
|
|
177
195
|
const { resolve } = createResolver(import.meta.url);
|
|
178
|
-
const runtimePath = resolve("./runtime");
|
|
179
196
|
nuxt.options.appConfig.rimelightComponents = defu(
|
|
180
197
|
nuxt.options.appConfig.rimelightComponents || {},
|
|
181
198
|
options
|
|
182
199
|
);
|
|
183
|
-
nuxt.options.
|
|
184
|
-
nuxt.options.build.transpile.push("rimelight-components");
|
|
185
|
-
nuxt.options.alias["#rimelight-components"] = runtimePath;
|
|
200
|
+
nuxt.options.alias["#rimelight-components"] = resolve("./runtime");
|
|
186
201
|
addComponentsDir({
|
|
187
202
|
path: resolve("./runtime/components/"),
|
|
188
203
|
pathPrefix: false,
|
|
204
|
+
//TODO Figure out if this can be typed better
|
|
189
205
|
prefix: options.prefix ?? void 0,
|
|
190
206
|
global: true
|
|
191
207
|
});
|
|
192
208
|
addImportsDir(resolve("./runtime/composables"));
|
|
193
209
|
addImportsDir(resolve("./runtime/utils"));
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
nuxt.options.build
|
|
210
|
+
const blockRendererFiles = readdirSync(
|
|
211
|
+
resolve("./runtime/components/blocks/renderer")
|
|
212
|
+
).filter((name2) => name2.endsWith(".vue"));
|
|
213
|
+
const blockRendererNames = blockRendererFiles.map((file) => {
|
|
214
|
+
const baseName = basename(file, ".vue");
|
|
215
|
+
return baseName.replace(/Renderer$/, "");
|
|
216
|
+
});
|
|
217
|
+
const blockRendererTemplate = addBlockMapTemplates(blockRendererNames);
|
|
218
|
+
nuxt.options.alias["#build/rimelight-block-renderer-map"] = blockRendererTemplate.dst;
|
|
219
|
+
const blockEditorFiles = readdirSync(
|
|
220
|
+
resolve("./runtime/components/blocks/editor")
|
|
221
|
+
).filter((name2) => name2.endsWith(".vue"));
|
|
222
|
+
const blockEditorNames = blockEditorFiles.map((file) => {
|
|
223
|
+
const baseName = basename(file, ".vue");
|
|
224
|
+
return baseName.replace(/Editor$/, "");
|
|
225
|
+
});
|
|
226
|
+
const blockEditorTemplate = addEditorBlockMapTemplates(blockEditorNames);
|
|
227
|
+
nuxt.options.alias["#build/rimelight-block-editor-map"] = blockEditorTemplate.dst;
|
|
203
228
|
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
204
|
-
nitroConfig.externals = nitroConfig.externals || {};
|
|
205
|
-
nitroConfig.externals.external = nitroConfig.externals.external || [];
|
|
206
|
-
nitroConfig.externals.external.push(resolve("./runtime"));
|
|
207
|
-
nitroConfig.externals.external.push("rimelight-components");
|
|
208
229
|
nitroConfig.alias = nitroConfig.alias || {};
|
|
209
|
-
nitroConfig.alias[
|
|
210
|
-
nitroConfig.
|
|
211
|
-
nitroConfig.virtual[editorAlias] = blockEditorTemplate.dst;
|
|
230
|
+
nitroConfig.alias["#build/rimelight-block-renderer-map"] = blockRendererTemplate.dst;
|
|
231
|
+
nitroConfig.alias["#build/rimelight-block-editor-map"] = blockEditorTemplate.dst;
|
|
212
232
|
});
|
|
213
233
|
}
|
|
214
234
|
});
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import { type Component } from "vue";
|
|
2
2
|
import { type BlockType } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Maps the block type string from the database to a dynamically imported Vue component.
|
|
5
|
+
*
|
|
6
|
+
* @param type The BlockType string from the content JSON (e.g., 'ParagraphBlock').
|
|
7
|
+
* @returns A lazily loaded Vue component reference, or undefined if not found.
|
|
8
|
+
*/
|
|
3
9
|
export declare const getBlockRendererComponent: (type: BlockType | string) => Component | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Maps the block type string from the database to a dynamically imported Vue component
|
|
12
|
+
* specifically for the editor view.
|
|
13
|
+
*
|
|
14
|
+
* @param type The BlockType string from the content JSON.
|
|
15
|
+
* @returns A lazily loaded Vue component reference, or undefined if not found.
|
|
16
|
+
*/
|
|
4
17
|
export declare const getBlockEditorComponent: (type: BlockType | string) => Component | undefined;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { defineAsyncComponent } from "vue";
|
|
2
|
-
import { BLOCK_RENDERER_COMPONENT_MAP } from "#rimelight-block-renderer-map";
|
|
3
|
-
import { BLOCK_EDITOR_COMPONENT_MAP } from "#rimelight-block-editor-map";
|
|
2
|
+
import { BLOCK_RENDERER_COMPONENT_MAP } from "#build/rimelight-block-renderer-map";
|
|
3
|
+
import { BLOCK_EDITOR_COMPONENT_MAP } from "#build/rimelight-block-editor-map";
|
|
4
4
|
export const getBlockRendererComponent = (type) => {
|
|
5
5
|
const componentImporter = BLOCK_RENDERER_COMPONENT_MAP[type];
|
|
6
6
|
if (!componentImporter) {
|
|
7
7
|
console.warn(
|
|
8
|
-
`[BlockMapper] Block component not found for type: ${type}.`
|
|
8
|
+
`[BlockMapper] Block component not found for type: ${type}. Please check block name.`
|
|
9
9
|
);
|
|
10
10
|
return void 0;
|
|
11
11
|
}
|
|
@@ -15,11 +15,10 @@ export const getBlockRendererComponent = (type) => {
|
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
17
|
export const getBlockEditorComponent = (type) => {
|
|
18
|
-
if (import.meta.server) return void 0;
|
|
19
18
|
const componentImporter = BLOCK_EDITOR_COMPONENT_MAP[type];
|
|
20
19
|
if (!componentImporter) {
|
|
21
20
|
console.warn(
|
|
22
|
-
`[EditorBlockMapper] Editor block component not found for type: ${type}.`
|
|
21
|
+
`[EditorBlockMapper] Editor block component not found for type: ${type}. Please check block name.`
|
|
23
22
|
);
|
|
24
23
|
return void 0;
|
|
25
24
|
}
|