@acdh-oeaw/keystatic-lib 0.6.0 → 0.7.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.
Files changed (51) hide show
  1. package/dist/_virtual/rolldown_runtime.js +27 -0
  2. package/dist/config.d.ts +6 -5
  3. package/dist/config.js +1 -3
  4. package/dist/create-asset-options.d.ts +7 -7
  5. package/dist/create-asset-options.js +15 -2
  6. package/dist/create-asset-options.js.map +1 -1
  7. package/dist/create-component.d.ts +6 -5
  8. package/dist/create-component.js +9 -2
  9. package/dist/create-component.js.map +1 -1
  10. package/dist/create-content-field-options.d.ts +10 -10
  11. package/dist/create-content-field-options.js +19 -3
  12. package/dist/create-content-field-options.js.map +1 -1
  13. package/dist/create-label.d.ts +4 -2
  14. package/dist/create-label.js +7 -2
  15. package/dist/create-label.js.map +1 -1
  16. package/dist/index.d.ts +8 -9
  17. package/dist/index.js +8 -8
  18. package/dist/node_modules/.pnpm/react@19.1.1/node_modules/react/cjs/react.development.js +718 -0
  19. package/dist/node_modules/.pnpm/react@19.1.1/node_modules/react/cjs/react.development.js.map +1 -0
  20. package/dist/node_modules/.pnpm/react@19.1.1/node_modules/react/cjs/react.production.js +354 -0
  21. package/dist/node_modules/.pnpm/react@19.1.1/node_modules/react/cjs/react.production.js.map +1 -0
  22. package/dist/node_modules/.pnpm/react@19.1.1/node_modules/react/index.js +15 -0
  23. package/dist/node_modules/.pnpm/react@19.1.1/node_modules/react/index.js.map +1 -0
  24. package/dist/preview/index.d.ts +7 -5
  25. package/dist/preview/index.js +21 -20
  26. package/dist/preview/index.js.map +1 -1
  27. package/dist/reader.d.ts +41 -38
  28. package/dist/reader.js +85 -84
  29. package/dist/reader.js.map +1 -1
  30. package/dist/resources.d.ts +14 -12
  31. package/dist/resources.js +34 -2
  32. package/dist/resources.js.map +1 -1
  33. package/dist/with-i18n-prefix.d.ts +5 -3
  34. package/dist/with-i18n-prefix.js +7 -2
  35. package/dist/with-i18n-prefix.js.map +1 -1
  36. package/license +1 -1
  37. package/package.json +44 -33
  38. package/dist/chunk-CI4JBTGG.js +0 -8
  39. package/dist/chunk-CI4JBTGG.js.map +0 -1
  40. package/dist/chunk-EEB35F4L.js +0 -15
  41. package/dist/chunk-EEB35F4L.js.map +0 -1
  42. package/dist/chunk-ENT7N2ZS.js +0 -16
  43. package/dist/chunk-ENT7N2ZS.js.map +0 -1
  44. package/dist/chunk-M7J4ISS4.js +0 -8
  45. package/dist/chunk-M7J4ISS4.js.map +0 -1
  46. package/dist/chunk-ZN3LEWB6.js +0 -35
  47. package/dist/chunk-ZN3LEWB6.js.map +0 -1
  48. package/dist/chunk-ZWZCXCMD.js +0 -10
  49. package/dist/chunk-ZWZCXCMD.js.map +0 -1
  50. package/dist/config.js.map +0 -1
  51. package/dist/index.js.map +0 -1
@@ -1,26 +1,27 @@
1
- import { useState, useEffect } from 'react';
1
+ import { __toESM } from "../_virtual/rolldown_runtime.js";
2
+ import { require_react } from "../node_modules/.pnpm/react@19.1.1/node_modules/react/index.js";
2
3
 
3
- // src/preview/index.ts
4
+ //#region src/preview/index.ts
5
+ var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
6
+ /** @see https://github.com/Thinkmill/keystatic/blob/main/packages/keystatic/src/form/fields/image/ui.tsx#L48-L63 */
4
7
  function useObjectUrl(params) {
5
- const data = params?.data;
6
- const contentType = params?.extension === "svg" ? "image/svg+xml" : void 0;
7
- const [url, setUrl] = useState(null);
8
- useEffect(() => {
9
- if (data == null) {
10
- setUrl(null);
11
- return void 0;
12
- }
13
- const url2 = URL.createObjectURL(
14
- new Blob([data], contentType ? { type: contentType } : void 0)
15
- );
16
- setUrl(url2);
17
- return () => {
18
- URL.revokeObjectURL(url2);
19
- };
20
- }, [contentType, data]);
21
- return url;
8
+ const data = params?.data;
9
+ const contentType = params?.extension === "svg" ? "image/svg+xml" : void 0;
10
+ const [url, setUrl] = (0, import_react.useState)(null);
11
+ (0, import_react.useEffect)(() => {
12
+ if (data == null) {
13
+ setUrl(null);
14
+ return void 0;
15
+ }
16
+ const url$1 = URL.createObjectURL(new Blob([data], contentType ? { type: contentType } : void 0));
17
+ setUrl(url$1);
18
+ return () => {
19
+ URL.revokeObjectURL(url$1);
20
+ };
21
+ }, [contentType, data]);
22
+ return url;
22
23
  }
23
24
 
25
+ //#endregion
24
26
  export { useObjectUrl };
25
- //# sourceMappingURL=index.js.map
26
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/preview/index.ts"],"names":["url"],"mappings":";;;AASO,SAAS,aAAa,MAAmC,EAAA;AAC/D,EAAA,MAAM,OAAO,MAAQ,EAAA,IAAA;AACrB,EAAA,MAAM,WAAc,GAAA,MAAA,EAAQ,SAAc,KAAA,KAAA,GAAQ,eAAkB,GAAA,KAAA,CAAA;AAEpE,EAAA,MAAM,CAAC,GAAA,EAAK,MAAM,CAAA,GAAI,SAAwB,IAAI,CAAA;AAElD,EAAA,SAAA,CAAU,MAAM;AACf,IAAA,IAAI,QAAQ,IAAM,EAAA;AACjB,MAAA,MAAA,CAAO,IAAI,CAAA;AACX,MAAO,OAAA,KAAA,CAAA;AAAA;AAGR,IAAA,MAAMA,OAAM,GAAI,CAAA,eAAA;AAAA,MACf,IAAI,IAAK,CAAA,CAAC,IAAI,CAAA,EAAG,cAAc,EAAE,IAAA,EAAM,WAAY,EAAA,GAAI,KAAS,CAAA;AAAA,KACjE;AACA,IAAA,MAAA,CAAOA,IAAG,CAAA;AAEV,IAAA,OAAO,MAAM;AACZ,MAAA,GAAA,CAAI,gBAAgBA,IAAG,CAAA;AAAA,KACxB;AAAA,GACE,EAAA,CAAC,WAAa,EAAA,IAAI,CAAC,CAAA;AAEtB,EAAO,OAAA,GAAA;AACR","file":"index.js","sourcesContent":["import { useEffect, useState } from \"react\";\n\nexport interface UseObjectUrlParams {\n\tdata: Uint8Array;\n\textension: string;\n\tfilename: string;\n}\n\n/** @see https://github.com/Thinkmill/keystatic/blob/main/packages/keystatic/src/form/fields/image/ui.tsx#L48-L63 */\nexport function useObjectUrl(params: UseObjectUrlParams | null) {\n\tconst data = params?.data;\n\tconst contentType = params?.extension === \"svg\" ? \"image/svg+xml\" : undefined;\n\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"]}
1
+ {"version":3,"file":"index.js","names":["url"],"sources":["../../src/preview/index.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nexport interface UseObjectUrlParams {\n\tdata: Uint8Array;\n\textension: string;\n\tfilename: string;\n}\n\n/** @see https://github.com/Thinkmill/keystatic/blob/main/packages/keystatic/src/form/fields/image/ui.tsx#L48-L63 */\nexport function useObjectUrl(params: UseObjectUrlParams | null) {\n\tconst data = params?.data;\n\tconst contentType = params?.extension === \"svg\" ? \"image/svg+xml\" : undefined;\n\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 as BlobPart], 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"],"mappings":";;;;;;AASA,SAAgB,aAAa,QAAmC;CAC/D,MAAM,OAAO,QAAQ;CACrB,MAAM,cAAc,QAAQ,cAAc,QAAQ,kBAAkB;CAEpE,MAAM,CAAC,KAAK,qCAAkC;AAE9C,mCAAgB;AACf,MAAI,QAAQ,MAAM;AACjB,UAAO;AACP,UAAO;;EAGR,MAAMA,QAAM,IAAI,gBACf,IAAI,KAAK,CAAC,OAAmB,cAAc,EAAE,MAAM,gBAAgB;AAEpE,SAAOA;AAEP,eAAa;AACZ,OAAI,gBAAgBA;;IAEnB,CAAC,aAAa;AAEjB,QAAO"}
package/dist/reader.d.ts CHANGED
@@ -1,43 +1,46 @@
1
- import * as url from 'url';
2
- import * as _keystatic_core from '@keystatic/core';
3
- import { Collection, ComponentSchema, Singleton, Config } from '@keystatic/core';
4
- import * as _keystatic_core_reader_github from '@keystatic/core/reader/github';
5
- import { createGitHubReader } from '@keystatic/core/reader/github';
6
- import { MDXModule } from 'mdx/types';
7
- import { Locale } from './config.js';
8
- import { WithoutI18nPrefix } from './with-i18n-prefix.js';
1
+ import { Locale } from "./config.js";
2
+ import { WithoutI18nPrefix } from "./with-i18n-prefix.js";
3
+ import * as _keystatic_core_reader_github0 from "@keystatic/core/reader/github";
4
+ import { createGitHubReader } from "@keystatic/core/reader/github";
5
+ import * as _keystatic_core0 from "@keystatic/core";
6
+ import { Collection, ComponentSchema, Config, Singleton } from "@keystatic/core";
7
+ import * as url0 from "url";
8
+ import { MDXModule } from "mdx/types";
9
9
 
10
+ //#region src/reader.d.ts
10
11
  type GitHubReaderConfig = Parameters<typeof createGitHubReader>[1];
11
- declare function createReader<TCollections extends Record<string, Collection<Record<string, ComponentSchema>, string>>, TSingletons extends Record<string, Singleton<Record<string, ComponentSchema>>>>(config: Config<TCollections, TSingletons>, getGitHubReaderConfig?: () => GitHubReaderConfig | null): _keystatic_core_reader_github.Reader<TCollections, TSingletons>;
12
+ declare function createReader<TCollections extends Record<string, Collection<Record<string, ComponentSchema>, string>>, TSingletons extends Record<string, Singleton<Record<string, ComponentSchema>>>>(config: Config<TCollections, TSingletons>, getGitHubReaderConfig?: () => GitHubReaderConfig | null): _keystatic_core_reader_github0.Reader<TCollections, TSingletons>;
12
13
  declare function createReaders<TCollections extends Record<string, Collection<Record<string, ComponentSchema>, string>>, TSingletons extends Record<string, Singleton<Record<string, ComponentSchema>>>, TLocale extends Locale, TMdxContent extends MDXModule>(config: Config<TCollections, TSingletons>, getMdxContent: (code: string, locale: TLocale, baseUrl: URL) => Promise<TMdxContent>): {
13
- createCollectionResource: <TKeys extends WithoutI18nPrefix<keyof TCollections & string, TLocale>>(name: TKeys, locale: TLocale) => {
14
- all: () => Promise<{
15
- collection: TKeys;
16
- id: string;
17
- md5: string;
18
- data: TCollections[`${TLocale}:${TKeys}`]["schema"] extends infer T extends Record<string, ComponentSchema> ? { [Key in keyof T]: TCollections[`${TLocale}:${TKeys}`]["slugField"] extends infer T_1 ? T_1 extends TCollections[`${TLocale}:${TKeys}`]["slugField"] ? T_1 extends Key ? TCollections[`${TLocale}:${TKeys}`]["schema"][Key] extends _keystatic_core.SlugFormField<any, any, any, infer SlugSerializedValue> ? SlugSerializedValue : _keystatic_core.ValueForReadingDeep<TCollections[`${TLocale}:${TKeys}`]["schema"][Key]> : _keystatic_core.ValueForReadingDeep<TCollections[`${TLocale}:${TKeys}`]["schema"][Key]> : never : never; } : never;
19
- compile(code: string): Promise<TMdxContent>;
20
- }[]>;
21
- baseUrl: (id: string) => url.URL;
22
- compile: (id: string, code: string) => Promise<TMdxContent>;
23
- list: () => Promise<string[]>;
24
- read: (id: string) => Promise<{
25
- collection: TKeys;
26
- id: string;
27
- md5: string;
28
- data: TCollections[`${TLocale}:${TKeys}`]["schema"] extends infer T extends Record<string, ComponentSchema> ? { [Key in keyof T]: TCollections[`${TLocale}:${TKeys}`]["slugField"] extends infer T_1 ? T_1 extends TCollections[`${TLocale}:${TKeys}`]["slugField"] ? T_1 extends Key ? TCollections[`${TLocale}:${TKeys}`]["schema"][Key] extends _keystatic_core.SlugFormField<any, any, any, infer SlugSerializedValue> ? SlugSerializedValue : _keystatic_core.ValueForReadingDeep<TCollections[`${TLocale}:${TKeys}`]["schema"][Key]> : _keystatic_core.ValueForReadingDeep<TCollections[`${TLocale}:${TKeys}`]["schema"][Key]> : never : never; } : never;
29
- compile(code: string): Promise<TMdxContent>;
30
- }>;
31
- };
32
- createSingletonResource: <TKeys extends WithoutI18nPrefix<keyof TSingletons & string, TLocale>>(name: TKeys, locale: TLocale) => {
33
- baseUrl: () => url.URL;
34
- compile: (code: string) => Promise<TMdxContent>;
35
- read: () => Promise<{
36
- singleton: TKeys;
37
- data: TSingletons[`${TLocale}:${TKeys}`]["schema"] extends infer T extends Record<string, ComponentSchema> ? { readonly [Key in keyof T]: _keystatic_core.ValueForReadingDeep<TSingletons[`${TLocale}:${TKeys}`]["schema"][Key]>; } : never;
38
- compile: (code: string) => Promise<TMdxContent>;
39
- }>;
40
- };
14
+ createCollectionResource: <TKeys extends WithoutI18nPrefix<keyof TCollections & string, TLocale>>(name: TKeys, locale: TLocale) => {
15
+ all: () => Promise<{
16
+ collection: TKeys;
17
+ id: string;
18
+ md5: string;
19
+ data: TCollections[`${TLocale}:${TKeys}`]["schema"] extends infer T extends Record<string, ComponentSchema> ? { [Key in keyof T]: SlugField extends Key ? T[Key] extends _keystatic_core0.SlugFormField<any, any, any, infer SlugSerializedValue> ? SlugSerializedValue : (Opts[0] extends infer T_1 ? T_1 extends Opts[0] ? T_1 extends {} ? T_1["resolveLinkedFiles"] : undefined : never : never) extends infer T_2 ? T_2 extends (Opts[0] extends infer T_3 ? T_3 extends Opts[0] ? T_3 extends {} ? T_3["resolveLinkedFiles"] : undefined : never : never) ? T_2 extends true ? _keystatic_core0.ValueForReadingDeep<T[Key]> : _keystatic_core0.ValueForReading<T[Key]> : never : never : (Opts[0] extends infer T_4 ? T_4 extends Opts[0] ? T_4 extends {} ? T_4["resolveLinkedFiles"] : undefined : never : never) extends infer T_5 ? T_5 extends (Opts[0] extends infer T_6 ? T_6 extends Opts[0] ? T_6 extends {} ? T_6["resolveLinkedFiles"] : undefined : never : never) ? T_5 extends true ? _keystatic_core0.ValueForReadingDeep<T[Key]> : _keystatic_core0.ValueForReading<T[Key]> : never : never } : never;
20
+ compile(code: string): Promise<TMdxContent>;
21
+ }[]>;
22
+ baseUrl: (id: string) => url0.URL;
23
+ compile: (id: string, code: string) => Promise<TMdxContent>;
24
+ list: () => Promise<string[]>;
25
+ read: (id: string) => Promise<{
26
+ collection: TKeys;
27
+ id: string;
28
+ md5: string;
29
+ data: TCollections[`${TLocale}:${TKeys}`]["schema"] extends infer T extends Record<string, ComponentSchema> ? { [Key in keyof T]: SlugField extends Key ? T[Key] extends _keystatic_core0.SlugFormField<any, any, any, infer SlugSerializedValue> ? SlugSerializedValue : (Opts[0] extends infer T_1 ? T_1 extends Opts[0] ? T_1 extends {} ? T_1["resolveLinkedFiles"] : undefined : never : never) extends infer T_2 ? T_2 extends (Opts[0] extends infer T_3 ? T_3 extends Opts[0] ? T_3 extends {} ? T_3["resolveLinkedFiles"] : undefined : never : never) ? T_2 extends true ? _keystatic_core0.ValueForReadingDeep<T[Key]> : _keystatic_core0.ValueForReading<T[Key]> : never : never : (Opts[0] extends infer T_4 ? T_4 extends Opts[0] ? T_4 extends {} ? T_4["resolveLinkedFiles"] : undefined : never : never) extends infer T_5 ? T_5 extends (Opts[0] extends infer T_6 ? T_6 extends Opts[0] ? T_6 extends {} ? T_6["resolveLinkedFiles"] : undefined : never : never) ? T_5 extends true ? _keystatic_core0.ValueForReadingDeep<T[Key]> : _keystatic_core0.ValueForReading<T[Key]> : never : never } : never;
30
+ compile(code: string): Promise<TMdxContent>;
31
+ }>;
32
+ };
33
+ createSingletonResource: <TKeys extends WithoutI18nPrefix<keyof TSingletons & string, TLocale>>(name: TKeys, locale: TLocale) => {
34
+ baseUrl: () => url0.URL;
35
+ compile: (code: string) => Promise<TMdxContent>;
36
+ read: () => Promise<{
37
+ singleton: TKeys;
38
+ md5: string;
39
+ data: TSingletons[`${TLocale}:${TKeys}`]["schema"] extends infer T extends Record<string, ComponentSchema> ? { readonly [Key in keyof T]: _keystatic_core0.ValueForReadingDeep<T[Key]> } : never;
40
+ compile: (code: string) => Promise<TMdxContent>;
41
+ }>;
42
+ };
41
43
  };
42
-
44
+ //#endregion
43
45
  export { createReader, createReaders };
46
+ //# sourceMappingURL=reader.d.ts.map
package/dist/reader.js CHANGED
@@ -1,92 +1,93 @@
1
- import { withI18nPrefix } from './chunk-M7J4ISS4.js';
2
- import assert from 'node:assert/strict';
3
- import { createHash } from 'node:crypto';
4
- import { join } from 'node:path';
5
- import { pathToFileURL } from 'node:url';
6
- import { serialize } from 'node:v8';
7
- import { createReader as createReader$1 } from '@keystatic/core/reader';
8
- import { createGitHubReader } from '@keystatic/core/reader/github';
1
+ import { withI18nPrefix } from "./with-i18n-prefix.js";
2
+ import assert from "node:assert/strict";
3
+ import { createHash } from "node:crypto";
4
+ import { join } from "node:path";
5
+ import { pathToFileURL } from "node:url";
6
+ import { serialize } from "node:v8";
7
+ import { createReader as createReader$1 } from "@keystatic/core/reader";
8
+ import { createGitHubReader } from "@keystatic/core/reader/github";
9
9
 
10
+ //#region src/reader.ts
10
11
  function createReader(config, getGitHubReaderConfig) {
11
- const gitHubConfig = getGitHubReaderConfig?.();
12
- if (gitHubConfig != null) {
13
- return createGitHubReader(config, gitHubConfig);
14
- }
15
- return createReader$1(process.cwd(), config);
12
+ const gitHubConfig = getGitHubReaderConfig?.();
13
+ if (gitHubConfig != null) return createGitHubReader(config, gitHubConfig);
14
+ return createReader$1(process.cwd(), config);
16
15
  }
17
16
  function createReaders(config, getMdxContent) {
18
- function createCollectionResource(name, locale) {
19
- const reader = createReader(config);
20
- const collectionName = withI18nPrefix(name, locale);
21
- const collectionReader = reader.collections[collectionName];
22
- const collectionConfig = reader.config.collections?.[collectionName];
23
- assert(collectionConfig?.path);
24
- function baseUrl(id) {
25
- return pathToFileURL(join(process.cwd(), collectionConfig.path.replace(/\*+/, id)));
26
- }
27
- async function compile(id, code) {
28
- return getMdxContent(code, locale, baseUrl(id));
29
- }
30
- function list() {
31
- return collectionReader.list();
32
- }
33
- async function read(id) {
34
- const data = await collectionReader.readOrThrow(id, { resolveLinkedFiles: true });
35
- const md5 = createHash("md5").update(serialize(data)).digest("hex");
36
- return {
37
- collection: name,
38
- id,
39
- md5,
40
- data,
41
- compile(code) {
42
- return compile(id, code);
43
- }
44
- };
45
- }
46
- async function all() {
47
- const ids = await list();
48
- return Promise.all(ids.map(read));
49
- }
50
- return {
51
- all,
52
- baseUrl,
53
- compile,
54
- list,
55
- read
56
- };
57
- }
58
- function createSingletonResource(name, locale) {
59
- const reader = createReader(config);
60
- const i18nName = withI18nPrefix(name, locale);
61
- const singletonReader = reader.singletons[i18nName];
62
- const singletonConfig = reader.config.singletons?.[i18nName];
63
- assert(singletonConfig?.path);
64
- function baseUrl() {
65
- return pathToFileURL(join(process.cwd(), singletonConfig.path));
66
- }
67
- async function compile(code) {
68
- return getMdxContent(code, locale, baseUrl());
69
- }
70
- async function read() {
71
- const data = await singletonReader.readOrThrow({ resolveLinkedFiles: true });
72
- return {
73
- singleton: name,
74
- data,
75
- compile
76
- };
77
- }
78
- return {
79
- baseUrl,
80
- compile,
81
- read
82
- };
83
- }
84
- return {
85
- createCollectionResource,
86
- createSingletonResource
87
- };
17
+ function createCollectionResource(name, locale) {
18
+ const reader = createReader(config);
19
+ const collectionName = withI18nPrefix(name, locale);
20
+ const collectionReader = reader.collections[collectionName];
21
+ const collectionConfig = reader.config.collections?.[collectionName];
22
+ assert(collectionConfig?.path);
23
+ function baseUrl(id) {
24
+ return pathToFileURL(join(process.cwd(), collectionConfig.path.replace(/\*+/, id)));
25
+ }
26
+ async function compile(id, code) {
27
+ return getMdxContent(code, locale, baseUrl(id));
28
+ }
29
+ function list() {
30
+ return collectionReader.list();
31
+ }
32
+ async function read(id) {
33
+ const data = await collectionReader.readOrThrow(id, { resolveLinkedFiles: true });
34
+ const md5 = createHash("md5").update(serialize(data)).digest("hex");
35
+ return {
36
+ collection: name,
37
+ id,
38
+ md5,
39
+ data,
40
+ compile(code) {
41
+ return compile(id, code);
42
+ }
43
+ };
44
+ }
45
+ async function all() {
46
+ const ids = await list();
47
+ return Promise.all(ids.map(read));
48
+ }
49
+ return {
50
+ all,
51
+ baseUrl,
52
+ compile,
53
+ list,
54
+ read
55
+ };
56
+ }
57
+ function createSingletonResource(name, locale) {
58
+ const reader = createReader(config);
59
+ const i18nName = withI18nPrefix(name, locale);
60
+ const singletonReader = reader.singletons[i18nName];
61
+ const singletonConfig = reader.config.singletons?.[i18nName];
62
+ assert(singletonConfig?.path);
63
+ function baseUrl() {
64
+ return pathToFileURL(join(process.cwd(), singletonConfig.path));
65
+ }
66
+ async function compile(code) {
67
+ return getMdxContent(code, locale, baseUrl());
68
+ }
69
+ async function read() {
70
+ const data = await singletonReader.readOrThrow({ resolveLinkedFiles: true });
71
+ const md5 = createHash("md5").update(serialize(data)).digest("hex");
72
+ return {
73
+ singleton: name,
74
+ md5,
75
+ data,
76
+ compile
77
+ };
78
+ }
79
+ return {
80
+ baseUrl,
81
+ compile,
82
+ read
83
+ };
84
+ }
85
+ return {
86
+ createCollectionResource,
87
+ createSingletonResource
88
+ };
88
89
  }
89
90
 
91
+ //#endregion
90
92
  export { createReader, createReaders };
91
- //# sourceMappingURL=reader.js.map
92
93
  //# sourceMappingURL=reader.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/reader.ts"],"names":["createLocalReader"],"mappings":"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","file":"reader.js","sourcesContent":["import assert from \"node:assert/strict\";\nimport { createHash } from \"node:crypto\";\nimport { join } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { serialize } from \"node:v8\";\n\nimport type { Collection, ComponentSchema, Config, Singleton } from \"@keystatic/core\";\nimport { createReader as createLocalReader } from \"@keystatic/core/reader\";\nimport { createGitHubReader } from \"@keystatic/core/reader/github\";\nimport type { MDXModule } from \"mdx/types\";\n\nimport type { Locale } from \"./config\";\nimport { withI18nPrefix, type WithoutI18nPrefix } from \"./with-i18n-prefix\";\n\ntype GitHubReaderConfig = Parameters<typeof createGitHubReader>[1];\n\nexport function createReader<\n\tTCollections extends Record<string, Collection<Record<string, ComponentSchema>, string>>,\n\tTSingletons extends Record<string, Singleton<Record<string, ComponentSchema>>>,\n>(\n\tconfig: Config<TCollections, TSingletons>,\n\tgetGitHubReaderConfig?: () => GitHubReaderConfig | null,\n) {\n\tconst gitHubConfig = getGitHubReaderConfig?.();\n\n\tif (gitHubConfig != null) {\n\t\treturn createGitHubReader(config, gitHubConfig);\n\t}\n\n\treturn createLocalReader(process.cwd(), config);\n}\n\nexport function createReaders<\n\tTCollections extends Record<string, Collection<Record<string, ComponentSchema>, string>>,\n\tTSingletons extends Record<string, Singleton<Record<string, ComponentSchema>>>,\n\tTLocale extends Locale,\n\tTMdxContent extends MDXModule,\n>(\n\tconfig: Config<TCollections, TSingletons>,\n\tgetMdxContent: (code: string, locale: TLocale, baseUrl: URL) => Promise<TMdxContent>,\n) {\n\tfunction createCollectionResource<\n\t\tTKeys extends WithoutI18nPrefix<keyof TCollections & string, TLocale>,\n\t>(name: TKeys, locale: TLocale) {\n\t\tconst reader = createReader(config);\n\t\tconst collectionName = withI18nPrefix(name, locale);\n\n\t\tconst collectionReader = reader.collections[collectionName];\n\t\tconst collectionConfig = reader.config.collections?.[collectionName];\n\n\t\tassert(collectionConfig?.path);\n\n\t\tfunction baseUrl(id: string) {\n\t\t\treturn pathToFileURL(join(process.cwd(), collectionConfig!.path!.replace(/\\*+/, id)));\n\t\t}\n\n\t\tasync function compile(id: string, code: string) {\n\t\t\treturn getMdxContent(code, locale, baseUrl(id));\n\t\t}\n\n\t\tfunction list() {\n\t\t\treturn collectionReader.list();\n\t\t}\n\n\t\tasync function read(id: string) {\n\t\t\tconst data = await collectionReader.readOrThrow(id, { resolveLinkedFiles: true });\n\t\t\tconst md5 = createHash(\"md5\").update(serialize(data)).digest(\"hex\");\n\n\t\t\treturn {\n\t\t\t\tcollection: name,\n\t\t\t\tid,\n\t\t\t\tmd5,\n\t\t\t\tdata,\n\t\t\t\tcompile(code: string) {\n\t\t\t\t\treturn compile(id, code);\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tasync function all() {\n\t\t\tconst ids = await list();\n\n\t\t\treturn Promise.all(ids.map(read));\n\t\t}\n\n\t\treturn {\n\t\t\tall,\n\t\t\tbaseUrl,\n\t\t\tcompile,\n\t\t\tlist,\n\t\t\tread,\n\t\t};\n\t}\n\n\tfunction createSingletonResource<\n\t\tTKeys extends WithoutI18nPrefix<keyof TSingletons & string, TLocale>,\n\t>(name: TKeys, locale: TLocale) {\n\t\tconst reader = createReader(config);\n\t\tconst i18nName = withI18nPrefix(name, locale);\n\n\t\tconst singletonReader = reader.singletons[i18nName];\n\t\tconst singletonConfig = reader.config.singletons?.[i18nName];\n\n\t\tassert(singletonConfig?.path);\n\n\t\tfunction baseUrl() {\n\t\t\treturn pathToFileURL(join(process.cwd(), singletonConfig!.path!));\n\t\t}\n\n\t\tasync function compile(code: string) {\n\t\t\treturn getMdxContent(code, locale, baseUrl());\n\t\t}\n\n\t\tasync function read() {\n\t\t\tconst data = await singletonReader.readOrThrow({ resolveLinkedFiles: true });\n\n\t\t\treturn {\n\t\t\t\tsingleton: name,\n\t\t\t\tdata,\n\t\t\t\tcompile,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tbaseUrl,\n\t\t\tcompile,\n\t\t\tread,\n\t\t};\n\t}\n\n\treturn {\n\t\tcreateCollectionResource,\n\t\tcreateSingletonResource,\n\t};\n}\n"]}
1
+ {"version":3,"file":"reader.js","names":["createLocalReader"],"sources":["../src/reader.ts"],"sourcesContent":["import assert from \"node:assert/strict\";\nimport { createHash } from \"node:crypto\";\nimport { join } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { serialize } from \"node:v8\";\n\nimport type { Collection, ComponentSchema, Config, Singleton } from \"@keystatic/core\";\nimport { createReader as createLocalReader } from \"@keystatic/core/reader\";\nimport { createGitHubReader } from \"@keystatic/core/reader/github\";\nimport type { MDXModule } from \"mdx/types\";\n\nimport type { Locale } from \"./config\";\nimport { withI18nPrefix, type WithoutI18nPrefix } from \"./with-i18n-prefix\";\n\ntype GitHubReaderConfig = Parameters<typeof createGitHubReader>[1];\n\nexport function createReader<\n\tTCollections extends Record<string, Collection<Record<string, ComponentSchema>, string>>,\n\tTSingletons extends Record<string, Singleton<Record<string, ComponentSchema>>>,\n>(\n\tconfig: Config<TCollections, TSingletons>,\n\tgetGitHubReaderConfig?: () => GitHubReaderConfig | null,\n) {\n\tconst gitHubConfig = getGitHubReaderConfig?.();\n\n\tif (gitHubConfig != null) {\n\t\treturn createGitHubReader(config, gitHubConfig);\n\t}\n\n\treturn createLocalReader(process.cwd(), config);\n}\n\nexport function createReaders<\n\tTCollections extends Record<string, Collection<Record<string, ComponentSchema>, string>>,\n\tTSingletons extends Record<string, Singleton<Record<string, ComponentSchema>>>,\n\tTLocale extends Locale,\n\tTMdxContent extends MDXModule,\n>(\n\tconfig: Config<TCollections, TSingletons>,\n\tgetMdxContent: (code: string, locale: TLocale, baseUrl: URL) => Promise<TMdxContent>,\n) {\n\tfunction createCollectionResource<\n\t\tTKeys extends WithoutI18nPrefix<keyof TCollections & string, TLocale>,\n\t>(name: TKeys, locale: TLocale) {\n\t\tconst reader = createReader(config);\n\t\tconst collectionName = withI18nPrefix(name, locale);\n\n\t\tconst collectionReader = reader.collections[collectionName];\n\t\tconst collectionConfig = reader.config.collections?.[collectionName];\n\n\t\tassert(collectionConfig?.path);\n\n\t\tfunction baseUrl(id: string) {\n\t\t\treturn pathToFileURL(join(process.cwd(), collectionConfig!.path!.replace(/\\*+/, id)));\n\t\t}\n\n\t\tasync function compile(id: string, code: string) {\n\t\t\treturn getMdxContent(code, locale, baseUrl(id));\n\t\t}\n\n\t\tfunction list() {\n\t\t\treturn collectionReader.list();\n\t\t}\n\n\t\tasync function read(id: string) {\n\t\t\tconst data = await collectionReader.readOrThrow(id, { resolveLinkedFiles: true });\n\t\t\tconst md5 = createHash(\"md5\").update(serialize(data)).digest(\"hex\");\n\n\t\t\treturn {\n\t\t\t\tcollection: name,\n\t\t\t\tid,\n\t\t\t\tmd5,\n\t\t\t\tdata,\n\t\t\t\tcompile(code: string) {\n\t\t\t\t\treturn compile(id, code);\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\tasync function all() {\n\t\t\tconst ids = await list();\n\n\t\t\treturn Promise.all(ids.map(read));\n\t\t}\n\n\t\treturn {\n\t\t\tall,\n\t\t\tbaseUrl,\n\t\t\tcompile,\n\t\t\tlist,\n\t\t\tread,\n\t\t};\n\t}\n\n\tfunction createSingletonResource<\n\t\tTKeys extends WithoutI18nPrefix<keyof TSingletons & string, TLocale>,\n\t>(name: TKeys, locale: TLocale) {\n\t\tconst reader = createReader(config);\n\t\tconst i18nName = withI18nPrefix(name, locale);\n\n\t\tconst singletonReader = reader.singletons[i18nName];\n\t\tconst singletonConfig = reader.config.singletons?.[i18nName];\n\n\t\tassert(singletonConfig?.path);\n\n\t\tfunction baseUrl() {\n\t\t\treturn pathToFileURL(join(process.cwd(), singletonConfig!.path!));\n\t\t}\n\n\t\tasync function compile(code: string) {\n\t\t\treturn getMdxContent(code, locale, baseUrl());\n\t\t}\n\n\t\tasync function read() {\n\t\t\tconst data = await singletonReader.readOrThrow({ resolveLinkedFiles: true });\n\t\t\tconst md5 = createHash(\"md5\").update(serialize(data)).digest(\"hex\");\n\n\t\t\treturn {\n\t\t\t\tsingleton: name,\n\t\t\t\tmd5,\n\t\t\t\tdata,\n\t\t\t\tcompile,\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tbaseUrl,\n\t\t\tcompile,\n\t\t\tread,\n\t\t};\n\t}\n\n\treturn {\n\t\tcreateCollectionResource,\n\t\tcreateSingletonResource,\n\t};\n}\n"],"mappings":";;;;;;;;;;AAgBA,SAAgB,aAIf,QACA,uBACC;CACD,MAAM,eAAe;AAErB,KAAI,gBAAgB,KACnB,QAAO,mBAAmB,QAAQ;AAGnC,QAAOA,eAAkB,QAAQ,OAAO;;AAGzC,SAAgB,cAMf,QACA,eACC;CACD,SAAS,yBAEP,MAAa,QAAiB;EAC/B,MAAM,SAAS,aAAa;EAC5B,MAAM,iBAAiB,eAAe,MAAM;EAE5C,MAAM,mBAAmB,OAAO,YAAY;EAC5C,MAAM,mBAAmB,OAAO,OAAO,cAAc;AAErD,SAAO,kBAAkB;EAEzB,SAAS,QAAQ,IAAY;AAC5B,UAAO,cAAc,KAAK,QAAQ,OAAO,iBAAkB,KAAM,QAAQ,OAAO;;EAGjF,eAAe,QAAQ,IAAY,MAAc;AAChD,UAAO,cAAc,MAAM,QAAQ,QAAQ;;EAG5C,SAAS,OAAO;AACf,UAAO,iBAAiB;;EAGzB,eAAe,KAAK,IAAY;GAC/B,MAAM,OAAO,MAAM,iBAAiB,YAAY,IAAI,EAAE,oBAAoB;GAC1E,MAAM,MAAM,WAAW,OAAO,OAAO,UAAU,OAAO,OAAO;AAE7D,UAAO;IACN,YAAY;IACZ;IACA;IACA;IACA,QAAQ,MAAc;AACrB,YAAO,QAAQ,IAAI;;;;EAKtB,eAAe,MAAM;GACpB,MAAM,MAAM,MAAM;AAElB,UAAO,QAAQ,IAAI,IAAI,IAAI;;AAG5B,SAAO;GACN;GACA;GACA;GACA;GACA;;;CAIF,SAAS,wBAEP,MAAa,QAAiB;EAC/B,MAAM,SAAS,aAAa;EAC5B,MAAM,WAAW,eAAe,MAAM;EAEtC,MAAM,kBAAkB,OAAO,WAAW;EAC1C,MAAM,kBAAkB,OAAO,OAAO,aAAa;AAEnD,SAAO,iBAAiB;EAExB,SAAS,UAAU;AAClB,UAAO,cAAc,KAAK,QAAQ,OAAO,gBAAiB;;EAG3D,eAAe,QAAQ,MAAc;AACpC,UAAO,cAAc,MAAM,QAAQ;;EAGpC,eAAe,OAAO;GACrB,MAAM,OAAO,MAAM,gBAAgB,YAAY,EAAE,oBAAoB;GACrE,MAAM,MAAM,WAAW,OAAO,OAAO,UAAU,OAAO,OAAO;AAE7D,UAAO;IACN,WAAW;IACX;IACA;IACA;;;AAIF,SAAO;GACN;GACA;GACA;;;AAIF,QAAO;EACN;EACA"}
@@ -1,22 +1,24 @@
1
- import { ComponentSchema, Collection, Singleton } from '@keystatic/core';
2
- import { Locale } from './config.js';
1
+ import { Locale } from "./config.js";
2
+ import { Collection, ComponentSchema, Singleton } from "@keystatic/core";
3
3
 
4
+ //#region src/resources.d.ts
4
5
  declare function createPaths<TPath extends `/${string}/`>(path: TPath, locale: Locale): {
5
- readonly assetPath: `/content/assets/${string}${TPath}`;
6
- readonly downloadPath: `/content/downloads/${string}${TPath}`;
6
+ readonly assetPath: `/content/assets/${string}${TPath}`;
7
+ readonly downloadPath: `/content/downloads/${string}${TPath}`;
7
8
  };
8
9
  type Paths<TPath extends `/${string}/`> = ReturnType<typeof createPaths<TPath>>;
9
10
  declare function createCollectionPaths<TPath extends `/${string}/`>(path: TPath, locale: Locale): {
10
- readonly contentPath: `./content/${string}${TPath}*/`;
11
- readonly assetPath: `/content/assets/${string}${TPath}`;
12
- readonly downloadPath: `/content/downloads/${string}${TPath}`;
11
+ readonly contentPath: `./content/${string}${TPath}*/`;
12
+ readonly assetPath: `/content/assets/${string}${TPath}`;
13
+ readonly downloadPath: `/content/downloads/${string}${TPath}`;
13
14
  };
14
15
  declare function createSingletonPaths<TPath extends `/${string}/`>(path: TPath, locale: Locale): {
15
- readonly contentPath: `./content/${string}${TPath}`;
16
- readonly assetPath: `/content/assets/${string}${TPath}`;
17
- readonly downloadPath: `/content/downloads/${string}${TPath}`;
16
+ readonly contentPath: `./content/${string}${TPath}`;
17
+ readonly assetPath: `/content/assets/${string}${TPath}`;
18
+ readonly downloadPath: `/content/downloads/${string}${TPath}`;
18
19
  };
19
20
  declare function createCollection<TPath extends `/${string}/`, TLocale extends Locale, TSchema extends Record<string, ComponentSchema>, TSlugField extends string>(path: TPath, createLocalisedCollectionFactory: (paths: ReturnType<typeof createCollectionPaths<TPath>>, locale: TLocale) => Collection<TSchema, TSlugField>): (locale: TLocale) => Collection<TSchema, TSlugField>;
20
21
  declare function createSingleton<TPath extends `/${string}/`, TLocale extends Locale, TSchema extends Record<string, ComponentSchema>>(path: TPath, createLocalisedSingletonFactory: (paths: ReturnType<typeof createSingletonPaths<TPath>>, locale: TLocale) => Singleton<TSchema>): (locale: TLocale) => Singleton<TSchema>;
21
-
22
- export { type Paths, createCollection, createCollectionPaths, createPaths, createSingleton, createSingletonPaths };
22
+ //#endregion
23
+ export { Paths, createCollection, createCollectionPaths, createPaths, createSingleton, createSingletonPaths };
24
+ //# sourceMappingURL=resources.d.ts.map
package/dist/resources.js CHANGED
@@ -1,3 +1,35 @@
1
- export { createCollection, createCollectionPaths, createPaths, createSingleton, createSingletonPaths } from './chunk-ZN3LEWB6.js';
2
- //# sourceMappingURL=resources.js.map
1
+ //#region src/resources.ts
2
+ function createPaths(path, locale) {
3
+ return {
4
+ assetPath: `/content/assets/${locale}${path}`,
5
+ downloadPath: `/content/downloads/${locale}${path}`
6
+ };
7
+ }
8
+ function createCollectionPaths(path, locale) {
9
+ return {
10
+ ...createPaths(path, locale),
11
+ contentPath: `./content/${locale}${path}*/`
12
+ };
13
+ }
14
+ function createSingletonPaths(path, locale) {
15
+ return {
16
+ ...createPaths(path, locale),
17
+ contentPath: `./content/${locale}${path}`
18
+ };
19
+ }
20
+ function createCollection(path, createLocalisedCollectionFactory) {
21
+ return function createLocalisedCollection(locale) {
22
+ const paths = createCollectionPaths(path, locale);
23
+ return createLocalisedCollectionFactory(paths, locale);
24
+ };
25
+ }
26
+ function createSingleton(path, createLocalisedSingletonFactory) {
27
+ return function createLocalisedSingleton(locale) {
28
+ const paths = createSingletonPaths(path, locale);
29
+ return createLocalisedSingletonFactory(paths, locale);
30
+ };
31
+ }
32
+
33
+ //#endregion
34
+ export { createCollection, createCollectionPaths, createPaths, createSingleton, createSingletonPaths };
3
35
  //# sourceMappingURL=resources.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"resources.js"}
1
+ {"version":3,"file":"resources.js","names":[],"sources":["../src/resources.ts"],"sourcesContent":["import type { Collection, ComponentSchema, Singleton } from \"@keystatic/core\";\n\nimport type { Locale } from \"./config\";\n\nexport function createPaths<TPath extends `/${string}/`>(path: TPath, locale: Locale) {\n\treturn {\n\t\tassetPath: `/content/assets/${locale}${path}`,\n\t\tdownloadPath: `/content/downloads/${locale}${path}`,\n\t} as const;\n}\n\nexport type Paths<TPath extends `/${string}/`> = ReturnType<typeof createPaths<TPath>>;\n\nexport function createCollectionPaths<TPath extends `/${string}/`>(path: TPath, locale: Locale) {\n\treturn {\n\t\t...createPaths(path, locale),\n\t\tcontentPath: `./content/${locale}${path}*/`,\n\t} as const;\n}\n\nexport function createSingletonPaths<TPath extends `/${string}/`>(path: TPath, locale: Locale) {\n\treturn {\n\t\t...createPaths(path, locale),\n\t\tcontentPath: `./content/${locale}${path}`,\n\t} as const;\n}\n\nexport function createCollection<\n\tTPath extends `/${string}/`,\n\tTLocale extends Locale,\n\tTSchema extends Record<string, ComponentSchema>,\n\tTSlugField extends string,\n>(\n\tpath: TPath,\n\tcreateLocalisedCollectionFactory: (\n\t\tpaths: ReturnType<typeof createCollectionPaths<TPath>>,\n\t\tlocale: TLocale,\n\t) => Collection<TSchema, TSlugField>,\n) {\n\treturn function createLocalisedCollection(locale: TLocale) {\n\t\tconst paths = createCollectionPaths(path, locale);\n\t\treturn createLocalisedCollectionFactory(paths, locale);\n\t};\n}\n\nexport function createSingleton<\n\tTPath extends `/${string}/`,\n\tTLocale extends Locale,\n\tTSchema extends Record<string, ComponentSchema>,\n>(\n\tpath: TPath,\n\tcreateLocalisedSingletonFactory: (\n\t\tpaths: ReturnType<typeof createSingletonPaths<TPath>>,\n\t\tlocale: TLocale,\n\t) => Singleton<TSchema>,\n) {\n\treturn function createLocalisedSingleton(locale: TLocale) {\n\t\tconst paths = createSingletonPaths(path, locale);\n\t\treturn createLocalisedSingletonFactory(paths, locale);\n\t};\n}\n"],"mappings":";AAIA,SAAgB,YAAyC,MAAa,QAAgB;AACrF,QAAO;EACN,WAAW,mBAAmB,SAAS;EACvC,cAAc,sBAAsB,SAAS;;;AAM/C,SAAgB,sBAAmD,MAAa,QAAgB;AAC/F,QAAO;EACN,GAAG,YAAY,MAAM;EACrB,aAAa,aAAa,SAAS,KAAK;;;AAI1C,SAAgB,qBAAkD,MAAa,QAAgB;AAC9F,QAAO;EACN,GAAG,YAAY,MAAM;EACrB,aAAa,aAAa,SAAS;;;AAIrC,SAAgB,iBAMf,MACA,kCAIC;AACD,QAAO,SAAS,0BAA0B,QAAiB;EAC1D,MAAM,QAAQ,sBAAsB,MAAM;AAC1C,SAAO,iCAAiC,OAAO;;;AAIjD,SAAgB,gBAKf,MACA,iCAIC;AACD,QAAO,SAAS,yBAAyB,QAAiB;EACzD,MAAM,QAAQ,qBAAqB,MAAM;AACzC,SAAO,gCAAgC,OAAO"}
@@ -1,6 +1,8 @@
1
- import { Locale } from './config.js';
1
+ import { Locale } from "./config.js";
2
2
 
3
+ //#region src/with-i18n-prefix.d.ts
3
4
  declare function withI18nPrefix<TLabel extends string, TLocale extends Locale>(label: TLabel, locale: TLocale): `${TLocale}:${TLabel}`;
4
5
  type WithoutI18nPrefix<T extends string, TLocale extends Locale> = T extends `${TLocale}:${infer U}` ? U : T;
5
-
6
- export { type WithoutI18nPrefix, withI18nPrefix };
6
+ //#endregion
7
+ export { WithoutI18nPrefix, withI18nPrefix };
8
+ //# sourceMappingURL=with-i18n-prefix.d.ts.map
@@ -1,3 +1,8 @@
1
- export { withI18nPrefix } from './chunk-M7J4ISS4.js';
2
- //# sourceMappingURL=with-i18n-prefix.js.map
1
+ //#region src/with-i18n-prefix.ts
2
+ function withI18nPrefix(label, locale) {
3
+ return `${locale}:${label}`;
4
+ }
5
+
6
+ //#endregion
7
+ export { withI18nPrefix };
3
8
  //# sourceMappingURL=with-i18n-prefix.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"with-i18n-prefix.js"}
1
+ {"version":3,"file":"with-i18n-prefix.js","names":[],"sources":["../src/with-i18n-prefix.ts"],"sourcesContent":["import type { Locale } from \"./config\";\n\nexport function withI18nPrefix<TLabel extends string, TLocale extends Locale>(\n\tlabel: TLabel,\n\tlocale: TLocale,\n) {\n\treturn `${locale}:${label}` as const;\n}\n\nexport type WithoutI18nPrefix<\n\tT extends string,\n\tTLocale extends Locale,\n> = T extends `${TLocale}:${infer U}` ? U : T;\n"],"mappings":";AAEA,SAAgB,eACf,OACA,QACC;AACD,QAAO,GAAG,OAAO,GAAG"}
package/license CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Austrian Centre for Digital Humanities & Cultural Heritage
3
+ Copyright (c) 2024-2025 Austrian Centre for Digital Humanities
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
6
  associated documentation files (the "Software"), to deal in the Software without restriction,
package/package.json CHANGED
@@ -1,10 +1,21 @@
1
1
  {
2
2
  "name": "@acdh-oeaw/keystatic-lib",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
+ "engines": {
7
+ "node": "22.x || 24.x"
8
+ },
9
+ "devEngines": {
10
+ "runtime": {
11
+ "name": "node",
12
+ "version": "22.x",
13
+ "onFail": "download"
14
+ }
15
+ },
6
16
  "exports": {
7
17
  ".": "./dist/index.js",
18
+ "./fields/*": "./dist/fields/*.js",
8
19
  "./preview": "./dist/preview/index.js",
9
20
  "./reader": "./dist/reader.js"
10
21
  },
@@ -12,49 +23,49 @@
12
23
  "dist"
13
24
  ],
14
25
  "sideEffects": false,
15
- "engines": {
16
- "node": ">=22",
17
- "pnpm": "9.x"
18
- },
19
26
  "dependencies": {
20
27
  "@sindresorhus/slugify": "^2.2.1",
21
28
  "@types/mdx": "^2.0.13"
22
29
  },
23
30
  "peerDependencies": {
31
+ "@keystar/ui": "0.x",
24
32
  "@keystatic/core": "0.x"
25
33
  },
26
34
  "devDependencies": {
27
35
  "@acdh-oeaw/commitlint-config": "^2.0.0",
28
- "@acdh-oeaw/eslint-config": "^2.0.5",
29
- "@acdh-oeaw/eslint-config-node": "^2.0.5",
30
- "@acdh-oeaw/eslint-config-react": "^2.0.6",
31
- "@acdh-oeaw/prettier-config": "^2.0.0",
32
- "@acdh-oeaw/tsconfig-lib": "^1.1.1",
33
- "@changesets/changelog-github": "^0.5.0",
34
- "@changesets/cli": "^2.27.10",
35
- "@commitlint/cli": "^19.6.0",
36
- "@keystatic/core": "^0.5.42",
37
- "@types/node": "^22.10.1",
38
- "@types/react": "^18.3.13",
39
- "eslint": "^9.16.0",
40
- "eslint-config-flat-gitignore": "^0.3.0",
41
- "globals": "^15.13.0",
42
- "is-ci": "^3.0.1",
43
- "lint-staged": "^15.2.10",
44
- "npm-run-all2": "^7.0.1",
45
- "prettier": "^3.4.2",
46
- "react": "^18.3.1",
47
- "simple-git-hooks": "^2.11.1",
48
- "tsup": "^8.3.5",
49
- "tsx": "^4.19.2",
50
- "typescript": "^5.7.2"
36
+ "@acdh-oeaw/eslint-config": "^2.0.9",
37
+ "@acdh-oeaw/eslint-config-node": "^2.0.9",
38
+ "@acdh-oeaw/eslint-config-react": "^2.0.13",
39
+ "@acdh-oeaw/prettier-config": "^2.0.1",
40
+ "@acdh-oeaw/tsconfig-lib": "^1.3.0",
41
+ "@changesets/changelog-github": "^0.5.1",
42
+ "@changesets/cli": "^2.29.6",
43
+ "@commitlint/cli": "^19.8.1",
44
+ "@keystar/ui": "^0.7.19",
45
+ "@keystatic/core": "^0.5.48",
46
+ "@types/node": "^22.18.0",
47
+ "@types/react": "^19.1.11",
48
+ "eslint": "^9.34.0",
49
+ "eslint-config-flat-gitignore": "^2.1.0",
50
+ "globals": "^16.3.0",
51
+ "is-in-ci": "^2.0.0",
52
+ "lint-staged": "^16.1.5",
53
+ "npm-run-all2": "^8.0.4",
54
+ "prettier": "^3.6.2",
55
+ "react": "^19.1.1",
56
+ "simple-git-hooks": "^2.13.1",
57
+ "tsdown": "^0.14.2",
58
+ "tsx": "^4.20.5",
59
+ "typescript": "^5.9.2",
60
+ "typescript-eslint": "^8.41.0",
61
+ "node": "runtime:22.x"
51
62
  },
52
63
  "commitlint": {
53
64
  "extends": "@acdh-oeaw/commitlint-config"
54
65
  },
55
66
  "lint-staged": {
56
67
  "*.ts": [
57
- "eslint --cache --fix",
68
+ "eslint --fix",
58
69
  "prettier --cache --cache-location ./.prettiercache --write"
59
70
  ],
60
71
  "*.!(ts)": "prettier --cache --cache-location ./.prettiercache --ignore-unknown --write"
@@ -66,18 +77,18 @@
66
77
  "pre-push": "pnpm run validate"
67
78
  },
68
79
  "scripts": {
69
- "build": "tsup",
80
+ "build": "tsdown",
70
81
  "changeset:add": "changeset add",
71
82
  "changeset:status": "changeset status --verbose",
72
83
  "ci:release": "changeset publish",
73
84
  "ci:version": "changeset version && prettier \"**/CHANGELOG.md\" --write",
74
85
  "format:check": "prettier . --cache --cache-location ./.prettiercache --check --ignore-path ./.gitignore",
75
86
  "format:fix": "pnpm run format:check --write",
76
- "lint:check": "eslint . --cache",
87
+ "lint:check": "eslint .",
77
88
  "lint:fix": "pnpm run lint:check --fix",
78
- "setup": "is-ci || simple-git-hooks",
89
+ "setup": "is-in-ci || simple-git-hooks",
79
90
  "test": "tsx --test --test-reporter spec",
80
91
  "types:check": "tsc --noEmit",
81
- "validate": "run-p format:check lint:check types:check test"
92
+ "validate": "run-s format:check lint:check types:check test"
82
93
  }
83
94
  }
@@ -1,8 +0,0 @@
1
- // src/create-label.ts
2
- function createLabel(label, locale) {
3
- return `${label} (${locale})`;
4
- }
5
-
6
- export { createLabel };
7
- //# sourceMappingURL=chunk-CI4JBTGG.js.map
8
- //# sourceMappingURL=chunk-CI4JBTGG.js.map