@sanity/react-loader
Advanced tools
Comparing version 0.8.0-pink-lizard to 0.8.1-pink-lizard
@@ -9,2 +9,8 @@ # Changelog | ||
### Dependencies | ||
* The following workspace dependencies were updated | ||
* dependencies | ||
* @sanity/core-loader bumped to 0.7.4-pink-lizard | ||
## [0.8.0-pink-lizard](https://github.com/sanity-io/visual-editing/compare/react-loader-v0.7.2-pink-lizard...react-loader-v0.8.0-pink-lizard) (2023-11-09) | ||
@@ -11,0 +17,0 @@ |
@@ -1,67 +0,1 @@ | ||
import { createQueryStore as createQueryStore$1 } from '@sanity/core-loader'; | ||
import { useState, useMemo, useEffect } from 'react'; | ||
const createQueryStore = options => { | ||
const { | ||
createFetcherStore, | ||
setServerClient, | ||
enableLiveMode, | ||
unstable__cache | ||
} = createQueryStore$1(options); | ||
const DEFAULT_PARAMS = {}; | ||
const useQuery = (query2, params = DEFAULT_PARAMS, options2 = {}) => { | ||
const [initial] = useState(() => options2.initial); | ||
const $params = useMemo(() => JSON.stringify(params), [params]); | ||
const [snapshot, setSnapshot] = useState(() => { | ||
const fetcher = createFetcherStore(query2, JSON.parse($params), initial); | ||
return fetcher.value; | ||
}); | ||
useEffect(() => { | ||
const fetcher = createFetcherStore(query2, JSON.parse($params), initial); | ||
const unlisten = fetcher.listen(snapshot2 => { | ||
setSnapshot(snapshot2); | ||
}); | ||
return () => unlisten(); | ||
}, [$params, initial, query2]); | ||
return snapshot; | ||
}; | ||
const useLiveMode = ({ | ||
allowStudioOrigin, | ||
client, | ||
onConnect, | ||
onDisconnect | ||
}) => { | ||
useEffect(() => { | ||
const disableLiveMode = enableLiveMode({ | ||
allowStudioOrigin, | ||
client, | ||
onConnect, | ||
onDisconnect | ||
}); | ||
return () => disableLiveMode(); | ||
}, [allowStudioOrigin, client, onConnect, onDisconnect]); | ||
}; | ||
const query = async (query2, params = {}) => { | ||
if (typeof document !== "undefined") { | ||
throw new Error("Cannot use `query` in a browser environment, you should use it inside a loader, getStaticProps, getServerSideProps, getInitialProps, or in a React Server Component."); | ||
} | ||
const { | ||
result, | ||
resultSourceMap | ||
} = await unstable__cache.fetch(JSON.stringify({ | ||
query: query2, | ||
params | ||
})); | ||
return { | ||
data: result, | ||
sourceMap: resultSourceMap | ||
}; | ||
}; | ||
return { | ||
query, | ||
useQuery, | ||
setServerClient, | ||
useLiveMode | ||
}; | ||
}; | ||
export { createQueryStore }; | ||
//# sourceMappingURL=index.js.map | ||
import{createQueryStore as e}from"@sanity/core-loader";import{useState as r,useMemo as t,useEffect as n}from"react";const o=o=>{const{createFetcherStore:i,setServerClient:s,enableLiveMode:a,unstable__cache:c}=e(o),u={};return{query:async(e,r={})=>{if("undefined"!=typeof document)throw new Error("Cannot use `query` in a browser environment, you should use it inside a loader, getStaticProps, getServerSideProps, getInitialProps, or in a React Server Component.");const{result:t,resultSourceMap:n}=await c.fetch(JSON.stringify({query:e,params:r}));return{data:t,sourceMap:n}},useQuery:(e,o=u,s={})=>{const[a]=r((()=>s.initial)),c=t((()=>JSON.stringify(o)),[o]),[l,S]=r((()=>i(e,JSON.parse(c),a).value));return n((()=>{const r=i(e,JSON.parse(c),a).listen((e=>{S(e)}));return()=>r()}),[c,a,e]),l},setServerClient:s,useLiveMode:({allowStudioOrigin:e,client:r,onConnect:t,onDisconnect:o})=>{n((()=>{const n=a({allowStudioOrigin:e,client:r,onConnect:t,onDisconnect:o});return()=>n()}),[e,r,t,o])}}};export{o as createQueryStore};//# sourceMappingURL=index.js.map |
500
dist/jsx.js
@@ -1,499 +0,1 @@ | ||
import { forwardRef, createElement } from 'react'; | ||
import { getPublishedId, studioPath, jsonPathToStudioPath, 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"]; | ||
// src/error/flatten/flatten.ts | ||
// src/utils/getIssues/getIssues.ts | ||
function getIssues(issues) { | ||
return { | ||
issues | ||
}; | ||
} | ||
// src/utils/getOutput/getOutput.ts | ||
function getOutput(output) { | ||
return { | ||
output | ||
}; | ||
} | ||
// src/utils/executePipe/utils/getIssue/getIssue.ts | ||
function getIssue(info, issue) { | ||
return { | ||
reason: info?.reason, | ||
validation: issue.validation, | ||
origin: info?.origin || "value", | ||
message: issue.message, | ||
input: issue.input, | ||
path: issue.path, | ||
abortEarly: info?.abortEarly, | ||
abortPipeEarly: info?.abortPipeEarly, | ||
skipPipe: info?.skipPipe | ||
}; | ||
} | ||
// src/utils/executePipe/utils/getPipeInfo/getPipeInfo.ts | ||
function getPipeInfo(info, reason) { | ||
return { | ||
reason, | ||
origin: info?.origin, | ||
abortEarly: info?.abortEarly, | ||
abortPipeEarly: info?.abortPipeEarly, | ||
skipPipe: info?.skipPipe | ||
}; | ||
} | ||
// src/utils/executePipe/executePipe.ts | ||
function executePipe(input, pipe, parseInfo, reason) { | ||
if (!pipe || !pipe.length || parseInfo?.skipPipe) { | ||
return getOutput(input); | ||
} | ||
let pipeInfo; | ||
let issues; | ||
let output = input; | ||
for (const action of pipe) { | ||
const result = action(output); | ||
if (result.issues) { | ||
pipeInfo = pipeInfo || getPipeInfo(parseInfo, reason); | ||
for (const issueInfo of result.issues) { | ||
const issue = getIssue(pipeInfo, issueInfo); | ||
issues ? issues.push(issue) : issues = [issue]; | ||
} | ||
if (pipeInfo.abortEarly || pipeInfo.abortPipeEarly) { | ||
break; | ||
} | ||
} else { | ||
output = result.output; | ||
} | ||
} | ||
return issues ? getIssues(issues) : getOutput(output); | ||
} | ||
// src/utils/getDefaultArgs/getDefaultArgs.ts | ||
function getDefaultArgs(arg1, arg2) { | ||
return Array.isArray(arg1) ? [void 0, arg1] : [arg1, arg2]; | ||
} | ||
// src/utils/getErrorMessage/getErrorMessage.ts | ||
function getErrorMessage(error) { | ||
return typeof error === "function" ? error() : error; | ||
} | ||
// src/utils/getPipeIssues/getPipeIssues.ts | ||
function getPipeIssues(validation, error, input) { | ||
return getIssues([{ | ||
validation, | ||
message: getErrorMessage(error), | ||
input | ||
}]); | ||
} | ||
// src/utils/getRestAndDefaultArgs/getRestAndDefaultArgs.ts | ||
function getRestAndDefaultArgs(arg1, arg2, arg3) { | ||
if (!arg1 || typeof arg1 === "object" && !Array.isArray(arg1)) { | ||
const [error2, pipe2] = getDefaultArgs(arg2, arg3); | ||
return [arg1, error2, pipe2]; | ||
} | ||
const [error, pipe] = getDefaultArgs(arg1, arg2); | ||
return [void 0, error, pipe]; | ||
} | ||
// src/utils/getSchemaIssues/getSchemaIssues.ts | ||
function getSchemaIssues(info, reason, validation, error, input, issues) { | ||
return { | ||
issues: [{ | ||
reason, | ||
validation, | ||
origin: info?.origin || "value", | ||
message: getErrorMessage(error), | ||
input, | ||
issues, | ||
abortEarly: info?.abortEarly, | ||
abortPipeEarly: info?.abortPipeEarly, | ||
skipPipe: info?.skipPipe | ||
}] | ||
}; | ||
} | ||
// src/methods/is/is.ts | ||
function is(schema, input) { | ||
return !schema._parse(input, { | ||
abortEarly: true | ||
}).issues; | ||
} | ||
// src/schemas/object/object.ts | ||
function object(entries, arg2, arg3, arg4) { | ||
const [rest, error, pipe] = getRestAndDefaultArgs(arg2, arg3, arg4); | ||
let cachedEntries; | ||
return { | ||
/** | ||
* The schema type. | ||
*/ | ||
type: "object", | ||
/** | ||
* The entries schema. | ||
*/ | ||
entries, | ||
/** | ||
* The rest schema. | ||
*/ | ||
rest, | ||
/** | ||
* Whether it's async. | ||
*/ | ||
async: false, | ||
/** | ||
* Parses unknown input based on its schema. | ||
* | ||
* @param input The input to be parsed. | ||
* @param info The parse info. | ||
* | ||
* @returns The parsed output. | ||
*/ | ||
_parse(input, info) { | ||
if (!input || typeof input !== "object") { | ||
return getSchemaIssues(info, "type", "object", error || "Invalid type", input); | ||
} | ||
cachedEntries = cachedEntries || Object.entries(entries); | ||
let issues; | ||
const output = {}; | ||
for (const [key, schema] of cachedEntries) { | ||
const value2 = input[key]; | ||
const result = schema._parse(value2, info); | ||
if (result.issues) { | ||
const pathItem = { | ||
type: "object", | ||
input, | ||
key, | ||
value: value2 | ||
}; | ||
for (const issue of result.issues) { | ||
if (issue.path) { | ||
issue.path.unshift(pathItem); | ||
} else { | ||
issue.path = [pathItem]; | ||
} | ||
issues?.push(issue); | ||
} | ||
if (!issues) { | ||
issues = result.issues; | ||
} | ||
if (info?.abortEarly) { | ||
break; | ||
} | ||
} else if (result.output !== void 0 || key in input) { | ||
output[key] = result.output; | ||
} | ||
} | ||
if (rest && !(info?.abortEarly && issues)) { | ||
for (const key in input) { | ||
if (!(key in entries)) { | ||
const value2 = input[key]; | ||
const result = rest._parse(value2, info); | ||
if (result.issues) { | ||
const pathItem = { | ||
type: "object", | ||
input, | ||
key, | ||
value: value2 | ||
}; | ||
for (const issue of result.issues) { | ||
if (issue.path) { | ||
issue.path.unshift(pathItem); | ||
} else { | ||
issue.path = [pathItem]; | ||
} | ||
issues?.push(issue); | ||
} | ||
if (!issues) { | ||
issues = result.issues; | ||
} | ||
if (info?.abortEarly) { | ||
break; | ||
} | ||
} else { | ||
output[key] = result.output; | ||
} | ||
} | ||
} | ||
} | ||
return issues ? getIssues(issues) : executePipe(output, pipe, info, "object"); | ||
} | ||
}; | ||
} | ||
// src/schemas/optional/optional.ts | ||
function optional(wrapped, default_) { | ||
return { | ||
/** | ||
* The schema type. | ||
*/ | ||
type: "optional", | ||
/** | ||
* The wrapped schema. | ||
*/ | ||
wrapped, | ||
/** | ||
* Returns the default value. | ||
*/ | ||
getDefault() { | ||
return typeof default_ === "function" ? default_() : default_; | ||
}, | ||
/** | ||
* Whether it's async. | ||
*/ | ||
async: false, | ||
/** | ||
* Parses unknown input based on its schema. | ||
* | ||
* @param input The input to be parsed. | ||
* @param info The parse info. | ||
* | ||
* @returns The parsed output. | ||
*/ | ||
_parse(input, info) { | ||
if (input === void 0) { | ||
const override = this.getDefault(); | ||
if (override === void 0) { | ||
return getOutput(input); | ||
} | ||
input = override; | ||
} | ||
return wrapped._parse(input, info); | ||
} | ||
}; | ||
} | ||
// src/schemas/string/string.ts | ||
function string(arg1, arg2) { | ||
const [error, pipe] = getDefaultArgs(arg1, arg2); | ||
return { | ||
/** | ||
* The schema type. | ||
*/ | ||
type: "string", | ||
/** | ||
* Whether it's async. | ||
*/ | ||
async: false, | ||
/** | ||
* Parses unknown input based on its schema. | ||
* | ||
* @param input The input to be parsed. | ||
* @param info The parse info. | ||
* | ||
* @returns The parsed output. | ||
*/ | ||
_parse(input, info) { | ||
if (typeof input !== "string") { | ||
return getSchemaIssues(info, "type", "string", error || "Invalid type", input); | ||
} | ||
return executePipe(input, pipe, info, "string"); | ||
} | ||
}; | ||
} | ||
// src/validations/minLength/minLength.ts | ||
function minLength(requirement, error) { | ||
return input => input.length < requirement ? getPipeIssues("min_length", error || "Invalid length", input) : getOutput(input); | ||
} | ||
function isRecord(value) { | ||
return typeof value === "object" && value !== null && !Array.isArray(value); | ||
} | ||
function isArray(value) { | ||
return value !== null && Array.isArray(value); | ||
} | ||
function pathToUrlString(path) { | ||
let str = ""; | ||
for (const segment of path) { | ||
if (typeof segment === "string") { | ||
if (str) str += "."; | ||
str += segment; | ||
continue; | ||
} | ||
if (typeof segment === "number") { | ||
if (str) str += ":"; | ||
str += `${segment}`; | ||
continue; | ||
} | ||
if (isArray(segment)) { | ||
if (str) str += ":"; | ||
str += `${segment.join(",")}}`; | ||
continue; | ||
} | ||
if (segment._key) { | ||
if (str) str += ":"; | ||
str += `${segment._key}`; | ||
continue; | ||
} | ||
} | ||
return str; | ||
} | ||
function resolveSanityNode(context, csm, resultPath, keyedResultPath) { | ||
const { | ||
mapping, | ||
pathSuffix | ||
} = resolveMapping(resultPath, csm) || {}; | ||
if (!mapping) { | ||
return void 0; | ||
} | ||
if (mapping.source.type === "literal") { | ||
return void 0; | ||
} | ||
if (mapping.source.type === "unknown") { | ||
return void 0; | ||
} | ||
const sourceDoc = csm.documents[mapping.source.document]; | ||
const sourceBasePath = csm.paths[mapping.source.path]; | ||
if (sourceDoc && sourceBasePath) { | ||
return { | ||
baseUrl: context.baseUrl, | ||
dataset: context.dataset, | ||
id: getPublishedId(sourceDoc._id), | ||
path: studioPath.toString(jsonPathToStudioPath(resolvedKeyedSourcePath({ | ||
keyedResultPath, | ||
pathSuffix, | ||
sourceBasePath | ||
}))), | ||
projectId: context.projectId, | ||
tool: context.tool, | ||
type: sourceDoc._type, | ||
workspace: context.workspace | ||
}; | ||
} | ||
return void 0; | ||
} | ||
const lengthyStr = string([minLength(1)]); | ||
const optionalLengthyStr = optional(lengthyStr); | ||
const sanityNodeSchema = object({ | ||
projectId: optionalLengthyStr, | ||
dataset: optionalLengthyStr, | ||
id: lengthyStr, | ||
path: lengthyStr, | ||
type: optionalLengthyStr, | ||
baseUrl: lengthyStr, | ||
workspace: optionalLengthyStr, | ||
tool: optionalLengthyStr | ||
}); | ||
function isValidSanityNode(node) { | ||
return is(sanityNodeSchema, node); | ||
} | ||
function encodeSanityNodeData(node) { | ||
const { | ||
projectId, | ||
dataset, | ||
id: _id, | ||
path, | ||
baseUrl, | ||
tool, | ||
workspace, | ||
type | ||
} = node; | ||
if (!isValidSanityNode(node)) { | ||
return void 0; | ||
} | ||
const parts = [["project", projectId], ["dataset", dataset], ["id", getPublishedId(_id)], ["type", type], ["path", pathToUrlString(studioPath.fromString(path))], ["base", encodeURIComponent(baseUrl)], ["workspace", workspace], ["tool", tool]]; | ||
return parts.filter(([, value]) => !!value).map(part => part.join("=")).join(";"); | ||
} | ||
const SANITY_KEYS = ["_createdAt", "_dataset", "_id", "_key", "_originalId", "_projectId", "_ref", "_rev", "_strengthenOnPublish", "_type", "_updatedAt", "_weak"]; | ||
function isSourceNode(t) { | ||
return isRecord(t) && t.$$type$$ === "sanity"; | ||
} | ||
function unwrapData(wrapper) { | ||
if (wrapper === void 0) { | ||
return void 0; | ||
} | ||
if (wrapper === null) { | ||
return null; | ||
} | ||
if (isSourceNode(wrapper)) { | ||
return wrapper.value; | ||
} | ||
if (isArray(wrapper)) { | ||
return wrapper.map(item => unwrapData(item)); | ||
} | ||
if (isRecord(wrapper)) { | ||
return Object.fromEntries(Object.entries(wrapper).map(([k, v]) => SANITY_KEYS.includes(k) ? [k, v] : [k, unwrapData(v)])); | ||
} | ||
throw new Error("invalid wrapped value"); | ||
} | ||
function wrapData(context, value, sourceMap, resultPath = [], keyedResultPath = []) { | ||
if (value === void 0) { | ||
return void 0; | ||
} | ||
if (value === null) { | ||
return null; | ||
} | ||
if (isArray(value)) { | ||
return value.map((t, idx) => wrapData(context, t, sourceMap, resultPath.concat(idx), keyedResultPath.concat(isRecord(t) && "_key" in t && typeof t._key === "string" ? { | ||
_key: t._key, | ||
_index: idx | ||
} : idx))); | ||
} | ||
if (isRecord(value)) { | ||
return Object.fromEntries(Object.entries(value).map(([k, v]) => SANITY_KEYS.includes(k) ? [k, v] : [k, wrapData(context, v, sourceMap, resultPath.concat(k), keyedResultPath.concat(k))])); | ||
} | ||
return { | ||
$$type$$: "sanity", | ||
path: studioPath.toString(jsonPathToStudioPath(resultPath)) || void 0, | ||
source: sourceMap ? resolveSanityNode(context, sourceMap, resultPath, keyedResultPath) : void 0, | ||
value | ||
}; | ||
} | ||
const SanityElement = forwardRef(function SanityElement2(props, ref) { | ||
const { | ||
as, | ||
children: node, | ||
...restProps | ||
} = props; | ||
if (node?.source) { | ||
return createElement(as, { | ||
...restProps, | ||
"data-sanity": encodeSanityNodeData(node.source), | ||
ref | ||
}, node.value); | ||
} | ||
return createElement(as, restProps, node?.value); | ||
}); | ||
const svgElements = ["animate", "circle", "defs", "desc", "ellipse", "g", "image", "line", "filter", "marker", "mask", "metadata", "path", "pattern", "polygon", "polyline", "rect", "stop", "svg", "switch", "symbol", "text", "tspan", "use", "view", "clipPath", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "foreignObject", "linearGradient", "radialGradient", "textPath"]; | ||
function isHTMLElement(name) { | ||
return htmlElements.includes(name); | ||
} | ||
function isSVGElement(name) { | ||
return svgElements.includes(name); | ||
} | ||
const sanity = new Proxy({}, { | ||
get(target, prop) { | ||
if (isHTMLElement(prop)) { | ||
if (target[prop]) return target[prop]; | ||
const SanityComponent = forwardRef(function SanityComponent2(props, ref) { | ||
return createElement(SanityElement, { | ||
as: prop, | ||
ref, | ||
...props | ||
}); | ||
}); | ||
SanityComponent.displayName = `sanity.${prop}`; | ||
target[prop] = SanityComponent; | ||
return SanityComponent; | ||
} | ||
if (isSVGElement(prop)) { | ||
if (target[prop]) return target[prop]; | ||
const SanityComponent = forwardRef(function SanityComponent2(props, ref) { | ||
return createElement(SanityElement, { | ||
as: prop, | ||
ref, | ||
...props | ||
}); | ||
}); | ||
SanityComponent.displayName = `sanity.${prop}`; | ||
target[prop] = SanityComponent; | ||
return SanityComponent; | ||
} | ||
throw new Error(`No such element: ${prop}`); | ||
} | ||
}); | ||
export { encodeSanityNodeData, sanity, unwrapData, wrapData }; | ||
//# sourceMappingURL=jsx.js.map | ||
import{forwardRef as e,createElement as t}from"react";import{getPublishedId as r,studioPath as n,jsonPathToStudioPath as i,resolveMapping as o,resolvedKeyedSourcePath as a}from"@sanity/client/csm";const s=["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"];function u(e){return{issues:e}}function p(e){return{output:e}}function c(e,t){return{reason:e?.reason,validation:t.validation,origin:e?.origin||"value",message:t.message,input:t.input,path:t.path,abortEarly:e?.abortEarly,abortPipeEarly:e?.abortPipeEarly,skipPipe:e?.skipPipe}}function f(e,t){return{reason:t,origin:e?.origin,abortEarly:e?.abortEarly,abortPipeEarly:e?.abortPipeEarly,skipPipe:e?.skipPipe}}function l(e,t,r,n){if(!t||!t.length||r?.skipPipe)return p(e);let i,o,a=e;for(const e of t){const t=e(a);if(t.issues){i=i||f(r,n);for(const e of t.issues){const t=c(i,e);o?o.push(t):o=[t]}if(i.abortEarly||i.abortPipeEarly)break}else a=t.output}return o?u(o):p(a)}function d(e,t){return Array.isArray(e)?[void 0,e]:[e,t]}function y(e){return"function"==typeof e?e():e}function b(e,t,r,n,i,o){return{issues:[{reason:t,validation:r,origin:e?.origin||"value",message:y(n),input:i,issues:o,abortEarly:e?.abortEarly,abortPipeEarly:e?.abortPipeEarly,skipPipe:e?.skipPipe}]}}function h(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function g(e){return null!==e&&Array.isArray(e)}function m(e){let t="";for(const r of e)"string"!=typeof r?"number"!=typeof r?g(r)?(t&&(t+=":"),t+=`${r.join(",")}}`):r._key&&(t&&(t+=":"),t+=`${r._key}`):(t&&(t+=":"),t+=`${r}`):(t&&(t+="."),t+=r);return t}function v(e,t,s,u){const{mapping:p,pathSuffix:c}=o(s,t)||{};if(!p)return;if("literal"===p.source.type)return;if("unknown"===p.source.type)return;const f=t.documents[p.source.document],l=t.paths[p.source.path];return f&&l?{baseUrl:e.baseUrl,dataset:e.dataset,id:r(f._id),path:n.toString(i(a({keyedResultPath:u,pathSuffix:c,sourceBasePath:l}))),projectId:e.projectId,tool:e.tool,type:f._type,workspace:e.workspace}:void 0}const k=function(e,t){const[r,n]=d(e,t);return{type:"string",async:!1,_parse:(e,t)=>"string"!=typeof e?b(t,"type","string",r||"Invalid type",e):l(e,n,t,"string")}}([(P=1,e=>e.length<P?function(e,t,r){return u([{validation:e,message:y(t),input:r}])}("min_length",$||"Invalid length",e):p(e))]),_={type:"optional",wrapped:w=k,getDefault:()=>"function"==typeof E?E():E,async:!1,_parse(e,t){if(void 0===e){const t=this.getDefault();if(void 0===t)return p(e);e=t}return w._parse(e,t)}},j=function(e,t,r,n){const[i,o,a]=function(e,t,r){if(!e||"object"==typeof e&&!Array.isArray(e)){const[n,i]=d(t,r);return[e,n,i]}const[n,i]=d(e,t);return[void 0,n,i]}(t,r,n);let s;return{type:"object",entries:e,rest:i,async:!1,_parse(t,r){if(!t||"object"!=typeof t)return b(r,"type","object",o||"Invalid type",t);let n;s=s||Object.entries(e);const p={};for(const[e,i]of s){const o=t[e],a=i._parse(o,r);if(a.issues){const i={type:"object",input:t,key:e,value:o};for(const e of a.issues)e.path?e.path.unshift(i):e.path=[i],n?.push(e);if(n||(n=a.issues),r?.abortEarly)break}else(void 0!==a.output||e in t)&&(p[e]=a.output)}if(i&&(!r?.abortEarly||!n))for(const o in t)if(!(o in e)){const e=t[o],a=i._parse(e,r);if(a.issues){const i={type:"object",input:t,key:o,value:e};for(const e of a.issues)e.path?e.path.unshift(i):e.path=[i],n?.push(e);if(n||(n=a.issues),r?.abortEarly)break}else p[o]=a.output}return n?u(n):l(p,a,r,"object")}}}({projectId:_,dataset:_,id:k,path:k,type:_,baseUrl:k,workspace:_,tool:_});var w,E,P,$;function A(e){const{projectId:t,dataset:i,id:o,path:a,baseUrl:s,tool:u,workspace:p,type:c}=e;if(function(e){return t=e,!j._parse(t,{abortEarly:!0}).issues;var t}(e))return[["project",t],["dataset",i],["id",r(o)],["type",c],["path",m(n.fromString(a))],["base",encodeURIComponent(s)],["workspace",p],["tool",u]].filter((([,e])=>!!e)).map((e=>e.join("="))).join(";")}const I=["_createdAt","_dataset","_id","_key","_originalId","_projectId","_ref","_rev","_strengthenOnPublish","_type","_updatedAt","_weak"];function x(e){if(void 0!==e){if(null===e)return null;if(h(t=e)&&"sanity"===t.$$type$$)return e.value;var t;if(g(e))return e.map((e=>x(e)));if(h(e))return Object.fromEntries(Object.entries(e).map((([e,t])=>I.includes(e)?[e,t]:[e,x(t)])));throw new Error("invalid wrapped value")}}function D(e,t,r,o=[],a=[]){if(void 0!==t)return null===t?null:g(t)?t.map(((t,n)=>D(e,t,r,o.concat(n),a.concat(h(t)&&"_key"in t&&"string"==typeof t._key?{_key:t._key,_index:n}:n)))):h(t)?Object.fromEntries(Object.entries(t).map((([t,n])=>I.includes(t)?[t,n]:[t,D(e,n,r,o.concat(t),a.concat(t))]))):{$$type$$:"sanity",path:n.toString(i(o))||void 0,source:r?v(e,r,o,a):void 0,value:t}}const S=e((function(e,r){const{as:n,children:i,...o}=e;return i?.source?t(n,{...o,"data-sanity":A(i.source),ref:r},i.value):t(n,o,i?.value)})),O=["animate","circle","defs","desc","ellipse","g","image","line","filter","marker","mask","metadata","path","pattern","polygon","polyline","rect","stop","svg","switch","symbol","text","tspan","use","view","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"];const M=new Proxy({},{get(r,n){if(i=n,s.includes(i)){if(r[n])return r[n];const i=e((function(e,r){return t(S,{as:n,ref:r,...e})}));return i.displayName=`sanity.${n}`,r[n]=i,i}var i;if(function(e){return O.includes(e)}(n)){if(r[n])return r[n];const i=e((function(e,r){return t(S,{as:n,ref:r,...e})}));return i.displayName=`sanity.${n}`,r[n]=i,i}throw new Error(`No such element: ${n}`)}});export{A as encodeSanityNodeData,M as sanity,x as unwrapData,D as wrapData};//# sourceMappingURL=jsx.js.map |
{ | ||
"name": "@sanity/react-loader", | ||
"version": "0.8.0-pink-lizard", | ||
"version": "0.8.1-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.7.3-pink-lizard" | ||
"@sanity/core-loader": "0.7.4-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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
337768
469
3
1
+ Added@sanity/core-loader@0.7.4-pink-lizard(transitive)
- Removed@sanity/core-loader@0.7.3-pink-lizard(transitive)