Comparing version 0.9.11 to 0.9.12
{ | ||
"name": "aurumjs", | ||
"version": "0.9.11", | ||
"version": "0.9.12", | ||
"main": "prebuilt/esnext/aurumjs.js", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -7,3 +7,5 @@ export * from './rendering/webcomponent.js'; | ||
export { TextAreaProps } from './nodes/textarea.js'; | ||
export * from './nodes/string_adapter.js'; | ||
export { aurumToHTML } from './builtin_components/dom_adapter.js'; | ||
export { aurumToString, AurumStringAdapterConfig } from './nodes/string_adapter.js'; | ||
export { aurumToVDOM, VDOM, VDOMNode } from './nodes/vdom_adapter.js'; | ||
export * from './builtin_components/router.js'; | ||
@@ -31,3 +33,2 @@ export * from './builtin_components/suspense.js'; | ||
export * from './utilities/iteration.js'; | ||
export { aurumToHTML } from './builtin_components/dom_adapter.js'; | ||
export { debugMode, enableDebugMode, enableDiagnosticMode } from './debug_mode.js'; | ||
@@ -34,0 +35,0 @@ export { AttributeValue, ClassType, StyleType, DataDrain, StringSource } from './utilities/common.js'; |
export * from './rendering/webcomponent.js'; | ||
export { SingularAurumElement, ArrayAurumElement, createAPI, createLifeCycle, createRenderSession, AurumElement, aurumElementModelIdentitiy } from './rendering/aurum_element.js'; | ||
export * from './nodes/string_adapter.js'; | ||
export { aurumToHTML } from './builtin_components/dom_adapter.js'; | ||
export { aurumToString } from './nodes/string_adapter.js'; | ||
export { aurumToVDOM, VDOM } from './nodes/vdom_adapter.js'; | ||
export * from './builtin_components/router.js'; | ||
@@ -26,5 +28,4 @@ export * from './builtin_components/suspense.js'; | ||
export * from './utilities/iteration.js'; | ||
export { aurumToHTML } from './builtin_components/dom_adapter.js'; | ||
export { debugMode, enableDebugMode, enableDiagnosticMode } from './debug_mode.js'; | ||
export { RemoteProtocol, getRemoteFunction } from './aurum_server/aurum_server_client.js'; | ||
//# sourceMappingURL=aurumjs.js.map |
@@ -1,4 +0,4 @@ | ||
import { ClassType, DataDrain, Callback, MapLike, AttributeValue, StyleType } from '../utilities/common.js'; | ||
import { Renderable, AurumComponentAPI } from '../rendering/aurum_element.js'; | ||
import { AurumComponentAPI, Renderable } from '../rendering/aurum_element.js'; | ||
import { CancellationToken } from '../utilities/cancellation_token.js'; | ||
import { AttributeValue, Callback, ClassType, DataDrain, MapLike, StyleType } from '../utilities/common.js'; | ||
export interface HTMLNodeProps<T> { | ||
@@ -5,0 +5,0 @@ id?: AttributeValue; |
@@ -1,6 +0,6 @@ | ||
import { ArrayDataSource, DataSource, MapDataSource } from '../stream/data_source.js'; | ||
import { handleClass, handleStyle } from '../nodes/rendering_helpers.js'; | ||
import { AurumElement, createRenderSession, renderInternal } from '../rendering/aurum_element.js'; | ||
import { DataSource } from '../stream/data_source.js'; | ||
import { dsUnique } from '../stream/data_source_operators.js'; | ||
import { DuplexDataSource } from '../stream/duplex_data_source.js'; | ||
import { AurumElement, renderInternal, createRenderSession } from '../rendering/aurum_element.js'; | ||
import { dsUnique } from '../stream/data_source_operators.js'; | ||
import { aurumClassName, camelCaseToKebabCase } from '../utilities/classname.js'; | ||
/** | ||
@@ -104,6 +104,22 @@ * @internal | ||
if (props.style) { | ||
handleStyle(node, props.style, cleanUp); | ||
const result = handleStyle(props.style, cleanUp); | ||
if (result instanceof DataSource) { | ||
result.listenAndRepeat((v) => { | ||
node.setAttribute('style', v); | ||
}, cleanUp); | ||
} | ||
else { | ||
node.setAttribute('style', result); | ||
} | ||
} | ||
if (props.class) { | ||
handleClass(node, props.class, cleanUp); | ||
const result = handleClass(props.class, cleanUp); | ||
if (result instanceof DataSource) { | ||
result.listenAndRepeat((v) => { | ||
node.className = v; | ||
}, cleanUp); | ||
} | ||
else { | ||
node.className = result; | ||
} | ||
} | ||
@@ -197,114 +213,2 @@ } | ||
} | ||
function handleClass(node, data, cleanUp) { | ||
if (typeof data === 'string') { | ||
node.className = data; | ||
} | ||
else if (data instanceof DataSource || data instanceof DuplexDataSource) { | ||
data.transform(dsUnique(), cleanUp) | ||
.withInitial(data.value) | ||
.listenAndRepeat((v) => { | ||
if (Array.isArray(v)) { | ||
node.className = v.join(' '); | ||
} | ||
else { | ||
node.className = v; | ||
} | ||
}); | ||
} | ||
else if (data instanceof ArrayDataSource) { | ||
const value = data.reduce((p, c) => `${p} ${c}`, '', cleanUp); | ||
node.className = value.value; | ||
value.listen((v) => { | ||
node.className = v; | ||
}, cleanUp); | ||
} | ||
else if (data instanceof MapDataSource || (typeof data === 'object' && !Array.isArray(data))) { | ||
//@ts-ignore | ||
const result = aurumClassName(data, cleanUp); | ||
return handleClass(node, result, cleanUp); | ||
} | ||
else { | ||
const value = data.reduce((p, c) => { | ||
if (!c) { | ||
return p; | ||
} | ||
if (typeof c === 'string') { | ||
return `${p} ${c}`; | ||
} | ||
else { | ||
if (c.value) { | ||
return `${p} ${c.value}`; | ||
} | ||
else { | ||
return p; | ||
} | ||
} | ||
}, ''); | ||
node.className = value; | ||
for (const i of data) { | ||
if (i instanceof DataSource) { | ||
i.transform(dsUnique(), cleanUp).listen((v) => { | ||
const value = data.reduce((p, c) => { | ||
if (typeof c === 'string') { | ||
return `${p} ${c}`; | ||
} | ||
else { | ||
if (c.value) { | ||
return `${p} ${c.value}`; | ||
} | ||
else { | ||
return p; | ||
} | ||
} | ||
}, ''); | ||
node.className = value; | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
function handleStyle(node, data, cleanUp) { | ||
if (typeof data === 'string') { | ||
node.style.cssText = data; | ||
} | ||
else if (data instanceof DataSource || data instanceof DuplexDataSource) { | ||
if (typeof data.value === 'string') { | ||
node.setAttribute('style', data.value); | ||
} | ||
data.transform(dsUnique(), cleanUp).listen((v) => { | ||
if (typeof v === 'string') { | ||
node.setAttribute('style', v); | ||
} | ||
}); | ||
} | ||
else if (data instanceof MapDataSource) { | ||
const ds = data.toEntriesArrayDataSource(cleanUp).reduce((p, c) => { | ||
return `${p}${camelCaseToKebabCase(c[0])}:${c[1]};`; | ||
}, '', cleanUp); | ||
ds.listenAndRepeat((v) => { | ||
node.setAttribute('style', v); | ||
}, cleanUp); | ||
} | ||
else if (typeof data === 'object' && !Array.isArray(data)) { | ||
const result = new ArrayDataSource(); | ||
let index = 0; | ||
for (const i in data) { | ||
if (data[i] instanceof DataSource) { | ||
const myIndex = index; | ||
result.push([i, data[i].value]); | ||
data[i].listen((v) => { | ||
result.set(myIndex, [i, v]); | ||
}, cleanUp); | ||
} | ||
else { | ||
result.push([i, data[i]]); | ||
} | ||
index++; | ||
} | ||
const ds = result.reduce((p, c) => `${p}${camelCaseToKebabCase(c[0])}:${c[1]};`, '', cleanUp); | ||
ds.listenAndRepeat((v) => { | ||
node.setAttribute('style', v); | ||
}, cleanUp); | ||
} | ||
} | ||
//# sourceMappingURL=dom_adapter.js.map |
@@ -0,1 +1,2 @@ | ||
import { Renderable } from '../rendering/aurum_element.js'; | ||
export interface AurumStringAdapterConfig { | ||
@@ -7,3 +8,3 @@ attributeBlacklist?: string[]; | ||
} | ||
export declare function aurumToString(content: any, config?: AurumStringAdapterConfig): Promise<string>; | ||
export declare function aurumToString(content: Renderable | Renderable[], config?: AurumStringAdapterConfig): Promise<string>; | ||
//# sourceMappingURL=string_adapter.d.ts.map |
@@ -74,4 +74,7 @@ export * from './rendering/webcomponent.js'; | ||
export { TextAreaProps } from './nodes/textarea.js'; | ||
export * from './nodes/string_adapter.js'; | ||
export { aurumToHTML } from './builtin_components/dom_adapter.js'; | ||
export { aurumToString, AurumStringAdapterConfig } from './nodes/string_adapter.js'; | ||
export { aurumToVDOM, VDOM, VDOMNode } from './nodes/vdom_adapter.js'; | ||
export * from './builtin_components/router.js'; | ||
@@ -101,5 +104,4 @@ export * from './builtin_components/suspense.js'; | ||
export { aurumToHTML } from './builtin_components/dom_adapter.js'; | ||
export { debugMode, enableDebugMode, enableDiagnosticMode } from './debug_mode.js'; | ||
export { AttributeValue, ClassType, StyleType, DataDrain, StringSource } from './utilities/common.js'; | ||
export { RemoteProtocol, getRemoteFunction } from './aurum_server/aurum_server_client.js'; |
@@ -1,8 +0,8 @@ | ||
import { StringSource, ClassType, DataDrain, Callback, MapLike, AttributeValue, StyleType } from '../utilities/common.js'; | ||
import { ArrayDataSource, DataSource, MapDataSource, ReadOnlyDataSource } from '../stream/data_source.js'; | ||
import { handleClass, handleStyle } from '../nodes/rendering_helpers.js'; | ||
import { AurumComponentAPI, AurumElement, createRenderSession, Renderable, Rendered, renderInternal } from '../rendering/aurum_element.js'; | ||
import { DataSource } from '../stream/data_source.js'; | ||
import { dsUnique } from '../stream/data_source_operators.js'; | ||
import { DuplexDataSource } from '../stream/duplex_data_source.js'; | ||
import { Renderable, AurumComponentAPI, AurumElement, Rendered, renderInternal, createRenderSession } from '../rendering/aurum_element.js'; | ||
import { CancellationToken } from '../utilities/cancellation_token.js'; | ||
import { dsUnique } from '../stream/data_source_operators.js'; | ||
import { aurumClassName, camelCaseToKebabCase } from '../utilities/classname.js'; | ||
import { AttributeValue, Callback, ClassType, DataDrain, MapLike, StringSource, StyleType } from '../utilities/common.js'; | ||
@@ -167,7 +167,21 @@ export interface HTMLNodeProps<T> { | ||
if (props.style) { | ||
handleStyle(node, props.style, cleanUp); | ||
const result = handleStyle(props.style, cleanUp); | ||
if (result instanceof DataSource) { | ||
result.listenAndRepeat((v) => { | ||
node.setAttribute('style', v); | ||
}, cleanUp); | ||
} else { | ||
node.setAttribute('style', result); | ||
} | ||
} | ||
if (props.class) { | ||
handleClass(node, props.class, cleanUp); | ||
const result = handleClass(props.class, cleanUp); | ||
if (result instanceof DataSource) { | ||
result.listenAndRepeat((v) => { | ||
node.className = v; | ||
}, cleanUp); | ||
} else { | ||
node.className = result; | ||
} | ||
} | ||
@@ -259,106 +273,1 @@ } | ||
} | ||
function handleClass(node: HTMLElement, data: ClassType, cleanUp: CancellationToken) { | ||
if (typeof data === 'string') { | ||
node.className = data; | ||
} else if (data instanceof DataSource || data instanceof DuplexDataSource) { | ||
data.transform(dsUnique(), cleanUp) | ||
.withInitial(data.value) | ||
.listenAndRepeat((v) => { | ||
if (Array.isArray(v)) { | ||
node.className = v.join(' '); | ||
} else { | ||
node.className = v; | ||
} | ||
}); | ||
} else if (data instanceof ArrayDataSource) { | ||
const value: DataSource<string> = data.reduce<string>((p, c) => `${p} ${c}`, '', cleanUp); | ||
node.className = value.value; | ||
value.listen((v) => { | ||
node.className = v; | ||
}, cleanUp); | ||
} else if (data instanceof MapDataSource || (typeof data === 'object' && !Array.isArray(data))) { | ||
//@ts-ignore | ||
const result = aurumClassName(data, cleanUp); | ||
return handleClass(node, result, cleanUp); | ||
} else { | ||
const value: string = (data as Array<string | ReadOnlyDataSource<string>>).reduce<string>((p, c) => { | ||
if (!c) { | ||
return p; | ||
} | ||
if (typeof c === 'string') { | ||
return `${p} ${c}`; | ||
} else { | ||
if (c.value) { | ||
return `${p} ${c.value}`; | ||
} else { | ||
return p; | ||
} | ||
} | ||
}, ''); | ||
node.className = value; | ||
for (const i of data as Array<string | ReadOnlyDataSource<string>>) { | ||
if (i instanceof DataSource) { | ||
i.transform(dsUnique(), cleanUp).listen((v) => { | ||
const value: string = (data as Array<string | ReadOnlyDataSource<string>>).reduce<string>((p, c) => { | ||
if (typeof c === 'string') { | ||
return `${p} ${c}`; | ||
} else { | ||
if (c.value) { | ||
return `${p} ${c.value}`; | ||
} else { | ||
return p; | ||
} | ||
} | ||
}, ''); | ||
node.className = value; | ||
}); | ||
} | ||
} | ||
} | ||
} | ||
function handleStyle(node: HTMLElement, data: StyleType, cleanUp: CancellationToken) { | ||
if (typeof data === 'string') { | ||
node.style.cssText = data; | ||
} else if (data instanceof DataSource || data instanceof DuplexDataSource) { | ||
if (typeof data.value === 'string') { | ||
node.setAttribute('style', data.value); | ||
} | ||
data.transform(dsUnique(), cleanUp).listen((v) => { | ||
if (typeof v === 'string') { | ||
node.setAttribute('style', v); | ||
} | ||
}); | ||
} else if (data instanceof MapDataSource) { | ||
const ds = data.toEntriesArrayDataSource(cleanUp).reduce<string>( | ||
(p, c) => { | ||
return `${p}${camelCaseToKebabCase(c[0])}:${c[1]};`; | ||
}, | ||
'', | ||
cleanUp | ||
); | ||
ds.listenAndRepeat((v) => { | ||
node.setAttribute('style', v); | ||
}, cleanUp); | ||
} else if (typeof data === 'object' && !Array.isArray(data)) { | ||
const result = new ArrayDataSource<[string, string]>(); | ||
let index = 0; | ||
for (const i in data) { | ||
if (data[i] instanceof DataSource) { | ||
const myIndex = index; | ||
result.push([i, data[i].value]); | ||
(data[i] as ReadOnlyDataSource<string>).listen((v) => { | ||
result.set(myIndex, [i, v]); | ||
}, cleanUp); | ||
} else { | ||
result.push([i, data[i]]); | ||
} | ||
index++; | ||
} | ||
const ds = result.reduce<string>((p, c) => `${p}${camelCaseToKebabCase(c[0])}:${c[1]};`, '', cleanUp); | ||
ds.listenAndRepeat((v) => { | ||
node.setAttribute('style', v); | ||
}, cleanUp); | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { AurumElementModel, createAPI } from '../rendering/aurum_element.js'; | ||
import { AurumElementModel, createAPI, Renderable } from '../rendering/aurum_element.js'; | ||
import { ArrayDataSource, DataSource } from '../stream/data_source.js'; | ||
@@ -13,3 +13,3 @@ import { DuplexDataSource } from '../stream/duplex_data_source.js'; | ||
export async function aurumToString(content: any, config: AurumStringAdapterConfig = {}): Promise<string> { | ||
export async function aurumToString(content: Renderable | Renderable[], config: AurumStringAdapterConfig = {}): Promise<string> { | ||
if (content === undefined || content === null) { | ||
@@ -16,0 +16,0 @@ return ''; |
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 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
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
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
2553238
214
38932