@dialecte/core 0.4.8 → 0.4.9
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/document/document.d.ts +7 -0
- package/dist/document/document.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/project/project.d.ts +24 -13
- package/dist/project/project.d.ts.map +1 -1
- package/dist/{project-DxIu-3AU.js → project-D-KS3OPN.js} +24 -16
- package/dist/test.js +1 -1
- package/package.json +1 -1
|
@@ -38,12 +38,19 @@ export declare class Document<GenericConfig extends AnyDialecteConfig, GenericEx
|
|
|
38
38
|
readonly channelName: string;
|
|
39
39
|
/** Announce a mutation on the project channel (provided by the owning Project) */
|
|
40
40
|
private notify;
|
|
41
|
+
/**
|
|
42
|
+
* Recompute this document's canUndo/canRedo on the shared project entry
|
|
43
|
+
* (provided by the owning Project). Called locally after a commit so the
|
|
44
|
+
* flags are up to date synchronously, without depending on a channel echo.
|
|
45
|
+
*/
|
|
46
|
+
private refreshHistoryStatus;
|
|
41
47
|
/** Track concurrent transactions to manage loading flag */
|
|
42
48
|
private activeTransactions;
|
|
43
49
|
constructor(store: Store, config: GenericConfig, documentId: string, extensions: GenericExtension | undefined, hooks: DialecteHooks<GenericConfig> | undefined, project: {
|
|
44
50
|
state: DocumentState;
|
|
45
51
|
channelName: string;
|
|
46
52
|
notify: (message: ProjectChannelMessage) => void;
|
|
53
|
+
refreshHistoryStatus: () => Promise<void>;
|
|
47
54
|
});
|
|
48
55
|
private withQueryExtensions;
|
|
49
56
|
private withAllExtensions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/document/document.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAI3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;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as f, M as p, N as m, O as h, P as g, Q as _, R as v, S as y, T as b, U as x, V as S, W as C, X as w, Y as T, Z as E, _ as D, a as O, at as k, b as A, c as j, ct as M, d as N, et as P, f as F, g as I, h as L, i as R, it as z, j as B, k as V, l as H, lt as U, m as W, n as G, nt as K, o as q, ot as J, p as Y, q as X, r as Z, rt as Q, s as $, st as ee, t as te, tt as ne, u as re, ut as ie, v as ae, w as oe, x as se, y as ce } from "./project-
|
|
1
|
+
import { $ as e, A as t, B as n, C as r, D as i, E as a, F as o, G as s, H as c, I as l, J as u, K as d, L as f, M as p, N as m, O as h, P as g, Q as _, R as v, S as y, T as b, U as x, V as S, W as C, X as w, Y as T, Z as E, _ as D, a as O, at as k, b as A, c as j, ct as M, d as N, et as P, f as F, g as I, h as L, i as R, it as z, j as B, k as V, l as H, lt as U, m as W, n as G, nt as K, o as q, ot as J, p as Y, q as X, r as Z, rt as Q, s as $, st as ee, t as te, tt as ne, u as re, ut as ie, v as ae, w as oe, x as se, y as ce } from "./project-D-KS3OPN.js";
|
|
2
2
|
import { m as le, p as ue } from "./utils-C5_11hqg.js";
|
|
3
3
|
export { V as AnyQuery, i as AnyTransaction, N as BLOBS_SCHEMA, F as BLOB_DATA_SCHEMA, Y as CHANGELOG_SCHEMA, W as DOCUMENTS_SCHEMA, re as DexieStore, oe as Document, le as ERROR_CATALOG, H as InMemoryStore, L as META_SCHEMA, p as ParseSession, te as Project, h as Query, I as TABLE_BLOBS, D as TABLE_BLOB_PREFIX, ae as TABLE_CHANGELOG, ce as TABLE_DOCUMENTS, A as TABLE_META, se as TABLE_RECORD_PREFIX, f as TEMP_IDB_ID_ATTRIBUTE_NAME, a as Transaction, C as applyOmit, x as applyOrder, u as applyUnwrap, ie as bindExtensions, y as blobTableName, R as buildDocumentState, g as buildXmlDocument, S as collectSnapshotRecords, o as downloadFile, q as exportBlob, $ as exportDocument, K as findAncestors, P as findByAttributes, e as findDescendants, v as formatXml, E as getAttribute, _ as getAttributeFullObject, T as getAttributes, w as getAttributesFullObject, z as getChild, Q as getChildren, ee as getRecord, J as getRecords, k as getRecordsByTagName, t as getSnapshot, c as getTree, Z as importDocument, M as indexStagedDeletesByParent, G as initEmptyDocument, m as inspectXml, s as isOmitted, b as isTransactionContext, ne as matchesAttributeFilter, U as overlayAllStaged, d as parseOmit, B as parseXmlFile, O as reconcileDocumentState, r as recordTableName, n as recordsToTree, j as resolveStore, X as shouldStopTraversal, ue as throwDialecteError, l as xmlDocumentToString };
|
|
@@ -11,16 +11,18 @@ import { AnyDialecteConfig, BlobAttachment, BlobRecord, DialecteHooks } from '..
|
|
|
11
11
|
export declare class Project<GenericConfig extends AnyDialecteConfig, GenericModules extends ExtensionModules = Record<never, never>, GenericStore extends Store = Store> {
|
|
12
12
|
private _name?;
|
|
13
13
|
private _store?;
|
|
14
|
-
/** Posting side of the project channel. Never listened to. */
|
|
15
|
-
private _postChannel?;
|
|
16
14
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* the exact instance that posted it, so this
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*/
|
|
23
|
-
private
|
|
15
|
+
* The project channel: posts this realm's mutations and listens for other
|
|
16
|
+
* realms' (other tab / iframe / second Project instance). BroadcastChannel
|
|
17
|
+
* withholds a message from the exact instance that posted it, so this realm
|
|
18
|
+
* never receives its own posts — local state is maintained inline by the
|
|
19
|
+
* mutation methods, and the listener folds in only foreign messages.
|
|
20
|
+
*/
|
|
21
|
+
private _channel?;
|
|
22
|
+
/** Set once close()/destroy() begins, to stop new channel-triggered store work. */
|
|
23
|
+
private closing;
|
|
24
|
+
/** In-flight fire-and-forget work triggered by foreign messages, awaited on teardown. */
|
|
25
|
+
private readonly pendingBroadcastWork;
|
|
24
26
|
private readonly storage;
|
|
25
27
|
private configs;
|
|
26
28
|
private defaultConfigKey;
|
|
@@ -28,7 +30,7 @@ export declare class Project<GenericConfig extends AnyDialecteConfig, GenericMod
|
|
|
28
30
|
private hooks?;
|
|
29
31
|
get name(): string;
|
|
30
32
|
private get store();
|
|
31
|
-
private get
|
|
33
|
+
private get channel();
|
|
32
34
|
/**
|
|
33
35
|
* Name of this project's BroadcastChannel — the public event contract.
|
|
34
36
|
* Open your own instance (see createChannel) to receive every
|
|
@@ -59,11 +61,20 @@ export declare class Project<GenericConfig extends AnyDialecteConfig, GenericMod
|
|
|
59
61
|
*/
|
|
60
62
|
open(name: string): Promise<this>;
|
|
61
63
|
/**
|
|
62
|
-
* Fold an incoming channel message into project state.
|
|
63
|
-
* own posts
|
|
64
|
-
*
|
|
64
|
+
* Fold an incoming channel message into project state. This realm never
|
|
65
|
+
* receives its own posts (BroadcastChannel withholds them from the posting
|
|
66
|
+
* instance), so this only ever handles foreign messages — another tab, an
|
|
67
|
+
* iframe, or a second Project instance. Local mutations maintain state inline.
|
|
65
68
|
*/
|
|
66
69
|
private onChannelMessage;
|
|
70
|
+
/**
|
|
71
|
+
* Track channel-triggered fire-and-forget work so `close`/`destroy` can wait for
|
|
72
|
+
* it to settle before tearing down the store. A foreign message delivered as the
|
|
73
|
+
* project is closing would otherwise read or reconcile the store after it was
|
|
74
|
+
* closed/deleted — surfacing as DatabaseClosedError or ConstraintError. The work
|
|
75
|
+
* keeps its own error swallowing; here it is only awaited, never rethrown.
|
|
76
|
+
*/
|
|
77
|
+
private trackBroadcastWork;
|
|
67
78
|
/** Recompute canUndo/canRedo for a document from the store's history. */
|
|
68
79
|
private refreshHistoryStatus;
|
|
69
80
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/project/project.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAIrC,OAAO,KAAK,EACX,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAEhB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EAAE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AAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,KAC3E,OAAO,CAAC,MAAM,EAAE,CAAC,GACpB,OAAO,CAAC,MAAM,EAAE,CAAC;IAYpB,iHAAiH;IACjH,mBAAmB,IAAI,UAAU,CAAC,YAAY,CAAC,qBAAqB,CAAC,CAAC;YAIxD,YAAY;IAK1B;;;;;OAKG;YACW,sBAAsB;CAKpC"}
|
|
@@ -3481,7 +3481,7 @@ function Wt(e) {
|
|
|
3481
3481
|
//#region src/document/document.ts
|
|
3482
3482
|
var G = class {
|
|
3483
3483
|
constructor(e, t, n, r, i, a) {
|
|
3484
|
-
this.activeTransactions = 0, this.store = e, this.config = t, this.documentId = n, this.hooks = i, this.extensionsRegistry = r, this.state = a.state, this.channelName = a.channelName, this.notify = a.notify;
|
|
3484
|
+
this.activeTransactions = 0, this.store = e, this.config = t, this.documentId = n, this.hooks = i, this.extensionsRegistry = r, this.state = a.state, this.channelName = a.channelName, this.notify = a.notify, this.refreshHistoryStatus = a.refreshHistoryStatus;
|
|
3485
3485
|
}
|
|
3486
3486
|
withQueryExtensions(e) {
|
|
3487
3487
|
let t = te(this.extensionsRegistry?.query, e);
|
|
@@ -3513,7 +3513,7 @@ var G = class {
|
|
|
3513
3513
|
let n = this.withAllExtensions(this.createTransaction());
|
|
3514
3514
|
try {
|
|
3515
3515
|
let r = await e(n);
|
|
3516
|
-
return await n.commit(), this.notify({
|
|
3516
|
+
return await n.commit(), await this.refreshHistoryStatus(), this.notify({
|
|
3517
3517
|
type: "commit",
|
|
3518
3518
|
documentId: this.documentId,
|
|
3519
3519
|
timestamp: this.state.lastUpdate ?? Date.now()
|
|
@@ -3556,7 +3556,7 @@ var G = class {
|
|
|
3556
3556
|
if (!o) {
|
|
3557
3557
|
o = !0, this.activeTransactions++, this.state.loading = !0;
|
|
3558
3558
|
try {
|
|
3559
|
-
await n.commit(), this.notify({
|
|
3559
|
+
await n.commit(), await this.refreshHistoryStatus(), this.notify({
|
|
3560
3560
|
type: "commit",
|
|
3561
3561
|
documentId: this.documentId,
|
|
3562
3562
|
timestamp: this.state.lastUpdate ?? Date.now()
|
|
@@ -8060,11 +8060,11 @@ var Tn = class {
|
|
|
8060
8060
|
detail: "Call project.open(name) before accessing project properties."
|
|
8061
8061
|
}), this._store;
|
|
8062
8062
|
}
|
|
8063
|
-
get
|
|
8064
|
-
return o(this.
|
|
8063
|
+
get channel() {
|
|
8064
|
+
return o(this._channel !== void 0, {
|
|
8065
8065
|
key: "PROJECT_NOT_OPENED",
|
|
8066
8066
|
detail: "Call project.open(name) before accessing project properties."
|
|
8067
|
-
}), this.
|
|
8067
|
+
}), this._channel;
|
|
8068
8068
|
}
|
|
8069
8069
|
get channelName() {
|
|
8070
8070
|
return `dialecte::project::${this.name}`;
|
|
@@ -8073,10 +8073,10 @@ var Tn = class {
|
|
|
8073
8073
|
return new BroadcastChannel(this.channelName);
|
|
8074
8074
|
}
|
|
8075
8075
|
notify(e) {
|
|
8076
|
-
this.
|
|
8076
|
+
this.channel.postMessage(e);
|
|
8077
8077
|
}
|
|
8078
8078
|
constructor(e) {
|
|
8079
|
-
this.state = {
|
|
8079
|
+
this.closing = !1, this.pendingBroadcastWork = /* @__PURE__ */ new Set(), this.state = {
|
|
8080
8080
|
documents: /* @__PURE__ */ new Map(),
|
|
8081
8081
|
activeTransactions: 0
|
|
8082
8082
|
};
|
|
@@ -8087,7 +8087,7 @@ var Tn = class {
|
|
|
8087
8087
|
}) : void 0;
|
|
8088
8088
|
}
|
|
8089
8089
|
async open(e) {
|
|
8090
|
-
this._name = e, this.
|
|
8090
|
+
this._name = e, this.closing = !1, this._channel = new BroadcastChannel(this.channelName), this._channel.addEventListener("message", (e) => {
|
|
8091
8091
|
this.onChannelMessage(e.data);
|
|
8092
8092
|
});
|
|
8093
8093
|
let t = yn(e, this.storage, this.configs[this.defaultConfigKey]);
|
|
@@ -8097,30 +8097,37 @@ var Tn = class {
|
|
|
8097
8097
|
return await Promise.all(n.map((e) => this.refreshHistoryStatus(e.id))), this;
|
|
8098
8098
|
}
|
|
8099
8099
|
onChannelMessage(e) {
|
|
8100
|
-
switch (e?.type) {
|
|
8100
|
+
if (!this.closing) switch (e?.type) {
|
|
8101
8101
|
case "init-empty-document":
|
|
8102
8102
|
case "document-removed":
|
|
8103
8103
|
case "document-imported":
|
|
8104
|
-
this.reconcileFromBroadcast(e.documentId)
|
|
8104
|
+
this.trackBroadcastWork(this.reconcileFromBroadcast(e.documentId));
|
|
8105
8105
|
break;
|
|
8106
8106
|
case "commit": {
|
|
8107
8107
|
let t = this.state.documents.get(e.documentId);
|
|
8108
|
-
t && (t.lastUpdate = e.timestamp ?? Date.now()), this.refreshHistoryStatus(e.documentId)
|
|
8108
|
+
t && (t.lastUpdate = e.timestamp ?? Date.now()), this.trackBroadcastWork(this.refreshHistoryStatus(e.documentId));
|
|
8109
8109
|
break;
|
|
8110
8110
|
}
|
|
8111
8111
|
}
|
|
8112
8112
|
}
|
|
8113
|
+
trackBroadcastWork(e) {
|
|
8114
|
+
let t = e.catch(() => {}).finally(() => {
|
|
8115
|
+
this.pendingBroadcastWork.delete(t);
|
|
8116
|
+
});
|
|
8117
|
+
this.pendingBroadcastWork.add(t);
|
|
8118
|
+
}
|
|
8113
8119
|
async refreshHistoryStatus(e) {
|
|
8120
|
+
if (this.closing) return;
|
|
8114
8121
|
let t = this.state.documents.get(e);
|
|
8115
8122
|
if (!t) return;
|
|
8116
8123
|
let { canUndo: n, canRedo: r } = await this.store.getHistoryStatus(e);
|
|
8117
8124
|
t.canUndo = n, t.canRedo = r;
|
|
8118
8125
|
}
|
|
8119
8126
|
close() {
|
|
8120
|
-
this.
|
|
8127
|
+
this.closing = !0, this._channel?.close(), this.store.close();
|
|
8121
8128
|
}
|
|
8122
8129
|
async destroy() {
|
|
8123
|
-
this.
|
|
8130
|
+
this.closing = !0, this._channel?.close(), await Promise.allSettled(this.pendingBroadcastWork), await this.store.destroy(), this.state.documents.clear();
|
|
8124
8131
|
}
|
|
8125
8132
|
async initEmptyDocument(e) {
|
|
8126
8133
|
let t = await wn({
|
|
@@ -8188,7 +8195,8 @@ var Tn = class {
|
|
|
8188
8195
|
return new G(this.store, n, e, this.mergedExtensions, this.hooks, {
|
|
8189
8196
|
state: t,
|
|
8190
8197
|
channelName: this.channelName,
|
|
8191
|
-
notify: (e) => this.notify(e)
|
|
8198
|
+
notify: (e) => this.notify(e),
|
|
8199
|
+
refreshHistoryStatus: () => this.refreshHistoryStatus(e)
|
|
8192
8200
|
});
|
|
8193
8201
|
}
|
|
8194
8202
|
async getDocumentStatus(e) {
|
|
@@ -8310,7 +8318,7 @@ var Tn = class {
|
|
|
8310
8318
|
Sn(this.state.documents, e);
|
|
8311
8319
|
}
|
|
8312
8320
|
async reconcileFromBroadcast(e) {
|
|
8313
|
-
await this.store.reconcile(e), await this.refreshState();
|
|
8321
|
+
this.closing || (await this.store.reconcile(e), await this.refreshState());
|
|
8314
8322
|
}
|
|
8315
8323
|
};
|
|
8316
8324
|
//#endregion
|
package/dist/test.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dt as e, t, u as n, z as r } from "./project-
|
|
1
|
+
import { dt as e, t, u as n, z as r } from "./project-D-KS3OPN.js";
|
|
2
2
|
import { DIALECTE_NAMESPACES as i, standardizeRecord as a, toTrackedRecord as o, toTreeRecord as s } from "./helpers.js";
|
|
3
3
|
import { expect as c, it as l } from "vitest";
|
|
4
4
|
//#region src/test/assert-xml/xpath-parser.ts
|