nodoku-core 0.2.2 → 0.2.3
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/esm/bin/generate-component-resolver.js +1 -5
- package/esm/bin/generate-skin-schema.js +1 -4
- package/esm/bin/manifest-loader.js +13 -3
- package/esm/bin/manifest.js +1 -24
- package/esm/core/dummy-comp.jsx +3 -5
- package/esm/core/rendering-page.jsx +5 -4
- package/package.json +1 -1
- package/types/bin/manifest.d.ts +5 -7
|
@@ -12,16 +12,12 @@ register('./import-load-hooks.js', import.meta.url);
|
|
|
12
12
|
*/
|
|
13
13
|
// @ts-ignore
|
|
14
14
|
const template = (await import("./mustache/component-resolver.ts.hbs")).default;
|
|
15
|
-
class TemplateView {
|
|
16
|
-
modules = [];
|
|
17
|
-
comps = [];
|
|
18
|
-
}
|
|
19
15
|
function calculateTemplateView(dirNodeModules = undefined) {
|
|
20
16
|
if (!dirNodeModules) {
|
|
21
17
|
dirNodeModules = `${path.resolve()}/node_modules`;
|
|
22
18
|
}
|
|
23
19
|
const manifests = loadManifestsFromFolder(dirNodeModules);
|
|
24
|
-
const view =
|
|
20
|
+
const view = { modules: [], comps: [] };
|
|
25
21
|
manifests.forEach((m, k) => {
|
|
26
22
|
let prefix = "";
|
|
27
23
|
if (m.namespace) {
|
|
@@ -12,15 +12,12 @@ register('./import-load-hooks.js', import.meta.url);
|
|
|
12
12
|
*/
|
|
13
13
|
// @ts-ignore
|
|
14
14
|
const template = (await import("./mustache/visual-schema.json.hbs")).default;
|
|
15
|
-
class TemplateView {
|
|
16
|
-
components = new Map();
|
|
17
|
-
}
|
|
18
15
|
function calculateTemplateView(schemaDestinationDir, dirNodeModules = undefined) {
|
|
19
16
|
if (!dirNodeModules) {
|
|
20
17
|
dirNodeModules = path.resolve("./node_modules");
|
|
21
18
|
}
|
|
22
19
|
const components = loadManifestsFromFolder(dirNodeModules);
|
|
23
|
-
const tv = new
|
|
20
|
+
const tv = { components: new Map() };
|
|
24
21
|
components.forEach((m) => {
|
|
25
22
|
m.components.forEach((cd, cn) => {
|
|
26
23
|
const moduleDir = `${dirNodeModules}/${m.moduleName}`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ComponentDef, Manifest } from "./manifest.js";
|
|
2
1
|
import fs from "node:fs";
|
|
3
2
|
import path from "path";
|
|
4
3
|
export function loadManifestsFromFolder(dir) {
|
|
@@ -23,7 +22,11 @@ function loadComponentsByManifest(dir, moduleName) {
|
|
|
23
22
|
const stat = fs.statSync(moduleDir);
|
|
24
23
|
if (stat.isFile()) {
|
|
25
24
|
if (f == "nodoku.manifest.json") {
|
|
26
|
-
const manifest =
|
|
25
|
+
const manifest = {
|
|
26
|
+
moduleName: moduleName,
|
|
27
|
+
moduleDir: moduleDir,
|
|
28
|
+
components: new Map()
|
|
29
|
+
};
|
|
27
30
|
console.log("found manifest ", `${dir}/${f}`, "reading...");
|
|
28
31
|
let json;
|
|
29
32
|
if (stat.isSymbolicLink()) {
|
|
@@ -39,7 +42,14 @@ function loadComponentsByManifest(dir, moduleName) {
|
|
|
39
42
|
const v = json.components[k];
|
|
40
43
|
console.log("adding ", k, v);
|
|
41
44
|
// comps.set(k, Manifest.from(k, moduleName, v));
|
|
42
|
-
manifest.components.set(k, new ComponentDef(v.implementation, v.schemaFile, v.optionsFile, v.defaultThemeFile, v.numBlocks))
|
|
45
|
+
// manifest.components.set(k, new ComponentDef(v.implementation, v.schemaFile, v.optionsFile, v.defaultThemeFile, v.numBlocks))
|
|
46
|
+
manifest.components.set(k, {
|
|
47
|
+
implementation: v.implementation,
|
|
48
|
+
themeSchema: v.schemaFile,
|
|
49
|
+
optionsSchema: v.optionsFile,
|
|
50
|
+
defaultThemeFile: v.defaultThemeFile,
|
|
51
|
+
numBlocks: v.numBlocks
|
|
52
|
+
});
|
|
43
53
|
});
|
|
44
54
|
return manifest;
|
|
45
55
|
}
|
package/esm/bin/manifest.js
CHANGED
|
@@ -1,24 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
implementation;
|
|
3
|
-
themeSchema;
|
|
4
|
-
optionsSchema;
|
|
5
|
-
defaultThemeFile;
|
|
6
|
-
numBlocks;
|
|
7
|
-
constructor(componentImplementation, componentSchema, optionsSchema, defaultThemeFile, numBlocks) {
|
|
8
|
-
this.implementation = componentImplementation;
|
|
9
|
-
this.themeSchema = componentSchema;
|
|
10
|
-
this.optionsSchema = optionsSchema;
|
|
11
|
-
this.defaultThemeFile = defaultThemeFile;
|
|
12
|
-
this.numBlocks = numBlocks;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export class Manifest {
|
|
16
|
-
moduleName;
|
|
17
|
-
moduleDir;
|
|
18
|
-
namespace = undefined;
|
|
19
|
-
components = new Map();
|
|
20
|
-
constructor(moduleName, moduleDir) {
|
|
21
|
-
this.moduleName = moduleName;
|
|
22
|
-
this.moduleDir = moduleDir;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
1
|
+
export {};
|
package/esm/core/dummy-comp.jsx
CHANGED
|
@@ -8,12 +8,10 @@ export async function DummyComp(props) {
|
|
|
8
8
|
async function render(rowIndex, componentIndex, block, t) {
|
|
9
9
|
console.log("this is my block", block.callToActions.map(cta => `${cta.ctaUrl.key}`));
|
|
10
10
|
return (<div className={"w-full w-full flex flex-col items-left justify-left border border-4 border-red-200 relative pb-10"}>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<div className={"top-0 bottom-0 left-0 right-0 absolute bg-white "} style={{ zIndex: -5, opacity: 0.7 }}>
|
|
11
|
+
<div className={"top-0 bottom-0 left-0 right-0 absolute bg-white "} style={{ zIndex: -5, opacity: 0.7 }}></div>
|
|
12
|
+
<div className={"p-5 w-full bg-red-400 text-center"}>
|
|
13
|
+
dummy component<h3><b>{`ns-${block.namespace}-row-${rowIndex}-i-${componentIndex}`}</b></h3>
|
|
15
14
|
</div>
|
|
16
|
-
<div className={"p-5 w-full bg-red-400 text-center"}>dummy component<h3><b>{`ns-${block.namespace}-row-${rowIndex}-i-${componentIndex}`}</b></h3></div>
|
|
17
15
|
|
|
18
16
|
|
|
19
17
|
<div className="p-5">
|
|
@@ -31,7 +31,8 @@ async function RenderingPage(props) {
|
|
|
31
31
|
else {
|
|
32
32
|
l = [await createRow(undefined, 0, content, lng, imageProvider, i18nextProvider, actualComponentResolver)];
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
const actualSkin = mergeTheme(skin, { renderingPage: { base: "", decoration: "" }, rows: [] });
|
|
35
|
+
return <div className={`rows-container ${ts(actualSkin, "renderingPage")}`}>{l}</div>;
|
|
35
36
|
}
|
|
36
37
|
function generateSkinByContentBlocks(blocks, skin) {
|
|
37
38
|
const rendered = new Set();
|
|
@@ -75,7 +76,7 @@ async function createRow(row, iRow, blocks, lng, imageProvider, i18nProvider, co
|
|
|
75
76
|
}
|
|
76
77
|
const rowComponents = l.flatMap((p) => p);
|
|
77
78
|
if (rowComponents.length == 0) {
|
|
78
|
-
return
|
|
79
|
+
return <div key={`row-${iRow}`}></div>;
|
|
79
80
|
}
|
|
80
81
|
const numComponents = rowComponents.length;
|
|
81
82
|
const rowEffectiveTheme = mergeTheme(row?.theme, defaultRowThemeImpl);
|
|
@@ -137,8 +138,8 @@ async function createRow(row, iRow, blocks, lng, imageProvider, i18nProvider, co
|
|
|
137
138
|
if (rowEffectiveTheme.rowDisplay == "flex") {
|
|
138
139
|
rowDisplay = "flex flex-row justify-center flex-wrap flex-1";
|
|
139
140
|
}
|
|
140
|
-
return (<div key={`row-${iRow}`} className={
|
|
141
|
-
{rowComponents.map((c) => <div className={`nd-component-holder ${flexBasis} ${ts(rowEffectiveTheme, "componentHolder")}
|
|
141
|
+
return (<div key={`row-${iRow}`} className={`row-${iRow} ${rowDisplay} ${rowEffectiveTheme?.base} ${rowEffectiveTheme?.decoration} class-row-${iRow}`}>
|
|
142
|
+
{rowComponents.map((c, i) => <div key={`row-${iRow}-component-${i}`} className={`row-${iRow}-component-${i} nd-component-holder ${flexBasis} ${ts(rowEffectiveTheme, "componentHolder")}`}>
|
|
142
143
|
{c}
|
|
143
144
|
</div>)}
|
|
144
145
|
</div>);
|
package/package.json
CHANGED
package/types/bin/manifest.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type ComponentDef = {
|
|
2
2
|
implementation: string;
|
|
3
3
|
themeSchema: string;
|
|
4
4
|
optionsSchema: string;
|
|
5
5
|
defaultThemeFile: string;
|
|
6
6
|
numBlocks: string | number;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export declare class Manifest {
|
|
7
|
+
};
|
|
8
|
+
export type Manifest = {
|
|
10
9
|
moduleName: string;
|
|
11
10
|
moduleDir: string;
|
|
12
|
-
namespace
|
|
11
|
+
namespace?: string;
|
|
13
12
|
components: Map<string, ComponentDef>;
|
|
14
|
-
|
|
15
|
-
}
|
|
13
|
+
};
|