tinacms 0.0.0-a318f2f-20241010063440 → 0.0.0-a4a2eeb-20250102014725
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/admin/types.d.ts +3 -0
- package/dist/cache/node-cache.d.ts +1 -0
- package/dist/client.js +22 -23
- package/dist/client.mjs +3 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +209 -283
- package/dist/index.mjs +221 -295
- package/dist/{node-cache-7fa2452c.mjs → node-cache-4c336858.mjs} +18 -11
- package/dist/toolkit/fields/plugins/wrap-field-with-meta.d.ts +8 -0
- package/package.json +27 -28
- package/dist/__vite-browser-external-d06ac358.mjs +0 -4
package/dist/admin/types.d.ts
CHANGED
package/dist/client.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
(function(global, factory) {
|
|
2
|
-
typeof exports === "object" && typeof module !== "undefined" ? factory(exports
|
|
3
|
-
})(this, function(exports2
|
|
2
|
+
typeof exports === "object" && typeof module !== "undefined" ? factory(exports) : typeof define === "function" && define.amd ? define(["exports"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.tinacms = {}));
|
|
3
|
+
})(this, function(exports2) {
|
|
4
4
|
"use strict";
|
|
5
|
-
const { fetch: fetchPonyfillFN, Headers: HeadersPonyfill } = fetchPonyfill();
|
|
6
|
-
const fetchDefined = typeof fetch === "undefined" ? fetchPonyfillFN : fetch;
|
|
7
|
-
const HeadersDefined = typeof Headers === "undefined" ? HeadersPonyfill : Headers;
|
|
8
5
|
const TINA_HOST = "content.tinajs.io";
|
|
9
6
|
class TinaClient {
|
|
10
7
|
constructor({
|
|
@@ -39,7 +36,7 @@
|
|
|
39
36
|
var _a;
|
|
40
37
|
await this.init();
|
|
41
38
|
const errorPolicyDefined = errorPolicy || this.errorPolicy;
|
|
42
|
-
const headers = new
|
|
39
|
+
const headers = new Headers();
|
|
43
40
|
if (this.readonlyToken) {
|
|
44
41
|
headers.append("X-API-KEY", this.readonlyToken);
|
|
45
42
|
}
|
|
@@ -72,7 +69,7 @@
|
|
|
72
69
|
return value;
|
|
73
70
|
}
|
|
74
71
|
}
|
|
75
|
-
const res = await
|
|
72
|
+
const res = await fetch(url, optionsObject);
|
|
76
73
|
if (!res.ok) {
|
|
77
74
|
let additionalInfo = "";
|
|
78
75
|
if (res.status === 401) {
|
|
@@ -105,21 +102,27 @@
|
|
|
105
102
|
const client = new TinaClient(args);
|
|
106
103
|
return client;
|
|
107
104
|
}
|
|
108
|
-
const makeCacheDir = async (dir, fs) => {
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
const
|
|
105
|
+
const makeCacheDir = async (dir, fs, path, os) => {
|
|
106
|
+
const pathParts = dir.split(path.sep).filter(Boolean);
|
|
107
|
+
const cacheHash = pathParts[pathParts.length - 1];
|
|
108
|
+
const rootUser = pathParts[0];
|
|
112
109
|
let cacheDir = dir;
|
|
113
|
-
if (!fs.existsSync(path.join(path.sep,
|
|
114
|
-
cacheDir = path.join(os.tmpdir(),
|
|
110
|
+
if (!fs.existsSync(path.join(path.sep, rootUser))) {
|
|
111
|
+
cacheDir = path.join(os.tmpdir(), cacheHash);
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
115
|
+
} catch (error) {
|
|
116
|
+
throw new Error(`Failed to create cache directory: ${error.message}`);
|
|
115
117
|
}
|
|
116
|
-
fs.mkdirSync(cacheDir, { recursive: true });
|
|
117
118
|
return cacheDir;
|
|
118
119
|
};
|
|
119
120
|
const NodeCache = async (dir) => {
|
|
120
|
-
const fs =
|
|
121
|
-
const
|
|
122
|
-
const
|
|
121
|
+
const fs = require("node:fs");
|
|
122
|
+
const path = require("node:path");
|
|
123
|
+
const os = require("node:os");
|
|
124
|
+
const { createHash } = require("node:crypto");
|
|
125
|
+
const cacheDir = await makeCacheDir(dir, fs, path, os);
|
|
123
126
|
return {
|
|
124
127
|
makeKey: (key) => {
|
|
125
128
|
const input = key && key instanceof Object ? JSON.stringify(key) : key || "";
|
|
@@ -147,12 +150,8 @@
|
|
|
147
150
|
};
|
|
148
151
|
const nodeCache = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
149
152
|
__proto__: null,
|
|
150
|
-
NodeCache
|
|
151
|
-
|
|
152
|
-
const __viteBrowserExternal = {};
|
|
153
|
-
const __viteBrowserExternal$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
154
|
-
__proto__: null,
|
|
155
|
-
default: __viteBrowserExternal
|
|
153
|
+
NodeCache,
|
|
154
|
+
makeCacheDir
|
|
156
155
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
157
156
|
exports2.TINA_HOST = TINA_HOST;
|
|
158
157
|
exports2.TinaClient = TinaClient;
|
package/dist/client.mjs
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import fetchPonyfill from "fetch-ponyfill";
|
|
2
|
-
const { fetch: fetchPonyfillFN, Headers: HeadersPonyfill } = fetchPonyfill();
|
|
3
|
-
const fetchDefined = typeof fetch === "undefined" ? fetchPonyfillFN : fetch;
|
|
4
|
-
const HeadersDefined = typeof Headers === "undefined" ? HeadersPonyfill : Headers;
|
|
5
1
|
const TINA_HOST = "content.tinajs.io";
|
|
6
2
|
class TinaClient {
|
|
7
3
|
constructor({
|
|
@@ -24,7 +20,7 @@ class TinaClient {
|
|
|
24
20
|
}
|
|
25
21
|
try {
|
|
26
22
|
if (this.cacheDir && typeof window === "undefined" && typeof require !== "undefined") {
|
|
27
|
-
const { NodeCache } = await import("./node-cache-
|
|
23
|
+
const { NodeCache } = await import("./node-cache-4c336858.mjs");
|
|
28
24
|
this.cache = await NodeCache(this.cacheDir);
|
|
29
25
|
}
|
|
30
26
|
} catch (e) {
|
|
@@ -36,7 +32,7 @@ class TinaClient {
|
|
|
36
32
|
var _a;
|
|
37
33
|
await this.init();
|
|
38
34
|
const errorPolicyDefined = errorPolicy || this.errorPolicy;
|
|
39
|
-
const headers = new
|
|
35
|
+
const headers = new Headers();
|
|
40
36
|
if (this.readonlyToken) {
|
|
41
37
|
headers.append("X-API-KEY", this.readonlyToken);
|
|
42
38
|
}
|
|
@@ -69,7 +65,7 @@ class TinaClient {
|
|
|
69
65
|
return value;
|
|
70
66
|
}
|
|
71
67
|
}
|
|
72
|
-
const res = await
|
|
68
|
+
const res = await fetch(url, optionsObject);
|
|
73
69
|
if (!res.ok) {
|
|
74
70
|
let additionalInfo = "";
|
|
75
71
|
if (res.status === 401) {
|
package/dist/index.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export type TinaCollection = Collection;
|
|
|
53
53
|
export type TinaCloudSchema = Schema;
|
|
54
54
|
export declare const defineSchema: (config: Schema) => Schema<false>;
|
|
55
55
|
export declare const defineLegacyConfig: (config: Omit<TinaCMSProviderDefaultProps, "children">) => Omit<TinaCMSProviderDefaultProps, "children">;
|
|
56
|
-
interface MediaStoreClass {
|
|
56
|
+
export interface MediaStoreClass {
|
|
57
57
|
new (...args: any[]): MediaStore;
|
|
58
58
|
}
|
|
59
59
|
export declare const defineStaticConfig: (config: Config<(cms: TinaCMS) => TinaCMS, formifyCallback, DocumentCreatorCallback, MediaStoreClass>) => Config<(cms: TinaCMS) => TinaCMS, formifyCallback, import("./hooks/use-content-creator").DocumentCreatorArgs, MediaStoreClass, undefined>;
|