@cocreate/server-side-render 1.10.1 → 1.10.2

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +49 -49
  3. package/src/index.js +11 -10
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [1.10.2](https://github.com/CoCreate-app/CoCreate-server-side-render/compare/v1.10.1...v1.10.2) (2024-03-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * handle key instead of name ([b28001e](https://github.com/CoCreate-app/CoCreate-server-side-render/commit/b28001e22aded06127cbe69bc10c51a4a05735f8))
7
+ * update node-html-parser ([51947c0](https://github.com/CoCreate-app/CoCreate-server-side-render/commit/51947c04ccbca67be79a1f5c4d7419231b99169c))
8
+
1
9
  ## [1.10.1](https://github.com/CoCreate-app/CoCreate-server-side-render/compare/v1.10.0...v1.10.1) (2024-02-05)
2
10
 
3
11
 
package/package.json CHANGED
@@ -1,51 +1,51 @@
1
1
  {
2
- "name": "@cocreate/server-side-render",
3
- "version": "1.10.1",
4
- "description": "A simple server-side-render component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
- "keywords": [
6
- "server-side-render",
7
- "cocreate",
8
- "low-code-framework",
9
- "no-code-framework",
10
- "cocreatejs",
11
- "cocreatejs-component",
12
- "cocreate-framework",
13
- "no-code",
14
- "low-code",
15
- "collaborative-framework",
16
- "realtime",
17
- "realtime-framework",
18
- "collaboration",
19
- "shared-editing",
20
- "html5-framework",
21
- "javascript-framework"
22
- ],
23
- "publishConfig": {
24
- "access": "public"
25
- },
26
- "scripts": {
27
- "start": "npx webpack --config webpack.config.js",
28
- "build": "npx webpack --mode=production --config webpack.config.js",
29
- "dev": "npx webpack --config webpack.config.js --watch",
30
- "postinstall": "node -e \"const { execSync } = require('child_process'); try { execSync('coc --version', { stdio: 'ignore' }); } catch (error) { try { execSync('npm install -g @cocreate/cli', { stdio: 'inherit' }); console.log('Installed \"@cocreate/cli\" globally.'); } catch (error) { console.error('Failed to install \"@cocreate/cli\" globally:', error); } }\""
31
- },
32
- "repository": {
33
- "type": "git",
34
- "url": "git+https://github.com/CoCreate-app/CoCreate-server-side-render.git"
35
- },
36
- "author": "CoCreate LLC",
37
- "license": "MIT",
38
- "bugs": {
39
- "url": "https://github.com/CoCreate-app/CoCreate-server-side-render/issues"
40
- },
41
- "homepage": "https://cocreate.app/docs/server-side-render",
42
- "funding": {
43
- "type": "GitHub Sponsors ❤",
44
- "url": "https://github.com/sponsors/CoCreate-app"
45
- },
46
- "main": "./src/index.js",
47
- "dependencies": {
48
- "@cocreate/utils": "^1.30.0",
49
- "node-html-parser": "^6.1.4"
50
- }
2
+ "name": "@cocreate/server-side-render",
3
+ "version": "1.10.2",
4
+ "description": "A simple server-side-render component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
5
+ "keywords": [
6
+ "server-side-render",
7
+ "cocreate",
8
+ "low-code-framework",
9
+ "no-code-framework",
10
+ "cocreatejs",
11
+ "cocreatejs-component",
12
+ "cocreate-framework",
13
+ "no-code",
14
+ "low-code",
15
+ "collaborative-framework",
16
+ "realtime",
17
+ "realtime-framework",
18
+ "collaboration",
19
+ "shared-editing",
20
+ "html5-framework",
21
+ "javascript-framework"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "scripts": {
27
+ "start": "npx webpack --config webpack.config.js",
28
+ "build": "npx webpack --mode=production --config webpack.config.js",
29
+ "dev": "npx webpack --config webpack.config.js --watch",
30
+ "postinstall": "node -e \"const { execSync } = require('child_process'); try { execSync('coc --version', { stdio: 'ignore' }); } catch (error) { try { execSync('npm install -g @cocreate/cli', { stdio: 'inherit' }); console.log('Installed \"@cocreate/cli\" globally.'); } catch (error) { console.error('Failed to install \"@cocreate/cli\" globally:', error); } }\""
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://github.com/CoCreate-app/CoCreate-server-side-render.git"
35
+ },
36
+ "author": "CoCreate LLC",
37
+ "license": "MIT",
38
+ "bugs": {
39
+ "url": "https://github.com/CoCreate-app/CoCreate-server-side-render/issues"
40
+ },
41
+ "homepage": "https://cocreate.app/docs/server-side-render",
42
+ "funding": {
43
+ "type": "GitHub Sponsors ❤",
44
+ "url": "https://github.com/sponsors/CoCreate-app"
45
+ },
46
+ "main": "./src/index.js",
47
+ "dependencies": {
48
+ "@cocreate/utils": "^1.30.0",
49
+ "node-html-parser": "^6.1.12"
50
+ }
51
51
  }
package/src/index.js CHANGED
@@ -13,10 +13,11 @@ class CoCreateServerSideRender {
13
13
  let dep = [];
14
14
  let dbCache = new Map();
15
15
 
16
+ // Does not support instanceof HTMLCollection
16
17
  async function render(html, lastKey) {
17
18
  const dom = parse(html);
18
19
  for (let el of dom.querySelectorAll(
19
- "[array][name][object]"
20
+ "[array][key][object]"
20
21
  )) {
21
22
  let meta = el.attributes;
22
23
 
@@ -36,16 +37,16 @@ class CoCreateServerSideRender {
36
37
  continue;
37
38
  let _id = meta["object"],
38
39
  array = meta['array'],
39
- name = meta['name'];
40
- let key = _id + array + name;
41
- if (!_id || !name || !array) continue;
42
- if (!checkValue(_id) || !checkValue(name) || !checkValue(array)) continue;
43
- if (dep.includes(key))
40
+ key = meta['key'];
41
+ let crudKey = _id + array + key;
42
+ if (!_id || !key || !array) continue;
43
+ if (!checkValue(_id) || !checkValue(key) || !checkValue(array)) continue;
44
+ if (dep.includes(crudKey))
44
45
  throw new Error(
45
- `infinite loop: ${lastKey} ${array} ${name} ${_id} has been already rendered`
46
+ `infinite loop: ${lastKey} ${array} ${key} ${_id} has been already rendered`
46
47
  );
47
48
  else
48
- dep.push(key)
49
+ dep.push(crudKey)
49
50
 
50
51
  let cacheKey = _id + array;
51
52
  let data;
@@ -66,11 +67,11 @@ class CoCreateServerSideRender {
66
67
  dbCache.set(cacheKey, data)
67
68
  }
68
69
 
69
- if (!data || !data[name]) {
70
+ if (!data || !data[key]) {
70
71
  dep.pop();
71
72
  continue;
72
73
  }
73
- let chunk = data[name];
74
+ let chunk = data[key];
74
75
  if (!chunk) {
75
76
  dep.pop();
76
77
  continue;