worldorbit 2.5.2
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.md +5 -0
- package/README.md +250 -0
- package/dist/browser/core/dist/index.js +4009 -0
- package/dist/browser/markdown/dist/index.js +3951 -0
- package/dist/browser/viewer/dist/index.js +5981 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.js +84 -0
- package/dist/errors.d.ts +7 -0
- package/dist/errors.js +16 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +25 -0
- package/dist/normalize.d.ts +2 -0
- package/dist/normalize.js +243 -0
- package/dist/parse.d.ts +2 -0
- package/dist/parse.js +126 -0
- package/dist/render.d.ts +6 -0
- package/dist/render.js +683 -0
- package/dist/tokenize.d.ts +4 -0
- package/dist/tokenize.js +68 -0
- package/dist/types.d.ts +208 -0
- package/dist/types.js +1 -0
- package/dist/unpkg/core/dist/index.js +4081 -0
- package/dist/unpkg/markdown/dist/index.js +3979 -0
- package/dist/unpkg/test.html +1 -0
- package/dist/unpkg/viewer/dist/index.js +6038 -0
- package/dist/unpkg/worldorbit-core.min.js +5 -0
- package/dist/unpkg/worldorbit-markdown.min.js +81 -0
- package/dist/unpkg/worldorbit-viewer.min.js +232 -0
- package/dist/unpkg/worldorbit.d.ts +2 -0
- package/dist/unpkg/worldorbit.js +2 -0
- package/dist/unpkg/worldorbit.min.js +236 -0
- package/dist/validate.d.ts +2 -0
- package/dist/validate.js +31 -0
- package/dist/viewer-state.d.ts +16 -0
- package/dist/viewer-state.js +130 -0
- package/dist/viewer.d.ts +2 -0
- package/dist/viewer.js +434 -0
- package/package.json +64 -0
- package/packages/core/README.md +13 -0
- package/packages/core/dist/atlas-edit.d.ts +11 -0
- package/packages/core/dist/atlas-edit.js +210 -0
- package/packages/core/dist/diagnostics.d.ts +10 -0
- package/packages/core/dist/diagnostics.js +109 -0
- package/packages/core/dist/draft-parse.d.ts +3 -0
- package/packages/core/dist/draft-parse.js +642 -0
- package/packages/core/dist/draft.d.ts +15 -0
- package/packages/core/dist/draft.js +343 -0
- package/packages/core/dist/errors.d.ts +7 -0
- package/packages/core/dist/errors.js +16 -0
- package/packages/core/dist/format.d.ts +4 -0
- package/packages/core/dist/format.js +364 -0
- package/packages/core/dist/index.d.ts +28 -0
- package/packages/core/dist/index.js +44 -0
- package/packages/core/dist/load.d.ts +4 -0
- package/packages/core/dist/load.js +130 -0
- package/packages/core/dist/markdown.d.ts +2 -0
- package/packages/core/dist/markdown.js +37 -0
- package/packages/core/dist/normalize.d.ts +2 -0
- package/packages/core/dist/normalize.js +304 -0
- package/packages/core/dist/parse.d.ts +2 -0
- package/packages/core/dist/parse.js +133 -0
- package/packages/core/dist/scene.d.ts +3 -0
- package/packages/core/dist/scene.js +1484 -0
- package/packages/core/dist/schema.d.ts +8 -0
- package/packages/core/dist/schema.js +298 -0
- package/packages/core/dist/tokenize.d.ts +4 -0
- package/packages/core/dist/tokenize.js +68 -0
- package/packages/core/dist/types.d.ts +382 -0
- package/packages/core/dist/types.js +1 -0
- package/packages/core/dist/validate.d.ts +2 -0
- package/packages/core/dist/validate.js +56 -0
- package/packages/editor/dist/editor.d.ts +2 -0
- package/packages/editor/dist/editor.js +2620 -0
- package/packages/editor/dist/index.d.ts +2 -0
- package/packages/editor/dist/index.js +1 -0
- package/packages/editor/dist/types.d.ts +53 -0
- package/packages/editor/dist/types.js +1 -0
- package/packages/markdown/README.md +9 -0
- package/packages/markdown/dist/html.d.ts +3 -0
- package/packages/markdown/dist/html.js +57 -0
- package/packages/markdown/dist/index.d.ts +4 -0
- package/packages/markdown/dist/index.js +3 -0
- package/packages/markdown/dist/rehype.d.ts +10 -0
- package/packages/markdown/dist/rehype.js +49 -0
- package/packages/markdown/dist/remark.d.ts +9 -0
- package/packages/markdown/dist/remark.js +28 -0
- package/packages/markdown/dist/types.d.ts +11 -0
- package/packages/markdown/dist/types.js +1 -0
- package/packages/viewer/README.md +12 -0
- package/packages/viewer/dist/atlas-state.d.ts +12 -0
- package/packages/viewer/dist/atlas-state.js +251 -0
- package/packages/viewer/dist/atlas-viewer.d.ts +2 -0
- package/packages/viewer/dist/atlas-viewer.js +448 -0
- package/packages/viewer/dist/custom-element.d.ts +1 -0
- package/packages/viewer/dist/custom-element.js +64 -0
- package/packages/viewer/dist/embed.d.ts +20 -0
- package/packages/viewer/dist/embed.js +138 -0
- package/packages/viewer/dist/index.d.ts +9 -0
- package/packages/viewer/dist/index.js +8 -0
- package/packages/viewer/dist/minimap.d.ts +3 -0
- package/packages/viewer/dist/minimap.js +63 -0
- package/packages/viewer/dist/render.d.ts +6 -0
- package/packages/viewer/dist/render.js +585 -0
- package/packages/viewer/dist/theme.d.ts +4 -0
- package/packages/viewer/dist/theme.js +98 -0
- package/packages/viewer/dist/tooltip.d.ts +3 -0
- package/packages/viewer/dist/tooltip.js +154 -0
- package/packages/viewer/dist/types.d.ts +256 -0
- package/packages/viewer/dist/types.js +1 -0
- package/packages/viewer/dist/viewer-state.d.ts +19 -0
- package/packages/viewer/dist/viewer-state.js +162 -0
- package/packages/viewer/dist/viewer.d.ts +2 -0
- package/packages/viewer/dist/viewer.js +1156 -0
package/dist/tokenize.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { WorldOrbitError } from "./errors.js";
|
|
2
|
+
export function tokenizeLine(input) {
|
|
3
|
+
return tokenizeLineDetailed(input).map((token) => token.value);
|
|
4
|
+
}
|
|
5
|
+
export function tokenizeLineDetailed(input, options = {}) {
|
|
6
|
+
const tokens = [];
|
|
7
|
+
const columnOffset = options.columnOffset ?? 0;
|
|
8
|
+
let current = "";
|
|
9
|
+
let tokenColumn = null;
|
|
10
|
+
let tokenWasQuoted = false;
|
|
11
|
+
let inQuotes = false;
|
|
12
|
+
let quoteColumn = null;
|
|
13
|
+
const pushToken = () => {
|
|
14
|
+
if (tokenColumn === null) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
tokens.push({
|
|
18
|
+
value: current,
|
|
19
|
+
column: tokenColumn,
|
|
20
|
+
quoted: tokenWasQuoted,
|
|
21
|
+
});
|
|
22
|
+
current = "";
|
|
23
|
+
tokenColumn = null;
|
|
24
|
+
tokenWasQuoted = false;
|
|
25
|
+
};
|
|
26
|
+
for (let index = 0; index < input.length; index++) {
|
|
27
|
+
const ch = input[index];
|
|
28
|
+
const absoluteColumn = columnOffset + index + 1;
|
|
29
|
+
if (inQuotes && ch === "\\") {
|
|
30
|
+
const next = input[index + 1];
|
|
31
|
+
if (next === '"' || next === "\\") {
|
|
32
|
+
current += next;
|
|
33
|
+
index++;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (ch === '"') {
|
|
38
|
+
if (!inQuotes) {
|
|
39
|
+
if (tokenColumn === null) {
|
|
40
|
+
tokenColumn = absoluteColumn;
|
|
41
|
+
}
|
|
42
|
+
tokenWasQuoted = true;
|
|
43
|
+
quoteColumn = absoluteColumn;
|
|
44
|
+
inQuotes = true;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
inQuotes = false;
|
|
48
|
+
}
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (!inQuotes && /\s/.test(ch)) {
|
|
52
|
+
pushToken();
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (tokenColumn === null) {
|
|
56
|
+
tokenColumn = absoluteColumn;
|
|
57
|
+
}
|
|
58
|
+
current += ch;
|
|
59
|
+
}
|
|
60
|
+
if (inQuotes) {
|
|
61
|
+
throw new WorldOrbitError("Unclosed quote in line", options.line, quoteColumn ?? columnOffset + input.length);
|
|
62
|
+
}
|
|
63
|
+
pushToken();
|
|
64
|
+
return tokens;
|
|
65
|
+
}
|
|
66
|
+
export function getIndent(rawLine) {
|
|
67
|
+
return rawLine.match(/^\s*/)?.[0].length ?? 0;
|
|
68
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
export type WorldOrbitObjectType = "system" | "star" | "planet" | "moon" | "belt" | "asteroid" | "comet" | "ring" | "structure" | "phenomenon";
|
|
2
|
+
export type PlacementMode = "orbit" | "at" | "surface" | "free";
|
|
3
|
+
export type Unit = "au" | "km" | "re" | "sol" | "me" | "d" | "y" | "h" | "deg";
|
|
4
|
+
export interface CoordinatePoint {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
}
|
|
8
|
+
export interface UnitValue {
|
|
9
|
+
value: number;
|
|
10
|
+
unit: Unit | null;
|
|
11
|
+
}
|
|
12
|
+
export interface AstSourceLocation {
|
|
13
|
+
line: number;
|
|
14
|
+
column: number;
|
|
15
|
+
}
|
|
16
|
+
export interface LineToken {
|
|
17
|
+
value: string;
|
|
18
|
+
column: number;
|
|
19
|
+
quoted: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface TokenizeOptions {
|
|
22
|
+
line?: number;
|
|
23
|
+
columnOffset?: number;
|
|
24
|
+
}
|
|
25
|
+
export interface AstDocument {
|
|
26
|
+
type: "document";
|
|
27
|
+
objects: AstObjectNode[];
|
|
28
|
+
}
|
|
29
|
+
export interface AstObjectNode {
|
|
30
|
+
type: "object";
|
|
31
|
+
objectType: WorldOrbitObjectType;
|
|
32
|
+
name: string;
|
|
33
|
+
inlineFields: AstFieldNode[];
|
|
34
|
+
blockFields: AstFieldNode[];
|
|
35
|
+
infoEntries: AstInfoEntryNode[];
|
|
36
|
+
location: AstSourceLocation;
|
|
37
|
+
}
|
|
38
|
+
export interface AstFieldNode {
|
|
39
|
+
type: "field";
|
|
40
|
+
key: string;
|
|
41
|
+
values: string[];
|
|
42
|
+
location: AstSourceLocation;
|
|
43
|
+
}
|
|
44
|
+
export interface AstInfoEntryNode {
|
|
45
|
+
type: "info-entry";
|
|
46
|
+
key: string;
|
|
47
|
+
value: string;
|
|
48
|
+
location: AstSourceLocation;
|
|
49
|
+
}
|
|
50
|
+
export interface WorldOrbitDocument {
|
|
51
|
+
format: "worldorbit";
|
|
52
|
+
version: "0.1";
|
|
53
|
+
system: WorldOrbitSystem | null;
|
|
54
|
+
objects: WorldOrbitObject[];
|
|
55
|
+
}
|
|
56
|
+
export interface WorldOrbitSystem {
|
|
57
|
+
type: "system";
|
|
58
|
+
id: string;
|
|
59
|
+
properties: Record<string, NormalizedValue>;
|
|
60
|
+
info: Record<string, string>;
|
|
61
|
+
}
|
|
62
|
+
export interface WorldOrbitObject {
|
|
63
|
+
type: Exclude<WorldOrbitObjectType, "system">;
|
|
64
|
+
id: string;
|
|
65
|
+
properties: Record<string, NormalizedValue>;
|
|
66
|
+
placement: Placement | null;
|
|
67
|
+
info: Record<string, string>;
|
|
68
|
+
}
|
|
69
|
+
export type NormalizedValue = string | number | boolean | string[] | UnitValue;
|
|
70
|
+
export type Placement = OrbitPlacement | AtPlacement | SurfacePlacement | FreePlacement;
|
|
71
|
+
export interface OrbitPlacement {
|
|
72
|
+
mode: "orbit";
|
|
73
|
+
target: string;
|
|
74
|
+
distance?: UnitValue;
|
|
75
|
+
semiMajor?: UnitValue;
|
|
76
|
+
eccentricity?: number;
|
|
77
|
+
period?: UnitValue;
|
|
78
|
+
angle?: UnitValue;
|
|
79
|
+
inclination?: UnitValue;
|
|
80
|
+
phase?: UnitValue;
|
|
81
|
+
}
|
|
82
|
+
export type SpecialPoint = "L1" | "L2" | "L3" | "L4" | "L5";
|
|
83
|
+
export type AtReference = NamedReference | LagrangeReference;
|
|
84
|
+
export interface NamedReference {
|
|
85
|
+
kind: "named";
|
|
86
|
+
name: string;
|
|
87
|
+
}
|
|
88
|
+
export interface LagrangeReference {
|
|
89
|
+
kind: "lagrange";
|
|
90
|
+
point: SpecialPoint;
|
|
91
|
+
primary: string;
|
|
92
|
+
secondary: string | null;
|
|
93
|
+
}
|
|
94
|
+
export interface AtPlacement {
|
|
95
|
+
mode: "at";
|
|
96
|
+
target: string;
|
|
97
|
+
reference: AtReference;
|
|
98
|
+
}
|
|
99
|
+
export interface SurfacePlacement {
|
|
100
|
+
mode: "surface";
|
|
101
|
+
target: string;
|
|
102
|
+
}
|
|
103
|
+
export interface FreePlacement {
|
|
104
|
+
mode: "free";
|
|
105
|
+
distance?: UnitValue;
|
|
106
|
+
descriptor?: string;
|
|
107
|
+
}
|
|
108
|
+
export interface SvgRenderOptions {
|
|
109
|
+
width?: number;
|
|
110
|
+
height?: number;
|
|
111
|
+
padding?: number;
|
|
112
|
+
}
|
|
113
|
+
export interface RenderBounds {
|
|
114
|
+
minX: number;
|
|
115
|
+
minY: number;
|
|
116
|
+
maxX: number;
|
|
117
|
+
maxY: number;
|
|
118
|
+
width: number;
|
|
119
|
+
height: number;
|
|
120
|
+
centerX: number;
|
|
121
|
+
centerY: number;
|
|
122
|
+
}
|
|
123
|
+
export interface RenderSceneObject {
|
|
124
|
+
renderId: string;
|
|
125
|
+
objectId: string;
|
|
126
|
+
object: WorldOrbitObject;
|
|
127
|
+
x: number;
|
|
128
|
+
y: number;
|
|
129
|
+
radius: number;
|
|
130
|
+
visualRadius: number;
|
|
131
|
+
anchorX?: number;
|
|
132
|
+
anchorY?: number;
|
|
133
|
+
label: string;
|
|
134
|
+
secondaryLabel: string;
|
|
135
|
+
fillColor?: string;
|
|
136
|
+
hidden: boolean;
|
|
137
|
+
}
|
|
138
|
+
export interface RenderOrbitVisual {
|
|
139
|
+
renderId: string;
|
|
140
|
+
objectId: string;
|
|
141
|
+
object: WorldOrbitObject;
|
|
142
|
+
parentId: string;
|
|
143
|
+
cx: number;
|
|
144
|
+
cy: number;
|
|
145
|
+
radius: number;
|
|
146
|
+
band: boolean;
|
|
147
|
+
hidden: boolean;
|
|
148
|
+
}
|
|
149
|
+
export type LeaderMode = "surface" | "at" | "free";
|
|
150
|
+
export interface RenderLeaderLine {
|
|
151
|
+
renderId: string;
|
|
152
|
+
objectId: string;
|
|
153
|
+
object: WorldOrbitObject;
|
|
154
|
+
x1: number;
|
|
155
|
+
y1: number;
|
|
156
|
+
x2: number;
|
|
157
|
+
y2: number;
|
|
158
|
+
mode: LeaderMode;
|
|
159
|
+
hidden: boolean;
|
|
160
|
+
}
|
|
161
|
+
export interface RenderScene {
|
|
162
|
+
width: number;
|
|
163
|
+
height: number;
|
|
164
|
+
padding: number;
|
|
165
|
+
title: string;
|
|
166
|
+
contentBounds: RenderBounds;
|
|
167
|
+
objects: RenderSceneObject[];
|
|
168
|
+
orbitVisuals: RenderOrbitVisual[];
|
|
169
|
+
leaders: RenderLeaderLine[];
|
|
170
|
+
}
|
|
171
|
+
export interface ViewerState {
|
|
172
|
+
scale: number;
|
|
173
|
+
rotationDeg: number;
|
|
174
|
+
translateX: number;
|
|
175
|
+
translateY: number;
|
|
176
|
+
selectedObjectId: string | null;
|
|
177
|
+
}
|
|
178
|
+
export interface InteractiveViewerOptions extends SvgRenderOptions {
|
|
179
|
+
source?: string;
|
|
180
|
+
document?: WorldOrbitDocument;
|
|
181
|
+
scene?: RenderScene;
|
|
182
|
+
minScale?: number;
|
|
183
|
+
maxScale?: number;
|
|
184
|
+
fitPadding?: number;
|
|
185
|
+
keyboard?: boolean;
|
|
186
|
+
pointer?: boolean;
|
|
187
|
+
touch?: boolean;
|
|
188
|
+
selection?: boolean;
|
|
189
|
+
panStep?: number;
|
|
190
|
+
zoomStep?: number;
|
|
191
|
+
rotationStep?: number;
|
|
192
|
+
onSelectionChange?: (selectedObject: RenderSceneObject | null) => void;
|
|
193
|
+
onViewChange?: (state: ViewerState) => void;
|
|
194
|
+
}
|
|
195
|
+
export interface WorldOrbitViewer {
|
|
196
|
+
setSource(source: string): void;
|
|
197
|
+
setDocument(document: WorldOrbitDocument): void;
|
|
198
|
+
setScene(scene: RenderScene): void;
|
|
199
|
+
getState(): ViewerState;
|
|
200
|
+
setState(state: Partial<ViewerState>): void;
|
|
201
|
+
zoomBy(factor: number, anchor?: CoordinatePoint): void;
|
|
202
|
+
panBy(dx: number, dy: number): void;
|
|
203
|
+
rotateBy(deg: number): void;
|
|
204
|
+
fitToSystem(): void;
|
|
205
|
+
focusObject(id: string): void;
|
|
206
|
+
resetView(): void;
|
|
207
|
+
destroy(): void;
|
|
208
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|