alinea 2.0.0-preview.0 → 2.0.0-preview.2
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.
- package/dist/.init/content/pages/welcome.json +1 -1
- package/dist/LICENSES.md +134 -80
- package/dist/adapter/next/DevRemote.d.ts +3 -0
- package/dist/adapter/next/DevRemote.js +37 -0
- package/dist/adapter/next/ForwardCredentials.d.ts +1 -0
- package/dist/adapter/next/ForwardCredentials.js +17 -0
- package/dist/adapter/next/cms.js +86 -38
- package/dist/adapter/next/context.d.ts +1 -1
- package/dist/adapter/next/context.js +11 -3
- package/dist/adapter/next/handler.d.ts +2 -0
- package/dist/adapter/next/handler.js +23 -16
- package/dist/adapter/next/with-alinea.js +18 -16
- package/dist/backend/Handler.d.ts +14 -13
- package/dist/backend/Handler.js +70 -36
- package/dist/backend/resolver/ParsePreview.d.ts +8 -4
- package/dist/backend/resolver/ParsePreview.js +40 -43
- package/dist/backend/router/Router.d.ts +1 -0
- package/dist/backend/router/Router.js +21 -15
- package/dist/bundled.d.ts +369 -99
- package/dist/chunks/chunk-6UT4N4CO.js +919 -0
- package/dist/chunks/{chunk-LUBOGJCG.js → chunk-6V4TAD2N.js} +1 -1
- package/dist/chunks/{chunk-TL7ZW6BX.js → chunk-A3XXZBOQ.js} +2535 -2999
- package/dist/chunks/chunk-AC5ATYI3.js +1434 -0
- package/dist/chunks/{chunk-7ORQ7BYK.js → chunk-KMLLLZ6X.js} +202 -269
- package/dist/chunks/{chunk-IWN3T3FL.js → chunk-O7XWTMCB.js} +1 -1
- package/dist/chunks/{chunk-53DZYORR.js → chunk-PAYSVIYI.js} +76 -176
- package/dist/chunks/{chunk-YK3OSMDM.js → chunk-S4AU6SRS.js} +188 -158
- package/dist/chunks/{chunk-EQ3TDHYD.js → chunk-UVOEM4AH.js} +6 -3
- package/dist/chunks/{chunk-I7X64JTZ.js → chunk-VXZM6V4P.js} +4 -4
- package/dist/cli/Generate.js +3 -13
- package/dist/cli/Serve.js +7 -3
- package/dist/cli/bin.js +8 -5
- package/dist/cli/generate/CompileConfig.js +3 -2
- package/dist/cli/generate/CopyStaticFiles.js +2 -3
- package/dist/cli/generate/DevDB.d.ts +1 -1
- package/dist/cli/generate/DevDB.js +3 -5
- package/dist/cli/serve/CreateLocalServer.d.ts +1 -1
- package/dist/cli/serve/CreateLocalServer.js +3 -2
- package/dist/cli/serve/DevServer.d.ts +3 -2
- package/dist/cli/serve/DevServer.js +60 -3
- package/dist/cli/serve/ServeContext.d.ts +1 -0
- package/dist/cli/serve/StartServer.d.ts +1 -0
- package/dist/cli/serve/StartServer.js +6 -1
- package/dist/cli/util/EnsureLibs.js +2 -2
- package/dist/cli/util/EnsureNode.js +2 -2
- package/dist/cloud/CloudRemote.d.ts +2 -1
- package/dist/cloud/CloudRemote.js +3 -2
- package/dist/components/Breadcrumbs.js +8 -8
- package/dist/components/Button.js +6 -6
- package/dist/components/Calendar.js +11 -11
- package/dist/components/Checkbox.js +7 -7
- package/dist/components/CheckboxGroup.js +6 -6
- package/dist/components/ColorSwatch.js +6 -6
- package/dist/components/ColorSwatchPicker.js +6 -6
- package/dist/components/ComboBox.js +17 -17
- package/dist/components/DateField.js +9 -9
- package/dist/components/DatePicker.js +10 -10
- package/dist/components/DateRangePicker.js +14 -14
- package/dist/components/Dialog.js +6 -6
- package/dist/components/Disclosure.js +13 -13
- package/dist/components/DropZone.js +6 -6
- package/dist/components/Label.js +16 -16
- package/dist/components/Link.js +6 -6
- package/dist/components/List.js +34 -34
- package/dist/components/Menu.js +10 -10
- package/dist/components/Modal.js +8 -8
- package/dist/components/MultipleSelect.js +33 -33
- package/dist/components/NumberField.d.ts +2 -1
- package/dist/components/NumberField.js +21 -11
- package/dist/components/Popover.js +6 -6
- package/dist/components/ProgressCircle.js +10 -10
- package/dist/components/RadioGroup.js +6 -6
- package/dist/components/SearchField.js +11 -11
- package/dist/components/Select.js +13 -13
- package/dist/components/Surface.js +3 -3
- package/dist/components/Switch.js +6 -6
- package/dist/components/Table.js +13 -13
- package/dist/components/Tabs.js +8 -8
- package/dist/components/TagGroup.js +7 -7
- package/dist/components/TextField.js +10 -10
- package/dist/components/TimeField.js +6 -6
- package/dist/components/Toggle.js +6 -6
- package/dist/components/Toolbar.js +7 -7
- package/dist/components/Tooltip.js +10 -10
- package/dist/components/Tree.js +9 -9
- package/dist/core/BlobTransport.d.ts +5 -0
- package/dist/core/BlobTransport.js +79 -0
- package/dist/core/Client.d.ts +2 -1
- package/dist/core/Client.js +17 -12
- package/dist/core/Config.d.ts +4 -0
- package/dist/core/Config.js +6 -0
- package/dist/core/Connection.d.ts +4 -3
- package/dist/core/Connection.js +7 -0
- package/dist/core/Graph.d.ts +3 -4
- package/dist/core/ListRow.d.ts +2 -0
- package/dist/core/OrderBy.d.ts +7 -3
- package/dist/core/TextDoc.d.ts +11 -0
- package/dist/core/Trace.d.ts +8 -0
- package/dist/core/Trace.js +32 -0
- package/dist/core/Type.d.ts +7 -1
- package/dist/core/db/CommitRequest.d.ts +0 -3
- package/dist/core/db/CommitRequest.js +0 -9
- package/dist/core/db/EntryDB.js +1 -1
- package/dist/core/db/EntryIndex.d.ts +12 -2
- package/dist/core/db/EntryIndex.js +131 -22
- package/dist/core/db/EntryResolver.js +104 -29
- package/dist/core/db/EntryTransaction.d.ts +1 -2
- package/dist/core/db/EntryTransaction.js +29 -22
- package/dist/core/db/LocalDB.d.ts +5 -5
- package/dist/core/db/LocalDB.js +27 -12
- package/dist/core/field/RichTextField.d.ts +30 -3
- package/dist/core/field/RichTextField.js +124 -56
- package/dist/core/media/MediaAltField.d.ts +1 -0
- package/dist/core/media/MediaAltField.js +9 -1
- package/dist/core/media/MediaLocation.d.ts +5 -2
- package/dist/core/media/MediaLocation.js +6 -7
- package/dist/core/media/MediaTypes.js +11 -0
- package/dist/core/source/CombinedSource.d.ts +2 -2
- package/dist/core/source/CombinedSource.js +6 -3
- package/dist/core/source/FSSource.d.ts +4 -3
- package/dist/core/source/FSSource.js +59 -27
- package/dist/core/source/GithubSource.d.ts +2 -2
- package/dist/core/source/GithubSource.js +21 -9
- package/dist/core/source/IndexedDBSource.d.ts +2 -2
- package/dist/core/source/IndexedDBSource.js +3 -1
- package/dist/core/source/MemorySource.d.ts +2 -2
- package/dist/core/source/MemorySource.js +3 -1
- package/dist/core/source/OverlaySource.d.ts +12 -0
- package/dist/core/source/OverlaySource.js +50 -0
- package/dist/core/source/Source.d.ts +5 -2
- package/dist/core/source/Source.js +3 -3
- package/dist/core/util/Async.d.ts +8 -2
- package/dist/core/util/Async.js +67 -0
- package/dist/core/util/EntryFilenames.d.ts +2 -2
- package/dist/core/util/EntryFilenames.js +3 -3
- package/dist/dashboard/App.css +158 -0
- package/dist/dashboard/App.js +2 -2
- package/dist/dashboard/app/AccessDenied.js +3 -3
- package/dist/dashboard/app/ActivityStatus.js +15 -15
- package/dist/dashboard/app/AppShell.js +1 -1
- package/dist/dashboard/app/AuthView.js +11 -11
- package/dist/dashboard/app/CompactField.js +10 -10
- package/dist/dashboard/app/DashboardErrorBoundary.js +5 -5
- package/dist/dashboard/app/DashboardLayout.js +22 -19
- package/dist/dashboard/app/EntryHeader.js +12 -12
- package/dist/dashboard/app/EntryReferences.js +9 -9
- package/dist/dashboard/app/EntrySidebar.d.ts +1 -1
- package/dist/dashboard/app/EntrySidebar.js +17 -16
- package/dist/dashboard/app/EntrySidebarPreview.d.ts +1 -1
- package/dist/dashboard/app/EntrySidebarPreview.js +19 -14
- package/dist/dashboard/app/EntryTranslationBanner.js +7 -7
- package/dist/dashboard/app/Explorer.js +51 -43
- package/dist/dashboard/app/ExplorerCards.js +34 -34
- package/dist/dashboard/app/ExplorerFileCard.js +18 -18
- package/dist/dashboard/app/ExplorerList.js +13 -13
- package/dist/dashboard/app/ExplorerModal.js +3 -3
- package/dist/dashboard/app/ExplorerTable.js +76 -61
- package/dist/dashboard/app/ExternalLinkPicker.js +15 -4
- package/dist/dashboard/app/LinkPicker.js +8 -8
- package/dist/dashboard/app/LocaleMenu.js +12 -12
- package/dist/dashboard/app/SidebarLayout.d.ts +8 -0
- package/dist/dashboard/app/SidebarLayout.js +1169 -0
- package/dist/dashboard/app/SidebarTree.js +46 -46
- package/dist/dashboard/app/WorkspaceMenu.js +17 -17
- package/dist/dashboard/app/WorkspaceRoots.js +23 -23
- package/dist/dashboard/app/editor/FileEditor.d.ts +2 -1
- package/dist/dashboard/app/editor/FileEditor.js +41 -32
- package/dist/dashboard/app/editor/FilePreview.js +4 -4
- package/dist/dashboard/app/editor/MediaAltField.view.d.ts +1 -1
- package/dist/dashboard/app/editor/MediaAltField.view.js +6 -9
- package/dist/dashboard/app/modals/CreateEntry.js +4 -4
- package/dist/dashboard/app/pages/EntryPage.js +57 -31
- package/dist/dashboard/app/pages/UsersPage.js +33 -33
- package/dist/dashboard/app/ui/DashboardModal.js +23 -23
- package/dist/dashboard/app/ui/Rail.js +3 -3
- package/dist/dashboard/app/ui/Sidebar.js +2 -2
- package/dist/dashboard/atoms/auth.js +2 -0
- package/dist/dashboard/atoms/dashboard.d.ts +9 -0
- package/dist/dashboard/atoms/dashboard.js +17 -0
- package/dist/dashboard/atoms/editor.d.ts +7 -1
- package/dist/dashboard/atoms/editor.js +4 -1
- package/dist/dashboard/atoms/entry.d.ts +48 -2
- package/dist/dashboard/atoms/entry.js +222 -17
- package/dist/dashboard/atoms/explorer.js +4 -9
- package/dist/dashboard/atoms/preview.d.ts +3 -0
- package/dist/dashboard/atoms/preview.js +18 -1
- package/dist/dashboard/atoms/root.d.ts +4 -1
- package/dist/dashboard/atoms/root.js +96 -157
- package/dist/dashboard/hooks.d.ts +4 -2
- package/dist/dashboard/hooks.js +9 -5
- package/dist/dashboard/icons.d.ts +1 -0
- package/dist/dashboard/icons.js +10 -0
- package/dist/field/check/CheckField.view.js +2 -2
- package/dist/field/code/CodeField.view.js +12 -12
- package/dist/field/date/DateField.view.js +12 -2
- package/dist/field/link/FileLink.d.ts +2 -2
- package/dist/field/link/FileLink.js +5 -3
- package/dist/field/link/ImageLink.d.ts +1 -1
- package/dist/field/link/ImageLink.js +1 -1
- package/dist/field/link/Link.js +2 -2
- package/dist/field/link/LinkField.view.js +155 -128
- package/dist/field/list/ListField.view.js +22 -33
- package/dist/field/metadata/MetadataField.view.js +19 -19
- package/dist/field/number/NumberField.d.ts +2 -0
- package/dist/field/number/NumberField.view.js +4 -2
- package/dist/field/richtext/PickTextLink.d.ts +7 -0
- package/dist/field/richtext/PickTextLink.js +104 -2
- package/dist/field/richtext/ReferenceLink.d.ts +4 -1
- package/dist/field/richtext/ReferenceLink.js +18 -4
- package/dist/field/richtext/RichTextDocument.d.ts +7 -2
- package/dist/field/richtext/RichTextDocument.js +34 -5
- package/dist/field/richtext/RichTextExtensions.d.ts +3 -1
- package/dist/field/richtext/RichTextExtensions.js +2704 -7467
- package/dist/field/richtext/RichTextField.d.ts +4 -0
- package/dist/field/richtext/RichTextField.story.d.ts +4 -0
- package/dist/field/richtext/RichTextField.view.js +43 -20
- package/dist/field/richtext/RichTextInsertMenu.js +281 -495
- package/dist/field/richtext/RichTextToolbar.d.ts +5 -2
- package/dist/field/richtext/RichTextToolbar.js +38 -3
- package/dist/field/richtext/Toolbar.d.ts +19 -1
- package/dist/field/richtext/Toolbar.js +18 -13
- package/dist/field/richtext/extensions/Anchor.js +1 -1
- package/dist/field/richtext/extensions/Link.js +1 -1
- package/dist/field/richtext/extensions/Small.js +1 -1
- package/dist/field/select/SelectField.view.js +8 -6
- package/dist/index.css +227 -16
- package/dist/next.cjs +18 -16
- package/dist/next.d.ts +2 -1
- package/dist/next.edge.d.ts +2 -1
- package/dist/picker/entry/EntryPicker.js +9 -35
- package/dist/preview/PreviewPayload.js +35 -250
- package/dist/ui/RichText.d.ts +1 -0
- package/dist/ui/RichText.js +29 -2
- package/package.json +6 -3
- package/dist/cli/util/ExternalPlugin.d.ts +0 -2
- package/dist/cli/util/ExternalPlugin.js +0 -919
- package/dist/chunks/{chunk-JFROOUG6.js → chunk-NIVGVRDS.js} +17 -17
package/dist/core/Graph.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type { Expr } from './Expr.js';
|
|
|
5
5
|
import type { Condition, Filter } from './Filter.js';
|
|
6
6
|
import type { Infer, StoredRow } from './Infer.js';
|
|
7
7
|
import type { HasField } from './Internal.js';
|
|
8
|
+
import type { OrderBy } from './OrderBy.js';
|
|
8
9
|
import type { Page } from './Page.js';
|
|
9
10
|
import type { PreviewRequest } from './Preview.js';
|
|
10
11
|
import type { Type } from './Type.js';
|
|
@@ -52,11 +53,9 @@ interface SelectObject {
|
|
|
52
53
|
}
|
|
53
54
|
export type Projection = SelectContent | SelectObject;
|
|
54
55
|
export type InferProjection<Selection> = InferSelection<Selection>;
|
|
55
|
-
export
|
|
56
|
-
asc?: Expr<any>;
|
|
57
|
-
desc?: Expr<any>;
|
|
56
|
+
export type Order = OrderBy & {
|
|
58
57
|
caseSensitive?: boolean;
|
|
59
|
-
}
|
|
58
|
+
};
|
|
60
59
|
type InferSelection<Selection> = Selection extends GraphQuery & Edge ? Expand<AnyQueryResult<Selection>> : Selection extends Expr<infer V> ? V : {
|
|
61
60
|
[K in keyof Selection]: Selection[K] extends Type<infer V> ? Type.Infer<V> : InferSelection<Selection[K]>;
|
|
62
61
|
};
|
package/dist/core/ListRow.d.ts
CHANGED
package/dist/core/OrderBy.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Expr } from './Expr.js';
|
|
2
|
-
export
|
|
2
|
+
export interface AscendingOrder {
|
|
3
3
|
asc: Expr<any>;
|
|
4
|
-
|
|
4
|
+
desc?: never;
|
|
5
|
+
}
|
|
6
|
+
export interface DescendingOrder {
|
|
7
|
+
asc?: never;
|
|
5
8
|
desc: Expr<any>;
|
|
6
|
-
}
|
|
9
|
+
}
|
|
10
|
+
export type OrderBy = AscendingOrder | DescendingOrder;
|
package/dist/core/TextDoc.d.ts
CHANGED
|
@@ -45,6 +45,17 @@ export interface ElementNode {
|
|
|
45
45
|
export declare namespace ElementNode {
|
|
46
46
|
const content = "content";
|
|
47
47
|
}
|
|
48
|
+
export interface ImageNode extends ElementNode {
|
|
49
|
+
_type: 'image';
|
|
50
|
+
_id?: string;
|
|
51
|
+
_link?: 'image';
|
|
52
|
+
_entry?: string;
|
|
53
|
+
src?: string;
|
|
54
|
+
alt?: string;
|
|
55
|
+
title?: string;
|
|
56
|
+
width?: number | string;
|
|
57
|
+
height?: number | string;
|
|
58
|
+
}
|
|
48
59
|
export interface BlockNode {
|
|
49
60
|
_id: string;
|
|
50
61
|
_type: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Config } from './Config.js';
|
|
2
|
+
export interface Tracer {
|
|
3
|
+
<Result>(name: string, run: () => Promise<Result>): Promise<Result>;
|
|
4
|
+
}
|
|
5
|
+
export interface TraceSpan {
|
|
6
|
+
<Result>(operation: () => Promise<Result>): Promise<Result>;
|
|
7
|
+
}
|
|
8
|
+
export declare function trace(config: Config, name: string): TraceSpan;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import "../chunks/chunk-CQ52GEHY.js";
|
|
2
|
+
|
|
3
|
+
// src/core/Trace.ts
|
|
4
|
+
function trace(config, name) {
|
|
5
|
+
const tracer = config?.tracer;
|
|
6
|
+
if (!tracer) return runDirect;
|
|
7
|
+
return async function runSpan(operation) {
|
|
8
|
+
let result;
|
|
9
|
+
let called = false;
|
|
10
|
+
function run() {
|
|
11
|
+
if (called) return result;
|
|
12
|
+
called = true;
|
|
13
|
+
try {
|
|
14
|
+
result = operation();
|
|
15
|
+
} catch (error) {
|
|
16
|
+
result = Promise.reject(error);
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
await tracer(name, run);
|
|
22
|
+
} catch {
|
|
23
|
+
}
|
|
24
|
+
return run();
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function runDirect(operation) {
|
|
28
|
+
return operation();
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
trace
|
|
32
|
+
};
|
package/dist/core/Type.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
|
+
import type { Config } from './Config.js';
|
|
2
3
|
import type { EntryStatus } from './Entry.js';
|
|
3
4
|
import type { Expr } from './Expr.js';
|
|
4
5
|
import { Field, type EntryAnchorTarget, type FieldAnchorContext, type FieldBeforeSaveContext } from './Field.js';
|
|
@@ -11,7 +12,9 @@ import type { View } from './View.js';
|
|
|
11
12
|
import type { EntryReferenceTarget } from './db/EntryReference.js';
|
|
12
13
|
import type { SummaryProps } from './media/Summary.js';
|
|
13
14
|
import type { Expand } from './util/Types.js';
|
|
14
|
-
export interface
|
|
15
|
+
export interface EntryUrlInput {
|
|
16
|
+
config: Config;
|
|
17
|
+
data: Record<string, unknown>;
|
|
15
18
|
status: EntryStatus;
|
|
16
19
|
path: string;
|
|
17
20
|
parentPaths: Array<string>;
|
|
@@ -19,6 +22,9 @@ export interface EntryUrlMeta {
|
|
|
19
22
|
workspace: string;
|
|
20
23
|
root: string;
|
|
21
24
|
}
|
|
25
|
+
export interface EntryUrlMeta extends EntryUrlInput {
|
|
26
|
+
defaultUrl: string;
|
|
27
|
+
}
|
|
22
28
|
export type EntryDefaultView = 'edit' | 'overview';
|
|
23
29
|
export type Type<Definition = object> = Definition & HasType;
|
|
24
30
|
type TypeRow<Definition> = Expand<{
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Change, ChangeFile, ChangesBatch } from '../source/Change.js';
|
|
2
|
-
import type { ReadonlyTree } from '../source/Tree.js';
|
|
3
2
|
import type { User } from '../User.js';
|
|
4
3
|
import type { RemoveFileMutation, UploadFileMutation } from './Mutation.js';
|
|
5
4
|
export interface AddContent extends ChangeFile {
|
|
@@ -17,7 +16,5 @@ export interface CommitRequest {
|
|
|
17
16
|
user?: User;
|
|
18
17
|
fromSha: string;
|
|
19
18
|
intoSha: string;
|
|
20
|
-
checks: Array<[path: string, sha: string]>;
|
|
21
19
|
changes: Array<CommitChange>;
|
|
22
20
|
}
|
|
23
|
-
export declare function checkCommit(tree: ReadonlyTree, request: CommitRequest): void;
|
|
@@ -40,16 +40,7 @@ function sourceChanges(request) {
|
|
|
40
40
|
})
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
function checkCommit(tree, request) {
|
|
44
|
-
if (tree.sha === request.fromSha) return;
|
|
45
|
-
for (const [path, sha] of request.checks) {
|
|
46
|
-
const entry = tree.get(path);
|
|
47
|
-
if (!entry) throw new Error(`Missing entry for ${path}`);
|
|
48
|
-
if (entry.sha !== sha) throw new Error(`Entry ${path} has changed`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
43
|
export {
|
|
52
|
-
checkCommit,
|
|
53
44
|
commitChanges,
|
|
54
45
|
sourceChanges
|
|
55
46
|
};
|
package/dist/core/db/EntryDB.js
CHANGED
|
@@ -13,7 +13,7 @@ var EntryDB = class extends LocalDB {
|
|
|
13
13
|
async mutate(mutations) {
|
|
14
14
|
const from = await this.source.getTree();
|
|
15
15
|
const tx = new EntryTransaction(this.config, this.index, this.source, from);
|
|
16
|
-
tx.apply(mutations);
|
|
16
|
+
await tx.apply(mutations);
|
|
17
17
|
const request = await tx.toRequest();
|
|
18
18
|
const contentChanges = sourceChanges(request);
|
|
19
19
|
const sha = this.indexChanges(contentChanges);
|
|
@@ -19,12 +19,20 @@ export interface EntryCondition {
|
|
|
19
19
|
language?(language: EntryLanguageNode): boolean;
|
|
20
20
|
entry?(entry: Entry): boolean;
|
|
21
21
|
}
|
|
22
|
+
interface EntryNodeQuery {
|
|
23
|
+
ids?: ReadonlyArray<string>;
|
|
24
|
+
parentIds?: ReadonlyArray<string | null>;
|
|
25
|
+
urls?: ReadonlyArray<string>;
|
|
26
|
+
workspaces?: ReadonlyArray<string>;
|
|
27
|
+
roots?: ReadonlyArray<string>;
|
|
28
|
+
types?: ReadonlyArray<string>;
|
|
29
|
+
}
|
|
22
30
|
export declare function combineConditions(a: EntryCondition, b: EntryCondition): EntryCondition;
|
|
23
31
|
interface EntryVersionData {
|
|
24
32
|
id: string;
|
|
25
33
|
type: string;
|
|
26
34
|
index: string;
|
|
27
|
-
searchableText
|
|
35
|
+
searchableText?: string;
|
|
28
36
|
title: string;
|
|
29
37
|
data: Record<string, unknown>;
|
|
30
38
|
seeded: string | null;
|
|
@@ -92,6 +100,7 @@ export declare class EntryGraph {
|
|
|
92
100
|
nodes: Array<EntryNode>;
|
|
93
101
|
constructor(config: Config, versionData: Map<string, EntryVersionData>, seeds: Map<string, Seed>);
|
|
94
102
|
byId(id: string): EntryNode | undefined;
|
|
103
|
+
candidateNodes(query: EntryNodeQuery): Array<EntryNode> | undefined;
|
|
95
104
|
get config(): Config;
|
|
96
105
|
byDir(dir: string): EntryNode | undefined;
|
|
97
106
|
entryByFilePath(filePath: string): Entry | undefined;
|
|
@@ -104,6 +113,7 @@ export declare class EntryIndex extends EventTarget {
|
|
|
104
113
|
initialSync: ReadonlyTree | undefined;
|
|
105
114
|
graph: EntryGraph;
|
|
106
115
|
constructor(config: Config);
|
|
116
|
+
clone(): EntryIndex;
|
|
107
117
|
get sha(): string;
|
|
108
118
|
filter(filter: EntryCondition): Iterable<Entry>;
|
|
109
119
|
findFirst<T extends Record<string, unknown>>(filter: (entry: Entry) => boolean): Entry<T> | undefined;
|
|
@@ -113,7 +123,7 @@ export declare class EntryIndex extends EventTarget {
|
|
|
113
123
|
get references(): Promise<EntryReferenceIndex>;
|
|
114
124
|
sync(source: Source): Promise<string>;
|
|
115
125
|
syncWith(source: Source): Promise<string>;
|
|
116
|
-
indexChanges(batch: ChangesBatch): Promise<string>;
|
|
126
|
+
indexChanges(batch: ChangesBatch, targetTree?: ReadonlyTree): Promise<string>;
|
|
117
127
|
seed(source: Source): Promise<void>;
|
|
118
128
|
byId(id: string): EntryNode | undefined;
|
|
119
129
|
fix(source: Source): Promise<void>;
|
|
@@ -1840,7 +1840,7 @@ import { IndexEvent } from "./IndexEvent.js";
|
|
|
1840
1840
|
function combineConditions(a, b) {
|
|
1841
1841
|
return {
|
|
1842
1842
|
search: a.search ?? b.search,
|
|
1843
|
-
nodes: a.nodes
|
|
1843
|
+
nodes: combineNodes(a.nodes, b.nodes),
|
|
1844
1844
|
node(node) {
|
|
1845
1845
|
return (a.node ? a.node(node) : true) && (b.node ? b.node(node) : true);
|
|
1846
1846
|
},
|
|
@@ -1852,6 +1852,14 @@ function combineConditions(a, b) {
|
|
|
1852
1852
|
}
|
|
1853
1853
|
};
|
|
1854
1854
|
}
|
|
1855
|
+
function combineNodes(a, b) {
|
|
1856
|
+
if (!a) return b;
|
|
1857
|
+
if (!b) return a;
|
|
1858
|
+
return matchingNodes(b, new Set(a));
|
|
1859
|
+
}
|
|
1860
|
+
function* matchingNodes(nodes, included) {
|
|
1861
|
+
for (const node of nodes) if (included.has(node)) yield node;
|
|
1862
|
+
}
|
|
1855
1863
|
var EntryLanguage = class extends Map {
|
|
1856
1864
|
locale;
|
|
1857
1865
|
parentDir;
|
|
@@ -1940,6 +1948,8 @@ var EntryLanguageNode = class {
|
|
|
1940
1948
|
assert(active, `EntryLanguageNode missing active version`);
|
|
1941
1949
|
this.active = active;
|
|
1942
1950
|
this.url = entryUrl(node.entryType, {
|
|
1951
|
+
config: node.graph.config,
|
|
1952
|
+
data: main.data,
|
|
1943
1953
|
status: main.status,
|
|
1944
1954
|
path: main.path,
|
|
1945
1955
|
parentPaths: this.parentPaths,
|
|
@@ -1979,6 +1989,7 @@ var EntryLanguageNode = class {
|
|
|
1979
1989
|
}
|
|
1980
1990
|
get entries() {
|
|
1981
1991
|
if (this.#entries) return this.#entries;
|
|
1992
|
+
const entryType = this.node.entryType;
|
|
1982
1993
|
const entries2 = (this.inheritedStatus ? [this.active] : [...this.language.values()]).map((version) => {
|
|
1983
1994
|
return {
|
|
1984
1995
|
...version,
|
|
@@ -1987,7 +1998,13 @@ var EntryLanguageNode = class {
|
|
|
1987
1998
|
parents: this.node.parents,
|
|
1988
1999
|
url: this.url,
|
|
1989
2000
|
active: version === this.active,
|
|
1990
|
-
main: version === this.main
|
|
2001
|
+
main: version === this.main,
|
|
2002
|
+
get searchableText() {
|
|
2003
|
+
return version.searchableText ??= Type.searchableText(
|
|
2004
|
+
entryType,
|
|
2005
|
+
version.data
|
|
2006
|
+
);
|
|
2007
|
+
}
|
|
1991
2008
|
};
|
|
1992
2009
|
});
|
|
1993
2010
|
this.#entries = entries2;
|
|
@@ -2073,7 +2090,16 @@ var EntryGraph = class _EntryGraph {
|
|
|
2073
2090
|
#filesById = /* @__PURE__ */ new Map();
|
|
2074
2091
|
#byId = /* @__PURE__ */ new Map();
|
|
2075
2092
|
#byDir = /* @__PURE__ */ new Map();
|
|
2076
|
-
#
|
|
2093
|
+
#nodesBy = {
|
|
2094
|
+
parentId: /* @__PURE__ */ new Map(),
|
|
2095
|
+
url: /* @__PURE__ */ new Map(),
|
|
2096
|
+
workspace: /* @__PURE__ */ new Map(),
|
|
2097
|
+
root: /* @__PURE__ */ new Map(),
|
|
2098
|
+
type: /* @__PURE__ */ new Map(),
|
|
2099
|
+
workspaceRoot: /* @__PURE__ */ new Map(),
|
|
2100
|
+
workspaceRootType: /* @__PURE__ */ new Map()
|
|
2101
|
+
};
|
|
2102
|
+
#nodeOrder = /* @__PURE__ */ new Map();
|
|
2077
2103
|
nodes;
|
|
2078
2104
|
#singleWorkspace;
|
|
2079
2105
|
#search;
|
|
@@ -2097,16 +2123,92 @@ var EntryGraph = class _EntryGraph {
|
|
|
2097
2123
|
this.#byDir.set(dir, version.id);
|
|
2098
2124
|
}
|
|
2099
2125
|
this.nodes = [...this.#filesById.keys()].map((file) => this.#mkNode(file)).sort((a, b) => compareStrings(a.index, b.index));
|
|
2100
|
-
for (const node of this.nodes) {
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
children.push(node);
|
|
2104
|
-
this.#childrenByParentId.set(node.parentId, children);
|
|
2126
|
+
for (const [order, node] of this.nodes.entries()) {
|
|
2127
|
+
this.#nodeOrder.set(node, order);
|
|
2128
|
+
this.#indexNode(node);
|
|
2105
2129
|
}
|
|
2106
2130
|
}
|
|
2107
2131
|
byId(id) {
|
|
2108
2132
|
return this.#byId.get(id);
|
|
2109
2133
|
}
|
|
2134
|
+
candidateNodes(query) {
|
|
2135
|
+
const candidates = [];
|
|
2136
|
+
const { ids, parentIds, urls, workspaces, roots, types } = query;
|
|
2137
|
+
if (ids) {
|
|
2138
|
+
const nodes = ids.flatMap((id) => this.byId(id) ?? []);
|
|
2139
|
+
return this.#ordered(nodes).filter((node) => this.#matches(node, query));
|
|
2140
|
+
}
|
|
2141
|
+
if (parentIds)
|
|
2142
|
+
candidates.push(this.#fromIndex(this.#nodesBy.parentId, parentIds));
|
|
2143
|
+
if (urls) candidates.push(this.#fromIndex(this.#nodesBy.url, urls));
|
|
2144
|
+
if (workspaces && roots && types) {
|
|
2145
|
+
const keys2 = workspaces.flatMap(
|
|
2146
|
+
(workspace) => roots.flatMap(
|
|
2147
|
+
(root) => types.map((type) => indexKey(workspace, root, type))
|
|
2148
|
+
)
|
|
2149
|
+
);
|
|
2150
|
+
candidates.push(this.#fromIndex(this.#nodesBy.workspaceRootType, keys2));
|
|
2151
|
+
} else if (workspaces && roots) {
|
|
2152
|
+
const keys2 = workspaces.flatMap(
|
|
2153
|
+
(workspace) => roots.map((root) => indexKey(workspace, root))
|
|
2154
|
+
);
|
|
2155
|
+
candidates.push(this.#fromIndex(this.#nodesBy.workspaceRoot, keys2));
|
|
2156
|
+
} else {
|
|
2157
|
+
if (workspaces)
|
|
2158
|
+
candidates.push(this.#fromIndex(this.#nodesBy.workspace, workspaces));
|
|
2159
|
+
if (roots) candidates.push(this.#fromIndex(this.#nodesBy.root, roots));
|
|
2160
|
+
if (types) candidates.push(this.#fromIndex(this.#nodesBy.type, types));
|
|
2161
|
+
}
|
|
2162
|
+
if (candidates.length === 0) return void 0;
|
|
2163
|
+
candidates.sort((a, b) => a.length - b.length);
|
|
2164
|
+
const [smallest, ...rest] = candidates;
|
|
2165
|
+
const intersection = rest.reduce(
|
|
2166
|
+
(result, nodes) => result.intersection(new Set(nodes)),
|
|
2167
|
+
new Set(smallest)
|
|
2168
|
+
);
|
|
2169
|
+
return Array.from(intersection);
|
|
2170
|
+
}
|
|
2171
|
+
#matches(node, query) {
|
|
2172
|
+
const { parentIds, urls, workspaces, roots, types } = query;
|
|
2173
|
+
if (parentIds && !parentIds.includes(node.parentId)) return false;
|
|
2174
|
+
if (workspaces && !workspaces.includes(node.workspace)) return false;
|
|
2175
|
+
if (roots && !roots.includes(node.root)) return false;
|
|
2176
|
+
if (types && !types.includes(node.type)) return false;
|
|
2177
|
+
if (urls) {
|
|
2178
|
+
const matchesUrl = Array.from(node.values()).some(
|
|
2179
|
+
(language) => urls.includes(language.url)
|
|
2180
|
+
);
|
|
2181
|
+
if (!matchesUrl) return false;
|
|
2182
|
+
}
|
|
2183
|
+
return true;
|
|
2184
|
+
}
|
|
2185
|
+
#indexNode(node) {
|
|
2186
|
+
addToIndex(this.#nodesBy.parentId, node.parentId, node);
|
|
2187
|
+
addToIndex(this.#nodesBy.workspace, node.workspace, node);
|
|
2188
|
+
addToIndex(this.#nodesBy.root, node.root, node);
|
|
2189
|
+
addToIndex(this.#nodesBy.type, node.type, node);
|
|
2190
|
+
addToIndex(
|
|
2191
|
+
this.#nodesBy.workspaceRoot,
|
|
2192
|
+
indexKey(node.workspace, node.root),
|
|
2193
|
+
node
|
|
2194
|
+
);
|
|
2195
|
+
addToIndex(
|
|
2196
|
+
this.#nodesBy.workspaceRootType,
|
|
2197
|
+
indexKey(node.workspace, node.root, node.type),
|
|
2198
|
+
node
|
|
2199
|
+
);
|
|
2200
|
+
const urls = new Set(Array.from(node.values(), (language) => language.url));
|
|
2201
|
+
for (const url of urls) addToIndex(this.#nodesBy.url, url, node);
|
|
2202
|
+
}
|
|
2203
|
+
#fromIndex(index, keys2) {
|
|
2204
|
+
if (keys2.length === 1) return [...index.get(keys2[0]) ?? []];
|
|
2205
|
+
return this.#ordered(keys2.flatMap((key) => index.get(key) ?? []));
|
|
2206
|
+
}
|
|
2207
|
+
#ordered(nodes) {
|
|
2208
|
+
return Array.from(new Set(nodes)).sort(
|
|
2209
|
+
(a, b) => this.#nodeOrder.get(a) - this.#nodeOrder.get(b)
|
|
2210
|
+
);
|
|
2211
|
+
}
|
|
2110
2212
|
get config() {
|
|
2111
2213
|
return this.#config;
|
|
2112
2214
|
}
|
|
@@ -2258,34 +2360,34 @@ var EntryGraph = class _EntryGraph {
|
|
|
2258
2360
|
this,
|
|
2259
2361
|
type,
|
|
2260
2362
|
parent,
|
|
2261
|
-
() => this.#
|
|
2363
|
+
() => this.#nodesBy.parentId.get(id) ?? [],
|
|
2262
2364
|
collection
|
|
2263
2365
|
);
|
|
2264
2366
|
this.#byId.set(id, node);
|
|
2265
2367
|
return node;
|
|
2266
2368
|
}
|
|
2267
2369
|
};
|
|
2370
|
+
function addToIndex(index, key, node) {
|
|
2371
|
+
const nodes = index.get(key) ?? [];
|
|
2372
|
+
nodes.push(node);
|
|
2373
|
+
index.set(key, nodes);
|
|
2374
|
+
}
|
|
2375
|
+
function indexKey(...parts) {
|
|
2376
|
+
return JSON.stringify(parts);
|
|
2377
|
+
}
|
|
2268
2378
|
var VersionParser = class extends Map {
|
|
2269
|
-
#config;
|
|
2270
|
-
constructor(config) {
|
|
2271
|
-
super();
|
|
2272
|
-
this.#config = config;
|
|
2273
|
-
}
|
|
2274
2379
|
parse(sha, blob) {
|
|
2275
2380
|
if (super.has(sha)) return super.get(sha);
|
|
2276
2381
|
const decoder = new TextDecoder();
|
|
2277
2382
|
const text = decoder.decode(blob);
|
|
2278
2383
|
const raw = JSON.parse(text);
|
|
2279
2384
|
const { meta, data } = parseRecord(raw);
|
|
2280
|
-
const entryType = this.#config.schema[meta.type];
|
|
2281
|
-
const searchableText = Type.searchableText(entryType, data);
|
|
2282
2385
|
const version = {
|
|
2283
2386
|
id: meta.id,
|
|
2284
2387
|
type: meta.type,
|
|
2285
2388
|
index: meta.index,
|
|
2286
2389
|
data,
|
|
2287
2390
|
title: data.title,
|
|
2288
|
-
searchableText,
|
|
2289
2391
|
seeded: meta.seeded ?? null,
|
|
2290
2392
|
rowHash: sha,
|
|
2291
2393
|
fileHash: sha
|
|
@@ -2296,7 +2398,7 @@ var VersionParser = class extends Map {
|
|
|
2296
2398
|
};
|
|
2297
2399
|
var ParserCache = class extends WeakMap {
|
|
2298
2400
|
get = (config) => {
|
|
2299
|
-
if (!this.has(config)) this.set(config, new VersionParser(
|
|
2401
|
+
if (!this.has(config)) this.set(config, new VersionParser());
|
|
2300
2402
|
return super.get(config);
|
|
2301
2403
|
};
|
|
2302
2404
|
};
|
|
@@ -2334,7 +2436,7 @@ function changedParentIds(previous, next) {
|
|
|
2334
2436
|
}
|
|
2335
2437
|
return parents;
|
|
2336
2438
|
}
|
|
2337
|
-
var EntryIndex = class extends EventTarget {
|
|
2439
|
+
var EntryIndex = class _EntryIndex extends EventTarget {
|
|
2338
2440
|
tree = ReadonlyTree.EMPTY;
|
|
2339
2441
|
initialSync;
|
|
2340
2442
|
graph;
|
|
@@ -2351,6 +2453,13 @@ var EntryIndex = class extends EventTarget {
|
|
|
2351
2453
|
this.graph = new EntryGraph(config, /* @__PURE__ */ new Map(), this.#seeds);
|
|
2352
2454
|
this.#singleWorkspace = Config.multipleWorkspaces(config) ? void 0 : keys(config.workspaces)[0];
|
|
2353
2455
|
}
|
|
2456
|
+
clone() {
|
|
2457
|
+
const clone = new _EntryIndex(this.#config);
|
|
2458
|
+
clone.tree = this.tree;
|
|
2459
|
+
clone.initialSync = this.initialSync;
|
|
2460
|
+
clone.graph = this.graph;
|
|
2461
|
+
return clone;
|
|
2462
|
+
}
|
|
2354
2463
|
get sha() {
|
|
2355
2464
|
return this.tree.sha;
|
|
2356
2465
|
}
|
|
@@ -2396,9 +2505,9 @@ var EntryIndex = class extends EventTarget {
|
|
|
2396
2505
|
if (!this.initialSync) this.initialSync = tree;
|
|
2397
2506
|
const batch = await bundleContents(source, this.tree.diff(tree));
|
|
2398
2507
|
if (batch.changes.length === 0) return tree.sha;
|
|
2399
|
-
return this.indexChanges(batch);
|
|
2508
|
+
return this.indexChanges(batch, tree);
|
|
2400
2509
|
}
|
|
2401
|
-
async indexChanges(batch) {
|
|
2510
|
+
async indexChanges(batch, targetTree) {
|
|
2402
2511
|
const { fromSha, changes } = batch;
|
|
2403
2512
|
if (fromSha !== this.tree.sha)
|
|
2404
2513
|
throw new ShaMismatchError(fromSha, this.tree.sha);
|
|
@@ -2442,7 +2551,7 @@ var EntryIndex = class extends EventTarget {
|
|
|
2442
2551
|
}
|
|
2443
2552
|
}
|
|
2444
2553
|
}
|
|
2445
|
-
const updatedTree = await this.tree.withChanges(batch);
|
|
2554
|
+
const updatedTree = targetTree ?? await this.tree.withChanges(batch);
|
|
2446
2555
|
const sha = updatedTree.sha;
|
|
2447
2556
|
this.tree = updatedTree;
|
|
2448
2557
|
const affectedParentIds = changedParentIds(previousRelations, nextRelations);
|