Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F9583481
index.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
index.ts
View Options
import
{
tempstream
}
from
"tempstream"
;
import
{
JDDContext
}
from
"./jdd-context"
;
import
{
Registry
}
from
"./registry"
;
export
*
from
"./component"
;
export
*
from
"./component-arguments/component-argument"
;
export
*
as
ComponentArguments
from
"./component-arguments/component-arguments"
;
export
*
from
"./component-arguments/component-arguments"
;
// exporting this also as root elements to make it easier to auto-import those
export
*
from
"./jdd-context"
;
export
*
from
"./registry"
;
export
{
insert_nbsp
}
from
"./utils/insert_nbsp"
;
export
type
JDDocument
=
Array
<
{
component_name
:
string
;
args
:
Record
<
string
,
unknown
>
;
}
>
;
export
function
countWords
(
registry
:
Registry
,
document
:
JDDocument
)
:
number
{
return
document
.
reduce
((
acc
,
{
component_name
,
args
})
=>
{
const
component
=
registry
.
get
(
component_name
);
if
(
!
component
)
{
console
.
warn
(
"Component not found in the registry: "
+
component_name
);
return
acc
+
0
;
}
return
acc
+
component
.
countWords
(
args
);
},
0
);
}
export
function
render
(
registry
:
Registry
,
document
:
JDDocument
,
context
:
JDDContext
)
{
return
tempstream
`
${
document
.
map
(({
component_name
,
args
}
) => {
const component = registry.get(component_name);
if (!component) {
console.warn(
"Component not found in the registry: " + component_name
);
return "";
}
for (const arg_name in component?.getArguments()) {
if (!Object.prototype.hasOwnProperty.call(args, arg_name)) {
args[arg_name] = component
?.getArguments()
[arg_name]?.getEmptyValue();
}
}
return component.toHTML(args, context);
})}`
;
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Sat, Oct 11, 09:50 (12 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
984158
Default Alt Text
index.ts (1 KB)
Attached To
Mode
rJDD jdd
Attached
Detach File
Event Timeline
Log In to Comment