Socket
Socket
Sign inDemoInstall

@json-layout/core

Package Overview
Dependencies
Maintainers
1
Versions
50
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 0.10.0 to 0.11.0

4

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

@@ -62,3 +62,3 @@ "type": "module",

"dependencies": {
"@json-layout/vocabulary": "^0.10.0",
"@json-layout/vocabulary": "^0.11.0",
"@types/markdown-it": "^13.0.1",

@@ -65,0 +65,0 @@ "ajv": "^8.12.0",

@@ -9,2 +9,3 @@ // compileStatic is meant to produce a serializable result

import MarkdownIt from 'markdown-it'
import { produce } from 'immer'
import i18n from '../i18n/index.js'

@@ -33,2 +34,13 @@ import { makeSkeletonTree } from './skeleton-tree.js'

// use Immer for efficient updating with immutability and no-op detection
/** @type {(draft: PartialCompileOptions, newOptions: PartialCompileOptions) => PartialCompileOptions} */
export const produceCompileOptions = produce((draft, newOptions) => {
for (const key of ['ajv', 'ajvOptions', 'code', 'markdown', 'markdownItOptions', 'locale', 'messages', 'optionsKeys']) {
// @ts-ignore
if (key in newOptions) draft[key] = newOptions[key]
// @ts-ignore
else delete draft[key]
}
})
/**

@@ -35,0 +47,0 @@ * @param {PartialCompileOptions} partialOptions

// import Debug from 'debug'
import { normalizeLayoutFragment, isSwitchStruct, isGetItemsExpression, isGetItemsFetch, isItemsLayout } from '@json-layout/vocabulary'
import { normalizeLayoutFragment, isSwitchStruct, isGetItemsExpression, isGetItemsFetch, isItemsLayout, getSchemaFragmentType } from '@json-layout/vocabulary'
import { makeSkeletonTree } from './skeleton-tree.js'

@@ -30,4 +30,3 @@

) {
// consolidate schema
if (!schema.type && schema.properties) schema.type = 'object'
const { type, nullable } = getSchemaFragmentType(schema)

@@ -53,4 +52,5 @@ // improve on ajv error messages based on ajv-errors (https://ajv.js.org/packages/ajv-errors.html)

else if (required) {
if (schema.type === 'object') defaultData = {}
if (schema.type === 'array') defaultData = []
if (nullable) defaultData = null
else if (type === 'object') defaultData = {}
else if (type === 'array') defaultData = []
}

@@ -108,3 +108,3 @@

const node = { key: key ?? '', pointer, parentPointer, pure, propertyKeys: [], roPropertyKeys: [] }
if (schema.type === 'object') {
if (type === 'object') {
if (schema.properties) {

@@ -172,3 +172,3 @@ node.children = node.children ?? []

for (let i = 0; i < schema.oneOf.length; i++) {
if (!schema.oneOf[i].type) schema.oneOf[i].type = schema.type
if (!schema.oneOf[i].type) schema.oneOf[i].type = type
const title = schema.oneOf[i].title ?? `option ${i}`

@@ -202,3 +202,3 @@ delete schema.oneOf[i].title

if (schema.type === 'array' && schema.items) {
if (type === 'array' && schema.items) {
if (Array.isArray(schema.items)) {

@@ -205,0 +205,0 @@ node.children = schema.items.map((/** @type {any} */ itemSchema, /** @type {number} */ i) => {

@@ -8,2 +8,4 @@ /**

export { resolveRefs } from "./utils/resolve-refs.js";
/** @type {(draft: PartialCompileOptions, newOptions: PartialCompileOptions) => PartialCompileOptions} */
export const produceCompileOptions: (draft: PartialCompileOptions, newOptions: PartialCompileOptions) => PartialCompileOptions;
export type SkeletonTree = import('./types.js').SkeletonTree;

@@ -10,0 +12,0 @@ export type SkeletonNode = import('./types.js').SkeletonNode;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc