Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sanity/react-loader

Package Overview
Dependencies
Maintainers
41
Versions
230
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/react-loader - npm Package Compare versions

Comparing version 0.4.3-pink-lizard to 0.5.0-pink-lizard

11

CHANGELOG.md
# Changelog
## [0.5.0-pink-lizard](https://github.com/sanity-io/visual-editing/compare/react-loader-v0.4.3-pink-lizard...react-loader-v0.5.0-pink-lizard) (2023-11-08)
### ⚠ BREAKING CHANGES
* lazy load live mode ([#281](https://github.com/sanity-io/visual-editing/issues/281))
### Bug Fixes
* lazy load live mode ([#281](https://github.com/sanity-io/visual-editing/issues/281)) ([e52991c](https://github.com/sanity-io/visual-editing/commit/e52991cc974df76647c4ede51de16527c14e6c10))
## [0.4.3-pink-lizard](https://github.com/sanity-io/visual-editing/compare/react-loader-v0.4.2-pink-lizard...react-loader-v0.4.3-pink-lizard) (2023-11-07)

@@ -4,0 +15,0 @@

22

dist/index.d.ts
import type { ContentSourceMap } from '@sanity/client'
import { CreateQueryStoreOptions } from '@sanity/core-loader'
import { LiveModeState } from '@sanity/core-loader'
import { EnableLiveModeOptions } from '@sanity/core-loader'
import type { QueryParams } from '@sanity/client'

@@ -8,17 +8,5 @@ import { QueryStoreState } from '@sanity/core-loader'

export declare const createQueryStore: (options: CreateQueryStoreOptions) => {
query: <Response_1>(
query: string,
params?: QueryParams,
) => Promise<{
data: Response_1
sourceMap: ContentSourceMap | undefined
}>
useQuery: <Response_2 = unknown, Error_1 = unknown>(
query: string,
params?: QueryParams,
options?: UseQueryOptions<Response_2> | undefined,
) => QueryStoreState<Response_2, Error_1>
useLiveMode: () => void
}
export declare const createQueryStore: (
options: CreateQueryStoreOptions,
) => QueryStore

@@ -37,3 +25,3 @@ export declare interface QueryStore {

export declare type UseLiveModeHook = () => LiveModeState
export declare type UseLiveModeHook = (options: EnableLiveModeOptions) => void

@@ -40,0 +28,0 @@ export declare type UseQueryHook = <Response = unknown, Error = unknown>(

import { createQueryStore as createQueryStore$1 } from '@sanity/core-loader';
import { useState, useMemo, useEffect, useSyncExternalStore, useCallback, startTransition } from 'react';
import { useState, useMemo, useEffect, startTransition } from 'react';
const createQueryStore = options => {
const {
createFetcherStore,
$LiveMode,
enableLiveMode,
unstable__cache

@@ -15,3 +15,2 @@ } = createQueryStore$1(options);

};
const initialLiveMode = $LiveMode.value;
const DEFAULT_PARAMS = {};

@@ -39,5 +38,15 @@ const useQuery = (query2, params = DEFAULT_PARAMS, options2 = {}) => {

};
const useLiveMode = () => {
const store = useSyncExternalStore(useCallback(onStoreChange => $LiveMode.listen(onStoreChange), []), () => $LiveMode.get(), () => initialLiveMode);
return store;
const useLiveMode = ({
allowStudioOrigin,
onConnect,
onDisconnect
}) => {
useEffect(() => {
const disableLiveMode = enableLiveMode({
allowStudioOrigin,
onConnect,
onDisconnect
});
return () => disableLiveMode();
}, [allowStudioOrigin, onConnect, onDisconnect]);
};

@@ -44,0 +53,0 @@ const query = async (query2, params = {}) => {

@@ -240,2 +240,3 @@ import { Any } from '@sanity/client/csm'

/** @public */
export declare interface SanityNodeContext {

@@ -242,0 +243,0 @@ baseUrl: string

import { forwardRef, createElement } from 'react';
import { getPublishedId, simplifyPath, resolveMapping, resolvedKeyedSourcePath } from '@sanity/client/csm';
import { studioPath, getPublishedId, simplifyPath, resolveMapping, resolvedKeyedSourcePath } from '@sanity/client/csm';
const htmlElements = ["a", "abbr", "address", "area", "article", "aside", "audio", "b", "base", "bdi", "bdo", "big", "blockquote", "body", "br", "button", "canvas", "caption", "cite", "code", "col", "colgroup", "data", "datalist", "dd", "del", "details", "dfn", "dialog", "div", "dl", "dt", "em", "embed", "fieldset", "figcaption", "figure", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "iframe", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "menu", "menuitem", "meta", "meter", "nav", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "script", "section", "select", "small", "source", "span", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "u", "ul", "var", "video", "wbr", "webview"];

@@ -334,60 +334,8 @@

}
const reKeySegment$1 = /_key\s*==\s*['"](.*)['"]/;
const reIndexTuple = /^\d*:\d*$/;
function isIndexSegment(segment) {
return typeof segment === "number" || typeof segment === "string" && /^\[\d+\]$/.test(segment);
}
function isKeySegment(segment) {
if (typeof segment === "string") {
return reKeySegment$1.test(segment.trim());
}
return typeof segment === "object" && "_key" in segment;
}
function isIndexTuple(segment) {
if (typeof segment === "string" && reIndexTuple.test(segment)) {
return true;
}
if (!Array.isArray(segment) || segment.length !== 2) {
return false;
}
const [from, to] = segment;
return (typeof from === "number" || from === "") && (typeof to === "number" || to === "");
}
const rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
const reKeySegment = /_key\s*==\s*['"](.*)['"]/;
function fromString(path) {
if (typeof path !== "string") {
throw new Error("Path is not a string");
}
const segments = path.match(rePropName);
if (!segments) {
throw new Error("Invalid path string");
}
return segments.map(normalizePathSegment);
}
function normalizePathSegment(segment) {
if (isIndexSegment(segment)) {
return normalizeIndexSegment(segment);
}
if (isKeySegment(segment)) {
return normalizeKeySegment(segment);
}
if (isIndexTuple(segment)) {
return normalizeIndexTupleSegment(segment);
}
return segment;
}
function normalizeIndexSegment(segment) {
return Number(segment.replace(/[^\d]/g, ""));
}
function normalizeKeySegment(segment) {
const segments = segment.match(reKeySegment);
return {
_key: segments[1]
};
}
function normalizeIndexTupleSegment(segment) {
const [from, to] = segment.split(":").map(seg => seg === "" ? seg : Number(seg));
return [from, to];
}
const {
/** @internal */
toString,
/** @internal */
fromString
} = studioPath;
function resolveSanityNode(context, csm, resultPath, keyedResultPath) {

@@ -394,0 +342,0 @@ const {

{
"name": "@sanity/react-loader",
"version": "0.4.3-pink-lizard",
"version": "0.5.0-pink-lizard",
"homepage": "https://github.com/sanity-io/visual-editing/tree/main/packages/react-loader#readme",

@@ -123,3 +123,3 @@ "bugs": {

"dependencies": {
"@sanity/core-loader": "0.4.4-pink-lizard"
"@sanity/core-loader": "0.5.0-pink-lizard"
},

@@ -126,0 +126,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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