@acdh-oeaw/keystatic-lib 0.1.2 → 0.2.0

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.
@@ -0,0 +1,4 @@
1
+ /** @see https://github.com/Thinkmill/keystatic/blob/main/packages/keystatic/src/form/fields/image/ui.tsx#L48-L63 */
2
+ declare function useObjectUrl(data: Uint8Array | null, contentType: string | undefined): string | null;
3
+
4
+ export { useObjectUrl };
@@ -0,0 +1,24 @@
1
+ import { useState, useEffect } from 'react';
2
+
3
+ // src/preview/index.ts
4
+ function useObjectUrl(data, contentType) {
5
+ const [url, setUrl] = useState(null);
6
+ useEffect(() => {
7
+ if (data == null) {
8
+ setUrl(null);
9
+ return void 0;
10
+ }
11
+ const url2 = URL.createObjectURL(
12
+ new Blob([data], contentType ? { type: contentType } : void 0)
13
+ );
14
+ setUrl(url2);
15
+ return () => {
16
+ URL.revokeObjectURL(url2);
17
+ };
18
+ }, [contentType, data]);
19
+ return url;
20
+ }
21
+
22
+ export { useObjectUrl };
23
+ //# sourceMappingURL=index.js.map
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/preview/index.ts"],"names":["url"],"mappings":";;;AAGO,SAAS,YAAA,CAAa,MAAyB,WAAiC,EAAA;AACtF,EAAA,MAAM,CAAC,GAAA,EAAK,MAAM,CAAA,GAAI,SAAwB,IAAI,CAAA,CAAA;AAElD,EAAA,SAAA,CAAU,MAAM;AACf,IAAA,IAAI,QAAQ,IAAM,EAAA;AACjB,MAAA,MAAA,CAAO,IAAI,CAAA,CAAA;AACX,MAAO,OAAA,KAAA,CAAA,CAAA;AAAA,KACR;AAEA,IAAA,MAAMA,OAAM,GAAI,CAAA,eAAA;AAAA,MACf,IAAI,IAAK,CAAA,CAAC,IAAI,CAAA,EAAG,cAAc,EAAE,IAAA,EAAM,WAAY,EAAA,GAAI,KAAS,CAAA,CAAA;AAAA,KACjE,CAAA;AACA,IAAA,MAAA,CAAOA,IAAG,CAAA,CAAA;AAEV,IAAA,OAAO,MAAM;AACZ,MAAA,GAAA,CAAI,gBAAgBA,IAAG,CAAA,CAAA;AAAA,KACxB,CAAA;AAAA,GACE,EAAA,CAAC,WAAa,EAAA,IAAI,CAAC,CAAA,CAAA;AAEtB,EAAO,OAAA,GAAA,CAAA;AACR","file":"index.js","sourcesContent":["import { useEffect, useState } from \"react\";\n\n/** @see https://github.com/Thinkmill/keystatic/blob/main/packages/keystatic/src/form/fields/image/ui.tsx#L48-L63 */\nexport function useObjectUrl(data: Uint8Array | null, contentType: string | undefined) {\n\tconst [url, setUrl] = useState<string | null>(null);\n\n\tuseEffect(() => {\n\t\tif (data == null) {\n\t\t\tsetUrl(null);\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst url = URL.createObjectURL(\n\t\t\tnew Blob([data], contentType ? { type: contentType } : undefined),\n\t\t);\n\t\tsetUrl(url);\n\n\t\treturn () => {\n\t\t\tURL.revokeObjectURL(url);\n\t\t};\n\t}, [contentType, data]);\n\n\treturn url;\n}\n"]}
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@acdh-oeaw/keystatic-lib",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": "./dist/index.js",
8
+ "./preview": "./dist/preview/index.js",
8
9
  "./reader": "./dist/reader.js"
9
10
  },
10
11
  "files": [
@@ -23,16 +24,18 @@
23
24
  "@keystatic/core": "0.x"
24
25
  },
25
26
  "devDependencies": {
26
- "@acdh-oeaw/commitlint-config": "^1.0.0",
27
+ "@acdh-oeaw/commitlint-config": "^2.0.0",
27
28
  "@acdh-oeaw/eslint-config": "^2.0.1",
28
29
  "@acdh-oeaw/eslint-config-node": "^2.0.1",
30
+ "@acdh-oeaw/eslint-config-react": "^2.0.2",
29
31
  "@acdh-oeaw/prettier-config": "^2.0.0",
30
- "@acdh-oeaw/tsconfig-lib": "^1.1.0",
32
+ "@acdh-oeaw/tsconfig-lib": "^1.1.1",
31
33
  "@changesets/changelog-github": "^0.5.0",
32
34
  "@changesets/cli": "^2.27.8",
33
- "@commitlint/cli": "^18.6.1",
34
- "@keystatic/core": "^0.5.34",
35
+ "@commitlint/cli": "^19.5.0",
36
+ "@keystatic/core": "^0.5.35",
35
37
  "@types/node": "^22.5.4",
38
+ "@types/react": "^18.3.5",
36
39
  "eslint": "^9.10.0",
37
40
  "eslint-config-flat-gitignore": "^0.3.0",
38
41
  "globals": "^15.9.0",
@@ -40,9 +43,10 @@
40
43
  "lint-staged": "^15.2.10",
41
44
  "npm-run-all2": "^6.2.2",
42
45
  "prettier": "^3.3.3",
46
+ "react": "^18.3.1",
43
47
  "simple-git-hooks": "^2.11.1",
44
48
  "tsup": "^8.2.4",
45
- "tsx": "^4.19.0",
49
+ "tsx": "^4.19.1",
46
50
  "typescript": "^5.6.2"
47
51
  },
48
52
  "commitlint": {