Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/writer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
"@mdbase-dev/connect": "0.1.0-beta.149",
"@mdbase-dev/connect-protocol": "file:vendor/mdbase-dev-connect-protocol-0.1.0-beta.145-e6e66bcd172f.tgz",
"@mdbase-dev/i18n": "0.1.0-beta.176",
"@mdbase-dev/sdk": "0.1.0-beta.187",
"@mdbase-dev/sdk-lab": "file:../../vendor/sdk-lab-beta157.tgz",
"@mdbase-dev/sdk-staging": "file:../../vendor/sdk-staging-beta157.tgz",
"@mdbase-dev/sdk": "0.1.0-beta.188",
"@mdbase-dev/sdk-lab": "file:../../vendor/sdk-lab-beta188.tgz",
"@mdbase-dev/sdk-staging": "file:../../vendor/sdk-staging-beta188.tgz",
"@mdbase-dev/ui": "0.1.0-beta.176",
"@mdbase-writer/core": "workspace:*",
"@myriaddreamin/typst-ts-renderer": "0.7.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/writer/scripts/browser-a11y-fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ export async function mountNative(body = "# Original manuscript\n\nConfirmed nat
phase: "ready",
});
fixture.client().describe = async () => ({
specVersion: "0.3.0", settings: new Map(), issues: [], inclusion: { include: ["image"] },
specVersion: "0.3.0", settings: {}, issues: [], inclusion: { include: ["image"] },
contracts: manifest.requirements.contracts.map((contract, index) => ({ ...contract, path: `_contracts/${contract.id}.md`, digest: contract.digest.replace(/^sha256:/, ""), contractType: "record", implementedBy: [names[index]!] })),
types: manifest.requirements.contracts.map((contract, index) => ({ name: names[index]!, path: `_types/${names[index]}.md`, implements: [{ contract: contract.id, version: contract.version, fields: new Map([["title", "title"], ["template", "template"], ["csl", "csl"]]) }] })),
types: manifest.requirements.contracts.map((contract, index) => ({ name: names[index]!, path: `_types/${names[index]}.md`, implements: [{ contract: contract.id, version: contract.version, fields: { title: "title", template: "template", csl: "csl" } }] })),
});
document.getElementById("root")!.hidden = true;
const host = document.createElement("div");
Expand Down
4 changes: 2 additions & 2 deletions apps/writer/scripts/browser-polish-r2-test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ try {
await page.screenshot({ path: `out/polish-r2/${name}-hold.png` });
await page.evaluate(() => {
const client = window.nativeFixture.client();
window.nativeHoldResolution = client.save(client.resolveHold(window.nativeHold, "keep_mine")).then(
window.nativeHoldResolution = client.settle(client.resolveHold(window.nativeHold, "keep_mine")).then(
result => { window.nativeHoldResult = { outcome: result.outcome }; },
error => { window.nativeHoldResult = { error: String(error) }; },
);
Expand All @@ -110,7 +110,7 @@ try {
await comparison.getByRole("textbox", { name: /Merged Markdown/ }).fill("Deliberately merged native draft\n");
await comparison.getByRole("button", { name: "Save merged version", exact: true }).click();
await page.waitForFunction(() => { const snapshot = window.writer.workspace.getSnapshot().records.get(window.writer.workspace.main).snapshot; return snapshot.state === "saved" && snapshot.body === "Deliberately merged native draft\n"; });
assert.equal(await page.evaluate(async () => (await window.nativeFixture.client().get({ path: "writing/main.md" }, { body: true })).body), "Deliberately merged native draft\n");
assert.equal(await page.evaluate(async () => (await window.nativeFixture.client().get({ path: "writing/main.md" }, { include: { body: true } })).body), "Deliberately merged native draft\n");
await page.evaluate(() => {
window.nativeFixture.replica().setOnline(false);
window.restoreStorage = Storage.prototype.setItem;
Expand Down
6 changes: 3 additions & 3 deletions apps/writer/scripts/writer-sdk.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const hash = (bytes) => createHash("sha256").update(bytes).digest("hex");

/** Intake pins (under vendor/) for each environment's SDK original. */
export const writerSdkPins = Object.freeze({
lab: "sdk-lab-beta157.json",
staging: "sdk-staging-beta157.json",
production: "sdk-production-beta187.json",
lab: "sdk-lab-beta188.json",
staging: "sdk-staging-beta188.json",
production: "sdk-production-beta188.json",
});

/** Installed package names to try, in order. The plain name comes first so a
Expand Down
14 changes: 7 additions & 7 deletions apps/writer/src/backend/native-schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { toPlain, type wire } from "@mdbase-dev/sdk";
import type { DescribeResult, JsonValue } from "@mdbase-dev/sdk";
import type { JsonObject } from "@mdbase-dev/connect";
import manifest from "../generated/mdbase-app.json";
import { annotationContract, CollectionSchema, domainContract, unavailableTypeMessage, type Domain, type WriterSchemaDescription } from "./collection.js";
Expand All @@ -7,8 +7,8 @@ import type { UnavailableType } from "./types.js";
const DOMAINS: readonly Domain[] = ["manuscript", "source", "annotation", "comment", "person"];
const domainOf = (id: string): Domain | undefined => DOMAINS.find(domain => domainContract(domain).id === id);
/** The definition path an issue is attached to, when it names one. */
function issuePath(details: unknown): string | null {
const path = details instanceof Map ? (details as Map<unknown, unknown>).get("path") : null;
function issuePath(details: JsonValue | undefined): string | null {
const path = typeof details === "object" && details !== null && !Array.isArray(details) ? details["path"] : null;
return typeof path === "string" && path ? path : null;
}

Expand All @@ -27,8 +27,8 @@ export function nativeJson(value: unknown): NativeJson {
export function nativeWriteFields(fields: JsonObject): { [key: string]: NativeJson } {
return Object.fromEntries(Object.entries(fields).map(([key, value]) => [key, nativeJson(value)]));
}
export function nativeObject(value: wire.Value): JsonObject {
const json = nativeJson(toPlain(value));
export function nativeObject(value: JsonValue): JsonObject {
const json = nativeJson(value);
if (json === null || typeof json !== "object" || Array.isArray(json)) throw new Error("Writer requires a native field map.");
return json;
}
Expand All @@ -48,7 +48,7 @@ export function manifestContractDigest(id: string, version: string): string | un
* recognise a starter name without its actual native contract implementation.
* The SDK remains responsible for root readiness and configuration/provisioning.
*/
export function nativeWriterSchema(catalog: wire.DescribeResult): CollectionSchema {
export function nativeWriterSchema(catalog: DescribeResult): CollectionSchema {
// Aggregate readiness belongs to the SDK. An unrelated definition diagnostic
// must not hide usable Writer records; exact domain bindings remain checked.
const required = manifest.requirements.contracts;
Expand Down Expand Up @@ -77,7 +77,7 @@ export function nativeWriterSchema(catalog: wire.DescribeResult): CollectionSche
if (domain && !unavailableTypes.some(entry => entry.name === type.name)) unavailableTypes.push({name: type.name, domain, message: unavailableTypeMessage(type.name, domain)});
return [];
}
return [{typeName: type.name, fields: Object.fromEntries(binding.fields)}];
return [{typeName: type.name, fields: binding.fields}];
})}));
const schema = new CollectionSchema({types: catalog.types.map(type => ({name: type.name})), contracts,
// A collection without settings reports null: that is no settings, not an error.
Expand Down
Loading