@sqlrooms/deck 0.29.0-rc.2 → 0.29.0-rc.3

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.
Files changed (123) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +69 -0
  3. package/dist/DeckJsonMap.d.ts +4 -0
  4. package/dist/DeckJsonMap.d.ts.map +1 -0
  5. package/dist/{DeckMap.js → DeckJsonMap.js} +57 -44
  6. package/dist/DeckJsonMap.js.map +1 -0
  7. package/dist/DeckJsonMapSpec.d.ts +7617 -0
  8. package/dist/DeckJsonMapSpec.d.ts.map +1 -0
  9. package/dist/DeckJsonMapSpec.js +81 -0
  10. package/dist/DeckJsonMapSpec.js.map +1 -0
  11. package/dist/DeckMapConfigPopoverEditor.d.ts +8 -0
  12. package/dist/DeckMapConfigPopoverEditor.d.ts.map +1 -0
  13. package/dist/DeckMapConfigPopoverEditor.js +43 -0
  14. package/dist/DeckMapConfigPopoverEditor.js.map +1 -0
  15. package/dist/createDeckJsonSpecFromDatasets.d.ts +11 -0
  16. package/dist/createDeckJsonSpecFromDatasets.d.ts.map +1 -0
  17. package/dist/createDeckJsonSpecFromDatasets.js +85 -0
  18. package/dist/createDeckJsonSpecFromDatasets.js.map +1 -0
  19. package/dist/dashboard.d.ts +4 -0
  20. package/dist/dashboard.d.ts.map +1 -0
  21. package/dist/dashboard.js +465 -0
  22. package/dist/dashboard.js.map +1 -0
  23. package/dist/dashboardConfig.d.ts +51 -0
  24. package/dist/dashboardConfig.d.ts.map +1 -0
  25. package/dist/dashboardConfig.js +54 -0
  26. package/dist/dashboardConfig.js.map +1 -0
  27. package/dist/datasets/PreparedDatasetStore.d.ts +120 -0
  28. package/dist/datasets/PreparedDatasetStore.d.ts.map +1 -0
  29. package/dist/datasets/PreparedDatasetStore.js +262 -0
  30. package/dist/datasets/PreparedDatasetStore.js.map +1 -0
  31. package/dist/datasets/helpers.d.ts +57 -0
  32. package/dist/datasets/helpers.d.ts.map +1 -0
  33. package/dist/datasets/helpers.js +146 -0
  34. package/dist/datasets/helpers.js.map +1 -0
  35. package/dist/datasets/normalizeDatasets.d.ts +8 -2
  36. package/dist/datasets/normalizeDatasets.d.ts.map +1 -1
  37. package/dist/datasets/normalizeDatasets.js +33 -48
  38. package/dist/datasets/normalizeDatasets.js.map +1 -1
  39. package/dist/datasets/tableAdapter.d.ts +11 -0
  40. package/dist/datasets/tableAdapter.d.ts.map +1 -0
  41. package/dist/datasets/tableAdapter.js +11 -0
  42. package/dist/datasets/tableAdapter.js.map +1 -0
  43. package/dist/datasets/types.d.ts +40 -0
  44. package/dist/datasets/types.d.ts.map +1 -0
  45. package/dist/datasets/types.js +2 -0
  46. package/dist/datasets/types.js.map +1 -0
  47. package/dist/datasets/usePreparedDatasetStates.d.ts +16 -0
  48. package/dist/datasets/usePreparedDatasetStates.d.ts.map +1 -0
  49. package/dist/datasets/usePreparedDatasetStates.js +59 -0
  50. package/dist/datasets/usePreparedDatasetStates.js.map +1 -0
  51. package/dist/index.d.ts +10 -3
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +7 -2
  54. package/dist/index.js.map +1 -1
  55. package/dist/json/colorScaleFunction.d.ts +14 -0
  56. package/dist/json/colorScaleFunction.d.ts.map +1 -0
  57. package/dist/json/colorScaleFunction.js +34 -0
  58. package/dist/json/colorScaleFunction.js.map +1 -0
  59. package/dist/json/compileColorScale.d.ts +4 -27
  60. package/dist/json/compileColorScale.d.ts.map +1 -1
  61. package/dist/json/compileColorScale.js +16 -450
  62. package/dist/json/compileColorScale.js.map +1 -1
  63. package/dist/json/compileGeoArrowAccessor.d.ts +7 -0
  64. package/dist/json/compileGeoArrowAccessor.d.ts.map +1 -1
  65. package/dist/json/compileGeoArrowAccessor.js +68 -2
  66. package/dist/json/compileGeoArrowAccessor.js.map +1 -1
  67. package/dist/json/createDeckJsonConfiguration.d.ts.map +1 -1
  68. package/dist/json/createDeckJsonConfiguration.js +86 -33
  69. package/dist/json/createDeckJsonConfiguration.js.map +1 -1
  70. package/dist/json/defaultClasses.d.ts +12 -6
  71. package/dist/json/defaultClasses.d.ts.map +1 -1
  72. package/dist/json/defaultClasses.js +7 -1
  73. package/dist/json/defaultClasses.js.map +1 -1
  74. package/dist/json/extractColorScaleLegends.d.ts +1 -1
  75. package/dist/json/extractColorScaleLegends.d.ts.map +1 -1
  76. package/dist/json/extractColorScaleLegends.js +8 -6
  77. package/dist/json/extractColorScaleLegends.js.map +1 -1
  78. package/dist/json/layerCompatibility.d.ts +9 -3
  79. package/dist/json/layerCompatibility.d.ts.map +1 -1
  80. package/dist/json/layerCompatibility.js +135 -11
  81. package/dist/json/layerCompatibility.js.map +1 -1
  82. package/dist/json/layerConfig.d.ts +7 -3
  83. package/dist/json/layerConfig.d.ts.map +1 -1
  84. package/dist/json/layerConfig.js +19 -8
  85. package/dist/json/layerConfig.js.map +1 -1
  86. package/dist/prepare/detectGeometryColumn.d.ts.map +1 -1
  87. package/dist/prepare/detectGeometryColumn.js +1 -1
  88. package/dist/prepare/detectGeometryColumn.js.map +1 -1
  89. package/dist/prepare/geoarrow.d.ts.map +1 -1
  90. package/dist/prepare/geoarrow.js.map +1 -1
  91. package/dist/prepare/geometryDecoder.d.ts +1 -2
  92. package/dist/prepare/geometryDecoder.d.ts.map +1 -1
  93. package/dist/prepare/geometryDecoder.js.map +1 -1
  94. package/dist/prepare/prepareDeckDataset.d.ts +46 -0
  95. package/dist/prepare/prepareDeckDataset.d.ts.map +1 -1
  96. package/dist/prepare/prepareDeckDataset.js +46 -0
  97. package/dist/prepare/prepareDeckDataset.js.map +1 -1
  98. package/dist/prepare/toGeoJsonBinary.d.ts.map +1 -1
  99. package/dist/prepare/toGeoJsonBinary.js +3 -2
  100. package/dist/prepare/toGeoJsonBinary.js.map +1 -1
  101. package/dist/prepare/wkbDecoder.d.ts.map +1 -1
  102. package/dist/prepare/wkbDecoder.js +36 -9
  103. package/dist/prepare/wkbDecoder.js.map +1 -1
  104. package/dist/types.d.ts +31 -92
  105. package/dist/types.d.ts.map +1 -1
  106. package/dist/types.js +6 -1
  107. package/dist/types.js.map +1 -1
  108. package/dist/useDeckLayersReadyRedraw.d.ts +13 -0
  109. package/dist/useDeckLayersReadyRedraw.d.ts.map +1 -0
  110. package/dist/useDeckLayersReadyRedraw.js +35 -0
  111. package/dist/useDeckLayersReadyRedraw.js.map +1 -0
  112. package/package.json +16 -10
  113. package/dist/ColorScaleLegend.d.ts +0 -8
  114. package/dist/ColorScaleLegend.d.ts.map +0 -1
  115. package/dist/ColorScaleLegend.js +0 -11
  116. package/dist/ColorScaleLegend.js.map +0 -1
  117. package/dist/DeckMap.d.ts +0 -4
  118. package/dist/DeckMap.d.ts.map +0 -1
  119. package/dist/DeckMap.js.map +0 -1
  120. package/dist/datasets/usePreparedDeckDatasets.d.ts +0 -3
  121. package/dist/datasets/usePreparedDeckDatasets.d.ts.map +0 -1
  122. package/dist/datasets/usePreparedDeckDatasets.js +0 -61
  123. package/dist/datasets/usePreparedDeckDatasets.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/datasets/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAwB,MAAM,UAAU,CAAC;AAClE,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAGtD,MAAM,CAAC,MAAM,oCAAoC,GAAG,EAAE,CAAC;AAEvD,IAAI,iBAAiB,GAAG,CAAC,CAAC;AAC1B,IAAI,iBAAiB,GAAG,CAAC,CAAC;AAC1B,IAAI,qBAAqB,GAAG,CAAC,CAAC;AAE9B,MAAM,eAAe,GAAG,IAAI,OAAO,EAAuB,CAAC;AAC3D,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAAkB,CAAC;AAE1D,4EAA4E;AAC5E,MAAM,UAAU,mBAAmB;IACjC,iBAAiB,IAAI,CAAC,CAAC;IACvB,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED;;;;;G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AC,MAAM,CACnD,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAC1C,CAAC;IAEF,IAAI,cAAc,CAAC,MAAM,IAAI,UAAU,EAAE,CAAC;QACxC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,SAAS,GAAG,cAAc;SAC7B,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,CAAC;SACjD,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC,cAAc,CAAC,CAAC;IAE7E,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,WAAW,GAAG,EAAC,GAAG,OAAO,EAAC,CAAC;IACjC,IAAI,YAAY,GAAG,cAAc,CAAC,MAAM,CAAC;IAEzC,KAAK,MAAM,CAAC,QAAQ,CAAC,IAAI,SAAS,EAAE,CAAC;QACnC,IAAI,YAAY,IAAI,UAAU,EAAE,CAAC;YAC/B,MAAM;QACR,CAAC;QAED,OAAO,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC7B,YAAY,IAAI,CAAC,CAAC;IACpB,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["import type * as arrow from 'apache-arrow';\nimport {isSqlDatasetInput, type DeckDatasetInput} from '../types';\nimport {resolveArrowTable} from './normalizeDatasets';\nimport type {PreparedDatasetCacheEntry} from './types';\n\nexport const DEFAULT_MAX_PREPARED_DATASET_ENTRIES = 20;\n\nlet nextDatasetAccess = 0;\nlet nextTableIdentity = 0;\nlet nextSqlSourceIdentity = 0;\n\nconst tableIdentities = new WeakMap<arrow.Table, string>();\nconst sqlSourceIdentities = new WeakMap<object, string>();\n\n/** Return a monotonic access timestamp used by the prepared-dataset LRU. */\nexport function nextAccessTimestamp(): number {\n nextDatasetAccess += 1;\n return nextDatasetAccess;\n}\n\n/**\n * Assign a stable cache identity to an Arrow table object.\n *\n * Table identities are stored in a `WeakMap` so this cache does not extend the\n * lifetime of tables once they are no longer referenced elsewhere.\n */\nexport function getTableIdentity(table: arrow.Table): string {\n const cached = tableIdentities.get(table);\n if (cached) {\n return cached;\n }\n\n nextTableIdentity += 1;\n const identity = `table:${nextTableIdentity}`;\n tableIdentities.set(table, identity);\n return identity;\n}\n\n/**\n * Assign a stable cache identity to the current SQL source object.\n *\n * For SQL datasets we include the upstream DuckDB connector identity in the\n * cache key so two rooms using the same SQL text do not accidentally share\n * prepared results across different database instances.\n */\nexport function getSqlSourceIdentity(sqlSourceIdentity: object): string {\n const cached = sqlSourceIdentities.get(sqlSourceIdentity);\n if (cached) {\n return cached;\n }\n\n nextSqlSourceIdentity += 1;\n const identity = `sql-source:${nextSqlSourceIdentity}`;\n sqlSourceIdentities.set(sqlSourceIdentity, identity);\n return identity;\n}\n\nexport function buildGeometryKey(input: DeckDatasetInput): string {\n return `${input.geometryColumn ?? ''}\\u0001${input.geometryEncodingHint ?? ''}`;\n}\n\n/**\n * Build the canonical cache key for one dataset input.\n *\n * The key intentionally ignores the user-facing dataset id and instead uses\n * the underlying data identity:\n *\n * - SQL datasets: DuckDB connector identity + SQL text + geometry options\n * - Arrow datasets: table object identity + geometry options\n *\n * Unresolved Arrow inputs (`arrowTable: undefined`) return `undefined`, which\n * signals that the dataset should remain in `loading` until a table exists.\n */\nexport function resolvePreparedDatasetCacheKey(options: {\n input: DeckDatasetInput;\n sqlSourceIdentity?: object;\n}): string | undefined {\n const {input, sqlSourceIdentity} = options;\n\n if (isSqlDatasetInput(input)) {\n if (!sqlSourceIdentity) {\n throw new Error(\n 'SQL dataset cache keys require a sqlSourceIdentity object.',\n );\n }\n\n return [\n 'sql',\n getSqlSourceIdentity(sqlSourceIdentity),\n input.sqlQuery,\n buildGeometryKey(input),\n ].join('\\u0001');\n }\n\n const table = resolveArrowTable(input);\n if (!table) {\n return undefined;\n }\n\n return ['arrow', getTableIdentity(table), buildGeometryKey(input)].join(\n '\\u0001',\n );\n}\n\n/**\n * Clone a cache entry while replacing its consumer set and refreshing the\n * access timestamp.\n *\n * This keeps the discriminated union shape intact while centralizing the\n * bookkeeping needed by consumer reconciliation and LRU tracking.\n */\nexport function cloneEntryWithConsumers(\n entry: PreparedDatasetCacheEntry,\n consumers: Set<string>,\n): PreparedDatasetCacheEntry {\n const lastAccessedAt = nextAccessTimestamp();\n\n if (entry.status === 'loading') {\n return {\n status: 'loading',\n promise: entry.promise,\n consumers,\n lastAccessedAt,\n };\n }\n\n if (entry.status === 'ready') {\n return {\n status: 'ready',\n prepared: entry.prepared,\n consumers,\n lastAccessedAt,\n };\n }\n\n return {\n status: 'error',\n error: entry.error,\n consumers,\n lastAccessedAt,\n };\n}\n\n/** Mark an entry as recently used without changing its lifecycle payload. */\nexport function touchEntry(\n entry: PreparedDatasetCacheEntry,\n): PreparedDatasetCacheEntry {\n return cloneEntryWithConsumers(entry, new Set(entry.consumers));\n}\n\n/**\n * Evict least-recently-used settled entries when the cache exceeds capacity.\n *\n * Only `ready` and `error` entries participate in eviction. `loading` entries\n * are preserved so in-flight work is not discarded, and referenced entries are\n * preserved so active maps never lose their prepared data mid-render.\n */\nexport function evictLruEntries(\n entries: Record<string, PreparedDatasetCacheEntry>,\n maxEntries: number,\n): Record<string, PreparedDatasetCacheEntry> {\n const settledEntries = Object.entries(entries).filter(\n ([, entry]) => entry.status !== 'loading',\n );\n\n if (settledEntries.length <= maxEntries) {\n return entries;\n }\n\n const evictable = settledEntries\n .filter(([, entry]) => entry.consumers.size === 0)\n .sort(([, left], [, right]) => left.lastAccessedAt - right.lastAccessedAt);\n\n if (evictable.length === 0) {\n return entries;\n }\n\n const nextEntries = {...entries};\n let settledCount = settledEntries.length;\n\n for (const [cacheKey] of evictable) {\n if (settledCount <= maxEntries) {\n break;\n }\n\n delete nextEntries[cacheKey];\n settledCount -= 1;\n }\n\n return nextEntries;\n}\n"]}
@@ -1,5 +1,11 @@
1
1
  import type * as arrow from 'apache-arrow';
2
- import type { DeckDatasetInput, DeckMapProps } from '../types';
2
+ import { type DeckDatasetInput, type DeckJsonMapProps } from '../types';
3
3
  export declare function resolveArrowTable(input: DeckDatasetInput): arrow.Table | undefined;
4
- export declare function normalizeDatasets(props: Pick<DeckMapProps, 'datasets' | 'sqlQuery' | 'arrowTable' | 'queryResult' | 'geometryColumn' | 'geometryEncodingHint'>): Record<string, DeckDatasetInput>;
4
+ /**
5
+ * Validate and normalize a raw datasets record into canonical
6
+ * `DeckDatasetInput` entries.
7
+ *
8
+ * @throws {Error} If `datasets` is empty (DeckJsonMap requires at least one entry).
9
+ */
10
+ export declare function normalizeDatasets(datasets: DeckJsonMapProps['datasets']): Record<string, DeckDatasetInput>;
5
11
  //# sourceMappingURL=normalizeDatasets.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalizeDatasets.d.ts","sourceRoot":"","sources":["../../src/datasets/normalizeDatasets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAC,gBAAgB,EAAE,YAAY,EAAsB,MAAM,UAAU,CAAC;AA8ClF,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,gBAAgB,GACtB,KAAK,CAAC,KAAK,GAAG,SAAS,CAEzB;AAED,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,IAAI,CACT,YAAY,EACV,UAAU,GACV,UAAU,GACV,YAAY,GACZ,aAAa,GACb,gBAAgB,GAChB,sBAAsB,CACzB,GACA,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CA2BlC"}
1
+ {"version":3,"file":"normalizeDatasets.d.ts","sourceRoot":"","sources":["../../src/datasets/normalizeDatasets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAC3C,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACtB,MAAM,UAAU,CAAC;AA4BlB,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,gBAAgB,GACtB,KAAK,CAAC,KAAK,GAAG,SAAS,CAMzB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,GACrC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAalC"}
@@ -1,57 +1,42 @@
1
- function getArrowTableFromQueryResult(queryResult) {
2
- return queryResult?.arrowTable;
3
- }
4
- function countDefinedInputs(input) {
5
- return Number(Boolean(input.sqlQuery)) +
6
- Number(Boolean(input.arrowTable)) +
7
- Number(Boolean(input.queryResult));
8
- }
9
- function assertArrowTable(value, datasetId) {
10
- if (!value) {
11
- throw new Error(`Dataset "${datasetId}" queryResult did not expose an arrowTable.`);
12
- }
13
- }
1
+ import { isArrowTableDatasetInput, isSqlDatasetInput, } from '../types';
2
+ import { toArrowTable } from './tableAdapter';
14
3
  function normalizeDatasetEntry(datasetId, input) {
15
- const normalized = {
16
- sqlQuery: input.sqlQuery,
17
- arrowTable: input.arrowTable,
18
- queryResult: input.queryResult,
19
- geometryColumn: input.geometryColumn,
20
- geometryEncodingHint: input.geometryEncodingHint,
21
- };
22
- const definedInputs = countDefinedInputs(normalized);
23
- if (definedInputs !== 1) {
24
- throw new Error(`Dataset "${datasetId}" must provide exactly one of sqlQuery, arrowTable, or queryResult.`);
4
+ if (isSqlDatasetInput(input)) {
5
+ return {
6
+ sqlQuery: input.sqlQuery,
7
+ geometryColumn: input.geometryColumn,
8
+ geometryEncodingHint: input.geometryEncodingHint,
9
+ };
25
10
  }
26
- if (normalized.queryResult) {
27
- assertArrowTable(getArrowTableFromQueryResult(normalized.queryResult), datasetId);
11
+ if (isArrowTableDatasetInput(input)) {
12
+ return {
13
+ arrowTable: input.arrowTable,
14
+ geometryColumn: input.geometryColumn,
15
+ geometryEncodingHint: input.geometryEncodingHint,
16
+ };
28
17
  }
29
- return normalized;
18
+ throw new Error(`Dataset "${datasetId}" has an unrecognized input shape. Expected either { sqlQuery } or { arrowTable }.`);
30
19
  }
31
20
  export function resolveArrowTable(input) {
32
- return input.arrowTable ?? getArrowTableFromQueryResult(input.queryResult);
33
- }
34
- export function normalizeDatasets(props) {
35
- if (props.datasets) {
36
- const entries = Object.entries(props.datasets).map(([datasetId, input]) => [
37
- datasetId,
38
- normalizeDatasetEntry(datasetId, input),
39
- ]);
40
- return Object.fromEntries(entries);
21
+ if (!isArrowTableDatasetInput(input) || input.arrowTable === undefined) {
22
+ return undefined;
41
23
  }
42
- const singleInput = {
43
- sqlQuery: props.sqlQuery,
44
- arrowTable: props.arrowTable,
45
- queryResult: props.queryResult,
46
- geometryColumn: props.geometryColumn,
47
- geometryEncodingHint: props.geometryEncodingHint,
48
- };
49
- const definedInputs = countDefinedInputs(singleInput);
50
- if (definedInputs === 0) {
51
- throw new Error('DeckMap requires either datasets or one of sqlQuery, arrowTable, or queryResult.');
24
+ return toArrowTable(input.arrowTable);
25
+ }
26
+ /**
27
+ * Validate and normalize a raw datasets record into canonical
28
+ * `DeckDatasetInput` entries.
29
+ *
30
+ * @throws {Error} If `datasets` is empty (DeckJsonMap requires at least one entry).
31
+ */
32
+ export function normalizeDatasets(datasets) {
33
+ const entries = Object.entries(datasets);
34
+ if (entries.length === 0) {
35
+ throw new Error('DeckJsonMap requires at least one dataset entry.');
52
36
  }
53
- return {
54
- default: normalizeDatasetEntry('default', singleInput),
55
- };
37
+ return Object.fromEntries(entries.map(([datasetId, input]) => [
38
+ datasetId,
39
+ normalizeDatasetEntry(datasetId, input),
40
+ ]));
56
41
  }
57
42
  //# sourceMappingURL=normalizeDatasets.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalizeDatasets.js","sourceRoot":"","sources":["../../src/datasets/normalizeDatasets.ts"],"names":[],"mapp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AC7E,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,KAQC;IAED,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;YACzE,SAAS;YACT,qBAAqB,CAAC,SAAS,EAAE,KAAK,CAAC;SACxC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,MAAM,WAAW,GAAqB;QACpC,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,oBAAoB,EAAE,KAAK,CAAC,oBAAoB;KACjD,CAAC;IAEF,MAAM,aAAa,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IACtD,IAAI,aAAa,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CACb,kFAAkF,CACnF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,OAAO,EAAE,qBAAqB,CAAC,SAAS,EAAE,WAAW,CAAC;KACvD,CAAC;AACJ,CAAC","sourcesContent":["import type * as arrow from 'apache-arrow';\nimport type {DeckDatasetInput, DeckMapProps, DeckQueryResultLike} from '../types';\n\nfunction getArrowTableFromQueryResult(queryResult: DeckQueryResultLike | undefined) {\n return queryResult?.arrowTable;\n}\n\nfunction countDefinedInputs(input: DeckDatasetInput) {\n return Number(Boolean(input.sqlQuery)) +\n Number(Boolean(input.arrowTable)) +\n Number(Boolean(input.queryResult));\n}\n\nfunction assertArrowTable(value: arrow.Table | undefined, datasetId: string) {\n if (!value) {\n throw new Error(\n `Dataset \"${datasetId}\" queryResult did not expose an arrowTable.`,\n );\n }\n}\n\nfunction normalizeDatasetEntry(\n datasetId: string,\n input: DeckDatasetInput,\n): DeckDatasetInput {\n const normalized: DeckDatasetInput = {\n sqlQuery: input.sqlQuery,\n arrowTable: input.arrowTable,\n queryResult: input.queryResult,\n geometryColumn: input.geometryColumn,\n geometryEncodingHint: input.geometryEncodingHint,\n };\n\n const definedInputs = countDefinedInputs(normalized);\n if (definedInputs !== 1) {\n throw new Error(\n `Dataset \"${datasetId}\" must provide exactly one of sqlQuery, arrowTable, or queryResult.`,\n );\n }\n\n if (normalized.queryResult) {\n assertArrowTable(getArrowTableFromQueryResult(normalized.queryResult), datasetId);\n }\n\n return normalized;\n}\n\nexport function resolveArrowTable(\n input: DeckDatasetInput,\n): arrow.Table | undefined {\n return input.arrowTable ?? getArrowTableFromQueryResult(input.queryResult);\n}\n\nexport function normalizeDatasets(\n props: Pick<\n DeckMapProps,\n | 'datasets'\n | 'sqlQuery'\n | 'arrowTable'\n | 'queryResult'\n | 'geometryColumn'\n | 'geometryEncodingHint'\n >,\n): Record<string, DeckDatasetInput> {\n if (props.datasets) {\n const entries = Object.entries(props.datasets).map(([datasetId, input]) => [\n datasetId,\n normalizeDatasetEntry(datasetId, input),\n ]);\n return Object.fromEntries(entries);\n }\n\n const singleInput: DeckDatasetInput = {\n sqlQuery: props.sqlQuery,\n arrowTable: props.arrowTable,\n queryResult: props.queryResult,\n geometryColumn: props.geometryColumn,\n geometryEncodingHint: props.geometryEncodingHint,\n };\n\n const definedInputs = countDefinedInputs(singleInput);\n if (definedInputs === 0) {\n throw new Error(\n 'DeckMap requires either datasets or one of sqlQuery, arrowTable, or queryResult.',\n );\n }\n\n return {\n default: normalizeDatasetEntry('default', singleInput),\n };\n}\n"]}
1
+ {"version":3,"file":"normalizeDatasets.js","sourceRoot":"","sources":["../../src/datasets/normalizeDatasets.ts"],"names":[],"mappings":"AACA,OAAO,EACL,wBAAwB,EACxB,iBAAiB,GAGlB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,YAAY,EAAC,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":["import type * as arrow from 'apache-arrow';\nimport {\n isArrowTableDatasetInput,\n isSqlDatasetInput,\n type DeckDatasetInput,\n type DeckJsonMapProps,\n} from '../types';\nimport {toArrowTable} from './tableAdapter';\n\nfunction normalizeDatasetEntry(\n datasetId: string,\n input: DeckDatasetInput,\n): DeckDatasetInput {\n if (isSqlDatasetInput(input)) {\n return {\n sqlQuery: input.sqlQuery,\n geometryColumn: input.geometryColumn,\n geometryEncodingHint: input.geometryEncodingHint,\n };\n }\n\n if (isArrowTableDatasetInput(input)) {\n return {\n arrowTable: input.arrowTable,\n geometryColumn: input.geometryColumn,\n geometryEncodingHint: input.geometryEncodingHint,\n };\n }\n\n throw new Error(\n `Dataset \"${datasetId}\" has an unrecognized input shape. Expected either { sqlQuery } or { arrowTable }.`,\n );\n}\n\nexport function resolveArrowTable(\n input: DeckDatasetInput,\n): arrow.Table | undefined {\n if (!isArrowTableDatasetInput(input) || input.arrowTable === undefined) {\n return undefined;\n }\n\n return toArrowTable(input.arrowTable);\n}\n\n/**\n * Validate and normalize a raw datasets record into canonical\n * `DeckDatasetInput` entries.\n *\n * @throws {Error} If `datasets` is empty (DeckJsonMap requires at least one entry).\n */\nexport function normalizeDatasets(\n datasets: DeckJsonMapProps['datasets'],\n): Record<string, DeckDatasetInput> {\n const entries = Object.entries(datasets);\n\n if (entries.length === 0) {\n throw new Error('DeckJsonMap requires at least one dataset entry.');\n }\n\n return Object.fromEntries(\n entries.map(([datasetId, input]) => [\n datasetId,\n normalizeDatasetEntry(datasetId, input),\n ]),\n );\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { Table as ArrowTable } from 'apache-arrow';
2
+ export type SupportedTable = ArrowTable;
3
+ /**
4
+ * Normalize supported table runtimes to Apache Arrow for deck preparation.
5
+ *
6
+ * `@sqlrooms/deck` uses Apache Arrow internally because GeoArrow integration
7
+ * and the existing preparation pipeline depend on Arrow's `Table` / `Vector`
8
+ * APIs. The public `arrowTable` dataset input is therefore Apache Arrow.
9
+ */
10
+ export declare function toArrowTable(table: SupportedTable): ArrowTable;
11
+ //# sourceMappingURL=tableAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tableAdapter.d.ts","sourceRoot":"","sources":["../../src/datasets/tableAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,IAAI,UAAU,EAAC,MAAM,cAAc,CAAC;AAEtD,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC;AAExC;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,GAAG,UAAU,CAE9D"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Normalize supported table runtimes to Apache Arrow for deck preparation.
3
+ *
4
+ * `@sqlrooms/deck` uses Apache Arrow internally because GeoArrow integration
5
+ * and the existing preparation pipeline depend on Arrow's `Table` / `Vector`
6
+ * APIs. The public `arrowTable` dataset input is therefore Apache Arrow.
7
+ */
8
+ export function toArrowTable(table) {
9
+ return table;
10
+ }
11
+ //# sourceMappingURL=tableAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tableAdapter.js","sourceRoot":"","sources":["../../src/datasets/tableAdapter.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,KAAqB;IAChD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import type {Table as ArrowTable} from 'apache-arrow';\n\nexport type SupportedTable = ArrowTable;\n\n/**\n * Normalize supported table runtimes to Apache Arrow for deck preparation.\n *\n * `@sqlrooms/deck` uses Apache Arrow internally because GeoArrow integration\n * and the existing preparation pipeline depend on Arrow's `Table` / `Vector`\n * APIs. The public `arrowTable` dataset input is therefore Apache Arrow.\n */\nexport function toArrowTable(table: SupportedTable): ArrowTable {\n return table;\n}\n"]}
@@ -0,0 +1,40 @@
1
+ import type * as arrow from 'apache-arrow';
2
+ import type { GeometryEncodingHint, PreparedDeckDataset } from '../prepare/types';
3
+ /**
4
+ * One cached prepared-dataset entry keyed by resolved dataset identity.
5
+ *
6
+ * The entry tracks both lifecycle state and eviction metadata:
7
+ *
8
+ * - `consumers` records which hook instances currently reference the entry, so
9
+ * live entries are not evicted while a map is still using them
10
+ * - `lastAccessedAt` drives the internal LRU policy for settled entries
11
+ * - the discriminated union stores either the in-flight preparation promise,
12
+ * the prepared dataset, or the terminal error
13
+ */
14
+ export type PreparedDatasetCacheEntry = {
15
+ /** Consumer ids currently subscribed to this cache entry. */
16
+ consumers: Set<string>;
17
+ /** Monotonic access counter used to evict the least-recently-used entry. */
18
+ lastAccessedAt: number;
19
+ } & ({
20
+ status: 'loading';
21
+ promise: Promise<void>;
22
+ } | {
23
+ status: 'ready';
24
+ prepared: PreparedDeckDataset;
25
+ } | {
26
+ status: 'error';
27
+ error: Error;
28
+ });
29
+ export type PreparedDatasetStoreOptions = {
30
+ /** Maximum number of settled prepared entries to retain before LRU eviction. */
31
+ maxEntries?: number;
32
+ /** Injectable preparation function for tests and future specialization. */
33
+ prepareDataset?: (options: {
34
+ datasetId: string;
35
+ geometryColumn?: string;
36
+ geometryEncodingHint?: GeometryEncodingHint;
37
+ table: arrow.Table;
38
+ }) => PreparedDeckDataset;
39
+ };
40
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/datasets/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAC,oBAAoB,EAAE,mBAAmB,EAAC,MAAM,kBAAkB,CAAC;AAEhF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,6DAA6D;IAC7D,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,4EAA4E;IAC5E,cAAc,EAAE,MAAM,CAAC;CACxB,GAAG,CACA;IAAC,MAAM,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;CAAC,GAC3C;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,mBAAmB,CAAA;CAAC,GAChD;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAC,CAClC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,gFAAgF;IAChF,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE;QACzB,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;QAC5C,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC;KACpB,KAAK,mBAAmB,CAAC;CAC3B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/datasets/types.ts"],"names":[],"mappings":"","sourcesContent":["import type * as arrow from 'apache-arrow';\nimport type {GeometryEncodingHint, PreparedDeckDataset} from '../prepare/types';\n\n/**\n * One cached prepared-dataset entry keyed by resolved dataset identity.\n *\n * The entry tracks both lifecycle state and eviction metadata:\n *\n * - `consumers` records which hook instances currently reference the entry, so\n * live entries are not evicted while a map is still using them\n * - `lastAccessedAt` drives the internal LRU policy for settled entries\n * - the discriminated union stores either the in-flight preparation promise,\n * the prepared dataset, or the terminal error\n */\nexport type PreparedDatasetCacheEntry = {\n /** Consumer ids currently subscribed to this cache entry. */\n consumers: Set<string>;\n /** Monotonic access counter used to evict the least-recently-used entry. */\n lastAccessedAt: number;\n} & (\n | {status: 'loading'; promise: Promise<void>}\n | {status: 'ready'; prepared: PreparedDeckDataset}\n | {status: 'error'; error: Error}\n);\n\nexport type PreparedDatasetStoreOptions = {\n /** Maximum number of settled prepared entries to retain before LRU eviction. */\n maxEntries?: number;\n /** Injectable preparation function for tests and future specialization. */\n prepareDataset?: (options: {\n datasetId: string;\n geometryColumn?: string;\n geometryEncodingHint?: GeometryEncodingHint;\n table: arrow.Table;\n }) => PreparedDeckDataset;\n};\n"]}
@@ -0,0 +1,16 @@
1
+ import { type DeckDatasetInput, type PreparedDeckDatasetState } from '../types';
2
+ /**
3
+ * Subscribe a `DeckJsonMap` instance to prepared dataset state.
4
+ *
5
+ * This hook is intentionally a thin React adapter over the internal prepared
6
+ * dataset store. The heavy work lives in the store so prepared geometry can be
7
+ * reused across rerenders and even across multiple map instances, while the
8
+ * hook itself focuses on subscribing React to the store and cleaning up the
9
+ * consumer membership for this map instance.
10
+ *
11
+ * It preserves the current loading behavior for unresolved Arrow inputs, so a
12
+ * caller can pass `{arrowTable: undefined}` and still render the basemap while
13
+ * data is loading.
14
+ */
15
+ export declare function usePreparedDatasetStates(datasets: Record<string, DeckDatasetInput>): Record<string, PreparedDeckDatasetState>;
16
+ //# sourceMappingURL=usePreparedDatasetStates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePreparedDatasetStates.d.ts","sourceRoot":"","sources":["../../src/datasets/usePreparedDatasetStates.ts"],"names":[],"mappings":"AAIA,OAAO,EAAC,KAAK,gBAAgB,EAAE,KAAK,wBAAwB,EAAC,MAAM,UAAU,CAAC;AA0B9E;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GACzC,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CA6B1C"}
@@ -0,0 +1,59 @@
1
+ import { useStoreWithDuckDb } from '@sqlrooms/duckdb';
2
+ import { useEffect, useId, useMemo, useState } from 'react';
3
+ import { useStore } from 'zustand';
4
+ import { shallow } from 'zustand/shallow';
5
+ import { preparedDatasetStore, resolvePreparedDeckDatasetStates, } from './PreparedDatasetStore';
6
+ /**
7
+ * Stabilize a `datasets` record so that a new object reference created on
8
+ * every render (e.g. an inline `{ earthquakes: { arrowTable } }` literal)
9
+ * does not cause downstream effects and memos to re-run when nothing
10
+ * actually changed. Uses Zustand's `shallow` to compare top-level keys
11
+ * and per-entry identity.
12
+ *
13
+ * Implemented via the "adjusting state during rendering" pattern so the
14
+ * React compiler does not flag ref access during render.
15
+ */
16
+ function useStableDatasets(datasets) {
17
+ const [stable, setStable] = useState(datasets);
18
+ if (!shallow(stable, datasets)) {
19
+ setStable(datasets);
20
+ }
21
+ return stable;
22
+ }
23
+ /**
24
+ * Subscribe a `DeckJsonMap` instance to prepared dataset state.
25
+ *
26
+ * This hook is intentionally a thin React adapter over the internal prepared
27
+ * dataset store. The heavy work lives in the store so prepared geometry can be
28
+ * reused across rerenders and even across multiple map instances, while the
29
+ * hook itself focuses on subscribing React to the store and cleaning up the
30
+ * consumer membership for this map instance.
31
+ *
32
+ * It preserves the current loading behavior for unresolved Arrow inputs, so a
33
+ * caller can pass `{arrowTable: undefined}` and still render the basemap while
34
+ * data is loading.
35
+ */
36
+ export function usePreparedDatasetStates(datasets) {
37
+ const stableDatasets = useStableDatasets(datasets);
38
+ const executeSql = useStoreWithDuckDb((state) => state.db.executeSql);
39
+ const connector = useStoreWithDuckDb((state) => state.db.connector);
40
+ const consumerId = useId();
41
+ const entries = useStore(preparedDatasetStore, (state) => state.entries);
42
+ useEffect(() => {
43
+ preparedDatasetStore.getState().syncDatasetsForConsumer({
44
+ consumerId,
45
+ datasets: stableDatasets,
46
+ executeSql,
47
+ sqlSourceIdentity: connector,
48
+ });
49
+ return () => {
50
+ preparedDatasetStore.getState().removeConsumer(consumerId);
51
+ };
52
+ }, [connector, consumerId, stableDatasets, executeSql]);
53
+ return useMemo(() => resolvePreparedDeckDatasetStates({
54
+ datasets: stableDatasets,
55
+ entries,
56
+ sqlSourceIdentity: connector,
57
+ }), [connector, stableDatasets, entries]);
58
+ }
59
+ //# sourceMappingURL=usePreparedDatasetStates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePreparedDatasetStates.js","sour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;YACtD,UAAU;YACV,QAAQ,EAAE,cAAc;YACxB,UAAU;YACV,iBAAiB,EAAE,SAAS;SAC7B,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,oBAAoB,CAAC,QAAQ,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QAC7D,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC;IAExD,OAAO,OAAO,CACZ,GAAG,EAAE,CACH,gCAAgC,CAAC;QAC/B,QAAQ,EAAE,cAAc;QACxB,OAAO;QACP,iBAAiB,EAAE,SAAS;KAC7B,CAAC,EACJ,CAAC,SAAS,EAAE,cAAc,EAAE,OAAO,CAAC,CACrC,CAAC;AACJ,CAAC","sourcesContent":["import {useStoreWithDuckDb} from '@sqlrooms/duckdb';\nimport {useEffect, useId, useMemo, useState} from 'react';\nimport {useStore} from 'zustand';\nimport {shallow} from 'zustand/shallow';\nimport {type DeckDatasetInput, type PreparedDeckDatasetState} from '../types';\nimport {\n preparedDatasetStore,\n resolvePreparedDeckDatasetStates,\n} from './PreparedDatasetStore';\n\n/**\n * Stabilize a `datasets` record so that a new object reference created on\n * every render (e.g. an inline `{ earthquakes: { arrowTable } }` literal)\n * does not cause downstream effects and memos to re-run when nothing\n * actually changed. Uses Zustand's `shallow` to compare top-level keys\n * and per-entry identity.\n *\n * Implemented via the \"adjusting state during rendering\" pattern so the\n * React compiler does not flag ref access during render.\n */\nfunction useStableDatasets(\n datasets: Record<string, DeckDatasetInput>,\n): Record<string, DeckDatasetInput> {\n const [stable, setStable] = useState(datasets);\n if (!shallow(stable, datasets)) {\n setStable(datasets);\n }\n return stable;\n}\n\n/**\n * Subscribe a `DeckJsonMap` instance to prepared dataset state.\n *\n * This hook is intentionally a thin React adapter over the internal prepared\n * dataset store. The heavy work lives in the store so prepared geometry can be\n * reused across rerenders and even across multiple map instances, while the\n * hook itself focuses on subscribing React to the store and cleaning up the\n * consumer membership for this map instance.\n *\n * It preserves the current loading behavior for unresolved Arrow inputs, so a\n * caller can pass `{arrowTable: undefined}` and still render the basemap while\n * data is loading.\n */\nexport function usePreparedDatasetStates(\n datasets: Record<string, DeckDatasetInput>,\n): Record<string, PreparedDeckDatasetState> {\n const stableDatasets = useStableDatasets(datasets);\n const executeSql = useStoreWithDuckDb((state) => state.db.executeSql);\n const connector = useStoreWithDuckDb((state) => state.db.connector);\n const consumerId = useId();\n const entries = useStore(preparedDatasetStore, (state) => state.entries);\n\n useEffect(() => {\n preparedDatasetStore.getState().syncDatasetsForConsumer({\n consumerId,\n datasets: stableDatasets,\n executeSql,\n sqlSourceIdentity: connector,\n });\n\n return () => {\n preparedDatasetStore.getState().removeConsumer(consumerId);\n };\n }, [connector, consumerId, stableDatasets, executeSql]);\n\n return useMemo(\n () =>\n resolvePreparedDeckDatasetStates({\n datasets: stableDatasets,\n entries,\n sqlSourceIdentity: connector,\n }),\n [connector, stableDatasets, entries],\n );\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -2,10 +2,17 @@
2
2
  * {@include ../README.md}
3
3
  * @packageDocumentation
4
4
  */
5
- export { DeckMap } from './DeckMap';
6
- export { ColorScaleLegend } from './ColorScaleLegend';
5
+ export { ColorScaleLegend } from '@sqlrooms/color-scales';
6
+ export { createDeckJsonSpecFromDatasets } from './createDeckJsonSpecFromDatasets';
7
+ export { deckMapDashboardAddPanelAction, deckMapDashboardPanelRenderer, } from './dashboard';
8
+ export { asDeckJsonMapConfig, createDeckMapDashboardDatasetQuery, createDeckMapDashboardDatasets, createDeckMapDashboardPanelConfig, DECK_MAP_DASHBOARD_PANEL_TYPE, resolveDeckMapDashboardDatasetSource, } from './dashboardConfig';
9
+ export type { DeckMapDashboardFitToDataConfig, CreateDeckMapDashboardPanelConfigOptions, DeckMapDashboardDatasetClientState, DeckMapDashboardDatasetConfig, DeckMapDashboardInteractionConfig, DeckMapDashboardPanelConfig, } from './dashboardConfig';
10
+ export { DeckJsonMap } from './DeckJsonMap';
11
+ export { ColorScaleFunction, GeometryEncodingHint as DeckGeometryEncodingHint, DeckJsonMapLayerSpec, DeckJsonMapSpec, LayerBindingConfig, LayerBindingProps, } from './DeckJsonMapSpec';
7
12
  export { createDeckJsonConfiguration } from './json/createDeckJsonConfiguration';
8
13
  export { prepareDeckDataset } from './prepare/prepareDeckDataset';
9
- export type { DeckDatasetInput, DeckMapProps, DeckQueryResultLike, LayerColorLegendConfig, LayerColorScale, LayerColorScaleProp, LayerExtensionProps, PreparedDeckDatasetState, } from './types';
14
+ export type { ColorLegendConfig, ColorScaleConfig } from '@sqlrooms/color-scales';
10
15
  export type { GeometryEncodingHint, PreparedDeckDataset, PreparedGeoArrowLayerData, ResolvedGeometryColumn, ResolvedGeometryEncoding, } from './prepare/types';
16
+ export { isArrowTableDatasetInput, isSqlDatasetInput } from './types';
17
+ export type { CreateDeckJsonSpecFromDatasetsOptions, DeckArrowTableDatasetInput, DeckAutoLayerType, DeckDatasetInput, DeckJsonMapProps, DeckJsonSpecDatasetHint, DeckSqlDatasetInput, DeckTable, PreparedDeckDatasetState, } from './types';
11
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,2BAA2B,EAAC,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAC,kBAAkB,EAAC,MAAM,8BAA8B,CAAC;AAEhE,YAAY,EACV,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,GACzB,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,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,GACzB,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -2,8 +2,13 @@
2
2
  * {@include ../README.md}
3
3
  * @packageDocumentation
4
4
  */
5
- export { DeckMap } from './DeckMap';
6
- export { ColorScaleLegend } from './ColorScaleLegend';
5
+ export { ColorScaleLegend } from '@sqlrooms/color-scales';
6
+ export { createDeckJsonSpecFromDatasets } from './createDeckJsonSpecFromDatasets';
7
+ export { deckMapDashboardAddPanelAction, deckMapDashboardPanelRenderer, } from './dashboard';
8
+ export { asDeckJsonMapConfig, createDeckMapDashboardDatasetQuery, createDeckMapDashboardDatasets, createDeckMapDashboardPanelConfig, DECK_MAP_DASHBOARD_PANEL_TYPE, resolveDeckMapDashboardDatasetSource, } from './dashboardConfig';
9
+ export { DeckJsonMap } from './DeckJsonMap';
10
+ export { ColorScaleFunction, GeometryEncodingHint as DeckGeometryEncodingHint, DeckJsonMapLayerSpec, DeckJsonMapSpec, LayerBindingConfig, LayerBindingProps, } from './DeckJsonMapSpec';
7
11
  export { createDeckJsonConfiguration } from './json/createDeckJsonConfiguration';
8
12
  export { prepareDeckDataset } from './prepare/prepareDeckDataset';
13
+ export { isArrowTableDatasetInput, isSqlDatasetInput } from './types';
9
14
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAClC,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAC,2BAA2B,EAAC,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAC,kBAAkB,EAAC,MAAM,8BAA8B,CAAC","sourcesContent":["/**\n * {@include ../README.md}\n * @packageDocumentation\n */\n\nexport {DeckMap} from './DeckMap';\nexport {ColorScaleLegend} from './ColorScaleLegend';\nexport {createDeckJsonConfiguration} from './json/createDeckJsonConfiguration';\nexport {prepareDeckDataset} from './prepare/prepareDeckDataset';\n\nexport type {\n DeckDatasetInput,\n DeckMapProps,\n DeckQueryResultLike,\n LayerColorLegendConfig,\n LayerColorScale,\n LayerColorScaleProp,\n LayerExtensionProps,\n PreparedDeckDatasetState,\n} from './types';\nexport type {\n GeometryEncodingHint,\n PreparedDeckDataset,\n PreparedGeoArrowLayerData,\n ResolvedGeometryColumn,\n ResolvedGeometryEncoding,\n} from './prepare/types';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAC,8BAA8B,EAAC,MAAM,kCAAkC,CAAC;AAChF,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,GAC9B,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,kCAAkC,EAClC,8BAA8B,EAC9B,iCAAiC,EACjC,6BAA6B,EAC7B,oCAAoC,GACrC,MAAM,mBAAmB,CAAC;AAS3B,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EACL,kBAAkB,EAClB,oBAAoB,IAAI,wBAAwB,EAChD,oBAAoB,EACpB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,2BAA2B,EAAC,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAC,kBAAkB,EAAC,MAAM,8BAA8B,CAAC;AAUhE,OAAO,EAAC,wBAAwB,EAAE,iBAAiB,EAAC,MAAM,SAAS,CAAC","sourcesContent":["/**\n * {@include ../README.md}\n * @packageDocumentation\n */\n\nexport {ColorScaleLegend} from '@sqlrooms/color-scales';\nexport {createDeckJsonSpecFromDatasets} from './createDeckJsonSpecFromDatasets';\nexport {\n deckMapDashboardAddPanelAction,\n deckMapDashboardPanelRenderer,\n} from './dashboard';\nexport {\n asDeckJsonMapConfig,\n createDeckMapDashboardDatasetQuery,\n createDeckMapDashboardDatasets,\n createDeckMapDashboardPanelConfig,\n DECK_MAP_DASHBOARD_PANEL_TYPE,\n resolveDeckMapDashboardDatasetSource,\n} from './dashboardConfig';\nexport type {\n DeckMapDashboardFitToDataConfig,\n CreateDeckMapDashboardPanelConfigOptions,\n DeckMapDashboardDatasetClientState,\n DeckMapDashboardDatasetConfig,\n DeckMapDashboardInteractionConfig,\n DeckMapDashboardPanelConfig,\n} from './dashboardConfig';\nexport {DeckJsonMap} from './DeckJsonMap';\nexport {\n ColorScaleFunction,\n GeometryEncodingHint as DeckGeometryEncodingHint,\n DeckJsonMapLayerSpec,\n DeckJsonMapSpec,\n LayerBindingConfig,\n LayerBindingProps,\n} from './DeckJsonMapSpec';\nexport {createDeckJsonConfiguration} from './json/createDeckJsonConfiguration';\nexport {prepareDeckDataset} from './prepare/prepareDeckDataset';\n\nexport type {ColorLegendConfig, ColorScaleConfig} from '@sqlrooms/color-scales';\nexport type {\n GeometryEncodingHint,\n PreparedDeckDataset,\n PreparedGeoArrowLayerData,\n ResolvedGeometryColumn,\n ResolvedGeometryEncoding,\n} from './prepare/types';\nexport {isArrowTableDatasetInput, isSqlDatasetInput} from './types';\nexport type {\n CreateDeckJsonSpecFromDatasetsOptions,\n DeckArrowTableDatasetInput,\n DeckAutoLayerType,\n DeckDatasetInput,\n DeckJsonMapProps,\n DeckJsonSpecDatasetHint,\n DeckSqlDatasetInput,\n DeckTable,\n PreparedDeckDatasetState,\n} from './types';\n"]}
@@ -0,0 +1,14 @@
1
+ import type { ColorScaleConfig } from '@sqlrooms/color-scales';
2
+ declare const SQLROOMS_COLOR_SCALE_MARKER: unique symbol;
3
+ export type ColorScaleMarker = {
4
+ colorScale: ColorScaleConfig;
5
+ [SQLROOMS_COLOR_SCALE_MARKER]: true;
6
+ };
7
+ export declare function createColorScaleMarker(value: ColorScaleConfig): ColorScaleMarker;
8
+ export declare function isColorScaleMarker(value: unknown): value is ColorScaleMarker;
9
+ export declare function getColorScale(props: Record<string, unknown>): {
10
+ propName: 'getFillColor' | 'getLineColor';
11
+ colorScale: ColorScaleConfig;
12
+ } | undefined;
13
+ export {};
14
+ //# sourceMappingURL=colorScaleFunction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorScaleFunction.d.ts","sourceRoot":"","sources":["../../src/json/colorScaleFunction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,wBAAwB,CAAC;AAG7D,QAAA,MAAM,2BAA2B,eAEhC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,gBAAgB,CAAC;IAC7B,CAAC,2BAA2B,CAAC,EAAE,IAAI,CAAC;CACrC,CAAC;AAEF,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,gBAAgB,GACtB,gBAAgB,CAKlB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAU5E;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAE5B;IAAC,QAAQ,EAAE,cAAc,GAAG,cAAc,CAAC;IAAC,UAAU,EAAE,gBAAgB,CAAA;CAAC,GACzE,SAAS,CAkBZ"}
@@ -0,0 +1,34 @@
1
+ import { isColorScaleFunction } from './layerConfig';
2
+ const SQLROOMS_COLOR_SCALE_MARKER = Symbol.for('@sqlrooms/deck/sqlrooms-color-scale');
3
+ export function createColorScaleMarker(value) {
4
+ return {
5
+ colorScale: value,
6
+ [SQLROOMS_COLOR_SCALE_MARKER]: true,
7
+ };
8
+ }
9
+ export function isColorScaleMarker(value) {
10
+ return Boolean(value &&
11
+ typeof value === 'object' &&
12
+ value[SQLROOMS_COLOR_SCALE_MARKER] &&
13
+ typeof value.colorScale === 'object' &&
14
+ value.colorScale != null);
15
+ }
16
+ export function getColorScale(props) {
17
+ for (const propName of ['getFillColor', 'getLineColor']) {
18
+ const value = props[propName];
19
+ if (isColorScaleMarker(value)) {
20
+ return {
21
+ propName,
22
+ colorScale: value.colorScale,
23
+ };
24
+ }
25
+ if (isColorScaleFunction(value)) {
26
+ return {
27
+ propName,
28
+ colorScale: value,
29
+ };
30
+ }
31
+ }
32
+ return undefined;
33
+ }
34
+ //# sourceMappingURL=colorScaleFunction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorScaleFunction.js","sourceRoot":"","sources":["../../src/json/colorScaleFunction.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,oBAAoB,EAAC,MAAM,eAAe,CAAC;AAEnD,MAAM,2BAA2B,GAAG,MAAM,CAAC,GAAG,CAC5C,qCAAqC,CACtC,CAAC;AAOF,MAAM,UAAU,sBAAsB,CACpC,KAAuB;IAEvB,OAAO;QACL,UAAU,EAAE,KAAK;QACjB,CAAC,2BAA2B,CAAC,EAAE,IAAI;KACpC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,OAAO,CACZ,KAAK;QACL,OAAO,KAAK,KAAK,QAAQ;QACxB,KAAmD,CAClD,2BAA2B,CAC5B;QACD,OAAQ,KAAgC,CAAC,UAAU,KAAK,QAAQ;QAC/D,KAAgC,CAAC,UAAU,IAAI,IAAI,CACrD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,KAA8B;IAI9B,KAAK,MAAM,QAAQ,IAAI,CAAC,cAAc,EAAE,cAAc,CAAU,EAAE,CAAC;QACjE,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC9B,IAAI,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO;gBACL,QAAQ;gBACR,UAAU,EAAE,KAAK,CAAC,UAAU;aAC7B,CAAC;QACJ,CAAC;QACD,IAAI,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,OAAO;gBACL,QAAQ;gBACR,UAAU,EAAE,KAAK;aAClB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type {ColorScaleConfig} from '@sqlrooms/color-scales';\nimport {isColorScaleFunction} from './layerConfig';\n\nconst SQLROOMS_COLOR_SCALE_MARKER = Symbol.for(\n '@sqlrooms/deck/sqlrooms-color-scale',\n);\n\nexport type ColorScaleMarker = {\n colorScale: ColorScaleConfig;\n [SQLROOMS_COLOR_SCALE_MARKER]: true;\n};\n\nexport function createColorScaleMarker(\n value: ColorScaleConfig,\n): ColorScaleMarker {\n return {\n colorScale: value,\n [SQLROOMS_COLOR_SCALE_MARKER]: true,\n };\n}\n\nexport function isColorScaleMarker(value: unknown): value is ColorScaleMarker {\n return Boolean(\n value &&\n typeof value === 'object' &&\n (value as {[SQLROOMS_COLOR_SCALE_MARKER]?: boolean})[\n SQLROOMS_COLOR_SCALE_MARKER\n ] &&\n typeof (value as {colorScale?: unknown}).colorScale === 'object' &&\n (value as {colorScale?: unknown}).colorScale != null,\n );\n}\n\nexport function getColorScale(\n props: Record<string, unknown>,\n):\n | {propName: 'getFillColor' | 'getLineColor'; colorScale: ColorScaleConfig}\n | undefined {\n for (const propName of ['getFillColor', 'getLineColor'] as const) {\n const value = props[propName];\n if (isColorScaleMarker(value)) {\n return {\n propName,\n colorScale: value.colorScale,\n };\n }\n if (isColorScaleFunction(value)) {\n return {\n propName,\n colorScale: value,\n };\n }\n }\n\n return undefined;\n}\n"]}
@@ -1,35 +1,12 @@
1
+ import { type ColorScaleConfig, type ResolvedColorLegend } from '@sqlrooms/color-scales';
1
2
  import type * as arrow from 'apache-arrow';
2
- import type { LayerColorScale } from '../types';
3
- export type ResolvedColorLegend = {
4
- type: 'continuous';
5
- title: string;
6
- gradient: string;
7
- ticks: Array<{
8
- label: string;
9
- offset: number;
10
- }>;
11
- } | {
12
- type: 'stepped';
13
- title: string;
14
- items: Array<{
15
- label: string;
16
- color: [number, number, number, number];
17
- }>;
18
- } | {
19
- type: 'categorical';
20
- title: string;
21
- items: Array<{
22
- label: string;
23
- color: [number, number, number, number];
24
- }>;
25
- };
26
3
  export declare function compileColorScale(options: {
27
4
  table: arrow.Table;
28
- colorScale: LayerColorScale;
29
- }): (value: unknown) => [number, number, number, number];
5
+ colorScale: ColorScaleConfig;
6
+ }): (value: unknown) => import("@sqlrooms/color-scales").ResolvedRGBA;
30
7
  export declare function buildColorScaleLegend(options: {
31
8
  table: arrow.Table;
32
- colorScale: LayerColorScale;
9
+ colorScale: ColorScaleConfig;
33
10
  title?: string;
34
11
  }): ResolvedColorLegend | null;
35
12
  //# sourceMappingURL=compileColorScale.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compileColorScale.d.ts","sourceRoot":"","sources":["../../src/json/compileColorScale.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAW3C,OAAO,KAAK,EAKV,eAAe,EAChB,MAAM,UAAU,CAAC;AA+GlB,MAAM,MAAM,mBAAmB,GAC3B;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,CAAC,CAAC;CAC/C,GACD;IACE,IAAI,EAAE,SAAS,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;KAAC,CAAC,CAAC;CACxE,GACD;IACE,IAAI,EAAE,aAAa,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,CAAC,MAAM,E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