@restless-dreams/orbit 0.0.0-stage → 0.2.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 +21 -0
- package/README.md +168 -2
- package/dist/bin/orbit.js +11666 -0
- package/dist/bin/orbit.js.map +60 -0
- package/dist/chunk-fkdfgtx9.js +17295 -0
- package/dist/chunk-fkdfgtx9.js.map +75 -0
- package/dist/chunk-y748hzcr.js +82 -0
- package/dist/chunk-y748hzcr.js.map +10 -0
- package/dist/chunk-zze4tc9n.js +408 -0
- package/dist/chunk-zze4tc9n.js.map +10 -0
- package/dist/core/auto-render.d.ts +85 -0
- package/dist/core/branch-colors.d.ts +57 -0
- package/dist/core/browser.d.ts +23 -0
- package/dist/core/create.d.ts +23 -0
- package/dist/core/diagnostics.d.ts +40 -0
- package/dist/core/dispatch.d.ts +23 -0
- package/dist/core/document-options.d.ts +18 -0
- package/dist/core/document-source.d.ts +128 -0
- package/dist/core/editing.d.ts +66 -0
- package/dist/core/engine/animation-clock.d.ts +40 -0
- package/dist/core/engine/camera.d.ts +70 -0
- package/dist/core/engine/colors.d.ts +51 -0
- package/dist/core/engine/display.d.ts +125 -0
- package/dist/core/engine/export.d.ts +32 -0
- package/dist/core/engine/glide.d.ts +34 -0
- package/dist/core/engine/labels.d.ts +106 -0
- package/dist/core/engine/node-drag.d.ts +49 -0
- package/dist/core/engine/scene.d.ts +160 -0
- package/dist/core/engine/spin.d.ts +62 -0
- package/dist/core/engine/surface-pattern.d.ts +20 -0
- package/dist/core/engine/text-measure.d.ts +116 -0
- package/dist/core/engine/views.d.ts +361 -0
- package/dist/core/extensions.d.ts +155 -0
- package/dist/core/format-upgrades.d.ts +33 -0
- package/dist/core/index.d.ts +46 -0
- package/dist/core/input-controller.d.ts +116 -0
- package/dist/core/languages.d.ts +201 -0
- package/dist/core/layout.d.ts +61 -0
- package/dist/core/map-tools/definitions.d.ts +71 -0
- package/dist/core/map-tools/input.d.ts +62 -0
- package/dist/core/map-tools/reading.d.ts +40 -0
- package/dist/core/map-tools/tools.d.ts +51 -0
- package/dist/core/markdown-writing.d.ts +87 -0
- package/dist/core/material.d.ts +25 -0
- package/dist/core/media.d.ts +42 -0
- package/dist/core/node-attributes.d.ts +31 -0
- package/dist/core/node-links.d.ts +25 -0
- package/dist/core/other-apps/freemind.d.ts +8 -0
- package/dist/core/other-apps/icons.d.ts +16 -0
- package/dist/core/other-apps/ideas.d.ts +76 -0
- package/dist/core/other-apps/import.d.ts +28 -0
- package/dist/core/other-apps/inflate.d.ts +22 -0
- package/dist/core/other-apps/markup.d.ts +51 -0
- package/dist/core/other-apps/notes.d.ts +80 -0
- package/dist/core/other-apps/opml.d.ts +26 -0
- package/dist/core/other-apps/reading.d.ts +36 -0
- package/dist/core/other-apps/xmind.d.ts +14 -0
- package/dist/core/other-apps/zip.d.ts +37 -0
- package/dist/core/parser-markdown.d.ts +42 -0
- package/dist/core/parser-yaml.d.ts +8 -0
- package/dist/core/print-layout.d.ts +70 -0
- package/dist/core/render-to-svg.d.ts +57 -0
- package/dist/core/renderer/content-painter.d.ts +30 -0
- package/dist/core/renderer/dom.d.ts +15 -0
- package/dist/core/renderer/families.d.ts +35 -0
- package/dist/core/renderer/label-painter.d.ts +93 -0
- package/dist/core/renderer/node-painter.d.ts +113 -0
- package/dist/core/renderer/numbers.d.ts +2 -0
- package/dist/core/renderer/options.d.ts +12 -0
- package/dist/core/renderer/rings-and-links.d.ts +23 -0
- package/dist/core/renderer/scene-helpers.d.ts +33 -0
- package/dist/core/renderer/trees.d.ts +22 -0
- package/dist/core/serializer-markdown.d.ts +18 -0
- package/dist/core/serializer-yaml.d.ts +2 -0
- package/dist/core/source-patch.d.ts +24 -0
- package/dist/core/source.d.ts +27 -0
- package/dist/core/styles.d.ts +6 -0
- package/dist/core/suggest.d.ts +8 -0
- package/dist/core/svg-renderer.d.ts +626 -0
- package/dist/core/text-layout.d.ts +54 -0
- package/dist/core/themes.d.ts +62 -0
- package/dist/core/types.d.ts +471 -0
- package/dist/core/ui/actions.d.ts +75 -0
- package/dist/core/ui/controls.d.ts +61 -0
- package/dist/core/ui/detail-sheet.d.ts +88 -0
- package/dist/core/ui/frames.d.ts +11 -0
- package/dist/core/ui/icons.d.ts +14 -0
- package/dist/core/ui/inline-editor.d.ts +79 -0
- package/dist/core/ui/media-players.d.ts +65 -0
- package/dist/core/ui/media-viewer.d.ts +169 -0
- package/dist/core/ui/media-zoom.d.ts +51 -0
- package/dist/core/ui/note-markdown.d.ts +19 -0
- package/dist/core/ui/outline.d.ts +44 -0
- package/dist/core/url-guard.d.ts +40 -0
- package/dist/core/utils.d.ts +23 -0
- package/dist/core/web-page/page.d.ts +59 -0
- package/dist/core/web-page/runtime.d.ts +13 -0
- package/dist/core/web-page/start.d.ts +1 -0
- package/dist/core/yaml-mini.d.ts +54 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4357 -0
- package/dist/index.js.map +29 -0
- package/dist/marked/index.d.ts +31 -0
- package/dist/marked/index.js +110 -0
- package/dist/marked/index.js.map +10 -0
- package/dist/react/index.d.ts +55 -0
- package/dist/react/index.js +352 -0
- package/dist/react/index.js.map +1 -0
- package/dist/web-page.d.ts +2 -0
- package/dist/web-page.js +130 -0
- package/llms-full.txt +2785 -0
- package/llms.txt +36 -0
- package/package.json +118 -4
- package/skills/orbit/SKILL.md +140 -0
- package/skills/orbit/references/editing.md +195 -0
- package/skills/orbit/references/extending.md +247 -0
- package/skills/orbit/references/format.md +331 -0
- package/skills/orbit/references/guide.md +546 -0
- package/skills/orbit/references/import-export.md +115 -0
- package/skills/orbit/references/languages.md +160 -0
- package/skills/orbit/references/map-tools.md +188 -0
- package/skills/orbit/references/media.md +160 -0
- package/skills/orbit/references/recipes.md +236 -0
- package/skills/orbit/references/theming.md +199 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How Orbit writes a map as markdown: its own form, the way people write
|
|
3
|
+
* maps. `serializeOrbitMarkdown` writes a whole map this way, and saving an
|
|
4
|
+
* edited map writes its changed ideas this way (see source-patch.ts).
|
|
5
|
+
*/
|
|
6
|
+
import type { OrbitDocument, OrbitNode } from './types.js';
|
|
7
|
+
/** A whole map in Orbit's own form. */
|
|
8
|
+
export declare const writeMarkdown: (doc: OrbitDocument) => string;
|
|
9
|
+
export declare const collectFrontmatter: (doc: Pick<OrbitDocument, "options" | "extra">) => Record<string, unknown>;
|
|
10
|
+
/**
|
|
11
|
+
* The root and its children are headings; everything under them is a
|
|
12
|
+
* list, the way people write maps. Below two levels, headings would only
|
|
13
|
+
* make a map harder to read.
|
|
14
|
+
*/
|
|
15
|
+
export declare const HEADING_LEVELS = 2;
|
|
16
|
+
/** The statuses a list item writes as a checkbox. */
|
|
17
|
+
export declare const CHECKBOXES: Record<string, string>;
|
|
18
|
+
/** What writing a node needs besides the node: which ids to write. */
|
|
19
|
+
export interface Writing {
|
|
20
|
+
/** The nodes whose ids the parsers wouldn't make from their text, so they are written. */
|
|
21
|
+
explicitIds: ReadonlySet<OrbitNode>;
|
|
22
|
+
}
|
|
23
|
+
export declare const emitHeading: (node: OrbitNode, level: number, writing: Writing) => string;
|
|
24
|
+
export declare const emitList: (children: OrbitNode[], indent: string, writing: Writing) => string;
|
|
25
|
+
/**
|
|
26
|
+
* A node as written: its line after the heading's `#`s or the item's
|
|
27
|
+
* marker (title, then the attributes that fit on it), and what follows the
|
|
28
|
+
* line, indented by `indent`.
|
|
29
|
+
*/
|
|
30
|
+
export declare const nodeParts: (node: OrbitNode, listItem: boolean, writing: Writing, indent: string) => {
|
|
31
|
+
line: string;
|
|
32
|
+
title: string;
|
|
33
|
+
inline: string;
|
|
34
|
+
body: string;
|
|
35
|
+
};
|
|
36
|
+
/** The pieces of a node as written, each ending with a line break (or empty): see `nodeParts`. */
|
|
37
|
+
export interface NodePieces {
|
|
38
|
+
title: string;
|
|
39
|
+
/** The attributes on the title line, with the space before them; empty when they don't fit there. */
|
|
40
|
+
inline: string;
|
|
41
|
+
/** The attributes that didn't fit on the line, as a block of their own. */
|
|
42
|
+
attributes: string;
|
|
43
|
+
media: string;
|
|
44
|
+
note: string;
|
|
45
|
+
}
|
|
46
|
+
export declare const nodePieces: (node: OrbitNode, listItem: boolean, writing: Writing, indent: string) => NodePieces;
|
|
47
|
+
export declare const titleLine: (node: OrbitNode, listItem: boolean, writing: Writing) => {
|
|
48
|
+
title: string;
|
|
49
|
+
attributes: Record<string, unknown>;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Attributes on the node's own line, `<!-- orbit status: done, priority: 2 -->`,
|
|
53
|
+
* when they are short, plain values: up to three of them, or more while the
|
|
54
|
+
* comment stays short, as a goal's numbers are (`type: goal, target: 5,
|
|
55
|
+
* current: 2, unit: apples`). Keys that wouldn't survive the comma-separated
|
|
56
|
+
* form (with a quote, a comma, a colon or a space of their own) go to the
|
|
57
|
+
* block form instead.
|
|
58
|
+
*/
|
|
59
|
+
export declare const inlineAttributes: (attributes: Record<string, unknown>) => string;
|
|
60
|
+
export declare const inlineValue: (value: unknown) => string | null;
|
|
61
|
+
/** What follows a node's line, indented under a list item: attributes that didn't fit on the line, media, then the note. */
|
|
62
|
+
export declare const body: (node: OrbitNode, blockAttributes: Record<string, unknown>, indent: string) => string;
|
|
63
|
+
/** Attributes as a `<!-- orbit … -->` block of their own, indented by `indent`; nothing when there are none. */
|
|
64
|
+
export declare const attributeBlock: (attributes: Record<string, unknown>, indent: string) => string;
|
|
65
|
+
/** A node's note as written under it, indented by `indent`. */
|
|
66
|
+
export declare const noteLines: (node: OrbitNode, indent: string) => string;
|
|
67
|
+
/**
|
|
68
|
+
* A note as paragraphs when they read back as the same note, otherwise
|
|
69
|
+
* quoted: quoted lines never turn into nodes, so a note can hold lines that
|
|
70
|
+
* look like headings, lists or media.
|
|
71
|
+
*/
|
|
72
|
+
export declare const noteText: (note: string, listItem: boolean) => string;
|
|
73
|
+
export declare const indentLines: (text: string, indent: string) => string;
|
|
74
|
+
/**
|
|
75
|
+
* A node's text as a heading or list item title: as is when it reads back
|
|
76
|
+
* unchanged, otherwise with its markup characters escaped.
|
|
77
|
+
*/
|
|
78
|
+
export declare const escapeTitle: (text: string) => string;
|
|
79
|
+
export declare const renderMedia: (node: OrbitNode) => string;
|
|
80
|
+
/**
|
|
81
|
+
* YAML to write inside an HTML comment. A "-->" in a value would end the
|
|
82
|
+
* comment early, so its ">" is written as an escape; strings holding one are
|
|
83
|
+
* always double-quoted, where the escape reads back as ">".
|
|
84
|
+
*/
|
|
85
|
+
export declare const commentYaml: (value: Record<string, unknown>) => string;
|
|
86
|
+
/** Attributes carried in `<!-- orbit ... -->` comments: the ones a node's title and lines don't show. */
|
|
87
|
+
export declare const collectAttrs: (node: OrbitNode, explicitIds: ReadonlySet<OrbitNode>) => Record<string, unknown>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { OrbitRendererTheme } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Material 3 themes from one color, the way Material You colors an app from
|
|
4
|
+
* its wallpaper: tonal palettes in the color's hue, surfaces and containers
|
|
5
|
+
* picked by tone, and branches in hues spread evenly around the color wheel
|
|
6
|
+
* from it. Picking colors by tone is what keeps text readable: two tones 50
|
|
7
|
+
* apart always have at least 4.5:1 contrast.
|
|
8
|
+
*/
|
|
9
|
+
/** Material's baseline color: the `material` and `material-night` themes are built from it. */
|
|
10
|
+
export declare const MATERIAL_SEED = "#6750A4";
|
|
11
|
+
export interface MaterialThemeOptions {
|
|
12
|
+
/** Dark surfaces with light text, like `material-night`, instead of light ones. */
|
|
13
|
+
dark?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** The tokens a Material theme takes from its color: everything else comes from `material` or `material-night`. */
|
|
16
|
+
export declare const MATERIAL_COLOR_TOKENS: readonly ["surface", "text", "muted-text", "root-text", "node-text", "node-text-inverse", "color-root", "color-1", "color-2", "color-3", "color-4", "color-5", "color-6", "color-7", "shade-light", "shade-dark", "node-stroke", "badge-stroke", "sun-halo", "ring-stroke", "link-stroke", "focus-ring", "note-indicator", "control-background", "control-text", "control-muted-text", "control-active-background", "control-active-text", "tooltip-background", "tooltip-text", "action-background", "action-text", "sheet-background", "sheet-text", "sheet-muted-text", "sheet-border", "chip-background", "chip-text", "link-text", "status-active", "status-done", "status-blocked", "status-todo", "status-neutral", "error-background", "error-border", "error-text"];
|
|
17
|
+
export type MaterialColorToken = (typeof MATERIAL_COLOR_TOKENS)[number];
|
|
18
|
+
/**
|
|
19
|
+
* A Material 3 theme built from `seed`, any CSS color Orbit reads (hex,
|
|
20
|
+
* `rgb()`, `oklch()`…). Use it as the `theme` option, or name it for every
|
|
21
|
+
* map: `registerTheme('brand', materialTheme('#0B57D0'))`.
|
|
22
|
+
*/
|
|
23
|
+
export declare const materialTheme: (seed: string, options?: MaterialThemeOptions) => OrbitRendererTheme;
|
|
24
|
+
/** Every color token of a Material theme built from `seed`. */
|
|
25
|
+
export declare const materialColors: (seed: string, dark: boolean) => Record<MaterialColorToken, string>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Video provider helpers shared by the parser (provider detection), the
|
|
3
|
+
* renderer (thumbnail derivation), and the detail sheet and media viewer
|
|
4
|
+
* (embed URL conversion, and links to a video's page on its site).
|
|
5
|
+
*
|
|
6
|
+
* YouTube and Vimeo forbid framing their watch pages (X-Frame-Options /
|
|
7
|
+
* frame-ancestors); only the dedicated embed endpoints may be iframed, so
|
|
8
|
+
* anything that puts a video URL into an <iframe> must go through
|
|
9
|
+
* `toVideoEmbedUrl` first.
|
|
10
|
+
*/
|
|
11
|
+
export type VideoProvider = 'youtube' | 'vimeo' | 'native';
|
|
12
|
+
/** Which player a video URL needs, by the site it is on; null when it isn't a video. */
|
|
13
|
+
export declare const detectVideoProvider: (url: string) => VideoProvider | null;
|
|
14
|
+
export declare const isNativeVideoUrl: (url: string) => boolean;
|
|
15
|
+
/** The video id in any of YouTube's URL shapes: watch pages, youtu.be, embeds, Shorts and lives. */
|
|
16
|
+
export declare const youtubeVideoId: (url: string) => string | null;
|
|
17
|
+
/**
|
|
18
|
+
* A Vimeo video's id, and the hash an unlisted video needs, from its page
|
|
19
|
+
* (`vimeo.com/123`, `/123/abc`, channels, groups, showcases) or its player.
|
|
20
|
+
*/
|
|
21
|
+
export declare const vimeoVideo: (url: string) => {
|
|
22
|
+
id: string;
|
|
23
|
+
hash?: string;
|
|
24
|
+
} | null;
|
|
25
|
+
/** The numeric id of a Vimeo video. */
|
|
26
|
+
export declare const vimeoVideoId: (url: string) => string | null;
|
|
27
|
+
/**
|
|
28
|
+
* Convert a video URL to a frameable embed URL. Returns null when no
|
|
29
|
+
* conversion is known (callers fall back to the original URL).
|
|
30
|
+
*/
|
|
31
|
+
export declare const toVideoEmbedUrl: (url: string, provider?: string) => string | null;
|
|
32
|
+
/** Whether a YouTube URL is a Short, a video that plays upright. */
|
|
33
|
+
export declare const isYouTubeShort: (url: string) => boolean;
|
|
34
|
+
/** Where a video is watched on its site: its YouTube or Vimeo page, or the URL itself. */
|
|
35
|
+
export declare const videoPageUrl: (url: string, provider?: string) => string;
|
|
36
|
+
export declare const youtubeThumbnailUrl: (url: string) => string | null;
|
|
37
|
+
/** True when an image, video or embed value has a usable `src`. */
|
|
38
|
+
export declare const hasMediaSource: (media: {
|
|
39
|
+
src?: unknown;
|
|
40
|
+
} | undefined | null) => media is {
|
|
41
|
+
src: string;
|
|
42
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { DiagnosticCollector } from './diagnostics.js';
|
|
2
|
+
import type { OrbitNode } from './types.js';
|
|
3
|
+
type ImageMedia = NonNullable<OrbitNode['image']>;
|
|
4
|
+
type VideoMedia = NonNullable<OrbitNode['video']>;
|
|
5
|
+
type EmbedMedia = NonNullable<OrbitNode['embed']>;
|
|
6
|
+
/**
|
|
7
|
+
* The fields a picture, video or embed was written with that Orbit doesn't
|
|
8
|
+
* read (a `width`, a provider it doesn't know): kept so saving writes them
|
|
9
|
+
* back, for a newer version or another app that reads them.
|
|
10
|
+
*/
|
|
11
|
+
export declare const mediaExtras: (media: object | undefined) => Record<string, unknown> | undefined;
|
|
12
|
+
/** A copy of a picture, video or embed, with the fields Orbit doesn't read. */
|
|
13
|
+
export declare const copyMedia: <Media extends object>(media: Media) => Media;
|
|
14
|
+
export declare const readImage: (value: unknown) => ImageMedia | undefined;
|
|
15
|
+
export declare const readVideo: (value: unknown) => VideoMedia | undefined;
|
|
16
|
+
export declare const readEmbed: (value: unknown) => EmbedMedia | undefined;
|
|
17
|
+
/** The attributes every node takes, in `<!-- orbit … -->` blocks and in YAML. */
|
|
18
|
+
export declare const NODE_ATTRIBUTE_KEYS: readonly ["color", "paletteColor", "icon", "status", "priority", "tags", "collapsed", "link", "note", "noteFormat", "image", "video", "embed", "caption", "id", "type"];
|
|
19
|
+
/** Keys a flavor accepts besides the node attributes, and the words that stand in for them. */
|
|
20
|
+
export interface AttributeVocabulary {
|
|
21
|
+
keys: readonly string[];
|
|
22
|
+
synonyms?: Readonly<Record<string, string>>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Applies one typed attribute (from a `<!-- orbit ... -->` block or a YAML
|
|
26
|
+
* node map) to a node. Unknown keys are kept in `node.attrs`, with a note
|
|
27
|
+
* when they look like a misspelled attribute. Values Orbit can't read are
|
|
28
|
+
* reported and kept in `node.attrs` too, so they're written back.
|
|
29
|
+
*/
|
|
30
|
+
export declare const assignNodeAttribute: (node: OrbitNode, key: string, value: unknown, diagnostics: DiagnosticCollector, line?: number, vocabulary?: AttributeVocabulary) => void;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Links between nodes. A node's link, or a link in its note, written as
|
|
3
|
+
* `#id` points at another node of the same map, the way `#heading` links
|
|
4
|
+
* point at a heading in a markdown page.
|
|
5
|
+
*/
|
|
6
|
+
import type { OrbitNode } from './types.js';
|
|
7
|
+
import type { DiagnosticCollector } from './diagnostics.js';
|
|
8
|
+
/** Whether a link points at a node of the same map: `#research`. */
|
|
9
|
+
export declare const isNodeLink: (href: string | undefined) => href is string;
|
|
10
|
+
/**
|
|
11
|
+
* The node a `#id` link points at: the node with that id, or the one whose
|
|
12
|
+
* id the fragment's text would get, so `#Research` and GitHub-style
|
|
13
|
+
* `#-research` anchors find `research` too.
|
|
14
|
+
*/
|
|
15
|
+
export declare const findLinkedNode: (root: OrbitNode, href: string) => OrbitNode | null;
|
|
16
|
+
/** `findLinkedNode` with the map's nodes indexed by `indexNodes`, for checking many links at once. */
|
|
17
|
+
export declare const findIndexedLinkedNode: (nodes: Map<string, OrbitNode>, href: string) => OrbitNode | null;
|
|
18
|
+
/** The map's nodes by id; when ids repeat, the first in the tree, as `findNodeById` finds it. */
|
|
19
|
+
export declare const indexNodes: (root: OrbitNode) => Map<string, OrbitNode>;
|
|
20
|
+
/** The `#id` links a node has: its link, then the ones in its note. */
|
|
21
|
+
export declare const nodeLinksOf: (node: OrbitNode) => string[];
|
|
22
|
+
/** Where a parser saw a node's link (`inNote` false) or a link in its note: the line it's on, when it knows. */
|
|
23
|
+
export type LinkLine = (node: OrbitNode, href: string, inNote: boolean) => number | undefined;
|
|
24
|
+
/** Reports each `#id` link, in a node's link or note, that points at no node of the map, on its own line where `lineOf` knows it. */
|
|
25
|
+
export declare const checkNodeLinks: (root: OrbitNode, diagnostics: DiagnosticCollector, lineOf?: LinkLine) => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FreeMind and Freeplane maps (`.mm`): nodes with their text (plain, or
|
|
3
|
+
* HTML), notes and Freeplane's details, links and arrow links, folds, icons,
|
|
4
|
+
* background colors, attributes and pictures.
|
|
5
|
+
*/
|
|
6
|
+
import { type OrbitImport, type OrbitImportOptions } from './reading.js';
|
|
7
|
+
/** A FreeMind or Freeplane map, from its file's bytes or text. */
|
|
8
|
+
export declare const importFreeMind: (data: Uint8Array | string, options?: OrbitImportOptions) => OrbitImport;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Other apps' icons and markers, as Orbit says the same thing: an emoji for
|
|
3
|
+
* the idea's icon, a priority, or a status. An icon with no meaning here
|
|
4
|
+
* returns null, and the reader warns that it was left out.
|
|
5
|
+
*/
|
|
6
|
+
export type IconMeaning = {
|
|
7
|
+
icon: string;
|
|
8
|
+
} | {
|
|
9
|
+
priority: number;
|
|
10
|
+
} | {
|
|
11
|
+
status: string;
|
|
12
|
+
};
|
|
13
|
+
/** A FreeMind or Freeplane icon's meaning: `full-3` is priority 3, `100%` done, `emoji-1F680` 🚀. */
|
|
14
|
+
export declare const freeMindIcon: (name: string) => IconMeaning | null;
|
|
15
|
+
/** An XMind marker's meaning: `priority-2` is priority 2, `task-done` done, `flag-red` 🚩. */
|
|
16
|
+
export declare const xmindMarker: (markerId: string) => IconMeaning | null;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What every reader of another app's file builds: a tree of ideas with what
|
|
3
|
+
* Orbit can show of each, the warnings for what it can't, and the step that
|
|
4
|
+
* turns the tree into an Orbit document, with ids the parsers would give it
|
|
5
|
+
* and links between ideas pointing at those ids.
|
|
6
|
+
*/
|
|
7
|
+
import type { OrbitDocument } from '../types.js';
|
|
8
|
+
import { type ImportedNote } from './notes.js';
|
|
9
|
+
/** Every kind of warning reading another app's map gives. */
|
|
10
|
+
export declare const IMPORT_WARNING_CODES: readonly ["floating-ideas-moved", "summaries-moved", "callouts-moved", "boundaries-in-notes", "links-in-notes", "missing-link-targets", "icons-not-kept", "pictures-not-kept", "attachments-not-kept", "local-links-not-kept", "encrypted-branches-not-read", "formatting-not-kept"];
|
|
11
|
+
export type OrbitImportWarningCode = (typeof IMPORT_WARNING_CODES)[number];
|
|
12
|
+
/** Something the other app's map had that Orbit keeps another way, or can't keep. */
|
|
13
|
+
export interface OrbitImportWarning {
|
|
14
|
+
code: OrbitImportWarningCode;
|
|
15
|
+
message: string;
|
|
16
|
+
/** How many places in the map it's about. */
|
|
17
|
+
count: number;
|
|
18
|
+
}
|
|
19
|
+
/** Every reason a file can't be read as a map. */
|
|
20
|
+
export declare const IMPORT_ERROR_CODES: readonly ["unknown-format", "unreadable", "empty", "password-protected", "too-large"];
|
|
21
|
+
export type OrbitImportErrorCode = (typeof IMPORT_ERROR_CODES)[number];
|
|
22
|
+
/** A file that can't be read as a map at all. */
|
|
23
|
+
export declare class OrbitImportError extends Error {
|
|
24
|
+
readonly code: OrbitImportErrorCode;
|
|
25
|
+
constructor(code: OrbitImportErrorCode, message: string);
|
|
26
|
+
}
|
|
27
|
+
/** The most ideas a map read from another app may have. */
|
|
28
|
+
export declare const MAX_IMPORTED_IDEAS = 100000;
|
|
29
|
+
/** The deepest a map read from another app may go. */
|
|
30
|
+
export declare const MAX_IMPORTED_DEPTH = 500;
|
|
31
|
+
/** A link from one idea to another, by the other app's id for it. */
|
|
32
|
+
export interface IdeaLink {
|
|
33
|
+
target: string;
|
|
34
|
+
/** What the other app calls the link, if anything. */
|
|
35
|
+
label?: string;
|
|
36
|
+
}
|
|
37
|
+
/** An idea as a reader finds it, before it becomes a node. */
|
|
38
|
+
export interface ImportedIdea {
|
|
39
|
+
text: string;
|
|
40
|
+
/** The other app's id for it, which links between ideas point at. */
|
|
41
|
+
sourceId?: string;
|
|
42
|
+
/** Its note, in parts: they're joined in order. */
|
|
43
|
+
notes: ImportedNote[];
|
|
44
|
+
/** A web or mail address. */
|
|
45
|
+
link?: string;
|
|
46
|
+
/** Links to other ideas: the first one becomes the idea's link when it has none, the others go in its note. */
|
|
47
|
+
ideaLinks: IdeaLink[];
|
|
48
|
+
collapsed?: boolean;
|
|
49
|
+
status?: string;
|
|
50
|
+
priority?: number;
|
|
51
|
+
tags: string[];
|
|
52
|
+
/** Emoji for its icons, in order: Orbit shows the first. */
|
|
53
|
+
icons: string[];
|
|
54
|
+
color?: string;
|
|
55
|
+
/** Its picture: a web address, or a file in the map's `media`. */
|
|
56
|
+
image?: string;
|
|
57
|
+
children: ImportedIdea[];
|
|
58
|
+
}
|
|
59
|
+
export declare const newIdea: (text: string) => ImportedIdea;
|
|
60
|
+
/** The warnings for one map, each kind counted once with a few examples. */
|
|
61
|
+
export declare class ImportReport {
|
|
62
|
+
private readonly found;
|
|
63
|
+
add(code: OrbitImportWarningCode, example?: string): void;
|
|
64
|
+
/** The warnings in the order of `IMPORT_WARNING_CODES`. */
|
|
65
|
+
get warnings(): OrbitImportWarning[];
|
|
66
|
+
}
|
|
67
|
+
/** A title on one line, as Orbit keeps titles: line breaks, tabs and runs of spaces become one space; other spaces stay as they are. */
|
|
68
|
+
export declare const oneLine: (text: string) => string;
|
|
69
|
+
/** A link in a note to the idea with this id in the other app: it points at the idea's Orbit id once the map is built. */
|
|
70
|
+
export declare const sourceLink: (sourceId: string) => string;
|
|
71
|
+
/**
|
|
72
|
+
* The tree as an Orbit document: titles on one line, an emoji at the start
|
|
73
|
+
* of a title as the idea's icon (as Orbit's markdown reads it), ids from the
|
|
74
|
+
* titles as the parsers give them, and links between ideas pointing at them.
|
|
75
|
+
*/
|
|
76
|
+
export declare const buildDocument: (rootIdea: ImportedIdea, report: ImportReport) => OrbitDocument;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps from other apps: OPML from outliners and most mind map apps,
|
|
3
|
+
* FreeMind and Freeplane's `.mm`, and XMind's `.xmind`. `importMap` tells
|
|
4
|
+
* the format from the file's name or what it holds and reads it into Orbit
|
|
5
|
+
* maps, with the pictures inside the file and warnings for what Orbit keeps
|
|
6
|
+
* another way or couldn't keep.
|
|
7
|
+
*/
|
|
8
|
+
import type { OrbitImport, OrbitImportFormat, OrbitImportOptions } from './reading.js';
|
|
9
|
+
/**
|
|
10
|
+
* The format of another app's map, from what the file holds, then from its
|
|
11
|
+
* name; null when it's none Orbit reads. Orbit's own markdown and YAML, and
|
|
12
|
+
* its zips, are null too: read those with `parseOrbit`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const detectImportFormat: (data: Uint8Array | string, name?: string) => OrbitImportFormat | null;
|
|
15
|
+
/**
|
|
16
|
+
* Another app's map as Orbit maps: OPML, FreeMind and Freeplane, or XMind.
|
|
17
|
+
* Pass the file's bytes (its text works for OPML and `.mm`) and its name.
|
|
18
|
+
* Throws an `OrbitImportError` for a file it can't read: one in no format it
|
|
19
|
+
* knows (`unknown-format`), a damaged one (`unreadable`), one with no ideas
|
|
20
|
+
* (`empty`), an XMind workbook with a password (`password-protected`), or one
|
|
21
|
+
* past its limits (`too-large`).
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* const { maps } = importMap(bytes, { name: 'Trip.xmind' });
|
|
25
|
+
* const markdown = serializeOrbitMarkdown(maps[0].document);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare const importMap: (data: Uint8Array | string, options?: OrbitImportOptions) => OrbitImport;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inflate (RFC 1951), the compression inside zip files, read synchronously
|
|
3
|
+
* and without `DecompressionStream`: the oldest browsers Orbit draws in
|
|
4
|
+
* can't decompress raw deflate data, and a command line has no need to wait.
|
|
5
|
+
* Codes are decoded the canonical way, a bit at a time, which is plenty fast
|
|
6
|
+
* for the few megabytes a map holds.
|
|
7
|
+
*/
|
|
8
|
+
/** Data that isn't valid deflate data, or holds more than it said it would. */
|
|
9
|
+
export declare class InflateError extends Error {
|
|
10
|
+
constructor(message: string);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Raw deflate data, inflated. `expected` sizes the output when it's known
|
|
14
|
+
* (a zip entry says so); the output never grows past `limit`, so a small
|
|
15
|
+
* file can't unpack into an enormous one.
|
|
16
|
+
*/
|
|
17
|
+
export declare const inflate: (data: Uint8Array, options?: {
|
|
18
|
+
expected?: number;
|
|
19
|
+
limit?: number;
|
|
20
|
+
}) => Uint8Array;
|
|
21
|
+
/** The CRC-32 zip files check their entries with. */
|
|
22
|
+
export declare const crc32: (bytes: Uint8Array) => number;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small XML reader for other apps' map files, and a forgiving reader for
|
|
3
|
+
* the HTML in their notes. Neither loads anything a file points to: XML
|
|
4
|
+
* reads its five entities and numeric references only, HTML adds a fixed
|
|
5
|
+
* table of common named ones, a DOCTYPE is skipped without reading what it
|
|
6
|
+
* declares, and the size of the input and the depth of nesting are capped.
|
|
7
|
+
*/
|
|
8
|
+
export interface MarkupElement {
|
|
9
|
+
/** The element's name as written, with its prefix: `xhtml:p`. */
|
|
10
|
+
name: string;
|
|
11
|
+
/** The name without a prefix, lowercased in HTML: `p`. */
|
|
12
|
+
localName: string;
|
|
13
|
+
/** Attributes by name as written, values decoded. */
|
|
14
|
+
attributes: Record<string, string>;
|
|
15
|
+
children: MarkupNode[];
|
|
16
|
+
}
|
|
17
|
+
/** An element, or text. */
|
|
18
|
+
export type MarkupNode = MarkupElement | string;
|
|
19
|
+
/** A file that isn't well-formed XML, or too big or too deep to read. */
|
|
20
|
+
export declare class MarkupError extends Error {
|
|
21
|
+
/** The 1-based line of the problem. */
|
|
22
|
+
readonly line: number;
|
|
23
|
+
constructor(message: string, line: number);
|
|
24
|
+
}
|
|
25
|
+
/** The most characters a file may have: far beyond any map, short of exhausting memory. */
|
|
26
|
+
export declare const MAX_MARKUP_LENGTH: number;
|
|
27
|
+
/** The deepest nesting read: deeper files are refused rather than risking the stack. */
|
|
28
|
+
export declare const MAX_MARKUP_DEPTH = 1000;
|
|
29
|
+
/**
|
|
30
|
+
* An XML file's bytes as text, in the encoding its byte order mark or its
|
|
31
|
+
* declaration names (UTF-8 when neither does). Old OPML files are often
|
|
32
|
+
* ISO-8859-1. A file that isn't valid UTF-8 and names no encoding is read as
|
|
33
|
+
* Windows-1252, which every byte is.
|
|
34
|
+
*/
|
|
35
|
+
export declare const decodeMarkup: (bytes: Uint8Array) => string;
|
|
36
|
+
/**
|
|
37
|
+
* The document element of an XML file. Throws a `MarkupError` for a file
|
|
38
|
+
* that isn't well-formed, so a damaged map is refused rather than read in part.
|
|
39
|
+
*/
|
|
40
|
+
export declare const parseXml: (text: string) => MarkupElement;
|
|
41
|
+
/** A piece of HTML, as the children of an element named `#fragment`. Never throws for markup it can read some way. */
|
|
42
|
+
export declare const parseHtml: (text: string) => MarkupElement;
|
|
43
|
+
export declare const isElement: (node: MarkupNode) => node is MarkupElement;
|
|
44
|
+
/** The element's child elements, all of them or those with one local name. */
|
|
45
|
+
export declare const childElements: (element: MarkupElement, localName?: string) => MarkupElement[];
|
|
46
|
+
/** The element's first child element with this local name. */
|
|
47
|
+
export declare const childElement: (element: MarkupElement, localName: string) => MarkupElement | undefined;
|
|
48
|
+
/** An attribute by its name without a prefix: `href` finds `xlink:href`. */
|
|
49
|
+
export declare const attributeOf: (element: MarkupElement, localName: string) => string | undefined;
|
|
50
|
+
/** All the text inside an element, as written. */
|
|
51
|
+
export declare const textContent: (node: MarkupNode) => string;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notes and titles from other apps. HTML notes become markdown (paragraphs,
|
|
3
|
+
* headings, lists, quotes, code, bold, italic, strikethrough, links and
|
|
4
|
+
* pictures), never HTML. When markdown would show the note's text any other
|
|
5
|
+
* way (a `*` or `_` in it, a line that starts like a list), the note is kept
|
|
6
|
+
* as plain text instead, exactly as written: formatting can be lost, words
|
|
7
|
+
* never are.
|
|
8
|
+
*/
|
|
9
|
+
import { type MarkupElement, type MarkupNode } from './markup.js';
|
|
10
|
+
/** A note as Orbit keeps it. */
|
|
11
|
+
export interface ImportedNote {
|
|
12
|
+
text: string;
|
|
13
|
+
format: 'markdown' | 'plain';
|
|
14
|
+
}
|
|
15
|
+
/** Inline content, as the note's reader shows it. */
|
|
16
|
+
export type NoteInline = {
|
|
17
|
+
kind: 'text';
|
|
18
|
+
text: string;
|
|
19
|
+
} | {
|
|
20
|
+
kind: 'break';
|
|
21
|
+
} | {
|
|
22
|
+
kind: 'strong' | 'emphasis' | 'strike';
|
|
23
|
+
children: NoteInline[];
|
|
24
|
+
} | {
|
|
25
|
+
kind: 'code';
|
|
26
|
+
text: string;
|
|
27
|
+
} | {
|
|
28
|
+
kind: 'link';
|
|
29
|
+
href: string;
|
|
30
|
+
children: NoteInline[];
|
|
31
|
+
} | {
|
|
32
|
+
kind: 'image';
|
|
33
|
+
src: string;
|
|
34
|
+
alt: string;
|
|
35
|
+
};
|
|
36
|
+
/** A block of a note. */
|
|
37
|
+
export type NoteBlock = {
|
|
38
|
+
kind: 'paragraph';
|
|
39
|
+
inline: NoteInline[];
|
|
40
|
+
} | {
|
|
41
|
+
kind: 'heading';
|
|
42
|
+
level: number;
|
|
43
|
+
inline: NoteInline[];
|
|
44
|
+
} | {
|
|
45
|
+
kind: 'list';
|
|
46
|
+
ordered: boolean;
|
|
47
|
+
items: NoteBlock[][];
|
|
48
|
+
} | {
|
|
49
|
+
kind: 'quote';
|
|
50
|
+
blocks: NoteBlock[];
|
|
51
|
+
} | {
|
|
52
|
+
kind: 'code';
|
|
53
|
+
text: string;
|
|
54
|
+
};
|
|
55
|
+
/** How addresses in a note are kept. */
|
|
56
|
+
export interface NoteAddresses {
|
|
57
|
+
/** The address a link keeps, or null for its text alone. Default: web and mail addresses, and `#` links. */
|
|
58
|
+
link?: (href: string) => string | null;
|
|
59
|
+
/** The address a picture keeps, or null for its description alone. Default: web addresses. */
|
|
60
|
+
picture?: (src: string) => string | null;
|
|
61
|
+
}
|
|
62
|
+
/** Web and mail addresses, and links within the map. */
|
|
63
|
+
export declare const isKeptLink: (href: string) => boolean;
|
|
64
|
+
/** An address as a link keeps it: `www.example.com` is a web address; a file or anything else is null. */
|
|
65
|
+
export declare const keptAddress: (href: string) => string | null;
|
|
66
|
+
/** An HTML note (an element, or HTML as text) as an Orbit note; undefined when it holds no text. */
|
|
67
|
+
export declare const noteFromHtml: (html: MarkupElement | string, addresses?: NoteAddresses) => ImportedNote | undefined;
|
|
68
|
+
/** A plain text note: markdown when it reads the same as markdown, otherwise plain, as written. */
|
|
69
|
+
export declare const noteFromPlainText: (text: string | undefined) => ImportedNote | undefined;
|
|
70
|
+
/** Blocks as a note: markdown when every word reads back as written, otherwise plain text. */
|
|
71
|
+
export declare const noteFromBlocks: (blocks: NoteBlock[], addresses?: NoteAddresses) => ImportedNote | undefined;
|
|
72
|
+
/** Two or more notes as one: markdown if all are, otherwise plain text, separated by blank lines. */
|
|
73
|
+
export declare const joinNotes: (notes: (ImportedNote | undefined)[]) => ImportedNote | undefined;
|
|
74
|
+
/** A title from HTML: what a reader sees, on one line, and the address of its first link. */
|
|
75
|
+
export declare const titleFromHtml: (html: MarkupElement | string) => {
|
|
76
|
+
text: string;
|
|
77
|
+
link?: string;
|
|
78
|
+
};
|
|
79
|
+
/** The note's blocks, from HTML nodes. */
|
|
80
|
+
export declare const readBlocks: (nodes: MarkupNode[], addresses: NoteAddresses) => NoteBlock[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OPML, the outline format outliners and most mind map apps read and write.
|
|
3
|
+
* Reading keeps each outline's text, its note (`_note`, the convention
|
|
4
|
+
* OmniOutliner started and Workflowy, Dynalist and MindNode follow), its
|
|
5
|
+
* done or todo state (`_status`, `_complete`, `complete`), its link
|
|
6
|
+
* (`type="link"`'s `url`, a feed's `htmlUrl` or `xmlUrl`) and its categories
|
|
7
|
+
* as tags. Writing gives the same back, so a map Orbit writes reads back the
|
|
8
|
+
* same, and other apps read its text, notes, links and checkboxes.
|
|
9
|
+
*/
|
|
10
|
+
import type { OrbitDocument } from '../types.js';
|
|
11
|
+
import { type OrbitImport, type OrbitImportOptions } from './reading.js';
|
|
12
|
+
/** An OPML file, from its bytes or text. */
|
|
13
|
+
export declare const importOPML: (data: Uint8Array | string, options?: OrbitImportOptions) => OrbitImport;
|
|
14
|
+
export interface OrbitOPMLOptions {
|
|
15
|
+
/** The outline's title, in its head. Default: the map's `title`, or its root's text. */
|
|
16
|
+
title?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A map as OPML: the root is the one top outline, each node an outline
|
|
20
|
+
* with its icon and text, its note in `_note`, its link as `type="link"`
|
|
21
|
+
* with a `url`, its status in `_status` (`checked`, `unchecked` and
|
|
22
|
+
* `indeterminate` for done, todo and active; any other word as it is) and
|
|
23
|
+
* `_complete`, and its tags as `category`. Pictures, videos, colors and
|
|
24
|
+
* priorities have no place in OPML: a zip or the map's own file keeps them.
|
|
25
|
+
*/
|
|
26
|
+
export declare const exportOPML: (input: string | OrbitDocument, options?: OrbitOPMLOptions) => string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What reading another app's map gives back, and the first steps every
|
|
3
|
+
* reader shares: a file's bytes as text, and its XML read, with problems
|
|
4
|
+
* reported as `OrbitImportError`s.
|
|
5
|
+
*/
|
|
6
|
+
import type { OrbitDocument } from '../types.js';
|
|
7
|
+
import { type OrbitImportWarning } from './ideas.js';
|
|
8
|
+
import { type MarkupElement } from './markup.js';
|
|
9
|
+
/** The other apps' formats Orbit reads. */
|
|
10
|
+
export type OrbitImportFormat = 'opml' | 'freemind' | 'xmind';
|
|
11
|
+
export interface OrbitImportOptions {
|
|
12
|
+
/** The file's name: its extension tells the format, and a map with no single center is named after it. */
|
|
13
|
+
name?: string;
|
|
14
|
+
/** The file's format, when you know it. Default: from the name, then from what the file holds. */
|
|
15
|
+
format?: OrbitImportFormat;
|
|
16
|
+
/** The name of the center Orbit adds to a map with several top ideas and nothing to name it after. Default "Untitled map". */
|
|
17
|
+
untitled?: string;
|
|
18
|
+
}
|
|
19
|
+
/** One map read from another app's file. */
|
|
20
|
+
export interface OrbitImportedMap {
|
|
21
|
+
document: OrbitDocument;
|
|
22
|
+
/** Pictures from inside the file, by the address the map gives them: `media/sunrise.png`. Save them next to the map. */
|
|
23
|
+
media: Record<string, Uint8Array>;
|
|
24
|
+
/** What the other app had that Orbit keeps another way, or couldn't keep. */
|
|
25
|
+
warnings: OrbitImportWarning[];
|
|
26
|
+
}
|
|
27
|
+
/** What reading another app's file gives. */
|
|
28
|
+
export interface OrbitImport {
|
|
29
|
+
format: OrbitImportFormat;
|
|
30
|
+
/** The file's maps: one, or one for each sheet of an XMind workbook. */
|
|
31
|
+
maps: OrbitImportedMap[];
|
|
32
|
+
}
|
|
33
|
+
/** An XML file's top element, which must be `rootName`; `what` names the file in errors ("an OPML file"). */
|
|
34
|
+
export declare const readXmlFile: (data: Uint8Array | string, rootName: string, what: string) => MarkupElement;
|
|
35
|
+
/** A file's name without its folder or a map's extension: `notes/Trip.opml` is `Trip`. */
|
|
36
|
+
export declare const baseName: (name: string | undefined) => string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XMind workbooks (`.xmind`): zip archives holding `content.json` (XMind
|
|
3
|
+
* 2020 and later, and XMind Zen) or `content.xml` (XMind 8 and earlier),
|
|
4
|
+
* with their pictures. Each sheet becomes a map: its topics with their notes,
|
|
5
|
+
* labels, markers, links, folds, fill colors and pictures, floating topics,
|
|
6
|
+
* summaries and callouts under the topics they belong with, and
|
|
7
|
+
* relationships as links.
|
|
8
|
+
*/
|
|
9
|
+
import type { OrbitImport, OrbitImportOptions } from './reading.js';
|
|
10
|
+
/**
|
|
11
|
+
* An XMind workbook, from its bytes; or its `content.json` or `content.xml`
|
|
12
|
+
* as text, which reads without pictures.
|
|
13
|
+
*/
|
|
14
|
+
export declare const importXMind: (data: Uint8Array | string, options?: OrbitImportOptions) => OrbitImport;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads files out of a zip archive, such as an XMind map: its directory,
|
|
3
|
+
* then each entry on request, stored or deflated, checked against its
|
|
4
|
+
* CRC-32. Archives that span disks, need ZIP64 or are encrypted are refused,
|
|
5
|
+
* and so is an entry that would unpack past the archive's limits.
|
|
6
|
+
*/
|
|
7
|
+
/** An archive that can't be read, or an entry that can't be unpacked. */
|
|
8
|
+
export declare class ZipError extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
export interface ZipLimits {
|
|
12
|
+
/** The most entries an archive may list. */
|
|
13
|
+
entries: number;
|
|
14
|
+
/** The most bytes one entry may unpack to. */
|
|
15
|
+
entrySize: number;
|
|
16
|
+
/** The most bytes all the entries read may unpack to, together. */
|
|
17
|
+
totalSize: number;
|
|
18
|
+
}
|
|
19
|
+
export declare const DEFAULT_ZIP_LIMITS: ZipLimits;
|
|
20
|
+
/** Whether bytes start the way every zip archive does. */
|
|
21
|
+
export declare const isZip: (bytes: Uint8Array) => boolean;
|
|
22
|
+
export declare class ZipArchive {
|
|
23
|
+
private readonly bytes;
|
|
24
|
+
private readonly view;
|
|
25
|
+
private readonly limits;
|
|
26
|
+
private readonly entries;
|
|
27
|
+
private unpacked;
|
|
28
|
+
constructor(bytes: Uint8Array, limits?: Partial<ZipLimits>);
|
|
29
|
+
/** The names of the files in the archive, folders left out. */
|
|
30
|
+
get names(): string[];
|
|
31
|
+
has(name: string): boolean;
|
|
32
|
+
/** An entry's bytes, or null when the archive has no such file. */
|
|
33
|
+
read(name: string): Uint8Array | null;
|
|
34
|
+
/** An entry as UTF-8 text, or null when the archive has no such file. */
|
|
35
|
+
text(name: string): string | null;
|
|
36
|
+
private readDirectory;
|
|
37
|
+
}
|