Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F3010079
image.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
image.ts
View Options
import
{
JDDContext
}
from
"../index.js"
;
import
{
File
as
FileArgument
}
from
"./file.js"
;
import
{
FilePointer
}
from
"@sealcode/file-manager"
;
import
_locreq
from
"locreq"
;
import
{
module_dirname
}
from
"../utils/module-dirname.js"
;
const
locreq
=
_locreq
(
module_dirname
(
import
.
meta
.
url
));
const
default_example_images
:
Record
<
string
,
FilePointer
|
null
>
=
Object
.
fromEntries
(
[
"image1.jpg"
,
"image3.jpg"
,
"image4.jpg"
,
"image5.jpg"
].
map
((
key
)
=>
[
locreq
.
resolve
(
`resources/
${
key
}
`
),
null
,
])
);
export
class
Image
extends
FileArgument
{
private
example_images
=
default_example_images
;
getTypeName
()
{
return
"image"
;
}
setExampleImages
(
paths
:
string
[])
{
this
.
example_images
=
Object
.
fromEntries
(
paths
.
map
((
path
)
=>
[
path
,
null
])
);
return
this
;
}
async
getExampleValue
(
context
:
JDDContext
)
{
const
keys
=
Object
.
keys
(
this
.
example_images
);
const
key
=
keys
[
Math
.
floor
(
Math
.
random
()
*
keys
.
length
)];
if
(
!
this
.
example_images
[
key
])
{
const
file
=
context
.
file_manager
.
fromPath
(
key
);
this
.
example_images
[
key
]
=
file
;
await
file
.
save
(
false
);
}
return
this
.
example_images
[
key
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Wed, May 7, 19:36 (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
626020
Default Alt Text
image.ts (1 KB)
Attached To
Mode
rJDD jdd
Attached
Detach File
Event Timeline
Log In to Comment