@discoveryjs/discovery
Advanced tools
Changelog
1.0.0-beta.93 (06-02-2025)
navbuttons.uploadFromClipboard
buttonmarks
option for source
view, which allows injecting visual or text marks at specific points in the source textrefs
option in the source
view to ranges
type
field of entries in the ranges
option (previously refs
) to be optional. If the href
field is specified, the type
value defaults to link
; otherwise, it defaults to span
instead of spotlight
. The spotlight
type is now replaced by span
source
viewstruct
view to avoid auto expading numeric arraysChangelog
1.0.0-beta.92 (18-12-2024)
unloadData
event when modelfree
extension is usedsignature
view, similar to struct
viewactionCopySource
option to source
view to customise behaviour of "copy to clipboard" buttonsource
view when a string is passed as datamarkdown
views to correctly set target="_blank"
for links when the href
attribute contains an interpolated valuesource
view props into nested views rendering (action buttons, prelude, and postlude) through the context as sourceViewProps
struct
, signature
and source
views to relay on root settingsCmd+Click
or Ctrl+Click
in inspect mode to open hovered view page in view's showcasecomputeClassName()
and applyComputedClassName()
methods to view render context API--discovery-monospace-font-size
and --discovery-monospace-line-height
!anchor
is now treated as pageAnchor
. Previously, !anchor
was included in pageParams
, now it’s a separate value with its own property and event on the ViewModel
instancepageStateChange
event to no longer fire when !anchor
in the page hash changes, meaning ViewModel
will not initiate a render on !anchor
hash parameter changes!anchor
from ViewModel#pageParams
ViewModel#pageAnchor
to store the page’s anchor value (!anchor
) or null
pageAnchorChange
event for ViewModel
, which fires when pageAnchor
changesModel#encodePageHash()
to accept pageAnchor
as the 4th parameterModel#decodePageHash()
to return pageAnchor
ViewModel#setPage()
and ViewModel#setParams()
to reset the anchor (pageAnchor
) since pageParams
can hold !anchor
anymoreViewModel#setPageHashState(pageState, replace)
and ViewModel#setPageHashStateWithAnchor(pageStateWithAnchor, replace)
methodsViewModel#overridePageHashState(pageState, replace)
and ViewModel#overridePageHashStateWithAnchor(pageStateWithAnchor, replace)
methodsViewModel#getPageHashState()
and ViewModel#getPageHashStateWithAnchor()
methodsViewModel#setPageHash()
to transform hashes starting with #!
(e.g. #!{value}
) into #{current-hash}&!anchor={value}
. Note that a #!
hash will reset the anchor (set to null
) but keep other values intact. This change doesn’t conflict with existing logic since a valid encoded anchor uses #&!anchor=...
ViewModel#applyPageAnchor()
method to apply current pageAnchor
to rendered page contentpageLink()
jora query helper to accept a pageAnchor
parameterEmbedApp#setPageHashState()
and EmbedApp#setPageHashStateWithAnchor()
methodsEmbedApp#setPageAnchor()
methodEmbedApp#pageAnchor
observertable
view:
headerClassName
option in col config which behaves the same way as className
but applies to header cellview-table-header-cell
class to header cell elementsinput
view:
htmlStep
optionvalue
option to no longer be interpreted as a querydarkmode
) for simplicity and alignment with recent CSS updates and the Embed API:
DarkModeController
class to ColorScheme
ViewModel
options darkmode
and darkmodePersistent
to colorScheme
and colorSchemePersistent
(old options are still supported as fallbacks with a warning if the new options are not specified)ViewModel#darkmode
to ViewModel#colorScheme
navbuttons.darkmodeToggle
to navbuttons.colorSchemeToggle
ColorScheme#value
from boolean
to 'light'
or 'dark'
ColorScheme#mode
values to 'auto'
, 'manual'
and 'only'
ColorScheme#persistent
to store a boolean, indicating whether ColorScheme
is backed by a persistent storeColorScheme#state
with possible values: 'auto'
, 'light'
, 'light-only'
, 'dark'
and 'dark-only'
(value: boolean, mode: Mode) => void
to (value: ColorSchemeValue, mode: ColorSchemeState) => void
localStorageEntry()
to getLocalStorageEntry()
sessionStorageEntry()
to getSessionStorageEntry()
getLocalStorageValue(key)
and getSessionStorageValue(key)
methods to read values directly from storage; these methods return null
if no entry exists for the specified key
or if the storage is unavailablePersistentStorageEntry
class derived from Observer
Changelog
1.0.0-beta.91 (24-11-2024)
Model#context
:
context
to Model
options, allowing the model's context to be set and accessible from the beginning (available during setup and in extensions)Model#setContext(context, replace)
method, which extends the current context with the provided value or replaces it if replace
is true
context
event to Model
, with prevContext
and nextContext
parameters, triggered when the context changesModel#context
to be an accessor property, where the setter calls Model#setContext(value, true)
ViewModel#setData()
to no longer accept a context
argument or change the contextViewModel#setDataProgress()
to no longer change the context, despite accepting context
argumentViewModel
to trigger a render when the context
event is firedModel#legacyPrepare
readonly property to indicate whether the legacy prepare
method is used or the new setup()
methodstruct
view to define the setStructViewAnnotations
action when using the new setup()
method, allowing custom annotations to be specified across all struct
viewsembed
option of App
to accept a configEmbedApp#publicApi.notify(name, details)
method for sending notificationsonNotify(name, details)
option in the embed extension to define a callback for handling notification
messages from the embed hostEmbedApp#publicApi.setLocationSync()
method to simplify sync between the embed app and the host location, preventing potential pitfallsViewModel#enforceScheduledRenders()
to immediately execute scheduled rendersViewModel#scheduleRender()
to use setTimeout()
instead of Promise.resolve()
to ensure proper processing of event loop tasks, eliminating unnecessary rendersViewModel
initialization to minimize unnecessary rendersViewModel#renderPage()
, ViewModel#renderSidebar()
, and ViewModel#renderPage()
as private methods, as they are not intended for direct invocation anymoreViewModel#setPageParams()
to normalize the hash
by ensuring it starts with #
, preventing unnecessary events; for example, passing #page
and page
into the method will now consistently result in #page
being stored in ViewModel#pageHash
Model#log()
method:
Logger
class to utilsModel#logger
to hold a Logger
instanceModel#logLevel
, use Model#logger.logLevel
for getting or setting the log levelModel#log()
method, which do nothing but display an error:
Model#logger[level](...args)
instead of Model#log('level', ...args)
Model#logger[level].group(message, fn | array)
or Model#logger[level].groupCollapsed(message, fn | array)
instead of Model#logger({ level, message, collapsed: fn | array })
Changelog
1.0.0-beta.90 (15-11-2024)
@discoveryjs/discovery/embed
exportapplyContainerStyles()
to take a single darkmode
value instead of "options", with supported values: true
, false
, 'true'
, 'false'
, 'dark'
, 'light'
and 'auto'
applyContainerStyles()
to avoid applying transition styles to the container, preventing unwanted flashes of opposite colorssource
view to take source
, syntax
, lineNum
, refs
and maxSourceSizeToHighlight
options. It attempts to derive these values from data
when options are not explicitly provided for backward compatibility. The source
can be derived from data
as content
(for backward compatibility) or source
propertymime
, binary
and size
data options for source
viewmarked
to ^14.1.4
(used in markdown
view)<kbd>
in markdown
viewsignature
viewsignature
viewdiscovery
pageChangelog
1.0.0-beta.89 (04-11-2024)
Widget
class into ViewModel
pageStateChange
event to ViewModel
, triggered when pageId
, pageRef
, or pageParams
changesquery
property to functions produced from a string (jora query), i.e. with Model#queryFn(query)
clipboard
option to the upload
extension for enabling loading data from the clipboardpaste
eventunloadData
nav buttonloadData
nav button into uploadFile
Model#unloadData()
method to not reset contextapp-header
viewname
, version
, description
, and icon
options for Model
, storing these values in the info
propertymodel
property to a render context (result of ViewModel#getRenderContext()
) reflecting info
value--discovery-app-icon
CSS custom property which contains value of model's icon
@discoveryjs/discovery/utils
exportApp
so that options.extensions
are applied after implicit extensionsnav-button
view to align with button
view (text
, href
and external
as config options, disabled
is no longer treated as query)PageRenderer#define()
and ViewRenderer#define()
to allow specifying all options with a single config parameter:
// new signature
discovery.page.define('example', { render: [/* ... */], ...restOptions });
// old signature remains compatible
discovery.page.define('example', [/* ... */], { /* options */ });
export default
in the core modulesModel#pathToQuery()
method to correctly generate a query when part of the path contains a jora keywordtable
view when rendering a single cell with an explicit column setup and row data containing non-object valuesChangelog
1.0.0-beta.88 (24-10-2024)
context
option for all views, which executes before data
and replaces the input context value with its resultrows
option for table
view to specify data for rows, with data
being used by default if rows
is not specifieddetailsWhen
option for table
cells to explicitly control the activation of detailsbutton
view to take text
, href
and external
options; it attempts to derive these values from data
when options are not explicitly provided for backward compatibilitybutton
view so that disabled
values are no longer treated as queries. To use a query for disabling a button, specify it explicitly like { view: "button", disabled: "=query" }
struct
view actions popup, making it 2x fastertooltip
option to display a tooltip with a delay by defaultswitch
view export due switch
is reserved word and can't be an identifierChangelog
1.0.0-beta.87 (15-10-2024)
@starting-style
at-rule is used:
.init
class to the main container in initDom()
.init
class to the overlay during the initialization phase.done
and .error
classes on the main container on progressbar finishdelay
option from the constructorappearanceDelay
property.init
class to the main container at the first stage changecreateLoadDataState()
to take a dataset factory function instead of a load data request, enhancing its reusabilityModel#decodePageHash()
to return null
for pageRef
instead of undefined
Widget#setPageHash()
to always emit hashChanged
when hash
changes, disregarding changes of pageId
, pageRef
and pageParams
signature
view when a property contains duplicated objects, which previously led to incorrect optional
labelconsole.log()
in progressbarChangelog
1.0.0-beta.86 (27-09-2024)
setWorkTitle
method to the prepare context API to display additional text on the progress bar:export function async prepare(input, { setWorkTitle }) {
await setWorkTitle('phase 1');
// ...
await setWorkTitle('phase 2');
// ...
}
Progressbar
:
setStateStep(step)
method to set a secondary text for the stagesetState()
method to take second optional parameter step
awaitRepaintPenaltyTime
property to indicate time spending on awaiting for repaintonFinish
callback to add awaitRepaintPenaltyTime
to timings
arraydecoding
stagereceive
stage into receiving
lastStage
as it redundant, use value.stage
insteaddecoding
stage for load statereceive
stage into receiving
for load stateloadingTime
and decodingTime
into dataset timingsrender
function; now, crashes are isolated to the affected viewhideOnResize: true
when scrolling outside of the popup elementPopup
Changelog
1.0.0-beta.85 (15-09-2024)
Widget#scheduleRender()
to schedule render for all subjects when no subject is specified (invoked without parameters)struct
viewstruct
view:
These actions activate when certain actions are available in the context. First, if the
queryAcceptChanges
action exists and returns a truthy value for thestruct
's data (root value), then specific actions likequerySubquery
andqueryAppend
are checked for existence. If they exist, the relevant actions are added to the actions menu. These actions should take apath
andstruct
view data and make relevant changes to the query that the currentstruct
view instance is based on. Thediscovery
page provides such actions in the context, so anystruct
view that takes query editor output as its input data provides these actions.
querySubquery
action from the context (i.e., #.action.querySubquery
), which creates on the discovery
page a new node in the query graph with the selected path.queryAppend
action, which appends on the discovery
page the selected path to the current query in the query editor.table
view:
struct
viewscalarCol
option into valueCol
true
, false
, null
, NaN
, and Infinity
values to differentiate them from strings and numberscols
configuration:
colWhen
option (like when
or whenData
) for the table
view to conditionally render columns based on the table's datacontentWhen
option (like when
or whenData
) for table-cell
to conditionally render cell content based on the cell's datawhen
and whenData
options to behave as regular options for the table-cell
view:
when
canceled column rendering; now colWhen
should be used insteadwhenData
canceled cell content rendering; now contentWhen
(the table-cell
option) should be used insteadChangelog
1.0.0-beta.84 (05-09-2024)
Model
class as a base for Widget
and App
:
setup
option for configuring model-related aspects during initialization (immutable during the lifecycle), such as object markers, additional query methods, etc.loadDataFrom*
methods, so all the classes able to load data nowprops
options for a view definition, a function (or a string as a jora query) (data, { props, context}) => any
which should return a normalized propsview.options.props
is specifiedoverrideProps(obj)
jora helper method which overrides object's values (current) with values from passed obj
(#.props
by default)getReadableStreamFromSource()
util function to use a Blob
to produce a ReadableStream
from a valueloadDataFrom*()
functions to return { state, dataset }
object instead of { state, result }
(renamed result
into dataset
)link
, text
, text-numeric
and text-match
views to allow all render props to be passed via config, in addition to datasource
view to display tabs as 4 spaces (tab-size: 4
)onClick
option for badge
viewshint
option for badge
views, use tooltip
option insteadReadableStream
from a Blob
badge
viewsdata
query; now, crashes are isolated to the affected view