@xenosystem/blocks 0.23.1 → 0.25.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.
@@ -587,29 +587,29 @@ import { status, surface, text as text2 } from "@xenosystem/elements/tokens";
587
587
  import { PANEL_COLORS } from "@xenosystem/components/chrome";
588
588
  var soft = (c, pct) => `color-mix(in srgb, ${c} ${pct}%, transparent)`;
589
589
  var SURFACE_TOKENS = {
590
- "--cs-toolbar": `var(--xeno-viewport, ${surface.canvas})`,
591
- "--cs-menu": `var(--xeno-panel-header, ${surface.panelHeader})`,
590
+ "--cs-toolbar": `var(--xeno-surface, ${surface.canvas})`,
591
+ "--cs-menu": `var(--xeno-elevated, ${surface.panelHeader})`,
592
592
  "--cs-field": `var(--xeno-control, ${surface.input})`,
593
593
  "--cs-ink": `var(--xeno-text, ${text2.hover})`,
594
594
  "--cs-ink2": `var(--xeno-muted-text, ${text2.active})`,
595
- "--cs-ink3": `var(--xeno-muted-text, ${text2.active})`,
596
- "--cs-line": PANEL_COLORS.border,
597
- "--cs-edge": PANEL_COLORS.focus,
598
- "--cs-dot": PANEL_COLORS.soft,
599
- "--cs-lane": PANEL_COLORS.wash,
595
+ "--cs-ink3": `var(--xeno-muted, ${text2.active})`,
596
+ "--cs-line": `var(--xeno-border, ${PANEL_COLORS.border})`,
597
+ "--cs-edge": `var(--xeno-edge, ${PANEL_COLORS.focus})`,
598
+ "--cs-dot": `var(--xeno-dot, ${PANEL_COLORS.soft})`,
599
+ "--cs-lane": `var(--xeno-lane, ${PANEL_COLORS.wash})`,
600
600
  "--cs-accent": `var(--xeno-text, ${text2.hover})`,
601
- "--cs-accent-soft": PANEL_COLORS.soft,
601
+ "--cs-accent-soft": `var(--xeno-info-soft, ${PANEL_COLORS.soft})`,
602
602
  "--cs-cap": `var(--xeno-active, ${text2.active})`,
603
- "--cs-ok": status.success,
604
- "--cs-ok-soft": soft(status.success, 10),
605
- "--cs-ok-ink": PANEL_COLORS.successText,
606
- "--cs-warn": status.warning,
607
- "--cs-on-warn": surface.page,
603
+ "--cs-ok": `var(--xeno-ok, ${status.success})`,
604
+ "--cs-ok-soft": `var(--xeno-ok-soft, ${soft(status.success, 10)})`,
605
+ "--cs-ok-ink": `var(--xeno-success-text, ${PANEL_COLORS.successText})`,
606
+ "--cs-warn": `var(--xeno-warn, ${status.warning})`,
607
+ "--cs-on-warn": `var(--xeno-on-accent, ${surface.page})`,
608
608
  "--cs-danger": `var(--xeno-danger, ${status.danger})`,
609
- "--cs-danger-text": PANEL_COLORS.errorText,
610
- "--cs-on-danger": `var(--xeno-text, ${text2.hover})`,
611
- "--cs-shadow": `0 0 0 1px ${PANEL_COLORS.soft}`,
612
- "--cs-pop": `0 16px 40px ${PANEL_COLORS.well}, 0 0 0 1px ${PANEL_COLORS.border}`,
609
+ "--cs-danger-text": `var(--xeno-danger-text, ${PANEL_COLORS.errorText})`,
610
+ "--cs-on-danger": `var(--xeno-on-accent, ${text2.hover})`,
611
+ "--cs-shadow": `var(--xeno-shadow, 0 0 0 1px ${PANEL_COLORS.soft})`,
612
+ "--cs-pop": `var(--xeno-pop, 0 16px 40px ${PANEL_COLORS.well}, 0 0 0 1px ${PANEL_COLORS.border})`,
613
613
  "--cs-mono": "var(--xeno-font-mono, ui-monospace, monospace)"
614
614
  };
615
615
 
@@ -0,0 +1,60 @@
1
+ import { AnyExtension } from '@tiptap/core';
2
+ import * as Y from 'yjs';
3
+ import { Awareness } from 'y-protocols/awareness';
4
+ import { X as XenoDocNode } from '../format-BoLLqtrs.js';
5
+
6
+ /**
7
+ * Live co-editing for the document block — `@xenosystem/blocks/docs/collaboration`.
8
+ *
9
+ * The same construction XENO Docs uses (its DocumentEditor): TipTap's `Collaboration` extension binds the editor to an
10
+ * XML fragment of a Y.js document (field `prosemirror`), and `CollaborationCursor` draws the other writers' carets from
11
+ * a y-protocols `Awareness`. Edits from everyone merge as a CRDT, so two people typing in the same paragraph both land
12
+ * and every mark, block and attribute of the shared schema travels intact (nothing goes through Markdown).
13
+ *
14
+ * The block never connects anything. The HOST owns the transport (XENO Multiplayer, a provider) and the saving: it
15
+ * hands this module the `Y.Doc` and an `Awareness` it keeps in step, mounts the surface with
16
+ * `{ shared: true, history: false, extensions: createCollaborationExtensions(...) }`, and decides who seeds the shared
17
+ * document from the saved file ({@link seedSharedDocument}) and who writes it back to storage. This lives in its own
18
+ * subpath so a consumer that never co-edits does not need Y.js.
19
+ *
20
+ * @module
21
+ */
22
+
23
+ /** XENO Docs' field name: a document co-edited here and in XENO Docs is the same fragment. */
24
+ declare const SHARED_FIELD = "prosemirror";
25
+ interface CollaborationOptions {
26
+ /** The shared document. Its XML fragment `field` IS the document's content while it is open. */
27
+ document: Y.Doc;
28
+ /** Fragment name. Default {@link SHARED_FIELD}. */
29
+ field?: string;
30
+ /**
31
+ * Other writers' carets and selections: an Awareness the host keeps in step with its transport, and how THIS writer
32
+ * appears to them. The colour is the host's (a theme token's value), never the block's.
33
+ */
34
+ cursors?: {
35
+ awareness: Awareness;
36
+ user: {
37
+ name: string;
38
+ color: string;
39
+ };
40
+ };
41
+ }
42
+ /** The extensions that bind a document surface to a shared document. Mount with `shared: true, history: false`. */
43
+ declare function createCollaborationExtensions(options: CollaborationOptions): AnyExtension[];
44
+ /** True when the shared document holds nothing yet. */
45
+ declare function isSharedDocumentEmpty(document: Y.Doc, field?: string): boolean;
46
+ /**
47
+ * Put a saved document into an EMPTY shared one (the first writer to open it). Does nothing, and returns false, when it
48
+ * already holds content: one seed only, so two writers opening at once never get the text twice — the host still
49
+ * decides which one seeds. Content the schema cannot represent throws, so nothing is silently dropped.
50
+ */
51
+ declare function seedSharedDocument(document: Y.Doc, content: XenoDocNode, field?: string): boolean;
52
+ /**
53
+ * Replace the shared document with a saved one, in one change (a newer version was saved somewhere nobody here was
54
+ * writing, and nobody is in it now). Everyone still connected receives the replacement as an ordinary edit.
55
+ */
56
+ declare function replaceSharedDocument(document: Y.Doc, content: XenoDocNode, field?: string): void;
57
+ /** The shared document as the block's JSON, for a host that saves without an editor mounted. */
58
+ declare function sharedDocumentContent(document: Y.Doc, field?: string): XenoDocNode;
59
+
60
+ export { type CollaborationOptions, SHARED_FIELD, createCollaborationExtensions, isSharedDocumentEmpty, replaceSharedDocument, seedSharedDocument, sharedDocumentContent };
@@ -0,0 +1,49 @@
1
+ import {
2
+ createDocumentExtensions
3
+ } from "../chunk-KC2QBI2I.js";
4
+ import "../chunk-MDNEMOZD.js";
5
+ import "../chunk-2KG3PWR4.js";
6
+
7
+ // src/docs/collaboration.ts
8
+ import { getSchema } from "@tiptap/core";
9
+ import Collaboration from "@tiptap/extension-collaboration";
10
+ import CollaborationCursor from "@tiptap/extension-collaboration-cursor";
11
+ import { prosemirrorJSONToYXmlFragment, yXmlFragmentToProseMirrorRootNode } from "y-prosemirror";
12
+ var SHARED_FIELD = "prosemirror";
13
+ function createCollaborationExtensions(options) {
14
+ const field = options.field ?? SHARED_FIELD;
15
+ const list = [Collaboration.configure({ document: options.document, field })];
16
+ if (options.cursors) list.push(CollaborationCursor.configure({ provider: { awareness: options.cursors.awareness }, user: options.cursors.user }));
17
+ return list;
18
+ }
19
+ var schema = null;
20
+ function documentSchema() {
21
+ return schema ??= getSchema(createDocumentExtensions({ history: false }));
22
+ }
23
+ var fragmentOf = (document, field) => document.getXmlFragment(field ?? SHARED_FIELD);
24
+ function isSharedDocumentEmpty(document, field) {
25
+ return fragmentOf(document, field).length === 0;
26
+ }
27
+ function seedSharedDocument(document, content, field) {
28
+ if (!isSharedDocumentEmpty(document, field)) return false;
29
+ document.transact(() => {
30
+ prosemirrorJSONToYXmlFragment(documentSchema(), content, fragmentOf(document, field));
31
+ });
32
+ return true;
33
+ }
34
+ function replaceSharedDocument(document, content, field) {
35
+ document.transact(() => {
36
+ prosemirrorJSONToYXmlFragment(documentSchema(), content, fragmentOf(document, field));
37
+ });
38
+ }
39
+ function sharedDocumentContent(document, field) {
40
+ return yXmlFragmentToProseMirrorRootNode(fragmentOf(document, field), documentSchema()).toJSON();
41
+ }
42
+ export {
43
+ SHARED_FIELD,
44
+ createCollaborationExtensions,
45
+ isSharedDocumentEmpty,
46
+ replaceSharedDocument,
47
+ seedSharedDocument,
48
+ sharedDocumentContent
49
+ };
@@ -1,5 +1,6 @@
1
- import { XenoDocNode } from './format.js';
2
- export { DOCUMENT_MARK_TYPES, DOCUMENT_NODE_TYPES, JSONContent, LIMITS, SAFE_IMAGE, SAFE_LINK, ValidateOptions, XDOC_EXTENSION, XDOC_FORMAT, XDOC_VERSION, XdocError, XenoDocFile, XenoDocMark, XenoDocProblem, documentToMarkdown, emptyContent, markdownToDocument, nodeTypesIn, pageLinksIn, parseXdoc, plainText, serializeXdoc, validateContent, wordCount } from './format.js';
1
+ import { X as XenoDocNode } from '../format-BoLLqtrs.js';
2
+ export { D as DOCUMENT_MARK_TYPES, a as DOCUMENT_NODE_TYPES, L as LIMITS, S as SAFE_IMAGE, b as SAFE_LINK, V as ValidateOptions, c as XDOC_EXTENSION, d as XDOC_FORMAT, e as XDOC_VERSION, f as XdocError, g as XenoDocFile, h as XenoDocMark, i as XenoDocProblem, j as emptyContent, n as nodeTypesIn, p as pageLinksIn, k as parseXdoc, l as plainText, s as serializeXdoc, v as validateContent, w as wordCount } from '../format-BoLLqtrs.js';
3
+ export { JSONContent, documentToMarkdown, markdownToDocument } from './format.js';
3
4
  import * as _tiptap_core from '@tiptap/core';
4
5
  import { Node, Mark, AnyExtension, Editor } from '@tiptap/core';
5
6
  import * as _tiptap_extension_image from '@tiptap/extension-image';
@@ -286,11 +287,17 @@ interface DocumentSurfaceOptions extends Omit<DocumentExtensionOptions, 'onOpenP
286
287
  editorClass?: string;
287
288
  /** Accessible name for the text area. */
288
289
  label?: string;
290
+ /**
291
+ * The text lives in a SHARED document that `extensions` bind the editor to (`@xenosystem/blocks/docs/collaboration`,
292
+ * a Y.js document the host keeps in step). The surface then puts no content in the editor and a `load` never replaces
293
+ * it: replacing it here would replace it for everyone writing in it. Pass `history: false` with it (Y.js brings undo).
294
+ */
295
+ shared?: boolean;
289
296
  }
290
297
  /** Run one format command on a TipTap editor. Exported so XENO Docs' toolbar uses the SAME map. */
291
298
  declare function runFormat(editor: Editor, command: DocumentFormatCommand, arg?: unknown, promptLink?: DocumentSurfaceOptions['promptLink']): boolean;
292
299
  /** A {@link DocumentEditorHandle} over a TipTap editor. */
293
- declare function editorHandle(editor: Editor, promptLink?: DocumentSurfaceOptions['promptLink']): DocumentEditorHandle;
300
+ declare function editorHandle(editor: Editor, promptLink?: DocumentSurfaceOptions['promptLink'], shared?: boolean): DocumentEditorHandle;
294
301
  /**
295
302
  * Mount the editor into `element` and bind it to `controller`. Returns the teardown, which destroys
296
303
  * the editor — call it before the element is removed.
package/dist/docs/core.js CHANGED
@@ -1,18 +1,24 @@
1
1
  import {
2
- Callout,
3
2
  DOCUMENT_FORMAT_COMMANDS,
4
3
  DOCUMENT_TOOLBAR,
5
4
  DocumentController,
6
- PageBreak,
7
- SafeImage,
8
- ToggleBlock,
9
- WikiLinkMark,
10
- createDocumentExtensions,
11
5
  editorHandle,
12
6
  mountDocumentSurface,
13
7
  runFormat
14
- } from "../chunk-5VOA3OSG.js";
8
+ } from "../chunk-JEY4JFVJ.js";
15
9
  import "../chunk-HDP35LGH.js";
10
+ import {
11
+ documentToMarkdown,
12
+ markdownToDocument
13
+ } from "../chunk-5NDMACVU.js";
14
+ import {
15
+ Callout,
16
+ PageBreak,
17
+ SafeImage,
18
+ ToggleBlock,
19
+ WikiLinkMark,
20
+ createDocumentExtensions
21
+ } from "../chunk-KC2QBI2I.js";
16
22
  import {
17
23
  DOCUMENT_MARK_TYPES,
18
24
  DOCUMENT_NODE_TYPES,
@@ -23,9 +29,7 @@ import {
23
29
  XDOC_FORMAT,
24
30
  XDOC_VERSION,
25
31
  XdocError,
26
- documentToMarkdown,
27
32
  emptyContent,
28
- markdownToDocument,
29
33
  nodeTypesIn,
30
34
  pageLinksIn,
31
35
  parseXdoc,
@@ -33,7 +37,7 @@ import {
33
37
  serializeXdoc,
34
38
  validateContent,
35
39
  wordCount
36
- } from "../chunk-NFOBZJDF.js";
40
+ } from "../chunk-MDNEMOZD.js";
37
41
  import "../chunk-2KG3PWR4.js";
38
42
  export {
39
43
  Callout,
@@ -1,125 +1,5 @@
1
- /**
2
- * The XENO document FORMAT — `.xdoc`, XENO Docs' native file, now the one format every surface that
3
- * edits a document reads and writes (XENO Docs, XENO Notes' link mark, the platform workspace's
4
- * Write and Notes).
5
- *
6
- * A `.xdoc` is JSON: an envelope around a ProseMirror document (`content`, the TipTap `getJSON()`
7
- * shape). It is NOT HTML and is never rendered as HTML: a surface turns `content` into DOM through
8
- * the schema in `./schema`, which only knows the node and mark types listed here. That is the whole
9
- * XSS argument, and this module is what keeps it true at every boundary that accepts a file:
10
- *
11
- * - every node / mark type must be one of {@link DOCUMENT_NODE_TYPES} / {@link DOCUMENT_MARK_TYPES}
12
- * (a product may widen the set for ITS OWN extensions with `extraNodes` / `extraMarks`);
13
- * - every attribute is checked against the type's own rule — a link's `href` must be http(s) or
14
- * mailto, an image's `src` https or a raster `data:` image, a page link's id a UUID;
15
- * - depth and node count are bounded.
16
- *
17
- * {@link validateContent} reports what it refused instead of dropping it: a server refuses the file,
18
- * a surface opens it read-only. Silently dropping an unknown block would lose the user's words on the
19
- * next save — the same outcome as a bug, with a better excuse.
20
- *
21
- * This module imports nothing (no TipTap, no DOM), so a server, a migration script or a test can use
22
- * it without an editor.
23
- *
24
- * @module
25
- */
26
- /** The `format` field every `.xdoc` written from now on carries. */
27
- declare const XDOC_FORMAT = "xeno.xdoc";
28
- /** The current envelope version. */
29
- declare const XDOC_VERSION = 1;
30
- /** The file extension XENO Docs ships (`DocumentEditor.tsx` — `${title}.xdoc`). */
31
- declare const XDOC_EXTENSION = ".xdoc";
32
- /** One ProseMirror node, as TipTap's `getJSON()` writes it. */
33
- interface XenoDocNode {
34
- type: string;
35
- attrs?: Record<string, unknown>;
36
- content?: XenoDocNode[];
37
- marks?: XenoDocMark[];
38
- text?: string;
39
- }
40
- /** One mark on a text node. */
41
- interface XenoDocMark {
42
- type: string;
43
- attrs?: Record<string, unknown>;
44
- }
45
- /**
46
- * The `.xdoc` envelope. Field names are exactly the ones XENO Docs' autosave has always written
47
- * (`id, title, content, lastModified, created, wordCount`), so every existing file still parses;
48
- * `format` and `version` are the additive part.
49
- */
50
- interface XenoDocFile {
51
- format: typeof XDOC_FORMAT;
52
- version: number;
53
- id?: string;
54
- title: string;
55
- content: XenoDocNode;
56
- created: number;
57
- lastModified: number;
58
- wordCount: number;
59
- /**
60
- * XENO Docs' comment threads (its `Comment` mark points into them; XENO Docs keeps them as an object keyed by thread id). Carried through untouched by every surface,
61
- * so a document that round-trips through the workspace keeps its comments; only XENO Docs reads them.
62
- */
63
- commentThreads?: unknown;
64
- }
65
- /** Node types the shared schema renders. A file with any other type is refused, never coerced. */
66
- declare const DOCUMENT_NODE_TYPES: readonly ["doc", "paragraph", "text", "heading", "blockquote", "bulletList", "orderedList", "listItem", "taskList", "taskItem", "codeBlock", "horizontalRule", "hardBreak", "table", "tableRow", "tableCell", "tableHeader", "image", "callout", "toggleBlock", "pageBreak"];
67
- /** Mark types the shared schema renders. */
68
- declare const DOCUMENT_MARK_TYPES: readonly ["bold", "italic", "strike", "code", "underline", "link", "subscript", "superscript", "highlight", "wikiLink"];
69
- /** A link a reader can follow without running anything. */
70
- declare const SAFE_LINK: RegExp;
71
- /** An image a reader can load without running anything: https, or a raster image inline. */
72
- declare const SAFE_IMAGE: RegExp;
73
- /** Limits a file must stay inside. */
74
- declare const LIMITS: Readonly<{
75
- depth: 64;
76
- nodes: 50000;
77
- text: 2000000;
78
- }>;
79
- /** One reason a document was refused. `path` points at the offending node (`content[2].content[0]`). */
80
- interface XenoDocProblem {
81
- path: string;
82
- code: 'unknown_node' | 'unknown_mark' | 'bad_attr' | 'bad_shape' | 'too_deep' | 'too_large';
83
- detail: string;
84
- }
85
- /** Options for {@link validateContent}: a product's own extensions, allowed in ITS files only. */
86
- interface ValidateOptions {
87
- extraNodes?: Iterable<string>;
88
- extraMarks?: Iterable<string>;
89
- }
90
- /**
91
- * Check a ProseMirror document against the shared schema. Pure; never throws for bad input.
92
- *
93
- * Types in `extraNodes` / `extraMarks` are accepted with their attributes unchecked: they belong to the
94
- * product that declared them, and only that product's surface renders them.
95
- */
96
- declare function validateContent(content: unknown, options?: ValidateOptions): XenoDocProblem[];
97
- /** The error {@link parseXdoc} throws: the problems ride on it so a caller can say exactly what is wrong. */
98
- declare class XdocError extends Error {
99
- readonly problems: XenoDocProblem[];
100
- constructor(message: string, problems?: XenoDocProblem[]);
101
- }
102
- /** An empty document: one empty paragraph, which is what TipTap writes for a blank editor. */
103
- declare const emptyContent: () => XenoDocNode;
104
- /**
105
- * Parse a `.xdoc` file (text or an already-parsed object). Accepts the legacy XENO Docs envelope with
106
- * no `format` field. Throws {@link XdocError} for anything the shared schema would not render.
107
- */
108
- declare function parseXdoc(input: string | unknown, options?: ValidateOptions): XenoDocFile;
109
- /** Write a `.xdoc`. Validates first: a surface must never write a file the next surface refuses. */
110
- declare function serializeXdoc(doc: Omit<XenoDocFile, 'format' | 'version' | 'wordCount'> & {
111
- wordCount?: number;
112
- }, options?: ValidateOptions & {
113
- pretty?: boolean;
114
- }): string;
115
- /** The document's words without structure — what search indexes and an excerpt shows. */
116
- declare function plainText(content: XenoDocNode | undefined): string;
117
- /** Words, the way XENO Docs' status bar counts them. */
118
- declare function wordCount(content: XenoDocNode | undefined): number;
119
- /** The ids every page link (`wikiLink` mark) in the document points at, deduplicated, in order. */
120
- declare function pageLinksIn(content: XenoDocNode | undefined): string[];
121
- /** Every node type in a document — what a surface checks before it decides it can edit it. */
122
- declare function nodeTypesIn(content: XenoDocNode | undefined): Set<string>;
1
+ import { X as XenoDocNode } from '../format-BoLLqtrs.js';
2
+ export { D as DOCUMENT_MARK_TYPES, a as DOCUMENT_NODE_TYPES, L as LIMITS, S as SAFE_IMAGE, b as SAFE_LINK, V as ValidateOptions, c as XDOC_EXTENSION, d as XDOC_FORMAT, e as XDOC_VERSION, f as XdocError, g as XenoDocFile, h as XenoDocMark, i as XenoDocProblem, j as emptyContent, n as nodeTypesIn, p as pageLinksIn, k as parseXdoc, l as plainText, s as serializeXdoc, v as validateContent, w as wordCount } from '../format-BoLLqtrs.js';
123
3
 
124
4
  /**
125
5
  * Markdown import/export engine
@@ -142,4 +22,4 @@ interface JSONContent {
142
22
  declare function documentToMarkdown(doc: JSONContent): string;
143
23
  declare function markdownToDocument(md: string): XenoDocNode;
144
24
 
145
- export { DOCUMENT_MARK_TYPES, DOCUMENT_NODE_TYPES, type JSONContent, LIMITS, SAFE_IMAGE, SAFE_LINK, type ValidateOptions, XDOC_EXTENSION, XDOC_FORMAT, XDOC_VERSION, XdocError, type XenoDocFile, type XenoDocMark, type XenoDocNode, type XenoDocProblem, documentToMarkdown, emptyContent, markdownToDocument, nodeTypesIn, pageLinksIn, parseXdoc, plainText, serializeXdoc, validateContent, wordCount };
25
+ export { type JSONContent, XenoDocNode, documentToMarkdown, markdownToDocument };
@@ -1,4 +1,8 @@
1
1
  import "../chunk-HDP35LGH.js";
2
+ import {
3
+ documentToMarkdown,
4
+ markdownToDocument
5
+ } from "../chunk-5NDMACVU.js";
2
6
  import {
3
7
  DOCUMENT_MARK_TYPES,
4
8
  DOCUMENT_NODE_TYPES,
@@ -9,9 +13,7 @@ import {
9
13
  XDOC_FORMAT,
10
14
  XDOC_VERSION,
11
15
  XdocError,
12
- documentToMarkdown,
13
16
  emptyContent,
14
- markdownToDocument,
15
17
  nodeTypesIn,
16
18
  pageLinksIn,
17
19
  parseXdoc,
@@ -19,7 +21,7 @@ import {
19
21
  serializeXdoc,
20
22
  validateContent,
21
23
  wordCount
22
- } from "../chunk-NFOBZJDF.js";
24
+ } from "../chunk-MDNEMOZD.js";
23
25
  import "../chunk-2KG3PWR4.js";
24
26
  export {
25
27
  DOCUMENT_MARK_TYPES,
@@ -1,4 +1,5 @@
1
- export { DOCUMENT_MARK_TYPES, DOCUMENT_NODE_TYPES, JSONContent, LIMITS, SAFE_IMAGE, SAFE_LINK, ValidateOptions, XDOC_EXTENSION, XDOC_FORMAT, XDOC_VERSION, XdocError, XenoDocFile, XenoDocMark, XenoDocNode, XenoDocProblem, documentToMarkdown, emptyContent, markdownToDocument, nodeTypesIn, pageLinksIn, parseXdoc, plainText, serializeXdoc, validateContent, wordCount } from './format.js';
1
+ export { D as DOCUMENT_MARK_TYPES, a as DOCUMENT_NODE_TYPES, L as LIMITS, S as SAFE_IMAGE, b as SAFE_LINK, V as ValidateOptions, c as XDOC_EXTENSION, d as XDOC_FORMAT, e as XDOC_VERSION, f as XdocError, g as XenoDocFile, h as XenoDocMark, X as XenoDocNode, i as XenoDocProblem, j as emptyContent, n as nodeTypesIn, p as pageLinksIn, k as parseXdoc, l as plainText, s as serializeXdoc, v as validateContent, w as wordCount } from '../format-BoLLqtrs.js';
2
+ export { JSONContent, documentToMarkdown, markdownToDocument } from './format.js';
2
3
  import { DocumentController, DocumentSurfaceOptions, DocumentFormatCommand } from './core.js';
3
4
  export { Callout, CalloutType, DOCUMENT_FORMAT_COMMANDS, DOCUMENT_TOOLBAR, DocumentControllerOptions, DocumentEditorHandle, DocumentExtensionOptions, DocumentHostBridge, DocumentState, PageBreak, SafeImage, ToggleBlock, WikiLinkMark, WikiLinkOptions, XenoDocumentInput, XenoDocumentOpenPage, XenoDocumentSave, XenoDocumentStatus, createDocumentExtensions, editorHandle, mountDocumentSurface, runFormat } from './core.js';
4
5
  import { PanelModule, PanelManifest, BlockDeclaration } from '@xenosystem/block-sdk';
@@ -1,17 +1,23 @@
1
1
  import {
2
- Callout,
3
2
  DOCUMENT_FORMAT_COMMANDS,
4
3
  DOCUMENT_TOOLBAR,
5
4
  DocumentController,
5
+ editorHandle,
6
+ mountDocumentSurface,
7
+ runFormat
8
+ } from "../chunk-JEY4JFVJ.js";
9
+ import {
10
+ documentToMarkdown,
11
+ markdownToDocument
12
+ } from "../chunk-5NDMACVU.js";
13
+ import {
14
+ Callout,
6
15
  PageBreak,
7
16
  SafeImage,
8
17
  ToggleBlock,
9
18
  WikiLinkMark,
10
- createDocumentExtensions,
11
- editorHandle,
12
- mountDocumentSurface,
13
- runFormat
14
- } from "../chunk-5VOA3OSG.js";
19
+ createDocumentExtensions
20
+ } from "../chunk-KC2QBI2I.js";
15
21
  import {
16
22
  DOCUMENT_MARK_TYPES,
17
23
  DOCUMENT_NODE_TYPES,
@@ -22,9 +28,7 @@ import {
22
28
  XDOC_FORMAT,
23
29
  XDOC_VERSION,
24
30
  XdocError,
25
- documentToMarkdown,
26
31
  emptyContent,
27
- markdownToDocument,
28
32
  nodeTypesIn,
29
33
  pageLinksIn,
30
34
  parseXdoc,
@@ -32,7 +36,7 @@ import {
32
36
  serializeXdoc,
33
37
  validateContent,
34
38
  wordCount
35
- } from "../chunk-NFOBZJDF.js";
39
+ } from "../chunk-MDNEMOZD.js";
36
40
  import "../chunk-2KG3PWR4.js";
37
41
 
38
42
  // src/docs/document/panel.ts
@@ -0,0 +1,124 @@
1
+ /**
2
+ * The XENO document FORMAT — `.xdoc`, XENO Docs' native file, now the one format every surface that
3
+ * edits a document reads and writes (XENO Docs, XENO Notes' link mark, the platform workspace's
4
+ * Write and Notes).
5
+ *
6
+ * A `.xdoc` is JSON: an envelope around a ProseMirror document (`content`, the TipTap `getJSON()`
7
+ * shape). It is NOT HTML and is never rendered as HTML: a surface turns `content` into DOM through
8
+ * the schema in `./schema`, which only knows the node and mark types listed here. That is the whole
9
+ * XSS argument, and this module is what keeps it true at every boundary that accepts a file:
10
+ *
11
+ * - every node / mark type must be one of {@link DOCUMENT_NODE_TYPES} / {@link DOCUMENT_MARK_TYPES}
12
+ * (a product may widen the set for ITS OWN extensions with `extraNodes` / `extraMarks`);
13
+ * - every attribute is checked against the type's own rule — a link's `href` must be http(s) or
14
+ * mailto, an image's `src` https or a raster `data:` image, a page link's id a UUID;
15
+ * - depth and node count are bounded.
16
+ *
17
+ * {@link validateContent} reports what it refused instead of dropping it: a server refuses the file,
18
+ * a surface opens it read-only. Silently dropping an unknown block would lose the user's words on the
19
+ * next save — the same outcome as a bug, with a better excuse.
20
+ *
21
+ * This module imports nothing (no TipTap, no DOM), so a server, a migration script or a test can use
22
+ * it without an editor.
23
+ *
24
+ * @module
25
+ */
26
+ /** The `format` field every `.xdoc` written from now on carries. */
27
+ declare const XDOC_FORMAT = "xeno.xdoc";
28
+ /** The current envelope version. */
29
+ declare const XDOC_VERSION = 1;
30
+ /** The file extension XENO Docs ships (`DocumentEditor.tsx` — `${title}.xdoc`). */
31
+ declare const XDOC_EXTENSION = ".xdoc";
32
+ /** One ProseMirror node, as TipTap's `getJSON()` writes it. */
33
+ interface XenoDocNode {
34
+ type: string;
35
+ attrs?: Record<string, unknown>;
36
+ content?: XenoDocNode[];
37
+ marks?: XenoDocMark[];
38
+ text?: string;
39
+ }
40
+ /** One mark on a text node. */
41
+ interface XenoDocMark {
42
+ type: string;
43
+ attrs?: Record<string, unknown>;
44
+ }
45
+ /**
46
+ * The `.xdoc` envelope. Field names are exactly the ones XENO Docs' autosave has always written
47
+ * (`id, title, content, lastModified, created, wordCount`), so every existing file still parses;
48
+ * `format` and `version` are the additive part.
49
+ */
50
+ interface XenoDocFile {
51
+ format: typeof XDOC_FORMAT;
52
+ version: number;
53
+ id?: string;
54
+ title: string;
55
+ content: XenoDocNode;
56
+ created: number;
57
+ lastModified: number;
58
+ wordCount: number;
59
+ /**
60
+ * XENO Docs' comment threads (its `Comment` mark points into them; XENO Docs keeps them as an object keyed by thread id). Carried through untouched by every surface,
61
+ * so a document that round-trips through the workspace keeps its comments; only XENO Docs reads them.
62
+ */
63
+ commentThreads?: unknown;
64
+ }
65
+ /** Node types the shared schema renders. A file with any other type is refused, never coerced. */
66
+ declare const DOCUMENT_NODE_TYPES: readonly ["doc", "paragraph", "text", "heading", "blockquote", "bulletList", "orderedList", "listItem", "taskList", "taskItem", "codeBlock", "horizontalRule", "hardBreak", "table", "tableRow", "tableCell", "tableHeader", "image", "callout", "toggleBlock", "pageBreak"];
67
+ /** Mark types the shared schema renders. */
68
+ declare const DOCUMENT_MARK_TYPES: readonly ["bold", "italic", "strike", "code", "underline", "link", "subscript", "superscript", "highlight", "wikiLink"];
69
+ /** A link a reader can follow without running anything. */
70
+ declare const SAFE_LINK: RegExp;
71
+ /** An image a reader can load without running anything: https, or a raster image inline. */
72
+ declare const SAFE_IMAGE: RegExp;
73
+ /** Limits a file must stay inside. */
74
+ declare const LIMITS: Readonly<{
75
+ depth: 64;
76
+ nodes: 50000;
77
+ text: 2000000;
78
+ }>;
79
+ /** One reason a document was refused. `path` points at the offending node (`content[2].content[0]`). */
80
+ interface XenoDocProblem {
81
+ path: string;
82
+ code: 'unknown_node' | 'unknown_mark' | 'bad_attr' | 'bad_shape' | 'too_deep' | 'too_large';
83
+ detail: string;
84
+ }
85
+ /** Options for {@link validateContent}: a product's own extensions, allowed in ITS files only. */
86
+ interface ValidateOptions {
87
+ extraNodes?: Iterable<string>;
88
+ extraMarks?: Iterable<string>;
89
+ }
90
+ /**
91
+ * Check a ProseMirror document against the shared schema. Pure; never throws for bad input.
92
+ *
93
+ * Types in `extraNodes` / `extraMarks` are accepted with their attributes unchecked: they belong to the
94
+ * product that declared them, and only that product's surface renders them.
95
+ */
96
+ declare function validateContent(content: unknown, options?: ValidateOptions): XenoDocProblem[];
97
+ /** The error {@link parseXdoc} throws: the problems ride on it so a caller can say exactly what is wrong. */
98
+ declare class XdocError extends Error {
99
+ readonly problems: XenoDocProblem[];
100
+ constructor(message: string, problems?: XenoDocProblem[]);
101
+ }
102
+ /** An empty document: one empty paragraph, which is what TipTap writes for a blank editor. */
103
+ declare const emptyContent: () => XenoDocNode;
104
+ /**
105
+ * Parse a `.xdoc` file (text or an already-parsed object). Accepts the legacy XENO Docs envelope with
106
+ * no `format` field. Throws {@link XdocError} for anything the shared schema would not render.
107
+ */
108
+ declare function parseXdoc(input: string | unknown, options?: ValidateOptions): XenoDocFile;
109
+ /** Write a `.xdoc`. Validates first: a surface must never write a file the next surface refuses. */
110
+ declare function serializeXdoc(doc: Omit<XenoDocFile, 'format' | 'version' | 'wordCount'> & {
111
+ wordCount?: number;
112
+ }, options?: ValidateOptions & {
113
+ pretty?: boolean;
114
+ }): string;
115
+ /** The document's words without structure — what search indexes and an excerpt shows. */
116
+ declare function plainText(content: XenoDocNode | undefined): string;
117
+ /** Words, the way XENO Docs' status bar counts them. */
118
+ declare function wordCount(content: XenoDocNode | undefined): number;
119
+ /** The ids every page link (`wikiLink` mark) in the document points at, deduplicated, in order. */
120
+ declare function pageLinksIn(content: XenoDocNode | undefined): string[];
121
+ /** Every node type in a document — what a surface checks before it decides it can edit it. */
122
+ declare function nodeTypesIn(content: XenoDocNode | undefined): Set<string>;
123
+
124
+ export { DOCUMENT_MARK_TYPES as D, LIMITS as L, SAFE_IMAGE as S, type ValidateOptions as V, type XenoDocNode as X, DOCUMENT_NODE_TYPES as a, SAFE_LINK as b, XDOC_EXTENSION as c, XDOC_FORMAT as d, XDOC_VERSION as e, XdocError as f, type XenoDocFile as g, type XenoDocMark as h, type XenoDocProblem as i, emptyContent as j, parseXdoc as k, plainText as l, nodeTypesIn as n, pageLinksIn as p, serializeXdoc as s, validateContent as v, wordCount as w };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,12 @@
1
+ export { P as PLATFORM_SHELL_BLOCK_MANIFEST, a as PLATFORM_SHELL_PANEL_ID } from './manifest-B2JS8PxD.js';
2
+ import '@xenosystem/block-sdk';
3
+
1
4
  /**
2
5
  * `@xenosystem/blocks` — rung 3 of the FRONT ladder — BLOCKS (`XENO FRONT-END HIERARCHY.md`).
3
6
  * Families are subpaths: `@xenosystem/blocks/auth`, `/edit`, `/data`, `/time`, `/ops`, `/trust`,
4
- * `/agent`, `/docs`, `/corpus`. This root re-exports nothing on purpose: import the family you mount, so a product
5
- * carries only it. Naming rule: `XENO PACKAGE NAMING - STANDARD.md`.
7
+ * `/agent`, `/docs`, `/corpus`, `/shell`. Import the family you mount so a product carries only it.
8
+ * Naming rule: `XENO PACKAGE NAMING - STANDARD.md`.
6
9
  */
7
- declare const BLOCKS_VERSION = "0.8.1";
10
+ declare const BLOCKS_VERSION = "0.25.0";
8
11
 
9
12
  export { BLOCKS_VERSION };
package/dist/index.js CHANGED
@@ -1,7 +1,13 @@
1
+ import {
2
+ PLATFORM_SHELL_BLOCK_MANIFEST,
3
+ PLATFORM_SHELL_PANEL_ID
4
+ } from "./chunk-OB3VAVQI.js";
1
5
  import "./chunk-2KG3PWR4.js";
2
6
 
3
7
  // src/index.ts
4
- var BLOCKS_VERSION = "0.8.1";
8
+ var BLOCKS_VERSION = "0.25.0";
5
9
  export {
6
- BLOCKS_VERSION
10
+ BLOCKS_VERSION,
11
+ PLATFORM_SHELL_BLOCK_MANIFEST,
12
+ PLATFORM_SHELL_PANEL_ID
7
13
  };
@@ -0,0 +1,18 @@
1
+ import { PanelManifest } from '@xenosystem/block-sdk';
2
+
3
+ /**
4
+ * The `xeno.core.shell` manifest — unified XENO Platform Application Shell block.
5
+ *
6
+ * Unifies the 56px icon rail, 15px concave corner flares, collapsible floating sidebar plate,
7
+ * 46px desktop topbar with native drag region & window controls, 21-stop theme switcher,
8
+ * and 9-state updater pill across every XENO desktop product and xeno-apps.
9
+ *
10
+ * @module
11
+ */
12
+
13
+ /** Canonical block manifest identifier. */
14
+ declare const PLATFORM_SHELL_PANEL_ID = "xeno.core.shell";
15
+ /** Canonical block manifest conforming to `@xenosystem/block-sdk`. */
16
+ declare const PLATFORM_SHELL_BLOCK_MANIFEST: PanelManifest;
17
+
18
+ export { PLATFORM_SHELL_BLOCK_MANIFEST as P, PLATFORM_SHELL_PANEL_ID as a };