Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ibgreen committed Sep 25, 2023
1 parent 897f3a4 commit 730e9ca
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 19 deletions.
1 change: 0 additions & 1 deletion modules/core/src/index.ts
Expand Up @@ -46,7 +46,6 @@ export {default as Deck} from './lib/deck';

export {default as LayerManager} from './lib/layer-manager';
export {default as AttributeManager} from './lib/attribute/attribute-manager';
export type {SharedLayerState} from './lib/layer';
export {default as Layer} from './lib/layer';
export {default as CompositeLayer} from './lib/composite-layer';
export {default as DeckRenderer} from './lib/deck-renderer';
Expand Down
9 changes: 3 additions & 6 deletions modules/core/src/lib/layer.ts
Expand Up @@ -185,14 +185,13 @@ export type UpdateParameters<LayerT extends Layer> = {
changeFlags: ChangeFlags;
};

export type SharedLayerState = {
type SharedLayerState = {
model?: Model;
[key: string]: any;
};

export default abstract class Layer<
PropsT extends {} = {},
StateT extends SharedLayerState = SharedLayerState
PropsT extends {} = {}
> extends Component<PropsT & Required<LayerProps>> {
static defaultProps: DefaultProps = defaultProps;
static layerName: string = 'Layer';
Expand All @@ -208,7 +207,7 @@ export default abstract class Layer<
// However, they are most extensively accessed in a layer's lifecycle methods, where they are always defined.
// Checking for null state constantly in layer implementation is unnecessarily verbose.
context!: LayerContext; // Will reference layer manager's context, contains state shared by layers
state!: StateT; // Will be set to the shared layer state object during layer matching
state!: SharedLayerState; // Will be set to the shared layer state object during layer matching

parent: Layer | null = null;

Expand Down Expand Up @@ -869,7 +868,6 @@ export default abstract class Layer<
});
this._clearChangeFlags(); // populate this.internalState.changeFlags

// @ts-expect-error
this.state = {};
// for backwards compatibility with older layers
// TODO - remove in next release
Expand Down Expand Up @@ -922,7 +920,6 @@ export default abstract class Layer<
this.internalState = internalState as LayerState<this>;

// Move state
// @ts-expect-error
this.state = state;
// We keep the state ref on old layers to support async actions
// oldLayer.state = null;
Expand Down
5 changes: 0 additions & 5 deletions modules/layers/src/geojson-layer/geojson-layer.ts
Expand Up @@ -296,15 +296,10 @@ type _GeojsonLayerTextPointProps = {
const FEATURE_TYPES = ['points', 'linestrings', 'polygons'];

const defaultProps: DefaultProps<GeoJsonLayerProps> = {
// @ts-expect-error
...getDefaultProps(POINT_LAYER.circle),
// @ts-expect-error
...getDefaultProps(POINT_LAYER.icon),
// @ts-expect-error
...getDefaultProps(POINT_LAYER.text),
// @ts-expect-error
...getDefaultProps(LINE_LAYER),
// @ts-expect-error
...getDefaultProps(POLYGON_LAYER),

// Overwrite sub layer defaults
Expand Down
12 changes: 5 additions & 7 deletions modules/layers/src/scatterplot-layer/scatterplot-layer.ts
Expand Up @@ -28,7 +28,6 @@ import type {
LayerProps,
LayerDataSource,
UpdateParameters,
SharedLayerState,
Accessor,
Unit,
Position,
Expand Down Expand Up @@ -148,10 +147,6 @@ type _ScatterplotLayerProps<DataT> = {
getColor?: Accessor<DataT, Color>;
};

type ScatterplotState = SharedLayerState & {
uniformStore: UniformStore<{scatterplot: ScatterplotLayerUniforms}>;
};

const defaultProps: DefaultProps<ScatterplotLayerProps> = {
radiusUnits: 'meters',
radiusScale: {type: 'number', min: 0, value: 1},
Expand Down Expand Up @@ -182,12 +177,15 @@ const defaultProps: DefaultProps<ScatterplotLayerProps> = {

/** Render circles at given coordinates. */
export default class ScatterplotLayer<DataT = any, ExtraPropsT extends {} = {}> extends Layer<
ExtraPropsT & Required<_ScatterplotLayerProps<DataT>>,
ScatterplotState
ExtraPropsT & Required<_ScatterplotLayerProps<DataT>>
> {
static defaultProps = defaultProps;
static layerName: string = 'ScatterplotLayer';

state!: Layer['state'] & {
uniformStore: UniformStore<{scatterplot: ScatterplotLayerUniforms}>;
};

getShaders() {
return super.getShaders({vs, fs, modules: [project32, picking]});
}
Expand Down

0 comments on commit 730e9ca

Please sign in to comment.