@canonical/dataviews-core 0.45.0 → 0.47.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.
- package/LICENSE +166 -0
- package/package.json +4 -3
- package/dist/esm/lib/collection/createCollectionCoordinator.js +0 -202
- package/dist/esm/lib/collection/createCollectionCoordinator.js.map +0 -1
- package/dist/esm/lib/collection/createSaveSession.js +0 -103
- package/dist/esm/lib/collection/createSaveSession.js.map +0 -1
- package/dist/esm/lib/createIdentity.js +0 -22
- package/dist/esm/lib/createIdentity.js.map +0 -1
- package/dist/esm/lib/field/createFieldInteraction.js +0 -80
- package/dist/esm/lib/field/createFieldInteraction.js.map +0 -1
- package/dist/esm/lib/field/index.js +0 -2
- package/dist/esm/lib/field/index.js.map +0 -1
- package/dist/esm/lib/geometry/columnTemplate.js +0 -38
- package/dist/esm/lib/geometry/columnTemplate.js.map +0 -1
- package/dist/esm/lib/geometry/createPresentation.js +0 -79
- package/dist/esm/lib/geometry/createPresentation.js.map +0 -1
- package/dist/esm/lib/geometry/sizingEquals.js +0 -10
- package/dist/esm/lib/geometry/sizingEquals.js.map +0 -1
- package/dist/esm/lib/identityBrand.js +0 -3
- package/dist/esm/lib/identityBrand.js.map +0 -1
- package/dist/esm/lib/isIdentity.js +0 -15
- package/dist/esm/lib/isIdentity.js.map +0 -1
- package/dist/esm/lib/location/createLocationBinding.js +0 -214
- package/dist/esm/lib/location/createLocationBinding.js.map +0 -1
- package/dist/esm/lib/operation/createOperation.js +0 -83
- package/dist/esm/lib/operation/createOperation.js.map +0 -1
- package/dist/esm/lib/operation/index.js +0 -2
- package/dist/esm/lib/operation/index.js.map +0 -1
- package/dist/esm/lib/query/canonicalSlice.js +0 -64
- package/dist/esm/lib/query/canonicalSlice.js.map +0 -1
- package/dist/esm/lib/query/defaultWindow.js +0 -11
- package/dist/esm/lib/query/defaultWindow.js.map +0 -1
- package/dist/esm/lib/query/sliceEquals.js +0 -30
- package/dist/esm/lib/query/sliceEquals.js.map +0 -1
- package/dist/esm/lib/source/createSourceBinding.js +0 -192
- package/dist/esm/lib/source/createSourceBinding.js.map +0 -1
- package/dist/esm/lib/source/reasonOf.js +0 -11
- package/dist/esm/lib/source/reasonOf.js.map +0 -1
- package/dist/esm/lib/source/supportsSlice.js +0 -68
- package/dist/esm/lib/source/supportsSlice.js.map +0 -1
- package/dist/esm/lib/views/createIndexedDBViewStore.js +0 -513
- package/dist/esm/lib/views/createIndexedDBViewStore.js.map +0 -1
- package/dist/esm/lib/views/createProviderViews.js +0 -573
- package/dist/esm/lib/views/createProviderViews.js.map +0 -1
- package/dist/esm/lib/wire/wireGrammar.js +0 -59
- package/dist/esm/lib/wire/wireGrammar.js.map +0 -1
- package/dist/types/lib/collection/createCollectionCoordinator.d.ts +0 -115
- package/dist/types/lib/collection/createCollectionCoordinator.d.ts.map +0 -1
- package/dist/types/lib/collection/createSaveSession.d.ts +0 -64
- package/dist/types/lib/collection/createSaveSession.d.ts.map +0 -1
- package/dist/types/lib/createIdentity.d.ts +0 -20
- package/dist/types/lib/createIdentity.d.ts.map +0 -1
- package/dist/types/lib/field/createFieldInteraction.d.ts +0 -77
- package/dist/types/lib/field/createFieldInteraction.d.ts.map +0 -1
- package/dist/types/lib/field/index.d.ts +0 -3
- package/dist/types/lib/field/index.d.ts.map +0 -1
- package/dist/types/lib/geometry/columnTemplate.d.ts +0 -21
- package/dist/types/lib/geometry/columnTemplate.d.ts.map +0 -1
- package/dist/types/lib/geometry/createPresentation.d.ts +0 -32
- package/dist/types/lib/geometry/createPresentation.d.ts.map +0 -1
- package/dist/types/lib/geometry/sizingEquals.d.ts +0 -4
- package/dist/types/lib/geometry/sizingEquals.d.ts.map +0 -1
- package/dist/types/lib/identityBrand.d.ts +0 -3
- package/dist/types/lib/identityBrand.d.ts.map +0 -1
- package/dist/types/lib/isIdentity.d.ts +0 -11
- package/dist/types/lib/isIdentity.d.ts.map +0 -1
- package/dist/types/lib/location/createLocationBinding.d.ts +0 -77
- package/dist/types/lib/location/createLocationBinding.d.ts.map +0 -1
- package/dist/types/lib/operation/createOperation.d.ts +0 -62
- package/dist/types/lib/operation/createOperation.d.ts.map +0 -1
- package/dist/types/lib/operation/index.d.ts +0 -3
- package/dist/types/lib/operation/index.d.ts.map +0 -1
- package/dist/types/lib/query/canonicalSlice.d.ts +0 -17
- package/dist/types/lib/query/canonicalSlice.d.ts.map +0 -1
- package/dist/types/lib/query/defaultWindow.d.ts +0 -9
- package/dist/types/lib/query/defaultWindow.d.ts.map +0 -1
- package/dist/types/lib/query/sliceEquals.d.ts +0 -7
- package/dist/types/lib/query/sliceEquals.d.ts.map +0 -1
- package/dist/types/lib/source/createSourceBinding.d.ts +0 -66
- package/dist/types/lib/source/createSourceBinding.d.ts.map +0 -1
- package/dist/types/lib/source/reasonOf.d.ts +0 -3
- package/dist/types/lib/source/reasonOf.d.ts.map +0 -1
- package/dist/types/lib/source/supportsSlice.d.ts +0 -9
- package/dist/types/lib/source/supportsSlice.d.ts.map +0 -1
- package/dist/types/lib/views/createIndexedDBViewStore.d.ts +0 -90
- package/dist/types/lib/views/createIndexedDBViewStore.d.ts.map +0 -1
- package/dist/types/lib/views/createProviderViews.d.ts +0 -53
- package/dist/types/lib/views/createProviderViews.d.ts.map +0 -1
- package/dist/types/lib/wire/wireGrammar.d.ts +0 -31
- package/dist/types/lib/wire/wireGrammar.d.ts.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
|
166
|
+
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/dataviews-core",
|
|
3
3
|
"description": "Framework-agnostic collection-views core for Canonical apps: query grammar, schema-enforced field validation, observation channels, selection and window projection, lifecycle transition records, the request-lifecycle coordinator, the provider assembling them, the Location port with the flat URL query grammar and the authority loop that keeps them in step, and the source contract with its local-array, observable-query-client and Relay forward-connection sources, the provider's saved views over a store it is given and its presentation — column widths, order and visibility — over a presentation store or in memory, an explicitly imported local-first IndexedDB store implementing both, and the explicitly imported virtual range a virtualized table mounts its rows by",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.47.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@biomejs/biome": "2.5.15",
|
|
61
61
|
"@canonical/biome-config": "0.43.0",
|
|
62
|
-
"@canonical/router-core": "^0.
|
|
62
|
+
"@canonical/router-core": "^0.47.0",
|
|
63
63
|
"@canonical/typescript-config": "0.44.0",
|
|
64
64
|
"@canonical/webarchitect": "0.44.0",
|
|
65
65
|
"@tanstack/query-core": "^5.102.8",
|
|
@@ -70,5 +70,6 @@
|
|
|
70
70
|
"relay-runtime": "^21.0.1",
|
|
71
71
|
"typescript": "^7.0.2",
|
|
72
72
|
"vitest": "^5.0.0"
|
|
73
|
-
}
|
|
73
|
+
},
|
|
74
|
+
"gitHead": "f846e7e21001a0fcbc4cd9f28c14a55cea7f4974"
|
|
74
75
|
}
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import createIdentity, {} from "../createIdentity.js";
|
|
2
|
-
import applyQueryCommand from "../query/applyQueryCommand.js";
|
|
3
|
-
import canonicalSlice from "../query/canonicalSlice.js";
|
|
4
|
-
import DEFAULT_RESULT_WINDOW from "../query/defaultWindow.js";
|
|
5
|
-
const emptySlice = Object.freeze({
|
|
6
|
-
filter: [],
|
|
7
|
-
search: null,
|
|
8
|
-
sort: [],
|
|
9
|
-
group: null,
|
|
10
|
-
});
|
|
11
|
-
/** Monotonic instance key: exact cross-instance distinctness, no
|
|
12
|
-
* environment requirements. */
|
|
13
|
-
let coordinatorInstances = 0;
|
|
14
|
-
const idleResult = Object.freeze({
|
|
15
|
-
status: "idle",
|
|
16
|
-
rows: null,
|
|
17
|
-
count: null,
|
|
18
|
-
provenance: null,
|
|
19
|
-
lastError: null,
|
|
20
|
-
});
|
|
21
|
-
const fingerprintOf = (slice, window) => JSON.stringify([canonicalSlice(slice), window], (_key, value) => typeof value === "number" && !Number.isFinite(value)
|
|
22
|
-
? // An object marker cannot collide with any genuine operand: the
|
|
23
|
-
// operand domain has no objects.
|
|
24
|
-
{ nonfinite: String(value) }
|
|
25
|
-
: value);
|
|
26
|
-
/**
|
|
27
|
-
* Copy a caller-supplied slice so later mutations of the original cannot
|
|
28
|
-
* corrupt adopted or seeded state, including nested predicate and
|
|
29
|
-
* sort-term objects.
|
|
30
|
-
*/
|
|
31
|
-
const copySlice = (slice) => Object.freeze({
|
|
32
|
-
filter: Object.freeze(slice.filter.map((predicate) => Object.freeze({
|
|
33
|
-
field: predicate.field,
|
|
34
|
-
operator: predicate.operator,
|
|
35
|
-
operands: Object.freeze([...predicate.operands]),
|
|
36
|
-
}))),
|
|
37
|
-
search: slice.search,
|
|
38
|
-
sort: Object.freeze(slice.sort.map((term) => Object.freeze({ field: term.field, direction: term.direction }))),
|
|
39
|
-
group: slice.group,
|
|
40
|
-
});
|
|
41
|
-
const copyWindow = (window) => {
|
|
42
|
-
if (!Number.isInteger(window.page) || window.page < 1) {
|
|
43
|
-
throw new Error("page must be a positive integer");
|
|
44
|
-
}
|
|
45
|
-
if (!Number.isInteger(window.size) || window.size < 1) {
|
|
46
|
-
throw new Error("size must be a positive integer");
|
|
47
|
-
}
|
|
48
|
-
return Object.freeze({ page: window.page, size: window.size });
|
|
49
|
-
};
|
|
50
|
-
/**
|
|
51
|
-
* Create the collection coordinator: one owner of query/window coherence
|
|
52
|
-
* and the request lifecycle. Requests carry scope-bound identities; only
|
|
53
|
-
* the completion of the most recently issued request publishes, once. The
|
|
54
|
-
* authority for the applied query (for example the browser URL) and the
|
|
55
|
-
* execution of requests are wired above this layer.
|
|
56
|
-
*/
|
|
57
|
-
export default function createCollectionCoordinator(config = {}) {
|
|
58
|
-
const seedSlice = config.slice === undefined ? emptySlice : copySlice(config.slice);
|
|
59
|
-
const seedWindow = copyWindow(config.window === undefined ? DEFAULT_RESULT_WINDOW : config.window);
|
|
60
|
-
let scope = createIdentity();
|
|
61
|
-
// Instance-unique request ids: a completion routed to the wrong
|
|
62
|
-
// coordinator must mismatch loudly, never publish silently.
|
|
63
|
-
const instanceKey = `i${++coordinatorInstances}`;
|
|
64
|
-
let counter = 0;
|
|
65
|
-
let lastRequestId = null;
|
|
66
|
-
/** Fingerprint of the query and window that produced the displayed rows. */
|
|
67
|
-
let publishedFingerprint = null;
|
|
68
|
-
let slice = seedSlice;
|
|
69
|
-
let window = seedWindow;
|
|
70
|
-
let currentFingerprint = fingerprintOf(slice, window);
|
|
71
|
-
let result = idleResult;
|
|
72
|
-
let disposed = false;
|
|
73
|
-
function buildSnapshot() {
|
|
74
|
-
return Object.freeze({
|
|
75
|
-
scope,
|
|
76
|
-
slice,
|
|
77
|
-
window,
|
|
78
|
-
result,
|
|
79
|
-
resultsMatchCurrentQuery: result.provenance !== null &&
|
|
80
|
-
publishedFingerprint === currentFingerprint,
|
|
81
|
-
pendingRequestId: lastRequestId,
|
|
82
|
-
disposed,
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
let snapshot = buildSnapshot();
|
|
86
|
-
const publish = (next) => {
|
|
87
|
-
result = next;
|
|
88
|
-
snapshot = buildSnapshot();
|
|
89
|
-
};
|
|
90
|
-
const beginRequest = (refreshing) => {
|
|
91
|
-
counter += 1;
|
|
92
|
-
lastRequestId = `${instanceKey}:r${counter}`;
|
|
93
|
-
publish({
|
|
94
|
-
status: refreshing ? "refreshing" : "pending",
|
|
95
|
-
rows: result.rows,
|
|
96
|
-
count: result.count,
|
|
97
|
-
provenance: result.provenance,
|
|
98
|
-
lastError: null,
|
|
99
|
-
});
|
|
100
|
-
return lastRequestId;
|
|
101
|
-
};
|
|
102
|
-
return {
|
|
103
|
-
get state() {
|
|
104
|
-
return snapshot;
|
|
105
|
-
},
|
|
106
|
-
dispatch(command) {
|
|
107
|
-
if (disposed) {
|
|
108
|
-
return {
|
|
109
|
-
status: "rejected",
|
|
110
|
-
reason: "coordinator is disposed",
|
|
111
|
-
slice,
|
|
112
|
-
window,
|
|
113
|
-
requestId: null,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
const applied = applyQueryCommand(slice, window, command);
|
|
117
|
-
if (applied.status === "rejected") {
|
|
118
|
-
return { ...applied, requestId: null };
|
|
119
|
-
}
|
|
120
|
-
if (!applied.queryChanged && !applied.windowChanged) {
|
|
121
|
-
return { ...applied, requestId: null };
|
|
122
|
-
}
|
|
123
|
-
slice = applied.slice;
|
|
124
|
-
window = applied.window;
|
|
125
|
-
currentFingerprint = fingerprintOf(slice, window);
|
|
126
|
-
const requestId = beginRequest(false);
|
|
127
|
-
return { ...applied, requestId };
|
|
128
|
-
},
|
|
129
|
-
refresh() {
|
|
130
|
-
if (disposed) {
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
return beginRequest(true);
|
|
134
|
-
},
|
|
135
|
-
adopt(nextSlice, nextWindow) {
|
|
136
|
-
if (disposed) {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
const copiedSlice = copySlice(nextSlice);
|
|
140
|
-
const copiedWindow = copyWindow(nextWindow);
|
|
141
|
-
const nextFingerprint = fingerprintOf(copiedSlice, copiedWindow);
|
|
142
|
-
if (nextFingerprint === currentFingerprint) {
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
slice = copiedSlice;
|
|
146
|
-
window = copiedWindow;
|
|
147
|
-
currentFingerprint = nextFingerprint;
|
|
148
|
-
return beginRequest(false);
|
|
149
|
-
},
|
|
150
|
-
complete(requestId, completion) {
|
|
151
|
-
if (disposed || lastRequestId === null || requestId !== lastRequestId) {
|
|
152
|
-
// Disposed coordinator, obsolete request, rotated scope, repeated
|
|
153
|
-
// delivery, or no request at all: such a completion never publishes.
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
lastRequestId = null;
|
|
157
|
-
if (completion.status === "success") {
|
|
158
|
-
publishedFingerprint = currentFingerprint;
|
|
159
|
-
publish({
|
|
160
|
-
status: "ready",
|
|
161
|
-
rows: [...completion.rows],
|
|
162
|
-
count: completion.count,
|
|
163
|
-
provenance: { requestId },
|
|
164
|
-
lastError: null,
|
|
165
|
-
});
|
|
166
|
-
return true;
|
|
167
|
-
}
|
|
168
|
-
publish({
|
|
169
|
-
status: result.rows === null
|
|
170
|
-
? "error"
|
|
171
|
-
: publishedFingerprint === currentFingerprint
|
|
172
|
-
? "ready"
|
|
173
|
-
: "stale",
|
|
174
|
-
rows: result.rows,
|
|
175
|
-
count: result.count,
|
|
176
|
-
provenance: result.provenance,
|
|
177
|
-
lastError: completion.reason,
|
|
178
|
-
});
|
|
179
|
-
return true;
|
|
180
|
-
},
|
|
181
|
-
rotateScope() {
|
|
182
|
-
if (disposed) {
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
scope = createIdentity();
|
|
186
|
-
lastRequestId = null;
|
|
187
|
-
slice = seedSlice;
|
|
188
|
-
window = seedWindow;
|
|
189
|
-
currentFingerprint = fingerprintOf(slice, window);
|
|
190
|
-
publishedFingerprint = null;
|
|
191
|
-
publish(idleResult);
|
|
192
|
-
},
|
|
193
|
-
dispose() {
|
|
194
|
-
disposed = true;
|
|
195
|
-
// A disposed coordinator ignores every completion, so it never
|
|
196
|
-
// reports a request as still awaiting one.
|
|
197
|
-
lastRequestId = null;
|
|
198
|
-
snapshot = buildSnapshot();
|
|
199
|
-
},
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
//# sourceMappingURL=createCollectionCoordinator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createCollectionCoordinator.js","sourceRoot":"","sources":["../../../../src/lib/collection/createCollectionCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,EAAE,EAAiB,MAAM,sBAAsB,CAAC;AACrE,OAAO,iBAAiB,MAAM,+BAA+B,CAAC;AAC9D,OAAO,cAAc,MAAM,4BAA4B,CAAC;AACxD,OAAO,qBAAqB,MAAM,2BAA2B,CAAC;AAgI9D,MAAM,UAAU,GAAU,MAAM,CAAC,MAAM,CAAC;IACtC,MAAM,EAAE,EAAE;IACV,MAAM,EAAE,IAAI;IACZ,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,IAAI;CACZ,CAAC,CAAC;AAEH;+B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aAAa,GAAG,IAAI,CAAC;YACrB,KAAK,GAAG,SAAS,CAAC;YAClB,MAAM,GAAG,UAAU,CAAC;YACpB,kBAAkB,GAAG,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YAClD,oBAAoB,GAAG,IAAI,CAAC;YAC5B,OAAO,CAAC,UAAU,CAAC,CAAC;QACtB,CAAC;QACD,OAAO;YACL,QAAQ,GAAG,IAAI,CAAC;YAChB,+DAA+D;YAC/D,2CAA2C;YAC3C,aAAa,GAAG,IAAI,CAAC;YACrB,QAAQ,GAAG,aAAa,EAAE,CAAC;QAC7B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Save-race semantics for durable preferences and views: a completion
|
|
3
|
-
* updates the submitted baseline only, so edits made while saving remain
|
|
4
|
-
* dirty, and a delayed external read never overwrites newer local state.
|
|
5
|
-
*/
|
|
6
|
-
/** Monotonic instance key: exact cross-session distinctness. */
|
|
7
|
-
let saveSessionInstances = 0;
|
|
8
|
-
/**
|
|
9
|
-
* Create a save session over one durable value. Persistence execution stays
|
|
10
|
-
* with the caller; this record owns only the baseline/dirty race. Attempt
|
|
11
|
-
* identities make completions one-shot: a late completion of a superseded
|
|
12
|
-
* attempt is ignored, exactly like superseded request completions.
|
|
13
|
-
*/
|
|
14
|
-
export default function createSaveSession(config) {
|
|
15
|
-
let baseline = config.initial;
|
|
16
|
-
let current = config.initial;
|
|
17
|
-
let submitted = null;
|
|
18
|
-
let currentAttempt = null;
|
|
19
|
-
// Instance-unique attempt ids: a completion routed to the wrong session
|
|
20
|
-
// must mismatch loudly, never advance a baseline silently.
|
|
21
|
-
const instanceKey = `i${++saveSessionInstances}`;
|
|
22
|
-
let attemptCounter = 0;
|
|
23
|
-
let status = "idle";
|
|
24
|
-
let revision = 0;
|
|
25
|
-
let failureReason = null;
|
|
26
|
-
let snapshot = buildSnapshot();
|
|
27
|
-
function buildSnapshot() {
|
|
28
|
-
return Object.freeze({
|
|
29
|
-
baseline,
|
|
30
|
-
current,
|
|
31
|
-
submitted,
|
|
32
|
-
status,
|
|
33
|
-
dirty: !config.equals(current, baseline),
|
|
34
|
-
revision,
|
|
35
|
-
failureReason,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return {
|
|
39
|
-
get state() {
|
|
40
|
-
return snapshot;
|
|
41
|
-
},
|
|
42
|
-
edit(next) {
|
|
43
|
-
current = next;
|
|
44
|
-
revision += 1;
|
|
45
|
-
if (status === "failed") {
|
|
46
|
-
status = "idle";
|
|
47
|
-
}
|
|
48
|
-
failureReason = null;
|
|
49
|
-
snapshot = buildSnapshot();
|
|
50
|
-
},
|
|
51
|
-
beginSave() {
|
|
52
|
-
if (status === "saving") {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
attemptCounter += 1;
|
|
56
|
-
currentAttempt = `${instanceKey}:s${attemptCounter}`;
|
|
57
|
-
submitted = current;
|
|
58
|
-
status = "saving";
|
|
59
|
-
failureReason = null;
|
|
60
|
-
// A save submission also moves the value's version: a read issued
|
|
61
|
-
// before it must not clobber the submitted state when it resolves.
|
|
62
|
-
revision += 1;
|
|
63
|
-
snapshot = buildSnapshot();
|
|
64
|
-
return currentAttempt;
|
|
65
|
-
},
|
|
66
|
-
saveCompleted(attempt) {
|
|
67
|
-
if (attempt !== currentAttempt || submitted === null) {
|
|
68
|
-
// Superseded or unknown attempt: never advance the baseline.
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
baseline = submitted;
|
|
72
|
-
submitted = null;
|
|
73
|
-
currentAttempt = null;
|
|
74
|
-
status = "idle";
|
|
75
|
-
failureReason = null;
|
|
76
|
-
snapshot = buildSnapshot();
|
|
77
|
-
},
|
|
78
|
-
saveFailed(attempt, reason) {
|
|
79
|
-
if (attempt !== currentAttempt || submitted === null) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
submitted = null;
|
|
83
|
-
currentAttempt = null;
|
|
84
|
-
status = "failed";
|
|
85
|
-
failureReason = reason;
|
|
86
|
-
snapshot = buildSnapshot();
|
|
87
|
-
},
|
|
88
|
-
applyExternalRead(value, seenRevision) {
|
|
89
|
-
if (status === "saving" || seenRevision !== revision) {
|
|
90
|
-
// A save is in flight, or the value moved on since the read was
|
|
91
|
-
// issued; the read must not overwrite either.
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
baseline = value;
|
|
95
|
-
current = value;
|
|
96
|
-
status = "idle";
|
|
97
|
-
failureReason = null;
|
|
98
|
-
snapshot = buildSnapshot();
|
|
99
|
-
return true;
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
//# sourceMappingURL=createSaveSession.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createSaveSession.js","sourceRoot":"","sources":["../../../../src/lib/collection/createSaveSession.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAwDH,gEAAgE;AAChE,IAAI,oBAAoB,GAAG,CAAC,CAAC;AAE7B;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,MAA4B;IAE5B,IAAI,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC;IAC9B,IAAI,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IAC7B,IAAI,SAAS,GAAa,IAAI,CAAC;IAC/B,IAAI,cAAc,GAAkB,IAAI,CAAC;IACzC,wEAAwE;IACxE,2DAA2D;IAC3D,MAAM,WAAW,GAAG,IAAI,EAAE,oBAAoB,EAAE,CAAC;IACjD,IAAI,cAAc,GAAG,CAAC,CAAC;IACvB,IAAI,MAAM,GAAkC,MAAM,CAAC;IACnD,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,aAAa,GAAkB,IAAI,CAAC;IACxC,IAAI,QAAQ,GAAG,aAAa,EAAE,CAAC;IAE/B,SAAS,aAAa;QACpB,OAAO,MAAM,CAAC,MAAM,CAAC;YACnB,QA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Ac;YACxC,IAAI,OAAO,KAAK,cAAc,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;gBACrD,OAAO;YACT,CAAC;YACD,SAAS,GAAG,IAAI,CAAC;YACjB,cAAc,GAAG,IAAI,CAAC;YACtB,MAAM,GAAG,QAAQ,CAAC;YAClB,aAAa,GAAG,MAAM,CAAC;YACvB,QAAQ,GAAG,aAAa,EAAE,CAAC;QAC7B,CAAC;QACD,iBAAiB,CAAC,KAAQ,EAAE,YAAoB;YAC9C,IAAI,MAAM,KAAK,QAAQ,IAAI,YAAY,KAAK,QAAQ,EAAE,CAAC;gBACrD,gEAAgE;gBAChE,8CAA8C;gBAC9C,OAAO,KAAK,CAAC;YACf,CAAC;YACD,QAAQ,GAAG,KAAK,CAAC;YACjB,OAAO,GAAG,KAAK,CAAC;YAChB,MAAM,GAAG,MAAM,CAAC;YAChB,aAAa,GAAG,IAAI,CAAC;YACrB,QAAQ,GAAG,aAAa,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { identityBrand } from "./identityBrand.js";
|
|
2
|
-
/**
|
|
3
|
-
* Create a fresh identity token, distinct from every other identity.
|
|
4
|
-
*
|
|
5
|
-
* Identity tokens mark runtime scopes (a provider, a column set, a cell
|
|
6
|
-
* handle) so consumers can enforce, at runtime, that a value created against
|
|
7
|
-
* one scope is not silently consumed by another. Structural copies of a
|
|
8
|
-
* token and forged-key look-alikes are rejected by `isIdentity`.
|
|
9
|
-
*/
|
|
10
|
-
export default function createIdentity() {
|
|
11
|
-
// The brand is a non-enumerable own property: spread and Object.assign
|
|
12
|
-
// skip it, and the guard's own-property check rejects Object.create copies.
|
|
13
|
-
const token = {};
|
|
14
|
-
Object.defineProperty(token, identityBrand, {
|
|
15
|
-
value: true,
|
|
16
|
-
enumerable: false,
|
|
17
|
-
writable: false,
|
|
18
|
-
configurable: false,
|
|
19
|
-
});
|
|
20
|
-
return Object.freeze(token);
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=createIdentity.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createIdentity.js","sourceRoot":"","sources":["../../../src/lib/createIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAYnD;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc;IACpC,uEAAuE;IACvE,4EAA4E;IAC5E,MAAM,KAAK,GAAG,EAAc,CAAC;IAC7B,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,aAAa,EAAE;QAC1C,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,KAAK;QACf,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import createIdentity, {} from "../createIdentity.js";
|
|
2
|
-
/**
|
|
3
|
-
* Create the interaction record for one filter field: it owns the input
|
|
4
|
-
* buffer and its feedback, and produces addressed query commands. It never
|
|
5
|
-
* owns the applied query — the coordinator does. A valid edit assumes its
|
|
6
|
-
* returned command is dispatched and accepted; external authoritative
|
|
7
|
-
* changes arrive through `setApplied`.
|
|
8
|
-
*/
|
|
9
|
-
export default function createFieldInteraction(config) {
|
|
10
|
-
if (config.field === "" || config.field.includes("\u0000")) {
|
|
11
|
-
throw new Error("field interaction requires a non-empty field name without NUL characters");
|
|
12
|
-
}
|
|
13
|
-
const identity = createIdentity();
|
|
14
|
-
let buffer = "";
|
|
15
|
-
let feedback = { kind: "none" };
|
|
16
|
-
let applied = null;
|
|
17
|
-
let snapshot = buildSnapshot();
|
|
18
|
-
function buildSnapshot() {
|
|
19
|
-
return Object.freeze({ buffer, feedback, applied });
|
|
20
|
-
}
|
|
21
|
-
const predicateFrom = (operands) => ({
|
|
22
|
-
field: config.field,
|
|
23
|
-
operator: config.operator,
|
|
24
|
-
operands: [...operands],
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
identity,
|
|
28
|
-
get state() {
|
|
29
|
-
return snapshot;
|
|
30
|
-
},
|
|
31
|
-
edit(nextBuffer) {
|
|
32
|
-
buffer = nextBuffer;
|
|
33
|
-
const validation = config.validate(nextBuffer);
|
|
34
|
-
if (validation.status === "valid") {
|
|
35
|
-
feedback = { kind: "applied" };
|
|
36
|
-
applied = predicateFrom(validation.operands);
|
|
37
|
-
snapshot = buildSnapshot();
|
|
38
|
-
return {
|
|
39
|
-
kind: "replacePredicate",
|
|
40
|
-
predicate: applied,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
if (validation.status === "incomplete") {
|
|
44
|
-
feedback = { kind: "incomplete" };
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
feedback = {
|
|
48
|
-
kind: "invalid",
|
|
49
|
-
reason: validation.reason,
|
|
50
|
-
retainsPredicate: applied !== null,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
snapshot = buildSnapshot();
|
|
54
|
-
return null;
|
|
55
|
-
},
|
|
56
|
-
clear() {
|
|
57
|
-
buffer = "";
|
|
58
|
-
feedback = { kind: "none" };
|
|
59
|
-
applied = null;
|
|
60
|
-
snapshot = buildSnapshot();
|
|
61
|
-
return {
|
|
62
|
-
kind: "removePredicate",
|
|
63
|
-
field: config.field,
|
|
64
|
-
operator: config.operator,
|
|
65
|
-
};
|
|
66
|
-
},
|
|
67
|
-
setApplied(nextApplied) {
|
|
68
|
-
if (nextApplied !== null &&
|
|
69
|
-
(nextApplied.field !== config.field ||
|
|
70
|
-
nextApplied.operator !== config.operator)) {
|
|
71
|
-
throw new Error(`setApplied received a predicate for ${nextApplied.field}/${nextApplied.operator} on a ${config.field}/${config.operator} record`);
|
|
72
|
-
}
|
|
73
|
-
applied = nextApplied;
|
|
74
|
-
buffer = config.format ? config.format(nextApplied) : "";
|
|
75
|
-
feedback = { kind: "none" };
|
|
76
|
-
snapshot = buildSnapshot();
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
//# sourceMappingURL=createFieldInteraction.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createFieldInteraction.js","sourceRoot":"","sources":["../../../../src/lib/field/createFieldInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,EAAE,EAAiB,MAAM,sBAAsB,CAAC;AA2ErE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAC5C,MAA8B;IAE9B,IAAI,MAAM,CAAC,KAAK,KAAK,EAAE,IAAI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CACb,0EAA0E,CAC3E,CAAC;IACJ,CAAC;IACD,MAAM,QAAQ,GAAG,cAAc,EAAE,CAAC;IAClC,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,QAAQ,GAAkB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC/C,IAAI,OAAO,GAAqB,IAAI,CAAC;IACrC,IAAI,QAAQ,GAAG,aAAa,EAAE,CAAC;IAE/B,SAAS,aAAa;QACpB,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,MAAM,aAAa,GAAG,CAAC,QAAqC,EAAa,EAAE,CAAC,CAAC;QAC3E,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,QAAQ,EAAE,CAAC,GAAG,QAAQ,CAAC;KACxB,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ;QACR,IAAI,KAAK;YACP,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,IAAI,CAAC,UAAkB;YACrB,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