oc-template-solid-compiler 0.2.0 → 0.4.0

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/lib/compile.js CHANGED
@@ -7,7 +7,6 @@ const solid = require('vite-plugin-solid');
7
7
  const { viteView, viteServer } = require('oc-vite-compiler');
8
8
 
9
9
  const verifyTypeScriptSetup = require('./verifyConfig');
10
- const higherOrderServerTemplate = require('./higherOrderServerTemplate');
11
10
  const solidOCProviderTemplate = require('./solidOCProviderTemplate');
12
11
  const htmlTemplate = require('./htmlTemplate');
13
12
 
@@ -23,8 +22,7 @@ const compiler = createCompile({
23
22
  },
24
23
  cb
25
24
  ),
26
- compileServer: (options, cb) =>
27
- viteServer({ ...options, serverWrapper: higherOrderServerTemplate }, cb),
25
+ compileServer: viteServer,
28
26
  compileStatics,
29
27
  getInfo
30
28
  });
@@ -1,16 +1,19 @@
1
+ const escapeCSS = require('cssesc');
2
+
1
3
  const viewTemplate = ({ templateId, css, bundle, hash }) => `function(model){
4
+ oc.solidComponents = oc.solidComponents || {};
5
+ oc.solidComponents['${hash}'] = oc.solidComponents['${hash}'] || (${bundle});
6
+ if (!model) return;
2
7
  var modelHTML = model.__html ? model.__html : '';
3
- var staticPath = model.solidComponent.props._staticPath;
4
- var props = JSON.stringify(model.solidComponent.props);
8
+ var staticPath = model.component.props._staticPath;
9
+ var props = JSON.stringify(model.component.props);
5
10
  window.oc = window.oc || {};
6
11
  window.oc.__solidTemplate = window.oc.__solidTemplate || { count: 0 };
7
- oc.solidComponents = oc.solidComponents || {};
8
- oc.solidComponents['${hash}'] = oc.solidComponents['${hash}'] || (${bundle});
9
12
  var count = window.oc.__solidTemplate.count;
10
13
  var templateId = "${templateId}-" + count;
11
14
  window.oc.__solidTemplate.count++;
12
15
  return '<div id="' + templateId + '" class="${templateId}">' + modelHTML + '</div>' +
13
- '${css ? '<style>' + css + '</style>' : ''}' +
16
+ '${css ? '<style>' + escapeCSS(css) + '</style>' : ''}' +
14
17
  '<script>' +
15
18
  'window.oc = window.oc || {};' +
16
19
  'oc.cmd = oc.cmd || [];' +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oc-template-solid-compiler",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -25,13 +25,14 @@
25
25
  "types": "./lib/oc-app.d.ts",
26
26
  "dependencies": {
27
27
  "chalk": "^3.0.0",
28
+ "cssesc": "^3.0.0",
28
29
  "immer": "^9.0.6",
29
30
  "oc-generic-template-compiler": "2.1.0",
30
31
  "oc-statics-compiler": "2.0.10",
31
32
  "oc-template-solid": "0.0.1",
32
- "oc-vite-compiler": "^2.0.0",
33
+ "oc-vite-compiler": "^2.1.0",
33
34
  "resolve": "^1.20.0",
34
- "solid-js": "^1.7.6",
35
+ "solid-js": "^1.7.8",
35
36
  "vite-plugin-solid": "^2.7.0"
36
37
  },
37
38
  "files": [
@@ -35,7 +35,7 @@
35
35
  "@types/testing-library__jest-dom": "^5.14.5",
36
36
  "jsdom": "^21.1.1",
37
37
  "oc-template-solid": "0.0.1",
38
- "oc-template-solid-compiler": "0.1.0",
38
+ "oc-template-solid-compiler": "0.4.0",
39
39
  "solid-js": "^1.7.0",
40
40
  "typescript": "5.0.2",
41
41
  "vitest": "^0.29.7"
@@ -1,28 +0,0 @@
1
- const removeExtension = (path) => path.replace(/\.(j|t)sx?$/, '');
2
-
3
- const higherOrderServerTemplate = ({ serverPath, componentName, componentVersion }) => `
4
- import { data as dataProvider } from '${removeExtension(serverPath)}';
5
-
6
- export const data = (context : any, callback : (error: any, data?: any) => void) => {
7
- dataProvider(context, (error: any, model: any) => {
8
- if (error) {
9
- return callback(error);
10
- }
11
- const props = Object.assign({}, model, {
12
- _staticPath: context.staticPath,
13
- _baseUrl: context.baseUrl,
14
- _componentName: "${componentName}",
15
- _componentVersion: "${componentVersion}"
16
- });
17
- const srcPathHasProtocol = context.staticPath.indexOf("http") === 0;
18
- const srcPath = srcPathHasProtocol ? context.staticPath : ("https:" + context.staticPath);
19
- return callback(null, Object.assign({}, {
20
- solidComponent: {
21
- props
22
- }
23
- }));
24
- });
25
- }
26
- `;
27
-
28
- module.exports = higherOrderServerTemplate;