mini-van-plate
Advanced tools
Comparing version 0.5.4-perf.0 to 0.5.4
{ | ||
"name": "mini-van-plate", | ||
"version": "0.5.4-perf.0", | ||
"version": "0.5.4", | ||
"description": "A minimalist template engine for DOM generation and manipulation, working for both client-side and server-side rendering", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -157,3 +157,3 @@ # **Mini-Van**: A Minimalist Template Engine for Client/Server-side Rendering without JSX | ||
```typescript | ||
import van from "https://deno.land/x/minivan@0.5.3/src/van-plate.js" | ||
import van from "https://deno.land/x/minivan@0.5.4/src/van-plate.js" | ||
@@ -199,3 +199,3 @@ const {a, body, li, p, ul} = van.tags | ||
import { DOMParser } from "https://deno.land/x/deno_dom@v0.1.38/deno-dom-wasm.ts" | ||
import van from "https://deno.land/x/minivan@0.5.3/src/mini-van.js" | ||
import van from "https://deno.land/x/minivan@0.5.4/src/mini-van.js" | ||
@@ -240,3 +240,3 @@ const document = new DOMParser().parseFromString("", "text/html")! | ||
```javascript | ||
import van from "https://cdn.jsdelivr.net/gh/vanjs-org/mini-van/public/mini-van-0.5.3.min.js" | ||
import van from "https://cdn.jsdelivr.net/gh/vanjs-org/mini-van/public/mini-van-0.5.4.min.js" | ||
``` | ||
@@ -247,6 +247,6 @@ | ||
```html | ||
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/vanjs-org/mini-van/public/mini-van-0.5.3.nomodule.min.js"></script> | ||
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/vanjs-org/mini-van/public/mini-van-0.5.4.nomodule.min.js"></script> | ||
``` | ||
Alternative, you can download the files ([`mini-van-0.5.3.min.js`](https://vanjs.org/autodownload?file=mini-van-0.5.3.min.js), [`mini-van-0.5.3.nomodule.min.js`](https://vanjs.org/autodownload?file=mini-van-0.5.3.nomodule.min.js)) and serve them locally. | ||
Alternative, you can download the files ([`mini-van-0.5.4.min.js`](https://vanjs.org/autodownload?file=mini-van-0.5.4.min.js), [`mini-van-0.5.4.nomodule.min.js`](https://vanjs.org/autodownload?file=mini-van-0.5.4.nomodule.min.js)) and serve them locally. | ||
@@ -261,3 +261,3 @@ You can find all relevant **Mini-Van** files in this [Download Table](https://vanjs.org/minivan#download-table). | ||
🙏 **VanJS** aims to build a better world by reducing the entry barrier for UI programming, with no intention or plan on commercialization whatsoever. If you find **VanJS** interesting, or could be useful for you some day, please consider starring the project. It takes just one seconds but your support means the world to us and helps spread **VanJS** to a wider audience. | ||
🙏 **VanJS** aims to build a better world by reducing the entry barrier of UI programming, with no intention or plan on commercialization whatsoever. If you find **VanJS** interesting, or could be useful for you some day, please consider starring the project. It takes just one seconds but your support means the world to us and helps spread **VanJS** to a wider audience. | ||
@@ -264,0 +264,0 @@ We're looking for the 1.0 milestone (commitment to API stability) soon, your precious feedback will be greatly appreciated. You can submit your feedback by [creating issues](https://github.com/vanjs-org/mini-van/issues/new). |
@@ -51,10 +51,6 @@ export interface State<T> { | ||
export interface VanObj<ElementType extends HasFirstChild, TextNodeType> { | ||
readonly state: <T>(initVal: T) => State<T> | ||
readonly val: <T>(s: T | StateView<T>) => T | ||
readonly oldVal: <T>(s: T | StateView<T>) => T | ||
readonly state: <T>(initVal?: T) => State<T> | ||
readonly derive: <T>(f: () => T) => State<T> | ||
readonly add: AddFunc<ElementType, TextNodeType> | ||
readonly _: (f: () => PropValue) => () => PropValue | ||
readonly tags: Tags<ElementType, TextNodeType> | ||
readonly tagsNS: (namespaceURI: string) => Tags<ElementType, TextNodeType> | ||
readonly tags: Tags<ElementType, TextNodeType> & ((namespaceURI: string) => Tags<ElementType, TextNodeType>) | ||
@@ -71,3 +67,3 @@ // Mini-Van specific API | ||
}) => VanObj<ElementType, TextNodeType> | ||
readonly tags: BrowserTags | ||
readonly tags: BrowserTags & ((namespaceURI: string) => Tags<Element, Text>) | ||
} | ||
@@ -74,0 +70,0 @@ |
@@ -12,8 +12,6 @@ /// <reference types="./mini-van.d.ts" /> | ||
let val = s => protoOf(s ?? 0) === stateProto ? s.val : s | ||
let plainValue = (k, v) => { | ||
let protoOfV = protoOf(v ?? 0) | ||
return protoOfV === stateProto ? v.val : | ||
protoOfV === funcProto && (!k?.startsWith("on") || v._isBindingFunc) ? v() : v | ||
protoOfV !== funcProto || k?.startsWith("on") ? v : v() | ||
} | ||
@@ -28,3 +26,3 @@ | ||
let vanWithDoc = doc => { | ||
let tagsNS = ns => new Proxy((name, ...args) => { | ||
let tag = (ns, name, ...args) => { | ||
let [props, ...children] = protoOf(args[0] ?? 0) === objProto ? args : [{}, ...args] | ||
@@ -39,9 +37,9 @@ let dom = ns ? doc.createElementNS(ns, name) : doc.createElement(name) | ||
return add(dom, ...children) | ||
}, {get: (tag, name) => tag.bind(null, name)}) | ||
} | ||
let tags = tagsNS() | ||
let handler = ns => ({get: (_, name) => tag.bind(_undefined, ns, name)}) | ||
let tags = new Proxy(ns => new Proxy(tag, handler(ns)), handler()) | ||
return { | ||
add, _: f => (f._isBindingFunc = 1, f), tags, tagsNS, state, | ||
val, oldVal: val, derive: f => state(f()), | ||
add, tags, state, derive: f => state(f()), | ||
html: (...args) => "<!DOCTYPE html>" + tags.html(...args).outerHTML, | ||
@@ -48,0 +46,0 @@ } |
@@ -9,10 +9,6 @@ export interface State<T> { | ||
export interface VanObj { | ||
readonly state: <T>(initVal: T) => State<T>; | ||
readonly val: <T>(s: T | StateView<T>) => T; | ||
readonly oldVal: <T>(s: T | StateView<T>) => T; | ||
readonly state: <T>(initVal?: T) => State<T>; | ||
readonly derive: <T>(f: () => T) => State<T>; | ||
readonly add: Function; | ||
readonly _: (f: () => PropValue) => () => PropValue; | ||
readonly tags: Record<string, Function>; | ||
readonly tagsNS: (namespaceURI: string) => Record<string, Function>; | ||
readonly tags: Record<string, Function> & ((namespaceURI: string) => Record<string, Function>); | ||
} |
@@ -27,10 +27,6 @@ export interface State<T> { | ||
export interface Van { | ||
readonly state: <T>(initVal: T) => State<T> | ||
readonly val: <T>(s: T | StateView<T>) => T | ||
readonly oldVal: <T>(s: T | StateView<T>) => T | ||
readonly state: <T>(initVal?: T) => State<T> | ||
readonly derive: <T>(f: () => T) => State<T> | ||
readonly add: (dom: Element, ...children: readonly ChildDom[]) => Element | ||
readonly _: (f: () => PropValue) => () => PropValue | ||
readonly tags: Readonly<Record<string, TagFunc>> | ||
readonly tagsNS: (namespaceURI: string) => Readonly<Record<string, TagFunc>> | ||
readonly tags: Readonly<Record<string, TagFunc>> & ((namespaceURI: string) => Readonly<Record<string, TagFunc>>) | ||
readonly html: (first?: Props | ChildDom, ...rest: readonly ChildDom[]) => string | ||
@@ -37,0 +33,0 @@ } |
@@ -30,3 +30,3 @@ /// <reference types="./van-plate.d.ts" /> | ||
const escapeAttr = v => v.replaceAll('"', """) | ||
const escapeAttr = v => v.replace(/"/g, """) | ||
@@ -39,8 +39,6 @@ const protoOf = Object.getPrototypeOf, funcProto = protoOf(protoOf), objProto = protoOf(noChild) | ||
const val = s => protoOf(s ?? 0) === stateProto ? s.val : s | ||
const plainValue = (v, k) => { | ||
let protoOfV = protoOf(v ?? 0) | ||
return protoOfV === stateProto ? v.val : | ||
protoOfV === funcProto && (!k?.startsWith("on") || v._isBindingFunc) ? v() : v | ||
protoOfV !== funcProto || k?.startsWith("on") ? v : v() | ||
} | ||
@@ -66,3 +64,3 @@ | ||
const tags = new Proxy((name, ...args) => { | ||
const tag = (name, ...args) => { | ||
const [props, ...children] = protoOf(args[0] ?? 0) === objProto ? args : [{}, ...args] | ||
@@ -78,4 +76,7 @@ const propsStr = Object.entries(props).map(([k, v]) => { | ||
children: children.flat(Infinity).filter(c => c != null)} | ||
}, { get: (tag, name) => tag.bind(null, name) }) | ||
} | ||
const handler = {get: (_, name) => tag.bind(null, name)} | ||
const tags = new Proxy(_ => new Proxy(tag, handler), handler) | ||
const add = (dom, ...children) => { | ||
@@ -87,4 +88,3 @@ dom.children.push(...children.flat(Infinity).filter(c => c != null)) | ||
export default { | ||
add, _: f => (f._isBindingFunc = 1, f), tags, tagsNS: () => tags, state, | ||
val, oldVal: val, derive: f => state(f()), | ||
add, tags, state, derive: f => state(f()), | ||
html: (...args) => { | ||
@@ -91,0 +91,0 @@ const buf = ["<!DOCTYPE html>"] |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
0
21513
204