tinacms 0.0.0-995c297-20250604070945 → 0.0.0-998975c-20251211003654

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 (123) hide show
  1. package/dist/admin/api.d.ts +4 -1
  2. package/dist/admin/components/{Sidebar.d.ts → AdminNav.d.ts} +0 -3
  3. package/dist/admin/components/Page.d.ts +3 -9
  4. package/dist/admin/pages/CollectionCreatePage.d.ts +1 -1
  5. package/dist/admin/pages/DashboardPage.d.ts +0 -3
  6. package/dist/admin/pages/ScreenPage.d.ts +0 -3
  7. package/dist/auth/AuthModal.d.ts +1 -4
  8. package/dist/auth/TinaCloudProvider.d.ts +0 -1
  9. package/dist/cache/node-cache.d.ts +6 -2
  10. package/dist/client.js +240 -181
  11. package/dist/index.js +120021 -118152
  12. package/dist/internalClient/index.d.ts +26 -1
  13. package/dist/react.d.ts +13 -6
  14. package/dist/react.js +209 -204
  15. package/dist/rich-text/index.d.ts +6 -0
  16. package/dist/rich-text/index.js +234 -230
  17. package/dist/rich-text/prism.js +16 -18
  18. package/dist/rich-text/static.d.ts +154 -0
  19. package/dist/rich-text/{index.mjs → static.js} +90 -96
  20. package/dist/tina-cms.d.ts +1 -1
  21. package/dist/toolkit/components/ProgressBar.d.ts +11 -0
  22. package/dist/toolkit/components/media/media-item.d.ts +11 -1
  23. package/dist/toolkit/components/ui/breadcrumb.d.ts +11 -0
  24. package/dist/toolkit/components/ui/button.d.ts +11 -0
  25. package/dist/toolkit/components/ui/calendar.d.ts +8 -0
  26. package/dist/toolkit/components/ui/date-time-picker.d.ts +111 -0
  27. package/dist/toolkit/components/ui/dropdown-menu.d.ts +25 -0
  28. package/dist/toolkit/components/ui/input.d.ts +3 -0
  29. package/dist/toolkit/components/ui/popover.d.ts +7 -0
  30. package/dist/toolkit/components/ui/select.d.ts +13 -0
  31. package/dist/toolkit/fields/components/color-picker/block-widget.d.ts +3 -0
  32. package/dist/toolkit/fields/components/color-picker/color-input.d.ts +35 -0
  33. package/dist/toolkit/fields/components/color-picker/color-picker.d.ts +6 -2
  34. package/dist/toolkit/fields/components/color-picker/color-utils.d.ts +37 -0
  35. package/dist/toolkit/fields/components/color-picker/sketch-widget.d.ts +3 -0
  36. package/dist/toolkit/fields/components/password-field.d.ts +1 -1
  37. package/dist/toolkit/fields/components/reference/components/button.d.ts +1 -1
  38. package/dist/toolkit/fields/components/reference/components/popover.d.ts +1 -1
  39. package/dist/toolkit/fields/components/reference/model/reference-link-props.d.ts +2 -0
  40. package/dist/toolkit/fields/components/select.d.ts +2 -2
  41. package/dist/toolkit/fields/components/text-field.d.ts +1 -1
  42. package/dist/toolkit/fields/plugins/button-toggle-field-plugin.d.ts +2 -2
  43. package/dist/toolkit/fields/plugins/checkbox-group-field-plugin.d.ts +2 -2
  44. package/dist/toolkit/fields/plugins/color-field-plugin.d.ts +1 -0
  45. package/dist/toolkit/fields/plugins/date-field-plugin.d.ts +0 -2
  46. package/dist/toolkit/fields/plugins/dnd-kit-wrapper.d.ts +49 -0
  47. package/dist/toolkit/fields/plugins/group-field-plugin.d.ts +1 -1
  48. package/dist/toolkit/fields/plugins/group-list-field-plugin.d.ts +3 -1
  49. package/dist/toolkit/fields/plugins/list-field-meta.d.ts +1 -1
  50. package/dist/toolkit/fields/plugins/list-field-plugin.d.ts +3 -0
  51. package/dist/toolkit/fields/plugins/mdx-field-plugin/index.d.ts +2 -2
  52. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/editor.d.ts +2 -2
  53. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/blockquote-element.d.ts +1 -1
  54. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/button.d.ts +2 -2
  55. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/code-block-element.d.ts +17 -0
  56. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block/error-message.d.ts +6 -0
  57. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-combobox.d.ts +5 -1
  58. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-line-element.d.ts +1 -1
  59. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/command.d.ts +7 -7
  60. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/list-element.d.ts +2 -2
  61. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/paragraph-element.d.ts +1 -1
  62. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/slash-input-element.d.ts +1 -1
  63. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-cell-element.d.ts +2 -2
  64. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-element.d.ts +1 -1
  65. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/table/table-row-element.d.ts +1 -1
  66. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/use-floating-toolbar-hook.d.ts +1 -1
  67. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/core/common.d.ts +6 -0
  68. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/create-html-block/index.d.ts +4 -0
  69. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/editor-plugins.d.ts +2 -2
  70. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/plugins/ui/components.d.ts +18 -18
  71. package/dist/toolkit/fields/plugins/radio-group-field-plugin.d.ts +2 -2
  72. package/dist/toolkit/fields/plugins/select-field-plugin.d.ts +2 -2
  73. package/dist/toolkit/fields/plugins/toggle-field-plugin.d.ts +2 -2
  74. package/dist/toolkit/form-builder/create-branch-modal.d.ts +13 -0
  75. package/dist/toolkit/form-builder/editorial-workflow-constants.d.ts +17 -0
  76. package/dist/toolkit/form-builder/fields-builder.d.ts +1 -1
  77. package/dist/toolkit/form-builder/form-builder.d.ts +4 -16
  78. package/dist/toolkit/form-builder/index.d.ts +1 -0
  79. package/dist/toolkit/forms/field.d.ts +3 -0
  80. package/dist/toolkit/forms/form.d.ts +22 -3
  81. package/dist/toolkit/git-client/git-client.d.ts +25 -2
  82. package/dist/toolkit/git-client/git-file.d.ts +18 -0
  83. package/dist/toolkit/git-client/git-media-store.d.ts +13 -0
  84. package/dist/toolkit/git-client/use-git-file.d.ts +4 -0
  85. package/dist/toolkit/icons/Tina.d.ts +0 -5
  86. package/dist/toolkit/icons/TinaExtended.d.ts +4 -0
  87. package/dist/toolkit/icons/index.d.ts +1 -0
  88. package/dist/toolkit/index.d.ts +1 -1
  89. package/dist/toolkit/plugin-branch-switcher/branch-button.d.ts +4 -1
  90. package/dist/toolkit/plugin-branch-switcher/index.d.ts +0 -1
  91. package/dist/toolkit/react-modals/modal/modal-actions.d.ts +2 -1
  92. package/dist/toolkit/react-modals/modal/modal-header.d.ts +1 -1
  93. package/dist/toolkit/react-sidebar/components/NavMenuTrigger.d.ts +11 -0
  94. package/dist/toolkit/react-sidebar/components/VersionInfo.d.ts +2 -0
  95. package/dist/toolkit/react-sidebar/components/badge.d.ts +6 -0
  96. package/dist/toolkit/react-sidebar/components/callout.d.ts +5 -0
  97. package/dist/toolkit/react-sidebar/components/form-list.d.ts +1 -1
  98. package/dist/toolkit/react-sidebar/components/local-warning.d.ts +3 -1
  99. package/dist/toolkit/react-sidebar/components/nav-components.d.ts +11 -0
  100. package/dist/toolkit/react-sidebar/components/nav-context.d.ts +15 -0
  101. package/dist/toolkit/react-sidebar/components/nav.d.ts +6 -3
  102. package/dist/toolkit/react-sidebar/components/resize-handle.d.ts +0 -5
  103. package/dist/toolkit/react-sidebar/components/sidebar-body.d.ts +28 -7
  104. package/dist/toolkit/react-sidebar/components/sidebar.d.ts +0 -7
  105. package/dist/toolkit/react-sidebar/components/sync-status.d.ts +5 -8
  106. package/dist/toolkit/react-sidebar/index.d.ts +4 -1
  107. package/dist/toolkit/styles/button.d.ts +2 -2
  108. package/dist/toolkit/styles/dropdown-button.d.ts +75 -0
  109. package/dist/toolkit/styles/index.d.ts +1 -0
  110. package/dist/toolkit/tina-state.d.ts +11 -0
  111. package/dist/unifiedClient/index.d.ts +1 -1
  112. package/dist/utils/cn.d.ts +2 -0
  113. package/dist/utils/index.d.ts +1 -0
  114. package/package.json +33 -62
  115. package/dist/admin/pages/IndexingPage.d.ts +0 -2
  116. package/dist/client.mjs +0 -132
  117. package/dist/index.mjs +0 -121660
  118. package/dist/node-cache-5e8db9f0.mjs +0 -63
  119. package/dist/react.mjs +0 -246
  120. package/dist/rich-text/prism.mjs +0 -16
  121. package/dist/toolkit/fields/plugins/mdx-field-plugin/plate/components/plate-ui/code-block-element.d.ts +0 -17
  122. package/dist/toolkit/plugin-branch-switcher/branch-banner.d.ts +0 -2
  123. 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 {};
@@ -29,7 +29,7 @@ export declare class TinaClient<GenQueries> {
29
29
  initialized: boolean;
30
30
  cacheLock: AsyncLock | undefined;
31
31
  cacheDir: string;
32
- cache: Cache;
32
+ cache: Cache | null;
33
33
  constructor({ token, url, queries, errorPolicy, cacheDir, }: TinaClientArgs<GenQueries>);
34
34
  init(): Promise<void>;
35
35
  request<DataType extends Record<string, any> = any>({ errorPolicy, ...args }: TinaClientRequestArgs, options: {
@@ -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-995c297-20250604070945",
3
+ "type": "module",
4
+ "typings": "dist/index.d.ts",
5
+ "version": "0.0.0-998975c-20251211003654",
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,25 +22,21 @@
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
- "src/client.ts"
48
- ],
49
- "build": {
50
- "rollupOptions": {
51
- "external": [
52
- "crypto",
53
- "fs",
54
- "path",
55
- "os"
56
- ]
28
+ {
29
+ "name": "src/client.ts",
30
+ "target": "node"
57
31
  }
58
- }
32
+ ]
59
33
  },
60
- "typings": "dist/index.d.ts",
61
34
  "license": "Apache-2.0",
62
35
  "dependencies": {
63
36
  "@ariakit/react": "^0.4.15",
37
+ "@dnd-kit/core": "^6.1.0",
38
+ "@dnd-kit/sortable": "^8.0.0",
39
+ "@dnd-kit/utilities": "^3.2.2",
64
40
  "@floating-ui/dom": "^1.6.13",
65
41
  "@floating-ui/react-dom": "^2.1.2",
66
42
  "@graphql-inspector/core": "^6.2.1",
@@ -70,11 +46,12 @@
70
46
  "@radix-ui/react-checkbox": "^1.1.4",
71
47
  "@radix-ui/react-dialog": "^1.1.6",
72
48
  "@radix-ui/react-dropdown-menu": "^2.1.6",
73
- "@radix-ui/react-popover": "^1.1.6",
49
+ "@radix-ui/react-popover": "^1.1.15",
50
+ "@radix-ui/react-select": "^2.2.6",
74
51
  "@radix-ui/react-separator": "^1.1.2",
75
52
  "@radix-ui/react-slot": "^1.1.2",
76
53
  "@radix-ui/react-toolbar": "^1.1.2",
77
- "@radix-ui/react-tooltip": "^1.2.6",
54
+ "@radix-ui/react-tooltip": "^1.2.8",
78
55
  "@react-hook/window-size": "^3.1.1",
79
56
  "@udecode/cmdk": "^0.2.1",
80
57
  "@udecode/cn": "^48.0.3",
@@ -107,23 +84,23 @@
107
84
  "color-string": "^1.9.1",
108
85
  "crypto-js": "^4.2.0",
109
86
  "date-fns": "2.30.0",
87
+ "es-toolkit": "^1.42.0",
110
88
  "final-form": "4.20.10",
111
89
  "final-form-arrays": "^3.1.0",
112
90
  "final-form-set-field-data": "^1.0.2",
113
91
  "graphql": "15.8.0",
114
92
  "graphql-tag": "^2.12.6",
115
93
  "is-hotkey": "^0.2.0",
116
- "lodash.get": "^4.4.2",
117
- "lodash.set": "^4.3.2",
118
94
  "lucide-react": "^0.424.0",
119
95
  "mermaid": "9.3.0",
120
96
  "moment": "2.29.4",
97
+ "moment-timezone": "^0.6.0",
121
98
  "monaco-editor": "0.31.0",
122
99
  "prism-react-renderer": "^2.4.1",
123
100
  "prop-types": "15.7.2",
124
- "react-beautiful-dnd": "^13.1.1",
125
- "react-color": "^2.19.3",
101
+ "react-colorful": "^5.6.1",
126
102
  "react-datetime": "^3.3.1",
103
+ "react-day-picker": "^9.11.1",
127
104
  "react-dropzone": "14.2.3",
128
105
  "react-final-form": "^6.5.9",
129
106
  "react-icons": "^5.4.0",
@@ -133,33 +110,27 @@
133
110
  "webfontloader": "1.6.28",
134
111
  "yup": "^1.6.1",
135
112
  "zod": "^3.24.2",
136
- "@tinacms/mdx": "0.0.0-995c297-20250604070945",
137
- "@tinacms/schema-tools": "0.0.0-995c297-20250604070945",
138
- "@tinacms/search": "0.0.0-995c297-20250604070945"
113
+ "@tinacms/mdx": "0.0.0-998975c-20251211003654",
114
+ "@tinacms/schema-tools": "0.0.0-998975c-20251211003654",
115
+ "@tinacms/search": "0.0.0-998975c-20251211003654"
139
116
  },
140
117
  "devDependencies": {
141
118
  "@graphql-tools/utils": "^10.8.1",
142
119
  "@testing-library/dom": "^10.4.0",
143
- "@testing-library/jest-dom": "^6.6.3",
120
+ "@testing-library/jest-dom": "^6.7.0",
144
121
  "@testing-library/react": "^16.2.0",
145
122
  "@testing-library/user-event": "^14.6.1",
146
123
  "@types/atob": "^2.1.4",
147
124
  "@types/codemirror": "^5.60.15",
148
125
  "@types/color-string": "^1.5.5",
149
- "@types/lodash.debounce": "^4.0.9",
150
- "@types/lodash.get": "^4.4.9",
151
126
  "@types/node": "^22.13.1",
152
127
  "@types/prop-types": "^15.7.14",
153
128
  "@types/react": "^18.3.18",
154
- "@types/react-beautiful-dnd": "^13.1.8",
155
- "@types/react-color": "^3.0.13",
156
129
  "@types/react-dom": "^18.3.5",
157
- "@types/yup": "^0.32.0",
158
- "lowlight": "^3.3.0",
159
130
  "happy-dom": "15.10.2",
160
131
  "identity-obj-proxy": "^3.0.0",
161
- "isomorphic-fetch": "^3.0.0",
162
132
  "jest-file-snapshot": "^0.7.0",
133
+ "lowlight": "^3.3.0",
163
134
  "next": "14.2.10",
164
135
  "react": "^18.3.1",
165
136
  "react-dom": "^18.3.1",
@@ -169,7 +140,7 @@
169
140
  "typescript": "^5.7.3",
170
141
  "vite": "^5.4.14",
171
142
  "vitest": "^2.1.9",
172
- "@tinacms/scripts": "0.0.0-995c297-20250604070945"
143
+ "@tinacms/scripts": "1.4.2"
173
144
  },
174
145
  "peerDependencies": {
175
146
  "react": ">=16.14.0",
@@ -1,2 +0,0 @@
1
- import { FC } from 'react';
2
- export declare const IndexingPage: FC;
package/dist/client.mjs DELETED
@@ -1,132 +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
- };