Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tilesets): Support widget calculations on tilesets #50

Merged
merged 2 commits into from
Feb 10, 2025

Conversation

donmccurdy
Copy link
Member

@donmccurdy donmccurdy commented Dec 31, 2024

Changes:

  • Migrate local calculations from C4R
  • Port local calculations to TypeScript
    • In some cases the types were not obvious, particularly required vs. optional parameters and overloaded types (see: SortColumns). I've used strict TS types where possible, and generally tried to make parameters required for internal functions so that defaults are applied only once at top-level calls.
  • Migrate unit tests from C4R
  • Add WidgetTilesetSource class
  • Refactor WidgetSource class hierarchy:
    • WidgetSource
      • WidgetRemoteSource
        • WidgetTableSource
        • WidgetQuerySource
      • WidgetTilesetSource
  • Add tileset example

@donmccurdy donmccurdy force-pushed the feat/sc-459604/tileset-widgets branch 2 times, most recently from 82c8732 to 2370ee5 Compare January 2, 2025 23:23
@donmccurdy donmccurdy changed the title feat(widgets): Add support for tileset sources and local widget calculations feat(tilesets): Add support for tileset sources and local widget calculations Jan 3, 2025
@donmccurdy donmccurdy added the enhancement New feature or request label Jan 3, 2025
@donmccurdy donmccurdy marked this pull request as ready for review January 3, 2025 17:39
@donmccurdy donmccurdy force-pushed the feat/sc-459604/tileset-widgets branch 2 times, most recently from 9affa4f to d7ff039 Compare January 15, 2025 20:37
@donmccurdy donmccurdy changed the title feat(tilesets): Add support for tileset sources and local widget calculations feat(tilesets): Support widget calculations on tilesets Jan 15, 2025
@donmccurdy donmccurdy force-pushed the feat/sc-459604/tileset-widgets branch 2 times, most recently from f9e9120 to 9070e96 Compare January 31, 2025 19:09
Copy link
Collaborator

@padawannn padawannn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job @donmccurdy. Some small comments, can you take a look?

package.json Show resolved Hide resolved
src/filters/tileFeatures.ts Outdated Show resolved Hide resolved
@@ -0,0 +1,6 @@
export * from './Filter.js';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we export the ts files instead of js files? I mean

export * from './Filter.ts';

instead of

export * from './Filter.js';

I've notice other exports like this in other places like https://github.com/CartoDB/carto-api-client/blob/main/src/index.ts#L1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't do .ts I think, the build process would have to rename the imports in .d.ts files to .js at build time, and TypeScript has for a very long time been against allowing that:

The filenames are supposed to be paths that can be resolved after TypeScript compilation, so we are stuck with either ./Filter or ./Filter.js. Currently the codebase has a mix of both ... so that is not great, I would like to clean it up to be consistent, I'll do that in a new PR. 😅

While I'm happy with either in an app like Builder, I think that for libraries we may need to use .js, because that's what should appear in the published .d.ts files. It's required for customers using certain configurations, particularly moduleResolution: 'nodenext'. I've had this feedback in some of my personal repositories in the past, discussion here:

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I've opened a new issue to track this:

I'll wait to make the changes until after this PR and the raster PR are merged, so we don't have a bunch of merge conflicts.

Copy link
Collaborator

@padawannn padawannn Feb 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@donmccurdy, why don't we export the file without the extension as Deck.gl does? https://github.com/visgl/deck.gl/blob/master/modules/core/src/index.ts#L90 I mean

export * from './Filter';

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So deck.gl is using ... from './Foo' in source files, but they've written a special build step that adds the .js extension to the generated .d.ts files:

https://github.com/uber-web/ocular/blob/6d84ec50d8c80dc2cf361e818e9edb35f597042a/modules/dev-tools/src/ts-plugins/ts-transform-append-extension/index.ts

Added in:

Admittedly putting the .js extension in source code is weird/ugly... but without customizing the build process I don't know of another way to solve that problem for customers. Another option would be to bundle the .d.ts files into one file, so there are no imports in the output, but that will complicate the build step and I haven't found a build setup that I trust for that yet. 😕

src/index.ts Show resolved Hide resolved
src/operations/groupBy.ts Show resolved Hide resolved
Copy link
Collaborator

@padawannn padawannn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your comments. I've approved the PR but please check this comment #50 (comment)

@donmccurdy donmccurdy force-pushed the feat/sc-459604/tileset-widgets branch from 9070e96 to 98664a1 Compare February 10, 2025 21:34
@donmccurdy donmccurdy merged commit b82cf71 into main Feb 10, 2025
5 checks passed
@donmccurdy donmccurdy deleted the feat/sc-459604/tileset-widgets branch February 10, 2025 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants