alinea 0.4.2 → 0.5.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 (187) hide show
  1. package/dist/alinea.d.ts +1 -1
  2. package/dist/alinea.js +12 -1
  3. package/dist/backend/Database.js +2 -2
  4. package/dist/backend/data/MemoryHandler.d.ts +3 -0
  5. package/dist/backend/data/MemoryHandler.js +67 -0
  6. package/dist/backend/test/Example.d.ts +4 -13
  7. package/dist/backend/test/ExampleTypes.d.ts +1 -4
  8. package/dist/chunks/{chunk-LRUUF55J.js → chunk-B6H4DO6X.js} +2 -3
  9. package/dist/cli/Generate.js +3 -3
  10. package/dist/cli/Serve.js +9 -5
  11. package/dist/cli/bin.js +1 -1
  12. package/dist/cli/generate/CompileConfig.js +1 -1
  13. package/dist/cli/generate/GenerateDashboard.js +1 -1
  14. package/dist/cli/generate/LoadConfig.js +5 -5
  15. package/dist/cli/static/dashboard/dev.js +2 -4
  16. package/dist/cli/util/FindConfigFile.js +1 -1
  17. package/dist/cloud/server/CloudAuthServer.js +1 -1
  18. package/dist/core/CMS.d.ts +3 -3
  19. package/dist/core/CMS.js +6 -10
  20. package/dist/core/Config.d.ts +37 -3
  21. package/dist/core/Config.js +5 -1
  22. package/dist/core/Entry.d.ts +7 -8
  23. package/dist/core/EntryRow.d.ts +3 -3
  24. package/dist/core/Field.d.ts +25 -19
  25. package/dist/core/Field.js +11 -0
  26. package/dist/{editor → core}/Picker.d.ts +8 -5
  27. package/dist/{editor → core}/Picker.js +1 -1
  28. package/dist/core/Schema.d.ts +1 -1
  29. package/dist/core/Section.d.ts +1 -5
  30. package/dist/core/Shape.d.ts +5 -3
  31. package/dist/core/TextDoc.d.ts +2 -2
  32. package/dist/core/Tracker.d.ts +16 -0
  33. package/dist/core/Tracker.js +28 -0
  34. package/dist/core/Type.d.ts +2 -1
  35. package/dist/core/Type.js +8 -2
  36. package/dist/core/driver/NextDriver.server.js +1 -1
  37. package/dist/core/driver/TestDriver.js +4 -2
  38. package/dist/core/field/ListField.d.ts +3 -3
  39. package/dist/core/field/ListField.js +2 -2
  40. package/dist/core/field/RecordField.d.ts +2 -2
  41. package/dist/core/field/RichTextField.d.ts +2 -2
  42. package/dist/core/field/RichTextField.js +5 -1
  43. package/dist/core/field/ScalarField.d.ts +2 -2
  44. package/dist/core/field/ScalarField.js +1 -1
  45. package/dist/core/field/UnionField.d.ts +3 -3
  46. package/dist/core/field/UnionField.js +2 -2
  47. package/dist/core/media/MediaSchema.browser.d.ts +5 -21
  48. package/dist/core/media/MediaSchema.browser.js +18 -15
  49. package/dist/core/media/MediaSchema.js +7 -1
  50. package/dist/core/pages/Target.js +5 -3
  51. package/dist/core/shape/ListShape.d.ts +12 -11
  52. package/dist/core/shape/ListShape.js +5 -1
  53. package/dist/core/shape/RecordShape.d.ts +1 -0
  54. package/dist/core/shape/RecordShape.js +5 -1
  55. package/dist/core/shape/RichTextShape.d.ts +1 -0
  56. package/dist/core/shape/RichTextShape.js +6 -2
  57. package/dist/core/shape/ScalarShape.d.ts +3 -2
  58. package/dist/core/shape/ScalarShape.js +5 -1
  59. package/dist/core/shape/UnionShape.d.ts +15 -14
  60. package/dist/core/shape/UnionShape.js +5 -1
  61. package/dist/core.d.ts +2 -0
  62. package/dist/core.js +2 -0
  63. package/dist/dashboard/App.js +0 -1
  64. package/dist/dashboard/Routes.d.ts +4 -8
  65. package/dist/dashboard/atoms/EntryEditorAtoms.d.ts +5 -9
  66. package/dist/dashboard/atoms/EntryEditorAtoms.js +9 -10
  67. package/dist/dashboard/atoms/EntrySummaryAtoms.d.ts +16 -2
  68. package/dist/dashboard/atoms/EntrySummaryAtoms.js +2 -0
  69. package/dist/dashboard/atoms/FormAtoms.d.ts +42 -0
  70. package/dist/dashboard/atoms/FormAtoms.js +158 -0
  71. package/dist/dashboard/dev/DevDashboard.js +7 -7
  72. package/dist/dashboard/editor/InputForm.d.ts +25 -0
  73. package/dist/dashboard/editor/InputForm.js +52 -0
  74. package/dist/dashboard/editor/UseField.d.ts +12 -0
  75. package/dist/dashboard/editor/UseField.js +50 -0
  76. package/dist/dashboard/hook/UseEntrySummary.d.ts +1 -1
  77. package/dist/dashboard/view/EntryEdit.js +5 -4
  78. package/dist/dashboard/view/EntryTree.js +3 -1
  79. package/dist/{editor → dashboard}/view/InputLabel.d.ts +2 -2
  80. package/dist/{editor → dashboard}/view/InputLabel.js +4 -4
  81. package/dist/dashboard/view/Toolbar.js +46 -57
  82. package/dist/dashboard/view/diff/FieldsDiff.js +1 -1
  83. package/dist/dashboard/view/entry/EntryPreview.d.ts +3 -3
  84. package/dist/dashboard/view/entry/EntryPreview.js +15 -3
  85. package/dist/dashboard/view/entry/EntryTitle.js +1 -5
  86. package/dist/dashboard/view/entry/FieldToolbar.js +2 -1
  87. package/dist/dashboard/view/entry/NewEntry.js +62 -44
  88. package/dist/dashboard/view/media/FileSummary.js +1 -1
  89. package/dist/dashboard/view/sidebar/SidebarSettings.js +69 -76
  90. package/dist/dashboard.d.ts +3 -0
  91. package/dist/dashboard.js +4 -0
  92. package/dist/index.css +85 -46
  93. package/dist/input/check/CheckField.browser.js +10 -10
  94. package/dist/input/check/CheckField.d.ts +6 -6
  95. package/dist/input/check/CheckField.js +1 -3
  96. package/dist/input/code/CodeField.browser.js +5 -6
  97. package/dist/input/code/CodeField.d.ts +4 -4
  98. package/dist/input/code/CodeField.js +1 -3
  99. package/dist/input/date/DateField.browser.js +7 -7
  100. package/dist/input/date/DateField.d.ts +4 -4
  101. package/dist/input/date/DateField.js +1 -3
  102. package/dist/input/hidden/HiddenField.d.ts +3 -8
  103. package/dist/input/hidden/HiddenField.js +1 -3
  104. package/dist/input/json/JsonField.browser.js +5 -6
  105. package/dist/input/json/JsonField.d.ts +5 -7
  106. package/dist/input/json/JsonField.js +1 -3
  107. package/dist/input/link/LinkConstructors.d.ts +46 -18
  108. package/dist/input/link/LinkConstructors.js +2 -0
  109. package/dist/input/link/LinkField.browser.d.ts +1 -0
  110. package/dist/input/link/LinkField.browser.js +31 -23
  111. package/dist/input/link/LinkField.d.ts +11 -14
  112. package/dist/input/link/LinkField.js +2 -5
  113. package/dist/input/link/LinkInput.stories.d.ts +0 -1
  114. package/dist/input/list/ListField.browser.d.ts +1 -3
  115. package/dist/input/list/ListField.browser.js +45 -29
  116. package/dist/input/list/ListField.d.ts +4 -4
  117. package/dist/input/list/ListField.js +1 -2
  118. package/dist/input/list/ListField.stories.d.ts +5 -0
  119. package/dist/input/metadata/MetadataField.browser.js +7 -7
  120. package/dist/input/metadata/MetadataField.d.ts +3 -3
  121. package/dist/input/metadata/MetadataField.js +2 -3
  122. package/dist/input/metadata/MetadataField.stories.d.ts +5 -0
  123. package/dist/input/number/NumberField.browser.js +25 -39
  124. package/dist/input/number/NumberField.d.ts +4 -6
  125. package/dist/input/number/NumberField.js +1 -3
  126. package/dist/input/object/ObjectField.browser.js +7 -4
  127. package/dist/input/object/ObjectField.d.ts +4 -4
  128. package/dist/input/object/ObjectField.js +1 -2
  129. package/dist/input/object/ObjectField.stories.d.ts +5 -0
  130. package/dist/input/path/PathField.browser.js +9 -13
  131. package/dist/input/path/PathField.d.ts +4 -5
  132. package/dist/input/path/PathField.js +1 -2
  133. package/dist/input/richtext/PickTextLink.js +29 -41
  134. package/dist/input/richtext/RichTextField.browser.d.ts +1 -3
  135. package/dist/input/richtext/RichTextField.browser.js +17 -18
  136. package/dist/input/richtext/RichTextField.d.ts +4 -4
  137. package/dist/input/richtext/RichTextField.js +1 -3
  138. package/dist/input/richtext/RichTextKit.js +1 -0
  139. package/dist/input/richtext/RichTextToolbar.js +18 -2
  140. package/dist/input/select/SelectField.browser.js +6 -9
  141. package/dist/input/select/SelectField.d.ts +7 -13
  142. package/dist/input/select/SelectField.js +2 -3
  143. package/dist/input/tabs/Tabs.browser.js +4 -3
  144. package/dist/input/tabs/Tabs.stories.d.ts +4 -0
  145. package/dist/input/text/TextField.browser.js +5 -5
  146. package/dist/input/text/TextField.d.ts +4 -6
  147. package/dist/input/text/TextField.js +1 -3
  148. package/dist/input/view/View.browser.js +1 -1
  149. package/dist/picker/entry/EntryPicker.browser.d.ts +1 -1
  150. package/dist/picker/entry/EntryPicker.browser.js +13 -7
  151. package/dist/picker/entry/EntryPicker.d.ts +7 -3
  152. package/dist/picker/entry/EntryPicker.js +2 -1
  153. package/dist/picker/entry/EntryPickerRow.js +1 -1
  154. package/dist/picker/entry/EntryReference.d.ts +4 -0
  155. package/dist/picker/url/UrlPicker.browser.d.ts +1 -1
  156. package/dist/picker/url/UrlPicker.browser.js +9 -16
  157. package/dist/picker/url/UrlPicker.d.ts +2 -2
  158. package/dist/picker/url/UrlPicker.js +1 -1
  159. package/dist/picker/url/UrlPickerRow.js +1 -1
  160. package/dist/ui/Pane.js +1 -1
  161. package/dist/ui/RichText.js +17 -3
  162. package/dist/ui/Typo.d.ts +5 -1
  163. package/dist/ui/Typo.js +1 -0
  164. package/dist/ui/icons/IcRoundPublish.d.ts +0 -1
  165. package/dist/ui/icons/IcRoundPublish.js +8 -4
  166. package/dist/ui/util/CreateTypo.d.ts +19 -3
  167. package/dist/ui/util/CreateTypo.js +21 -26
  168. package/dist/ui/util/TextareaAutosize.d.ts +1 -1
  169. package/package.json +2 -3
  170. package/dist/editor/InputState.d.ts +0 -41
  171. package/dist/editor/InputState.js +0 -67
  172. package/dist/editor/hook/UseField.d.ts +0 -25
  173. package/dist/editor/hook/UseField.js +0 -73
  174. package/dist/editor/hook/UseForm.d.ts +0 -29
  175. package/dist/editor/hook/UseForm.js +0 -106
  176. package/dist/editor/hook/UseInput.d.ts +0 -2
  177. package/dist/editor/hook/UseInput.js +0 -9
  178. package/dist/editor/view/Fields.d.ts +0 -8
  179. package/dist/editor/view/Fields.js +0 -20
  180. package/dist/editor/view/Input.d.ts +0 -11
  181. package/dist/editor/view/Input.js +0 -23
  182. package/dist/editor/view/InputField.d.ts +0 -14
  183. package/dist/editor/view/InputField.js +0 -17
  184. package/dist/editor/view/InputForm.d.ts +0 -8
  185. package/dist/editor/view/InputForm.js +0 -25
  186. package/dist/editor.d.ts +0 -7
  187. package/dist/editor.js +0 -8
package/dist/alinea.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { Meta as meta, page, root, schema, type, workspace } from 'alinea/core';
1
+ export { createConfig as config, Meta as meta, page, root, schema, track, type, workspace } from 'alinea/core';
2
2
  export type { Infer as infer } from 'alinea/core';
3
3
  export { createMediaRoot as media } from 'alinea/core/media/MediaRoot';
4
4
  export * from './input.js';
package/dist/alinea.js CHANGED
@@ -1,15 +1,26 @@
1
1
  import "./chunks/chunk-U5RRZUYZ.js";
2
2
 
3
3
  // src/alinea.ts
4
- import { Meta, page, root, schema, type, workspace } from "alinea/core";
4
+ import {
5
+ createConfig,
6
+ Meta,
7
+ page,
8
+ root,
9
+ schema,
10
+ track,
11
+ type,
12
+ workspace
13
+ } from "alinea/core";
5
14
  import { createMediaRoot } from "alinea/core/media/MediaRoot";
6
15
  export * from "./input.js";
7
16
  export {
17
+ createConfig as config,
8
18
  createMediaRoot as media,
9
19
  Meta as meta,
10
20
  page,
11
21
  root,
12
22
  schema,
23
+ track,
13
24
  type,
14
25
  workspace
15
26
  };
@@ -365,14 +365,14 @@ ${JSON.stringify(mutation)}`
365
365
  hash = hash.update(c);
366
366
  const contentHash = hash.digest().toString(16).padStart(8, "0");
367
367
  const modifiedAt = await tx(
368
- EntryRow().select(EntryRow.modifiedAt).orderBy(EntryRow.modifiedAt.desc()).first()
368
+ EntryRow().select(EntryRow.modifiedAt).orderBy(EntryRow.modifiedAt.desc()).maybeFirst()
369
369
  );
370
370
  await tx(AlineaMeta().delete());
371
371
  await tx(
372
372
  AlineaMeta().insertOne({
373
373
  commitHash,
374
374
  contentHash,
375
- modifiedAt
375
+ modifiedAt: modifiedAt ?? 0
376
376
  })
377
377
  );
378
378
  }
@@ -0,0 +1,3 @@
1
+ import { Database, Handler } from 'alinea/backend';
2
+ import { Config } from 'alinea/core';
3
+ export declare function createMemoryHandler(config: Config, db: Database): Handler;
@@ -0,0 +1,67 @@
1
+ import "../../chunks/chunk-U5RRZUYZ.js";
2
+
3
+ // src/backend/data/MemoryHandler.ts
4
+ import { Handler, JWTPreviews } from "alinea/backend";
5
+ import { createId } from "alinea/core";
6
+ var MemoryApi = class {
7
+ constructor(config, db) {
8
+ this.config = config;
9
+ this.db = db;
10
+ }
11
+ drafts = /* @__PURE__ */ new Map();
12
+ pending = [];
13
+ async mutate(params) {
14
+ const mutations = params.mutations.flatMap((mutate) => mutate.meta);
15
+ const toCommitHash = createId();
16
+ await this.db.applyMutations(mutations, toCommitHash);
17
+ this.pending.push({ ...params, toCommitHash });
18
+ return { commitHash: toCommitHash };
19
+ }
20
+ prepareUpload(file) {
21
+ throw new Error(`Not implemented`);
22
+ }
23
+ async revisions(file) {
24
+ return [];
25
+ }
26
+ async revisionData(file, revision) {
27
+ throw new Error(`Not implemented`);
28
+ }
29
+ async getDraft(entryId) {
30
+ return this.drafts.get(entryId);
31
+ }
32
+ async storeDraft(draft) {
33
+ this.drafts.set(draft.entryId, draft);
34
+ }
35
+ async pendingSince(commitHash) {
36
+ let i = this.pending.length;
37
+ for (; i >= 0; i--)
38
+ if (i > 0 && this.pending[i - 1].toCommitHash === commitHash)
39
+ break;
40
+ const pending = this.pending.slice(i);
41
+ if (pending.length === 0)
42
+ return void 0;
43
+ return {
44
+ toCommitHash: pending[pending.length - 1].toCommitHash,
45
+ mutations: pending.flatMap(
46
+ (params) => params.mutations.flatMap((mutate) => mutate.meta)
47
+ )
48
+ };
49
+ }
50
+ };
51
+ function createMemoryHandler(config, db) {
52
+ const api = new MemoryApi(config, db);
53
+ return new Handler({
54
+ db,
55
+ config,
56
+ target: api,
57
+ media: api,
58
+ history: api,
59
+ drafts: api,
60
+ pending: api,
61
+ previews: new JWTPreviews("dev"),
62
+ previewAuthToken: "dev"
63
+ });
64
+ }
65
+ export {
66
+ createMemoryHandler
67
+ };
@@ -1,10 +1,7 @@
1
1
  export declare function createExample(): {
2
2
  schema: {
3
3
  Page: import("alinea/core").Type<{
4
- name: import("../../input/path").PathField & import("../../input/text").TextField;
5
- name2: import("../../input/text").TextField;
6
- title: import("../../input/text").TextField;
7
- path: import("../../input/path").PathField;
4
+ [x: string]: any;
8
5
  }>;
9
6
  Container: import("alinea/core").Type<{
10
7
  title: import("../../input/text").TextField;
@@ -16,10 +13,7 @@ export declare function createExample(): {
16
13
  main: import("alinea/core").Workspace<{
17
14
  pages: import("alinea/core").Root<{
18
15
  entry1: import("alinea/core").PageSeed<{
19
- name: import("../../input/path").PathField & import("../../input/text").TextField;
20
- name2: import("../../input/text").TextField;
21
- title: import("../../input/text").TextField;
22
- path: import("../../input/path").PathField;
16
+ [x: string]: any;
23
17
  }, Record<string, any>>;
24
18
  entry2: import("alinea/core").PageSeed<{
25
19
  title: import("../../input/text").TextField;
@@ -31,10 +25,7 @@ export declare function createExample(): {
31
25
  }>;
32
26
  multiLanguage: import("alinea/core").Root<{
33
27
  localised1: import("alinea/core").PageSeed<{
34
- name: import("../../input/path").PathField & import("../../input/text").TextField;
35
- name2: import("../../input/text").TextField;
36
- title: import("../../input/text").TextField;
37
- path: import("../../input/path").PathField;
28
+ [x: string]: any;
38
29
  }, Record<string, any>>;
39
30
  localised2: import("alinea/core").PageSeed<{
40
31
  title: import("../../input/text").TextField;
@@ -44,7 +35,7 @@ export declare function createExample(): {
44
35
  localised3: any;
45
36
  }>;
46
37
  }>;
47
- media: import("alinea/core/media/MediaRoot").MediaRoot<{
38
+ media: import("../../core/media/MediaRoot").MediaRoot<{
48
39
  dir: import("alinea/core").PageSeed<{
49
40
  title: import("../../input/text").TextField;
50
41
  path: import("../../input/path").PathField;
@@ -1,6 +1,3 @@
1
1
  export declare const TypeWithTabs: import("alinea/core").Type<{
2
- name: import("../../input/path").PathField & import("../../input/text").TextField;
3
- name2: import("../../input/text").TextField;
4
- title: import("../../input/text").TextField;
5
- path: import("../../input/path").PathField;
2
+ [x: string]: any;
6
3
  }>;
@@ -2,7 +2,7 @@
2
2
  var package_default = {
3
3
  bin: "./dist/cli.js",
4
4
  name: "alinea",
5
- version: "0.4.2",
5
+ version: "0.5.0",
6
6
  license: "MIT",
7
7
  type: "module",
8
8
  scripts: {
@@ -41,7 +41,6 @@ var package_default = {
41
41
  ],
42
42
  workspaces: [
43
43
  "apps/web",
44
- "apps/demo",
45
44
  "apps/dev",
46
45
  "src/backend",
47
46
  "src/cli",
@@ -71,7 +70,7 @@ var package_default = {
71
70
  "@esbx/static": "^0.0.19",
72
71
  "@esbx/target": "^0.0.20",
73
72
  "@esbx/workspaces": "^0.0.19",
74
- "@ladle/react": "^2.15.0",
73
+ "@ladle/react": "^4.0.1",
75
74
  "@types/better-sqlite3": "^7.6.4",
76
75
  "@types/fs-extra": "^11.0.1",
77
76
  "@types/glob": "^7.1.4",
@@ -71,7 +71,7 @@ async function* generate(options) {
71
71
  const cms = await loadCMS(context.outDir);
72
72
  cms.exportStore(context.outDir, new Uint8Array());
73
73
  const fileData = new LocalData({
74
- config: cms,
74
+ config: cms.config,
75
75
  fs: fs.promises,
76
76
  rootDir,
77
77
  dashboardUrl: await options.dashboardUrl
@@ -80,7 +80,7 @@ async function* generate(options) {
80
80
  context,
81
81
  fileData,
82
82
  store,
83
- cms,
83
+ cms.config,
84
84
  nextBuild
85
85
  )) {
86
86
  yield { cms, db, localData: fileData };
@@ -96,7 +96,7 @@ async function* generate(options) {
96
96
  }
97
97
  if (done) {
98
98
  await Promise.all([
99
- generatePackage(context, cms),
99
+ generatePackage(context, cms.config),
100
100
  cms.exportStore(context.outDir, exportStore())
101
101
  ]);
102
102
  break;
package/dist/cli/Serve.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-LRUUF55J.js";
3
+ } from "../chunks/chunk-B6H4DO6X.js";
4
4
  import "../chunks/chunk-U5RRZUYZ.js";
5
5
 
6
6
  // src/cli/Serve.ts
@@ -77,16 +77,20 @@ async function serve(options) {
77
77
  } else {
78
78
  let createBackend2 = function() {
79
79
  if (process.env.ALINEA_CLOUD_DEBUG)
80
- return createCloudDebugHandler(currentCMS, db, rootDir);
80
+ return createCloudDebugHandler(currentCMS.config, db, rootDir);
81
81
  if (process.env.ALINEA_CLOUD_URL)
82
- return createCloudHandler(currentCMS, db, process.env.ALINEA_API_KEY);
82
+ return createCloudHandler(
83
+ currentCMS.config,
84
+ db,
85
+ process.env.ALINEA_API_KEY
86
+ );
83
87
  return new Handler({
84
- config: currentCMS,
88
+ config: currentCMS.config,
85
89
  db,
86
90
  target: fileData,
87
91
  media: fileData,
88
92
  drafts,
89
- history: new GitHistory(currentCMS, rootDir),
93
+ history: new GitHistory(currentCMS.config, rootDir),
90
94
  previews: new JWTPreviews("dev"),
91
95
  previewAuthToken: "dev"
92
96
  });
package/dist/cli/bin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-LRUUF55J.js";
3
+ } from "../chunks/chunk-B6H4DO6X.js";
4
4
  import "../chunks/chunk-U5RRZUYZ.js";
5
5
 
6
6
  // node_modules/mri/lib/index.mjs
@@ -54,7 +54,7 @@ function compileConfig({
54
54
  setup(build) {
55
55
  build.onEnd((res) => {
56
56
  if (res.errors.length) {
57
- console.log("> config has errors");
57
+ console.log("> Could not compile Alinea config");
58
58
  } else {
59
59
  results.emit(res);
60
60
  if (!watch)
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../../chunks/chunk-LRUUF55J.js";
3
+ } from "../../chunks/chunk-B6H4DO6X.js";
4
4
  import {
5
5
  __commonJS,
6
6
  __toESM
@@ -2,7 +2,7 @@ import "../../chunks/chunk-U5RRZUYZ.js";
2
2
 
3
3
  // src/cli/generate/LoadConfig.ts
4
4
  import { CMS } from "alinea/core/CMS";
5
- import { values } from "alinea/core/util/Objects";
5
+ import { createCMS } from "alinea/core/driver/DefaultDriver";
6
6
  import { createRequire } from "node:module";
7
7
  import path from "node:path";
8
8
  async function loadCMS(outDir) {
@@ -11,10 +11,10 @@ async function loadCMS(outDir) {
11
11
  const outFile = `file://${genConfigFile}?${unique}`;
12
12
  global.require = createRequire(import.meta.url);
13
13
  const exports = await import(outFile);
14
- for (const member of values(exports)) {
15
- if (member instanceof CMS)
16
- return member;
17
- }
14
+ if ("cms" in exports && exports.cms instanceof CMS)
15
+ return exports.cms;
16
+ if ("config" in exports)
17
+ return createCMS(exports.config);
18
18
  throw new Error(`No config found in "${genConfigFile}"`);
19
19
  }
20
20
  export {
@@ -1,4 +1,3 @@
1
- import {CMS} from 'alinea/core'
2
1
  import 'alinea/css'
3
2
  import {DevDashboard} from 'alinea/dashboard/dev/DevDashboard'
4
3
  import {jsx} from 'react/jsx-runtime'
@@ -13,8 +12,7 @@ reactRender(jsx(DevDashboard, {loadConfig}), into)
13
12
 
14
13
  async function loadConfig() {
15
14
  const exports = await import('/config.js?' + Math.random())
16
- for (const member of Object.values(exports)) {
17
- if (member instanceof CMS) return member
18
- }
15
+ if ('cms' in exports) return exports.cms.config
16
+ if ('config' in exports) return exports.config
19
17
  throw new Error(`No config found in "/config.js"`)
20
18
  }
@@ -9,7 +9,7 @@ var defaultLocations = [
9
9
  "cms",
10
10
  "src/cms"
11
11
  ];
12
- var testExtensions = [".js", ".ts", ".tsx", ".jsx"];
12
+ var testExtensions = [".ts", ".tsx", ".js", ".jsx"];
13
13
  function findConfigFile(cwd) {
14
14
  for (const location of defaultLocations) {
15
15
  for (const extension of testExtensions) {
@@ -3,7 +3,7 @@ import {
3
3
  } from "../../chunks/chunk-IKINPSS5.js";
4
4
  import {
5
5
  package_default
6
- } from "../../chunks/chunk-LRUUF55J.js";
6
+ } from "../../chunks/chunk-B6H4DO6X.js";
7
7
  import "../../chunks/chunk-U5RRZUYZ.js";
8
8
 
9
9
  // src/cloud/server/CloudAuthServer.ts
@@ -8,17 +8,17 @@ type Attachment = Workspace | Root;
8
8
  export interface CMSApi extends GraphRealmApi {
9
9
  resolver(): Promise<Resolver>;
10
10
  }
11
- export declare abstract class CMS extends GraphRealm implements Config, CMSApi {
11
+ export declare abstract class CMS extends GraphRealm implements CMSApi {
12
12
  #private;
13
13
  dashboard: DashboardConfig;
14
14
  graph: Graph;
15
+ config: Config;
15
16
  constructor(config: Config);
16
17
  abstract resolver(): Promise<Resolver>;
17
18
  abstract exportStore(cwd: string, store: Uint8Array): Promise<void>;
18
19
  abstract readStore(): Promise<Store>;
19
- get schema(): import("alinea/core").Schema<object>;
20
+ get schema(): import("alinea/core").Schema<{}>;
20
21
  get workspaces(): Record<string, Workspace>;
21
- get preview(): string | undefined;
22
22
  }
23
23
  export declare namespace CMS {
24
24
  const Link: unique symbol;
package/dist/core/CMS.js CHANGED
@@ -2,27 +2,26 @@ import "../chunks/chunk-U5RRZUYZ.js";
2
2
 
3
3
  // src/core/CMS.ts
4
4
  import { CloudAuthView } from "alinea/cloud/view/CloudAuth";
5
- import { MediaFile, MediaLibrary } from "alinea/core/media/MediaSchema";
5
+ import { createConfig } from "./Config.js";
6
6
  import { Graph, GraphRealm } from "./Graph.js";
7
7
  import { entries } from "./util/Objects.js";
8
8
  var attached = /* @__PURE__ */ new WeakMap();
9
9
  var CMS = class extends GraphRealm {
10
10
  dashboard;
11
11
  graph;
12
+ config;
12
13
  constructor(config) {
13
- const withMedia = {
14
- ...config,
15
- schema: { MediaLibrary, MediaFile, ...config.schema }
16
- };
17
- super(withMedia, async (params) => {
14
+ const normalizedConfig = createConfig(config);
15
+ super(normalizedConfig, async (params) => {
18
16
  const cnx = await this.resolver();
19
17
  return cnx.resolve(params);
20
18
  });
19
+ this.config = normalizedConfig;
21
20
  this.dashboard = {
22
21
  auth: CloudAuthView,
23
22
  ...config.dashboard
24
23
  };
25
- this.graph = new Graph(this, async (params) => {
24
+ this.graph = new Graph(normalizedConfig, async (params) => {
26
25
  const { resolve } = await this.resolver();
27
26
  return resolve(params);
28
27
  });
@@ -46,9 +45,6 @@ var CMS = class extends GraphRealm {
46
45
  get workspaces() {
47
46
  return this.config.workspaces;
48
47
  }
49
- get preview() {
50
- return this.config.preview;
51
- }
52
48
  };
53
49
  ((CMS2) => {
54
50
  CMS2.Link = Symbol.for("@alinea/CMS.Link");
@@ -1,4 +1,6 @@
1
+ import { ComponentType } from 'react';
1
2
  import { Auth } from './Auth.js';
3
+ import { Entry } from './Entry.js';
2
4
  import { Schema } from './Schema.js';
3
5
  import { Type } from './Type.js';
4
6
  import { Workspace, WorkspaceData } from './Workspace.js';
@@ -15,11 +17,19 @@ export interface Config {
15
17
  schema: Schema;
16
18
  /** A record containing workspace configurations */
17
19
  workspaces: Record<string, Workspace>;
18
- dashboard?: DashboardConfig;
19
20
  /** A url which will be embedded in the dashboard for live previews */
20
- preview?: string;
21
+ preview?: string | ComponentType<{
22
+ entry: Entry;
23
+ previewToken: string;
24
+ }>;
21
25
  /** Every edit will pass through a draft phase before being published */
22
26
  enableDrafts?: boolean;
27
+ /**
28
+ publicDir?: string
29
+ dashboardFile?: string
30
+ handlerUrl?:
31
+ */
32
+ dashboard?: DashboardConfig;
23
33
  }
24
34
  export declare namespace Config {
25
35
  function mainWorkspace(config: Config): WorkspaceData;
@@ -27,4 +37,28 @@ export declare namespace Config {
27
37
  function hasAuth(config: Config): boolean;
28
38
  }
29
39
  /** Create a new config instance */
30
- export declare function createConfig<Definition extends Config>(definition: Definition): Definition;
40
+ export declare function createConfig<Definition extends Config>(definition: Definition): Definition & {
41
+ schema: {
42
+ MediaLibrary: Type<{
43
+ title: import("../input/text.js").TextField;
44
+ path: import("../input/path.js").PathField;
45
+ }>;
46
+ MediaFile: Type<{
47
+ title: import("../input/text.js").TextField;
48
+ path: import("../input/path.js").PathField;
49
+ location: import("../input/hidden.js").HiddenField<string>;
50
+ extension: import("../input/hidden.js").HiddenField<string>;
51
+ size: import("../input/hidden.js").HiddenField<number>;
52
+ hash: import("../input/hidden.js").HiddenField<string>;
53
+ width: import("../input/hidden.js").HiddenField<number>;
54
+ height: import("../input/hidden.js").HiddenField<number>;
55
+ preview: import("../input/hidden.js").HiddenField<string>;
56
+ averageColor: import("../input/hidden.js").HiddenField<string>;
57
+ focus: import("../input/hidden.js").HiddenField<{
58
+ x: number;
59
+ y: number;
60
+ }>;
61
+ thumbHash: import("../input/hidden.js").HiddenField<string>;
62
+ }>;
63
+ };
64
+ };
@@ -1,6 +1,7 @@
1
1
  import "../chunks/chunk-U5RRZUYZ.js";
2
2
 
3
3
  // src/core/Config.ts
4
+ import { MediaSchema } from "alinea/core/media/MediaSchema";
4
5
  import { Workspace } from "./Workspace.js";
5
6
  var Config;
6
7
  ((Config2) => {
@@ -19,7 +20,10 @@ var Config;
19
20
  Config2.hasAuth = hasAuth;
20
21
  })(Config || (Config = {}));
21
22
  function createConfig(definition) {
22
- return definition;
23
+ return {
24
+ ...definition,
25
+ schema: { ...MediaSchema, ...definition.schema }
26
+ };
23
27
  }
24
28
  export {
25
29
  Config,
@@ -1,11 +1,8 @@
1
- import { Expand } from 'alinea/core';
2
- import { EntryRow } from './EntryRow.js';
1
+ import { EntryPhase } from './EntryRow.js';
3
2
  import { Target } from './pages/Target.js';
4
- export type Entry = Expand<EntryRow>;
5
- export declare const Entry: Target<{
6
- data: Record<string, any>;
3
+ export interface Entry {
7
4
  entryId: string;
8
- phase: import("alinea/core").EntryPhase;
5
+ phase: EntryPhase;
9
6
  title: string;
10
7
  type: string;
11
8
  seeded: boolean;
@@ -21,10 +18,12 @@ export declare const Entry: Target<{
21
18
  locale: string | null;
22
19
  modifiedAt: number;
23
20
  rowHash: string;
24
- fileHash: string;
25
21
  active: boolean;
26
22
  main: boolean;
27
23
  path: string;
24
+ fileHash: string;
28
25
  url: string;
26
+ data: Record<string, any>;
29
27
  searchableText: string;
30
- }>;
28
+ }
29
+ export declare const Entry: Target<Entry>;
@@ -40,7 +40,7 @@ export declare class EntryTable {
40
40
  * Represents an Entry row in the database,
41
41
  * field data is available in the data column in JSON format.
42
42
  */
43
- export interface EntryRow<Data = Record<string, any>> extends table<EntryTable> {
43
+ export type EntryRow<Data = Record<string, any>> = table<EntryTable> & {
44
44
  data: Data;
45
- }
46
- export declare const EntryRow: import("rado").IndexedTable<EntryTable, "url" | "path" | "phase" | "type" | "parentDir" | "childrenDir" | "parent" | "i18nId" | "versionId" | "rowHash" | "fileIdentifier">;
45
+ };
46
+ export declare const EntryRow: import("rado").IndexedTable<EntryTable, "url" | "path" | "rowHash" | "type" | "parent" | "fileIdentifier" | "parentDir" | "childrenDir" | "versionId" | "phase" | "i18nId">;
@@ -1,41 +1,47 @@
1
1
  import { LinkResolver } from 'alinea/backend/resolver/LinkResolver';
2
2
  import { Expr } from 'alinea/core/pages/Expr';
3
- import { InputState } from 'alinea/editor';
4
3
  import type { ComponentType } from 'react';
5
4
  import { Hint } from './Hint.js';
6
- import { Label } from './Label.js';
7
5
  import { Shape } from './Shape.js';
8
- export interface FieldOptions {
6
+ export interface FieldOptions<Value> {
7
+ label: string;
8
+ /** Hide this field in the dashboard */
9
9
  hidden?: boolean;
10
+ /** Mark this field as read-only */
10
11
  readOnly?: boolean;
12
+ /** The initial value of the field */
13
+ initialValue?: Value;
11
14
  }
12
- export interface FieldMeta<Value, OnChange, Options> {
15
+ export type WithoutLabel<Options extends FieldOptions<any>> = Omit<Options, 'label'>;
16
+ export interface FieldMeta<Value, Mutator, Options extends FieldOptions<Value>> {
13
17
  hint: Hint;
14
- label: Label;
15
- initialValue?: Value;
16
18
  options: Options;
17
- view?: FieldView<Value, OnChange, Options>;
19
+ view?: FieldView<Value, Mutator, Options>;
18
20
  postProcess?: (value: Value, loader: LinkResolver) => Promise<void>;
19
21
  }
20
- export interface FieldData<Value, OnChange, Options> extends FieldMeta<Value, OnChange, Options> {
21
- shape: Shape<Value, OnChange>;
22
+ export interface FieldData<Value, Mutator, Options extends FieldOptions<Value>> extends FieldMeta<Value, Mutator, Options> {
23
+ shape: Shape<Value, Mutator>;
22
24
  }
23
- export type FieldView<Value, OnChange, Options> = ComponentType<{
24
- state: InputState<readonly [Value, OnChange]>;
25
- field: Field<Value, OnChange, Options>;
25
+ export type FieldView<Value, Mutator, Options extends FieldOptions<Value>> = ComponentType<{
26
+ field: Field<Value, Mutator, Options>;
26
27
  }>;
27
- export interface Field<Value, OnChange, Options> extends Expr<Value> {
28
- [Field.Data]: FieldData<Value, OnChange, Options>;
28
+ export interface Field<Value, Mutator, Options extends FieldOptions<Value>> extends Expr<Value> {
29
+ [Field.Data]: FieldData<Value, Mutator, Options>;
30
+ [Field.Ref]: symbol;
29
31
  }
30
- export declare class Field<Value = unknown, OnChange = unknown, Options = {}> {
31
- constructor(data: FieldData<Value, OnChange, Options>);
32
+ export declare class Field<Value = any, Mutator = any, Options extends FieldOptions<Value> = FieldOptions<Value>> {
33
+ static index: number;
34
+ constructor(data: FieldData<Value, Mutator, Options>);
32
35
  }
33
36
  export declare namespace Field {
34
37
  const Data: unique symbol;
35
- function provideView<Value, OnChange, Options, Factory extends (...args: Array<any>) => Field<Value, OnChange, Options>>(view: FieldView<Value, OnChange, Options>, factory: Factory): Factory;
38
+ const Ref: unique symbol;
39
+ function provideView<Value, Mutator, Options extends FieldOptions<Value>, Factory extends (...args: Array<any>) => Field<Value, Mutator, Options>>(view: FieldView<Value, Mutator, Options>, factory: Factory): Factory;
40
+ function ref(field: Field): symbol;
36
41
  function shape(field: Field<any, any>): Shape;
37
42
  function hint(field: Field): Hint;
38
- function view<Value, OnChange, Options>(field: Field<Value, OnChange, Options>): FieldView<Value, OnChange, Options> | undefined;
39
- function options(field: Field): FieldOptions;
43
+ function label(field: Field): string;
44
+ function view<Value, Mutator, Options extends FieldOptions<Value>>(field: Field<Value, Mutator, Options>): FieldView<Value, Mutator, Options> | undefined;
45
+ function options<Value, Options extends FieldOptions<Value>>(field: Field<Value, any, Options>): Options;
40
46
  function isField(value: any): value is Field;
41
47
  }
@@ -2,16 +2,23 @@ import "../chunks/chunk-U5RRZUYZ.js";
2
2
 
3
3
  // src/core/Field.ts
4
4
  var Field = class _Field {
5
+ static index = 0;
5
6
  constructor(data) {
6
7
  this[_Field.Data] = data;
8
+ this[_Field.Ref] = Symbol(`Field.${data.options.label}.${_Field.index++}`);
7
9
  }
8
10
  };
9
11
  ((Field2) => {
10
12
  Field2.Data = Symbol.for("@alinea/Field.Data");
13
+ Field2.Ref = Symbol.for("@alinea/Field.Self");
11
14
  function provideView(view2, factory) {
12
15
  return (...args) => new Field2({ ...factory(...args)[Field2.Data], view: view2 });
13
16
  }
14
17
  Field2.provideView = provideView;
18
+ function ref(field) {
19
+ return field[Field2.Ref];
20
+ }
21
+ Field2.ref = ref;
15
22
  function shape(field) {
16
23
  return field[Field2.Data].shape;
17
24
  }
@@ -20,6 +27,10 @@ var Field = class _Field {
20
27
  return field[Field2.Data].hint;
21
28
  }
22
29
  Field2.hint = hint;
30
+ function label(field) {
31
+ return field[Field2.Data].options.label;
32
+ }
33
+ Field2.label = label;
23
34
  function view(field) {
24
35
  return field[Field2.Data].view;
25
36
  }