@malloy-publisher/sdk 0.4.0 → 0.4.1
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/README.md +19 -0
- package/dist/{DocumentStorageProvider-CyOJ0hqf.es.js → DocumentStorage-BiFqO15i.es.js} +137 -129
- package/dist/{DocumentStorageProvider-DGPQEd_l.cjs.js → DocumentStorage-CMyLifsz.cjs.js} +26 -26
- package/dist/{RenderedResult-Dp22kZsQ.cjs.js → RenderedResult-CZzE8wv-.cjs.js} +2 -2
- package/dist/{RenderedResult-BnPzJ9Jf.es.js → RenderedResult-CvrmYyr5.es.js} +1 -1
- package/dist/builder/index.cjs.js +50 -50
- package/dist/builder/index.es.js +3265 -3185
- package/dist/components/Dashboard/telemetry.d.ts +20 -8
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +16 -4
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +17 -5
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +69 -5
- package/dist/components/DocumentStorage/index.d.ts +1 -0
- package/dist/index.cjs.js +9 -9
- package/dist/index.es.js +508 -506
- package/package.json +1 -1
- package/src/components/Dashboard/telemetry.ts +20 -8
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +21 -3
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +706 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +358 -84
- package/src/components/DocumentStorage/BrowserDocumentStorage.ts +7 -6
- package/src/components/DocumentStorage/DocumentStorage.ts +78 -5
- package/src/components/DocumentStorage/index.ts +1 -0
- package/src/components/Package/Package.tsx +12 -7
package/package.json
CHANGED
|
@@ -12,8 +12,12 @@
|
|
|
12
12
|
export type DashboardEvent =
|
|
13
13
|
| {
|
|
14
14
|
type: "dashboard.opened";
|
|
15
|
-
/**
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The package file, a draft the host had saved beside it, or the
|
|
17
|
+
* host's own copy when that copy is the record. A record open is not a
|
|
18
|
+
* "draft" open: nothing was resumed and nothing is pending.
|
|
19
|
+
*/
|
|
20
|
+
from: "package" | "draft" | "record";
|
|
17
21
|
tiles: number;
|
|
18
22
|
durationMs: number;
|
|
19
23
|
}
|
|
@@ -24,13 +28,21 @@ export type DashboardEvent =
|
|
|
24
28
|
/** Whether a tile was added or removed, which moves declarations. */
|
|
25
29
|
structural: boolean;
|
|
26
30
|
/**
|
|
27
|
-
* Where it went
|
|
28
|
-
* that
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
31
|
+
* Where it went, named by which storage took the write rather than by
|
|
32
|
+
* where that storage happens to keep things, since "browser" and
|
|
33
|
+
* "host" do not divide by English: `package` is the package file on
|
|
34
|
+
* the server, `browser` is the Console's own browser store, and `host`
|
|
35
|
+
* is a host storage that holds the record.
|
|
36
|
+
*
|
|
37
|
+
* Separate because they are not the same event. A save into the
|
|
38
|
+
* package or the record is a change every reader sees; a browser save
|
|
39
|
+
* is one person's copy on one machine. Counting them together makes
|
|
40
|
+
* "dashboards are being edited" unreadable, because a read-only server
|
|
41
|
+
* reports exactly as much saving as a writable one.
|
|
32
42
|
*/
|
|
33
|
-
where: "package" | "browser";
|
|
43
|
+
where: "package" | "browser" | "host";
|
|
44
|
+
/** The workspace that took the write, so the event says so itself. */
|
|
45
|
+
workspace?: string;
|
|
34
46
|
durationMs: number;
|
|
35
47
|
}
|
|
36
48
|
| { type: "dashboard.save_refused"; reason: string }
|
|
@@ -146,12 +146,24 @@ export interface DashboardBuilderProps {
|
|
|
146
146
|
dashboards?: string[];
|
|
147
147
|
/** Saves and refusals, for the host to log; see `DashboardEvent`. */
|
|
148
148
|
onEvent?: DashboardEventHandler;
|
|
149
|
+
/**
|
|
150
|
+
* Whether the document differs from what was last saved, on every change
|
|
151
|
+
* and on mount.
|
|
152
|
+
*
|
|
153
|
+
* For a host that has to decide whether it may replace what is open — a
|
|
154
|
+
* newer version arriving from its store, a navigation away. `onChange`
|
|
155
|
+
* cannot answer that: the saved baseline lives in this hook, so a parent
|
|
156
|
+
* comparing the document it is handed against the one it passed in reads
|
|
157
|
+
* dirty immediately after a successful save.
|
|
158
|
+
*/
|
|
159
|
+
onDirtyChange?: (dirty: boolean) => void;
|
|
149
160
|
/**
|
|
150
161
|
* Where `onSave` puts the file, for the event it reports. The builder
|
|
151
|
-
* cannot tell — it is handed a function — and a save into the package
|
|
152
|
-
*
|
|
162
|
+
* cannot tell — it is handed a function — and a save into the package, into
|
|
163
|
+
* this browser, and into a host store that holds the record are not the
|
|
164
|
+
* same event.
|
|
153
165
|
*/
|
|
154
|
-
savesTo?: "package" | "browser";
|
|
166
|
+
savesTo?: "package" | "browser" | "host";
|
|
155
167
|
/**
|
|
156
168
|
* The host's own actions for the edit bar — Done — rendered beside
|
|
157
169
|
* undo, redo and save. The builder owns the edits; where the file goes
|
|
@@ -165,6 +177,7 @@ export function DashboardBuilder({
|
|
|
165
177
|
document,
|
|
166
178
|
onSave,
|
|
167
179
|
onChange,
|
|
180
|
+
onDirtyChange,
|
|
168
181
|
renderTile,
|
|
169
182
|
controls,
|
|
170
183
|
givens,
|
|
@@ -225,6 +238,11 @@ export function DashboardBuilder({
|
|
|
225
238
|
useEffect(() => {
|
|
226
239
|
onChange?.(editor.document);
|
|
227
240
|
}, [editor.document, onChange]);
|
|
241
|
+
// Also on mount, so a host that remounted the builder on new text is told
|
|
242
|
+
// the slate is clean rather than carrying the previous mount's answer.
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
onDirtyChange?.(editor.dirty);
|
|
245
|
+
}, [editor.dirty, onDirtyChange]);
|
|
228
246
|
// One object per document, or the popover's draft would reset on every
|
|
229
247
|
// render of the builder while it is open.
|
|
230
248
|
const settings = useMemo(
|