rimelight-components 2.0.73 → 2.0.75

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rimelight-components",
3
- "version": "2.0.73",
3
+ "version": "2.0.75",
4
4
  "docs": "https://rimelight.com/tools/rimelight-components",
5
5
  "configKey": "rimelightComponents",
6
6
  "compatibility": {
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.73";
7
+ const version = "2.0.75";
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/runtime/components/blocks/renderer/${fullComponentName}.vue`;
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 importerType = '() => Promise<{ default: import("vue").Component }>';
72
- return `import { Component } from 'vue'
73
- export declare const BLOCK_RENDERER_COMPONENT_MAP: Record<string, ${importerType}>`;
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/runtime/components/blocks/editor/${fullComponentName}.vue`;
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
- const importerType = '() => Promise<{ default: import("vue").Component }>';
99
- return `import { Component } from 'vue'
100
- export declare const BLOCK_EDITOR_COMPONENT_MAP: Record<string, ${importerType}>`;
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,45 +193,38 @@ 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.build.transpile.push(runtimePath);
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 getBlockNames = (dir, suffix) => readdirSync(resolve(dir)).filter((f) => f.endsWith(".vue")).map((f) => basename(f, ".vue").replace(new RegExp(`${suffix}$`), ""));
195
- const rendererNames = getBlockNames("./runtime/components/blocks/renderer", "Renderer");
196
- const editorNames = getBlockNames("./runtime/components/blocks/editor", "Editor");
197
- const blockRendererTemplate = addBlockMapTemplates(rendererNames);
198
- const blockEditorTemplate = addEditorBlockMapTemplates(editorNames);
199
- const rendererAlias = "#rimelight-block-renderer-map";
200
- const editorAlias = "#rimelight-block-editor-map";
201
- nuxt.options.alias[rendererAlias] = blockRendererTemplate.dst;
202
- nuxt.options.alias[editorAlias] = blockEditorTemplate.dst;
203
- nuxt.hook("nitro:config", (nitroConfig) => {
204
- nitroConfig.alias = nitroConfig.alias || {};
205
- nitroConfig.alias[rendererAlias] = blockRendererTemplate.dst;
206
- nitroConfig.virtual = nitroConfig.virtual || {};
207
- nitroConfig.virtual[editorAlias] = "export const BLOCK_EDITOR_COMPONENT_MAP = {}";
208
- nitroConfig.externals = nitroConfig.externals || {};
209
- nitroConfig.externals.inline = nitroConfig.externals.inline || [];
210
- nitroConfig.externals.inline.push(runtimePath);
211
- nitroConfig.externals.inline.push("rimelight-components");
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$/, "");
212
216
  });
213
- nuxt.hook("prepare:types", ({ references }) => {
214
- references.push({ path: blockRendererTemplate.dst });
215
- references.push({ path: blockEditorTemplate.dst });
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$/, "");
216
225
  });
226
+ const blockEditorTemplate = addEditorBlockMapTemplates(blockEditorNames);
227
+ nuxt.options.alias["#build/rimelight-block-editor-map"] = blockEditorTemplate.dst;
217
228
  }
218
229
  });
219
230
 
@@ -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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rimelight-components",
3
3
  "description": "A component library by Rimelight Entertainment.",
4
- "version": "2.0.73",
4
+ "version": "2.0.75",
5
5
  "type": "module",
6
6
  "repository": {
7
7
  "type": "git",