@rettangoli/fe 0.0.10 → 0.0.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rettangoli/fe",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "Frontend framework for building reactive web components",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/cli/build.js CHANGED
@@ -8,8 +8,9 @@ import {
8
8
  import esbuild from "esbuild";
9
9
  import { load as loadYaml } from "js-yaml";
10
10
  import { parse } from 'jempl';
11
- import { extractCategoryAndComponent } from '../common.js';
11
+ import { extractCategoryAndComponent } from '../commonBuild.js';
12
12
  import { getAllFiles } from '../commonBuild.js';
13
+ import path from "node:path";
13
14
 
14
15
  function capitalize(word) {
15
16
  return word ? word[0].toUpperCase() + word.slice(1) : word;
@@ -18,13 +19,12 @@ function capitalize(word) {
18
19
  // Function to process view files - loads YAML and creates temporary JS file
19
20
  export const writeViewFile = (view, category, component) => {
20
21
  // const { category, component } = extractCategoryAndComponent(filePath);
21
-
22
- const dir = `./.temp/${category}`;
22
+ const dir = path.join(".temp", category);
23
23
  if (!existsSync(dir)) {
24
24
  mkdirSync(dir, { recursive: true });
25
25
  }
26
26
  writeFileSync(
27
- `${dir}/${component}.view.js`,
27
+ path.join(dir, `${component}.view.js`),
28
28
  `export default ${JSON.stringify(view)};`,
29
29
  );
30
30
  };
@@ -41,6 +41,7 @@ export const bundleFile = async (options) => {
41
41
  loader: {
42
42
  ".wasm": "binary",
43
43
  },
44
+ platform: "browser",
44
45
  });
45
46
  };
46
47
 
@@ -83,10 +84,11 @@ const buildRettangoliFrontend = async (options) => {
83
84
  categories.push(category);
84
85
  }
85
86
 
87
+
86
88
  if (["handlers", "store"].includes(fileType)) {
87
89
  output += `import * as ${component}${capitalize(
88
90
  fileType,
89
- )} from '../${filePath}';\n`;
91
+ )} from '../${filePath.replaceAll(path.sep, "/")}';\n`;
90
92
 
91
93
  replaceMap[count] = `${component}${capitalize(fileType)}`;
92
94
  imports[category][component][fileType] = count;
@@ -4,9 +4,9 @@ import { load as loadYaml, loadAll } from "js-yaml";
4
4
  import { render, parse } from "jempl";
5
5
 
6
6
  import {
7
- extractCategoryAndComponent,
8
7
  flattenArrays,
9
8
  } from "../common.js";
9
+ import { extractCategoryAndComponent } from "../commonBuild.js";
10
10
  import { getAllFiles } from "../commonBuild.js";
11
11
  import path, { dirname } from "node:path";
12
12
 
package/src/cli/watch.js CHANGED
@@ -5,7 +5,7 @@ import { load as loadYaml } from "js-yaml";
5
5
  import { createServer } from 'vite'
6
6
  import { writeViewFile } from './build.js';
7
7
  import buildRettangoliFrontend from './build.js';
8
- import { extractCategoryAndComponent } from '../common.js';
8
+ import { extractCategoryAndComponent } from '../commonBuild.js';
9
9
 
10
10
  // Debounce mechanism to prevent excessive rebuilds
11
11
  let rebuildTimeout = null;
package/src/common.js CHANGED
@@ -165,13 +165,7 @@ export function createHttpClient(config) {
165
165
  }
166
166
 
167
167
 
168
- export const extractCategoryAndComponent = (filePath) => {
169
- const parts = filePath.split("/");
170
- const component = parts[parts.length - 1].split(".")[0];
171
- const category = parts[parts.length - 3];
172
- const fileType = parts[parts.length - 1].split(".")[1];
173
- return { category, component, fileType };
174
- }
168
+
175
169
 
176
170
 
177
171
 
@@ -2,7 +2,7 @@
2
2
  import { readdirSync, statSync } from "node:fs";
3
3
  import { join } from "node:path";
4
4
 
5
-
5
+ import { sep } from 'node:path';
6
6
  // Function to recursively get all files in a directory
7
7
  export function getAllFiles(dirPaths, arrayOfFiles = []) {
8
8
  dirPaths.forEach((dirPath) => {
@@ -19,4 +19,12 @@ export function getAllFiles(dirPaths, arrayOfFiles = []) {
19
19
  });
20
20
 
21
21
  return arrayOfFiles;
22
+ }
23
+
24
+ export const extractCategoryAndComponent = (filePath) => {
25
+ const parts = filePath.split(sep);
26
+ const component = parts[parts.length - 1].split(".")[0];
27
+ const category = parts[parts.length - 3];
28
+ const fileType = parts[parts.length - 1].split(".")[1];
29
+ return { category, component, fileType };
22
30
  }
package/src/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  import createComponent from './createComponent.js';
2
2
  import createWebPatch from './createWebPatch.js';
3
+ import { build } from './cli/index.js'
3
4
 
4
5
  export {
5
6
  createComponent,
6
7
  createWebPatch,
8
+ build
7
9
  }