alinea 0.5.2 → 0.5.4

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 (46) hide show
  1. package/dist/backend/Database.js +8 -0
  2. package/dist/backend/Store.js +1 -1
  3. package/dist/backend/data/ChangeSet.d.ts +2 -1
  4. package/dist/backend/data/ChangeSet.js +5 -0
  5. package/dist/chunks/{chunk-KWP47LDR.js → chunk-TBAB475U.js} +1 -1
  6. package/dist/chunks/{chunk-QV233D56.js → chunk-VRXHB6DJ.js} +5 -3
  7. package/dist/chunks/{sql.js-OZNQGHQS.js → sql.js-75HGQX6U.js} +1 -1
  8. package/dist/cli/Generate.js +1 -1
  9. package/dist/cli/Serve.js +1 -1
  10. package/dist/cli/bin.js +1 -1
  11. package/dist/cli/generate/GenerateDashboard.js +1 -1
  12. package/dist/cloud/server/CloudAuthServer.js +1 -1
  13. package/dist/core/Field.d.ts +2 -0
  14. package/dist/core/Mutation.d.ts +8 -1
  15. package/dist/core/Mutation.js +1 -0
  16. package/dist/core/Shape.d.ts +1 -9
  17. package/dist/core/Tracker.d.ts +6 -2
  18. package/dist/core/Tracker.js +9 -9
  19. package/dist/core/Type.d.ts +2 -5
  20. package/dist/core/Type.js +14 -8
  21. package/dist/core/driver/TestDriver.js +1 -1
  22. package/dist/core/shape/ListShape.d.ts +1 -3
  23. package/dist/core/shape/ListShape.js +0 -18
  24. package/dist/core/shape/RecordShape.d.ts +0 -2
  25. package/dist/core/shape/RecordShape.js +0 -8
  26. package/dist/core/shape/RichTextShape.d.ts +0 -2
  27. package/dist/core/shape/RichTextShape.js +3 -23
  28. package/dist/core/shape/ScalarShape.d.ts +0 -2
  29. package/dist/core/shape/ScalarShape.js +0 -6
  30. package/dist/core/shape/UnionShape.d.ts +1 -3
  31. package/dist/core/shape/UnionShape.js +0 -17
  32. package/dist/dashboard/atoms/EntryEditorAtoms.js +39 -8
  33. package/dist/dashboard/atoms/FormAtoms.js +33 -30
  34. package/dist/dashboard/util/PersistentStore.js +1 -1
  35. package/dist/dashboard/view/InputLabel.d.ts +3 -0
  36. package/dist/dashboard/view/InputLabel.js +8 -3
  37. package/dist/dashboard/view/entry/NewEntry.js +2 -1
  38. package/dist/input/link/LinkField.browser.js +80 -104
  39. package/dist/input/number/NumberField.browser.js +25 -9
  40. package/dist/input/path/PathField.browser.js +3 -6
  41. package/dist/input/path/PathField.js +2 -0
  42. package/dist/input/richtext/RichTextField.browser.js +3 -7
  43. package/dist/input/select/SelectField.browser.js +1 -1
  44. package/dist/input/text/TextField.browser.js +2 -9
  45. package/dist/ui/util/TextareaAutosize.d.ts +1 -1
  46. package/package.json +1 -1
@@ -201,6 +201,14 @@ ${JSON.stringify(mutation)}`
201
201
  );
202
202
  };
203
203
  }
204
+ case MutationType.Patch: {
205
+ const { patch } = mutation;
206
+ const rows = EntryRow({ entryId: mutation.entryId, main: true });
207
+ const current = await tx(rows.maybeFirst());
208
+ if (current)
209
+ await tx(rows.set({ data: { ...current.data, patch } }));
210
+ return () => this.updateHash(tx, rows);
211
+ }
204
212
  case MutationType.Archive: {
205
213
  const archived = EntryRow({
206
214
  entryId: mutation.entryId,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  connect
3
- } from "../chunks/chunk-QV233D56.js";
3
+ } from "../chunks/chunk-VRXHB6DJ.js";
4
4
  import "../chunks/chunk-FLZ4KUMA.js";
5
5
  import "../chunks/chunk-4JLFL6LD.js";
6
6
  import "../chunks/chunk-U5RRZUYZ.js";
@@ -1,5 +1,5 @@
1
1
  import { Config, EntryUrlMeta } from 'alinea/core';
2
- import { ArchiveMutation, CreateMutation, DiscardDraftMutation, EditMutation, FileRemoveMutation, MoveMutation, Mutation, OrderMutation, PublishMutation, RemoveEntryMutation, UploadMutation } from 'alinea/core/Mutation';
2
+ import { ArchiveMutation, CreateMutation, DiscardDraftMutation, EditMutation, FileRemoveMutation, MoveMutation, Mutation, OrderMutation, PatchMutation, PublishMutation, RemoveEntryMutation, UploadMutation } from 'alinea/core/Mutation';
3
3
  export declare enum ChangeType {
4
4
  Write = "write",
5
5
  Rename = "rename",
@@ -42,6 +42,7 @@ export declare class ChangeSetCreator {
42
42
  constructor(config: Config);
43
43
  entryLocation({ locale, parentPaths, path, phase }: EntryUrlMeta, extension: string): string;
44
44
  editChanges({ previousFile, file, entry }: EditMutation): Array<Change>;
45
+ patchChanges({ file, patch }: PatchMutation): Array<Change>;
45
46
  createChanges({ file, entry }: CreateMutation): Array<Change>;
46
47
  publishChanges({ file }: PublishMutation): Array<Change>;
47
48
  archiveChanges({ file }: ArchiveMutation): Array<Change>;
@@ -53,6 +53,9 @@ var ChangeSetCreator = class {
53
53
  contents: decoder.decode(loader.format(this.config.schema, record))
54
54
  });
55
55
  }
56
+ patchChanges({ file, patch }) {
57
+ return [{ type: "patch" /* Patch */, file, patch }];
58
+ }
56
59
  createChanges({ file, entry }) {
57
60
  const record = createRecord(entry);
58
61
  return [
@@ -160,6 +163,8 @@ var ChangeSetCreator = class {
160
163
  switch (mutation.type) {
161
164
  case MutationType.Edit:
162
165
  return this.editChanges(mutation);
166
+ case MutationType.Patch:
167
+ return this.patchChanges(mutation);
163
168
  case MutationType.Create:
164
169
  return this.createChanges(mutation);
165
170
  case MutationType.Publish:
@@ -2,7 +2,7 @@
2
2
  var package_default = {
3
3
  bin: "./dist/cli.js",
4
4
  name: "alinea",
5
- version: "0.5.2",
5
+ version: "0.5.4",
6
6
  license: "MIT",
7
7
  type: "module",
8
8
  scripts: {
@@ -336,7 +336,7 @@ var AsyncDriver = class extends DriverBase {
336
336
  }
337
337
  async transaction(run) {
338
338
  const id = `t${this.transactionId++}`;
339
- const [connection, release] = this.isolate();
339
+ const [connection, release] = await this.isolate();
340
340
  await connection.executeQuery(
341
341
  new QueryData.Transaction({ op: QueryData.TransactionOperation.Begin, id })
342
342
  );
@@ -405,12 +405,14 @@ var SyncWrapper = class _SyncWrapper extends AsyncDriver {
405
405
  async schemaInstructions(tableName) {
406
406
  return this.sync.schemaInstructions(tableName);
407
407
  }
408
- isolate() {
408
+ async isolate() {
409
+ const currentLock = this.lock;
409
410
  const connection = new _SyncWrapper(this.sync);
410
411
  let release, trigger = new Promise((resolve) => {
411
412
  release = async () => resolve();
412
413
  });
413
- this.lock = Promise.resolve(this.lock).then(() => trigger);
414
+ this.lock = Promise.resolve(currentLock).then(() => trigger);
415
+ await currentLock;
414
416
  return [connection, release];
415
417
  }
416
418
  };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  SqlJsDriver,
3
3
  connect
4
- } from "./chunk-QV233D56.js";
4
+ } from "./chunk-VRXHB6DJ.js";
5
5
  import "./chunk-FLZ4KUMA.js";
6
6
  import "./chunk-4JLFL6LD.js";
7
7
  import "./chunk-U5RRZUYZ.js";
@@ -27,7 +27,7 @@ function generatePackage(context, config) {
27
27
  async function createDb() {
28
28
  const { default: sqlite } = await import("@alinea/sqlite-wasm");
29
29
  const { Database } = await sqlite();
30
- const { connect } = await import("../chunks/sql.js-OZNQGHQS.js");
30
+ const { connect } = await import("../chunks/sql.js-75HGQX6U.js");
31
31
  const db = new Database();
32
32
  const store = connect(db).toAsync();
33
33
  return [store, () => db.export()];
package/dist/cli/Serve.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-KWP47LDR.js";
3
+ } from "../chunks/chunk-TBAB475U.js";
4
4
  import "../chunks/chunk-U5RRZUYZ.js";
5
5
 
6
6
  // src/cli/Serve.ts
package/dist/cli/bin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunks/chunk-KWP47LDR.js";
3
+ } from "../chunks/chunk-TBAB475U.js";
4
4
  import "../chunks/chunk-U5RRZUYZ.js";
5
5
 
6
6
  // node_modules/mri/lib/index.mjs
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../../chunks/chunk-KWP47LDR.js";
3
+ } from "../../chunks/chunk-TBAB475U.js";
4
4
  import {
5
5
  __commonJS,
6
6
  __toESM
@@ -3,7 +3,7 @@ import {
3
3
  } from "../../chunks/chunk-IKINPSS5.js";
4
4
  import {
5
5
  package_default
6
- } from "../../chunks/chunk-KWP47LDR.js";
6
+ } from "../../chunks/chunk-TBAB475U.js";
7
7
  import "../../chunks/chunk-U5RRZUYZ.js";
8
8
 
9
9
  // src/cloud/server/CloudAuthServer.ts
@@ -11,6 +11,8 @@ export interface FieldOptions<Value> {
11
11
  readOnly?: boolean;
12
12
  /** The initial value of the field */
13
13
  initialValue?: Value;
14
+ /** The value of this field is shared across all languages */
15
+ shared?: boolean;
14
16
  }
15
17
  export type WithoutLabel<Options extends FieldOptions<any>> = Omit<Options, 'label'>;
16
18
  export interface FieldMeta<Value, Mutator, Options extends FieldOptions<Value>> {
@@ -6,6 +6,7 @@ export declare enum MutationProgress {
6
6
  }
7
7
  export declare enum MutationType {
8
8
  Edit = "update",
9
+ Patch = "patch",
9
10
  Create = "create",
10
11
  Publish = "publish",
11
12
  Archive = "archive",
@@ -20,7 +21,7 @@ export type PendingMutation = Mutation & {
20
21
  mutationId: string;
21
22
  createdAt: number;
22
23
  };
23
- export type Mutation = EditMutation | CreateMutation | PublishMutation | ArchiveMutation | RemoveEntryMutation | DiscardDraftMutation | OrderMutation | MoveMutation | UploadMutation | FileRemoveMutation;
24
+ export type Mutation = EditMutation | PatchMutation | CreateMutation | PublishMutation | ArchiveMutation | RemoveEntryMutation | DiscardDraftMutation | OrderMutation | MoveMutation | UploadMutation | FileRemoveMutation;
24
25
  export interface EditMutation {
25
26
  type: MutationType.Edit;
26
27
  entryId: string;
@@ -56,6 +57,12 @@ export interface DiscardDraftMutation {
56
57
  entryId: string;
57
58
  file: string;
58
59
  }
60
+ export interface PatchMutation {
61
+ type: MutationType.Patch;
62
+ entryId: string;
63
+ file: string;
64
+ patch: object;
65
+ }
59
66
  export interface OrderMutation {
60
67
  type: MutationType.Order;
61
68
  entryId: string;
@@ -9,6 +9,7 @@ var MutationProgress = /* @__PURE__ */ ((MutationProgress2) => {
9
9
  })(MutationProgress || {});
10
10
  var MutationType = /* @__PURE__ */ ((MutationType2) => {
11
11
  MutationType2["Edit"] = "update";
12
+ MutationType2["Patch"] = "patch";
12
13
  MutationType2["Create"] = "create";
13
14
  MutationType2["Publish"] = "publish";
14
15
  MutationType2["Archive"] = "archive";
@@ -1,19 +1,11 @@
1
- import { LinkResolver } from 'alinea/backend/resolver/LinkResolver';
1
+ import type { LinkResolver } from 'alinea/backend/resolver/LinkResolver';
2
2
  import * as Y from 'yjs';
3
3
  import { Label } from './Label.js';
4
- import { RecordShape } from './shape/RecordShape.js';
5
4
  type YType = Y.Map<any>;
6
- export interface ShapeInfo {
7
- name: string;
8
- parents: Array<string>;
9
- shape: RecordShape;
10
- }
11
5
  export interface Shape<Value = any, Mutator = any> {
12
6
  initialValue?: Value;
13
7
  label: Label;
14
- innerTypes(parents: Array<string>): Array<ShapeInfo>;
15
8
  create(): Value;
16
- typeOfChild<C>(yValue: any, child: string): Shape<C, unknown>;
17
9
  toY(value: Value): any;
18
10
  fromY(yValue: any): Value;
19
11
  applyY(value: Value, parent: YType, key: string): void;
@@ -1,3 +1,4 @@
1
+ import { Mutation } from 'alinea/core/Mutation';
1
2
  import { Field, FieldOptions } from './Field.js';
2
3
  export interface FieldGetter {
3
4
  <Value>(field: Field<Value>): Value;
@@ -8,9 +9,12 @@ export interface OptionsTracker<Options = any> {
8
9
  export interface ValueTracker<Value = any> {
9
10
  (getter: FieldGetter): Value;
10
11
  }
12
+ export interface MutationTracker {
13
+ (mutations: Array<Mutation>): Array<Mutation> | Promise<Array<Mutation>>;
14
+ }
15
+ export declare function optionTrackerOf(field: Field): OptionsTracker<any> | undefined;
16
+ export declare function valueTrackerOf(field: Field): ValueTracker<any> | undefined;
11
17
  export declare namespace track {
12
18
  function options<Value, OnChange, Options extends FieldOptions<Value>>(field: Field<Value, OnChange, Options>, tracker: OptionsTracker<Options>): void;
13
- function optionTrackerOf(field: Field): OptionsTracker<any> | undefined;
14
19
  function value<Value>(field: Field<Value>, tracker: ValueTracker<Value>): void;
15
- function valueTrackerOf(field: Field): ValueTracker<any> | undefined;
16
20
  }
@@ -3,26 +3,26 @@ import "../chunks/chunk-U5RRZUYZ.js";
3
3
  // src/core/Tracker.ts
4
4
  import { Field } from "./Field.js";
5
5
  var optionTrackers = /* @__PURE__ */ new Map();
6
+ function optionTrackerOf(field) {
7
+ return optionTrackers.get(Field.ref(field));
8
+ }
6
9
  var valueTrackers = /* @__PURE__ */ new Map();
10
+ function valueTrackerOf(field) {
11
+ return valueTrackers.get(Field.ref(field));
12
+ }
7
13
  var track;
8
14
  ((track2) => {
9
15
  function options(field, tracker) {
10
16
  optionTrackers.set(Field.ref(field), tracker);
11
17
  }
12
18
  track2.options = options;
13
- function optionTrackerOf(field) {
14
- return optionTrackers.get(Field.ref(field));
15
- }
16
- track2.optionTrackerOf = optionTrackerOf;
17
19
  function value(field, tracker) {
18
20
  valueTrackers.set(Field.ref(field), tracker);
19
21
  }
20
22
  track2.value = value;
21
- function valueTrackerOf(field) {
22
- return valueTrackers.get(Field.ref(field));
23
- }
24
- track2.valueTrackerOf = valueTrackerOf;
25
23
  })(track || (track = {}));
26
24
  export {
27
- track
25
+ optionTrackerOf,
26
+ track,
27
+ valueTrackerOf
28
28
  };
@@ -64,17 +64,14 @@ export declare namespace Type {
64
64
  function label(type: Type): Label;
65
65
  function meta(type: Type): TypeMeta;
66
66
  function shape(type: Type): RecordShape;
67
+ function fields(type: Type): Record<string, Field>;
67
68
  function hint(type: Type): Hint;
68
69
  function sections(type: Type): Section[];
69
70
  function isContainer(type: Type): boolean;
70
71
  function target(type: Type): TypeTarget;
71
72
  function field(type: Type, name: string): Field | undefined;
72
73
  function isType(type: any): type is Type;
73
- function blankEntry(name: string, type: Type): {
74
- id: string;
75
- type: string;
76
- [key: string]: any;
77
- };
74
+ function sharedData(type: Type, entryData: Record<string, unknown>): Record<string, unknown> | undefined;
78
75
  }
79
76
  export interface TypeDefinition {
80
77
  [key: string]: Field<any, any> | Section;
package/dist/core/Type.js CHANGED
@@ -5,7 +5,6 @@ import { Cursor } from "alinea/core/pages/Cursor";
5
5
  import { Expr, and } from "alinea/core/pages/Expr";
6
6
  import { Field } from "./Field.js";
7
7
  import { Hint } from "./Hint.js";
8
- import { createId } from "./Id.js";
9
8
  import { Meta } from "./Meta.js";
10
9
  import { Section, section } from "./Section.js";
11
10
  import { createExprData } from "./pages/CreateExprData.js";
@@ -35,6 +34,10 @@ var Type;
35
34
  return type2[Type2.Data].shape;
36
35
  }
37
36
  Type2.shape = shape;
37
+ function fields(type2) {
38
+ return type2;
39
+ }
40
+ Type2.fields = fields;
38
41
  function hint(type2) {
39
42
  return type2[Type2.Data].hint;
40
43
  }
@@ -59,14 +62,17 @@ var Type;
59
62
  return Boolean(type2 && type2[Type2.Data]);
60
63
  }
61
64
  Type2.isType = isType;
62
- function blankEntry(name, type2) {
63
- return {
64
- ...Type2.shape(type2).create(),
65
- type: name,
66
- id: createId()
67
- };
65
+ function sharedData(type2, entryData) {
66
+ const res = {};
67
+ for (const [key, field2] of entries(fields(type2))) {
68
+ if (Field.options(field2).shared)
69
+ res[key] = entryData[key];
70
+ }
71
+ if (keys(res).length === 0)
72
+ return void 0;
73
+ return res;
68
74
  }
69
- Type2.blankEntry = blankEntry;
75
+ Type2.sharedData = sharedData;
70
76
  })(Type || (Type = {}));
71
77
  function fieldsOfDefinition(definition) {
72
78
  return entries(definition).flatMap(([key, value]) => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  connect
3
- } from "../../chunks/chunk-QV233D56.js";
3
+ } from "../../chunks/chunk-VRXHB6DJ.js";
4
4
  import "../../chunks/chunk-FLZ4KUMA.js";
5
5
  import "../../chunks/chunk-4JLFL6LD.js";
6
6
  import "../../chunks/chunk-U5RRZUYZ.js";
@@ -1,7 +1,7 @@
1
1
  import { LinkResolver } from 'alinea/backend/resolver/LinkResolver';
2
2
  import * as Y from 'yjs';
3
3
  import { Label } from '../Label.js';
4
- import { Shape, ShapeInfo } from '../Shape.js';
4
+ import { Shape } from '../Shape.js';
5
5
  import { PostProcess } from '../pages/PostProcess.js';
6
6
  import { RecordShape } from './RecordShape.js';
7
7
  export type ListRow = {
@@ -22,9 +22,7 @@ export declare class ListShape<T extends ListRow> implements Shape<Array<T>, Lis
22
22
  protected postProcess?: PostProcess<T[]> | undefined;
23
23
  values: Record<string, RecordShape>;
24
24
  constructor(label: Label, shapes: Record<string, RecordShape>, initialValue?: T[] | undefined, postProcess?: PostProcess<T[]> | undefined);
25
- innerTypes(parents: Array<string>): Array<ShapeInfo>;
26
25
  create(): T[];
27
- typeOfChild<C>(yValue: Y.Map<any>, child: string): Shape<C>;
28
26
  toY(value: Array<T>): Y.Map<unknown>;
29
27
  fromY(map: Y.Map<any>): Array<T>;
30
28
  applyY(value: T[], parent: Y.Map<any>, key: string): void;
@@ -6,7 +6,6 @@ import "../../chunks/chunk-O6EXLFU2.js";
6
6
  import "../../chunks/chunk-U5RRZUYZ.js";
7
7
 
8
8
  // src/core/shape/ListShape.ts
9
- import { Hint } from "../Hint.js";
10
9
  import { createId } from "../Id.js";
11
10
  import { generateKeyBetween } from "../util/FractionalIndexing.js";
12
11
  import { RecordShape } from "./RecordShape.js";
@@ -39,26 +38,9 @@ var ListShape = class {
39
38
  );
40
39
  }
41
40
  values;
42
- innerTypes(parents) {
43
- return Object.entries(this.shapes).flatMap(([name, shape]) => {
44
- const info = { name, shape, parents };
45
- const inner = shape.innerTypes(parents.concat(name));
46
- if (Hint.isDefinitionName(name))
47
- return [info, ...inner];
48
- return inner;
49
- });
50
- }
51
41
  create() {
52
42
  return this.initialValue ?? [];
53
43
  }
54
- typeOfChild(yValue, child) {
55
- const row = yValue.get(child);
56
- const type = row && row.get("type");
57
- const value = type && this.values[type];
58
- if (value)
59
- return value;
60
- throw new Error(`Could not determine type of child "${child}"`);
61
- }
62
44
  toY(value) {
63
45
  const map = new YMap();
64
46
  const rows = Array.isArray(value) ? value : [];
@@ -10,10 +10,8 @@ export declare class RecordShape<T = object> implements Shape<T, RecordMutator<T
10
10
  properties: Record<string, Shape>;
11
11
  initialValue?: T | undefined;
12
12
  constructor(label: Label, properties: Record<string, Shape>, initialValue?: T | undefined);
13
- innerTypes(parents: Array<string>): import("../Shape.js").ShapeInfo[];
14
13
  concat<X>(that: RecordShape<X> | undefined): RecordShape<T & X>;
15
14
  create(): T;
16
- typeOfChild<C>(yValue: T, child: string): Shape<C>;
17
15
  toY(value: T): Y.Map<unknown>;
18
16
  fromY(map: Y.Map<any>): T;
19
17
  applyY(value: T, map: Y.Doc | Y.Map<any>, key: string): undefined;
@@ -12,11 +12,6 @@ var RecordShape = class _RecordShape {
12
12
  this.properties = properties;
13
13
  this.initialValue = initialValue;
14
14
  }
15
- innerTypes(parents) {
16
- return entries(this.properties).flatMap(([name, shape]) => {
17
- return shape.innerTypes(parents.concat(name));
18
- });
19
- }
20
15
  concat(that) {
21
16
  if (!that)
22
17
  return this;
@@ -32,9 +27,6 @@ var RecordShape = class _RecordShape {
32
27
  })
33
28
  );
34
29
  }
35
- typeOfChild(yValue, child) {
36
- return this.properties[child];
37
- }
38
30
  toY(value) {
39
31
  const self = value || {};
40
32
  const map = new YMap();
@@ -27,9 +27,7 @@ export declare class RichTextShape<Blocks> implements Shape<TextDoc<Blocks>, Ric
27
27
  initialValue?: TextDoc<Blocks> | undefined;
28
28
  values: Record<string, RecordShape>;
29
29
  constructor(label: Label, shapes?: Record<string, RecordShape<object>> | undefined, initialValue?: TextDoc<Blocks> | undefined);
30
- innerTypes(parents: Array<string>): import("../Shape.js").ShapeInfo[];
31
30
  create(): TextDoc<Blocks>;
32
- typeOfChild<C>(yValue: Y.Map<any>, child: string): Shape<C>;
33
31
  toXml(rows: TextDoc<Blocks>): (Y.XmlElement<{
34
32
  [key: string]: string;
35
33
  }> | Y.XmlText)[];
@@ -11,7 +11,6 @@ import "../../chunks/chunk-U5RRZUYZ.js";
11
11
 
12
12
  // src/core/shape/RichTextShape.ts
13
13
  import { Entry } from "../Entry.js";
14
- import { Hint } from "../Hint.js";
15
14
  import { TextNode } from "../TextDoc.js";
16
15
  import { entries, fromEntries, keys } from "../util/Objects.js";
17
16
  import { RecordShape } from "./RecordShape.js";
@@ -94,28 +93,9 @@ var RichTextShape = class {
94
93
  ) : {};
95
94
  }
96
95
  values;
97
- innerTypes(parents) {
98
- if (!this.shapes)
99
- return [];
100
- return entries(this.shapes).flatMap(([name, shape]) => {
101
- const info = { name, shape, parents };
102
- const inner = shape.innerTypes(parents.concat(name));
103
- if (Hint.isDefinitionName(name))
104
- return [info, ...inner];
105
- return inner;
106
- });
107
- }
108
96
  create() {
109
97
  return this.initialValue ?? [];
110
98
  }
111
- typeOfChild(yValue, child) {
112
- const block = yValue.get(child);
113
- const type = block && block.get("type");
114
- const value = type && this.values && this.values[type];
115
- if (value)
116
- return value;
117
- throw new Error(`Type of block "${child}" not found`);
118
- }
119
99
  toXml(rows) {
120
100
  const types = this.values;
121
101
  return rows.map((row) => {
@@ -147,12 +127,12 @@ var RichTextShape = class {
147
127
  if (isEmpty)
148
128
  return [];
149
129
  return content.map((node) => {
150
- const type = types[node.type];
151
- if (type && "id" in node) {
130
+ const shape = types[node.type];
131
+ if (shape && "id" in node) {
152
132
  return {
153
133
  id: node.id,
154
134
  type: node.type,
155
- ...type.fromY(value.get(node.id))
135
+ ...shape.fromY(value.get(node.id))
156
136
  };
157
137
  }
158
138
  return node;
@@ -6,9 +6,7 @@ export declare class ScalarShape<T> implements Shape<T, ScalarMutator<T>> {
6
6
  label: Label;
7
7
  initialValue?: T | undefined;
8
8
  constructor(label: Label, initialValue?: T | undefined);
9
- innerTypes(): never[];
10
9
  create(): T;
11
- typeOfChild<C>(yValue: T, child: string): Shape<C>;
12
10
  toY(value: T): T;
13
11
  fromY(yValue: any): any;
14
12
  applyY(value: T, parent: Y.Map<any>, key: string): void;
@@ -6,15 +6,9 @@ var ScalarShape = class {
6
6
  this.label = label;
7
7
  this.initialValue = initialValue;
8
8
  }
9
- innerTypes() {
10
- return [];
11
- }
12
9
  create() {
13
10
  return this.initialValue;
14
11
  }
15
- typeOfChild(yValue, child) {
16
- throw new Error(`No children in scalar values`);
17
- }
18
12
  toY(value) {
19
13
  return value;
20
14
  }
@@ -1,7 +1,7 @@
1
1
  import { LinkResolver } from 'alinea/backend/resolver/LinkResolver';
2
2
  import * as Y from 'yjs';
3
3
  import { Label } from '../Label.js';
4
- import { Shape, ShapeInfo } from '../Shape.js';
4
+ import { Shape } from '../Shape.js';
5
5
  import { PostProcess } from '../pages/PostProcess.js';
6
6
  import { RecordShape } from './RecordShape.js';
7
7
  export interface UnionRow {
@@ -18,9 +18,7 @@ export declare class UnionShape<T extends UnionRow> implements Shape<T, UnionMut
18
18
  protected postProcess?: PostProcess<T> | undefined;
19
19
  shapes: Record<string, RecordShape>;
20
20
  constructor(label: Label, shapes: Record<string, RecordShape>, initialValue?: T | undefined, postProcess?: PostProcess<T> | undefined);
21
- innerTypes(parents: Array<string>): Array<ShapeInfo>;
22
21
  create(): T;
23
- typeOfChild<C>(yValue: Y.Map<any>, child: string): Shape<C>;
24
22
  toY(value: T): Y.Map<unknown>;
25
23
  fromY(map: Y.Map<any>): T;
26
24
  applyY(value: T, parent: Y.Map<any>, key: string): void;
@@ -5,7 +5,6 @@ import "../../chunks/chunk-O6EXLFU2.js";
5
5
  import "../../chunks/chunk-U5RRZUYZ.js";
6
6
 
7
7
  // src/core/shape/UnionShape.ts
8
- import { Hint } from "../Hint.js";
9
8
  import { createId } from "../Id.js";
10
9
  import { entries, fromEntries } from "../util/Objects.js";
11
10
  import { RecordShape } from "./RecordShape.js";
@@ -29,25 +28,9 @@ var UnionShape = class {
29
28
  );
30
29
  }
31
30
  shapes;
32
- innerTypes(parents) {
33
- return entries(this.shapes).flatMap(([name, shape]) => {
34
- const info = { name, shape, parents };
35
- const inner = shape.innerTypes(parents.concat(name));
36
- if (Hint.isDefinitionName(name))
37
- return [info, ...inner];
38
- return inner;
39
- });
40
- }
41
31
  create() {
42
32
  return this.initialValue ?? {};
43
33
  }
44
- typeOfChild(yValue, child) {
45
- const type = yValue && yValue.get("type");
46
- const shape = type && this.shapes[type];
47
- if (shape)
48
- return shape.typeOfChild(yValue, child);
49
- throw new Error(`Could not determine type of child "${child}"`);
50
- }
51
34
  toY(value) {
52
35
  if (Array.isArray(value))
53
36
  value = value[0] ?? {};