mini-van-plate
Advanced tools
Comparing version 0.5.7 to 0.6.0-rc.0
{ | ||
"name": "mini-van-plate", | ||
"version": "0.5.7", | ||
"version": "0.6.0-rc.0", | ||
"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.6/src/van-plate.js" | ||
import van from "https://deno.land/x/minivan@0.5.7/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.6/src/mini-van.js" | ||
import van from "https://deno.land/x/minivan@0.5.7/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.6.min.js" | ||
import van from "https://cdn.jsdelivr.net/gh/vanjs-org/mini-van/public/mini-van-0.5.7.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.6.nomodule.min.js"></script> | ||
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/vanjs-org/mini-van/public/mini-van-0.5.7.nomodule.min.js"></script> | ||
``` | ||
Alternative, you can download the files ([`mini-van-0.5.6.min.js`](https://vanjs.org/autodownload?file=mini-van-0.5.6.min.js), [`mini-van-0.5.6.nomodule.min.js`](https://vanjs.org/autodownload?file=mini-van-0.5.6.nomodule.min.js)) and serve them locally. | ||
Alternative, you can download the files ([`mini-van-0.5.7.min.js`](https://vanjs.org/autodownload?file=mini-van-0.5.7.min.js), [`mini-van-0.5.7.nomodule.min.js`](https://vanjs.org/autodownload?file=mini-van-0.5.7.nomodule.min.js)) and serve them locally. | ||
@@ -253,0 +253,0 @@ You can find all relevant **Mini-Van** files in this [Download Table](https://vanjs.org/minivan#download-table). |
@@ -17,2 +17,25 @@ export interface State<T> { | ||
} | ||
export type StateOf<T> = { | ||
readonly [K in keyof T]: State<T[K]>; | ||
}; | ||
export type ValueType<T> = T extends (infer V)[] ? V : T[keyof T]; | ||
export type KeyType<T> = T extends unknown[] ? number : string; | ||
export type ReplacementFunc<T> = T extends (infer V)[] ? (items: V[]) => readonly V[] : (items: [string, T[keyof T]][]) => readonly [string, T[keyof T]][]; | ||
export interface VanXObj { | ||
readonly calc: <R>(f: () => R) => R; | ||
readonly reactive: <T extends object>(obj: T) => T; | ||
readonly noreactive: <T extends object>(obj: T) => T; | ||
readonly stateFields: <T extends object>(obj: T) => StateOf<T>; | ||
readonly raw: <T extends object>(obj: T) => T; | ||
readonly list: <T extends object, ElementType>(container: (() => ElementType) | ElementType, items: T, itemFunc: (v: State<ValueType<T>>, deleter: () => void, k: KeyType<T>) => any) => ElementType; | ||
readonly replace: <T extends object>(obj: T, replacement: ReplacementFunc<T> | T) => T; | ||
readonly compact: <T extends object>(obj: T) => T; | ||
} | ||
export interface EnvObj { | ||
readonly van: VanObj; | ||
readonly vanX: VanXObj; | ||
} | ||
export declare const env: EnvObj; | ||
export declare const registerEnv: (input: Partial<EnvObj>) => void; | ||
export declare const dummyVanX: VanXObj; | ||
export {}; |
@@ -1,1 +0,29 @@ | ||
export {}; | ||
export const env = {}; | ||
export const registerEnv = (input) => { | ||
if (input.van) | ||
env.van = input.van; | ||
if (input.vanX) | ||
env.vanX = input.vanX; | ||
}; | ||
export const dummyVanX = { | ||
calc: f => f(), | ||
reactive: obj => obj, | ||
noreactive: obj => obj, | ||
stateFields: (obj) => { | ||
const states = Array.isArray(obj) ? [] : { __proto__: Object.getPrototypeOf(obj) }; | ||
for (const [k, v] of Object.entries(obj)) | ||
states[k] = env.van.state(v); | ||
return states; | ||
}, | ||
raw: obj => obj, | ||
list: (container, items, itemFunc) => { | ||
if (container instanceof Function) | ||
container = container(); | ||
const isArray = Array.isArray(items); | ||
for (const [k, v] of Object.entries(items)) | ||
env.van.add(container, itemFunc(v, () => { }, (isArray ? Number(k) : k))); | ||
return container; | ||
}, | ||
replace: obj => obj, | ||
compact: obj => obj, | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24073
267