Socket
Socket
Sign inDemoInstall

jsxte

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsxte - npm Package Compare versions

Comparing version 3.1.5 to 3.1.6

35

CHANGELOG.md

@@ -0,1 +1,36 @@

## 3.1.6 (October 23, 2023)
### Features
- #### feat: Add view-transition as allowed name for meta-tag. ([#225](https://github.com/ncpa0/jsxte/pull/225))
Updated types for the `<meta>` tag to allow for the `view-transition` as name attribute value.
- #### feat: allow null, undefined, booleans, string and numbers as jsx elements ([#221](https://github.com/ncpa0/jsxte/pull/221))
It is now possible to return other things from function components than elements created via `createElement` or JSX syntax. Anything that is not an object, string or number will be treated as if `<></>` was returned, returned strings and numbers will be treated as `<>{value}</>`, objects are expected to be elements created via `createElement` or JSX syntax (no change here).
This means that the following components are now possible:
```tsx
function MyComponent() {
return !!condition && <div>...</div>;
}
function MyComponent() {
return "Hello";
}
function MyComponent() {
return 2023;
}
// ok
renderToHtml(
<div>
<MyComponent />
</div>,
);
```
## 3.1.5 (October 10, 2023)

@@ -2,0 +37,0 @@

39

dist/legacy/html-parser/jsx-elem-to-html.js

@@ -33,5 +33,20 @@ "use strict";

var import_get_html_struct = require("./get-html-struct.js");
var isSyncElem = (e) => true;
var isTextNode = (e) => "type" in e && e.type === "textNode";
function assertSyncElem(e) {
}
var isTextNode = (e) => typeof e === "object" && e != null && "type" in e && e.type === "textNode";
var jsxElemToHtmlSync = (element, _componentApi, options) => {
switch (typeof element) {
case "string":
return element;
case "bigint":
case "number":
return String(element);
case "boolean":
case "function":
case "symbol":
case "undefined":
return "";
}
if (element === null)
return "";
const attributeMap = options?.attributeMap ?? {};

@@ -41,4 +56,3 @@ const currentIndent = options?.currentIndent ?? 0;

const componentApi = _componentApi ? import_component_api.ComponentApi.clone(_componentApi) : import_component_api.ComponentApi.create(options);
if (!isSyncElem(element))
throw new Error("");
assertSyncElem(element);
if (element.type === "textNode") {

@@ -142,6 +156,19 @@ const indentPadding = " ".repeat(currentIndent);

var jsxElemToHtmlAsync = async (element, _componentApi, options) => {
switch (typeof element) {
case "string":
return element;
case "bigint":
case "number":
return String(element);
case "boolean":
case "function":
case "symbol":
case "undefined":
return "";
}
if (element === null)
return "";
const { attributeMap = {}, currentIndent = 0, indent = 2 } = options ?? {};
const componentApi = _componentApi ? import_component_api.ComponentApi.clone(_componentApi) : import_component_api.ComponentApi.create(options);
if (!isSyncElem(element))
throw new Error("");
assertSyncElem(element);
if (element.type === "textNode") {

@@ -148,0 +175,0 @@ const indentPadding = " ".repeat(currentIndent);

@@ -30,8 +30,22 @@ "use strict";

var import_get_html_struct = require("../html-parser/get-html-struct.js");
var isSyncElem = (e) => true;
function assertSyncElem(e) {
}
var jsxElemToJsonSync = (element, _componentApi, options) => {
switch (typeof element) {
case "string":
return element;
case "bigint":
case "number":
return String(element);
case "boolean":
case "function":
case "symbol":
case "undefined":
return "";
}
if (element === null)
return "";
const attributeMap = options?.attributeMap ?? {};
const componentApi = _componentApi ? import_component_api.ComponentApi.clone(_componentApi) : import_component_api.ComponentApi.create(options);
if (!isSyncElem(element))
throw new Error("");
assertSyncElem(element);
if (element.type === "textNode") {

@@ -98,6 +112,19 @@ return element.text;

var jsxElemToJsonAsync = async (element, _componentApi, options) => {
switch (typeof element) {
case "string":
return element;
case "bigint":
case "number":
return String(element);
case "boolean":
case "function":
case "symbol":
case "undefined":
return "";
}
if (element === null)
return "";
const attributeMap = options?.attributeMap ?? {};
const componentApi = _componentApi ? import_component_api.ComponentApi.clone(_componentApi) : import_component_api.ComponentApi.create(options);
if (!isSyncElem(element))
throw new Error("");
assertSyncElem(element);
if (element.type === "textNode") {

@@ -104,0 +131,0 @@ return element.text;

@@ -34,3 +34,4 @@ "use strict";

var import_to_template_string_array = require("./to-template-string-array.js");
var isSyncElem = (e) => true;
function assertSyncElem(e) {
}
var concatToLastStringOrPush = (a, s) => {

@@ -46,6 +47,19 @@ if (s) {

var jsxElemToTagFuncArgsSync = (element, options, _componentApi = import_component_api.ComponentApi.create()) => {
switch (typeof element) {
case "string":
return [["", ""], [element]];
case "bigint":
case "number":
return [["", ""], [String(element)]];
case "boolean":
case "function":
case "symbol":
case "undefined":
return [["", ""], [""]];
}
if (element === null)
return [["", ""], [""]];
const { attributeMap = {} } = options;
const componentApi = _componentApi ? import_component_api.ComponentApi.clone(_componentApi) : import_component_api.ComponentApi.create({ attributeMap });
if (!isSyncElem(element))
throw new Error("");
assertSyncElem(element);
if (element.type === "textNode") {

@@ -52,0 +66,0 @@ return [["", ""], [element.text]];

2

dist/types/jsx/base-html-tag-props.d.ts

@@ -19,3 +19,3 @@ import type { ComponentApi } from "../component-api/component-api";

type: "tag";
tag: string | ((props: ElementProps, contextMap: ComponentApi) => Element) | ((props: ElementProps, contextMap: ComponentApi) => Promise<Element>) | ErrorBoundaryElement;
tag: ((props: ElementProps, contextMap: ComponentApi) => JSX.Element) | ErrorBoundaryElement;
props: ElementProps;

@@ -22,0 +22,0 @@ };

@@ -49,4 +49,4 @@ /// <reference path="prop-types/a-jsx-props.d.ts" />

namespace JSX {
type AsyncElement = Promise<JSXTE.TagElement | JSXTE.TextNodeElement>;
type SyncElement = JSXTE.TagElement | JSXTE.TextNodeElement;
type AsyncElement = Promise<JSXTE.TagElement | JSXTE.TextNodeElement | null | undefined | boolean | string | number>;
type SyncElement = JSXTE.TagElement | JSXTE.TextNodeElement | null | undefined | boolean | string | number;
type Element = SyncElement | AsyncElement;

@@ -53,0 +53,0 @@ interface IntrinsicElements {

@@ -7,3 +7,3 @@ declare global {

content?: string;
name?: "application-name" | "author" | "description" | "generator" | "keywords" | "viewport";
name?: "application-name" | "author" | "description" | "generator" | "keywords" | "viewport" | "view-transition";
}

@@ -10,0 +10,0 @@ }

{
"name": "jsxte",
"version": "3.1.5",
"version": "3.1.6",
"description": "JSX-based html templating engine for browsers or Node environments.",

@@ -46,7 +46,7 @@ "license": "MIT",

"@types/jest": "~29.5.4",
"@typescript-eslint/eslint-plugin": "~6.7.0",
"@typescript-eslint/parser": "~6.6.0",
"@typescript-eslint/eslint-plugin": "~6.8.0",
"@typescript-eslint/parser": "~6.8.0",
"axios": "~1.5.0",
"esbuild": "~0.19.2",
"eslint": "~8.49.0",
"eslint": "~8.51.0",
"eslint-config-prettier": "~9.0.0",

@@ -56,3 +56,3 @@ "eslint-plugin-prettier": "~5.0.0",

"husky": "~8.0.3",
"jest": "~29.6.4",
"jest": "~29.7.0",
"node-os-walk": "~1.0.2",

@@ -59,0 +59,0 @@ "pr-changelog-gen": "~1.1.3",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc