worldorbit 2.5.13 → 2.5.15
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 +37 -11
- package/dist/unpkg/worldorbit-core.min.js +12 -5
- package/dist/unpkg/worldorbit-markdown.min.js +32 -23
- package/dist/unpkg/worldorbit-viewer.min.js +55 -41
- package/dist/unpkg/worldorbit.js +1713 -231
- package/dist/unpkg/worldorbit.min.js +58 -44
- package/package.json +2 -2
- package/packages/core/README.md +5 -1
- package/packages/core/dist/atlas-edit.d.ts +2 -2
- package/packages/core/dist/atlas-edit.js +70 -7
- package/packages/core/dist/atlas-utils.d.ts +22 -0
- package/packages/core/dist/atlas-utils.js +189 -0
- package/packages/core/dist/atlas-validate.d.ts +2 -0
- package/packages/core/dist/atlas-validate.js +285 -0
- package/packages/core/dist/draft-parse.js +786 -153
- package/packages/core/dist/draft.d.ts +3 -0
- package/packages/core/dist/draft.js +47 -3
- package/packages/core/dist/format.js +165 -9
- package/packages/core/dist/load.js +58 -13
- package/packages/core/dist/normalize.js +7 -0
- package/packages/core/dist/scene.js +66 -13
- package/packages/core/dist/types.d.ts +97 -3
- package/packages/markdown/README.md +1 -1
- package/packages/viewer/README.md +2 -1
- package/packages/viewer/dist/atlas-state.js +7 -1
- package/packages/viewer/dist/atlas-viewer.js +35 -1
- package/packages/viewer/dist/render.js +16 -7
- package/packages/viewer/dist/theme.js +4 -0
- package/packages/viewer/dist/tooltip.js +35 -0
- package/packages/viewer/dist/types.d.ts +7 -0
- package/packages/viewer/dist/viewer.js +4 -0
- package/packages/editor/dist/editor.d.ts +0 -2
- package/packages/editor/dist/editor.js +0 -2998
- package/packages/editor/dist/index.d.ts +0 -2
- package/packages/editor/dist/index.js +0 -1
- package/packages/editor/dist/types.d.ts +0 -53
- package/packages/editor/dist/types.js +0 -1
- package/packages/markdown/dist/html.d.ts +0 -3
- package/packages/markdown/dist/html.js +0 -57
- package/packages/markdown/dist/index.d.ts +0 -4
- package/packages/markdown/dist/index.js +0 -3
- package/packages/markdown/dist/rehype.d.ts +0 -10
- package/packages/markdown/dist/rehype.js +0 -49
- package/packages/markdown/dist/remark.d.ts +0 -9
- package/packages/markdown/dist/remark.js +0 -28
- package/packages/markdown/dist/types.d.ts +0 -11
- package/packages/markdown/dist/types.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createWorldOrbitEditor } from "./editor.js";
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { AtlasDocumentPath, AtlasResolvedDiagnostic, WorldOrbitAtlasDocument, WorldOrbitAtlasSystem, WorldOrbitAtlasViewpoint, WorldOrbitObject } from "@worldorbit/core";
|
|
2
|
-
export interface WorldOrbitEditorSelection {
|
|
3
|
-
path: AtlasDocumentPath | null;
|
|
4
|
-
}
|
|
5
|
-
export interface WorldOrbitEditorSnapshot {
|
|
6
|
-
source: string;
|
|
7
|
-
atlasDocument: WorldOrbitAtlasDocument;
|
|
8
|
-
diagnostics: AtlasResolvedDiagnostic[];
|
|
9
|
-
selection: WorldOrbitEditorSelection | null;
|
|
10
|
-
}
|
|
11
|
-
export interface WorldOrbitEditorOptions {
|
|
12
|
-
source?: string;
|
|
13
|
-
atlasDocument?: WorldOrbitAtlasDocument;
|
|
14
|
-
showTextPane?: boolean;
|
|
15
|
-
showInspector?: boolean;
|
|
16
|
-
showPreview?: boolean;
|
|
17
|
-
viewerWidth?: number;
|
|
18
|
-
viewerHeight?: number;
|
|
19
|
-
shortcuts?: boolean;
|
|
20
|
-
onChange?: (snapshot: WorldOrbitEditorSnapshot) => void;
|
|
21
|
-
onDiagnosticsChange?: (diagnostics: AtlasResolvedDiagnostic[]) => void;
|
|
22
|
-
onSelectionChange?: (selection: WorldOrbitEditorSelection | null) => void;
|
|
23
|
-
onDirtyChange?: (dirty: boolean) => void;
|
|
24
|
-
}
|
|
25
|
-
export interface WorldOrbitEditor {
|
|
26
|
-
setSource(source: string): void;
|
|
27
|
-
setAtlasDocument(document: WorldOrbitAtlasDocument): void;
|
|
28
|
-
getSource(): string;
|
|
29
|
-
getAtlasDocument(): WorldOrbitAtlasDocument;
|
|
30
|
-
getDiagnostics(): AtlasResolvedDiagnostic[];
|
|
31
|
-
getSelection(): WorldOrbitEditorSelection | null;
|
|
32
|
-
isDirty(): boolean;
|
|
33
|
-
markSaved(): void;
|
|
34
|
-
selectPath(path: AtlasDocumentPath | null): void;
|
|
35
|
-
canUndo(): boolean;
|
|
36
|
-
canRedo(): boolean;
|
|
37
|
-
undo(): boolean;
|
|
38
|
-
redo(): boolean;
|
|
39
|
-
addObject(type?: WorldOrbitObject["type"]): string;
|
|
40
|
-
addViewpoint(): string;
|
|
41
|
-
addAnnotation(): string;
|
|
42
|
-
addMetadata(key?: string, value?: string): string;
|
|
43
|
-
removeSelection(): boolean;
|
|
44
|
-
exportSvg(): string;
|
|
45
|
-
exportEmbedMarkup(): string;
|
|
46
|
-
destroy(): void;
|
|
47
|
-
}
|
|
48
|
-
export interface WorldOrbitEditorFormState {
|
|
49
|
-
selection: WorldOrbitEditorSelection | null;
|
|
50
|
-
system: WorldOrbitAtlasSystem | null;
|
|
51
|
-
viewpoints: WorldOrbitAtlasViewpoint[];
|
|
52
|
-
objects: WorldOrbitObject[];
|
|
53
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { loadWorldOrbitSource, renderDocumentToScene, } from "@worldorbit/core";
|
|
2
|
-
import { createEmbedPayload, createWorldOrbitEmbedMarkup, renderSceneToSvg, } from "@worldorbit/viewer";
|
|
3
|
-
export function renderWorldOrbitBlock(source, options = {}) {
|
|
4
|
-
try {
|
|
5
|
-
const loaded = loadWorldOrbitSource(source);
|
|
6
|
-
const scene = renderDocumentToScene(loaded.document, resolveSourceRenderOptions(loaded, options));
|
|
7
|
-
if ((options.mode ?? "static") === "interactive") {
|
|
8
|
-
return createWorldOrbitEmbedMarkup(createEmbedPayload(scene, "interactive", {
|
|
9
|
-
initialViewpointId: options.initialViewpointId,
|
|
10
|
-
initialSelectionObjectId: options.initialSelectionObjectId,
|
|
11
|
-
initialFilter: options.initialFilter ?? null,
|
|
12
|
-
atlasState: options.atlasState ?? null,
|
|
13
|
-
minimap: options.minimap,
|
|
14
|
-
}), {
|
|
15
|
-
className: options.className ?? "worldorbit-block worldorbit-interactive",
|
|
16
|
-
theme: options.theme,
|
|
17
|
-
layers: options.layers,
|
|
18
|
-
subtitle: options.subtitle,
|
|
19
|
-
preset: options.preset,
|
|
20
|
-
initialViewpointId: options.initialViewpointId,
|
|
21
|
-
initialSelectionObjectId: options.initialSelectionObjectId,
|
|
22
|
-
initialFilter: options.initialFilter ?? null,
|
|
23
|
-
atlasState: options.atlasState ?? null,
|
|
24
|
-
minimap: options.minimap,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
return `<figure class="${escapeAttribute(options.className ?? "worldorbit-block worldorbit-static")}">${renderSceneToSvg(scene, options)}</figure>`;
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
if (options.strict) {
|
|
31
|
-
throw error;
|
|
32
|
-
}
|
|
33
|
-
return renderWorldOrbitError(error instanceof Error ? error.message : String(error));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export function renderWorldOrbitError(message) {
|
|
37
|
-
return `<pre class="worldorbit-error">WorldOrbit error: ${escapeHtml(message)}</pre>`;
|
|
38
|
-
}
|
|
39
|
-
function escapeHtml(value) {
|
|
40
|
-
return value
|
|
41
|
-
.replaceAll("&", "&")
|
|
42
|
-
.replaceAll("<", "<")
|
|
43
|
-
.replaceAll(">", ">");
|
|
44
|
-
}
|
|
45
|
-
function escapeAttribute(value) {
|
|
46
|
-
return escapeHtml(value).replaceAll("\"", """);
|
|
47
|
-
}
|
|
48
|
-
function resolveSourceRenderOptions(loaded, options) {
|
|
49
|
-
const atlasDocument = loaded.atlasDocument ?? loaded.draftDocument;
|
|
50
|
-
if (options.preset || !atlasDocument?.system?.defaults.preset) {
|
|
51
|
-
return options;
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
...options,
|
|
55
|
-
preset: atlasDocument.system.defaults.preset,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { WorldOrbitMarkdownOptions } from "./types.js";
|
|
2
|
-
interface HastNode {
|
|
3
|
-
type: string;
|
|
4
|
-
tagName?: string;
|
|
5
|
-
value?: string;
|
|
6
|
-
properties?: Record<string, unknown>;
|
|
7
|
-
children?: HastNode[];
|
|
8
|
-
}
|
|
9
|
-
export declare function rehypeWorldOrbit(options?: WorldOrbitMarkdownOptions): (tree: HastNode) => void;
|
|
10
|
-
export {};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { renderWorldOrbitBlock } from "./html.js";
|
|
2
|
-
export function rehypeWorldOrbit(options = {}) {
|
|
3
|
-
return function transform(tree) {
|
|
4
|
-
visitHastNodes(tree, (node, index, parent) => {
|
|
5
|
-
if (!parent || index === -1 || node.type !== "element" || node.tagName !== "pre") {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
const codeElement = node.children?.[0];
|
|
9
|
-
if (!codeElement || codeElement.type !== "element" || codeElement.tagName !== "code") {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const classNames = normalizeClassNames(codeElement.properties?.className);
|
|
13
|
-
if (!classNames.includes("language-worldorbit")) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const source = collectText(codeElement);
|
|
17
|
-
parent.children[index] = {
|
|
18
|
-
type: "raw",
|
|
19
|
-
value: renderWorldOrbitBlock(source, options),
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
function visitHastNodes(node, visitor, parent = null) {
|
|
25
|
-
const children = node.children ?? [];
|
|
26
|
-
for (let index = 0; index < children.length; index += 1) {
|
|
27
|
-
const child = children[index];
|
|
28
|
-
visitor(child, index, node);
|
|
29
|
-
visitHastNodes(child, visitor, node);
|
|
30
|
-
}
|
|
31
|
-
if (!parent) {
|
|
32
|
-
visitor(node, -1, null);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function normalizeClassNames(value) {
|
|
36
|
-
if (Array.isArray(value)) {
|
|
37
|
-
return value.map((entry) => String(entry));
|
|
38
|
-
}
|
|
39
|
-
if (typeof value === "string") {
|
|
40
|
-
return value.split(/\s+/).filter(Boolean);
|
|
41
|
-
}
|
|
42
|
-
return [];
|
|
43
|
-
}
|
|
44
|
-
function collectText(node) {
|
|
45
|
-
if (node.type === "text") {
|
|
46
|
-
return node.value ?? "";
|
|
47
|
-
}
|
|
48
|
-
return (node.children ?? []).map((child) => collectText(child)).join("");
|
|
49
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { WorldOrbitMarkdownOptions } from "./types.js";
|
|
2
|
-
interface MdNode {
|
|
3
|
-
type: string;
|
|
4
|
-
lang?: string | null;
|
|
5
|
-
value?: string;
|
|
6
|
-
children?: MdNode[];
|
|
7
|
-
}
|
|
8
|
-
export declare function remarkWorldOrbit(options?: WorldOrbitMarkdownOptions): (tree: MdNode) => void;
|
|
9
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { renderWorldOrbitBlock } from "./html.js";
|
|
2
|
-
export function remarkWorldOrbit(options = {}) {
|
|
3
|
-
return function transform(tree) {
|
|
4
|
-
visitMdNodes(tree, (node, index, parent) => {
|
|
5
|
-
if (!parent || index === -1 || node.type !== "code" || !isWorldOrbitLanguage(node.lang)) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
parent.children[index] = {
|
|
9
|
-
type: "html",
|
|
10
|
-
value: renderWorldOrbitBlock(node.value ?? "", options),
|
|
11
|
-
};
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function visitMdNodes(node, visitor, parent = null) {
|
|
16
|
-
const children = node.children ?? [];
|
|
17
|
-
for (let index = 0; index < children.length; index += 1) {
|
|
18
|
-
const child = children[index];
|
|
19
|
-
visitor(child, index, node);
|
|
20
|
-
visitMdNodes(child, visitor, node);
|
|
21
|
-
}
|
|
22
|
-
if (!parent) {
|
|
23
|
-
visitor(node, -1, null);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function isWorldOrbitLanguage(language) {
|
|
27
|
-
return (language ?? "").trim().toLowerCase() === "worldorbit";
|
|
28
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { SvgRenderOptions, ViewerAtlasState, ViewerFilter, WorldOrbitEmbedMode } from "@worldorbit/viewer";
|
|
2
|
-
export interface WorldOrbitMarkdownOptions extends SvgRenderOptions {
|
|
3
|
-
mode?: WorldOrbitEmbedMode;
|
|
4
|
-
strict?: boolean;
|
|
5
|
-
className?: string;
|
|
6
|
-
initialViewpointId?: string;
|
|
7
|
-
initialSelectionObjectId?: string;
|
|
8
|
-
initialFilter?: ViewerFilter | null;
|
|
9
|
-
atlasState?: ViewerAtlasState | null;
|
|
10
|
-
minimap?: boolean;
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|