tinacms 2.7.6 → 2.7.7

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.
package/dist/client.js CHANGED
@@ -197,3 +197,4 @@
197
197
  exports2.createClient = createClient;
198
198
  Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
199
199
  });
200
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sources":["../src/unifiedClient/index.ts","../src/cache/node-cache.ts"],"sourcesContent":["import type { Config } from '@tinacms/schema-tools';\nimport AsyncLock from 'async-lock';\nimport type { GraphQLError } from 'graphql';\nimport type { Cache } from '../cache/index';\n\nexport const TINA_HOST = 'content.tinajs.io';\nexport interface TinaClientArgs<GenQueries = Record<string, unknown>> {\n url: string;\n token?: string;\n queries: (client: TinaClient<GenQueries>) => GenQueries;\n errorPolicy?: Config['client']['errorPolicy'];\n cacheDir?: string;\n}\nexport type TinaClientRequestArgs = {\n variables?: Record<string, any>;\n query: string;\n errorPolicy?: 'throw' | 'include';\n} & Partial<Omit<TinaClientArgs, 'queries'>>;\n\nexport type TinaClientURLParts = {\n host: string;\n clientId: string;\n branch: string;\n isLocalClient: boolean;\n};\n\n/**\n * Replaces the part of a URL after 'github/' with a specified replacement string.\n *\n * @param {string} url The original URL.\n * @param {string} replacement The string to replace the part after 'github/'.\n * @returns {string} The modified URL, or the original URL if 'github/' is not found.\n */\nfunction replaceGithubPathSplit(url: string, replacement: string) {\n const parts = url.split('github/');\n if (parts.length > 1 && replacement) {\n return parts[0] + 'github/' + replacement;\n } else {\n return url;\n }\n}\n\nexport class TinaClient<GenQueries> {\n public apiUrl: string;\n public readonlyToken?: string;\n public queries: GenQueries;\n public errorPolicy: Config['client']['errorPolicy'];\n initialized = false;\n cacheLock: AsyncLock | undefined;\n cacheDir: string;\n cache: Cache;\n\n constructor({\n token,\n url,\n queries,\n errorPolicy,\n cacheDir,\n }: TinaClientArgs<GenQueries>) {\n this.apiUrl = url;\n this.readonlyToken = token?.trim();\n this.queries = queries(this);\n this.errorPolicy = errorPolicy || 'throw';\n this.cacheDir = cacheDir || '';\n }\n\n async init() {\n if (this.initialized) {\n return;\n }\n try {\n if (\n this.cacheDir &&\n typeof window === 'undefined' &&\n typeof require !== 'undefined'\n ) {\n const { NodeCache } = await import('../cache/node-cache');\n this.cache = await NodeCache(this.cacheDir);\n this.cacheLock = new AsyncLock();\n }\n } catch (e) {\n console.error(e);\n }\n this.initialized = true;\n }\n\n public async request<DataType extends Record<string, any> = any>(\n { errorPolicy, ...args }: TinaClientRequestArgs,\n options: { fetchOptions?: Parameters<typeof fetch>[1] }\n ) {\n await this.init();\n const errorPolicyDefined = errorPolicy || this.errorPolicy;\n const headers = new Headers();\n if (this.readonlyToken) {\n headers.append('X-API-KEY', this.readonlyToken);\n }\n headers.append('Content-Type', 'application/json');\n if (options?.fetchOptions) {\n if (options?.fetchOptions?.headers) {\n Object.entries(options.fetchOptions.headers).forEach(([key, value]) => {\n headers.append(key, value);\n });\n }\n }\n const { headers: _, ...providedFetchOptions } = options?.fetchOptions || {};\n\n const bodyString = JSON.stringify({\n query: args.query,\n variables: args?.variables || {},\n });\n\n const optionsObject: Parameters<typeof fetch>[1] = {\n method: 'POST',\n headers,\n body: bodyString,\n redirect: 'follow',\n ...providedFetchOptions,\n };\n\n // Look for the header and change to use this branch instead of the build time generated branch.\n // This comes from the clients fetch options:\n //client.queries.collection({}, {\n // fetchOptions: {\n // headers: {\n // 'x-branch': cookieStore.get('x-branch')?.value,\n // },\n // },\n //})\n const draftBranch = headers.get('x-branch');\n const url = replaceGithubPathSplit(args?.url || this.apiUrl, draftBranch);\n\n let key = '';\n let result: {\n data: DataType;\n errors: GraphQLError[] | null;\n query: string;\n };\n if (this.cache) {\n key = this.cache.makeKey(bodyString);\n await this.cacheLock.acquire(key, async () => {\n result = await this.cache.get(key);\n if (!result) {\n result = await requestFromServer<DataType>(\n url,\n args.query,\n optionsObject,\n errorPolicyDefined\n );\n await this.cache.set(key, result);\n }\n });\n } else {\n result = await requestFromServer<DataType>(\n url,\n args.query,\n optionsObject,\n errorPolicyDefined\n );\n }\n\n return result;\n }\n}\n\nasync function requestFromServer<DataType extends Record<string, any> = any>(\n url: string,\n query: string,\n optionsObject: RequestInit,\n errorPolicyDefined: 'throw' | 'include'\n) {\n const res = await fetch(url, optionsObject);\n if (!res.ok) {\n let additionalInfo = '';\n if (res.status === 401) {\n additionalInfo =\n 'Please check that your client ID, URL and read only token are configured properly.';\n }\n\n throw new Error(\n `Server responded with status code ${res.status}, ${res.statusText}. ${\n additionalInfo ? additionalInfo : ''\n } Please see our FAQ for more information: https://tina.io/docs/errors/faq/`\n );\n }\n const json = await res.json();\n if (json.errors && errorPolicyDefined === 'throw') {\n throw new Error(\n `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/\n Errors: \\n\\t${json.errors.map((error) => error.message).join('\\n')}`\n );\n }\n const result = {\n data: json?.data as DataType,\n errors: (json?.errors || null) as GraphQLError[] | null,\n query,\n };\n return result;\n}\n\nexport function createClient<GenQueries>(args: TinaClientArgs<GenQueries>) {\n const client = new TinaClient<ReturnType<typeof args.queries>>(args);\n return client;\n}\n","import type { Cache } from './index';\n\n// Create the cache directory if it doesn't exist.\n// Returns the path of the cache directory.\nexport const makeCacheDir = async (\n dir: string,\n fs: any,\n path: any,\n os: any\n) => {\n const pathParts = dir.split(path.sep).filter(Boolean);\n const cacheHash = pathParts[pathParts.length - 1];\n const rootUser = pathParts[0];\n let cacheDir = dir;\n\n // Check if the root directory exists. If not, create the cache in the tmp directory.\n if (!fs.existsSync(path.join(path.sep, rootUser))) {\n cacheDir = path.join(os.tmpdir(), cacheHash);\n }\n\n try {\n fs.mkdirSync(cacheDir, { recursive: true });\n } catch (error) {\n throw new Error(`Failed to create cache directory: ${error.message}`);\n }\n\n return cacheDir;\n};\n\nexport const NodeCache = async (dir: string): Promise<Cache> => {\n // TODO: These will need to be changed from using require to import when we eventually move to ESM\n const fs = require('node:fs');\n const path = require('node:path');\n const os = require('node:os');\n\n const { createHash } = require('node:crypto');\n const cacheDir = await makeCacheDir(dir, fs, path, os);\n\n return {\n makeKey: (key: any) => {\n const input =\n key && key instanceof Object ? JSON.stringify(key) : key || '';\n return createHash('sha256').update(input).digest('hex');\n },\n get: async (key: string) => {\n let readValue: object | undefined;\n\n const cacheFilename = `${cacheDir}/${key}`;\n try {\n const data = await fs.promises.readFile(cacheFilename, 'utf-8');\n readValue = JSON.parse(data);\n } catch (e) {\n if (e.code !== 'ENOENT') {\n console.error(\n `Failed to read cache file to ${cacheFilename}: ${e.message}`\n );\n }\n }\n\n return readValue;\n },\n set: async (key: string, value: any) => {\n const cacheFilename = `${cacheDir}/${key}`;\n try {\n await fs.promises.writeFile(cacheFilename, JSON.stringify(value), {\n encoding: 'utf-8',\n flag: 'wx', // Don't overwrite existing caches\n });\n } catch (e) {\n if (e.code !== 'EEXIST') {\n console.error(\n `Failed to write cache file to ${cacheFilename}: ${e.message}`\n );\n }\n }\n },\n };\n};\n"],"names":["NodeCache","key"],"mappings":";;;;AAKa,QAAA,YAAY;AA4BzB,WAAS,uBAAuB,KAAa,aAAqB;AAC1D,UAAA,QAAQ,IAAI,MAAM,SAAS;AAC7B,QAAA,MAAM,SAAS,KAAK,aAAa;AAC5B,aAAA,MAAM,CAAC,IAAI,YAAY;AAAA,IAAA,OACzB;AACE,aAAA;AAAA,IACT;AAAA,EACF;AAAA,EAEO,MAAM,WAAuB;AAAA,IAUlC,YAAY;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IAAA,GAC6B;AAXjB,WAAA,cAAA;AAYZ,WAAK,SAAS;AACT,WAAA,gBAAgB,+BAAO;AACvB,WAAA,UAAU,QAAQ,IAAI;AAC3B,WAAK,cAAc,eAAe;AAClC,WAAK,WAAW,YAAY;AAAA,IAC9B;AAAA,IAEA,MAAM,OAAO;AACX,UAAI,KAAK,aAAa;AACpB;AAAA,MACF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AU,eAAe,KAAK,UAAU,KAAK,GAAG;AAAA,YAChE,UAAU;AAAA,YACV,MAAM;AAAA;AAAA,UAAA,CACP;AAAA,iBACM,GAAG;AACN,cAAA,EAAE,SAAS,UAAU;AACf,oBAAA;AAAA,cACN,iCAAiC,aAAa,KAAK,EAAE,OAAO;AAAA,YAAA;AAAA,UAEhE;AAAA,QACF;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ;;;;;;;;;;;"}
package/dist/client.mjs CHANGED
@@ -130,3 +130,4 @@ export {
130
130
  TinaClient,
131
131
  createClient
132
132
  };
133
+ //# sourceMappingURL=client.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.mjs","sources":["../src/unifiedClient/index.ts"],"sourcesContent":["import type { Config } from '@tinacms/schema-tools';\nimport AsyncLock from 'async-lock';\nimport type { GraphQLError } from 'graphql';\nimport type { Cache } from '../cache/index';\n\nexport const TINA_HOST = 'content.tinajs.io';\nexport interface TinaClientArgs<GenQueries = Record<string, unknown>> {\n url: string;\n token?: string;\n queries: (client: TinaClient<GenQueries>) => GenQueries;\n errorPolicy?: Config['client']['errorPolicy'];\n cacheDir?: string;\n}\nexport type TinaClientRequestArgs = {\n variables?: Record<string, any>;\n query: string;\n errorPolicy?: 'throw' | 'include';\n} & Partial<Omit<TinaClientArgs, 'queries'>>;\n\nexport type TinaClientURLParts = {\n host: string;\n clientId: string;\n branch: string;\n isLocalClient: boolean;\n};\n\n/**\n * Replaces the part of a URL after 'github/' with a specified replacement string.\n *\n * @param {string} url The original URL.\n * @param {string} replacement The string to replace the part after 'github/'.\n * @returns {string} The modified URL, or the original URL if 'github/' is not found.\n */\nfunction replaceGithubPathSplit(url: string, replacement: string) {\n const parts = url.split('github/');\n if (parts.length > 1 && replacement) {\n return parts[0] + 'github/' + replacement;\n } else {\n return url;\n }\n}\n\nexport class TinaClient<GenQueries> {\n public apiUrl: string;\n public readonlyToken?: string;\n public queries: GenQueries;\n public errorPolicy: Config['client']['errorPolicy'];\n initialized = false;\n cacheLock: AsyncLock | undefined;\n cacheDir: string;\n cache: Cache;\n\n constructor({\n token,\n url,\n queries,\n errorPolicy,\n cacheDir,\n }: TinaClientArgs<GenQueries>) {\n this.apiUrl = url;\n this.readonlyToken = token?.trim();\n this.queries = queries(this);\n this.errorPolicy = errorPolicy || 'throw';\n this.cacheDir = cacheDir || '';\n }\n\n async init() {\n if (this.initialized) {\n return;\n }\n try {\n if (\n this.cacheDir &&\n typeof window === 'undefined' &&\n typeof require !== 'undefined'\n ) {\n const { NodeCache } = await import('../cache/node-cache');\n this.cache = await NodeCache(this.cacheDir);\n this.cacheLock = new AsyncLock();\n }\n } catch (e) {\n console.error(e);\n }\n this.initialized = true;\n }\n\n public async request<DataType extends Record<string, any> = any>(\n { errorPolicy, ...args }: TinaClientRequestArgs,\n options: { fetchOptions?: Parameters<typeof fetch>[1] }\n ) {\n await this.init();\n const errorPolicyDefined = errorPolicy || this.errorPolicy;\n const headers = new Headers();\n if (this.readonlyToken) {\n headers.append('X-API-KEY', this.readonlyToken);\n }\n headers.append('Content-Type', 'application/json');\n if (options?.fetchOptions) {\n if (options?.fetchOptions?.headers) {\n Object.entries(options.fetchOptions.headers).forEach(([key, value]) => {\n headers.append(key, value);\n });\n }\n }\n const { headers: _, ...providedFetchOptions } = options?.fetchOptions || {};\n\n const bodyString = JSON.stringify({\n query: args.query,\n variables: args?.variables || {},\n });\n\n const optionsObject: Parameters<typeof fetch>[1] = {\n method: 'POST',\n headers,\n body: bodyString,\n redirect: 'follow',\n ...providedFetchOptions,\n };\n\n // Look for the header and change to use this branch instead of the build time generated branch.\n // This comes from the clients fetch options:\n //client.queries.collection({}, {\n // fetchOptions: {\n // headers: {\n // 'x-branch': cookieStore.get('x-branch')?.value,\n // },\n // },\n //})\n const draftBranch = headers.get('x-branch');\n const url = replaceGithubPathSplit(args?.url || this.apiUrl, draftBranch);\n\n let key = '';\n let result: {\n data: DataType;\n errors: GraphQLError[] | null;\n query: string;\n };\n if (this.cache) {\n key = this.cache.makeKey(bodyString);\n await this.cacheLock.acquire(key, async () => {\n result = await this.cache.get(key);\n if (!result) {\n result = await requestFromServer<DataType>(\n url,\n args.query,\n optionsObject,\n errorPolicyDefined\n );\n await this.cache.set(key, result);\n }\n });\n } else {\n result = await requestFromServer<DataType>(\n url,\n args.query,\n optionsObject,\n errorPolicyDefined\n );\n }\n\n return result;\n }\n}\n\nasync function requestFromServer<DataType extends Record<string, any> = any>(\n url: string,\n query: string,\n optionsObject: RequestInit,\n errorPolicyDefined: 'throw' | 'include'\n) {\n const res = await fetch(url, optionsObject);\n if (!res.ok) {\n let additionalInfo = '';\n if (res.status === 401) {\n additionalInfo =\n 'Please check that your client ID, URL and read only token are configured properly.';\n }\n\n throw new Error(\n `Server responded with status code ${res.status}, ${res.statusText}. ${\n additionalInfo ? additionalInfo : ''\n } Please see our FAQ for more information: https://tina.io/docs/errors/faq/`\n );\n }\n const json = await res.json();\n if (json.errors && errorPolicyDefined === 'throw') {\n throw new Error(\n `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/\n Errors: \\n\\t${json.errors.map((error) => error.message).join('\\n')}`\n );\n }\n const result = {\n data: json?.data as DataType,\n errors: (json?.errors || null) as GraphQLError[] | null,\n query,\n };\n return result;\n}\n\nexport function createClient<GenQueries>(args: TinaClientArgs<GenQueries>) {\n const client = new TinaClient<ReturnType<typeof args.queries>>(args);\n return client;\n}\n"],"names":["key"],"mappings":";AAKO,MAAM,YAAY;AA4BzB,SAAS,uBAAuB,KAAa,aAAqB;AAC1D,QAAA,QAAQ,IAAI,MAAM,SAAS;AAC7B,MAAA,MAAM,SAAS,KAAK,aAAa;AAC5B,WAAA,MAAM,CAAC,IAAI,YAAY;AAAA,EAAA,OACzB;AACE,WAAA;AAAA,EACT;AACF;AAEO,MAAM,WAAuB;AAAA,EAUlC,YAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,GAC6B;AAXjB,SAAA,cA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nE,QAAA,SAAS,IAAI,WAA4C,IAAI;AAC5D,SAAA;AACT;"}
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("zod"), require("react"), require("react-dom"), require("@udecode/cn"), require("@udecode/plate"), require("@udecode/plate-common"), require("@udecode/plate-slash-command"), require("slate-react"), require("@udecode/plate-code-block"), require("@monaco-editor/react"), require("@headlessui/react"), require("class-variance-authority"), require("lucide-react"), require("mermaid"), require("@udecode/plate-heading"), require("@ariakit/react"), require("@udecode/plate-combobox"), require("@udecode/plate-table"), require("@udecode/plate-resizable"), require("@radix-ui/react-popover"), require("@radix-ui/react-slot"), require("@radix-ui/react-dropdown-menu"), require("@radix-ui/react-separator"), require("final-form-arrays"), require("final-form-set-field-data"), require("final-form"), require("react-final-form"), require("prop-types"), require("react-beautiful-dnd"), require("react-color"), require("color-string"), require("react-dropzone"), require("clsx"), require("tailwind-merge"), require("cmdk"), require("is-hotkey"), require("slate"), require("@react-hook/window-size"), require("lodash.get"), require("moment"), require("date-fns"), require("@udecode/plate-link"), require("@radix-ui/react-toolbar"), require("@radix-ui/react-tooltip"), require("@udecode/plate-paragraph"), require("@udecode/plate-block-quote"), require("@udecode/plate-floating"), require("graphql"), require("@tinacms/schema-tools"), require("graphql-tag"), require("@graphql-inspector/core"), require("yup"), require("react-router-dom"), require("@tinacms/mdx")) : typeof define === "function" && define.amd ? define(["exports", "zod", "react", "react-dom", "@udecode/cn", "@udecode/plate", "@udecode/plate-common", "@udecode/plate-slash-command", "slate-react", "@udecode/plate-code-block", "@monaco-editor/react", "@headlessui/react", "class-variance-authority", "lucide-react", "mermaid", "@udecode/plate-heading", "@ariakit/react", "@udecode/plate-combobox", "@udecode/plate-table", "@udecode/plate-resizable", "@radix-ui/react-popover", "@radix-ui/react-slot", "@radix-ui/react-dropdown-menu", "@radix-ui/react-separator", "final-form-arrays", "final-form-set-field-data", "final-form", "react-final-form", "prop-types", "react-beautiful-dnd", "react-color", "color-string", "react-dropzone", "clsx", "tailwind-merge", "cmdk", "is-hotkey", "slate", "@react-hook/window-size", "lodash.get", "moment", "date-fns", "@udecode/plate-link", "@radix-ui/react-toolbar", "@radix-ui/react-tooltip", "@udecode/plate-paragraph", "@udecode/plate-block-quote", "@udecode/plate-floating", "graphql", "@tinacms/schema-tools", "graphql-tag", "@graphql-inspector/core", "yup", "react-router-dom", "@tinacms/mdx"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
3
- })(this, function(exports2, zod, React, reactDom, cn$1, plate, plateCommon, plateSlashCommand, slateReact, plateCodeBlock, MonacoEditor, react, classVarianceAuthority, lucideReact, mermaid, plateHeading, react$1, plateCombobox, plateTable, plateResizable, PopoverPrimitive, reactSlot, DropdownMenuPrimitive, SeparatorPrimitive, arrayMutators, setFieldData, finalForm, reactFinalForm, PropTypes, reactBeautifulDnd, pkg$1, pkg, dropzone, clsx, tailwindMerge, cmdk, isHotkey, slate, windowSize, get, moment, dateFns, plateLink, ToolbarPrimitive, TooltipPrimitive, plateParagraph, plateBlockQuote, plateFloating, graphql, schemaTools, gql, core, yup, reactRouterDom, mdx) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("zod"), require("react"), require("react-dom"), require("@udecode/cn"), require("@udecode/plate"), require("@udecode/plate-common"), require("@udecode/plate-slash-command"), require("@udecode/plate-code-block"), require("@monaco-editor/react"), require("slate-react"), require("@headlessui/react"), require("class-variance-authority"), require("lucide-react"), require("mermaid"), require("@udecode/plate-heading"), require("@ariakit/react"), require("@udecode/plate-combobox"), require("@udecode/plate-table"), require("@udecode/plate-resizable"), require("@radix-ui/react-popover"), require("@radix-ui/react-slot"), require("@radix-ui/react-dropdown-menu"), require("@radix-ui/react-separator"), require("final-form-arrays"), require("final-form-set-field-data"), require("final-form"), require("react-final-form"), require("prop-types"), require("react-beautiful-dnd"), require("react-color"), require("color-string"), require("react-dropzone"), require("clsx"), require("tailwind-merge"), require("cmdk"), require("is-hotkey"), require("slate"), require("@react-hook/window-size"), require("lodash.get"), require("moment"), require("date-fns"), require("@udecode/plate-link"), require("@radix-ui/react-toolbar"), require("@radix-ui/react-tooltip"), require("@udecode/plate-paragraph"), require("@udecode/plate-block-quote"), require("@udecode/plate-floating"), require("graphql"), require("@tinacms/schema-tools"), require("graphql-tag"), require("@graphql-inspector/core"), require("yup"), require("react-router-dom"), require("@tinacms/mdx")) : typeof define === "function" && define.amd ? define(["exports", "zod", "react", "react-dom", "@udecode/cn", "@udecode/plate", "@udecode/plate-common", "@udecode/plate-slash-command", "@udecode/plate-code-block", "@monaco-editor/react", "slate-react", "@headlessui/react", "class-variance-authority", "lucide-react", "mermaid", "@udecode/plate-heading", "@ariakit/react", "@udecode/plate-combobox", "@udecode/plate-table", "@udecode/plate-resizable", "@radix-ui/react-popover", "@radix-ui/react-slot", "@radix-ui/react-dropdown-menu", "@radix-ui/react-separator", "final-form-arrays", "final-form-set-field-data", "final-form", "react-final-form", "prop-types", "react-beautiful-dnd", "react-color", "color-string", "react-dropzone", "clsx", "tailwind-merge", "cmdk", "is-hotkey", "slate", "@react-hook/window-size", "lodash.get", "moment", "date-fns", "@udecode/plate-link", "@radix-ui/react-toolbar", "@radix-ui/react-tooltip", "@udecode/plate-paragraph", "@udecode/plate-block-quote", "@udecode/plate-floating", "graphql", "@tinacms/schema-tools", "graphql-tag", "@graphql-inspector/core", "yup", "react-router-dom", "@tinacms/mdx"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP, global.NOOP));
3
+ })(this, function(exports2, zod, React, reactDom, cn$1, plate, plateCommon, plateSlashCommand, plateCodeBlock, MonacoEditor, slateReact, react, classVarianceAuthority, lucideReact, mermaid, plateHeading, react$1, plateCombobox, plateTable, plateResizable, PopoverPrimitive, reactSlot, DropdownMenuPrimitive, SeparatorPrimitive, arrayMutators, setFieldData, finalForm, reactFinalForm, PropTypes, reactBeautifulDnd, pkg$1, pkg, dropzone, clsx, tailwindMerge, cmdk, isHotkey, slate, windowSize, get, moment, dateFns, plateLink, ToolbarPrimitive, TooltipPrimitive, plateParagraph, plateBlockQuote, plateFloating, graphql, schemaTools, gql, core, yup, reactRouterDom, mdx) {
4
4
  "use strict";var __defProp = Object.defineProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
6
  var __publicField = (obj, key, value) => {
@@ -2954,7 +2954,6 @@ flowchart TD
2954
2954
  children,
2955
2955
  ...props
2956
2956
  }) => {
2957
- const selected = slateReact.useSelected();
2958
2957
  return /* @__PURE__ */ React.createElement(
2959
2958
  "div",
2960
2959
  {
@@ -2965,8 +2964,7 @@ flowchart TD
2965
2964
  ...attributes,
2966
2965
  ...props
2967
2966
  },
2968
- children,
2969
- selected && /* @__PURE__ */ React.createElement("span", { className: "absolute h-4 -top-2 inset-0 ring-2 ring-blue-100 ring-inset rounded-md z-10 pointer-events-none" })
2967
+ children
2970
2968
  );
2971
2969
  },
2972
2970
  [plate.ELEMENT_TABLE]: TableElement,
@@ -10888,7 +10886,7 @@ flowchart TD
10888
10886
  "Event Log"
10889
10887
  ));
10890
10888
  };
10891
- const version = "2.7.6";
10889
+ const version = "2.7.7";
10892
10890
  const Nav = ({
10893
10891
  isLocalMode,
10894
10892
  className = "",
@@ -32299,8 +32297,8 @@ This will work when developing locally but NOT when deployed to production.
32299
32297
  return client.request(query, { variables });
32300
32298
  };
32301
32299
  const GetCMS = ({ children }) => {
32300
+ const cms = useCMS$1();
32302
32301
  try {
32303
- const cms = useCMS$1();
32304
32302
  return /* @__PURE__ */ React.createElement(React.Fragment, null, children(cms));
32305
32303
  } catch (e) {
32306
32304
  return null;
@@ -33708,22 +33706,28 @@ This will work when developing locally but NOT when deployed to production.
33708
33706
  search
33709
33707
  }) => {
33710
33708
  const navigate = reactRouterDom.useNavigate();
33711
- const { collection, loading, error, reFetchCollection, collectionExtra } = search ? useSearchCollection(
33712
- cms,
33713
- collectionName,
33714
- includeDocuments,
33715
- folder,
33716
- startCursor || "",
33717
- search
33718
- ) : useGetCollection(
33719
- cms,
33720
- collectionName,
33721
- includeDocuments,
33722
- folder,
33723
- startCursor || "",
33724
- sortKey,
33725
- filterArgs
33726
- ) || {};
33709
+ const { collection, loading, error, reFetchCollection, collectionExtra } = search ? (
33710
+ // biome-ignore lint/correctness/useHookAtTopLevel: not ready to fix these yet
33711
+ useSearchCollection(
33712
+ cms,
33713
+ collectionName,
33714
+ includeDocuments,
33715
+ folder,
33716
+ startCursor || "",
33717
+ search
33718
+ )
33719
+ ) : (
33720
+ // biome-ignore lint/correctness/useHookAtTopLevel: not ready to fix these yet
33721
+ useGetCollection(
33722
+ cms,
33723
+ collectionName,
33724
+ includeDocuments,
33725
+ folder,
33726
+ startCursor || "",
33727
+ sortKey,
33728
+ filterArgs
33729
+ ) || {}
33730
+ );
33727
33731
  React.useEffect(() => {
33728
33732
  var _a, _b, _c, _d, _e, _f, _g, _h, _i;
33729
33733
  if (loading)
@@ -35078,3 +35082,4 @@ This will work when developing locally but NOT when deployed to production.
35078
35082
  exports2.wrapFieldsWithMeta = wrapFieldsWithMeta;
35079
35083
  Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
35080
35084
  });
35085
+ //# sourceMappingURL=index.js.map