@mdbase-dev/connect 0.1.0-beta.119 → 0.1.0-beta.121
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/browser/integrity.json +1 -1
- package/dist/browser/mdbase-connect.min.js +2 -2
- package/dist/browser/mdbase-connect.min.js.sha384 +1 -1
- package/dist/collection-client.js +0 -5
- package/dist/operation-types.d.ts +0 -5
- package/dist/record-session.d.ts +5 -0
- package/dist/record-session.js +16 -3
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
sha384-
|
|
1
|
+
sha384-Nv0Du948fR/kSC/QXiny8mY1SZ2akUFBT7QmsPb3irgnUGNN0LgsWDubjxozn5cU
|
|
@@ -617,11 +617,6 @@ function wireCollectionSetupAssessment(value) {
|
|
|
617
617
|
provisionDigest: value.provision_digest,
|
|
618
618
|
collectionRevision: value.collection_revision,
|
|
619
619
|
finalCollectionRevision: value.final_collection_revision,
|
|
620
|
-
baselineDiagnosticCount: value.baseline_diagnostic_count,
|
|
621
|
-
finalDiagnosticCount: value.final_diagnostic_count,
|
|
622
|
-
resolvedDiagnosticCount: value.resolved_diagnostic_count,
|
|
623
|
-
introducedDiagnosticCount: value.introduced_diagnostic_count,
|
|
624
|
-
baselineDiagnosticDigest: value.baseline_diagnostic_digest,
|
|
625
620
|
configuration: value.configuration,
|
|
626
621
|
typePacks: value.type_packs.map(wireTypePackAssessment),
|
|
627
622
|
finalResourceRevisions: value.final_resource_revisions,
|
|
@@ -580,11 +580,6 @@ export interface CollectionSetupAssessment {
|
|
|
580
580
|
provisionDigest: string;
|
|
581
581
|
collectionRevision: string;
|
|
582
582
|
finalCollectionRevision: string;
|
|
583
|
-
baselineDiagnosticCount: number;
|
|
584
|
-
finalDiagnosticCount: number;
|
|
585
|
-
resolvedDiagnosticCount: number;
|
|
586
|
-
introducedDiagnosticCount: number;
|
|
587
|
-
baselineDiagnosticDigest: string;
|
|
588
583
|
configuration: ConfigurationSetupAssessment[];
|
|
589
584
|
typePacks: TypePackAssessment[];
|
|
590
585
|
finalResourceRevisions: Record<string, string>;
|
package/dist/record-session.d.ts
CHANGED
|
@@ -87,6 +87,7 @@ export declare class MdbaseRecordSession<R> {
|
|
|
87
87
|
private inFlight;
|
|
88
88
|
private timer;
|
|
89
89
|
private lastEdit;
|
|
90
|
+
private disposed;
|
|
90
91
|
private readonly idleMs;
|
|
91
92
|
private current;
|
|
92
93
|
constructor(record: R, adapter: MdbaseRecordSessionAdapter<R>, options?: MdbaseRecordSessionOptions);
|
|
@@ -104,6 +105,8 @@ export declare class MdbaseRecordSession<R> {
|
|
|
104
105
|
restore(draft: {
|
|
105
106
|
body: string;
|
|
106
107
|
baseBody?: string;
|
|
108
|
+
patch?: JsonObject;
|
|
109
|
+
baseFrontmatter?: JsonObject;
|
|
107
110
|
}): void;
|
|
108
111
|
/**
|
|
109
112
|
* Continue a write interrupted before this session existed, such as one
|
|
@@ -111,6 +114,8 @@ export declare class MdbaseRecordSession<R> {
|
|
|
111
114
|
* settles; with autosave, recovery is attempted after one idle interval.
|
|
112
115
|
*/
|
|
113
116
|
resumeRecovery(requestId: string): void;
|
|
117
|
+
/** Stop automatic writes and subscriptions when the owning view closes. In-flight writes still settle. */
|
|
118
|
+
dispose(): void;
|
|
114
119
|
/** Schedule an autosave one idle interval from now. */
|
|
115
120
|
autosave(): void;
|
|
116
121
|
/**
|
package/dist/record-session.js
CHANGED
|
@@ -26,6 +26,7 @@ export class MdbaseRecordSession {
|
|
|
26
26
|
inFlight;
|
|
27
27
|
timer;
|
|
28
28
|
lastEdit = 0;
|
|
29
|
+
disposed = false;
|
|
29
30
|
idleMs;
|
|
30
31
|
current;
|
|
31
32
|
constructor(record, adapter, options = {}) {
|
|
@@ -62,11 +63,17 @@ export class MdbaseRecordSession {
|
|
|
62
63
|
*/
|
|
63
64
|
restore(draft) {
|
|
64
65
|
const current = this.adapter.body(this.record);
|
|
65
|
-
|
|
66
|
+
const frontmatter = this.adapter.frontmatter?.(this.record) ?? {};
|
|
67
|
+
const patch = Object.fromEntries(Object.entries(draft.patch ?? {}).filter(([key, value]) => JSON.stringify(frontmatter[key] ?? null) !== JSON.stringify(value)));
|
|
68
|
+
if (draft.body === current && Object.keys(patch).length === 0)
|
|
66
69
|
return;
|
|
67
70
|
this.body = draft.body;
|
|
68
|
-
|
|
71
|
+
this.patch = patch;
|
|
72
|
+
if ((draft.body !== current && draft.baseBody !== current)
|
|
73
|
+
|| Object.keys(patch).some((key) => !draft.baseFrontmatter
|
|
74
|
+
|| JSON.stringify(draft.baseFrontmatter[key] ?? null) !== JSON.stringify(frontmatter[key] ?? null))) {
|
|
69
75
|
this.remote = this.record;
|
|
76
|
+
}
|
|
70
77
|
this.emit();
|
|
71
78
|
}
|
|
72
79
|
/**
|
|
@@ -81,6 +88,12 @@ export class MdbaseRecordSession {
|
|
|
81
88
|
this.emit();
|
|
82
89
|
this.autosave();
|
|
83
90
|
}
|
|
91
|
+
/** Stop automatic writes and subscriptions when the owning view closes. In-flight writes still settle. */
|
|
92
|
+
dispose() {
|
|
93
|
+
this.disposed = true;
|
|
94
|
+
clearTimeout(this.timer);
|
|
95
|
+
this.listeners.clear();
|
|
96
|
+
}
|
|
84
97
|
/** Schedule an autosave one idle interval from now. */
|
|
85
98
|
autosave() {
|
|
86
99
|
this.lastEdit = Date.now();
|
|
@@ -227,7 +240,7 @@ export class MdbaseRecordSession {
|
|
|
227
240
|
}
|
|
228
241
|
schedule() {
|
|
229
242
|
clearTimeout(this.timer);
|
|
230
|
-
if (this.idleMs === undefined || this.remote || this.deleted)
|
|
243
|
+
if (this.disposed || this.idleMs === undefined || this.remote || this.deleted)
|
|
231
244
|
return;
|
|
232
245
|
const delay = Math.max(0, this.lastEdit + this.idleMs - Date.now());
|
|
233
246
|
this.timer = setTimeout(() => void this.save(), delay);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mdbase-dev/connect",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.121",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"README.md"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@mdbase-dev/connect-protocol": "0.1.0-beta.
|
|
36
|
+
"@mdbase-dev/connect-protocol": "0.1.0-beta.121"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"esbuild": "^0.28.1",
|