Skip to content

Commit 78841b5

Browse files
committed
experimenting with callable nodes
1 parent 109106c commit 78841b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1222
-326
lines changed

dist/index.core.esm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.core.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ export { methodstrings } from './src/loaders/methodstrings';
66
export * from './src/services/Service';
77
export * from './src/services/remote/remote.routes';
88
export * from './src/services/ecs/ECS.service';
9+
export { html, xml } from './src/loaders/html/html';
910
export * from './src/loaders/html/html.loader';
10-
export { DOMElement, addCustomElement, html } from './src/loaders/html/DOMElement';
11+
export { DOMElement, addCustomElement } from './src/loaders/html/DOMElement';
1112
export * from './src/loaders/html/wc.loader';
1213
export * from './src/services/e2ee/E2EE.service';
1314
export * from './src/services/http/HTTP.browser';

dist/index.esm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.node.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/src/core/Graph.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ export type Listener = {
6464
subInput?: boolean;
6565
onchange: Function;
6666
};
67-
export declare class GraphNode {
67+
export declare class Callable extends Function {
68+
__bound: Callable;
69+
__call: ((...args: any[]) => any);
70+
[key: string]: any;
71+
constructor();
72+
}
73+
export declare class GraphNode extends Callable {
6874
__node: {
6975
tag: string;
7076
unique: string;

dist/src/loaders/html/DOMElement.d.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,19 @@ export function parseFunctionFromText(method: any): any;
44
export class DOMElement extends HTMLElement {
55
static get tag(): string;
66
static addElement(tag?: string, cls?: typeof DOMElement, extend?: any): void;
7-
template: (self: any, props: any) => string;
8-
props: {};
97
useShadow: boolean;
10-
styles: any;
11-
oncreate: any;
12-
onresize: any;
13-
ondelete: any;
14-
onchanged: any;
15-
renderonchanged: boolean;
168
FRAGMENT: any;
179
STYLE: any;
1810
attachedShadow: boolean;
1911
obsAttributes: string[];
20-
get observedAttributes(): string[];
12+
props: {};
2113
attributeChangedCallback: (name: any, old: any, val: any) => void;
14+
onchanged: any;
2215
ONRESIZE: ((ev: any) => void) | ((ev: any) => void);
16+
ondelete: (() => void) | ((props?: {}) => void);
17+
oncreate: any;
18+
renderonchanged: number;
19+
template: any;
2320
connectedCallback(): void;
2421
delete: () => void;
2522
render: (props?: {}) => void;

dist/src/loaders/html/html.d.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
export declare function html(strings: TemplateStringsArray, ...args: any[]): (elm?: HTMLElement) => HTMLElement | DocumentFragment;
2+
/**
3+
*
4+
* let htmlfunction = html`<span></span>` //e.g. some html
5+
* htmlfunction(document.body); //append the template string to the desired element, or just return the prepared template element
6+
*
7+
* Syntax highlighting with lit-html plugin: https://open-vsx.org/extension/meganrogge/template-string-converter
8+
9+
// Example usage of the html function
10+
document.addEventListener("DOMContentLoaded", () => {
11+
const app = document.getElementById('app');
12+
13+
const title = document.createElement('h1');
14+
title.textContent = "Welcome to HTML Function Test";
15+
16+
const paragraph = document.createElement('p');
17+
paragraph.textContent = "This is a paragraph element created using native DOM API.";
18+
19+
// Creating HTML structure using the html function
20+
const content = html`
21+
<div>
22+
<h2>This is a test</h2>
23+
${title}
24+
<p>This is a paragraph element created using the html function.</p>
25+
${paragraph}
26+
</div>
27+
`();
28+
29+
app.appendChild(content);
30+
});
31+
32+
*/
33+
export declare function xml(strings: TemplateStringsArray, ...args: any[]): (elm?: Node, namespace?: string) => string;
34+
/** Test:
35+
*
36+
*
37+
const testXmlFunction = () => {
38+
const namespace = "http://www.example.com/test";
39+
const resultContainer = document.createElement('div');
40+
41+
const testElement = document.createElementNS(namespace, 'testElement');
42+
testElement.textContent = "Test Content";
43+
44+
const xmlAppender = xml`Hello, ${'World'}! This is a ${testElement}.`;
45+
const xmlString = xmlAppender(resultContainer, namespace);
46+
47+
resultContainer.innerHTML += `<pre>${xmlString}</pre>`;
48+
49+
console.log(xmlString);
50+
document.body.appendChild(resultContainer);
51+
};
52+
53+
testXmlFunction();
54+
*
55+
*
56+
*/

dist/src/loaders/index.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ export declare const animate: (node: GraphNode, parent: GraphNode | Graph, graph
3636
*
3737
* nodeA.__listeners['nodeB.x'] = {
3838
* callback:(result)=>void,
39-
* branch:{if:Function|any, then:Function|any|GraphNode}
39+
* branch:{
40+
* if:Function|any, //if a function using the result evaluates to true or if the value equals the if value
41+
* then:Function|any|GraphNode //call a function, return a different result, or call a node
42+
* }
4043
* }
4144
*
4245
*/

0 commit comments

Comments
 (0)