leanweb 1.1.1 → 1.1.5

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/README.md CHANGED
@@ -259,6 +259,7 @@ items = ["one", "two", "three"];
259
259
  <br />
260
260
  <button lw-on:click="resetName()">Reset Name</button>
261
261
  ```
262
+
262
263
  You could bind multiple events like `lw-on:click,change=handler($event, $node)`.
263
264
 
264
265
  ```javascript
@@ -318,24 +319,26 @@ imageWidth = 400;
318
319
  `demo-parent.html`
319
320
 
320
321
  ```html
321
- <demo-child lw-input:userData="user"></demo-child>
322
+ <demo-child lw-input:parent="self" lw-input:userData="user"></demo-child>
322
323
  ```
323
324
 
324
325
  `demo-parent.js`
325
326
 
326
327
  ```javascript
327
328
  // ...
329
+ // self is defined in LWElement as `self = this`;
328
330
  user = { firstname: "Qian", lastname: "Chen" };
329
331
  // ...
330
332
  ```
331
333
 
332
- The child is able to access the `user` object passed in with `lw-input:`
333
- directive from `inputReady()` method.
334
+ The child is able to access the `parent` and `user` object passed in with
335
+ `lw-input:` directive from `inputReady()` method.
334
336
  `demo-child.js`
335
337
 
336
338
  ```javascript
337
339
  // ...
338
340
  inputReady() {
341
+ console.log(this.parent);
339
342
  console.log(this.userData);
340
343
  }
341
344
  // ...
package/commands/build.js CHANGED
@@ -121,18 +121,18 @@ const require = createRequire(import.meta.url);
121
121
  const buildHTML = () => {
122
122
  project.components.forEach(cmp => {
123
123
  const cmpName = utils.getComponentName(cmp);
124
- const htmlFilename = `${projectPath}/${buildDir}/components/${cmp}/${cmpName}.html`;
124
+ const htmlFilename = `${buildDir}/components/${cmp}/${cmpName}.html`;
125
125
  const htmlFileExists = fs.existsSync(htmlFilename);
126
126
  if (htmlFileExists) {
127
127
 
128
- const scssFilename = `${projectPath}/${buildDir}/components/${cmp}/${cmpName}.scss`;
128
+ const scssFilename = `${buildDir}/components/${cmp}/${cmpName}.scss`;
129
129
  const scssFileExists = fs.existsSync(scssFilename);
130
130
  let cssString = '';
131
131
  if (scssFileExists) {
132
132
  let scssString = `@use "global-styles.scss";\n`;
133
133
  scssString += fs.readFileSync(scssFilename, 'utf8');
134
134
  scssString += '\n[lw-false],[lw-for]{display:none !important;}\n';
135
- cssString = utils.buildCSS(scssString, `${projectPath}/${buildDir}/components/${cmp}`);
135
+ cssString = utils.buildCSS(scssString, `${buildDir}/components/${cmp}`);
136
136
  }
137
137
  const styleString = cssString || '';
138
138
  const htmlString = fs.readFileSync(htmlFilename, 'utf8');
@@ -144,16 +144,16 @@ const require = createRequire(import.meta.url);
144
144
  fs.writeFileSync(`${buildDir}/components/${cmp}/ast.js`, `export default ${JSON.stringify(ast, null, 0)};`);
145
145
  }
146
146
  });
147
- const htmlString = fs.readFileSync(`${projectPath}/${buildDir}/index.html`, 'utf8');
147
+ const htmlString = fs.readFileSync(`${buildDir}/index.html`, 'utf8');
148
148
  fs.writeFileSync(`${buildDir}/index.html`, htmlString);
149
149
  };
150
150
 
151
151
  const buildSCSS = () => {
152
- const projectScssFilename = `${projectPath}/src/${project.name}.scss`;
152
+ const projectScssFilename = `${projectPath}/${utils.dirs.src}/${project.name}.scss`;
153
153
  let projectCssString = '';
154
154
  if (fs.existsSync(projectScssFilename)) {
155
155
  const projectScssString = fs.readFileSync(projectScssFilename, 'utf8');
156
- projectCssString += utils.buildCSS(projectScssString, `${projectPath}/${buildDir}`);
156
+ projectCssString += utils.buildCSS(projectScssString, buildDir);
157
157
  }
158
158
  fs.writeFileSync(`${buildDir}/${project.name}.css`, projectCssString);
159
159
  };
@@ -52,7 +52,7 @@ const require = createRequire(import.meta.url);
52
52
  }
53
53
 
54
54
  if (!fs.existsSync(`${cmpPath}/${cmpName}.scss`)) {
55
- fs.writeFileSync(`${cmpPath}/${cmpName}.scss`, ':host {\n\tdisplay: inline-block;\n\tposition: relative;\n}');
55
+ fs.writeFileSync(`${cmpPath}/${cmpName}.scss`, '');
56
56
  }
57
57
  }
58
58
  })();
package/commands/init.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import fse from 'fs-extra';
3
3
  import git from 'isomorphic-git';
4
- import globby from 'globby';
4
+ import { globby } from 'globby';
5
5
  import * as utils from './utils.js';
6
6
 
7
7
  import path from 'path';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "leanweb",
3
- "version": "1.1.1",
3
+ "version": "1.1.5",
4
4
  "description": "Builds framework agnostic web components.",
5
5
  "bin": {
6
6
  "leanweb": "leanweb.js",
@@ -20,25 +20,25 @@
20
20
  "author": "Qian Chen",
21
21
  "license": "MIT",
22
22
  "dependencies": {
23
- "@babel/core": "^7.16.12",
24
- "@babel/parser": "^7.16.12",
25
- "@babel/plugin-transform-runtime": "^7.16.10",
23
+ "@babel/core": "^7.17.0",
24
+ "@babel/parser": "^7.17.0",
25
+ "@babel/plugin-transform-runtime": "^7.17.0",
26
26
  "@babel/preset-env": "^7.16.11",
27
27
  "babel-loader": "^8.2.3",
28
- "clean-css": "^5.2.2",
29
- "css-loader": "^6.5.1",
28
+ "clean-css": "^5.2.4",
29
+ "css-loader": "^6.6.0",
30
30
  "fs-extra": "^10.0.0",
31
- "globby": "^13.0.0",
31
+ "globby": "^13.1.1",
32
32
  "html-minifier": "^4.0.0",
33
- "isomorphic-git": "^1.10.5",
33
+ "isomorphic-git": "^1.11.2",
34
34
  "json5-loader": "^4.0.1",
35
35
  "node-watch": "^0.7.3",
36
36
  "parse5": "^6.0.1",
37
37
  "raw-loader": "^4.0.2",
38
- "sass": "^1.49.0",
38
+ "sass": "^1.49.7",
39
39
  "sass-loader": "^12.4.0",
40
40
  "semver": "^7.3.5",
41
- "webpack": "^5.67.0",
42
- "webpack-dev-server": "^4.7.3"
41
+ "webpack": "^5.68.0",
42
+ "webpack-dev-server": "^4.7.4"
43
43
  }
44
44
  }
@@ -97,6 +97,7 @@ const nextAllSiblings = (el, selector) => {
97
97
  };
98
98
 
99
99
  export default class LWElement extends HTMLElement {
100
+ self = this;
100
101
  constructor(ast) {
101
102
  super();
102
103
  this.ast = ast;