@jay-framework/compiler-jay-html 0.15.6 → 0.16.1

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 (2) hide show
  1. package/dist/index.js +30 -8
  2. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -14359,6 +14359,9 @@ function filterContentNodes(childNodes, onlyIfMultiple = false) {
14359
14359
  function textEscape$1(s) {
14360
14360
  return s.replace(/'/g, "\\'");
14361
14361
  }
14362
+ function escapeForJsString(s) {
14363
+ return s.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r");
14364
+ }
14362
14365
  const PROPERTY = 1;
14363
14366
  const BOOLEAN_ATTRIBUTE = 3;
14364
14367
  const propertyMapping = {
@@ -22411,7 +22414,7 @@ function renderServerAttributes(element, context) {
22411
22414
  )
22412
22415
  );
22413
22416
  } else {
22414
- const escaped = attrValue.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
22417
+ const escaped = escapeForJsString(attrValue);
22415
22418
  parts.push(w(indent, `' ${attrCanonical}="${escaped}"'`));
22416
22419
  }
22417
22420
  } else if (attrCanonical === "class") {
@@ -22426,7 +22429,7 @@ function renderServerAttributes(element, context) {
22426
22429
  )
22427
22430
  );
22428
22431
  } else {
22429
- const escaped = attrValue.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
22432
+ const escaped = escapeForJsString(attrValue);
22430
22433
  parts.push(w(indent, `' class="${escaped}"'`));
22431
22434
  }
22432
22435
  } else if (attrCanonical === "style") {
@@ -22443,7 +22446,7 @@ function renderServerAttributes(element, context) {
22443
22446
  )
22444
22447
  );
22445
22448
  } else {
22446
- const escaped = attrValue.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
22449
+ const escaped = escapeForJsString(attrValue);
22447
22450
  parts.push(w(indent, `' style="${escaped}"'`));
22448
22451
  }
22449
22452
  } else {
@@ -22460,7 +22463,7 @@ function renderServerAttributes(element, context) {
22460
22463
  )
22461
22464
  );
22462
22465
  } else {
22463
- const escaped = attrValue.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
22466
+ const escaped = escapeForJsString(attrValue);
22464
22467
  parts.push(w(indent, `' ${attrCanonical}="${escaped}"'`));
22465
22468
  }
22466
22469
  }
@@ -22609,7 +22612,7 @@ function renderServerAttributesAsString(element, context) {
22609
22612
  )
22610
22613
  );
22611
22614
  } else {
22612
- const escaped = attrValue.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
22615
+ const escaped = escapeForJsString(attrValue);
22613
22616
  parts.push(new RenderFragment(`' ${attrCanonical}="${escaped}"'`));
22614
22617
  }
22615
22618
  } else if (attrCanonical === "class") {
@@ -22623,7 +22626,7 @@ function renderServerAttributesAsString(element, context) {
22623
22626
  )
22624
22627
  );
22625
22628
  } else {
22626
- const escaped = attrValue.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
22629
+ const escaped = escapeForJsString(attrValue);
22627
22630
  parts.push(new RenderFragment(`' class="${escaped}"'`));
22628
22631
  }
22629
22632
  } else if (attrCanonical === "style") {
@@ -22639,7 +22642,7 @@ function renderServerAttributesAsString(element, context) {
22639
22642
  )
22640
22643
  );
22641
22644
  } else {
22642
- const escaped = attrValue.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
22645
+ const escaped = escapeForJsString(attrValue);
22643
22646
  parts.push(new RenderFragment(`' style="${escaped}"'`));
22644
22647
  }
22645
22648
  } else {
@@ -22655,7 +22658,7 @@ function renderServerAttributesAsString(element, context) {
22655
22658
  )
22656
22659
  );
22657
22660
  } else {
22658
- const escaped = attrValue.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
22661
+ const escaped = escapeForJsString(attrValue);
22659
22662
  parts.push(new RenderFragment(`' ${attrCanonical}="${escaped}"'`));
22660
22663
  }
22661
22664
  }
@@ -23112,11 +23115,26 @@ function collectImportedAliases(type2, aliases2) {
23112
23115
  collectImportedAliases(type2.itemType, aliases2);
23113
23116
  }
23114
23117
  }
23118
+ function containsFileType(type2) {
23119
+ if (isAtomicType(type2))
23120
+ return type2.name === "file";
23121
+ if (isOptionalType(type2))
23122
+ return containsFileType(type2.innerType);
23123
+ if (isArrayType$1(type2))
23124
+ return containsFileType(type2.itemType);
23125
+ if (isRecordType(type2))
23126
+ return containsFileType(type2.itemType);
23127
+ if (isObjectType$1(type2))
23128
+ return Object.values(type2.props).some(containsFileType);
23129
+ return false;
23130
+ }
23115
23131
  function renderType(type2, aliasToViewState, indent) {
23116
23132
  if (isOptionalType(type2)) {
23117
23133
  return renderType(type2.innerType, aliasToViewState, indent);
23118
23134
  }
23119
23135
  if (isAtomicType(type2)) {
23136
+ if (type2.name === "file")
23137
+ return "JayFile";
23120
23138
  return type2.name;
23121
23139
  }
23122
23140
  if (isEnumType(type2)) {
@@ -23197,6 +23215,10 @@ function compileAction(actionWithValidations, contractResolver = defaultContract
23197
23215
  `import { ${resolved.viewStateName} } from '${resolved.importPath}';`
23198
23216
  );
23199
23217
  }
23218
+ const usesFileType = containsFileType(action.inputType) || action.outputType && containsFileType(action.outputType);
23219
+ if (usesFileType) {
23220
+ importStatements.push(`import { JayFile } from '@jay-framework/fullstack-component';`);
23221
+ }
23200
23222
  if (importStatements.length > 0) {
23201
23223
  sections.push(importStatements.join("\n"));
23202
23224
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/compiler-jay-html",
3
- "version": "0.15.6",
3
+ "version": "0.16.1",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -34,12 +34,12 @@
34
34
  },
35
35
  "author": "",
36
36
  "dependencies": {
37
- "@jay-framework/compiler-analyze-exported-types": "^0.15.6",
38
- "@jay-framework/compiler-shared": "^0.15.6",
39
- "@jay-framework/component": "^0.15.6",
40
- "@jay-framework/logger": "^0.15.6",
41
- "@jay-framework/runtime": "^0.15.6",
42
- "@jay-framework/secure": "^0.15.6",
37
+ "@jay-framework/compiler-analyze-exported-types": "^0.16.1",
38
+ "@jay-framework/compiler-shared": "^0.16.1",
39
+ "@jay-framework/component": "^0.16.1",
40
+ "@jay-framework/logger": "^0.16.1",
41
+ "@jay-framework/runtime": "^0.16.1",
42
+ "@jay-framework/secure": "^0.16.1",
43
43
  "@types/js-yaml": "^4.0.9",
44
44
  "change-case": "^4.1.2",
45
45
  "js-yaml": "^4.1.0",
@@ -51,8 +51,8 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@caiogondim/strip-margin": "^1.0.0",
54
- "@jay-framework/4-react": "^0.15.6",
55
- "@jay-framework/dev-environment": "^0.15.6",
54
+ "@jay-framework/4-react": "^0.16.1",
55
+ "@jay-framework/dev-environment": "^0.16.1",
56
56
  "@testing-library/jest-dom": "^6.2.0",
57
57
  "@types/js-beautify": "^1",
58
58
  "@types/node": "^20.11.5",