Skip to content

Commit 4e4b109

Browse files
committed
wip
1 parent 551aadf commit 4e4b109

File tree

3 files changed

+35
-19
lines changed

3 files changed

+35
-19
lines changed

modules/editable-layers/src/lib/layers/segments-layer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {ArrowStyles, DEFAULT_STYLE, MAX_ARROWS} from '../style';
66
import {NebulaLayer} from '../nebula-layer';
77
import {toDeckColor} from '../../utils/utils';
88
import {DeckCache} from '../deck-renderer/deck-cache';
9-
import {PathMarkerLayer} from '@deck.gl-community/layers';
9+
import {PathMarkerLayer} from '../../../../layers/src/path-marker-layer/path-marker-layer';
1010

1111
const NEBULA_TO_DECK_DIRECTIONS = {
1212
[ArrowStyles.NONE]: {forward: false, backward: false},

modules/graph-layers/src/style/graph-layer-stylesheet.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: MIT
33
// Copyright (c) vis.gl contributors
44

5-
import type {GraphStylesheet, GraphStyleValue, GraphStyleType} from './graph-style-engine';
5+
import type {GraphStylesheet, GraphStyleType} from './graph-style-engine';
66

77
export type GraphNodeStyleType = Exclude<
88
GraphStyleType,
@@ -35,11 +35,6 @@ export type GraphLayerStylesheet = {
3535
edges?: GraphLayerEdgeStyle | GraphLayerEdgeStyle[];
3636
};
3737

38-
export type NormalizedGraphLayerStylesheet = {
39-
nodes: GraphLayerNodeStyle[];
40-
edges: GraphLayerEdgeStyle[];
41-
};
42-
4338
export type GraphLayerStylesheetInput = GraphLayerStylesheet | null | undefined;
4439

4540
export type NormalizedGraphLayerStylesheet = {
@@ -87,12 +82,12 @@ export function normalizeGraphLayerStylesheet({
8782
? [resolvedEdgeStyles]
8883
: DEFAULT_GRAPH_LAYER_STYLESHEET.edges;
8984

90-
const edges: GraphLayerEdgeStyle[] = (edgeEntries as GraphLayerEdgeStyle[])
85+
const edges: GraphLayerEdgeStyle[] = (edgeEntries)
9186
.filter(Boolean)
9287
.map((edgeStyleEntry) => ({
9388
...edgeStyleEntry,
94-
type: ((edgeStyleEntry as GraphLayerEdgeStyle).type ?? 'edge') as EdgeStyleType,
95-
decorators: (edgeStyleEntry as GraphLayerEdgeStyle).decorators ?? []
89+
type: ((edgeStyleEntry).type ?? 'edge'),
90+
decorators: (edgeStyleEntry).decorators ?? []
9691
})) as GraphLayerEdgeStyle[];
9792

9893
return {
@@ -101,8 +96,4 @@ export function normalizeGraphLayerStylesheet({
10196
};
10297
}
10398

104-
export type {
105-
GraphStyleValue,
106-
GraphStylesheet,
107-
GraphStyleType
108-
} from './graph-style-engine';
99+
export type {GraphStyleValue, GraphStylesheet, GraphStyleType} from './graph-style-engine';

modules/graph-layers/src/style/style-property.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -343,15 +343,39 @@ type LeafParseResult = {
343343
updateTrigger: unknown;
344344
};
345345

346+
function describeStyleValue(value: unknown): string {
347+
if (typeof value === 'string') {
348+
return value;
349+
}
350+
if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'undefined') {
351+
return String(value);
352+
}
353+
if (value === null) {
354+
return 'null';
355+
}
356+
if (typeof value === 'function') {
357+
return value.name ? `[Function ${value.name}]` : '[Function]';
358+
}
359+
if (Array.isArray(value)) {
360+
return `[${value.map((item) => describeStyleValue(item)).join(', ')}]`;
361+
}
362+
try {
363+
return JSON.stringify(value);
364+
} catch {
365+
return String(value);
366+
}
367+
}
368+
346369
/** Parse a non-stateful style value into deck.gl compatible form. */
347370
function parseLeafValue(key: string, value: GraphStyleLeafValue | undefined): LeafParseResult {
348371
const formatter = PROPERTY_FORMATTERS[key] || IDENTITY;
349372

350373
if (typeof value === 'undefined') {
351374
const formatted = formatter(DEFAULT_STYLES[key]);
352375
if (formatted === null) {
353-
log.warn(`Invalid ${key} value: ${value}`);
354-
throw new Error(`Invalid ${key} value: ${value}`);
376+
const description = describeStyleValue(value);
377+
log.warn(`Invalid ${key} value: ${description}`);
378+
throw new Error(`Invalid ${key} value: ${description}`);
355379
}
356380
return {value: formatted, isAccessor: false, updateTrigger: false};
357381
}
@@ -372,8 +396,9 @@ function parseLeafValue(key: string, value: GraphStyleLeafValue | undefined): Le
372396

373397
const formatted = formatter(value);
374398
if (formatted === null) {
375-
log.warn(`Invalid ${key} value: ${value}`);
376-
throw new Error(`Invalid ${key} value: ${value}`);
399+
const description = describeStyleValue(value);
400+
log.warn(`Invalid ${key} value: ${description}`);
401+
throw new Error(`Invalid ${key} value: ${description}`);
377402
}
378403

379404
return {value: formatted, isAccessor: false, updateTrigger: false};

0 commit comments

Comments
 (0)