You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@json-layout/core

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@json-layout/core - npm Package Compare versions

Comparing version

to
1.12.2

8

package.json
{
"name": "@json-layout/core",
"version": "1.12.1",
"version": "1.12.2",
"description": "Compilation and state management utilities for JSON Layout.",

@@ -56,7 +56,7 @@ "type": "module",

"scripts": {
"test:only": "node --no-experimental-fetch --test --test-only test/*.spec.js",
"test": "mkdir -p tmp && node --no-experimental-fetch --test test/*.spec.js",
"test:only": "node --test --test-only test/*.spec.js",
"test": "mkdir -p tmp && node --test test/*.spec.js",
"build": "rm -rf ./types && tsc -p tsconfig.build.json",
"watch:build": "tsc -p tsconfig.build.json --watch --preserveWatchOutput",
"watch:test": "node --no-experimental-fetch --test --watch test/*.spec.js"
"watch:test": "node --test --watch test/*.spec.js"
},

@@ -63,0 +63,0 @@ "repository": {

@@ -54,2 +54,3 @@ import debug from 'debug'

const logSelectItems = debug('jl:select-items')
const logGetItems = debug('jl:get-items')
const logActivatedItems = debug('jl:activated-items')

@@ -320,6 +321,9 @@

for (const node of createStateTreeContext.getItemsDataRequests) {
logGetItems(node.fullKey, 'automatic get items triggered')
this.getItems(node).then(items => {
logGetItems(node.fullKey, 'automatic get items, fetched results', items)
const rawData = /** @type {any[]} */(node.data ?? [])
const existingItems = rawData.map(item => this.prepareSelectItem(node, item))
const data = produceListData(rawData, existingItems, items)
logGetItems(node.fullKey, 'automatic get items, input produced data', data)
this.input(node, data)

@@ -422,3 +426,3 @@ }, err => console.error('error fetching items', node.fullKey, err))

if (activateKey !== undefined) {
logActivatedItems('activated item on input', node.fullKey, activateKey)
logActivatedItems(node.fullKey, 'activated item on input', activateKey)
this.activatedItems = produce(this.activatedItems, draft => { draft[node.fullKey] = activateKey })

@@ -563,6 +567,6 @@ this._autofocusTarget = node.fullKey + '/' + activateKey

rawItems = node.itemsCacheKey
logSelectItems(`${node.fullKey} - raw items from context or schema or getItems expression`, rawItems)
logGetItems(node.fullKey, 'raw items from context or schema or getItems expression', rawItems)
}
if (node.layout.getItems && isGetItemsFetch(node.layout.getItems)) {
logSelectItems(`${node.fullKey} - will fetch raw items from URL`, node.itemsCacheKey)
logGetItems(node.fullKey, 'will fetch raw items from URL', node.itemsCacheKey)
const url = new URL(node.itemsCacheKey)

@@ -585,3 +589,3 @@ /** @type {Record<string, string> | null} */

if (qSearchParam) {
logSelectItems(`${node.fullKey} - apply search params`, qSearchParam)
logGetItems(node.fullKey, 'apply search params', qSearchParam)
appliedQ = true

@@ -594,3 +598,3 @@ if (q) url.searchParams.set(qSearchParam, q)

rawItems = await node.options.fetch(url.href, fetchOptions)
logSelectItems(`${node.fullKey} - raw items URL`, rawItems)
logGetItems(node.fullKey, 'raw items fetched from URL', rawItems)
}

@@ -603,3 +607,3 @@

rawItems = this.evalNodeExpression(node, node.layout.getItems.itemsResults, rawItems)
logSelectItems(`${node.fullKey} - items passed through the getItems.itemsResults expression`, rawItems)
logGetItems(node.fullKey, 'items passed through the getItems.itemsResults expression', rawItems)
}

@@ -667,3 +671,3 @@

logSelectItems(`${node.fullKey} - select item after applying itemValue/itemKey/itemTitle/itemIcon expressions`, item)
logSelectItems('select item after applying itemValue/itemKey/itemTitle/itemIcon expressions', node.fullKey, item)
return /** @type {import('@json-layout/vocabulary').SelectItem} */(item)

@@ -682,3 +686,3 @@ }

activateItem (node, key) {
logActivatedItems('activate item explicitly', node.fullKey, key)
logActivatedItems(node.fullKey, 'activate item explicitly', key)
this.activatedItems = produce(this.activatedItems, draft => { draft[node.fullKey] = key })

@@ -693,3 +697,3 @@ this._autofocusTarget = node.fullKey + '/' + key

const newParentData = { ...parentNode.data }
logActivatedItems('remove properties of previous oneOf activated item', node.fullKey, node.children?.[0].fullKey)
logActivatedItems(node.fullKey, 'remove properties of previous oneOf activated item', node.children?.[0].fullKey)
for (const propertyKey of node.children?.[0].skeleton.propertyKeys) {

@@ -712,3 +716,3 @@ delete newParentData[propertyKey]

deactivateItem (node) {
logActivatedItems('deactivate item explicitly', node.fullKey)
logActivatedItems(node.fullKey, 'deactivate item explicitly')
// also deactivate children oneOf for example

@@ -718,3 +722,3 @@ this.activatedItems = produce(this.activatedItems, draft => {

if (key.startsWith(node.fullKey)) {
logActivatedItems('item deactivation deletes a key', key)
logActivatedItems(node.fullKey, 'item deactivation deletes a key', key)
delete draft[key]

@@ -721,0 +725,0 @@ }

@@ -11,2 +11,3 @@ import { isSwitchStruct, childIsCompositeCompObject, childIsSlotCompObject, isCompositeLayout, isFocusableLayout, isItemsLayout, isGetItemsExpression, isGetItemsFetch, isListLayout } from '@json-layout/vocabulary'

const logValidation = debug('jl:validation')
const logGetItems = debug('jl:get-items')

@@ -385,2 +386,5 @@ /**

if (context._debugCache) context._debugCache[fullKey] = (context._debugCache[fullKey] ?? []).concat(['hit'])
if (reusedNode.layout.comp === 'list' && reusedNode.layout.getItems) {
logGetItems(fullKey, 'list component node is fully reused from cache, no fetch will be triggered')
}
return reusedNode

@@ -771,2 +775,7 @@ } else {

const shouldLoadData = layout.comp === 'list' && itemsCacheKey && reusedNode?.itemsCacheKey !== itemsCacheKey
if (shouldLoadData) {
logGetItems(fullKey, 'list component with getItems expression registered for fetch', itemsCacheKey)
} else if (layout.comp === 'list' && itemsCacheKey) {
logGetItems(fullKey, 'list component with unchanged getItems cache key, no fetch will be triggered', itemsCacheKey)
}
const node = produceStateNode(

@@ -773,0 +782,0 @@ reusedNode ?? /** @type {import('./types.js').StateNode} */({}),

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet