@acdh-oeaw/keystatic-lib 0.6.1 → 0.7.1

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 (50) hide show
  1. package/dist/config.d.ts +6 -5
  2. package/dist/config.js +1 -3
  3. package/dist/create-asset-options.d.ts +7 -7
  4. package/dist/create-asset-options.js +15 -2
  5. package/dist/create-asset-options.js.map +1 -1
  6. package/dist/create-component.d.ts +6 -5
  7. package/dist/create-component.js +9 -2
  8. package/dist/create-component.js.map +1 -1
  9. package/dist/create-content-field-options.d.ts +10 -10
  10. package/dist/create-content-field-options.js +19 -3
  11. package/dist/create-content-field-options.js.map +1 -1
  12. package/dist/create-label.d.ts +4 -2
  13. package/dist/create-label.js +7 -2
  14. package/dist/create-label.js.map +1 -1
  15. package/dist/fields/color-picker.d.ts +13 -0
  16. package/dist/fields/color-picker.js +53 -0
  17. package/dist/fields/color-picker.js.map +1 -0
  18. package/dist/fields/readonly.d.ts +13 -0
  19. package/dist/fields/readonly.js +47 -0
  20. package/dist/fields/readonly.js.map +1 -0
  21. package/dist/index.d.ts +8 -9
  22. package/dist/index.js +8 -8
  23. package/dist/preview/index.d.ts +7 -5
  24. package/dist/preview/index.js +19 -20
  25. package/dist/preview/index.js.map +1 -1
  26. package/dist/reader.d.ts +41 -39
  27. package/dist/reader.js +85 -86
  28. package/dist/reader.js.map +1 -1
  29. package/dist/resources.d.ts +14 -12
  30. package/dist/resources.js +34 -2
  31. package/dist/resources.js.map +1 -1
  32. package/dist/with-i18n-prefix.d.ts +5 -3
  33. package/dist/with-i18n-prefix.js +7 -2
  34. package/dist/with-i18n-prefix.js.map +1 -1
  35. package/license +1 -1
  36. package/package.json +46 -34
  37. package/dist/chunk-CI4JBTGG.js +0 -8
  38. package/dist/chunk-CI4JBTGG.js.map +0 -1
  39. package/dist/chunk-EEB35F4L.js +0 -15
  40. package/dist/chunk-EEB35F4L.js.map +0 -1
  41. package/dist/chunk-ENT7N2ZS.js +0 -16
  42. package/dist/chunk-ENT7N2ZS.js.map +0 -1
  43. package/dist/chunk-M7J4ISS4.js +0 -8
  44. package/dist/chunk-M7J4ISS4.js.map +0 -1
  45. package/dist/chunk-ZN3LEWB6.js +0 -35
  46. package/dist/chunk-ZN3LEWB6.js.map +0 -1
  47. package/dist/chunk-ZWZCXCMD.js +0 -10
  48. package/dist/chunk-ZWZCXCMD.js.map +0 -1
  49. package/dist/config.js.map +0 -1
  50. package/dist/index.js.map +0 -1
package/dist/config.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ //#region src/config.d.ts
1
2
  /**
2
3
  * Provide supported locales by augmenting the interface:
3
4
  *
@@ -7,10 +8,10 @@
7
8
  * }
8
9
  * ```
9
10
  */
10
- interface KeystaticConfig {
11
- }
11
+ interface KeystaticConfig {}
12
12
  type Locale = KeystaticConfig extends {
13
- locales: string;
13
+ locales: string;
14
14
  } ? KeystaticConfig["locales"] : string;
15
-
16
- export type { KeystaticConfig, Locale };
15
+ //#endregion
16
+ export { KeystaticConfig, Locale };
17
+ //# sourceMappingURL=config.d.ts.map
package/dist/config.js CHANGED
@@ -1,3 +1 @@
1
-
2
- //# sourceMappingURL=config.js.map
3
- //# sourceMappingURL=config.js.map
1
+ export { };
@@ -1,11 +1,11 @@
1
- import { Paths } from './resources.js';
2
- import '@keystatic/core';
3
- import './config.js';
1
+ import { Paths } from "./resources.js";
4
2
 
3
+ //#region src/create-asset-options.d.ts
5
4
  declare function createAssetOptions<TPath extends `/${string}/`>(path: Paths<TPath>["assetPath"] | Paths<TPath>["downloadPath"]): {
6
- directory: `./public/assets/content/assets/${string}${TPath}` | `./public/assets/content/downloads/${string}${TPath}`;
7
- publicPath: `/assets/content/assets/${string}${TPath}` | `/assets/content/downloads/${string}${TPath}`;
8
- transformFilename(originalFilename: string): string;
5
+ directory: `./public/assets/content/assets/${string}${TPath}` | `./public/assets/content/downloads/${string}${TPath}`;
6
+ publicPath: `/assets/content/assets/${string}${TPath}` | `/assets/content/downloads/${string}${TPath}`;
7
+ transformFilename(originalFilename: string): string;
9
8
  };
10
-
9
+ //#endregion
11
10
  export { createAssetOptions };
11
+ //# sourceMappingURL=create-asset-options.d.ts.map
@@ -1,3 +1,16 @@
1
- export { createAssetOptions } from './chunk-ENT7N2ZS.js';
2
- //# sourceMappingURL=create-asset-options.js.map
1
+ import slugify from "@sindresorhus/slugify";
2
+
3
+ //#region src/create-asset-options.ts
4
+ function createAssetOptions(path) {
5
+ return {
6
+ directory: `./public/assets${path}`,
7
+ publicPath: `/assets${path}`,
8
+ transformFilename(originalFilename) {
9
+ return slugify(originalFilename, { preserveCharacters: ["."] });
10
+ }
11
+ };
12
+ }
13
+
14
+ //#endregion
15
+ export { createAssetOptions };
3
16
  //# sourceMappingURL=create-asset-options.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"create-asset-options.js"}
1
+ {"version":3,"file":"create-asset-options.js","names":[],"sources":["../src/create-asset-options.ts"],"sourcesContent":["import slugify from \"@sindresorhus/slugify\";\n\nimport type { Paths } from \"./resources\";\n\nexport function createAssetOptions<TPath extends `/${string}/`>(\n\tpath: Paths<TPath>[\"assetPath\"] | Paths<TPath>[\"downloadPath\"],\n) {\n\treturn {\n\t\tdirectory: `./public/assets${path}` as const,\n\t\tpublicPath: `/assets${path}` as const,\n\t\ttransformFilename(originalFilename: string) {\n\t\t\treturn slugify(originalFilename, { preserveCharacters: [\".\"] });\n\t\t},\n\t};\n}\n"],"mappings":";;;AAIA,SAAgB,mBACf,MACC;AACD,QAAO;EACN,WAAW,kBAAkB;EAC7B,YAAY,UAAU;EACtB,kBAAkB,kBAA0B;AAC3C,UAAO,QAAQ,kBAAkB,EAAE,oBAAoB,CAAC"}
@@ -1,8 +1,9 @@
1
- import { ContentComponent } from '@keystatic/core/content-components';
2
- import { Locale } from './config.js';
3
- import { Paths } from './resources.js';
4
- import '@keystatic/core';
1
+ import { Locale } from "./config.js";
2
+ import { Paths } from "./resources.js";
3
+ import { ContentComponent } from "@keystatic/core/content-components";
5
4
 
5
+ //#region src/create-component.d.ts
6
6
  declare function createComponent<TPath extends `/${string}/`, TLocale extends Locale, TComponents extends Record<string, ContentComponent>>(createComponentFactory: (paths: Paths<TPath>, locale: TLocale) => TComponents): (paths: Paths<TPath>, locale: TLocale) => TComponents;
7
-
7
+ //#endregion
8
8
  export { createComponent };
9
+ //# sourceMappingURL=create-component.d.ts.map
@@ -1,3 +1,10 @@
1
- export { createComponent } from './chunk-ZWZCXCMD.js';
2
- //# sourceMappingURL=create-component.js.map
1
+ //#region src/create-component.ts
2
+ function createComponent(createComponentFactory) {
3
+ return function createComponent$1(paths, locale) {
4
+ return createComponentFactory(paths, locale);
5
+ };
6
+ }
7
+
8
+ //#endregion
9
+ export { createComponent };
3
10
  //# sourceMappingURL=create-component.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"create-component.js"}
1
+ {"version":3,"file":"create-component.js","names":["createComponent"],"sources":["../src/create-component.ts"],"sourcesContent":["import type { ContentComponent } from \"@keystatic/core/content-components\";\n\nimport type { Locale } from \"./config\";\nimport type { Paths } from \"./resources\";\n\nexport function createComponent<\n\tTPath extends `/${string}/`,\n\tTLocale extends Locale,\n\tTComponents extends Record<string, ContentComponent>,\n>(createComponentFactory: (paths: Paths<TPath>, locale: TLocale) => TComponents) {\n\treturn function createComponent(paths: Paths<TPath>, locale: TLocale) {\n\t\treturn createComponentFactory(paths, locale);\n\t};\n}\n"],"mappings":";AAKA,SAAgB,gBAId,wBAA+E;AAChF,QAAO,SAASA,kBAAgB,OAAqB,QAAiB;AACrE,SAAO,uBAAuB,OAAO"}
@@ -1,14 +1,14 @@
1
- import { Paths } from './resources.js';
2
- import '@keystatic/core';
3
- import './config.js';
1
+ import { Paths } from "./resources.js";
4
2
 
3
+ //#region src/create-content-field-options.d.ts
5
4
  declare function createContentFieldOptions<TPath extends `/${string}/`>(paths: Paths<TPath>): {
6
- heading: readonly [2, 3, 4, 5];
7
- image: {
8
- directory: `./public/assets/content/assets/${string}${TPath}` | `./public/assets/content/downloads/${string}${TPath}`;
9
- publicPath: `/assets/content/assets/${string}${TPath}` | `/assets/content/downloads/${string}${TPath}`;
10
- transformFilename(originalFilename: string): string;
11
- };
5
+ heading: readonly [2, 3, 4, 5];
6
+ image: {
7
+ directory: `./public/assets/content/assets/${string}${TPath}` | `./public/assets/content/downloads/${string}${TPath}`;
8
+ publicPath: `/assets/content/assets/${string}${TPath}` | `/assets/content/downloads/${string}${TPath}`;
9
+ transformFilename(originalFilename: string): string;
10
+ };
12
11
  };
13
-
12
+ //#endregion
14
13
  export { createContentFieldOptions };
14
+ //# sourceMappingURL=create-content-field-options.d.ts.map
@@ -1,4 +1,20 @@
1
- export { createContentFieldOptions } from './chunk-EEB35F4L.js';
2
- import './chunk-ENT7N2ZS.js';
3
- //# sourceMappingURL=create-content-field-options.js.map
1
+ import { createAssetOptions } from "./create-asset-options.js";
2
+
3
+ //#region src/create-content-field-options.ts
4
+ function createContentFieldOptions(paths) {
5
+ const assetPaths = createAssetOptions(paths.assetPath);
6
+ const headingLevels = [
7
+ 2,
8
+ 3,
9
+ 4,
10
+ 5
11
+ ];
12
+ return {
13
+ heading: headingLevels,
14
+ image: assetPaths
15
+ };
16
+ }
17
+
18
+ //#endregion
19
+ export { createContentFieldOptions };
4
20
  //# sourceMappingURL=create-content-field-options.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"create-content-field-options.js"}
1
+ {"version":3,"file":"create-content-field-options.js","names":[],"sources":["../src/create-content-field-options.ts"],"sourcesContent":["import { createAssetOptions } from \"./create-asset-options\";\nimport type { Paths } from \"./resources\";\n\nexport function createContentFieldOptions<TPath extends `/${string}/`>(paths: Paths<TPath>) {\n\tconst assetPaths = createAssetOptions(paths.assetPath);\n\tconst headingLevels = [2, 3, 4, 5] as const;\n\n\treturn {\n\t\theading: headingLevels,\n\t\timage: assetPaths,\n\t};\n}\n"],"mappings":";;;AAGA,SAAgB,0BAAuD,OAAqB;CAC3F,MAAM,aAAa,mBAAmB,MAAM;CAC5C,MAAM,gBAAgB;EAAC;EAAG;EAAG;EAAG;;AAEhC,QAAO;EACN,SAAS;EACT,OAAO"}
@@ -1,5 +1,7 @@
1
- import { Locale } from './config.js';
1
+ import { Locale } from "./config.js";
2
2
 
3
+ //#region src/create-label.d.ts
3
4
  declare function createLabel(label: string, locale: Locale): string;
4
-
5
+ //#endregion
5
6
  export { createLabel };
7
+ //# sourceMappingURL=create-label.d.ts.map
@@ -1,3 +1,8 @@
1
- export { createLabel } from './chunk-CI4JBTGG.js';
2
- //# sourceMappingURL=create-label.js.map
1
+ //#region src/create-label.ts
2
+ function createLabel(label, locale) {
3
+ return `${label} (${locale})`;
4
+ }
5
+
6
+ //#endregion
7
+ export { createLabel };
3
8
  //# sourceMappingURL=create-label.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"create-label.js"}
1
+ {"version":3,"file":"create-label.js","names":[],"sources":["../src/create-label.ts"],"sourcesContent":["import type { Locale } from \"./config\";\n\nexport function createLabel(label: string, locale: Locale) {\n\treturn `${label} (${locale})`;\n}\n"],"mappings":";AAEA,SAAgB,YAAY,OAAe,QAAgB;AAC1D,QAAO,GAAG,MAAM,IAAI,OAAO"}
@@ -0,0 +1,13 @@
1
+ import { BasicFormField } from "@keystatic/core";
2
+
3
+ //#region src/fields/color-picker.d.ts
4
+ interface ColorPickerFieldProps {
5
+ defaultValue?: string;
6
+ description?: string;
7
+ label: string;
8
+ }
9
+ declare function ColorPickerField(props: ColorPickerFieldProps): BasicFormField<string>;
10
+ declare const colorPicker: typeof ColorPickerField;
11
+ //#endregion
12
+ export { colorPicker };
13
+ //# sourceMappingURL=color-picker.d.ts.map
@@ -0,0 +1,53 @@
1
+ import { TextField } from "@keystar/ui/text-field";
2
+ import { jsx } from "react/jsx-runtime";
3
+
4
+ //#region src/fields/color-picker.tsx
5
+ function ColorPickerField(props) {
6
+ const { defaultValue, description, label } = props;
7
+ return {
8
+ kind: "form",
9
+ label,
10
+ Input(props$1) {
11
+ /**
12
+ * For simple usecases, the browser built-in color input should work.
13
+ *
14
+ * For a better color-picker, consider using
15
+ * @see https://react-spectrum.adobe.com/react-aria/ColorPicker.html
16
+ */
17
+ return /* @__PURE__ */ jsx(TextField, {
18
+ ...props$1,
19
+ description,
20
+ label,
21
+ type: "color"
22
+ });
23
+ },
24
+ defaultValue() {
25
+ return defaultValue ?? "";
26
+ },
27
+ parse(value) {
28
+ return parse(value);
29
+ },
30
+ serialize(value) {
31
+ return { value: value === "" ? void 0 : value };
32
+ },
33
+ validate(value) {
34
+ return validate(value);
35
+ },
36
+ reader: { parse(value) {
37
+ return validate(parse(value));
38
+ } }
39
+ };
40
+ }
41
+ function parse(value) {
42
+ if (value === void 0) return "";
43
+ if (typeof value !== "string") throw new Error("Must be a string");
44
+ return value;
45
+ }
46
+ function validate(value) {
47
+ return value;
48
+ }
49
+ const colorPicker = ColorPickerField;
50
+
51
+ //#endregion
52
+ export { colorPicker };
53
+ //# sourceMappingURL=color-picker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color-picker.js","names":["props"],"sources":["../../src/fields/color-picker.tsx"],"sourcesContent":["import { TextField } from \"@keystar/ui/text-field\";\nimport type { BasicFormField, FormFieldStoredValue } from \"@keystatic/core\";\n\ninterface ColorPickerFieldProps {\n\tdefaultValue?: string;\n\tdescription?: string;\n\tlabel: string;\n}\n\nfunction ColorPickerField(props: ColorPickerFieldProps): BasicFormField<string> {\n\tconst { defaultValue, description, label } = props;\n\n\treturn {\n\t\tkind: \"form\",\n\t\tlabel,\n\t\tInput(props) {\n\t\t\t/**\n\t\t\t * For simple usecases, the browser built-in color input should work.\n\t\t\t *\n\t\t\t * For a better color-picker, consider using\n\t\t\t * @see https://react-spectrum.adobe.com/react-aria/ColorPicker.html\n\t\t\t */\n\t\t\treturn <TextField {...props} description={description} label={label} type=\"color\" />;\n\t\t},\n\t\tdefaultValue() {\n\t\t\treturn defaultValue ?? \"\";\n\t\t},\n\t\tparse(value) {\n\t\t\treturn parse(value);\n\t\t},\n\t\tserialize(value) {\n\t\t\treturn { value: value === \"\" ? undefined : value };\n\t\t},\n\t\tvalidate(value) {\n\t\t\treturn validate(value);\n\t\t},\n\t\treader: {\n\t\t\tparse(value) {\n\t\t\t\treturn validate(parse(value));\n\t\t\t},\n\t\t},\n\t};\n}\n\nfunction parse(value: FormFieldStoredValue): string {\n\tif (value === undefined) {\n\t\treturn \"\";\n\t}\n\tif (typeof value !== \"string\") {\n\t\tthrow new Error(\"Must be a string\");\n\t}\n\treturn value;\n}\n\nfunction validate(value: string): string {\n\treturn value;\n}\n\nexport const colorPicker = ColorPickerField;\n"],"mappings":";;;;AASA,SAAS,iBAAiB,OAAsD;CAC/E,MAAM,EAAE,cAAc,aAAa,UAAU;AAE7C,QAAO;EACN,MAAM;EACN;EACA,MAAM,SAAO;;;;;;;AAOZ,UAAO,oBAAC;IAAU,GAAIA;IAAoB;IAAoB;IAAO,MAAK;;;EAE3E,eAAe;AACd,UAAO,gBAAgB;;EAExB,MAAM,OAAO;AACZ,UAAO,MAAM;;EAEd,UAAU,OAAO;AAChB,UAAO,EAAE,OAAO,UAAU,KAAK,SAAY;;EAE5C,SAAS,OAAO;AACf,UAAO,SAAS;;EAEjB,QAAQ,EACP,MAAM,OAAO;AACZ,UAAO,SAAS,MAAM;;;;AAM1B,SAAS,MAAM,OAAqC;AACnD,KAAI,UAAU,OACb,QAAO;AAER,KAAI,OAAO,UAAU,SACpB,OAAM,IAAI,MAAM;AAEjB,QAAO;;AAGR,SAAS,SAAS,OAAuB;AACxC,QAAO;;AAGR,MAAa,cAAc"}
@@ -0,0 +1,13 @@
1
+ import { BasicFormField } from "@keystatic/core";
2
+
3
+ //#region src/fields/readonly.d.ts
4
+ interface ReadonlyFieldProps {
5
+ defaultValue?: string;
6
+ description?: string;
7
+ label: string;
8
+ }
9
+ declare function ReadonlyField(props: ReadonlyFieldProps): BasicFormField<string>;
10
+ declare const readonly: typeof ReadonlyField;
11
+ //#endregion
12
+ export { readonly };
13
+ //# sourceMappingURL=readonly.d.ts.map
@@ -0,0 +1,47 @@
1
+ import { TextField } from "@keystar/ui/text-field";
2
+ import { jsx } from "react/jsx-runtime";
3
+
4
+ //#region src/fields/readonly.tsx
5
+ function ReadonlyField(props) {
6
+ const { defaultValue, description, label } = props;
7
+ return {
8
+ kind: "form",
9
+ label,
10
+ Input(props$1) {
11
+ return /* @__PURE__ */ jsx(TextField, {
12
+ ...props$1,
13
+ description,
14
+ isReadOnly: true,
15
+ label
16
+ });
17
+ },
18
+ defaultValue() {
19
+ return defaultValue ?? "";
20
+ },
21
+ parse(value) {
22
+ return parse(value);
23
+ },
24
+ serialize(value) {
25
+ return { value: value === "" ? void 0 : value };
26
+ },
27
+ validate(value) {
28
+ return validate(value);
29
+ },
30
+ reader: { parse(value) {
31
+ return validate(parse(value));
32
+ } }
33
+ };
34
+ }
35
+ function parse(value) {
36
+ if (value === void 0) return "";
37
+ if (typeof value !== "string") throw new Error("Must be a string");
38
+ return value;
39
+ }
40
+ function validate(value) {
41
+ return value;
42
+ }
43
+ const readonly = ReadonlyField;
44
+
45
+ //#endregion
46
+ export { readonly };
47
+ //# sourceMappingURL=readonly.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readonly.js","names":["props"],"sources":["../../src/fields/readonly.tsx"],"sourcesContent":["import { TextField } from \"@keystar/ui/text-field\";\nimport type { BasicFormField, FormFieldStoredValue } from \"@keystatic/core\";\n\ninterface ReadonlyFieldProps {\n\tdefaultValue?: string;\n\tdescription?: string;\n\tlabel: string;\n}\n\nfunction ReadonlyField(props: ReadonlyFieldProps): BasicFormField<string> {\n\tconst { defaultValue, description, label } = props;\n\n\treturn {\n\t\tkind: \"form\",\n\t\tlabel,\n\t\tInput(props) {\n\t\t\treturn <TextField {...props} description={description} isReadOnly={true} label={label} />;\n\t\t},\n\t\tdefaultValue() {\n\t\t\treturn defaultValue ?? \"\";\n\t\t},\n\t\tparse(value) {\n\t\t\treturn parse(value);\n\t\t},\n\t\tserialize(value) {\n\t\t\treturn { value: value === \"\" ? undefined : value };\n\t\t},\n\t\tvalidate(value) {\n\t\t\treturn validate(value);\n\t\t},\n\t\treader: {\n\t\t\tparse(value) {\n\t\t\t\treturn validate(parse(value));\n\t\t\t},\n\t\t},\n\t};\n}\n\nfunction parse(value: FormFieldStoredValue): string {\n\tif (value === undefined) {\n\t\treturn \"\";\n\t}\n\tif (typeof value !== \"string\") {\n\t\tthrow new Error(\"Must be a string\");\n\t}\n\treturn value;\n}\n\nfunction validate(value: string): string {\n\treturn value;\n}\n\nexport const readonly = ReadonlyField;\n"],"mappings":";;;;AASA,SAAS,cAAc,OAAmD;CACzE,MAAM,EAAE,cAAc,aAAa,UAAU;AAE7C,QAAO;EACN,MAAM;EACN;EACA,MAAM,SAAO;AACZ,UAAO,oBAAC;IAAU,GAAIA;IAAoB;IAAa,YAAY;IAAa;;;EAEjF,eAAe;AACd,UAAO,gBAAgB;;EAExB,MAAM,OAAO;AACZ,UAAO,MAAM;;EAEd,UAAU,OAAO;AAChB,UAAO,EAAE,OAAO,UAAU,KAAK,SAAY;;EAE5C,SAAS,OAAO;AACf,UAAO,SAAS;;EAEjB,QAAQ,EACP,MAAM,OAAO;AACZ,UAAO,SAAS,MAAM;;;;AAM1B,SAAS,MAAM,OAAqC;AACnD,KAAI,UAAU,OACb,QAAO;AAER,KAAI,OAAO,UAAU,SACpB,OAAM,IAAI,MAAM;AAEjB,QAAO;;AAGR,SAAS,SAAS,OAAuB;AACxC,QAAO;;AAGR,MAAa,WAAW"}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- export { KeystaticConfig } from './config.js';
2
- export { createAssetOptions } from './create-asset-options.js';
3
- export { createComponent } from './create-component.js';
4
- export { createContentFieldOptions } from './create-content-field-options.js';
5
- export { createLabel } from './create-label.js';
6
- export { Paths, createCollection, createCollectionPaths, createSingleton, createSingletonPaths } from './resources.js';
7
- export { WithoutI18nPrefix, withI18nPrefix } from './with-i18n-prefix.js';
8
- import '@keystatic/core/content-components';
9
- import '@keystatic/core';
1
+ import { KeystaticConfig } from "./config.js";
2
+ import { Paths, createCollection, createCollectionPaths, createSingleton, createSingletonPaths } from "./resources.js";
3
+ import { createAssetOptions } from "./create-asset-options.js";
4
+ import { createComponent } from "./create-component.js";
5
+ import { createContentFieldOptions } from "./create-content-field-options.js";
6
+ import { createLabel } from "./create-label.js";
7
+ import { WithoutI18nPrefix, withI18nPrefix } from "./with-i18n-prefix.js";
8
+ export { type KeystaticConfig, type Paths, type WithoutI18nPrefix, createAssetOptions, createCollection, createCollectionPaths, createComponent, createContentFieldOptions, createLabel, createSingleton, createSingletonPaths, withI18nPrefix };
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- export { createComponent } from './chunk-ZWZCXCMD.js';
2
- export { createContentFieldOptions } from './chunk-EEB35F4L.js';
3
- export { createAssetOptions } from './chunk-ENT7N2ZS.js';
4
- export { createLabel } from './chunk-CI4JBTGG.js';
5
- export { withI18nPrefix } from './chunk-M7J4ISS4.js';
6
- export { createCollection, createCollectionPaths, createSingleton, createSingletonPaths } from './chunk-ZN3LEWB6.js';
7
- //# sourceMappingURL=index.js.map
8
- //# sourceMappingURL=index.js.map
1
+ import { createAssetOptions } from "./create-asset-options.js";
2
+ import { createComponent } from "./create-component.js";
3
+ import { createContentFieldOptions } from "./create-content-field-options.js";
4
+ import { createLabel } from "./create-label.js";
5
+ import { createCollection, createCollectionPaths, createSingleton, createSingletonPaths } from "./resources.js";
6
+ import { withI18nPrefix } from "./with-i18n-prefix.js";
7
+
8
+ export { createAssetOptions, createCollection, createCollectionPaths, createComponent, createContentFieldOptions, createLabel, createSingleton, createSingletonPaths, withI18nPrefix };
@@ -1,9 +1,11 @@
1
+ //#region src/preview/index.d.ts
1
2
  interface UseObjectUrlParams {
2
- data: Uint8Array;
3
- extension: string;
4
- filename: string;
3
+ data: Uint8Array;
4
+ extension: string;
5
+ filename: string;
5
6
  }
6
7
  /** @see https://github.com/Thinkmill/keystatic/blob/main/packages/keystatic/src/form/fields/image/ui.tsx#L48-L63 */
7
8
  declare function useObjectUrl(params: UseObjectUrlParams | null): string | null;
8
-
9
- export { type UseObjectUrlParams, useObjectUrl };
9
+ //#endregion
10
+ export { UseObjectUrlParams, useObjectUrl };
11
+ //# sourceMappingURL=index.d.ts.map
@@ -1,26 +1,25 @@
1
- import { useState, useEffect } from 'react';
1
+ import { useEffect, useState } from "react";
2
2
 
3
- // src/preview/index.ts
3
+ //#region src/preview/index.ts
4
+ /** @see https://github.com/Thinkmill/keystatic/blob/main/packages/keystatic/src/form/fields/image/ui.tsx#L48-L63 */
4
5
  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;
6
+ const data = params?.data;
7
+ const contentType = params?.extension === "svg" ? "image/svg+xml" : void 0;
8
+ const [url, setUrl] = useState(null);
9
+ useEffect(() => {
10
+ if (data == null) {
11
+ setUrl(null);
12
+ return void 0;
13
+ }
14
+ const url$1 = URL.createObjectURL(new Blob([data], contentType ? { type: contentType } : void 0));
15
+ setUrl(url$1);
16
+ return () => {
17
+ URL.revokeObjectURL(url$1);
18
+ };
19
+ }, [contentType, data]);
20
+ return url;
22
21
  }
23
22
 
23
+ //#endregion
24
24
  export { useObjectUrl };
25
- //# sourceMappingURL=index.js.map
26
25
  //# 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,UAAU,SAAwB;AAE9C,iBAAgB;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,44 +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
- md5: string;
38
- 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;
39
- compile: (code: string) => Promise<TMdxContent>;
40
- }>;
41
- };
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
+ };
42
43
  };
43
-
44
+ //#endregion
44
45
  export { createReader, createReaders };
46
+ //# sourceMappingURL=reader.d.ts.map
package/dist/reader.js CHANGED
@@ -1,94 +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
- const md5 = createHash("md5").update(serialize(data)).digest("hex");
73
- return {
74
- singleton: name,
75
- md5,
76
- data,
77
- compile
78
- };
79
- }
80
- return {
81
- baseUrl,
82
- compile,
83
- read
84
- };
85
- }
86
- return {
87
- createCollectionResource,
88
- createSingletonResource
89
- };
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
+ };
90
89
  }
91
90
 
91
+ //#endregion
92
92
  export { createReader, createReaders };
93
- //# sourceMappingURL=reader.js.map
94
93
  //# sourceMappingURL=reader.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/reader.ts"],"names":["createLocalReader"],"mappings":";;;;;;;;;AAgBO,SAAS,YAAA,CAIf,QACA,qBACC,EAAA;AACD,EAAA,MAAM,eAAe,qBAAwB,IAAA;AAE7C,EAAA,IAAI,gBAAgB,IAAM,EAAA;AACzB,IAAO,OAAA,kBAAA,CAAmB,QAAQ,YAAY,CAAA;AAAA;AAG/C,EAAA,OAAOA,cAAkB,CAAA,OAAA,CAAQ,GAAI,EAAA,EAAG,MAAM,CAAA;AAC/C;AAEO,SAAS,aAAA,CAMf,QACA,aACC,EAAA;AACD,EAAS,SAAA,wBAAA,CAEP,MAAa,MAAiB,EAAA;AAC/B,IAAM,MAAA,MAAA,GAAS,aAAa,MAAM,CAAA;AAClC,IAAM,MAAA,cAAA,GAAiB,cAAe,CAAA,IAAA,EAAM,MAAM,CAAA;AAElD,IAAM,MAAA,gBAAA,GAAmB,MAAO,CAAA,WAAA,CAAY,cAAc,CAAA;AAC1D,IAAA,MAAM,gBAAmB,GAAA,MAAA,CAAO,MAAO,CAAA,WAAA,GAAc,cAAc,CAAA;AAEnE,IAAA,MAAA,CAAO,kBAAkB,IAAI,CAAA;AAE7B,IAAA,SAAS,QAAQ,EAAY,EAAA;AAC5B,MAAO,OAAA,aAAA,CAAc,IAAK,CAAA,OAAA,CAAQ,GAAI,EAAA,EAAG,gBAAkB,CAAA,IAAA,CAAM,OAAQ,CAAA,KAAA,EAAO,EAAE,CAAC,CAAC,CAAA;AAAA;AAGrF,IAAe,eAAA,OAAA,CAAQ,IAAY,IAAc,EAAA;AAChD,MAAA,OAAO,aAAc,CAAA,IAAA,EAAM,MAAQ,EAAA,OAAA,CAAQ,EAAE,CAAC,CAAA;AAAA;AAG/C,IAAA,SAAS,IAAO,GAAA;AACf,MAAA,OAAO,iBAAiB,IAAK,EAAA;AAAA;AAG9B,IAAA,eAAe,KAAK,EAAY,EAAA;AAC/B,MAAM,MAAA,IAAA,GAAO,MAAM,gBAAiB,CAAA,WAAA,CAAY,IAAI,EAAE,kBAAA,EAAoB,MAAM,CAAA;AAChF,MAAM,MAAA,GAAA,GAAM,UAAW,CAAA,KAAK,CAAE,CAAA,MAAA,CAAO,UAAU,IAAI,CAAC,CAAE,CAAA,MAAA,CAAO,KAAK,CAAA;AAElE,MAAO,OAAA;AAAA,QACN,UAAY,EAAA,IAAA;AAAA,QACZ,EAAA;AAAA,QACA,GAAA;AAAA,QACA,IAAA;AAAA,QACA,QAAQ,IAAc,EAAA;AACrB,UAAO,OAAA,OAAA,CAAQ,IAAI,IAAI,CAAA;AAAA;AACxB,OACD;AAAA;AAGD,IAAA,eAAe,GAAM,GAAA;AACpB,MAAM,MAAA,GAAA,GAAM,MAAM,IAAK,EAAA;AAEvB,MAAA,OAAO,OAAQ,CAAA,GAAA,CAAI,GAAI,CAAA,GAAA,CAAI,IAAI,CAAC,CAAA;AAAA;AAGjC,IAAO,OAAA;AAAA,MACN,GAAA;AAAA,MACA,OAAA;AAAA,MACA,OAAA;AAAA,MACA,IAAA;AAAA,MACA;AAAA,KACD;AAAA;AAGD,EAAS,SAAA,uBAAA,CAEP,MAAa,MAAiB,EAAA;AAC/B,IAAM,MAAA,MAAA,GAAS,aAAa,MAAM,CAAA;AAClC,IAAM,MAAA,QAAA,GAAW,cAAe,CAAA,IAAA,EAAM,MAAM,CAAA;AAE5C,IAAM,MAAA,eAAA,GAAkB,MAAO,CAAA,UAAA,CAAW,QAAQ,CAAA;AAClD,IAAA,MAAM,eAAkB,GAAA,MAAA,CAAO,MAAO,CAAA,UAAA,GAAa,QAAQ,CAAA;AAE3D,IAAA,MAAA,CAAO,iBAAiB,IAAI,CAAA;AAE5B,IAAA,SAAS,OAAU,GAAA;AAClB,MAAA,OAAO,cAAc,IAAK,CAAA,OAAA,CAAQ,KAAO,EAAA,eAAA,CAAiB,IAAK,CAAC,CAAA;AAAA;AAGjE,IAAA,eAAe,QAAQ,IAAc,EAAA;AACpC,MAAA,OAAO,aAAc,CAAA,IAAA,EAAM,MAAQ,EAAA,OAAA,EAAS,CAAA;AAAA;AAG7C,IAAA,eAAe,IAAO,GAAA;AACrB,MAAA,MAAM,OAAO,MAAM,eAAA,CAAgB,YAAY,EAAE,kBAAA,EAAoB,MAAM,CAAA;AAC3E,MAAM,MAAA,GAAA,GAAM,UAAW,CAAA,KAAK,CAAE,CAAA,MAAA,CAAO,UAAU,IAAI,CAAC,CAAE,CAAA,MAAA,CAAO,KAAK,CAAA;AAElE,MAAO,OAAA;AAAA,QACN,SAAW,EAAA,IAAA;AAAA,QACX,GAAA;AAAA,QACA,IAAA;AAAA,QACA;AAAA,OACD;AAAA;AAGD,IAAO,OAAA;AAAA,MACN,OAAA;AAAA,MACA,OAAA;AAAA,MACA;AAAA,KACD;AAAA;AAGD,EAAO,OAAA;AAAA,IACN,wBAAA;AAAA,IACA;AAAA,GACD;AACD","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\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"]}
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.1",
3
+ "version": "0.7.1",
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,50 @@
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": {
24
- "@keystatic/core": "0.x"
31
+ "@keystar/ui": "0.x",
32
+ "@keystatic/core": "0.x",
33
+ "react": "19.x"
25
34
  },
26
35
  "devDependencies": {
27
36
  "@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"
37
+ "@acdh-oeaw/eslint-config": "^2.0.9",
38
+ "@acdh-oeaw/eslint-config-node": "^2.0.9",
39
+ "@acdh-oeaw/eslint-config-react": "^2.0.13",
40
+ "@acdh-oeaw/prettier-config": "^2.0.1",
41
+ "@acdh-oeaw/tsconfig-lib": "^1.3.0",
42
+ "@changesets/changelog-github": "^0.5.1",
43
+ "@changesets/cli": "^2.29.6",
44
+ "@commitlint/cli": "^19.8.1",
45
+ "@keystar/ui": "^0.7.19",
46
+ "@keystatic/core": "^0.5.48",
47
+ "@types/node": "^22.18.0",
48
+ "@types/react": "^19.1.11",
49
+ "eslint": "^9.34.0",
50
+ "eslint-config-flat-gitignore": "^2.1.0",
51
+ "globals": "^16.3.0",
52
+ "is-in-ci": "^2.0.0",
53
+ "lint-staged": "^16.1.5",
54
+ "npm-run-all2": "^8.0.4",
55
+ "prettier": "^3.6.2",
56
+ "react": "^19.1.1",
57
+ "simple-git-hooks": "^2.13.1",
58
+ "tsdown": "^0.14.2",
59
+ "tsx": "^4.20.5",
60
+ "typescript": "^5.9.2",
61
+ "typescript-eslint": "^8.41.0",
62
+ "node": "runtime:22.x"
51
63
  },
52
64
  "commitlint": {
53
65
  "extends": "@acdh-oeaw/commitlint-config"
54
66
  },
55
67
  "lint-staged": {
56
68
  "*.ts": [
57
- "eslint --cache --fix",
69
+ "eslint --fix",
58
70
  "prettier --cache --cache-location ./.prettiercache --write"
59
71
  ],
60
72
  "*.!(ts)": "prettier --cache --cache-location ./.prettiercache --ignore-unknown --write"
@@ -66,18 +78,18 @@
66
78
  "pre-push": "pnpm run validate"
67
79
  },
68
80
  "scripts": {
69
- "build": "tsup",
81
+ "build": "tsdown",
70
82
  "changeset:add": "changeset add",
71
83
  "changeset:status": "changeset status --verbose",
72
84
  "ci:release": "changeset publish",
73
85
  "ci:version": "changeset version && prettier \"**/CHANGELOG.md\" --write",
74
86
  "format:check": "prettier . --cache --cache-location ./.prettiercache --check --ignore-path ./.gitignore",
75
87
  "format:fix": "pnpm run format:check --write",
76
- "lint:check": "eslint . --cache",
88
+ "lint:check": "eslint .",
77
89
  "lint:fix": "pnpm run lint:check --fix",
78
- "setup": "is-ci || simple-git-hooks",
90
+ "setup": "is-in-ci || simple-git-hooks",
79
91
  "test": "tsx --test --test-reporter spec",
80
92
  "types:check": "tsc --noEmit",
81
- "validate": "run-p format:check lint:check types:check test"
93
+ "validate": "run-s format:check lint:check types:check test"
82
94
  }
83
95
  }
@@ -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
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/create-label.ts"],"names":[],"mappings":";AAEO,SAAS,WAAA,CAAY,OAAe,MAAgB,EAAA;AAC1D,EAAO,OAAA,CAAA,EAAG,KAAK,CAAA,EAAA,EAAK,MAAM,CAAA,CAAA,CAAA;AAC3B","file":"chunk-CI4JBTGG.js","sourcesContent":["import type { Locale } from \"./config\";\n\nexport function createLabel(label: string, locale: Locale) {\n\treturn `${label} (${locale})`;\n}\n"]}
@@ -1,15 +0,0 @@
1
- import { createAssetOptions } from './chunk-ENT7N2ZS.js';
2
-
3
- // src/create-content-field-options.ts
4
- function createContentFieldOptions(paths) {
5
- const assetPaths = createAssetOptions(paths.assetPath);
6
- const headingLevels = [2, 3, 4, 5];
7
- return {
8
- heading: headingLevels,
9
- image: assetPaths
10
- };
11
- }
12
-
13
- export { createContentFieldOptions };
14
- //# sourceMappingURL=chunk-EEB35F4L.js.map
15
- //# sourceMappingURL=chunk-EEB35F4L.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/create-content-field-options.ts"],"names":[],"mappings":";;;AAGO,SAAS,0BAAuD,KAAqB,EAAA;AAC3F,EAAM,MAAA,UAAA,GAAa,kBAAmB,CAAA,KAAA,CAAM,SAAS,CAAA;AACrD,EAAA,MAAM,aAAgB,GAAA,CAAC,CAAG,EAAA,CAAA,EAAG,GAAG,CAAC,CAAA;AAEjC,EAAO,OAAA;AAAA,IACN,OAAS,EAAA,aAAA;AAAA,IACT,KAAO,EAAA;AAAA,GACR;AACD","file":"chunk-EEB35F4L.js","sourcesContent":["import { createAssetOptions } from \"./create-asset-options\";\nimport type { Paths } from \"./resources\";\n\nexport function createContentFieldOptions<TPath extends `/${string}/`>(paths: Paths<TPath>) {\n\tconst assetPaths = createAssetOptions(paths.assetPath);\n\tconst headingLevels = [2, 3, 4, 5] as const;\n\n\treturn {\n\t\theading: headingLevels,\n\t\timage: assetPaths,\n\t};\n}\n"]}
@@ -1,16 +0,0 @@
1
- import slugify from '@sindresorhus/slugify';
2
-
3
- // src/create-asset-options.ts
4
- function createAssetOptions(path) {
5
- return {
6
- directory: `./public/assets${path}`,
7
- publicPath: `/assets${path}`,
8
- transformFilename(originalFilename) {
9
- return slugify(originalFilename, { preserveCharacters: ["."] });
10
- }
11
- };
12
- }
13
-
14
- export { createAssetOptions };
15
- //# sourceMappingURL=chunk-ENT7N2ZS.js.map
16
- //# sourceMappingURL=chunk-ENT7N2ZS.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/create-asset-options.ts"],"names":[],"mappings":";;;AAIO,SAAS,mBACf,IACC,EAAA;AACD,EAAO,OAAA;AAAA,IACN,SAAA,EAAW,kBAAkB,IAAI,CAAA,CAAA;AAAA,IACjC,UAAA,EAAY,UAAU,IAAI,CAAA,CAAA;AAAA,IAC1B,kBAAkB,gBAA0B,EAAA;AAC3C,MAAA,OAAO,QAAQ,gBAAkB,EAAA,EAAE,oBAAoB,CAAC,GAAG,GAAG,CAAA;AAAA;AAC/D,GACD;AACD","file":"chunk-ENT7N2ZS.js","sourcesContent":["import slugify from \"@sindresorhus/slugify\";\n\nimport type { Paths } from \"./resources\";\n\nexport function createAssetOptions<TPath extends `/${string}/`>(\n\tpath: Paths<TPath>[\"assetPath\"] | Paths<TPath>[\"downloadPath\"],\n) {\n\treturn {\n\t\tdirectory: `./public/assets${path}` as const,\n\t\tpublicPath: `/assets${path}` as const,\n\t\ttransformFilename(originalFilename: string) {\n\t\t\treturn slugify(originalFilename, { preserveCharacters: [\".\"] });\n\t\t},\n\t};\n}\n"]}
@@ -1,8 +0,0 @@
1
- // src/with-i18n-prefix.ts
2
- function withI18nPrefix(label, locale) {
3
- return `${locale}:${label}`;
4
- }
5
-
6
- export { withI18nPrefix };
7
- //# sourceMappingURL=chunk-M7J4ISS4.js.map
8
- //# sourceMappingURL=chunk-M7J4ISS4.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/with-i18n-prefix.ts"],"names":[],"mappings":";AAEO,SAAS,cAAA,CACf,OACA,MACC,EAAA;AACD,EAAO,OAAA,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,KAAK,CAAA,CAAA;AAC1B","file":"chunk-M7J4ISS4.js","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"]}
@@ -1,35 +0,0 @@
1
- // 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
- export { createCollection, createCollectionPaths, createPaths, createSingleton, createSingletonPaths };
34
- //# sourceMappingURL=chunk-ZN3LEWB6.js.map
35
- //# sourceMappingURL=chunk-ZN3LEWB6.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/resources.ts"],"names":[],"mappings":";AAIO,SAAS,WAAA,CAAyC,MAAa,MAAgB,EAAA;AACrF,EAAO,OAAA;AAAA,IACN,SAAW,EAAA,CAAA,gBAAA,EAAmB,MAAM,CAAA,EAAG,IAAI,CAAA,CAAA;AAAA,IAC3C,YAAc,EAAA,CAAA,mBAAA,EAAsB,MAAM,CAAA,EAAG,IAAI,CAAA;AAAA,GAClD;AACD;AAIO,SAAS,qBAAA,CAAmD,MAAa,MAAgB,EAAA;AAC/F,EAAO,OAAA;AAAA,IACN,GAAG,WAAY,CAAA,IAAA,EAAM,MAAM,CAAA;AAAA,IAC3B,WAAa,EAAA,CAAA,UAAA,EAAa,MAAM,CAAA,EAAG,IAAI,CAAA,EAAA;AAAA,GACxC;AACD;AAEO,SAAS,oBAAA,CAAkD,MAAa,MAAgB,EAAA;AAC9F,EAAO,OAAA;AAAA,IACN,GAAG,WAAY,CAAA,IAAA,EAAM,MAAM,CAAA;AAAA,IAC3B,WAAa,EAAA,CAAA,UAAA,EAAa,MAAM,CAAA,EAAG,IAAI,CAAA;AAAA,GACxC;AACD;AAEO,SAAS,gBAAA,CAMf,MACA,gCAIC,EAAA;AACD,EAAO,OAAA,SAAS,0BAA0B,MAAiB,EAAA;AAC1D,IAAM,MAAA,KAAA,GAAQ,qBAAsB,CAAA,IAAA,EAAM,MAAM,CAAA;AAChD,IAAO,OAAA,gCAAA,CAAiC,OAAO,MAAM,CAAA;AAAA,GACtD;AACD;AAEO,SAAS,eAAA,CAKf,MACA,+BAIC,EAAA;AACD,EAAO,OAAA,SAAS,yBAAyB,MAAiB,EAAA;AACzD,IAAM,MAAA,KAAA,GAAQ,oBAAqB,CAAA,IAAA,EAAM,MAAM,CAAA;AAC/C,IAAO,OAAA,+BAAA,CAAgC,OAAO,MAAM,CAAA;AAAA,GACrD;AACD","file":"chunk-ZN3LEWB6.js","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"]}
@@ -1,10 +0,0 @@
1
- // src/create-component.ts
2
- function createComponent(createComponentFactory) {
3
- return function createComponent2(paths, locale) {
4
- return createComponentFactory(paths, locale);
5
- };
6
- }
7
-
8
- export { createComponent };
9
- //# sourceMappingURL=chunk-ZWZCXCMD.js.map
10
- //# sourceMappingURL=chunk-ZWZCXCMD.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/create-component.ts"],"names":["createComponent"],"mappings":";AAKO,SAAS,gBAId,sBAA+E,EAAA;AAChF,EAAO,OAAA,SAASA,gBAAgB,CAAA,KAAA,EAAqB,MAAiB,EAAA;AACrE,IAAO,OAAA,sBAAA,CAAuB,OAAO,MAAM,CAAA;AAAA,GAC5C;AACD","file":"chunk-ZWZCXCMD.js","sourcesContent":["import type { ContentComponent } from \"@keystatic/core/content-components\";\n\nimport type { Locale } from \"./config\";\nimport type { Paths } from \"./resources\";\n\nexport function createComponent<\n\tTPath extends `/${string}/`,\n\tTLocale extends Locale,\n\tTComponents extends Record<string, ContentComponent>,\n>(createComponentFactory: (paths: Paths<TPath>, locale: TLocale) => TComponents) {\n\treturn function createComponent(paths: Paths<TPath>, locale: TLocale) {\n\t\treturn createComponentFactory(paths, locale);\n\t};\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"config.js"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}