tinacms 0.0.0-b67f55a-20250513032422 → 0.0.0-b749957-20251208035121

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.
Files changed (190) hide show
  1. package/dist/__vite-browser-external-d06ac358.js +4 -0
  2. package/dist/admin/api.d.ts +4 -1
  3. package/dist/admin/components/{Sidebar.d.ts → AdminNav.d.ts} +0 -3
  4. package/dist/admin/components/Page.d.ts +3 -9
  5. package/dist/admin/components/ui/tooltip.d.ts +7 -0
  6. package/dist/admin/pages/CollectionCreatePage.d.ts +1 -1
  7. package/dist/admin/pages/CollectionListPage.d.ts +2 -2
  8. package/dist/admin/pages/DashboardPage.d.ts +0 -3
  9. package/dist/admin/pages/ScreenPage.d.ts +0 -3
  10. package/dist/auth/AuthModal.d.ts +1 -4
  11. package/dist/auth/TinaCloudProvider.d.ts +0 -1
  12. package/dist/client.js +131 -186
  13. package/dist/index.js +122051 -33723
  14. package/dist/internalClient/index.d.ts +26 -1
  15. package/dist/{node-cache-5e8db9f0.mjs → node-cache-c9558e1e.js} +5 -6
  16. package/dist/react.d.ts +13 -6
  17. package/dist/react.js +209 -205
  18. package/dist/rich-text/index.d.ts +6 -0
  19. package/dist/rich-text/index.js +234 -225
  20. package/dist/rich-text/prism.js +16 -19
  21. package/dist/rich-text/static.d.ts +154 -0
  22. package/dist/rich-text/{index.mjs → static.js} +99 -100
  23. package/dist/tina-cms.d.ts +1 -1
  24. package/dist/toolkit/components/ProgressBar.d.ts +11 -0
  25. package/dist/toolkit/components/media/media-item.d.ts +11 -1
  26. package/dist/toolkit/components/ui/breadcrumb.d.ts +11 -0
  27. package/dist/toolkit/components/ui/button.d.ts +11 -0
  28. package/dist/toolkit/components/ui/calendar.d.ts +8 -0
  29. package/dist/toolkit/components/ui/date-time-picker.d.ts +111 -0
  30. package/dist/toolkit/components/ui/dropdown-menu.d.ts +25 -0
  31. package/dist/toolkit/components/ui/input.d.ts +3 -0
  32. package/dist/toolkit/components/ui/popover.d.ts +7 -0
  33. package/dist/toolkit/components/ui/select.d.ts +13 -0
  34. package/dist/toolkit/fields/components/color-picker/block-widget.d.ts +3 -0
  35. package/dist/toolkit/fields/components/color-picker/color-input.d.ts +35 -0
  36. package/dist/toolkit/fields/components/color-picker/color-picker.d.ts +6 -2
  37. package/dist/toolkit/fields/components/color-picker/color-utils.d.ts +37 -0
  38. package/dist/toolkit/fields/components/color-picker/sketch-widget.d.ts +3 -0
  39. package/dist/toolkit/fields/components/password-field.d.ts +1 -1
  40. package/dist/toolkit/fields/components/reference/components/button.d.ts +2 -2
  41. package/dist/toolkit/fields/components/reference/components/command.d.ts +21 -33
  42. package/dist/toolkit/fields/components/reference/components/popover.d.ts +1 -1
  43. package/dist/toolkit/fields/components/reference/model/reference-link-props.d.ts +2 -0
  44. package/dist/toolkit/fields/components/select.d.ts +2 -2
  45. package/dist/toolkit/fields/components/text-field.d.ts +1 -1
  46. package/dist/toolkit/fields/plugins/button-toggle-field-plugin.d.ts +2 -2
  47. package/dist/toolkit/fields/plugins/checkbox-group-field-plugin.d.ts +2 -2
  48. package/dist/toolkit/fields/plugins/color-field-plugin.d.ts +1 -0
  49. package/dist/toolkit/fields/plugins/date-field-plugin.d.ts +0 -2
  50. package/dist/toolkit/fields/plugins/dnd-kit-wrapper.d.ts +49 -0
  51. package/dist/toolkit/fields/plugins/group-field-plugin.d.ts +1 -1
  52. package/dist/toolkit/fields/plugins/group-list-field-plugin.d.ts +3 -1
  53. package/dist/toolkit/fields/plugins/list-field-meta.d.ts +1 -1
  54. package/dist/toolkit/fields/plugins/list-field-plugin.d.ts +3 -0
  55. package/dist/toolkit/fields/plugins/mdx-field-plugin/index.d.ts +2 -2
  56. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/editor.d.ts +20 -18
  57. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/blockquote-element.d.ts +14 -10
  58. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/button.d.ts +5 -5
  59. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/code-block-element.d.ts +17 -0
  60. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/error-message.d.ts +6 -0
  61. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-combobox.d.ts +6 -0
  62. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-toolbar-button.d.ts +6 -6
  63. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-leaf.d.ts +2 -11
  64. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-line-element.d.ts +14 -10
  65. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-syntax-leaf.d.ts +2 -11
  66. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/command.d.ts +112 -0
  67. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/dialog.d.ts +12 -0
  68. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/dropdown-menu.d.ts +10 -10
  69. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/floating-toolbar.d.ts +2 -2
  70. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/hr-element.d.ts +3 -0
  71. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/hr-toolbar-button.d.ts +18 -0
  72. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/icons.d.ts +2 -1
  73. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/image-toolbar-button.d.ts +6 -6
  74. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/indent-list-toolbar-button.d.ts +6 -19
  75. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/inline-combobox.d.ts +1 -1
  76. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/input.d.ts +3 -3
  77. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-element.d.ts +4 -11
  78. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-floating-toolbar.d.ts +4 -5
  79. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/link-toolbar-button.d.ts +4 -4
  80. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/list-element.d.ts +28 -11
  81. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-element.d.ts +3 -10
  82. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/mermaid-toolbar-button.d.ts +6 -8
  83. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/paragraph-element.d.ts +15 -0
  84. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/popover.d.ts +7 -2
  85. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/quote-toolbar-button.d.ts +6 -6
  86. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/raw-markdown-toolbar-button.d.ts +6 -6
  87. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/resizable.d.ts +24 -21
  88. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/separator.d.ts +2 -2
  89. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/slash-input-element.d.ts +15 -11
  90. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/block-selection.d.ts +6 -0
  91. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-cell-element.d.ts +33 -0
  92. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/{table-dropdown-menu.d.ts → table/table-dropdown-menu.d.ts} +1 -0
  93. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-element.d.ts +20 -0
  94. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-row-element.d.ts +15 -0
  95. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/toolbar.d.ts +7 -7
  96. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-hook.d.ts +10 -0
  97. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-state.d.ts +22 -0
  98. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/hooks/use-create-editor.d.ts +6 -0
  99. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-block.d.ts +1 -1
  100. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-lists.d.ts +1 -1
  101. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-marks.d.ts +1 -1
  102. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/autoformat/autoformat-utils.d.ts +3 -5
  103. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/common.d.ts +11 -6
  104. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/formatting.d.ts +18 -2
  105. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/index.d.ts +0 -1
  106. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-html-block/index.d.ts +6 -0
  107. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-img-plugin/index.d.ts +2 -2
  108. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-invalid-markdown-plugin/index.d.ts +5 -5
  109. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-mdx-plugins/component.d.ts +7 -4
  110. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-mdx-plugins/index.d.ts +3 -5
  111. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/editor-plugins.d.ts +520 -0
  112. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +262 -207
  113. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/floating-toolbar-plugin.d.ts +1 -0
  114. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/toolbar/toolbar-overrides.d.ts +1 -1
  115. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/transforms/is-url.d.ts +1 -2
  116. package/dist/toolkit/fields/plugins/radio-group-field-plugin.d.ts +2 -2
  117. package/dist/toolkit/fields/plugins/select-field-plugin.d.ts +2 -2
  118. package/dist/toolkit/fields/plugins/toggle-field-plugin.d.ts +2 -2
  119. package/dist/toolkit/form-builder/create-branch-modal.d.ts +13 -0
  120. package/dist/toolkit/form-builder/editorial-workflow-constants.d.ts +17 -0
  121. package/dist/toolkit/form-builder/fields-builder.d.ts +1 -1
  122. package/dist/toolkit/form-builder/form-builder.d.ts +8 -9
  123. package/dist/toolkit/form-builder/index.d.ts +1 -0
  124. package/dist/toolkit/forms/field.d.ts +3 -0
  125. package/dist/toolkit/forms/form.d.ts +22 -3
  126. package/dist/toolkit/git-client/git-client.d.ts +25 -2
  127. package/dist/toolkit/git-client/git-file.d.ts +18 -0
  128. package/dist/toolkit/git-client/git-media-store.d.ts +13 -0
  129. package/dist/toolkit/git-client/use-git-file.d.ts +4 -0
  130. package/dist/toolkit/icons/Tina.d.ts +0 -5
  131. package/dist/toolkit/icons/TinaExtended.d.ts +4 -0
  132. package/dist/toolkit/icons/index.d.ts +1 -0
  133. package/dist/toolkit/index.d.ts +1 -1
  134. package/dist/toolkit/plugin-branch-switcher/branch-button.d.ts +4 -1
  135. package/dist/toolkit/plugin-branch-switcher/index.d.ts +0 -1
  136. package/dist/toolkit/react-modals/modal/modal-actions.d.ts +2 -1
  137. package/dist/toolkit/react-modals/modal/modal-header.d.ts +1 -1
  138. package/dist/toolkit/react-sidebar/components/NavMenuTrigger.d.ts +11 -0
  139. package/dist/toolkit/react-sidebar/components/VersionInfo.d.ts +2 -0
  140. package/dist/toolkit/react-sidebar/components/badge.d.ts +6 -0
  141. package/dist/toolkit/react-sidebar/components/callout.d.ts +5 -0
  142. package/dist/toolkit/react-sidebar/components/form-list.d.ts +1 -1
  143. package/dist/toolkit/react-sidebar/components/local-warning.d.ts +3 -1
  144. package/dist/toolkit/react-sidebar/components/nav-components.d.ts +11 -0
  145. package/dist/toolkit/react-sidebar/components/nav-context.d.ts +15 -0
  146. package/dist/toolkit/react-sidebar/components/nav.d.ts +6 -3
  147. package/dist/toolkit/react-sidebar/components/resize-handle.d.ts +0 -5
  148. package/dist/toolkit/react-sidebar/components/sidebar-body.d.ts +3 -7
  149. package/dist/toolkit/react-sidebar/components/sidebar.d.ts +0 -7
  150. package/dist/toolkit/react-sidebar/components/sync-status.d.ts +5 -8
  151. package/dist/toolkit/react-sidebar/index.d.ts +4 -1
  152. package/dist/toolkit/styles/button.d.ts +2 -2
  153. package/dist/toolkit/styles/dropdown-button.d.ts +75 -0
  154. package/dist/toolkit/styles/index.d.ts +1 -0
  155. package/dist/toolkit/tina-state.d.ts +11 -0
  156. package/dist/utils/cn.d.ts +2 -0
  157. package/dist/utils/index.d.ts +1 -0
  158. package/package.json +53 -70
  159. package/dist/admin/pages/IndexingPage.d.ts +0 -2
  160. package/dist/client.js.map +0 -1
  161. package/dist/client.mjs +0 -133
  162. package/dist/client.mjs.map +0 -1
  163. package/dist/index.js.map +0 -1
  164. package/dist/index.mjs +0 -35106
  165. package/dist/index.mjs.map +0 -1
  166. package/dist/node-cache-5e8db9f0.mjs.map +0 -1
  167. package/dist/react.js.map +0 -1
  168. package/dist/react.mjs +0 -247
  169. package/dist/react.mjs.map +0 -1
  170. package/dist/rich-text/index.js.map +0 -1
  171. package/dist/rich-text/index.mjs.map +0 -1
  172. package/dist/rich-text/prism.js.map +0 -1
  173. package/dist/rich-text/prism.mjs +0 -17
  174. package/dist/rich-text/prism.mjs.map +0 -1
  175. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-element.d.ts +0 -11
  176. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-cell-element.d.ts +0 -27
  177. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-element.d.ts +0 -14
  178. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table-row-element.d.ts +0 -13
  179. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/with-correct-void-behavior.d.ts +0 -8
  180. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-code-block/index.d.ts +0 -3
  181. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-link-plugin/index.d.ts +0 -15
  182. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/custom/mermaid-plugin.d.ts +0 -2
  183. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/create-soft-break-plugin.d.ts +0 -7
  184. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/index.d.ts +0 -6
  185. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/on-key-down-soft-break.d.ts +0 -5
  186. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/soft-break/types.d.ts +0 -11
  187. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/code-block/index.d.ts +0 -11
  188. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/transforms/insert-empty-block.d.ts +0 -2
  189. package/dist/toolkit/plugin-branch-switcher/branch-banner.d.ts +0 -2
  190. package/dist/toolkit/react-datetime/DateTime.d.ts +0 -135
@@ -0,0 +1,75 @@
1
+ import * as React from 'react';
2
+ import { ButtonProps } from './button';
3
+ export interface DropdownButtonItem {
4
+ label: string;
5
+ onClick: () => void;
6
+ variant?: 'default' | 'destructive';
7
+ icon?: React.ReactNode;
8
+ disabled?: boolean;
9
+ }
10
+ export interface DropdownButtonProps extends Omit<ButtonProps, 'onClick'> {
11
+ /**
12
+ * The main action to perform when the button is clicked
13
+ */
14
+ onMainAction?: () => void;
15
+ /**
16
+ * Array of dropdown menu items
17
+ */
18
+ items: DropdownButtonItem[];
19
+ /**
20
+ * Whether to show the dropdown arrow in a split button style
21
+ * @default true
22
+ */
23
+ showSplitButton?: boolean;
24
+ /**
25
+ * Alignment of the dropdown menu
26
+ * @default 'end'
27
+ */
28
+ align?: 'start' | 'center' | 'end';
29
+ }
30
+ /**
31
+ * A button component that combines a primary action with a dropdown menu of additional options.
32
+ *
33
+ * This component follows the split-button pattern found in TinaCMS, where the main button
34
+ * performs a primary action and a small arrow button opens a dropdown menu with additional options.
35
+ *
36
+ * @example
37
+ * // Basic usage with split button
38
+ * <DropdownButton
39
+ * variant="primary"
40
+ * onMainAction={() => console.log('Save to new branch')}
41
+ * items={[
42
+ * { label: 'Save to protected branch', onClick: () => console.log('Protected') },
43
+ * { label: 'Save and publish', onClick: () => console.log('Publish') },
44
+ * ]}
45
+ * >
46
+ * Save to new branch
47
+ * </DropdownButton>
48
+ *
49
+ * @example
50
+ * // Dropdown-only button (no main action)
51
+ * <DropdownButton
52
+ * variant="secondary"
53
+ * showSplitButton={false}
54
+ * items={[
55
+ * { label: 'Save to new branch', onClick: () => console.log('New branch') },
56
+ * { label: 'Save to protected branch', onClick: () => console.log('Protected') },
57
+ * ]}
58
+ * >
59
+ * Save options
60
+ * </DropdownButton>
61
+ *
62
+ * @example
63
+ * // With icons and destructive action
64
+ * <DropdownButton
65
+ * variant="primary"
66
+ * onMainAction={() => console.log('Save')}
67
+ * items={[
68
+ * { label: 'Duplicate', onClick: () => console.log('Duplicate'), icon: <CopyIcon /> },
69
+ * { label: 'Delete', onClick: () => console.log('Delete'), variant: 'destructive', icon: <TrashIcon /> },
70
+ * ]}
71
+ * >
72
+ * Save
73
+ * </DropdownButton>
74
+ */
75
+ export declare const DropdownButton: React.ForwardRefExoticComponent<DropdownButtonProps & React.RefAttributes<HTMLButtonElement>>;
@@ -2,3 +2,4 @@ export * from './button';
2
2
  export * from './font-loader';
3
3
  export * from './overflow-menu';
4
4
  export * from './message';
5
+ export * from './dropdown-button';
@@ -15,6 +15,12 @@ type FormList = {
15
15
  items: FormListItem[];
16
16
  formIds: string[];
17
17
  };
18
+ type Breadcrumb = {
19
+ label: string;
20
+ formId: string;
21
+ formName: string;
22
+ namespace: string[];
23
+ };
18
24
  export type TinaAction = {
19
25
  type: 'forms:add';
20
26
  value: Form;
@@ -63,6 +69,7 @@ export type TinaAction = {
63
69
  value: boolean;
64
70
  };
65
71
  export interface TinaState {
72
+ breadcrumbs: Breadcrumb[];
66
73
  activeFormId: string | null;
67
74
  /**
68
75
  * Forms are wrapped here because we need `activeFieldName` to be reactive, so adding it as a propery
@@ -85,4 +92,8 @@ export interface TinaState {
85
92
  }
86
93
  export declare const initialState: (cms: TinaCMS) => TinaState;
87
94
  export declare function tinaReducer(state: TinaState, action: TinaAction): TinaState;
95
+ export declare function calculateBreadcrumbs(forms: {
96
+ activeFieldName?: string | null;
97
+ tinaForm: Form;
98
+ }[], activeFormId: string, activeFieldName?: string): Breadcrumb[];
88
99
  export {};
@@ -0,0 +1,2 @@
1
+ import { type ClassValue } from 'clsx';
2
+ export declare function cn(...inputs: ClassValue[]): string;
@@ -20,3 +20,4 @@ export interface CreateClientProps {
20
20
  export declare const createClient: ({ clientId, isLocalClient, branch, tinaioConfig, schema, apiUrl, tinaGraphQLVersion, }: CreateClientProps) => Client;
21
21
  export declare function assertShape<T>(value: unknown, yupSchema: (args: typeof yup) => yup.AnySchema, errorMessage?: string): asserts value is T;
22
22
  export declare function safeAssertShape<T>(value: unknown, yupSchema: (args: typeof yup) => yup.AnySchema): boolean;
23
+ export declare const get: (obj: any, path: any, defaultValue?: any) => any;
package/package.json CHANGED
@@ -1,39 +1,19 @@
1
1
  {
2
2
  "name": "tinacms",
3
- "version": "0.0.0-b67f55a-20250513032422",
3
+ "type": "module",
4
+ "typings": "dist/index.d.ts",
5
+ "version": "0.0.0-b749957-20251208035121",
4
6
  "main": "dist/index.js",
5
- "module": "./dist/index.mjs",
7
+ "module": "./dist/index.js",
6
8
  "exports": {
7
- ".": {
8
- "types": "./dist/index.d.ts",
9
- "import": "./dist/index.mjs",
10
- "require": "./dist/index.js"
11
- },
12
- "./dist/client": {
13
- "types": "./dist/client.d.ts",
14
- "import": "./dist/client.mjs",
15
- "require": "./dist/client.js"
16
- },
17
- "./dist/edit-state": {
18
- "types": "./dist/edit-state.d.ts",
19
- "import": "./dist/edit-state.mjs",
20
- "require": "./dist/edit-state.js"
21
- },
22
- "./dist/react": {
23
- "types": "./dist/react.d.ts",
24
- "import": "./dist/react.mjs",
25
- "require": "./dist/react.js"
26
- },
27
- "./dist/rich-text": {
28
- "types": "./dist/rich-text/index.d.ts",
29
- "import": "./dist/rich-text/index.mjs",
30
- "require": "./dist/rich-text/index.js"
31
- },
32
- "./dist/rich-text/prism": {
33
- "types": "./dist/rich-text/prism.d.ts",
34
- "import": "./dist/rich-text/prism.mjs",
35
- "require": "./dist/rich-text/prism.js"
36
- }
9
+ ".": "./dist/index.js",
10
+ "./dist/client": "./dist/client.js",
11
+ "./dist/edit-state": "./dist/edit-state.js",
12
+ "./react": "./dist/react.js",
13
+ "./dist/react": "./dist/react.js",
14
+ "./dist/rich-text": "./dist/rich-text/index.js",
15
+ "./dist/rich-text/static": "./dist/rich-text/static.js",
16
+ "./dist/rich-text/prism": "./dist/rich-text/prism.js"
37
17
  },
38
18
  "files": [
39
19
  "dist"
@@ -42,6 +22,7 @@
42
22
  "entryPoints": [
43
23
  "src/index.ts",
44
24
  "src/rich-text/index.tsx",
25
+ "src/rich-text/static.tsx",
45
26
  "src/rich-text/prism.tsx",
46
27
  "src/react.tsx",
47
28
  "src/client.ts"
@@ -57,10 +38,12 @@
57
38
  }
58
39
  }
59
40
  },
60
- "typings": "dist/index.d.ts",
61
41
  "license": "Apache-2.0",
62
42
  "dependencies": {
63
43
  "@ariakit/react": "^0.4.15",
44
+ "@dnd-kit/core": "^6.1.0",
45
+ "@dnd-kit/sortable": "^8.0.0",
46
+ "@dnd-kit/utilities": "^3.2.2",
64
47
  "@floating-ui/dom": "^1.6.13",
65
48
  "@floating-ui/react-dom": "^2.1.2",
66
49
  "@graphql-inspector/core": "^6.2.1",
@@ -70,28 +53,37 @@
70
53
  "@radix-ui/react-checkbox": "^1.1.4",
71
54
  "@radix-ui/react-dialog": "^1.1.6",
72
55
  "@radix-ui/react-dropdown-menu": "^2.1.6",
73
- "@radix-ui/react-popover": "^1.1.6",
56
+ "@radix-ui/react-popover": "^1.1.15",
57
+ "@radix-ui/react-select": "^2.2.6",
74
58
  "@radix-ui/react-separator": "^1.1.2",
75
59
  "@radix-ui/react-slot": "^1.1.2",
76
60
  "@radix-ui/react-toolbar": "^1.1.2",
77
- "@radix-ui/react-tooltip": "^1.1.8",
61
+ "@radix-ui/react-tooltip": "^1.2.8",
78
62
  "@react-hook/window-size": "^3.1.1",
79
- "@udecode/cn": "^33.0.0",
80
- "@udecode/plate": "^36.5.9",
81
- "@udecode/plate-autoformat": "^36.5.6",
82
- "@udecode/plate-block-quote": "^36.0.0",
83
- "@udecode/plate-code-block": "^36.5.6",
84
- "@udecode/plate-combobox": "^36.0.0",
85
- "@udecode/plate-common": "^36.5.9",
86
- "@udecode/plate-floating": "^36.3.8",
87
- "@udecode/plate-heading": "^36.0.12",
88
- "@udecode/plate-indent-list": "^36.5.2",
89
- "@udecode/plate-link": "^36.5.9",
90
- "@udecode/plate-list": "^36.5.2",
91
- "@udecode/plate-paragraph": "^36.0.0",
92
- "@udecode/plate-resizable": "36.0.0",
93
- "@udecode/plate-slash-command": "^36.0.0",
94
- "@udecode/plate-table": "36.5.8",
63
+ "@udecode/cmdk": "^0.2.1",
64
+ "@udecode/cn": "^48.0.3",
65
+ "@udecode/plate": "^48.0.3",
66
+ "@udecode/plate-autoformat": "^48.0.0",
67
+ "@udecode/plate-basic-marks": "^48.0.0",
68
+ "@udecode/plate-block-quote": "^48",
69
+ "@udecode/plate-break": "^48",
70
+ "@udecode/plate-code-block": "^48.0.0",
71
+ "@udecode/plate-combobox": "^48",
72
+ "@udecode/plate-dnd": "^48.0.0",
73
+ "@udecode/plate-floating": "^48.0.0",
74
+ "@udecode/plate-heading": "^48",
75
+ "@udecode/plate-horizontal-rule": "^48",
76
+ "@udecode/plate-indent-list": "^48.0.0",
77
+ "@udecode/plate-link": "^48.0.0",
78
+ "@udecode/plate-list": "^48.0.0",
79
+ "@udecode/plate-node-id": "^48.0.0",
80
+ "@udecode/plate-reset-node": "^48",
81
+ "@udecode/plate-resizable": "^48",
82
+ "@udecode/plate-selection": "^48.0.0",
83
+ "@udecode/plate-slash-command": "^48.0.0",
84
+ "@udecode/plate-table": "^48.0.0",
85
+ "@udecode/plate-trailing-block": "^48.0.0",
86
+ "add": "^2.0.6",
95
87
  "async-lock": "^1.4.1",
96
88
  "class-variance-authority": "^0.7.1",
97
89
  "clsx": "^2.1.1",
@@ -99,62 +91,53 @@
99
91
  "color-string": "^1.9.1",
100
92
  "crypto-js": "^4.2.0",
101
93
  "date-fns": "2.30.0",
94
+ "es-toolkit": "^1.42.0",
102
95
  "final-form": "4.20.10",
103
96
  "final-form-arrays": "^3.1.0",
104
97
  "final-form-set-field-data": "^1.0.2",
105
98
  "graphql": "15.8.0",
106
99
  "graphql-tag": "^2.12.6",
107
100
  "is-hotkey": "^0.2.0",
108
- "lodash.get": "^4.4.2",
109
- "lodash.set": "^4.3.2",
110
101
  "lucide-react": "^0.424.0",
111
102
  "mermaid": "9.3.0",
112
103
  "moment": "2.29.4",
104
+ "moment-timezone": "^0.6.0",
113
105
  "monaco-editor": "0.31.0",
114
106
  "prism-react-renderer": "^2.4.1",
115
107
  "prop-types": "15.7.2",
116
- "react-beautiful-dnd": "^13.1.1",
117
- "react-color": "^2.19.3",
108
+ "react-colorful": "^5.6.1",
118
109
  "react-datetime": "^3.3.1",
110
+ "react-day-picker": "^9.11.1",
119
111
  "react-dropzone": "14.2.3",
120
112
  "react-final-form": "^6.5.9",
121
113
  "react-icons": "^5.4.0",
122
114
  "react-router-dom": "6.3.0",
123
115
  "react-use": "^17.6.0",
124
- "slate": "^0.103.0",
125
- "slate-history": "^0.100.0",
126
- "slate-hyperscript": "^0.100.0",
127
- "slate-react": "^0.107.1",
128
116
  "tailwind-merge": "^2.6.0",
129
117
  "webfontloader": "1.6.28",
130
118
  "yup": "^1.6.1",
131
119
  "zod": "^3.24.2",
132
- "@tinacms/schema-tools": "1.7.3",
133
- "@tinacms/mdx": "1.6.2",
134
- "@tinacms/search": "1.0.44"
120
+ "@tinacms/mdx": "2.0.0",
121
+ "@tinacms/schema-tools": "2.0.0",
122
+ "@tinacms/search": "0.0.0-b749957-20251208035121"
135
123
  },
136
124
  "devDependencies": {
137
125
  "@graphql-tools/utils": "^10.8.1",
138
126
  "@testing-library/dom": "^10.4.0",
139
- "@testing-library/jest-dom": "^6.6.3",
127
+ "@testing-library/jest-dom": "^6.7.0",
140
128
  "@testing-library/react": "^16.2.0",
141
129
  "@testing-library/user-event": "^14.6.1",
142
130
  "@types/atob": "^2.1.4",
143
131
  "@types/codemirror": "^5.60.15",
144
132
  "@types/color-string": "^1.5.5",
145
- "@types/lodash.debounce": "^4.0.9",
146
- "@types/lodash.get": "^4.4.9",
147
133
  "@types/node": "^22.13.1",
148
134
  "@types/prop-types": "^15.7.14",
149
135
  "@types/react": "^18.3.18",
150
- "@types/react-beautiful-dnd": "^13.1.8",
151
- "@types/react-color": "^3.0.13",
152
136
  "@types/react-dom": "^18.3.5",
153
- "@types/yup": "^0.32.0",
154
137
  "happy-dom": "15.10.2",
155
138
  "identity-obj-proxy": "^3.0.0",
156
- "isomorphic-fetch": "^3.0.0",
157
139
  "jest-file-snapshot": "^0.7.0",
140
+ "lowlight": "^3.3.0",
158
141
  "next": "14.2.10",
159
142
  "react": "^18.3.1",
160
143
  "react-dom": "^18.3.1",
@@ -164,7 +147,7 @@
164
147
  "typescript": "^5.7.3",
165
148
  "vite": "^5.4.14",
166
149
  "vitest": "^2.1.9",
167
- "@tinacms/scripts": "1.3.4"
150
+ "@tinacms/scripts": "0.0.0-b749957-20251208035121"
168
151
  },
169
152
  "peerDependencies": {
170
153
  "react": ">=16.14.0",
@@ -1,2 +0,0 @@
1
- import { FC } from 'react';
2
- export declare const IndexingPage: FC;
@@ -1 +0,0 @@
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;AA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AAS,UAAU,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 DELETED
@@ -1,133 +0,0 @@
1
- import AsyncLock from "async-lock";
2
- const TINA_HOST = "content.tinajs.io";
3
- function replaceGithubPathSplit(url, replacement) {
4
- const parts = url.split("github/");
5
- if (parts.length > 1 && replacement) {
6
- return parts[0] + "github/" + replacement;
7
- } else {
8
- return url;
9
- }
10
- }
11
- class TinaClient {
12
- constructor({
13
- token,
14
- url,
15
- queries,
16
- errorPolicy,
17
- cacheDir
18
- }) {
19
- this.initialized = false;
20
- this.apiUrl = url;
21
- this.readonlyToken = token == null ? void 0 : token.trim();
22
- this.queries = queries(this);
23
- this.errorPolicy = errorPolicy || "throw";
24
- this.cacheDir = cacheDir || "";
25
- }
26
- async init() {
27
- if (this.initialized) {
28
- return;
29
- }
30
- try {
31
- if (this.cacheDir && typeof window === "undefined" && typeof require !== "undefined") {
32
- const { NodeCache } = await import("./node-cache-5e8db9f0.mjs");
33
- this.cache = await NodeCache(this.cacheDir);
34
- this.cacheLock = new AsyncLock();
35
- }
36
- } catch (e) {
37
- console.error(e);
38
- }
39
- this.initialized = true;
40
- }
41
- async request({ errorPolicy, ...args }, options) {
42
- var _a;
43
- await this.init();
44
- const errorPolicyDefined = errorPolicy || this.errorPolicy;
45
- const headers = new Headers();
46
- if (this.readonlyToken) {
47
- headers.append("X-API-KEY", this.readonlyToken);
48
- }
49
- headers.append("Content-Type", "application/json");
50
- if (options == null ? void 0 : options.fetchOptions) {
51
- if ((_a = options == null ? void 0 : options.fetchOptions) == null ? void 0 : _a.headers) {
52
- Object.entries(options.fetchOptions.headers).forEach(([key2, value]) => {
53
- headers.append(key2, value);
54
- });
55
- }
56
- }
57
- const { headers: _, ...providedFetchOptions } = (options == null ? void 0 : options.fetchOptions) || {};
58
- const bodyString = JSON.stringify({
59
- query: args.query,
60
- variables: (args == null ? void 0 : args.variables) || {}
61
- });
62
- const optionsObject = {
63
- method: "POST",
64
- headers,
65
- body: bodyString,
66
- redirect: "follow",
67
- ...providedFetchOptions
68
- };
69
- const draftBranch = headers.get("x-branch");
70
- const url = replaceGithubPathSplit((args == null ? void 0 : args.url) || this.apiUrl, draftBranch);
71
- let key = "";
72
- let result;
73
- if (this.cache) {
74
- key = this.cache.makeKey(bodyString);
75
- await this.cacheLock.acquire(key, async () => {
76
- result = await this.cache.get(key);
77
- if (!result) {
78
- result = await requestFromServer(
79
- url,
80
- args.query,
81
- optionsObject,
82
- errorPolicyDefined
83
- );
84
- await this.cache.set(key, result);
85
- }
86
- });
87
- } else {
88
- result = await requestFromServer(
89
- url,
90
- args.query,
91
- optionsObject,
92
- errorPolicyDefined
93
- );
94
- }
95
- return result;
96
- }
97
- }
98
- async function requestFromServer(url, query, optionsObject, errorPolicyDefined) {
99
- const res = await fetch(url, optionsObject);
100
- if (!res.ok) {
101
- let additionalInfo = "";
102
- if (res.status === 401) {
103
- additionalInfo = "Please check that your client ID, URL and read only token are configured properly.";
104
- }
105
- throw new Error(
106
- `Server responded with status code ${res.status}, ${res.statusText}. ${additionalInfo ? additionalInfo : ""} Please see our FAQ for more information: https://tina.io/docs/errors/faq/`
107
- );
108
- }
109
- const json = await res.json();
110
- if (json.errors && errorPolicyDefined === "throw") {
111
- throw new Error(
112
- `Unable to fetch, please see our FAQ for more information: https://tina.io/docs/errors/faq/
113
- Errors:
114
- ${json.errors.map((error) => error.message).join("\n")}`
115
- );
116
- }
117
- const result = {
118
- data: json == null ? void 0 : json.data,
119
- errors: (json == null ? void 0 : json.errors) || null,
120
- query
121
- };
122
- return result;
123
- }
124
- function createClient(args) {
125
- const client = new TinaClient(args);
126
- return client;
127
- }
128
- export {
129
- TINA_HOST,
130
- TinaClient,
131
- createClient
132
- };
133
- //# sourceMappingURL=client.mjs.map
@@ -1 +0,0 @@
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,cAAA;AAYZ,SAAK,SAAS;AACT,SAAA,gBAAgB,+BAAO;AACvB,SAAA,UAAU,QAAQ,IAAI;AAC3B,SAAK,cAAc,eAAe;AAClC,SAAK,WAAW,YAAY;AAAA,EAC9B;AAAA,EAEA,MAAM,OAAO;AACX,QAAI,KAAK,aAAa;AACpB;AAAA,IACF;AACI,QAAA;AACF,UACE,KAAK,YACL,OAAO,WAAW,eAClB,OAAO,YAAY,aACnB;AACA,c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