albio
Advanced tools
Comparing version 1.0.47 to 1.0.48
20
index.js
@@ -15,4 +15,4 @@ 'use strict'; | ||
function $$checkDirtyDeps(dirt, deps) { | ||
if (dirt.length === 0) return false; | ||
return dirt.some((key) => deps.indexOf(key) > -1); | ||
if (!dirt.size) return false; | ||
return [...dirt].some((key) => deps.indexOf(key) > -1); | ||
} | ||
@@ -40,9 +40,13 @@ | ||
function $$invalidate(dirty, names, ret, update) { | ||
let dependencies = new Set(); | ||
function $$invalidate( | ||
dirty, | ||
names, | ||
ret, | ||
update, | ||
) { | ||
const toDirty = names.split(','); | ||
toDirty.forEach((name) => dependencies.add(name)); | ||
[...dependencies].forEach((dependency) => dirty.push(dependency)); | ||
scheduleUpdate(update); | ||
toDirty.forEach((name) => dirty.add(name)); | ||
scheduleUpdate(() => { | ||
return update(dirty); | ||
}); | ||
return ret; | ||
@@ -49,0 +53,0 @@ } |
@@ -19,4 +19,4 @@ 'use strict'; | ||
function $$checkDirtyDeps(dirt, deps) { | ||
if (dirt.length === 0) return false; | ||
return dirt.some((key) => deps.indexOf(key) > -1); | ||
if (!dirt.size) return false; | ||
return [...dirt].some((key) => deps.indexOf(key) > -1); | ||
} | ||
@@ -44,9 +44,13 @@ | ||
function $$invalidate(dirty, names, ret, update) { | ||
let dependencies = new Set(); | ||
function $$invalidate( | ||
dirty, | ||
names, | ||
ret, | ||
update, | ||
) { | ||
const toDirty = names.split(','); | ||
toDirty.forEach((name) => dependencies.add(name)); | ||
[...dependencies].forEach((dependency) => dirty.push(dependency)); | ||
scheduleUpdate(update); | ||
toDirty.forEach((name) => dirty.add(name)); | ||
scheduleUpdate(() => { | ||
return update(dirty); | ||
}); | ||
return ret; | ||
@@ -53,0 +57,0 @@ } |
{ | ||
"name": "albio", | ||
"version": "1.0.47", | ||
"version": "1.0.48", | ||
"description": "🚀 Tiny compiler-powered reactivity library for sensible web apps", | ||
@@ -5,0 +5,0 @@ "main": "index", |
import { type ASTNode, Binding, Listener, Props } from './interfaces'; | ||
import { Node, Statement } from 'estree'; | ||
import Component from './components/Component'; | ||
interface CompilerParams { | ||
@@ -9,2 +10,3 @@ nodes: ASTNode[]; | ||
residuals?: Node[]; | ||
blocks?: Component[]; | ||
} | ||
@@ -21,2 +23,3 @@ export default class Compiler { | ||
residuals: Node[]; | ||
blocks: Component[]; | ||
ast: Node[]; | ||
@@ -23,0 +26,0 @@ constructor(parsed: CompilerParams); |
@@ -1,9 +0,12 @@ | ||
import { ChildNode } from 'domhandler'; | ||
import { Block, type BlockType } from '../interfaces'; | ||
export default class Component { | ||
type: BlockType; | ||
startNode: ChildNode; | ||
endNode: ChildNode; | ||
chunk: ChildNode[]; | ||
constructor(block: Block); | ||
import { ASTNode, Binding, Listener } from '../interfaces'; | ||
import { CompilerParams } from '../interfaces'; | ||
export default abstract class Component { | ||
allEntities: ASTNode[]; | ||
rootEntities: ASTNode[]; | ||
childEntities: ASTNode[]; | ||
bindings: Binding[]; | ||
listeners: Listener[]; | ||
identifiers: string[]; | ||
constructor(parsed: CompilerParams); | ||
abstract populateDeps(...args: any): void; | ||
} |
@@ -1,15 +0,21 @@ | ||
import { EachBlock } from '../interfaces'; | ||
import Component from './Component'; | ||
import { ASTNode, Binding, EachBlock, IterableKey } from '../interfaces'; | ||
import { Node } from 'estree'; | ||
interface IterableKey { | ||
name: string; | ||
variableRef: string; | ||
} | ||
export default class EachBlockComponent extends Component { | ||
identifier: string; | ||
import BlockComponent from './Block'; | ||
export default class EachBlockComponent extends BlockComponent { | ||
tag: string; | ||
iterable: string; | ||
keys: IterableKey[]; | ||
vars: { | ||
block_arr_name: string; | ||
create_func_name: string; | ||
}; | ||
constructor(block: EachBlock); | ||
render_each_block(): Node; | ||
render_each_for(node: Node | Node[]): Node[]; | ||
render_each_populate(): Node; | ||
render_each_create(): Node; | ||
render_each_mount(nodes: ASTNode[], identifiers: string[]): Node; | ||
render_each_update(nodes: ASTNode[], identifiers: string[]): Node[]; | ||
render_each_current(): Node; | ||
render(): Node; | ||
populateDeps(bindings: Binding[], keys: IterableKey[], iterable: string): void; | ||
} | ||
export {}; |
export * from './parse/index'; | ||
export { default as Compiler } from './compile'; | ||
export * from './components/index'; | ||
export { default as Renderer } from './render'; | ||
export { type ChildNode, type ParentNode, Element, Text, Comment } from 'domhandler'; |
@@ -1,3 +0,6 @@ | ||
import { ChildNode } from 'domhandler'; | ||
import { AnyNode } from 'domhandler'; | ||
import { Node, Statement } from 'estree'; | ||
import { Component } from './components'; | ||
export type ASTNode = BaseNode | TextTag | ElementTag | Binding | CommentTag; | ||
export type BlockType = 'each' | 'if' | 'else'; | ||
/** | ||
@@ -14,12 +17,13 @@ * Maybe include start and end location in parsing instead of index so that you can incorporate blocks | ||
children?: ASTNode[]; | ||
next?: ASTNode; | ||
prev?: ASTNode; | ||
startIndex: number | null; | ||
endIndex: number | null; | ||
} | ||
export type BlockType = 'each' | 'if' | 'else'; | ||
export interface Block { | ||
index: number; | ||
nodeType: BlockType; | ||
startNode: ChildNode; | ||
endNode: ChildNode | null; | ||
chunk: ChildNode[]; | ||
startNode: AnyNode; | ||
endNode: AnyNode | null; | ||
chunk: AnyNode[]; | ||
} | ||
@@ -55,4 +59,2 @@ export interface EachBlock extends Block { | ||
deps: string[]; | ||
startIndex: undefined; | ||
endIndex: undefined; | ||
} | ||
@@ -67,2 +69,14 @@ export interface Props { | ||
} | ||
export interface CompilerParams { | ||
nodes: ASTNode[]; | ||
listeners: Listener[]; | ||
props?: Props; | ||
reactives?: Statement[]; | ||
residuals?: Node[]; | ||
blocks?: Component[]; | ||
} | ||
export interface IterableKey { | ||
name: string; | ||
variableRef: string; | ||
} | ||
export {}; |
@@ -6,3 +6,3 @@ import { Listener, type ASTNode } from '../interfaces'; | ||
export declare function addText(nodes: ASTNode[], index: number, value: string, tag: Text, parent?: ASTNode): number; | ||
export declare function addBinding(nodes: ASTNode[], index: number, data: string, parent?: ASTNode): number; | ||
export declare function addBinding(nodes: ASTNode[], index: number, data: string, tag: AnyNode, parent?: ASTNode): number; | ||
export declare function parseElement(nodes: ASTNode[], listeners: Listener[], index: number, tag: Element, parent?: ASTNode): number; | ||
@@ -9,0 +9,0 @@ export declare function parseComment(nodes: ASTNode[], index: number, tag: Comment, parent?: ASTNode): number; |
@@ -6,4 +6,3 @@ import { Node, Identifier } from 'estree'; | ||
export declare function destringify(str: string): string; | ||
export declare function generateNodeStr(identifiers: string[], node: ASTNode): string; | ||
export declare function generateAttrStr(identifiers: string[], node: ASTNode): string[]; | ||
export declare function createUniqueName(func: string): string; | ||
export declare function generateNodeStr(identifiers: string[], node: ASTNode): Node[]; | ||
export declare function generateAttrStr(identifiers: string[], node: ASTNode): Node[]; |
export declare function $$element(node: any): any; | ||
export declare function $$setData(text: Text, data: any): void; | ||
export declare function $$text(data: any): Text; | ||
export declare function $$checkDirtyDeps(dirt: string[], deps: string[]): boolean; | ||
export declare function $$checkDirtyDeps(dirt: Set<string>, deps: string[]): boolean; |
@@ -1,1 +0,1 @@ | ||
export declare function $$invalidate(dirty: string[], names: string, ret: any, update: () => void): any; | ||
export declare function $$invalidate(dirty: Set<string>, names: string, ret: any, update: (...args: any) => void): any; |
Sorry, the diff of this file is too big to display
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
3845802
34
32963