@deck.gl-community/infovis-layers 9.3.5 → 9.3.7
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/dist/index.cjs +2998 -114
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/layers/animation-layer/animation-layer.d.ts +30 -0
- package/dist/layers/animation-layer/animation-layer.d.ts.map +1 -0
- package/dist/layers/animation-layer/animation-layer.js +53 -0
- package/dist/layers/animation-layer/animation-layer.js.map +1 -0
- package/dist/layers/animation-layer/animation.d.ts +86 -0
- package/dist/layers/animation-layer/animation.d.ts.map +1 -0
- package/dist/layers/animation-layer/animation.js +214 -0
- package/dist/layers/animation-layer/animation.js.map +1 -0
- package/dist/layers/block-layer/block-layer-fragment.glsl.d.ts +3 -0
- package/dist/layers/block-layer/block-layer-fragment.glsl.d.ts.map +1 -0
- package/dist/layers/block-layer/block-layer-fragment.glsl.js +41 -0
- package/dist/layers/block-layer/block-layer-fragment.glsl.js.map +1 -0
- package/dist/layers/block-layer/block-layer-uniforms.d.ts +27 -0
- package/dist/layers/block-layer/block-layer-uniforms.d.ts.map +1 -0
- package/dist/layers/block-layer/block-layer-uniforms.js +26 -0
- package/dist/layers/block-layer/block-layer-uniforms.js.map +1 -0
- package/dist/layers/block-layer/block-layer-vertex.glsl.d.ts +3 -0
- package/dist/layers/block-layer/block-layer-vertex.glsl.d.ts.map +1 -0
- package/dist/layers/block-layer/block-layer-vertex.glsl.js +67 -0
- package/dist/layers/block-layer/block-layer-vertex.glsl.js.map +1 -0
- package/dist/layers/block-layer/block-layer.d.ts +71 -0
- package/dist/layers/block-layer/block-layer.d.ts.map +1 -0
- package/dist/layers/block-layer/block-layer.js +108 -0
- package/dist/layers/block-layer/block-layer.js.map +1 -0
- package/dist/layers/fast-text-layer/fast-text-layer.d.ts +148 -0
- package/dist/layers/fast-text-layer/fast-text-layer.d.ts.map +1 -0
- package/dist/layers/fast-text-layer/fast-text-layer.js +862 -0
- package/dist/layers/fast-text-layer/fast-text-layer.js.map +1 -0
- package/dist/layers/fast-text-layer/fast-text-layer.test.d.ts +2 -0
- package/dist/layers/fast-text-layer/fast-text-layer.test.d.ts.map +1 -0
- package/dist/layers/fast-text-layer/fast-text-layer.test.js +300 -0
- package/dist/layers/fast-text-layer/fast-text-layer.test.js.map +1 -0
- package/dist/layers/fast-text-layer/fast-text-layout.d.ts +179 -0
- package/dist/layers/fast-text-layer/fast-text-layout.d.ts.map +1 -0
- package/dist/layers/fast-text-layer/fast-text-layout.js +665 -0
- package/dist/layers/fast-text-layer/fast-text-layout.js.map +1 -0
- package/dist/layers/fast-text-layer/font-atlas.d.ts +98 -0
- package/dist/layers/fast-text-layer/font-atlas.d.ts.map +1 -0
- package/dist/layers/fast-text-layer/font-atlas.js +337 -0
- package/dist/layers/fast-text-layer/font-atlas.js.map +1 -0
- package/dist/layers/fast-text-layer/index.d.ts +4 -0
- package/dist/layers/fast-text-layer/index.d.ts.map +1 -0
- package/dist/layers/fast-text-layer/index.js +4 -0
- package/dist/layers/fast-text-layer/index.js.map +1 -0
- package/dist/layers/time-delta-layer.d.ts +22 -60
- package/dist/layers/time-delta-layer.d.ts.map +1 -1
- package/dist/layers/time-delta-layer.js +23 -45
- package/dist/layers/time-delta-layer.js.map +1 -1
- package/dist/synchronized-views/synchronized-views.js +1 -1
- package/dist/synchronized-views/synchronized-views.js.map +1 -1
- package/dist/utils/format-utils.d.ts +27 -3
- package/dist/utils/format-utils.d.ts.map +1 -1
- package/dist/utils/format-utils.js +72 -40
- package/dist/utils/format-utils.js.map +1 -1
- package/dist/utils/utf8-string-view.d.ts +53 -0
- package/dist/utils/utf8-string-view.d.ts.map +1 -0
- package/dist/utils/utf8-string-view.js +169 -0
- package/dist/utils/utf8-string-view.js.map +1 -0
- package/dist/utils/utf8-string-view.test.d.ts +2 -0
- package/dist/utils/utf8-string-view.test.d.ts.map +1 -0
- package/dist/utils/utf8-string-view.test.js +88 -0
- package/dist/utils/utf8-string-view.test.js.map +1 -0
- package/dist/views/bounds-utils.d.ts +23 -0
- package/dist/views/bounds-utils.d.ts.map +1 -0
- package/dist/views/bounds-utils.js +65 -0
- package/dist/views/bounds-utils.js.map +1 -0
- package/dist/views/layer-bounds-filter.d.ts +48 -0
- package/dist/views/layer-bounds-filter.d.ts.map +1 -0
- package/dist/views/layer-bounds-filter.js +99 -0
- package/dist/views/layer-bounds-filter.js.map +1 -0
- package/dist/views/orthographic-utils.d.ts +30 -2
- package/dist/views/orthographic-utils.d.ts.map +1 -1
- package/dist/views/orthographic-utils.js +33 -14
- package/dist/views/orthographic-utils.js.map +1 -1
- package/dist/views/view-layout/build-views-from-view-layout.d.ts +37 -0
- package/dist/views/view-layout/build-views-from-view-layout.d.ts.map +1 -0
- package/dist/views/view-layout/build-views-from-view-layout.js +413 -0
- package/dist/views/view-layout/build-views-from-view-layout.js.map +1 -0
- package/dist/views/view-layout/index.d.ts +3 -0
- package/dist/views/view-layout/index.d.ts.map +1 -0
- package/dist/views/view-layout/index.js +3 -0
- package/dist/views/view-layout/index.js.map +1 -0
- package/dist/views/view-layout/view-layout-item.d.ts +74 -0
- package/dist/views/view-layout/view-layout-item.d.ts.map +1 -0
- package/dist/views/view-layout/view-layout-item.js +48 -0
- package/dist/views/view-layout/view-layout-item.js.map +1 -0
- package/dist/views/view-layout/view-layout.test.d.ts +2 -0
- package/dist/views/view-layout/view-layout.test.d.ts.map +1 -0
- package/dist/views/view-layout/view-layout.test.js +112 -0
- package/dist/views/view-layout/view-layout.test.js.map +1 -0
- package/dist/views/viewport-bounds-utils.d.ts +55 -0
- package/dist/views/viewport-bounds-utils.d.ts.map +1 -0
- package/dist/views/viewport-bounds-utils.js +70 -0
- package/dist/views/viewport-bounds-utils.js.map +1 -0
- package/package.json +11 -4
- package/src/index.ts +91 -2
- package/src/layers/animation-layer/animation-layer.ts +92 -0
- package/src/layers/animation-layer/animation.ts +328 -0
- package/src/layers/block-layer/block-layer-fragment.glsl.ts +41 -0
- package/src/layers/block-layer/block-layer-uniforms.ts +43 -0
- package/src/layers/block-layer/block-layer-vertex.glsl.ts +67 -0
- package/src/layers/block-layer/block-layer.ts +199 -0
- package/src/layers/fast-text-layer/fast-text-layer.test.ts +359 -0
- package/src/layers/fast-text-layer/fast-text-layer.ts +1208 -0
- package/src/layers/fast-text-layer/fast-text-layout.ts +1124 -0
- package/src/layers/fast-text-layer/font-atlas.ts +574 -0
- package/src/layers/fast-text-layer/index.ts +37 -0
- package/src/layers/time-delta-layer.ts +47 -62
- package/src/synchronized-views/synchronized-views.ts +1 -1
- package/src/utils/format-utils.ts +90 -40
- package/src/utils/utf8-string-view.test.ts +119 -0
- package/src/utils/utf8-string-view.ts +273 -0
- package/src/views/bounds-utils.ts +88 -0
- package/src/views/layer-bounds-filter.ts +160 -0
- package/src/views/orthographic-utils.ts +65 -18
- package/src/views/view-layout/build-views-from-view-layout.ts +547 -0
- package/src/views/view-layout/index.ts +18 -0
- package/src/views/view-layout/view-layout-item.ts +125 -0
- package/src/views/view-layout/view-layout.test.ts +129 -0
- package/src/views/viewport-bounds-utils.ts +104 -0
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import { ViewLayoutItem } from "./view-layout-item.js";
|
|
2
|
+
/**
|
|
3
|
+
* Compiles one `ViewLayoutItem` tree into concrete deck.gl views and resolved rectangles.
|
|
4
|
+
*
|
|
5
|
+
* @param args - Root layout plus the current canvas size and optional previous compilation.
|
|
6
|
+
* @returns Concrete views with numeric bounds plus resolved rectangles keyed by view id.
|
|
7
|
+
*/
|
|
8
|
+
export function buildViewsFromViewLayout(args) {
|
|
9
|
+
const rootRect = {
|
|
10
|
+
x: 0,
|
|
11
|
+
y: 0,
|
|
12
|
+
width: Math.max(1, args.width),
|
|
13
|
+
height: Math.max(1, args.height)
|
|
14
|
+
};
|
|
15
|
+
const previousViewsById = new Map((args.previous?.views ?? [])
|
|
16
|
+
.map(view => [getViewId(view), view])
|
|
17
|
+
.filter((entry) => Boolean(entry[0])));
|
|
18
|
+
const outputViews = [];
|
|
19
|
+
const rectsById = {};
|
|
20
|
+
compileLayoutItem({
|
|
21
|
+
item: args.layout,
|
|
22
|
+
rect: rootRect,
|
|
23
|
+
outputViews,
|
|
24
|
+
rectsById,
|
|
25
|
+
previousViewsById
|
|
26
|
+
});
|
|
27
|
+
return {
|
|
28
|
+
views: outputViews,
|
|
29
|
+
rectsById
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Compiles one validated layout node inside the given parent rectangle.
|
|
34
|
+
*
|
|
35
|
+
* @param args - Layout item, allocated bounds, and compilation accumulators.
|
|
36
|
+
*/
|
|
37
|
+
function compileLayoutItem(args) {
|
|
38
|
+
const { item } = args;
|
|
39
|
+
switch (item.props.type) {
|
|
40
|
+
case 'row':
|
|
41
|
+
compileStackLayout({ ...args, orientation: 'row', children: item.props.children });
|
|
42
|
+
return;
|
|
43
|
+
case 'column':
|
|
44
|
+
compileStackLayout({ ...args, orientation: 'column', children: item.props.children });
|
|
45
|
+
return;
|
|
46
|
+
case 'overlay':
|
|
47
|
+
compileOverlayLayout({ ...args, children: item.props.children });
|
|
48
|
+
return;
|
|
49
|
+
case 'view':
|
|
50
|
+
compileResolvedView({
|
|
51
|
+
view: item.props.view,
|
|
52
|
+
rect: applyInsets(args.rect, item.props.inset),
|
|
53
|
+
outputViews: args.outputViews,
|
|
54
|
+
rectsById: args.rectsById,
|
|
55
|
+
previousViewsById: args.previousViewsById
|
|
56
|
+
});
|
|
57
|
+
return;
|
|
58
|
+
case 'spacer':
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Compiles one stack container by splitting the stack axis across its children.
|
|
64
|
+
*
|
|
65
|
+
* @param args - Stack orientation, children, and compilation accumulators.
|
|
66
|
+
*/
|
|
67
|
+
function compileStackLayout(args) {
|
|
68
|
+
const containerRect = applyInsets(args.rect, args.item.props.inset);
|
|
69
|
+
const children = args.children.filter(isPresentChild);
|
|
70
|
+
if (children.length === 0) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const containerAxisLength = args.orientation === 'row' ? containerRect.width : containerRect.height;
|
|
74
|
+
const explicitLengths = children.map(child => resolveStackChildAxisLength(child, args.orientation, containerAxisLength));
|
|
75
|
+
const fixedLength = explicitLengths.reduce((sum, length) => sum + (length ?? 0), 0);
|
|
76
|
+
const flexibleChildCount = explicitLengths.filter(length => length === undefined).length;
|
|
77
|
+
const flexibleLength = flexibleChildCount > 0
|
|
78
|
+
? Math.max(containerAxisLength - fixedLength, 0) / flexibleChildCount
|
|
79
|
+
: 0;
|
|
80
|
+
let cursor = args.orientation === 'row' ? containerRect.x : containerRect.y;
|
|
81
|
+
children.forEach((child, index) => {
|
|
82
|
+
const childAxisLength = explicitLengths[index] ?? flexibleLength;
|
|
83
|
+
const childRect = args.orientation === 'row'
|
|
84
|
+
? {
|
|
85
|
+
x: cursor,
|
|
86
|
+
y: containerRect.y,
|
|
87
|
+
width: childAxisLength,
|
|
88
|
+
height: containerRect.height
|
|
89
|
+
}
|
|
90
|
+
: {
|
|
91
|
+
x: containerRect.x,
|
|
92
|
+
y: cursor,
|
|
93
|
+
width: containerRect.width,
|
|
94
|
+
height: childAxisLength
|
|
95
|
+
};
|
|
96
|
+
cursor += childAxisLength;
|
|
97
|
+
compileLayoutChild({
|
|
98
|
+
child,
|
|
99
|
+
rect: childRect,
|
|
100
|
+
outputViews: args.outputViews,
|
|
101
|
+
rectsById: args.rectsById,
|
|
102
|
+
previousViewsById: args.previousViewsById
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Compiles one overlay container by giving every child the same parent rectangle.
|
|
108
|
+
*
|
|
109
|
+
* @param args - Overlay children, parent rectangle, and compilation accumulators.
|
|
110
|
+
*/
|
|
111
|
+
function compileOverlayLayout(args) {
|
|
112
|
+
const containerRect = applyInsets(args.rect, args.item.props.inset);
|
|
113
|
+
args.children.filter(isPresentChild).forEach(child => compileLayoutChild({
|
|
114
|
+
child,
|
|
115
|
+
rect: containerRect,
|
|
116
|
+
outputViews: args.outputViews,
|
|
117
|
+
rectsById: args.rectsById,
|
|
118
|
+
previousViewsById: args.previousViewsById
|
|
119
|
+
}));
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Compiles one child entry, which may be a nested layout item or a raw deck view.
|
|
123
|
+
*
|
|
124
|
+
* @param args - Child node plus the rectangle allocated for it.
|
|
125
|
+
*/
|
|
126
|
+
function compileLayoutChild(args) {
|
|
127
|
+
if (args.child instanceof ViewLayoutItem) {
|
|
128
|
+
compileLayoutItem({
|
|
129
|
+
item: args.child,
|
|
130
|
+
rect: args.rect,
|
|
131
|
+
outputViews: args.outputViews,
|
|
132
|
+
rectsById: args.rectsById,
|
|
133
|
+
previousViewsById: args.previousViewsById
|
|
134
|
+
});
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
compileResolvedView({
|
|
138
|
+
view: args.child,
|
|
139
|
+
rect: args.rect,
|
|
140
|
+
outputViews: args.outputViews,
|
|
141
|
+
rectsById: args.rectsById,
|
|
142
|
+
previousViewsById: args.previousViewsById
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Resolves one raw deck view against a parent rectangle and reuses a previous instance when equal.
|
|
147
|
+
*
|
|
148
|
+
* @param args - View instance, allocated rectangle, and compilation accumulators.
|
|
149
|
+
*/
|
|
150
|
+
function compileResolvedView(args) {
|
|
151
|
+
const resolvedRect = resolveViewRectWithinParent(args.view, args.rect);
|
|
152
|
+
const viewId = getRequiredViewId(args.view);
|
|
153
|
+
args.rectsById[viewId] = resolvedRect;
|
|
154
|
+
const nextProps = {
|
|
155
|
+
...args.view.props,
|
|
156
|
+
x: resolvedRect.x,
|
|
157
|
+
y: resolvedRect.y,
|
|
158
|
+
width: resolvedRect.width,
|
|
159
|
+
height: resolvedRect.height
|
|
160
|
+
};
|
|
161
|
+
const previousView = args.previousViewsById.get(viewId);
|
|
162
|
+
const nextView = previousView &&
|
|
163
|
+
previousView.constructor === args.view.constructor &&
|
|
164
|
+
arePropsEqual(previousView.props, nextProps)
|
|
165
|
+
? previousView
|
|
166
|
+
: instantiateView(args.view, nextProps);
|
|
167
|
+
args.outputViews.push(nextView);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Resolves one stack child length in the active stack axis, if it declares one.
|
|
171
|
+
*
|
|
172
|
+
* @param child - Stack child to inspect.
|
|
173
|
+
* @param orientation - Active stack orientation.
|
|
174
|
+
* @param parentAxisLength - Parent length in the active stack axis.
|
|
175
|
+
* @returns Numeric child length, or `undefined` when the child should share remaining space.
|
|
176
|
+
*/
|
|
177
|
+
function resolveStackChildAxisLength(child, orientation, parentAxisLength) {
|
|
178
|
+
const axisValue = getAxisLengthValue(child, orientation);
|
|
179
|
+
if (axisValue === undefined) {
|
|
180
|
+
return undefined;
|
|
181
|
+
}
|
|
182
|
+
return resolveLength(axisValue, parentAxisLength);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Resolves one raw deck view rectangle within the given parent rectangle.
|
|
186
|
+
*
|
|
187
|
+
* @param view - Raw deck view instance to position.
|
|
188
|
+
* @param parentRect - Parent rectangle allocated by the layout compiler.
|
|
189
|
+
* @returns Concrete rectangle for the compiled view.
|
|
190
|
+
*/
|
|
191
|
+
function resolveViewRectWithinParent(view, parentRect) {
|
|
192
|
+
const props = view.props;
|
|
193
|
+
const x = parentRect.x + resolveOffset(props.x, parentRect.width);
|
|
194
|
+
const y = parentRect.y + resolveOffset(props.y, parentRect.height);
|
|
195
|
+
const width = resolveDimension(props.width, parentRect.width, parentRect.width);
|
|
196
|
+
const height = resolveDimension(props.height, parentRect.height, parentRect.height);
|
|
197
|
+
return {
|
|
198
|
+
x,
|
|
199
|
+
y,
|
|
200
|
+
width,
|
|
201
|
+
height
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Re-instantiates one deck view with a new resolved props object.
|
|
206
|
+
*
|
|
207
|
+
* @param view - Existing deck view instance whose constructor should be reused.
|
|
208
|
+
* @param props - Resolved props for the compiled view.
|
|
209
|
+
* @returns Fresh deck view instance with resolved numeric bounds.
|
|
210
|
+
*/
|
|
211
|
+
function instantiateView(view, props) {
|
|
212
|
+
const ViewConstructor = view.constructor;
|
|
213
|
+
return new ViewConstructor(props);
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Reads the stack-axis length expression from one child, whether nested or raw.
|
|
217
|
+
*
|
|
218
|
+
* @param child - Candidate child entry.
|
|
219
|
+
* @param orientation - Active stack orientation.
|
|
220
|
+
* @returns Width for rows, height for columns, or `undefined` for flexible children.
|
|
221
|
+
*/
|
|
222
|
+
function getAxisLengthValue(child, orientation) {
|
|
223
|
+
if (child instanceof ViewLayoutItem) {
|
|
224
|
+
return orientation === 'row' ? child.props.width : child.props.height;
|
|
225
|
+
}
|
|
226
|
+
const props = child.props;
|
|
227
|
+
return orientation === 'row'
|
|
228
|
+
? props.width
|
|
229
|
+
: props.height;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Shrinks one rectangle by optional insets.
|
|
233
|
+
*
|
|
234
|
+
* @param rect - Rectangle allocated by the parent layout step.
|
|
235
|
+
* @param inset - Insets to apply inside that rectangle.
|
|
236
|
+
* @returns Inset rectangle clamped to non-negative size.
|
|
237
|
+
*/
|
|
238
|
+
function applyInsets(rect, inset) {
|
|
239
|
+
if (!inset) {
|
|
240
|
+
return rect;
|
|
241
|
+
}
|
|
242
|
+
const top = inset.top ?? 0;
|
|
243
|
+
const right = inset.right ?? 0;
|
|
244
|
+
const bottom = inset.bottom ?? 0;
|
|
245
|
+
const left = inset.left ?? 0;
|
|
246
|
+
return {
|
|
247
|
+
x: rect.x + left,
|
|
248
|
+
y: rect.y + top,
|
|
249
|
+
width: Math.max(0, rect.width - left - right),
|
|
250
|
+
height: Math.max(0, rect.height - top - bottom)
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Resolves one optional x/y offset against a parent length.
|
|
255
|
+
*
|
|
256
|
+
* @param value - Authored offset expression.
|
|
257
|
+
* @param parentLength - Parent width or height used for percentage resolution.
|
|
258
|
+
* @returns Numeric offset in deck pixels.
|
|
259
|
+
*/
|
|
260
|
+
function resolveOffset(value, parentLength) {
|
|
261
|
+
if (value === undefined || value === null) {
|
|
262
|
+
return 0;
|
|
263
|
+
}
|
|
264
|
+
return resolveLength(value, parentLength);
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Resolves one optional width or height against a parent length.
|
|
268
|
+
*
|
|
269
|
+
* @param value - Authored dimension expression.
|
|
270
|
+
* @param parentLength - Parent width or height used for percentage resolution.
|
|
271
|
+
* @param fallback - Fallback dimension used when no explicit expression is provided.
|
|
272
|
+
* @returns Numeric dimension in deck pixels.
|
|
273
|
+
*/
|
|
274
|
+
function resolveDimension(value, parentLength, fallback) {
|
|
275
|
+
if (value === undefined || value === null) {
|
|
276
|
+
return fallback;
|
|
277
|
+
}
|
|
278
|
+
return resolveLength(value, parentLength);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Resolves one numeric, percentage, or `calc(...)` length expression.
|
|
282
|
+
*
|
|
283
|
+
* @param value - Authored length expression.
|
|
284
|
+
* @param parentLength - Parent length used for percentage resolution.
|
|
285
|
+
* @returns Numeric length in deck pixels.
|
|
286
|
+
*/
|
|
287
|
+
function resolveLength(value, parentLength) {
|
|
288
|
+
if (typeof value === 'number') {
|
|
289
|
+
return value;
|
|
290
|
+
}
|
|
291
|
+
const normalized = value.trim();
|
|
292
|
+
if (normalized.length === 0) {
|
|
293
|
+
throw new Error('View layout length must not be empty.');
|
|
294
|
+
}
|
|
295
|
+
if (normalized.startsWith('calc(') && normalized.endsWith(')')) {
|
|
296
|
+
return resolveCalcExpression(normalized.slice(5, -1), parentLength);
|
|
297
|
+
}
|
|
298
|
+
return resolveLengthTerm(normalized, parentLength);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Resolves one simple `calc(...)` expression made of additive length terms.
|
|
302
|
+
*
|
|
303
|
+
* @param expression - Inner `calc(...)` expression without the wrapper.
|
|
304
|
+
* @param parentLength - Parent length used for percentage resolution.
|
|
305
|
+
* @returns Numeric length in deck pixels.
|
|
306
|
+
*/
|
|
307
|
+
function resolveCalcExpression(expression, parentLength) {
|
|
308
|
+
const sanitized = expression.replace(/\s+/g, '');
|
|
309
|
+
const terms = sanitized.match(/[+-]?[^+-]+/g);
|
|
310
|
+
if (!terms) {
|
|
311
|
+
throw new Error(`Unsupported calc expression: calc(${expression})`);
|
|
312
|
+
}
|
|
313
|
+
return terms.reduce((sum, term) => sum + resolveLengthTerm(term, parentLength), 0);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Resolves one atomic length term such as `10`, `10px`, or `50%`.
|
|
317
|
+
*
|
|
318
|
+
* @param term - One atomic length term.
|
|
319
|
+
* @param parentLength - Parent length used for percentage resolution.
|
|
320
|
+
* @returns Numeric length in deck pixels.
|
|
321
|
+
*/
|
|
322
|
+
function resolveLengthTerm(term, parentLength) {
|
|
323
|
+
if (term.endsWith('%')) {
|
|
324
|
+
return (Number.parseFloat(term.slice(0, -1)) / 100) * parentLength;
|
|
325
|
+
}
|
|
326
|
+
if (term.endsWith('px')) {
|
|
327
|
+
return Number.parseFloat(term.slice(0, -2));
|
|
328
|
+
}
|
|
329
|
+
return Number.parseFloat(term);
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Reads the string id from one deck view when present.
|
|
333
|
+
*
|
|
334
|
+
* @param view - Deck view instance to inspect.
|
|
335
|
+
* @returns String id or `null` when absent.
|
|
336
|
+
*/
|
|
337
|
+
function getViewId(view) {
|
|
338
|
+
const viewId = view.props.id;
|
|
339
|
+
return typeof viewId === 'string' && viewId.length > 0 ? viewId : null;
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Reads the required id from one deck view, throwing when missing.
|
|
343
|
+
*
|
|
344
|
+
* @param view - Deck view instance to inspect.
|
|
345
|
+
* @returns Non-empty string id.
|
|
346
|
+
*/
|
|
347
|
+
function getRequiredViewId(view) {
|
|
348
|
+
const viewId = getViewId(view);
|
|
349
|
+
if (!viewId) {
|
|
350
|
+
throw new Error('Every compiled deck view must have a string id.');
|
|
351
|
+
}
|
|
352
|
+
return viewId;
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Compares two props objects for structural equality.
|
|
356
|
+
*
|
|
357
|
+
* @param left - Previous props object.
|
|
358
|
+
* @param right - Next props object.
|
|
359
|
+
* @returns Whether both props objects are structurally equal.
|
|
360
|
+
*/
|
|
361
|
+
function arePropsEqual(left, right) {
|
|
362
|
+
if (left === right) {
|
|
363
|
+
return true;
|
|
364
|
+
}
|
|
365
|
+
const leftKeys = Object.keys(left);
|
|
366
|
+
const rightKeys = Object.keys(right);
|
|
367
|
+
if (leftKeys.length !== rightKeys.length) {
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
return leftKeys.every(key => areValuesEqual(left[key], right[key]));
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Recursively compares two primitive, array, or plain-object values.
|
|
374
|
+
*
|
|
375
|
+
* @param left - Previous value.
|
|
376
|
+
* @param right - Next value.
|
|
377
|
+
* @returns Whether both values are structurally equal.
|
|
378
|
+
*/
|
|
379
|
+
function areValuesEqual(left, right) {
|
|
380
|
+
if (Object.is(left, right)) {
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
383
|
+
if (Array.isArray(left) && Array.isArray(right)) {
|
|
384
|
+
return (left.length === right.length &&
|
|
385
|
+
left.every((value, index) => areValuesEqual(value, right[index])));
|
|
386
|
+
}
|
|
387
|
+
if (isPlainObject(left) && isPlainObject(right)) {
|
|
388
|
+
const leftEntries = Object.keys(left);
|
|
389
|
+
const rightEntries = Object.keys(right);
|
|
390
|
+
return (leftEntries.length === rightEntries.length &&
|
|
391
|
+
leftEntries.every(key => areValuesEqual(left[key], right[key])));
|
|
392
|
+
}
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Detects plain object records used by structural equality.
|
|
397
|
+
*
|
|
398
|
+
* @param value - Candidate value.
|
|
399
|
+
* @returns Whether the value is a plain object record.
|
|
400
|
+
*/
|
|
401
|
+
function isPlainObject(value) {
|
|
402
|
+
return (Boolean(value) && typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype);
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Removes falsey optional children from authored child arrays.
|
|
406
|
+
*
|
|
407
|
+
* @param child - Candidate authored child entry.
|
|
408
|
+
* @returns Whether the child should be compiled.
|
|
409
|
+
*/
|
|
410
|
+
function isPresentChild(child) {
|
|
411
|
+
return Boolean(child);
|
|
412
|
+
}
|
|
413
|
+
//# sourceMappingURL=build-views-from-view-layout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-views-from-view-layout.js","sourceRoot":"","sources":["../../../src/views/view-layout/build-views-from-view-layout.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAC,8BAA2B;AAsClD;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,IASxC;IACC,MAAM,QAAQ,GAAmB;QAC/B,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,CAAC;QACJ,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC;QAC9B,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;KACjC,CAAC;IACF,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAC/B,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC;SACzB,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K,CAAC,CAAC,CAAC,CAClE,CAAC;IACJ,CAAC;IACD,IAAI,aAAa,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QAChD,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtC,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,CACL,WAAW,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM;YAC1C,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAChE,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,CACL,OAAO,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,MAAM,CAAC,SAAS,CACjG,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,cAAc,CACrB,KAAsB;IAEtB,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { buildViewsFromViewLayout, type CompiledDeckViews, type ViewLayoutRect } from "./build-views-from-view-layout.js";
|
|
2
|
+
export { ViewLayoutItem, type ViewLayoutBaseProps, type ViewLayoutChild, type ViewLayoutColumnProps, type ViewLayoutInsets, type ViewLayoutItemProps, type ViewLayoutLength, type ViewLayoutOverlayProps, type ViewLayoutRowProps, type ViewLayoutSpacerProps, type ViewLayoutViewProps } from "./view-layout-item.js";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/views/view-layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACpB,0CAAuC;AACxC,OAAO,EACL,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACzB,8BAA2B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/views/view-layout/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EAGzB,0CAAuC;AACxC,OAAO,EACL,cAAc,EAWf,8BAA2B"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { View } from '@deck.gl/core';
|
|
2
|
+
/** CSS-like length accepted by the view layout builder. */
|
|
3
|
+
export type ViewLayoutLength = number | string;
|
|
4
|
+
/** Insets applied inside an allocated child rectangle before compiling its contents. */
|
|
5
|
+
export type ViewLayoutInsets = {
|
|
6
|
+
/** Top inset in pixels. */
|
|
7
|
+
top?: number;
|
|
8
|
+
/** Right inset in pixels. */
|
|
9
|
+
right?: number;
|
|
10
|
+
/** Bottom inset in pixels. */
|
|
11
|
+
bottom?: number;
|
|
12
|
+
/** Left inset in pixels. */
|
|
13
|
+
left?: number;
|
|
14
|
+
};
|
|
15
|
+
/** A raw deck.gl view or nested layout item allowed inside `children`. */
|
|
16
|
+
export type ViewLayoutChild = ViewLayoutItem | View | null | false | undefined;
|
|
17
|
+
/** Common layout metadata shared by every authored layout item. */
|
|
18
|
+
export type ViewLayoutBaseProps = {
|
|
19
|
+
/** Optional width expression resolved against the current parent bounds. */
|
|
20
|
+
width?: ViewLayoutLength;
|
|
21
|
+
/** Optional height expression resolved against the current parent bounds. */
|
|
22
|
+
height?: ViewLayoutLength;
|
|
23
|
+
/** Optional insets applied after parent layout allocation. */
|
|
24
|
+
inset?: ViewLayoutInsets;
|
|
25
|
+
};
|
|
26
|
+
/** One horizontal layout container that splits width among its children. */
|
|
27
|
+
export type ViewLayoutRowProps = ViewLayoutBaseProps & {
|
|
28
|
+
/** Discriminator for horizontal stack layout. */
|
|
29
|
+
type: 'row';
|
|
30
|
+
/** Ordered child items or raw deck views. */
|
|
31
|
+
children: readonly ViewLayoutChild[];
|
|
32
|
+
};
|
|
33
|
+
/** One vertical layout container that splits height among its children. */
|
|
34
|
+
export type ViewLayoutColumnProps = ViewLayoutBaseProps & {
|
|
35
|
+
/** Discriminator for vertical stack layout. */
|
|
36
|
+
type: 'column';
|
|
37
|
+
/** Ordered child items or raw deck views. */
|
|
38
|
+
children: readonly ViewLayoutChild[];
|
|
39
|
+
};
|
|
40
|
+
/** One overlay container that gives each child the same parent bounds. */
|
|
41
|
+
export type ViewLayoutOverlayProps = ViewLayoutBaseProps & {
|
|
42
|
+
/** Discriminator for overlay layout. */
|
|
43
|
+
type: 'overlay';
|
|
44
|
+
/** Ordered child items or raw deck views. */
|
|
45
|
+
children: readonly ViewLayoutChild[];
|
|
46
|
+
};
|
|
47
|
+
/** One wrapped raw deck view with optional layout-only overrides. */
|
|
48
|
+
export type ViewLayoutViewProps = ViewLayoutBaseProps & {
|
|
49
|
+
/** Discriminator for a wrapped raw deck view. */
|
|
50
|
+
type: 'view';
|
|
51
|
+
/** Underlying deck.gl view instance to compile. */
|
|
52
|
+
view: View;
|
|
53
|
+
};
|
|
54
|
+
/** One empty slot used to reserve fixed space in a stack. */
|
|
55
|
+
export type ViewLayoutSpacerProps = ViewLayoutBaseProps & {
|
|
56
|
+
/** Discriminator for an empty spacer item. */
|
|
57
|
+
type: 'spacer';
|
|
58
|
+
};
|
|
59
|
+
/** Discriminated union accepted by the `ViewLayoutItem` constructor. */
|
|
60
|
+
export type ViewLayoutItemProps = ViewLayoutRowProps | ViewLayoutColumnProps | ViewLayoutOverlayProps | ViewLayoutViewProps | ViewLayoutSpacerProps;
|
|
61
|
+
/**
|
|
62
|
+
* Thin runtime wrapper around one discriminated-union layout node.
|
|
63
|
+
*/
|
|
64
|
+
export declare class ViewLayoutItem {
|
|
65
|
+
/** Validated props backing this layout node. */
|
|
66
|
+
readonly props: ViewLayoutItemProps;
|
|
67
|
+
/**
|
|
68
|
+
* Creates one validated layout item from discriminated-union props.
|
|
69
|
+
*
|
|
70
|
+
* @param props - Layout item props keyed by `type`.
|
|
71
|
+
*/
|
|
72
|
+
constructor(props: ViewLayoutItemProps);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=view-layout-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-layout-item.d.ts","sourceRoot":"","sources":["../../../src/views/view-layout/view-layout-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AAEnC,2DAA2D;AAC3D,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/C,wFAAwF;AACxF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,2BAA2B;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4BAA4B;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,0EAA0E;AAC1E,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,SAAS,CAAC;AAE/E,mEAAmE;AACnE,MAAM,MAAM,mBAAmB,GAAG;IAChC,4EAA4E;IAC5E,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,8DAA8D;IAC9D,KAAK,CAAC,EA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|
4
|
+
*/
|
|
5
|
+
export class ViewLayoutItem {
|
|
6
|
+
/** Validated props backing this layout node. */
|
|
7
|
+
props;
|
|
8
|
+
/**
|
|
9
|
+
* Creates one validated layout item from discriminated-union props.
|
|
10
|
+
*
|
|
11
|
+
* @param props - Layout item props keyed by `type`.
|
|
12
|
+
*/
|
|
13
|
+
constructor(props) {
|
|
14
|
+
assertViewLayoutItemProps(props);
|
|
15
|
+
this.props = props;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Validates one discriminated-union prop object before storing it on a layout item.
|
|
20
|
+
*
|
|
21
|
+
* @param props - Candidate layout props passed to the constructor.
|
|
22
|
+
*/
|
|
23
|
+
function assertViewLayoutItemProps(props) {
|
|
24
|
+
if (!props || typeof props !== 'object') {
|
|
25
|
+
throw new Error('ViewLayoutItem props must be an object.');
|
|
26
|
+
}
|
|
27
|
+
switch (props.type) {
|
|
28
|
+
case 'row':
|
|
29
|
+
case 'column':
|
|
30
|
+
case 'overlay':
|
|
31
|
+
if (!Array.isArray(props.children)) {
|
|
32
|
+
throw new Error(`ViewLayoutItem "${props.type}" requires a children array.`);
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
case 'view':
|
|
36
|
+
if (!(props.view instanceof View)) {
|
|
37
|
+
throw new Error('ViewLayoutItem "view" requires a deck.gl View instance.');
|
|
38
|
+
}
|
|
39
|
+
break;
|
|
40
|
+
case 'spacer':
|
|
41
|
+
break;
|
|
42
|
+
default: {
|
|
43
|
+
const exhaustiveCheck = props;
|
|
44
|
+
throw new Error(`Unsupported view layout item: ${String(exhaustiveCheck)}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=view-layout-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-layout-item.js","sourceRoot":"","sources":["../../../src/views/view-layout/view-layout-item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,eAAe,CAAC;AA4EnC;;GAEG;AACH,MAAM,OAAO,cAAc;IACzB,gDAAgD;IACvC,KAAK,CAAsB;IAEpC;;;;OAIG;IACH,YAAY,KAA0B;QACpC,yBAAyB,CAAC,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AAED;;;;GAIG;AACH,SAAS,yBAAyB,CAAC,KAA0B;IAC3D,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,KAAK,CAAC;QACX,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS;YACZ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACnC,MAAM,IAAI,KAAK,CAAC,mBAAmB,KAAK,CAAC,IAAI,8BAA8B,CAAC,CAAC;YAC/E,CAAC;YACD,MAAM;QACR,KAAK,MAAM;YACT,IAAI,CAAC,CAAC,KAAK,CAAC,IAAI,YAAY,IAAI,CAAC,EAAE,CAAC;gBAClC,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;YAC7E,CAAC;YACD,MAAM;QACR,KAAK,QAAQ;YACX,MAAM;QACR,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,eAAe,GAAU,KAAK,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,iCAAiC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view-layout.test.d.ts","sourceRoot":"","sources":["../../../src/views/view-layout/view-layout.test.ts"],"names":[],"mappings":""}
|