sanity 5.2.0-next.37 → 5.2.0-next.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var version = "5.2.0-next.37+7926a94242", peerDependencies = {
1
+ var version = "5.2.0-next.38+029f8fe061", peerDependencies = {
2
2
  "styled-components": "^6.1.15"
3
3
  };
4
4
  export {
@@ -7,7 +7,7 @@ try {
7
7
  try {
8
8
  buildVersion = buildVersion || // This is replaced by `@sanity/pkg-utils` at build time
9
9
  // and must always be references by its full static name, e.g. no optional chaining, no `if (process && process.env)` etc.
10
- "5.2.0-next.37+7926a94242";
10
+ "5.2.0-next.38+029f8fe061";
11
11
  } catch {
12
12
  }
13
13
  const SANITY_VERSION = buildVersion || `${version}-dev`;
@@ -74,12 +74,7 @@ function getDefinedTypeName(type) {
74
74
  }
75
75
  const HTML_TAGS = ["img", "style"], SVG_TAGS = ["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"], SVG_FILTER_TAGS = ["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"], ALLOWED_TAGS = [...SVG_TAGS, ...HTML_TAGS, ...SVG_FILTER_TAGS], HTML_ATTRIBUTES = ["alt", "class", "crossorigin", "decoding", "elementtiming", "fetchpriority", "height", "loading", "src", "srcset", "style", "width"], SVG_ATTRIBUTES = ["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"], ALLOWED_ATTR = [...SVG_ATTRIBUTES, ...HTML_ATTRIBUTES], config = {
76
76
  ALLOWED_ATTR,
77
- ALLOWED_TAGS,
78
- /**
79
- * Required to allow for the use of `style` tags,
80
- * namely rendering the style tags from `styled-components`
81
- */
82
- FORCE_BODY: !0
77
+ ALLOWED_TAGS
83
78
  }, MAX_CUSTOM_PROPERTY_DEPTH = 5;
84
79
  function extractCreateWorkspaceManifest(workspace) {
85
80
  const serializedSchema = extractManifestSchemaTypes(workspace.schema), serializedTools = extractManifestTools(workspace.tools);
@@ -1 +1 @@
1
- {"version":3,"file":"extractManifest.cjs","sources":["../../../../src/_internal/manifest/Icon.tsx","../../../../src/_internal/manifest/manifestTypeHelpers.ts","../../../../src/_internal/manifest/purifyConfig.ts","../../../../src/_internal/manifest/extractWorkspaceManifest.tsx","../../../../src/_internal/cli/threads/extractManifest.ts"],"sourcesContent":["import {ThemeProvider} from '@sanity/ui'\nimport {buildTheme} from '@sanity/ui/theme'\nimport {type ComponentType, isValidElement, type ReactNode} from 'react'\nimport {isValidElementType} from 'react-is'\nimport {createDefaultIcon} from 'sanity'\n\nconst theme = buildTheme()\n\ninterface SchemaIconProps {\n icon?: ComponentType | ReactNode\n title: string\n subtitle?: string\n}\n\nconst SchemaIcon = ({icon, title, subtitle}: SchemaIconProps): React.JSX.Element => {\n return <ThemeProvider theme={theme}>{normalizeIcon(icon, title, subtitle)}</ThemeProvider>\n}\n\nfunction normalizeIcon(\n Icon: ComponentType | ReactNode | undefined,\n title: string,\n subtitle = '',\n): React.JSX.Element {\n if (isValidElementType(Icon)) return <Icon />\n if (isValidElement(Icon)) return Icon\n return createDefaultIcon(title, subtitle)\n}\n\nexport {SchemaIcon}\nexport type {SchemaIconProps}\n","import {\n type CrossDatasetReferenceSchemaType,\n type GlobalDocumentReferenceSchemaType,\n type ObjectField,\n type ObjectSchemaType,\n type ReferenceSchemaType,\n type SchemaType,\n} from '@sanity/types'\n\nconst DEFAULT_IMAGE_FIELDS = ['asset', 'hotspot', 'crop', 'media']\nconst DEFAULT_FILE_FIELDS = ['asset', 'media']\nconst DEFAULT_GEOPOINT_FIELDS = ['lat', 'lng', 'alt']\nconst DEFAULT_SLUG_FIELDS = ['current', 'source']\n\ntype InternalOwnProps = {fields?: unknown[]; type?: string; name?: string}\n\nexport function getCustomFields(type: ObjectSchemaType): (ObjectField & {fieldset?: string})[] {\n const fields = type.fieldsets\n ? type.fieldsets.flatMap((fs) => {\n if (fs.single) {\n return fs.field\n }\n return fs.fields.map((field) => ({\n ...field,\n fieldset: fs.name,\n }))\n })\n : type.fields\n\n if (isType(type, 'block')) {\n return []\n }\n if (isType(type, 'slug')) {\n return fields.filter((f) => !DEFAULT_SLUG_FIELDS.includes(f.name))\n }\n if (isType(type, 'geopoint')) {\n return fields.filter((f) => !DEFAULT_GEOPOINT_FIELDS.includes(f.name))\n }\n if (isType(type, 'image')) {\n return fields.filter((f) => !DEFAULT_IMAGE_FIELDS.includes(f.name))\n }\n if (isType(type, 'file')) {\n return fields.filter((f) => !DEFAULT_FILE_FIELDS.includes(f.name))\n }\n return fields\n}\n\nexport function isReference(type: SchemaType): type is ReferenceSchemaType {\n return isType(type, 'reference')\n}\n\nexport function isCrossDatasetReference(type: SchemaType): type is CrossDatasetReferenceSchemaType {\n return isType(type, 'crossDatasetReference')\n}\n\nexport function isGlobalDocumentReference(\n type: SchemaType,\n): type is GlobalDocumentReferenceSchemaType {\n return isType(type, 'globalDocumentReference')\n}\n\nexport function isObjectField(maybeOjectField: unknown): boolean {\n return (\n typeof maybeOjectField === 'object' && maybeOjectField !== null && 'name' in maybeOjectField\n )\n}\n\nexport function isCustomized(maybeCustomized: SchemaType): boolean {\n const internalOwnProps = getSchemaTypeInternalOwnProps(maybeCustomized)\n\n const hasFieldsArray =\n isObjectField(maybeCustomized) &&\n !isReference(maybeCustomized) &&\n !isCrossDatasetReference(maybeCustomized) &&\n !isGlobalDocumentReference(maybeCustomized) &&\n 'fields' in maybeCustomized &&\n Array.isArray(maybeCustomized.fields) &&\n // needed to differentiate inline, named array object types from globally defined types\n // we only consider it customized if the _definition_ has fields declared\n // this holds for all customizable object-like types: object, document, image and file\n internalOwnProps?.fields\n\n if (!hasFieldsArray) {\n return false\n }\n\n const fields = getCustomFields(maybeCustomized)\n return !!fields.length\n}\n\nexport function isType(schemaType: SchemaType, typeName: string): boolean {\n if (schemaType.name === typeName) {\n return true\n }\n if (!schemaType.type) {\n return false\n }\n return isType(schemaType.type, typeName)\n}\n\nexport function isDefined<T>(value: T | null | undefined): value is T {\n return value !== null && value !== undefined\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object'\n}\n\nexport function isPrimitive(value: unknown): value is string | boolean | number {\n return isString(value) || isBoolean(value) || isNumber(value)\n}\n\nexport function isString(value: unknown): value is string {\n return typeof value === 'string'\n}\n\nfunction isNumber(value: unknown): value is number {\n return typeof value === 'boolean'\n}\n\nfunction isBoolean(value: unknown): value is boolean {\n return typeof value === 'number'\n}\n\n/**\n * _internal_ownProps contains the _definition_ for the type.\n * Without it we cannot differentiate inline array item types from globally defined types in array.of\n */\nexport function getSchemaTypeInternalOwnProps(type: SchemaType): InternalOwnProps | undefined {\n return (type as {_internal_ownProps?: InternalOwnProps})?._internal_ownProps\n}\n\n/**\n * This allows us to differentiate inline array.of type definitions vs global type names on compiled schema types\n */\nexport function getDefinedTypeName(type: SchemaType): string | undefined {\n return getSchemaTypeInternalOwnProps(type)?.type\n}\n","import {type Config} from 'isomorphic-dompurify'\n\n/**\n * This file maintains our sanitization configuration for DOMPurify.\n * We use an allowlist for tags and attributes to ensure that only safe\n * elements and attributes are allowed.\n *\n * This is easier to loosen as specs develop & use-cases are discovered.\n */\n\n///////// Tags\n\nconst HTML_TAGS = ['img', 'style']\n\nconst SVG_TAGS = [\n 'svg',\n 'a',\n 'altglyph',\n 'altglyphdef',\n 'altglyphitem',\n 'animatecolor',\n 'animatemotion',\n 'animatetransform',\n 'circle',\n 'clippath',\n 'defs',\n 'desc',\n 'ellipse',\n 'filter',\n 'font',\n 'g',\n 'glyph',\n 'glyphref',\n 'hkern',\n 'image',\n 'line',\n 'lineargradient',\n 'marker',\n 'mask',\n 'metadata',\n 'mpath',\n 'path',\n 'pattern',\n 'polygon',\n 'polyline',\n 'radialgradient',\n 'rect',\n 'stop',\n 'style',\n 'switch',\n 'symbol',\n 'text',\n 'textpath',\n 'title',\n 'tref',\n 'tspan',\n 'view',\n 'vkern',\n] as const\n\nconst SVG_FILTER_TAGS = [\n 'feBlend',\n 'feColorMatrix',\n 'feComponentTransfer',\n 'feComposite',\n 'feConvolveMatrix',\n 'feDiffuseLighting',\n 'feDisplacementMap',\n 'feDistantLight',\n 'feDropShadow',\n 'feFlood',\n 'feFuncA',\n 'feFuncB',\n 'feFuncG',\n 'feFuncR',\n 'feGaussianBlur',\n 'feImage',\n 'feMerge',\n 'feMergeNode',\n 'feMorphology',\n 'feOffset',\n 'fePointLight',\n 'feSpecularLighting',\n 'feSpotLight',\n 'feTile',\n 'feTurbulence',\n] as const\n\nconst ALLOWED_TAGS: Config['ALLOWED_TAGS'] = [...SVG_TAGS, ...HTML_TAGS, ...SVG_FILTER_TAGS]\n\n///////// Attributes\n\nconst HTML_ATTRIBUTES = [\n 'alt',\n 'class',\n 'crossorigin',\n 'decoding',\n 'elementtiming',\n 'fetchpriority',\n 'height',\n 'loading',\n 'src',\n 'srcset',\n 'style',\n 'width',\n]\n\nconst SVG_ATTRIBUTES = [\n 'accent-height',\n 'accumulate',\n 'additive',\n 'alignment-baseline',\n 'amplitude',\n 'ascent',\n 'attributename',\n 'attributetype',\n 'azimuth',\n 'basefrequency',\n 'baseline-shift',\n 'begin',\n 'bias',\n 'by',\n 'class',\n 'clip',\n 'clippathunits',\n 'clip-path',\n 'clip-rule',\n 'color',\n 'color-interpolation',\n 'color-interpolation-filters',\n 'color-profile',\n 'color-rendering',\n 'cx',\n 'cy',\n 'd',\n 'dx',\n 'dy',\n 'diffuseconstant',\n 'direction',\n 'display',\n 'divisor',\n 'dur',\n 'edgemode',\n 'elevation',\n 'end',\n 'exponent',\n 'fill',\n 'fill-opacity',\n 'fill-rule',\n 'filter',\n 'filterunits',\n 'flood-color',\n 'flood-opacity',\n 'font-family',\n 'font-size',\n 'font-size-adjust',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'fx',\n 'fy',\n 'g1',\n 'g2',\n 'glyph-name',\n 'glyphref',\n 'gradientunits',\n 'gradienttransform',\n 'height',\n 'href',\n 'id',\n 'image-rendering',\n 'in',\n 'in2',\n 'intercept',\n 'k',\n 'k1',\n 'k2',\n 'k3',\n 'k4',\n 'kerning',\n 'keypoints',\n 'keysplines',\n 'keytimes',\n 'lang',\n 'lengthadjust',\n 'letter-spacing',\n 'kernelmatrix',\n 'kernelunitlength',\n 'lighting-color',\n 'local',\n 'marker-end',\n 'marker-mid',\n 'marker-start',\n 'markerheight',\n 'markerunits',\n 'markerwidth',\n 'maskcontentunits',\n 'maskunits',\n 'max',\n 'mask',\n 'media',\n 'method',\n 'mode',\n 'min',\n 'name',\n 'numoctaves',\n 'offset',\n 'operator',\n 'opacity',\n 'order',\n 'orient',\n 'orientation',\n 'origin',\n 'overflow',\n 'paint-order',\n 'path',\n 'pathlength',\n 'patterncontentunits',\n 'patterntransform',\n 'patternunits',\n 'points',\n 'preservealpha',\n 'preserveaspectratio',\n 'primitiveunits',\n 'r',\n 'rx',\n 'ry',\n 'radius',\n 'refx',\n 'refy',\n 'repeatcount',\n 'repeatdur',\n 'restart',\n 'result',\n 'rotate',\n 'scale',\n 'seed',\n 'shape-rendering',\n 'slope',\n 'specularconstant',\n 'specularexponent',\n 'spreadmethod',\n 'startoffset',\n 'stddeviation',\n 'stitchtiles',\n 'stop-color',\n 'stop-opacity',\n 'stroke-dasharray',\n 'stroke-dashoffset',\n 'stroke-linecap',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke',\n 'stroke-width',\n 'style',\n 'surfacescale',\n 'systemlanguage',\n 'tabindex',\n 'tablevalues',\n 'targetx',\n 'targety',\n 'transform',\n 'transform-origin',\n 'text-anchor',\n 'text-decoration',\n 'text-rendering',\n 'textlength',\n 'type',\n 'u1',\n 'u2',\n 'unicode',\n 'values',\n 'viewbox',\n 'visibility',\n 'version',\n 'vert-adv-y',\n 'vert-origin-x',\n 'vert-origin-y',\n 'width',\n 'word-spacing',\n 'wrap',\n 'writing-mode',\n 'xchannelselector',\n 'ychannelselector',\n 'x',\n 'x1',\n 'x2',\n 'xmlns',\n 'y',\n 'y1',\n 'y2',\n 'z',\n 'zoomandpan',\n] as const\n\nconst ALLOWED_ATTR: Config['ALLOWED_ATTR'] = [...SVG_ATTRIBUTES, ...HTML_ATTRIBUTES]\n\nconst config = {\n ALLOWED_ATTR,\n ALLOWED_TAGS,\n /**\n * Required to allow for the use of `style` tags,\n * namely rendering the style tags from `styled-components`\n */\n FORCE_BODY: true,\n} satisfies Config\n\nexport {config}\n","import DOMPurify from 'isomorphic-dompurify'\nimport {startCase} from 'lodash-es'\nimport {renderToString} from 'react-dom/server'\nimport {\n type ArraySchemaType,\n type BlockDefinition,\n type BooleanSchemaType,\n ConcreteRuleClass,\n createSchema,\n type CrossDatasetReferenceSchemaType,\n type FileSchemaType,\n type GlobalDocumentReferenceSchemaType,\n type MultiFieldSet,\n type NumberSchemaType,\n type ObjectField,\n type ObjectSchemaType,\n type ReferenceSchemaType,\n type Rule,\n type RuleSpec,\n type Schema,\n type SchemaType,\n type SchemaValidationValue,\n type SpanSchemaType,\n type StringSchemaType,\n type Workspace,\n} from 'sanity'\n\nimport {SchemaIcon, type SchemaIconProps} from './Icon'\nimport {\n getCustomFields,\n getDefinedTypeName,\n isCrossDatasetReference,\n isCustomized,\n isDefined,\n isGlobalDocumentReference,\n isPrimitive,\n isRecord,\n isReference,\n isString,\n isType,\n} from './manifestTypeHelpers'\nimport {\n type CreateWorkspaceManifest,\n type ManifestField,\n type ManifestFieldset,\n type ManifestSchemaType,\n type ManifestSerializable,\n type ManifestTitledValue,\n type ManifestTool,\n type ManifestValidationGroup,\n type ManifestValidationRule,\n} from './manifestTypes'\nimport {config} from './purifyConfig'\n\ninterface Context {\n schema: Schema\n}\n\ntype SchemaTypeKey =\n | keyof ArraySchemaType\n | keyof BooleanSchemaType\n | keyof FileSchemaType\n | keyof NumberSchemaType\n | keyof ObjectSchemaType\n | keyof StringSchemaType\n | keyof ReferenceSchemaType\n | keyof BlockDefinition\n | 'group' // we strip this from fields\n\ntype Validation = {validation: ManifestValidationGroup[]} | Record<string, never>\ntype ObjectFields = {fields: ManifestField[]} | Record<string, never>\ntype SerializableProp = ManifestSerializable | ManifestSerializable[] | undefined\ntype ManifestValidationFlag = ManifestValidationRule['flag']\ntype ValidationRuleTransformer = (rule: RuleSpec) => ManifestValidationRule | undefined\n\nconst MAX_CUSTOM_PROPERTY_DEPTH = 5\n\nexport function extractCreateWorkspaceManifest(workspace: Workspace): CreateWorkspaceManifest {\n const serializedSchema = extractManifestSchemaTypes(workspace.schema)\n const serializedTools = extractManifestTools(workspace.tools)\n\n return {\n name: workspace.name,\n title: workspace.title,\n subtitle: workspace.subtitle,\n basePath: workspace.basePath,\n projectId: workspace.projectId,\n dataset: workspace.dataset,\n icon: resolveIcon({\n icon: workspace.icon,\n title: workspace.title,\n subtitle: workspace.subtitle,\n }),\n mediaLibrary: workspace.mediaLibrary,\n schema: serializedSchema,\n tools: serializedTools,\n }\n}\n\n/**\n * Extracts all serializable properties from userland schema types,\n * so they best-effort can be used as definitions for Schema.compile\n. */\nexport function extractManifestSchemaTypes(schema: Schema): ManifestSchemaType[] {\n const typeNames = schema.getTypeNames()\n const context = {schema}\n\n const studioDefaultTypeNames = createSchema({name: 'default', types: []}).getTypeNames()\n\n return typeNames\n .filter((typeName) => !studioDefaultTypeNames.includes(typeName))\n .map((typeName) => schema.get(typeName))\n .filter((type): type is SchemaType => typeof type !== 'undefined')\n .map((type) => transformType(type, context))\n}\n\nfunction transformCommonTypeFields(\n type: SchemaType & {fieldset?: string},\n typeName: string,\n context: Context,\n): Omit<ManifestSchemaType, 'name' | 'title' | 'type'> {\n const arrayProps =\n typeName === 'array' && type.jsonType === 'array' ? transformArrayMember(type, context) : {}\n\n const referenceProps = isReference(type) ? transformReference(type) : {}\n const crossDatasetRefProps = isCrossDatasetReference(type)\n ? transformCrossDatasetReference(type)\n : {}\n const globalRefProps = isGlobalDocumentReference(type)\n ? transformGlobalDocumentReference(type)\n : {}\n\n const objectFields: ObjectFields =\n type.jsonType === 'object' && type.type && isCustomized(type)\n ? {\n fields: getCustomFields(type).map((objectField) => transformField(objectField, context)),\n }\n : {}\n\n return {\n ...retainCustomTypeProps(type),\n ...transformValidation(type.validation),\n ...ensureString('description', type.description),\n ...objectFields,\n ...arrayProps,\n ...referenceProps,\n ...crossDatasetRefProps,\n ...globalRefProps,\n ...ensureConditional('readOnly', type.readOnly),\n ...ensureConditional('hidden', type.hidden),\n ...transformFieldsets(type),\n // fieldset prop gets instrumented via getCustomFields\n ...ensureString('fieldset', type.fieldset),\n ...transformBlockType(type, context),\n }\n}\n\nfunction transformFieldsets(\n type: SchemaType,\n): {fieldsets: ManifestFieldset[]} | Record<string, never> {\n if (type.jsonType !== 'object') {\n return {}\n }\n const fieldsets = type.fieldsets\n ?.filter((fs): fs is MultiFieldSet => !fs.single)\n .map((fs) => {\n const options = isRecord(fs.options) ? {options: retainSerializableProps(fs.options)} : {}\n return {\n name: fs.name,\n ...ensureCustomTitle(fs.name, fs.title),\n ...ensureString('description', fs.description),\n ...ensureConditional('readOnly', fs.readOnly),\n ...ensureConditional('hidden', fs.hidden),\n ...options,\n }\n })\n\n return fieldsets?.length ? {fieldsets} : {}\n}\n\nfunction transformType(type: SchemaType, context: Context): ManifestSchemaType {\n const typeName = type.type ? type.type.name : type.jsonType\n\n return {\n ...transformCommonTypeFields(type, typeName, context),\n name: type.name,\n type: typeName,\n ...ensureCustomTitle(type.name, type.title),\n }\n}\n\nfunction retainCustomTypeProps(type: SchemaType): Record<string, SerializableProp> {\n const manuallySerializedFields: SchemaTypeKey[] = [\n //explicitly added\n 'name',\n 'title',\n 'description',\n 'readOnly',\n 'hidden',\n 'validation',\n 'fieldsets',\n 'fields',\n 'to',\n 'of',\n // not serialized\n 'type',\n 'jsonType',\n '__experimental_actions',\n '__experimental_formPreviewTitle',\n '__experimental_omnisearch_visibility',\n '__experimental_search',\n 'components',\n 'icon',\n 'orderings',\n 'preview',\n 'groups',\n //only exists on fields\n 'group',\n // we know about these, but let them be generically handled\n // deprecated\n // rows (from text)\n // initialValue\n // options\n // crossDatasetReference props\n ]\n const typeWithoutManuallyHandledFields = Object.fromEntries(\n Object.entries(type).filter(\n ([key]) => !manuallySerializedFields.includes(key as unknown as SchemaTypeKey),\n ),\n )\n return retainSerializableProps(typeWithoutManuallyHandledFields) as Record<\n string,\n SerializableProp\n >\n}\n\nfunction retainSerializableProps(maybeSerializable: unknown, depth = 0): SerializableProp {\n if (depth > MAX_CUSTOM_PROPERTY_DEPTH) {\n return undefined\n }\n\n if (!isDefined(maybeSerializable)) {\n return undefined\n }\n\n if (isPrimitive(maybeSerializable)) {\n // cull empty strings\n if (maybeSerializable === '') {\n return undefined\n }\n return maybeSerializable\n }\n\n // url-schemes ect..\n if (maybeSerializable instanceof RegExp) {\n return maybeSerializable.toString()\n }\n\n if (Array.isArray(maybeSerializable)) {\n const arrayItems = maybeSerializable\n .map((item) => retainSerializableProps(item, depth + 1))\n .filter((item): item is ManifestSerializable => isDefined(item))\n return arrayItems.length ? arrayItems : undefined\n }\n\n if (isRecord(maybeSerializable)) {\n const serializableEntries = Object.entries(maybeSerializable)\n .map(([key, value]) => {\n return [key, retainSerializableProps(value, depth + 1)]\n })\n .filter(([, value]) => isDefined(value))\n return serializableEntries.length ? Object.fromEntries(serializableEntries) : undefined\n }\n\n return undefined\n}\n\nfunction transformField(field: ObjectField & {fieldset?: string}, context: Context): ManifestField {\n const fieldType = field.type\n const typeName = getDefinedTypeName(fieldType) ?? fieldType.name\n return {\n ...transformCommonTypeFields(fieldType, typeName, context),\n name: field.name,\n type: typeName,\n ...ensureCustomTitle(field.name, fieldType.title),\n // this prop gets added synthetically via getCustomFields\n ...ensureString('fieldset', field.fieldset),\n }\n}\n\nfunction transformArrayMember(\n arrayMember: ArraySchemaType,\n context: Context,\n): Pick<ManifestField, 'of'> {\n return {\n of: arrayMember.of.map((type) => {\n const typeName = getDefinedTypeName(type) ?? type.name\n return {\n ...transformCommonTypeFields(type, typeName, context),\n type: typeName,\n ...(typeName === type.name ? {} : {name: type.name}),\n ...ensureCustomTitle(type.name, type.title),\n }\n }),\n }\n}\n\nfunction transformReference(reference: ReferenceSchemaType): Pick<ManifestSchemaType, 'to'> {\n return {\n to: (reference.to ?? []).map((type) => {\n return {\n ...retainCustomTypeProps(type),\n type: type.name,\n }\n }),\n }\n}\n\nfunction transformCrossDatasetReference(\n reference: CrossDatasetReferenceSchemaType,\n): Pick<ManifestSchemaType, 'to' | 'preview'> {\n return {\n to: (reference.to ?? []).map((crossDataset) => {\n const preview = crossDataset.preview?.select\n ? {preview: {select: crossDataset.preview.select}}\n : {}\n return {\n type: crossDataset.type,\n ...ensureCustomTitle(crossDataset.type, crossDataset.title),\n ...preview,\n }\n }),\n }\n}\n\nfunction transformGlobalDocumentReference(\n reference: GlobalDocumentReferenceSchemaType,\n): Pick<ManifestSchemaType, 'to' | 'preview'> {\n return {\n to: (reference.to ?? []).map((crossDataset) => {\n const preview = crossDataset.preview?.select\n ? {preview: {select: crossDataset.preview.select}}\n : {}\n return {\n type: crossDataset.type,\n ...ensureCustomTitle(crossDataset.type, crossDataset.title),\n ...preview,\n }\n }),\n }\n}\n\nconst transformTypeValidationRule: ValidationRuleTransformer = (rule) => {\n return {\n ...rule,\n constraint:\n 'constraint' in rule &&\n (typeof rule.constraint === 'string'\n ? rule.constraint.toLowerCase()\n : retainSerializableProps(rule.constraint)),\n }\n}\n\nconst validationRuleTransformers: Partial<\n Record<ManifestValidationFlag, ValidationRuleTransformer>\n> = {\n type: transformTypeValidationRule,\n}\n\nfunction transformValidation(validation: SchemaValidationValue): Validation {\n const validationArray = (Array.isArray(validation) ? validation : [validation]).filter(\n (value): value is Rule => typeof value === 'object' && '_type' in value,\n )\n\n // we dont want type in the output as that is implicitly given by the typedef itself an will only bloat the payload\n const disallowedFlags = ['type']\n\n // Validation rules that refer to other fields use symbols, which cannot be serialized. It would\n // be possible to transform these to a serializable type, but we haven't implemented that for now.\n const disallowedConstraintTypes: (symbol | unknown)[] = [ConcreteRuleClass.FIELD_REF]\n\n const serializedValidation = validationArray\n .map(({_rules, _message, _level}) => {\n const message: Partial<Pick<ManifestValidationGroup, 'message'>> =\n typeof _message === 'string' ? {message: _message} : {}\n\n const serializedRules = _rules\n .filter((rule) => {\n if (!('constraint' in rule)) {\n return false\n }\n\n const {flag, constraint} = rule\n\n if (disallowedFlags.includes(flag)) {\n return false\n }\n\n return !(\n typeof constraint === 'object' &&\n 'type' in constraint &&\n disallowedConstraintTypes.includes(constraint.type)\n )\n })\n .reduce<ManifestValidationRule[]>((rules, rule) => {\n const transformer: ValidationRuleTransformer =\n validationRuleTransformers[rule.flag] ??\n ((spec) => retainSerializableProps(spec) as ManifestValidationRule)\n\n const transformedRule = transformer(rule)\n if (!transformedRule) {\n return rules\n }\n return [...rules, transformedRule]\n }, [])\n\n return {\n rules: serializedRules,\n level: _level,\n ...message,\n }\n })\n .filter((group) => !!group.rules.length)\n\n return serializedValidation.length ? {validation: serializedValidation} : {}\n}\n\nfunction ensureCustomTitle(typeName: string, value: unknown) {\n const titleObject = ensureString('title', value)\n\n const defaultTitle = startCase(typeName)\n // omit title if its the same as default, to reduce payload\n if (titleObject.title === defaultTitle) {\n return {}\n }\n return titleObject\n}\n\nfunction ensureString<Key extends string>(key: Key, value: unknown) {\n if (typeof value === 'string') {\n return {\n [key]: value,\n }\n }\n\n return {}\n}\n\nfunction ensureConditional<const Key extends string>(key: Key, value: unknown) {\n if (typeof value === 'boolean') {\n return {\n [key]: value,\n }\n }\n\n if (typeof value === 'function') {\n return {\n [key]: 'conditional',\n }\n }\n\n return {}\n}\n\nexport function transformBlockType(\n blockType: SchemaType,\n context: Context,\n): Pick<ManifestSchemaType, 'marks' | 'lists' | 'styles' | 'of'> | Record<string, never> {\n if (blockType.jsonType !== 'object' || !isType(blockType, 'block')) {\n return {}\n }\n\n const childrenField = blockType.fields?.find((field) => field.name === 'children') as\n | {type: ArraySchemaType}\n | undefined\n\n if (!childrenField) {\n return {}\n }\n const ofType = childrenField.type.of\n if (!ofType) {\n return {}\n }\n const spanType = ofType.find((memberType) => memberType.name === 'span') as\n | ObjectSchemaType\n | undefined\n if (!spanType) {\n return {}\n }\n const inlineObjectTypes = (ofType.filter((memberType) => memberType.name !== 'span') ||\n []) as ObjectSchemaType[]\n\n return {\n marks: {\n annotations: (spanType as SpanSchemaType).annotations.map((t) => transformType(t, context)),\n decorators: resolveEnabledDecorators(spanType),\n },\n lists: resolveEnabledListItems(blockType),\n styles: resolveEnabledStyles(blockType),\n of: inlineObjectTypes.map((t) => transformType(t, context)),\n }\n}\n\nfunction resolveEnabledStyles(blockType: ObjectSchemaType): ManifestTitledValue[] | undefined {\n const styleField = blockType.fields?.find((btField) => btField.name === 'style')\n return resolveTitleValueArray(styleField?.type?.options?.list)\n}\n\nfunction resolveEnabledDecorators(spanType: ObjectSchemaType): ManifestTitledValue[] | undefined {\n return 'decorators' in spanType ? resolveTitleValueArray(spanType.decorators) : undefined\n}\n\nfunction resolveEnabledListItems(blockType: ObjectSchemaType): ManifestTitledValue[] | undefined {\n const listField = blockType.fields?.find((btField) => btField.name === 'listItem')\n return resolveTitleValueArray(listField?.type?.options?.list)\n}\n\nfunction resolveTitleValueArray(possibleArray: unknown): ManifestTitledValue[] | undefined {\n if (!possibleArray || !Array.isArray(possibleArray)) {\n return undefined\n }\n const titledValues = possibleArray\n .filter(\n (d): d is {value: string; title?: string} => isRecord(d) && !!d.value && isString(d.value),\n )\n .map((item) => {\n return {\n value: item.value,\n ...ensureString('title', item.title),\n } satisfies ManifestTitledValue\n })\n if (!titledValues?.length) {\n return undefined\n }\n\n return titledValues\n}\n\nconst extractManifestTools = (tools: Workspace['tools']): ManifestTool[] =>\n tools.map((tool) => {\n const {\n title,\n name,\n icon,\n __internalApplicationType: type,\n } = tool as Workspace['tools'][number] & {__internalApplicationType: string}\n return {\n title,\n name,\n type: type || null,\n icon: resolveIcon({\n icon,\n title,\n }),\n } satisfies ManifestTool\n })\n\nconst resolveIcon = (props: SchemaIconProps): string | null => {\n try {\n const html = renderToString(<SchemaIcon {...props} />)\n return DOMPurify.sanitize(html.trim(), config)\n } catch {\n return null\n }\n}\n","import {isMainThread, parentPort, workerData as _workerData} from 'node:worker_threads'\n\nimport {extractCreateWorkspaceManifest} from '../../manifest/extractWorkspaceManifest'\nimport {getStudioWorkspaces} from '../util/getStudioWorkspaces'\nimport {mockBrowserEnvironment} from '../util/mockBrowserEnvironment'\n\n/** @internal */\nexport interface ExtractManifestWorkerData {\n workDir: string\n}\n\nasync function main() {\n if (isMainThread || !parentPort) {\n throw new Error('This module must be run as a worker thread')\n }\n\n const opts = _workerData as ExtractManifestWorkerData\n\n const cleanup = mockBrowserEnvironment(opts.workDir)\n\n try {\n const workspaces = await getStudioWorkspaces({basePath: opts.workDir})\n\n for (const workspace of workspaces) {\n parentPort?.postMessage(extractCreateWorkspaceManifest(workspace))\n }\n } finally {\n parentPort?.close()\n cleanup()\n }\n}\n\nvoid main().then(() => process.exit())\n"],"names":["theme","buildTheme","SchemaIcon","t0","$","_c","icon","title","subtitle","t1","normalizeIcon","t2","jsx","ThemeProvider","Icon","isValidElementType","isValidElement","createDefaultIcon","DEFAULT_IMAGE_FIELDS","DEFAULT_FILE_FIELDS","DEFAULT_GEOPOINT_FIELDS","DEFAULT_SLUG_FIELDS","getCustomFields","type","fields","fieldsets","flatMap","fs","single","field","map","fieldset","name","isType","filter","f","includes","isReference","isCrossDatasetReference","isGlobalDocumentReference","isObjectField","maybeOjectField","isCustomized","maybeCustomized","internalOwnProps","getSchemaTypeInternalOwnProps","Array","isArray","length","schemaType","typeName","isDefined","value","isRecord","isPrimitive","isString","isBoolean","isNumber","_internal_ownProps","getDefinedTypeName","HTML_TAGS","SVG_TAGS","SVG_FILTER_TAGS","ALLOWED_TAGS","HTML_ATTRIBUTES","SVG_ATTRIBUTES","ALLOWED_ATTR","config","FORCE_BODY","MAX_CUSTOM_PROPERTY_DEPTH","extractCreateWorkspaceManifest","workspace","serializedSchema","extractManifestSchemaTypes","schema","serializedTools","extractManifestTools","tools","basePath","projectId","dataset","resolveIcon","mediaLibrary","typeNames","getTypeNames","studioDefaultTypeNames","createSchema","types","get","transformType","transformCommonTypeFields","context","arrayProps","jsonType","transformArrayMember","referenceProps","transformReference","crossDatasetRefProps","transformCrossDatasetReference","globalRefProps","transformGlobalDocumentReference","objectFields","objectField","transformField","retainCustomTypeProps","transformValidation","validation","ensureString","description","ensureConditional","readOnly","hidden","transformFieldsets","transformBlockType","options","retainSerializableProps","ensureCustomTitle","manuallySerializedFields","typeWithoutManuallyHandledFields","Object","fromEntries","entries","key","maybeSerializable","depth","RegExp","toString","arrayItems","item","undefined","serializableEntries","fieldType","arrayMember","of","reference","to","crossDataset","preview","select","transformTypeValidationRule","rule","constraint","toLowerCase","validationRuleTransformers","validationArray","disallowedFlags","disallowedConstraintTypes","ConcreteRuleClass","FIELD_REF","serializedValidation","_rules","_message","_level","message","rules","flag","reduce","transformedRule","spec","level","group","titleObject","defaultTitle","startCase","blockType","childrenField","find","ofType","spanType","memberType","inlineObjectTypes","marks","annotations","t","decorators","resolveEnabledDecorators","lists","resolveEnabledListItems","styles","resolveEnabledStyles","styleField","btField","resolveTitleValueArray","list","listField","possibleArray","titledValues","d","tool","__internalApplicationType","props","html","renderToString","DOMPurify","sanitize","trim","main","isMainThread","parentPort","Error","opts","_workerData","cleanup","mockBrowserEnvironment","workDir","workspaces","getStudioWorkspaces","postMessage","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OA,SAAU;AACnB;AAEO,SAASC,SAASD,OAAkD;AACzE,SAAO,CAAC,CAACA,SAAS,OAAOA,SAAU;AACrC;AAEO,SAASE,YAAYF,OAAoD;AAC9E,SAAOG,SAASH,KAAK,KAAKI,UAAUJ,KAAK,KAAKK,SAASL,KAAK;AAC9D;AAEO,SAASG,SAASH,OAAiC;AACxD,SAAO,OAAOA,SAAU;AAC1B;AAEA,SAASK,SAASL,OAAiC;AACjD,SAAO,OAAOA,SAAU;AAC1B;AAEA,SAASI,UAAUJ,OAAkC;AACnD,SAAO,OAAOA,SAAU;AAC1B;AAMO,SAASP,8BAA8BtB,MAAgD;AAC5F,SAAQA,MAAkDmC;AAC5D;AAKO,SAASC,mBAAmBpC,MAAsC;AACvE,SAAOsB,8BAA8BtB,IAAI,GAAGA;AAC9C;AC7HA,MAAMqC,YAAY,CAAC,OAAO,OAAO,GAE3BC,WAAW,CACf,OACA,KACA,YACA,eACA,gBACA,gBACA,iBACA,oBACA,UACA,YACA,QACA,QACA,WACA,UACA,QACA,KACA,SACA,YACA,SACA,SACA,QACA,kBACA,UACA,QACA,YACA,SACA,QACA,WACA,WACA,YACA,kBACA,QACA,QACA,SACA,UACA,UACA,QACA,YACA,SACA,QACA,SACA,QACA,OAAO,GAGHC,kBAAkB,CACtB,WACA,iBACA,uBACA,eACA,oBACA,qBACA,qBACA,kBACA,gBACA,WACA,WACA,WACA,WACA,WACA,kBACA,WACA,WACA,eACA,gBACA,YACA,gBACA,sBACA,eACA,UACA,cAAc,GAGVC,eAAuC,CAAC,GAAGF,UAAU,GAAGD,WAAW,GAAGE,eAAe,GAIrFE,kBAAkB,CACtB,OACA,SACA,eACA,YACA,iBACA,iBACA,UACA,WACA,OACA,UACA,SACA,OAAO,GAGHC,iBAAiB,CACrB,iBACA,cACA,YACA,sBACA,aACA,UACA,iBACA,iBACA,WACA,iBACA,kBACA,SACA,QACA,MACA,SACA,QACA,iBACA,aACA,aACA,SACA,uBACA,+BACA,iBACA,mBACA,MACA,MACA,KACA,MACA,MACA,mBACA,aACA,WACA,WACA,OACA,YACA,aACA,OACA,YACA,QACA,gBACA,aACA,UACA,eACA,eACA,iBACA,eACA,aACA,oBACA,gBACA,cACA,gBACA,eACA,MACA,MACA,MACA,MACA,cACA,YACA,iBACA,qBACA,UACA,QACA,MACA,mBACA,MACA,OACA,aACA,KACA,MACA,MACA,MACA,MACA,WACA,aACA,cACA,YACA,QACA,gBACA,kBACA,gBACA,oBACA,kBACA,SACA,cACA,cACA,gBACA,gBACA,eACA,eACA,oBACA,aACA,OACA,QACA,SACA,UACA,QACA,OACA,QACA,cACA,UACA,YACA,WACA,SACA,UACA,eACA,UACA,YACA,eACA,QACA,cACA,uBACA,oBACA,gBACA,UACA,iBACA,uBACA,kBACA,KACA,MACA,MACA,UACA,QACA,QACA,eACA,aACA,WACA,UACA,UACA,SACA,QACA,mBACA,SACA,oBACA,oBACA,gBACA,eACA,gBACA,eACA,cACA,gBACA,oBACA,qBACA,kBACA,mBACA,qBACA,kBACA,UACA,gBACA,SACA,gBACA,kBACA,YACA,eACA,WACA,WACA,aACA,oBACA,eACA,mBACA,kBACA,cACA,QACA,MACA,MACA,WACA,UACA,WACA,cACA,WACA,cACA,iBACA,iBACA,SACA,gBACA,QACA,gBACA,oBACA,oBACA,KACA,MACA,MACA,SACA,KACA,MACA,MACA,KACA,YAAY,GAGRC,eAAuC,CAAC,GAAGD,gBAAgB,GAAGD,eAAe,GAE7EG,SAAS;AAAA,EACbD;AAAAA,EACAH;AAAAA;AAAAA;AAAAA;AAAAA;AAAAA,EAKAK,YAAY;AACd,GCxOMC,4BAA4B;AAE3B,SAASC,+BAA+BC,WAA+C;AAC5F,QAAMC,mBAAmBC,2BAA2BF,UAAUG,MAAM,GAC9DC,kBAAkBC,qBAAqBL,UAAUM,KAAK;AAE5D,SAAO;AAAA,IACL7C,MAAMuC,UAAUvC;AAAAA,IAChBzB,OAAOgE,UAAUhE;AAAAA,IACjBC,UAAU+D,UAAU/D;AAAAA,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C,GAEG0E,cAAe6G,CAAAA,UAA0C;AAC7D,MAAI;AACF,UAAMC,OAAOC,OAAAA,eAAepL,2BAAAA,IAAC,YAAA,EAAW,GAAIkL,OAAM,CAAG;AACrD,WAAOG,mBAAAA,QAAUC,SAASH,KAAKI,KAAAA,GAAQhI,MAAM;AAAA,EAC/C,QAAQ;AACN,WAAO;AAAA,EACT;AACF;ACziBA,eAAeiI,OAAO;AACpB,MAAIC,oBAAAA,gBAAgB,CAACC,oBAAAA;AACnB,UAAM,IAAIC,MAAM,4CAA4C;AAG9D,QAAMC,OAAOC,oBAAAA,YAEPC,UAAUC,uBAAAA,uBAAuBH,KAAKI,OAAO;AAEnD,MAAI;AACF,UAAMC,aAAa,MAAMC,wCAAoB;AAAA,MAAChI,UAAU0H,KAAKI;AAAAA,IAAAA,CAAQ;AAErE,eAAWrI,aAAasI;AACtBP,0BAAAA,YAAYS,YAAYzI,+BAA+BC,SAAS,CAAC;AAAA,EAErE,UAAA;AACE+H,oCAAYU,MAAAA,GACZN,QAAAA;AAAAA,EACF;AACF;AAEKN,KAAAA,EAAOa,KAAK,MAAMC,QAAQC,MAAM;"}
1
+ {"version":3,"file":"extractManifest.cjs","sources":["../../../../src/_internal/manifest/Icon.tsx","../../../../src/_internal/manifest/manifestTypeHelpers.ts","../../../../src/_internal/manifest/purifyConfig.ts","../../../../src/_internal/manifest/extractWorkspaceManifest.tsx","../../../../src/_internal/cli/threads/extractManifest.ts"],"sourcesContent":["import {ThemeProvider} from '@sanity/ui'\nimport {buildTheme} from '@sanity/ui/theme'\nimport {type ComponentType, isValidElement, type ReactNode} from 'react'\nimport {isValidElementType} from 'react-is'\nimport {createDefaultIcon} from 'sanity'\n\nconst theme = buildTheme()\n\ninterface SchemaIconProps {\n icon?: ComponentType | ReactNode\n title: string\n subtitle?: string\n}\n\nconst SchemaIcon = ({icon, title, subtitle}: SchemaIconProps): React.JSX.Element => {\n return <ThemeProvider theme={theme}>{normalizeIcon(icon, title, subtitle)}</ThemeProvider>\n}\n\nfunction normalizeIcon(\n Icon: ComponentType | ReactNode | undefined,\n title: string,\n subtitle = '',\n): React.JSX.Element {\n if (isValidElementType(Icon)) return <Icon />\n if (isValidElement(Icon)) return Icon\n return createDefaultIcon(title, subtitle)\n}\n\nexport {SchemaIcon}\nexport type {SchemaIconProps}\n","import {\n type CrossDatasetReferenceSchemaType,\n type GlobalDocumentReferenceSchemaType,\n type ObjectField,\n type ObjectSchemaType,\n type ReferenceSchemaType,\n type SchemaType,\n} from '@sanity/types'\n\nconst DEFAULT_IMAGE_FIELDS = ['asset', 'hotspot', 'crop', 'media']\nconst DEFAULT_FILE_FIELDS = ['asset', 'media']\nconst DEFAULT_GEOPOINT_FIELDS = ['lat', 'lng', 'alt']\nconst DEFAULT_SLUG_FIELDS = ['current', 'source']\n\ntype InternalOwnProps = {fields?: unknown[]; type?: string; name?: string}\n\nexport function getCustomFields(type: ObjectSchemaType): (ObjectField & {fieldset?: string})[] {\n const fields = type.fieldsets\n ? type.fieldsets.flatMap((fs) => {\n if (fs.single) {\n return fs.field\n }\n return fs.fields.map((field) => ({\n ...field,\n fieldset: fs.name,\n }))\n })\n : type.fields\n\n if (isType(type, 'block')) {\n return []\n }\n if (isType(type, 'slug')) {\n return fields.filter((f) => !DEFAULT_SLUG_FIELDS.includes(f.name))\n }\n if (isType(type, 'geopoint')) {\n return fields.filter((f) => !DEFAULT_GEOPOINT_FIELDS.includes(f.name))\n }\n if (isType(type, 'image')) {\n return fields.filter((f) => !DEFAULT_IMAGE_FIELDS.includes(f.name))\n }\n if (isType(type, 'file')) {\n return fields.filter((f) => !DEFAULT_FILE_FIELDS.includes(f.name))\n }\n return fields\n}\n\nexport function isReference(type: SchemaType): type is ReferenceSchemaType {\n return isType(type, 'reference')\n}\n\nexport function isCrossDatasetReference(type: SchemaType): type is CrossDatasetReferenceSchemaType {\n return isType(type, 'crossDatasetReference')\n}\n\nexport function isGlobalDocumentReference(\n type: SchemaType,\n): type is GlobalDocumentReferenceSchemaType {\n return isType(type, 'globalDocumentReference')\n}\n\nexport function isObjectField(maybeOjectField: unknown): boolean {\n return (\n typeof maybeOjectField === 'object' && maybeOjectField !== null && 'name' in maybeOjectField\n )\n}\n\nexport function isCustomized(maybeCustomized: SchemaType): boolean {\n const internalOwnProps = getSchemaTypeInternalOwnProps(maybeCustomized)\n\n const hasFieldsArray =\n isObjectField(maybeCustomized) &&\n !isReference(maybeCustomized) &&\n !isCrossDatasetReference(maybeCustomized) &&\n !isGlobalDocumentReference(maybeCustomized) &&\n 'fields' in maybeCustomized &&\n Array.isArray(maybeCustomized.fields) &&\n // needed to differentiate inline, named array object types from globally defined types\n // we only consider it customized if the _definition_ has fields declared\n // this holds for all customizable object-like types: object, document, image and file\n internalOwnProps?.fields\n\n if (!hasFieldsArray) {\n return false\n }\n\n const fields = getCustomFields(maybeCustomized)\n return !!fields.length\n}\n\nexport function isType(schemaType: SchemaType, typeName: string): boolean {\n if (schemaType.name === typeName) {\n return true\n }\n if (!schemaType.type) {\n return false\n }\n return isType(schemaType.type, typeName)\n}\n\nexport function isDefined<T>(value: T | null | undefined): value is T {\n return value !== null && value !== undefined\n}\n\nexport function isRecord(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object'\n}\n\nexport function isPrimitive(value: unknown): value is string | boolean | number {\n return isString(value) || isBoolean(value) || isNumber(value)\n}\n\nexport function isString(value: unknown): value is string {\n return typeof value === 'string'\n}\n\nfunction isNumber(value: unknown): value is number {\n return typeof value === 'boolean'\n}\n\nfunction isBoolean(value: unknown): value is boolean {\n return typeof value === 'number'\n}\n\n/**\n * _internal_ownProps contains the _definition_ for the type.\n * Without it we cannot differentiate inline array item types from globally defined types in array.of\n */\nexport function getSchemaTypeInternalOwnProps(type: SchemaType): InternalOwnProps | undefined {\n return (type as {_internal_ownProps?: InternalOwnProps})?._internal_ownProps\n}\n\n/**\n * This allows us to differentiate inline array.of type definitions vs global type names on compiled schema types\n */\nexport function getDefinedTypeName(type: SchemaType): string | undefined {\n return getSchemaTypeInternalOwnProps(type)?.type\n}\n","import {type Config} from 'isomorphic-dompurify'\n\n/**\n * This file maintains our sanitization configuration for DOMPurify.\n * We use an allowlist for tags and attributes to ensure that only safe\n * elements and attributes are allowed.\n *\n * This is easier to loosen as specs develop & use-cases are discovered.\n */\n\n///////// Tags\n\nconst HTML_TAGS = ['img', 'style']\n\nconst SVG_TAGS = [\n 'svg',\n 'a',\n 'altglyph',\n 'altglyphdef',\n 'altglyphitem',\n 'animatecolor',\n 'animatemotion',\n 'animatetransform',\n 'circle',\n 'clippath',\n 'defs',\n 'desc',\n 'ellipse',\n 'filter',\n 'font',\n 'g',\n 'glyph',\n 'glyphref',\n 'hkern',\n 'image',\n 'line',\n 'lineargradient',\n 'marker',\n 'mask',\n 'metadata',\n 'mpath',\n 'path',\n 'pattern',\n 'polygon',\n 'polyline',\n 'radialgradient',\n 'rect',\n 'stop',\n 'style',\n 'switch',\n 'symbol',\n 'text',\n 'textpath',\n 'title',\n 'tref',\n 'tspan',\n 'view',\n 'vkern',\n] as const\n\nconst SVG_FILTER_TAGS = [\n 'feBlend',\n 'feColorMatrix',\n 'feComponentTransfer',\n 'feComposite',\n 'feConvolveMatrix',\n 'feDiffuseLighting',\n 'feDisplacementMap',\n 'feDistantLight',\n 'feDropShadow',\n 'feFlood',\n 'feFuncA',\n 'feFuncB',\n 'feFuncG',\n 'feFuncR',\n 'feGaussianBlur',\n 'feImage',\n 'feMerge',\n 'feMergeNode',\n 'feMorphology',\n 'feOffset',\n 'fePointLight',\n 'feSpecularLighting',\n 'feSpotLight',\n 'feTile',\n 'feTurbulence',\n] as const\n\nconst ALLOWED_TAGS: Config['ALLOWED_TAGS'] = [...SVG_TAGS, ...HTML_TAGS, ...SVG_FILTER_TAGS]\n\n///////// Attributes\n\nconst HTML_ATTRIBUTES = [\n 'alt',\n 'class',\n 'crossorigin',\n 'decoding',\n 'elementtiming',\n 'fetchpriority',\n 'height',\n 'loading',\n 'src',\n 'srcset',\n 'style',\n 'width',\n]\n\nconst SVG_ATTRIBUTES = [\n 'accent-height',\n 'accumulate',\n 'additive',\n 'alignment-baseline',\n 'amplitude',\n 'ascent',\n 'attributename',\n 'attributetype',\n 'azimuth',\n 'basefrequency',\n 'baseline-shift',\n 'begin',\n 'bias',\n 'by',\n 'class',\n 'clip',\n 'clippathunits',\n 'clip-path',\n 'clip-rule',\n 'color',\n 'color-interpolation',\n 'color-interpolation-filters',\n 'color-profile',\n 'color-rendering',\n 'cx',\n 'cy',\n 'd',\n 'dx',\n 'dy',\n 'diffuseconstant',\n 'direction',\n 'display',\n 'divisor',\n 'dur',\n 'edgemode',\n 'elevation',\n 'end',\n 'exponent',\n 'fill',\n 'fill-opacity',\n 'fill-rule',\n 'filter',\n 'filterunits',\n 'flood-color',\n 'flood-opacity',\n 'font-family',\n 'font-size',\n 'font-size-adjust',\n 'font-stretch',\n 'font-style',\n 'font-variant',\n 'font-weight',\n 'fx',\n 'fy',\n 'g1',\n 'g2',\n 'glyph-name',\n 'glyphref',\n 'gradientunits',\n 'gradienttransform',\n 'height',\n 'href',\n 'id',\n 'image-rendering',\n 'in',\n 'in2',\n 'intercept',\n 'k',\n 'k1',\n 'k2',\n 'k3',\n 'k4',\n 'kerning',\n 'keypoints',\n 'keysplines',\n 'keytimes',\n 'lang',\n 'lengthadjust',\n 'letter-spacing',\n 'kernelmatrix',\n 'kernelunitlength',\n 'lighting-color',\n 'local',\n 'marker-end',\n 'marker-mid',\n 'marker-start',\n 'markerheight',\n 'markerunits',\n 'markerwidth',\n 'maskcontentunits',\n 'maskunits',\n 'max',\n 'mask',\n 'media',\n 'method',\n 'mode',\n 'min',\n 'name',\n 'numoctaves',\n 'offset',\n 'operator',\n 'opacity',\n 'order',\n 'orient',\n 'orientation',\n 'origin',\n 'overflow',\n 'paint-order',\n 'path',\n 'pathlength',\n 'patterncontentunits',\n 'patterntransform',\n 'patternunits',\n 'points',\n 'preservealpha',\n 'preserveaspectratio',\n 'primitiveunits',\n 'r',\n 'rx',\n 'ry',\n 'radius',\n 'refx',\n 'refy',\n 'repeatcount',\n 'repeatdur',\n 'restart',\n 'result',\n 'rotate',\n 'scale',\n 'seed',\n 'shape-rendering',\n 'slope',\n 'specularconstant',\n 'specularexponent',\n 'spreadmethod',\n 'startoffset',\n 'stddeviation',\n 'stitchtiles',\n 'stop-color',\n 'stop-opacity',\n 'stroke-dasharray',\n 'stroke-dashoffset',\n 'stroke-linecap',\n 'stroke-linejoin',\n 'stroke-miterlimit',\n 'stroke-opacity',\n 'stroke',\n 'stroke-width',\n 'style',\n 'surfacescale',\n 'systemlanguage',\n 'tabindex',\n 'tablevalues',\n 'targetx',\n 'targety',\n 'transform',\n 'transform-origin',\n 'text-anchor',\n 'text-decoration',\n 'text-rendering',\n 'textlength',\n 'type',\n 'u1',\n 'u2',\n 'unicode',\n 'values',\n 'viewbox',\n 'visibility',\n 'version',\n 'vert-adv-y',\n 'vert-origin-x',\n 'vert-origin-y',\n 'width',\n 'word-spacing',\n 'wrap',\n 'writing-mode',\n 'xchannelselector',\n 'ychannelselector',\n 'x',\n 'x1',\n 'x2',\n 'xmlns',\n 'y',\n 'y1',\n 'y2',\n 'z',\n 'zoomandpan',\n] as const\n\nconst ALLOWED_ATTR: Config['ALLOWED_ATTR'] = [...SVG_ATTRIBUTES, ...HTML_ATTRIBUTES]\n\nconst config = {\n ALLOWED_ATTR,\n ALLOWED_TAGS,\n} satisfies Config\n\nexport {config}\n","import DOMPurify from 'isomorphic-dompurify'\nimport {startCase} from 'lodash-es'\nimport {renderToString} from 'react-dom/server'\nimport {\n type ArraySchemaType,\n type BlockDefinition,\n type BooleanSchemaType,\n ConcreteRuleClass,\n createSchema,\n type CrossDatasetReferenceSchemaType,\n type FileSchemaType,\n type GlobalDocumentReferenceSchemaType,\n type MultiFieldSet,\n type NumberSchemaType,\n type ObjectField,\n type ObjectSchemaType,\n type ReferenceSchemaType,\n type Rule,\n type RuleSpec,\n type Schema,\n type SchemaType,\n type SchemaValidationValue,\n type SpanSchemaType,\n type StringSchemaType,\n type Workspace,\n} from 'sanity'\n\nimport {SchemaIcon, type SchemaIconProps} from './Icon'\nimport {\n getCustomFields,\n getDefinedTypeName,\n isCrossDatasetReference,\n isCustomized,\n isDefined,\n isGlobalDocumentReference,\n isPrimitive,\n isRecord,\n isReference,\n isString,\n isType,\n} from './manifestTypeHelpers'\nimport {\n type CreateWorkspaceManifest,\n type ManifestField,\n type ManifestFieldset,\n type ManifestSchemaType,\n type ManifestSerializable,\n type ManifestTitledValue,\n type ManifestTool,\n type ManifestValidationGroup,\n type ManifestValidationRule,\n} from './manifestTypes'\nimport {config} from './purifyConfig'\n\ninterface Context {\n schema: Schema\n}\n\ntype SchemaTypeKey =\n | keyof ArraySchemaType\n | keyof BooleanSchemaType\n | keyof FileSchemaType\n | keyof NumberSchemaType\n | keyof ObjectSchemaType\n | keyof StringSchemaType\n | keyof ReferenceSchemaType\n | keyof BlockDefinition\n | 'group' // we strip this from fields\n\ntype Validation = {validation: ManifestValidationGroup[]} | Record<string, never>\ntype ObjectFields = {fields: ManifestField[]} | Record<string, never>\ntype SerializableProp = ManifestSerializable | ManifestSerializable[] | undefined\ntype ManifestValidationFlag = ManifestValidationRule['flag']\ntype ValidationRuleTransformer = (rule: RuleSpec) => ManifestValidationRule | undefined\n\nconst MAX_CUSTOM_PROPERTY_DEPTH = 5\n\nexport function extractCreateWorkspaceManifest(workspace: Workspace): CreateWorkspaceManifest {\n const serializedSchema = extractManifestSchemaTypes(workspace.schema)\n const serializedTools = extractManifestTools(workspace.tools)\n\n return {\n name: workspace.name,\n title: workspace.title,\n subtitle: workspace.subtitle,\n basePath: workspace.basePath,\n projectId: workspace.projectId,\n dataset: workspace.dataset,\n icon: resolveIcon({\n icon: workspace.icon,\n title: workspace.title,\n subtitle: workspace.subtitle,\n }),\n mediaLibrary: workspace.mediaLibrary,\n schema: serializedSchema,\n tools: serializedTools,\n }\n}\n\n/**\n * Extracts all serializable properties from userland schema types,\n * so they best-effort can be used as definitions for Schema.compile\n. */\nexport function extractManifestSchemaTypes(schema: Schema): ManifestSchemaType[] {\n const typeNames = schema.getTypeNames()\n const context = {schema}\n\n const studioDefaultTypeNames = createSchema({name: 'default', types: []}).getTypeNames()\n\n return typeNames\n .filter((typeName) => !studioDefaultTypeNames.includes(typeName))\n .map((typeName) => schema.get(typeName))\n .filter((type): type is SchemaType => typeof type !== 'undefined')\n .map((type) => transformType(type, context))\n}\n\nfunction transformCommonTypeFields(\n type: SchemaType & {fieldset?: string},\n typeName: string,\n context: Context,\n): Omit<ManifestSchemaType, 'name' | 'title' | 'type'> {\n const arrayProps =\n typeName === 'array' && type.jsonType === 'array' ? transformArrayMember(type, context) : {}\n\n const referenceProps = isReference(type) ? transformReference(type) : {}\n const crossDatasetRefProps = isCrossDatasetReference(type)\n ? transformCrossDatasetReference(type)\n : {}\n const globalRefProps = isGlobalDocumentReference(type)\n ? transformGlobalDocumentReference(type)\n : {}\n\n const objectFields: ObjectFields =\n type.jsonType === 'object' && type.type && isCustomized(type)\n ? {\n fields: getCustomFields(type).map((objectField) => transformField(objectField, context)),\n }\n : {}\n\n return {\n ...retainCustomTypeProps(type),\n ...transformValidation(type.validation),\n ...ensureString('description', type.description),\n ...objectFields,\n ...arrayProps,\n ...referenceProps,\n ...crossDatasetRefProps,\n ...globalRefProps,\n ...ensureConditional('readOnly', type.readOnly),\n ...ensureConditional('hidden', type.hidden),\n ...transformFieldsets(type),\n // fieldset prop gets instrumented via getCustomFields\n ...ensureString('fieldset', type.fieldset),\n ...transformBlockType(type, context),\n }\n}\n\nfunction transformFieldsets(\n type: SchemaType,\n): {fieldsets: ManifestFieldset[]} | Record<string, never> {\n if (type.jsonType !== 'object') {\n return {}\n }\n const fieldsets = type.fieldsets\n ?.filter((fs): fs is MultiFieldSet => !fs.single)\n .map((fs) => {\n const options = isRecord(fs.options) ? {options: retainSerializableProps(fs.options)} : {}\n return {\n name: fs.name,\n ...ensureCustomTitle(fs.name, fs.title),\n ...ensureString('description', fs.description),\n ...ensureConditional('readOnly', fs.readOnly),\n ...ensureConditional('hidden', fs.hidden),\n ...options,\n }\n })\n\n return fieldsets?.length ? {fieldsets} : {}\n}\n\nfunction transformType(type: SchemaType, context: Context): ManifestSchemaType {\n const typeName = type.type ? type.type.name : type.jsonType\n\n return {\n ...transformCommonTypeFields(type, typeName, context),\n name: type.name,\n type: typeName,\n ...ensureCustomTitle(type.name, type.title),\n }\n}\n\nfunction retainCustomTypeProps(type: SchemaType): Record<string, SerializableProp> {\n const manuallySerializedFields: SchemaTypeKey[] = [\n //explicitly added\n 'name',\n 'title',\n 'description',\n 'readOnly',\n 'hidden',\n 'validation',\n 'fieldsets',\n 'fields',\n 'to',\n 'of',\n // not serialized\n 'type',\n 'jsonType',\n '__experimental_actions',\n '__experimental_formPreviewTitle',\n '__experimental_omnisearch_visibility',\n '__experimental_search',\n 'components',\n 'icon',\n 'orderings',\n 'preview',\n 'groups',\n //only exists on fields\n 'group',\n // we know about these, but let them be generically handled\n // deprecated\n // rows (from text)\n // initialValue\n // options\n // crossDatasetReference props\n ]\n const typeWithoutManuallyHandledFields = Object.fromEntries(\n Object.entries(type).filter(\n ([key]) => !manuallySerializedFields.includes(key as unknown as SchemaTypeKey),\n ),\n )\n return retainSerializableProps(typeWithoutManuallyHandledFields) as Record<\n string,\n SerializableProp\n >\n}\n\nfunction retainSerializableProps(maybeSerializable: unknown, depth = 0): SerializableProp {\n if (depth > MAX_CUSTOM_PROPERTY_DEPTH) {\n return undefined\n }\n\n if (!isDefined(maybeSerializable)) {\n return undefined\n }\n\n if (isPrimitive(maybeSerializable)) {\n // cull empty strings\n if (maybeSerializable === '') {\n return undefined\n }\n return maybeSerializable\n }\n\n // url-schemes ect..\n if (maybeSerializable instanceof RegExp) {\n return maybeSerializable.toString()\n }\n\n if (Array.isArray(maybeSerializable)) {\n const arrayItems = maybeSerializable\n .map((item) => retainSerializableProps(item, depth + 1))\n .filter((item): item is ManifestSerializable => isDefined(item))\n return arrayItems.length ? arrayItems : undefined\n }\n\n if (isRecord(maybeSerializable)) {\n const serializableEntries = Object.entries(maybeSerializable)\n .map(([key, value]) => {\n return [key, retainSerializableProps(value, depth + 1)]\n })\n .filter(([, value]) => isDefined(value))\n return serializableEntries.length ? Object.fromEntries(serializableEntries) : undefined\n }\n\n return undefined\n}\n\nfunction transformField(field: ObjectField & {fieldset?: string}, context: Context): ManifestField {\n const fieldType = field.type\n const typeName = getDefinedTypeName(fieldType) ?? fieldType.name\n return {\n ...transformCommonTypeFields(fieldType, typeName, context),\n name: field.name,\n type: typeName,\n ...ensureCustomTitle(field.name, fieldType.title),\n // this prop gets added synthetically via getCustomFields\n ...ensureString('fieldset', field.fieldset),\n }\n}\n\nfunction transformArrayMember(\n arrayMember: ArraySchemaType,\n context: Context,\n): Pick<ManifestField, 'of'> {\n return {\n of: arrayMember.of.map((type) => {\n const typeName = getDefinedTypeName(type) ?? type.name\n return {\n ...transformCommonTypeFields(type, typeName, context),\n type: typeName,\n ...(typeName === type.name ? {} : {name: type.name}),\n ...ensureCustomTitle(type.name, type.title),\n }\n }),\n }\n}\n\nfunction transformReference(reference: ReferenceSchemaType): Pick<ManifestSchemaType, 'to'> {\n return {\n to: (reference.to ?? []).map((type) => {\n return {\n ...retainCustomTypeProps(type),\n type: type.name,\n }\n }),\n }\n}\n\nfunction transformCrossDatasetReference(\n reference: CrossDatasetReferenceSchemaType,\n): Pick<ManifestSchemaType, 'to' | 'preview'> {\n return {\n to: (reference.to ?? []).map((crossDataset) => {\n const preview = crossDataset.preview?.select\n ? {preview: {select: crossDataset.preview.select}}\n : {}\n return {\n type: crossDataset.type,\n ...ensureCustomTitle(crossDataset.type, crossDataset.title),\n ...preview,\n }\n }),\n }\n}\n\nfunction transformGlobalDocumentReference(\n reference: GlobalDocumentReferenceSchemaType,\n): Pick<ManifestSchemaType, 'to' | 'preview'> {\n return {\n to: (reference.to ?? []).map((crossDataset) => {\n const preview = crossDataset.preview?.select\n ? {preview: {select: crossDataset.preview.select}}\n : {}\n return {\n type: crossDataset.type,\n ...ensureCustomTitle(crossDataset.type, crossDataset.title),\n ...preview,\n }\n }),\n }\n}\n\nconst transformTypeValidationRule: ValidationRuleTransformer = (rule) => {\n return {\n ...rule,\n constraint:\n 'constraint' in rule &&\n (typeof rule.constraint === 'string'\n ? rule.constraint.toLowerCase()\n : retainSerializableProps(rule.constraint)),\n }\n}\n\nconst validationRuleTransformers: Partial<\n Record<ManifestValidationFlag, ValidationRuleTransformer>\n> = {\n type: transformTypeValidationRule,\n}\n\nfunction transformValidation(validation: SchemaValidationValue): Validation {\n const validationArray = (Array.isArray(validation) ? validation : [validation]).filter(\n (value): value is Rule => typeof value === 'object' && '_type' in value,\n )\n\n // we dont want type in the output as that is implicitly given by the typedef itself an will only bloat the payload\n const disallowedFlags = ['type']\n\n // Validation rules that refer to other fields use symbols, which cannot be serialized. It would\n // be possible to transform these to a serializable type, but we haven't implemented that for now.\n const disallowedConstraintTypes: (symbol | unknown)[] = [ConcreteRuleClass.FIELD_REF]\n\n const serializedValidation = validationArray\n .map(({_rules, _message, _level}) => {\n const message: Partial<Pick<ManifestValidationGroup, 'message'>> =\n typeof _message === 'string' ? {message: _message} : {}\n\n const serializedRules = _rules\n .filter((rule) => {\n if (!('constraint' in rule)) {\n return false\n }\n\n const {flag, constraint} = rule\n\n if (disallowedFlags.includes(flag)) {\n return false\n }\n\n return !(\n typeof constraint === 'object' &&\n 'type' in constraint &&\n disallowedConstraintTypes.includes(constraint.type)\n )\n })\n .reduce<ManifestValidationRule[]>((rules, rule) => {\n const transformer: ValidationRuleTransformer =\n validationRuleTransformers[rule.flag] ??\n ((spec) => retainSerializableProps(spec) as ManifestValidationRule)\n\n const transformedRule = transformer(rule)\n if (!transformedRule) {\n return rules\n }\n return [...rules, transformedRule]\n }, [])\n\n return {\n rules: serializedRules,\n level: _level,\n ...message,\n }\n })\n .filter((group) => !!group.rules.length)\n\n return serializedValidation.length ? {validation: serializedValidation} : {}\n}\n\nfunction ensureCustomTitle(typeName: string, value: unknown) {\n const titleObject = ensureString('title', value)\n\n const defaultTitle = startCase(typeName)\n // omit title if its the same as default, to reduce payload\n if (titleObject.title === defaultTitle) {\n return {}\n }\n return titleObject\n}\n\nfunction ensureString<Key extends string>(key: Key, value: unknown) {\n if (typeof value === 'string') {\n return {\n [key]: value,\n }\n }\n\n return {}\n}\n\nfunction ensureConditional<const Key extends string>(key: Key, value: unknown) {\n if (typeof value === 'boolean') {\n return {\n [key]: value,\n }\n }\n\n if (typeof value === 'function') {\n return {\n [key]: 'conditional',\n }\n }\n\n return {}\n}\n\nexport function transformBlockType(\n blockType: SchemaType,\n context: Context,\n): Pick<ManifestSchemaType, 'marks' | 'lists' | 'styles' | 'of'> | Record<string, never> {\n if (blockType.jsonType !== 'object' || !isType(blockType, 'block')) {\n return {}\n }\n\n const childrenField = blockType.fields?.find((field) => field.name === 'children') as\n | {type: ArraySchemaType}\n | undefined\n\n if (!childrenField) {\n return {}\n }\n const ofType = childrenField.type.of\n if (!ofType) {\n return {}\n }\n const spanType = ofType.find((memberType) => memberType.name === 'span') as\n | ObjectSchemaType\n | undefined\n if (!spanType) {\n return {}\n }\n const inlineObjectTypes = (ofType.filter((memberType) => memberType.name !== 'span') ||\n []) as ObjectSchemaType[]\n\n return {\n marks: {\n annotations: (spanType as SpanSchemaType).annotations.map((t) => transformType(t, context)),\n decorators: resolveEnabledDecorators(spanType),\n },\n lists: resolveEnabledListItems(blockType),\n styles: resolveEnabledStyles(blockType),\n of: inlineObjectTypes.map((t) => transformType(t, context)),\n }\n}\n\nfunction resolveEnabledStyles(blockType: ObjectSchemaType): ManifestTitledValue[] | undefined {\n const styleField = blockType.fields?.find((btField) => btField.name === 'style')\n return resolveTitleValueArray(styleField?.type?.options?.list)\n}\n\nfunction resolveEnabledDecorators(spanType: ObjectSchemaType): ManifestTitledValue[] | undefined {\n return 'decorators' in spanType ? resolveTitleValueArray(spanType.decorators) : undefined\n}\n\nfunction resolveEnabledListItems(blockType: ObjectSchemaType): ManifestTitledValue[] | undefined {\n const listField = blockType.fields?.find((btField) => btField.name === 'listItem')\n return resolveTitleValueArray(listField?.type?.options?.list)\n}\n\nfunction resolveTitleValueArray(possibleArray: unknown): ManifestTitledValue[] | undefined {\n if (!possibleArray || !Array.isArray(possibleArray)) {\n return undefined\n }\n const titledValues = possibleArray\n .filter(\n (d): d is {value: string; title?: string} => isRecord(d) && !!d.value && isString(d.value),\n )\n .map((item) => {\n return {\n value: item.value,\n ...ensureString('title', item.title),\n } satisfies ManifestTitledValue\n })\n if (!titledValues?.length) {\n return undefined\n }\n\n return titledValues\n}\n\nconst extractManifestTools = (tools: Workspace['tools']): ManifestTool[] =>\n tools.map((tool) => {\n const {\n title,\n name,\n icon,\n __internalApplicationType: type,\n } = tool as Workspace['tools'][number] & {__internalApplicationType: string}\n return {\n title,\n name,\n type: type || null,\n icon: resolveIcon({\n icon,\n title,\n }),\n } satisfies ManifestTool\n })\n\nconst resolveIcon = (props: SchemaIconProps): string | null => {\n try {\n const html = renderToString(<SchemaIcon {...props} />)\n return DOMPurify.sanitize(html.trim(), config)\n } catch {\n return null\n }\n}\n","import {isMainThread, parentPort, workerData as _workerData} from 'node:worker_threads'\n\nimport {extractCreateWorkspaceManifest} from '../../manifest/extractWorkspaceManifest'\nimport {getStudioWorkspaces} from '../util/getStudioWorkspaces'\nimport {mockBrowserEnvironment} from '../util/mockBrowserEnvironment'\n\n/** @internal */\nexport interface ExtractManifestWorkerData {\n workDir: string\n}\n\nasync function main() {\n if (isMainThread || !parentPort) {\n throw new Error('This module must be run as a worker thread')\n }\n\n const opts = _workerData as ExtractManifestWorkerData\n\n const cleanup = mockBrowserEnvironment(opts.workDir)\n\n try {\n const workspaces = await getStudioWorkspaces({basePath: opts.workDir})\n\n for (const workspace of workspaces) {\n parentPort?.postMessage(extractCreateWorkspaceManifest(workspace))\n }\n } finally {\n parentPort?.close()\n cleanup()\n }\n}\n\nvoid main().then(() => process.exit())\n"],"names":["theme","buildTheme","SchemaIcon","t0","$","_c","icon","title","subtitle","t1","normalizeIcon","t2","jsx","ThemeProvider","Icon","isValidElementType","isValidElement","createDefaultIcon","DEFAULT_IMAGE_FIELDS","DEFAULT_FILE_FIELDS","DEFAULT_GEOPOINT_FIELDS","DEFAULT_SLUG_FIELDS","getCustomFields","type","fields","fieldsets","flatMap","fs","single","field","map","fieldset","name","isType","filter","f","includes","isReference","isCrossDatasetReference","isGlobalDocumentReference","isObjectField","maybeOjectField","isCustomized","maybeCustomized","internalOwnProps","getSchemaTypeInternalOwnProps","Array","isArray","length","schemaType","typeName","isDefined","value","isRecord","isPrimitive","isString","isBoolean","isNumber","_internal_ownProps","getDefinedTypeName","HTML_TAGS","SVG_TAGS","SVG_FILTER_TAGS","ALLOWED_TAGS","HTML_ATTRIBUTES","SVG_ATTRIBUTES","ALLOWED_ATTR","config","MAX_CUSTOM_PROPERTY_DEPTH","extractCreateWorkspaceManifest","workspace","serializedSchema","extractManifestSchemaTypes","schema","serializedTools","extractManifestTools","tools","basePath","projectId","dataset","resolveIcon","mediaLibrary","typeNames","getTypeNames","studioDefaultTypeNames","createSchema","types","get","transformType","transformCommonTypeFields","context","arrayProps","jsonType","transformArrayMember","referenceProps","transformReference","crossDatasetRefProps","transformCrossDatasetReference","globalRefProps","transformGlobalDocumentReference","objectFields","objectField","transformField","retainCustomTypeProps","transformValidation","validation","ensureString","description","ensureConditional","readOnly","hidden","transformFieldsets","transformBlockType","options","retainSerializableProps","ensureCustomTitle","manuallySerializedFields","typeWithoutManuallyHandledFields","Object","fromEntries","entries","key","maybeSerializable","depth","RegExp","toString","arrayItems","item","undefined","serializableEntries","fieldType","arrayMember","of","reference","to","crossDataset","preview","select","transformTypeValidationRule","rule","constraint","toLowerCase","validationRuleTransformers","validationArray","disallowedFlags","disallowedConstraintTypes","ConcreteRuleClass","FIELD_REF","serializedValidation","_rules","_message","_level","message","rules","flag","reduce","transformedRule","spec","level","group","titleObject","defaultTitle","startCase","blockType","childrenField","find","ofType","spanType","memberType","inlineObjectTypes","marks","annotations","t","decorators","resolveEnabledDecorators","lists","resolveEnabledListItems","styles","resolveEnabledStyles","styleField","btField","resolveTitleValueArray","list","listField","possibleArray","titledValues","d","tool","__internalApplicationType","props","html","renderToString","DOMPurify","sanitize","trim","main","isMainThread","parentPort","Error","opts","_workerData","cleanup","mockBrowserEnvironment","workDir","workspaces","getStudioWorkspaces","postMessage","close","then","process","exit"],"mappings":";;;;;;AAMA,MAAMA,QAAQC,QAAAA,WAAAA,GAQRC,aAAaC,CAAAA,OAAA;AAAA,QAAAC,IAAAC,kBAAA,CAAA,GAAC;AAAA,IAAAC;AAAAA,IAAAC;AAAAA,IAAAC;AAAAA,EAAAA,IAAAL;AAAwC,MAAAM;AAAAL,IAAA,CAAA,MAAAE,QAAAF,SAAAI,YAAAJ,EAAA,CAAA,MAAAG,SACrBE,KAAAC,cAAcJ,MAAMC,OAAOC,QAAQ,GAACJ,OAAAE,MAAAF,OAAAI,UAAAJ,OAAAG,OAAAH,OAAAK,MAAAA,KAAAL,EAAA,CAAA;AAAA,MAAAO;AAAA,SAAAP,SAAAK,MAAlEE,KAAAC,+BAACC,GAAAA,eAAA,EAAqBb,OAAQS,UAAAA,GAAAA,CAAqC,GAAgBL,OAAAK,IAAAL,OAAAO,MAAAA,KAAAP,EAAA,CAAA,GAAnFO;AAAmF;AAG5F,SAASD,cACPI,MACAP,OACAC,WAAW,IACQ;AACnB,SAAIO,QAAAA,mBAAmBD,IAAI,IAAUF,2BAAAA,IAAC,MAAA,CAAA,CAAI,IACtCI,MAAAA,eAAeF,IAAI,IAAUA,OAC1BG,OAAAA,kBAAkBV,OAAOC,QAAQ;AAC1C;ACjBA,MAAMU,uBAAuB,CAAC,SAAS,WAAW,QAAQ,OAAO,GAC3DC,sBAAsB,CAAC,SAAS,OAAO,GACvCC,0BAA0B,CAAC,OAAO,OAAO,KAAK,GAC9CC,sBAAsB,CAAC,WAAW,QAAQ;AAIzC,SAASC,gBAAgBC,MAA+D;AAC7F,QAAMC,SAAS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IrFE,kBAAkB,CACtB,OACA,SACA,eACA,YACA,iBACA,iBACA,UACA,WACA,OACA,UACA,SACA,OAAO,GAGHC,iBAAiB,CACrB,iBACA,cACA,YACA,sBACA,aACA,UACA,iBACA,iBACA,WACA,iBACA,kBACA,SACA,QACA,MACA,SACA,QACA,iBACA,aACA,aACA,SACA,uBACA,+BACA,iBACA,mBACA,MACA,MACA,KACA,MACA,MACA,mBACA,aACA,WACA,WACA,OACA,YACA,aACA,OACA,YACA,QACA,gBACA,aACA,UACA,eACA,eACA,iBACA,eACA,aACA,oBACA,gBACA,cACA,gBACA,eACA,MACA,MACA,MACA,MACA,cACA,YACA,iBACA,qBACA,UACA,QACA,MACA,mBACA,MACA,OACA,aACA,KACA,MACA,MACA,MACA,MACA,WACA,aACA,cACA,YACA,QACA,gBACA,kBACA,gBACA,oBACA,kBACA,SACA,cACA,cACA,gBACA,gBACA,eACA,eACA,oBACA,aACA,OACA,QACA,SACA,UACA,QACA,OACA,QACA,cACA,UACA,YACA,WACA,SACA,UACA,eACA,UACA,YACA,eACA,QACA,cACA,uBACA,oBACA,gBACA,UACA,iBACA,uBACA,kBACA,KACA,MACA,MACA,UACA,QACA,QACA,eACA,aACA,WACA,UACA,UACA,SACA,QACA,mBACA,SACA,oBACA,oBACA,gBACA,eACA,gBACA,eACA,cACA,gBACA,oBACA,qBACA,kBACA,mBACA,qBACA,kBACA,UACA,gBACA,SACA,gBACA,kBACA,YACA,eACA,WACA,WACA,aACA,oBACA,eACA,mBACA,kBACA,cACA,QACA,MACA,MACA,WACA,UACA,WACA,cACA,WACA,cACA,iBACA,iBACA,SACA,gBACA,QACA,gBACA,oBACA,oBACA,KACA,MACA,MACA,SACA,KACA,MACA,MACA,KACA,YAAY,GAGRC,eAAuC,CAAC,GAAGD,gBAAgB,GAAGD,eAAe,GAE7EG,SAAS;AAAA,EACbD;AAAAA,EACAH;AACF,GCnOMK,4BAA4B;AAE3B,SAASC,+BAA+BC,WAA+C;AAC5F,QAAMC,mB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AAAA,EAAAA,IACzBoK;AACJ,SAAO;AAAA,IACLpL;AAAAA,IACAyB;AAAAA,IACAT,MAAMA,QAAQ;AAAA,IACdjB,MAAM0E,YAAY;AAAA,MAChB1E;AAAAA,MACAC;AAAAA,IAAAA,CACD;AAAA,EAAA;AAEL,CAAC,GAEGyE,cAAe6G,CAAAA,UAA0C;AAC7D,MAAI;AACF,UAAMC,OAAOC,OAAAA,eAAenL,2BAAAA,IAAC,YAAA,EAAW,GAAIiL,OAAM,CAAG;AACrD,WAAOG,mBAAAA,QAAUC,SAASH,KAAKI,KAAAA,GAAQ/H,MAAM;AAAA,EAC/C,QAAQ;AACN,WAAO;AAAA,EACT;AACF;ACziBA,eAAegI,OAAO;AACpB,MAAIC,oBAAAA,gBAAgB,CAACC,oBAAAA;AACnB,UAAM,IAAIC,MAAM,4CAA4C;AAG9D,QAAMC,OAAOC,oBAAAA,YAEPC,UAAUC,uBAAAA,uBAAuBH,KAAKI,OAAO;AAEnD,MAAI;AACF,UAAMC,aAAa,MAAMC,wCAAoB;AAAA,MAAChI,UAAU0H,KAAKI;AAAAA,IAAAA,CAAQ;AAErE,eAAWrI,aAAasI;AACtBP,0BAAAA,YAAYS,YAAYzI,+BAA+BC,SAAS,CAAC;AAAA,EAErE,UAAA;AACE+H,oCAAYU,MAAAA,GACZN,QAAAA;AAAAA,EACF;AACF;AAEKN,KAAAA,EAAOa,KAAK,MAAMC,QAAQC,MAAM;"}
package/lib/index.js CHANGED
@@ -9,7 +9,7 @@ import { SchedulesContext as SchedulesContext2 } from "sanity/_singletons";
9
9
  import { Badge, Grid, rem, Box, Stack, Card, Spinner, Text as Text$1, Layer, Flex, Button as Button$1, Skeleton, Heading, Avatar, AvatarStack, Inline, Breadcrumbs, useClickOutsideEvent, Code, useTheme, useGlobalKeyDown, MenuDivider, Menu, useElementRect, Autocomplete, useToast, useElementSize, AvatarCounter, TextInput as TextInput$1, Container as Container$2, Checkbox as Checkbox$1, Switch as Switch$1, Select, LayerProvider, ElementQuery, TabList, rgba, useLayer, MenuItem as MenuItem$1, useBoundaryElement, BoundaryElementProvider, usePortal, PortalProvider, Portal, _responsive, useRootTheme, useArrayProp, TextArea, TextSkeleton, useMediaIndex, isHTMLElement, Radio, TabPanel, studioTheme, Label, Dialog as Dialog$1, ThemeColorProvider, DialogProvider, focusLastDescendant, focusFirstDescendant, VirtualList as VirtualList$1, usePrefersDark, ThemeProvider, ToastProvider } from "@sanity/ui";
10
10
  import { useVirtualizer, defaultRangeExtractor, elementScroll } from "@tanstack/react-virtual";
11
11
  import { throttle, isEqual as isEqual$2, memoize as memoize$1, partition, groupBy, omit, isPlainObject as isPlainObject$1, get, flatten as flatten$1, uniqBy, sample, uniq, orderBy, xor, debounce, keyBy, toLower, compact, words, intersection, union, flow, trim, sortBy, isFinite, pickBy, findIndex as findIndex$1, clone, isObject, isString as isString$1, noop as noop$6, capitalize, deburr, startCase, last as last$1, difference, upperFirst, set as set$1, find, uniqueId, castArray, pick, sortedIndex, values, identity as identity$2, isEmpty as isEmpty$1, range, sum as sum$1, max, escapeRegExp as escapeRegExp$1 } from "lodash-es";
12
- import { styled, css, keyframes, useTheme as useTheme$1, createGlobalStyle, ServerStyleSheet } from "styled-components";
12
+ import { styled, css, keyframes, useTheme as useTheme$1, createGlobalStyle } from "styled-components";
13
13
  import { EllipsisHorizontalIcon, ErrorOutlineIcon, CircleIcon, CalendarIcon, UnpublishIcon, PublishIcon, EditIcon, CloseIcon, TrashIcon, AddCircleIcon, TimelineIcon, ChevronRightIcon, DocumentIcon, ImageIcon, ChevronDownIcon, ArrowRightIcon, ArrowDownIcon, RevertIcon, WarningOutlineIcon, InfoOutlineIcon, CheckmarkIcon, AddIcon, HelpCircleIcon, AccessDeniedIcon, ToggleArrowRightIcon, SyncIcon, LaunchIcon, BulbOutlineIcon, UnknownIcon, UploadIcon, DragHandleIcon, SearchIcon, StackCompactIcon, PanelLeftIcon, InsertAboveIcon, InsertBelowIcon, CopyIcon, AddDocumentIcon, ChevronLeftIcon, EarthGlobeIcon, EarthAmericasIcon, LinkIcon, UlistIcon, OlistIcon, CodeIcon, UnderlineIcon, StrikethroughIcon, ItalicIcon, BoldIcon, BlockElementIcon, InlineElementIcon, CollapseIcon, ExpandIcon, ResetIcon, Icon, ChevronUpIcon, DownloadIcon, DocumentsIcon, ReadOnlyIcon, BinaryDocumentIcon, CropIcon, EyeOpenIcon, DotIcon, LockIcon, CheckmarkCircleIcon, PinFilledIcon, PinIcon, RestoreIcon, ClockIcon, CloseCircleIcon, UnarchiveIcon, ArchiveIcon, ArrowUpIcon, ControlsIcon, SpinnerIcon, ArrowLeftIcon, SortIcon, ComposeSparklesIcon, ClipboardIcon, StringIcon, NumberIcon, BlockContentIcon, UndoIcon, UnlinkIcon, LinkRemovedIcon, AddCommentIcon, CommentIcon, SelectIcon, TaskIcon, UserIcon, DesktopIcon, MoonIcon, SunIcon, EyeClosedIcon, DoubleChevronRightIcon, AddUserIcon, CogIcon, BoltIcon, LeaveIcon, UsersIcon, GithubIcon, RefreshIcon, MenuIcon } from "@sanity/icons";
14
14
  import { Button, ErrorBoundary, Tooltip, Popover, MenuItem, MenuButton, TooltipDelayGroupProvider, Dialog, Tab } from "./_chunks-es/TooltipDelayGroupProvider.js";
15
15
  import { Hotkeys } from "./_chunks-es/TooltipDelayGroupProvider.js";
@@ -85363,25 +85363,17 @@ const purifyConfig = {
85363
85363
  "feSpotLight",
85364
85364
  "feTile",
85365
85365
  "feTurbulence"
85366
- ],
85367
- /**
85368
- * Required to allow for the use of `style` tags,
85369
- * namely rendering the style tags from `styled-components`
85370
- */
85371
- FORCE_BODY: !0
85366
+ ]
85372
85367
  };
85373
85368
  function normalizeIcon(Icon2, title, subtitle = "") {
85374
85369
  return isValidElementType(Icon2) ? /* @__PURE__ */ jsx(Icon2, {}) : isValidElement(Icon2) ? Icon2 : createDefaultIcon(title, subtitle);
85375
85370
  }
85376
85371
  const resolveIcon = (props2) => {
85377
- const sheet = new ServerStyleSheet();
85378
85372
  try {
85379
- const iconElement = normalizeIcon(props2.icon, props2.title, props2.subtitle), wrappedElement = /* @__PURE__ */ jsx(ThemeProvider, { theme: props2.theme, children: iconElement }), elementHtml = renderToStaticMarkup(sheet.collectStyles(wrappedElement)), html = `${sheet.getStyleTags()}${elementHtml}`.trim();
85373
+ const iconElement = normalizeIcon(props2.icon, props2.title, props2.subtitle), wrappedElement = /* @__PURE__ */ jsx(ThemeProvider, { theme: props2.theme, children: iconElement }), html = renderToStaticMarkup(wrappedElement).trim();
85380
85374
  return DOMPurify.sanitize(html, purifyConfig);
85381
85375
  } catch {
85382
85376
  return;
85383
- } finally {
85384
- sheet.seal();
85385
85377
  }
85386
85378
  }, buildId = (
85387
85379
  // @ts-expect-error: __SANITY_BUILD_TIMESTAMP__ is a global env variable set by the vite config