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

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 +35 -29
  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
@@ -1,7 +1,58 @@
1
+ const GEOARROW_COMPILED_ACCESSOR = Symbol.for('@sqlrooms/deck/compiled-geoarrow-accessor');
1
2
  function isValidIdentifier(name) {
2
3
  return /^[A-Za-z_$][\w$]*$/.test(name);
3
4
  }
4
5
  const RESERVED_IDENTIFIERS = new Set([
6
+ // JS keywords & future reserved words
7
+ 'abstract',
8
+ 'arguments',
9
+ 'async',
10
+ 'await',
11
+ 'break',
12
+ 'case',
13
+ 'catch',
14
+ 'class',
15
+ 'const',
16
+ 'continue',
17
+ 'debugger',
18
+ 'default',
19
+ 'delete',
20
+ 'do',
21
+ 'else',
22
+ 'enum',
23
+ 'eval',
24
+ 'export',
25
+ 'extends',
26
+ 'finally',
27
+ 'for',
28
+ 'function',
29
+ 'if',
30
+ 'implements',
31
+ 'import',
32
+ 'in',
33
+ 'instanceof',
34
+ 'interface',
35
+ 'let',
36
+ 'new',
37
+ 'of',
38
+ 'package',
39
+ 'private',
40
+ 'protected',
41
+ 'public',
42
+ 'return',
43
+ 'static',
44
+ 'super',
45
+ 'switch',
46
+ 'this',
47
+ 'throw',
48
+ 'try',
49
+ 'typeof',
50
+ 'var',
51
+ 'void',
52
+ 'while',
53
+ 'with',
54
+ 'yield',
55
+ // Literals & globals used in expressions
5
56
  'true',
6
57
  'false',
7
58
  'null',
@@ -15,6 +66,7 @@ const RESERVED_IDENTIFIERS = new Set([
15
66
  'Array',
16
67
  'Object',
17
68
  'Date',
69
+ // Accessor runtime parameter
18
70
  'target',
19
71
  ]);
20
72
  function unique(values) {
@@ -54,7 +106,12 @@ function copyArrayLikeIntoTarget(result) {
54
106
  export function compileGeoArrowAccessor(expression, table) {
55
107
  const trimmedExpression = expression.trim();
56
108
  if (trimmedExpression === '-') {
57
- return ({ index, data, }) => data.data.get(index);
109
+ const accessor = ({ index, data, }) => data.data.get(index);
110
+ Object.defineProperty(accessor, GEOARROW_COMPILED_ACCESSOR, {
111
+ value: true,
112
+ enumerable: false,
113
+ });
114
+ return accessor;
58
115
  }
59
116
  const bindings = resolveColumnBindings(trimmedExpression, table);
60
117
  const evaluator = new Function(...bindings.map((binding) => binding.identifier), 'target', `return (${trimmedExpression});`);
@@ -62,7 +119,7 @@ export function compileGeoArrowAccessor(expression, table) {
62
119
  // GeoArrow callbacks are batch-oriented rather than deck.gl/json row-oriented. If
63
120
  // the next version aligns with deck.gl/json accessors, remove this compiler and
64
121
  // let the standard JSON conversion pipeline handle expressions.
65
- return ({ index, data, target, }) => {
122
+ const accessor = ({ index, data, target, }) => {
66
123
  const batch = data.data;
67
124
  const args = bindings.map((binding) => binding.columnName
68
125
  ? batch.getChild(binding.columnName)?.get(index)
@@ -70,5 +127,14 @@ export function compileGeoArrowAccessor(expression, table) {
70
127
  const result = evaluator(...args, target);
71
128
  return copyArrayLikeIntoTarget(result);
72
129
  };
130
+ Object.defineProperty(accessor, GEOARROW_COMPILED_ACCESSOR, {
131
+ value: true,
132
+ enumerable: false,
133
+ });
134
+ return accessor;
135
+ }
136
+ export function isCompiledGeoArrowAccessor(value) {
137
+ return (typeof value === 'function' &&
138
+ Boolean(value[GEOARROW_COMPILED_ACCESSOR]));
73
139
  }
74
140
  //# sourceMappingURL=compileGeoArrowAccessor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compileGeoArrowAccessor.js","sourceRoot":"","sources":["../../src/json/compileGeoArrowAccessor.ts"],"names":[],"mappings":"AAEA,SAAS,iBAAiB,CAAC,IAAY;IACrC,OAAO,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,MAAM;IACN,OAAO;IACP,MAAM;IACN,WAAW;IACX,KAAK;IACL,UAAU;IACV,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,OAAO;IACP,QAAQ;IACR,MAAM;IACN,QAAQ;CACT,CAAC,CAAC;AAEH,SAAS,MAAM,CAAI,MAAW;IAC5B,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,qBAAqB,CAAC,UAAkB,EAAE,KAAkB;IACnE,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM;SACzC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;SAC1B,MAAM,CAAC,iBAAiB,CAAC,CAAC;IAE7B,MAAM,WAAW,GAAG,MAAM,CACxB,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAC;SACrD,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACxB,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,oBAAoB,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CACjE,CAAC;IAEF,OAAO,WAAW,CAAC,GAAG,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K,CAAC,CAAC;IAEjE,MAAM,SAAS,GAAG,IAAI,QAAQ,CAC5B,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,EAChD,QAAQ,EACR,WAAW,iBAAiB,IAAI,CACE,CAAC;IAErC,+EAA+E;IAC/E,kFAAkF;IAClF,gFAAgF;IAChF,gEAAgE;IAChE,OAAO,CAAC,EACN,KAAK,EACL,IAAI,EACJ,MAAM,GAKP,EAAE,EAAE;QACH,MAAM,KAAK,GAAG,IAAI,CAAC,IAAuC,CAAC;QAC3D,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CACpC,OAAO,CAAC,UAAU;YAChB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC;YAChD,CAAC,CAAC,SAAS,CACd,CAAC;QACF,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC;QAC1C,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type * as arrow from 'apache-arrow';\n\nfunction isValidIdentifier(name: string) {\n return /^[A-Za-z_$][\\w$]*$/.test(name);\n}\n\nconst RESERVED_IDENTIFIERS = new Set([\n 'true',\n 'false',\n 'null',\n 'undefined',\n 'NaN',\n 'Infinity',\n 'Math',\n 'Number',\n 'String',\n 'Boolean',\n 'Array',\n 'Object',\n 'Date',\n 'target',\n]);\n\nfunction unique<T>(values: T[]) {\n return [...new Set(values)];\n}\n\nfunction resolveColumnBindings(expression: string, table: arrow.Table) {\n const schemaFieldNames = table.schema.fields\n .map((field) => field.name)\n .filter(isValidIdentifier);\n\n const identifiers = unique(\n Array.from(expression.matchAll(/\\b[A-Za-z_$][\\w$]*\\b/g))\n .map((match) => match[0])\n .filter((identifier) => !RESERVED_IDENTIFIERS.has(identifier)),\n );\n\n return identifiers.map((identifier) => {\n const exactMatch = schemaFieldNames.find(\n (fieldName) => fieldName === identifier,\n );\n if (exactMatch) {\n return {identifier, columnName: exactMatch};\n }\n\n const caseInsensitiveMatches = schemaFieldNames.filter(\n (fieldName) => fieldName.toLowerCase() === identifier.toLowerCase(),\n );\n\n return {\n identifier,\n columnName:\n caseInsensitiveMatches.length === 1\n ? caseInsensitiveMatches[0]!\n : undefined,\n };\n });\n}\n\nfunction copyArrayLikeIntoTarget(result: unknown) {\n if (!Array.isArray(result) && !ArrayBuffer.isView(result)) {\n return result;\n }\n\n // TODO(geoarrow-upgrade): Keep returning plain JS arrays for 0.3.x. Reusing deck's\n // typed `target` buffer here caused `ScatterplotLayer` binary attribute errors\n // (`Float64Array`) when GeoArrow delegated to deck sublayers. If the next GeoArrow\n // runtime changes the callback contract, re-evaluate whether target reuse is safe.\n return Array.from(result as ArrayLike<number>);\n}\n\nexport function compileGeoArrowAccessor(\n expression: string,\n table: arrow.Table,\n) {\n const trimmedExpression = expression.trim();\n if (trimmedExpression === '-') {\n return ({\n index,\n data,\n }: {\n index: number;\n data: {data: {get: (i: number) => unknown}};\n }) => data.data.get(index);\n }\n\n const bindings = resolveColumnBindings(trimmedExpression, table);\n\n const evaluator = new Function(\n ...bindings.map((binding) => binding.identifier),\n 'target',\n `return (${trimmedExpression});`,\n ) as (...args: unknown[]) => unknown;\n\n // TODO(geoarrow-upgrade): This custom evaluator exists because published 0.3.x\n // GeoArrow callbacks are batch-oriented rather than deck.gl/json row-oriented. If\n // the next version aligns with deck.gl/json accessors, remove this compiler and\n // let the standard JSON conversion pipeline handle expressions.\n return ({\n index,\n data,\n target,\n }: {\n index: number;\n data: {data: {get: (i: number) => Record<string, unknown>}};\n target: number[];\n }) => {\n const batch = data.data as arrow.Table | arrow.RecordBatch;\n const args = bindings.map((binding) =>\n binding.columnName\n ? batch.getChild(binding.columnName)?.get(index)\n : undefined,\n );\n const result = evaluator(...args, target);\n return copyArrayLikeIntoTarget(result);\n };\n}\n"]}
1
+ {"version":3,"file":"compileGeoArrowAccessor.js","sourceRoot":"","sources":["../../src/json/compileGeoArrowAccessor.ts"],"names":[],"mappings":"AAEA,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAC3C,2CAA2C,CAC5C,CAAC;AAEF,SAAS,iBAAiB,CAAC,IAAY;IACrC,OAAO,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,sCAAsC;IACtC,UAAU;IACV,WAAW;IACX,OAAO;IACP,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,UAAU;IACV,UAAU;IACV,SAAS;IACT,QAAQ;IACR,IAAI;IACJ,MAAM;IACN,MAAM;IACN,MAAM;IACN,QAAQ;IACR,SAAS;IACT,SAAS;IACT,KAAK;IACL,UAAU;IACV,IAAI;IACJ,YAAY;IACZ,QAAQ;IACR,IAAI;IACJ,YAAY;IACZ,WAAW;IACX,KAAK;IACL,KAAK;IACL,IAAI;IACJ,SAAS;IACT,SAAS;IACT,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,MAAM;IACN,OAAO;IACP,KAAK;IACL,QAAQ;IACR,KAAK;IACL,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,yCAAyC;IACzC,MAAM;IACN,OAAO;IACP,MAAM;IACN,WAAW;IACX,KAAK;IACL,UAAU;IACV,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,OAAO;IACP,QAAQ;IACR,MAAM;IACN,6BAA6B;IAC7B,QAAQ;CACT,CAAC,CAAC;AAEH,SAAS,MAAM,CAAI,MAAW;IAC5B,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAC9B,CAAC;AAED,SAAS,qBAA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,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC;YAChD,CAAC,CAAC,SAAS,CACd,CAAC;QACF,MAAM,MAAM,GAAG,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC;QAC1C,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC,CAAC;IAEF,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,0BAA0B,EAAE;QAC1D,KAAK,EAAE,IAAI;QACX,UAAU,EAAE,KAAK;KAClB,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,0BAA0B,CACxC,KAAc;IAMd,OAAO,CACL,OAAO,KAAK,KAAK,UAAU;QAC3B,OAAO,CACJ,KAAkD,CACjD,0BAA0B,CAC3B,CACF,CACF,CAAC;AACJ,CAAC","sourcesContent":["import type * as arrow from 'apache-arrow';\n\nconst GEOARROW_COMPILED_ACCESSOR = Symbol.for(\n '@sqlrooms/deck/compiled-geoarrow-accessor',\n);\n\nfunction isValidIdentifier(name: string) {\n return /^[A-Za-z_$][\\w$]*$/.test(name);\n}\n\nconst RESERVED_IDENTIFIERS = new Set([\n // JS keywords & future reserved words\n 'abstract',\n 'arguments',\n 'async',\n 'await',\n 'break',\n 'case',\n 'catch',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'else',\n 'enum',\n 'eval',\n 'export',\n 'extends',\n 'finally',\n 'for',\n 'function',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'interface',\n 'let',\n 'new',\n 'of',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'static',\n 'super',\n 'switch',\n 'this',\n 'throw',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'while',\n 'with',\n 'yield',\n // Literals & globals used in expressions\n 'true',\n 'false',\n 'null',\n 'undefined',\n 'NaN',\n 'Infinity',\n 'Math',\n 'Number',\n 'String',\n 'Boolean',\n 'Array',\n 'Object',\n 'Date',\n // Accessor runtime parameter\n 'target',\n]);\n\nfunction unique<T>(values: T[]) {\n return [...new Set(values)];\n}\n\nfunction resolveColumnBindings(expression: string, table: arrow.Table) {\n const schemaFieldNames = table.schema.fields\n .map((field) => field.name)\n .filter(isValidIdentifier);\n\n const identifiers = unique(\n Array.from(expression.matchAll(/\\b[A-Za-z_$][\\w$]*\\b/g))\n .map((match) => match[0])\n .filter((identifier) => !RESERVED_IDENTIFIERS.has(identifier)),\n );\n\n return identifiers.map((identifier) => {\n const exactMatch = schemaFieldNames.find(\n (fieldName) => fieldName === identifier,\n );\n if (exactMatch) {\n return {identifier, columnName: exactMatch};\n }\n\n const caseInsensitiveMatches = schemaFieldNames.filter(\n (fieldName) => fieldName.toLowerCase() === identifier.toLowerCase(),\n );\n\n return {\n identifier,\n columnName:\n caseInsensitiveMatches.length === 1\n ? caseInsensitiveMatches[0]!\n : undefined,\n };\n });\n}\n\nfunction copyArrayLikeIntoTarget(result: unknown) {\n if (!Array.isArray(result) && !ArrayBuffer.isView(result)) {\n return result;\n }\n\n // TODO(geoarrow-upgrade): Keep returning plain JS arrays for 0.3.x. Reusing deck's\n // typed `target` buffer here caused `ScatterplotLayer` binary attribute errors\n // (`Float64Array`) when GeoArrow delegated to deck sublayers. If the next GeoArrow\n // runtime changes the callback contract, re-evaluate whether target reuse is safe.\n return Array.from(result as ArrayLike<number>);\n}\n\nexport function compileGeoArrowAccessor(\n expression: string,\n table: arrow.Table,\n) {\n const trimmedExpression = expression.trim();\n if (trimmedExpression === '-') {\n const accessor = ({\n index,\n data,\n }: {\n index: number;\n data: {data: {get: (i: number) => unknown}};\n }) => data.data.get(index);\n Object.defineProperty(accessor, GEOARROW_COMPILED_ACCESSOR, {\n value: true,\n enumerable: false,\n });\n return accessor;\n }\n\n const bindings = resolveColumnBindings(trimmedExpression, table);\n\n const evaluator = new Function(\n ...bindings.map((binding) => binding.identifier),\n 'target',\n `return (${trimmedExpression});`,\n ) as (...args: unknown[]) => unknown;\n\n // TODO(geoarrow-upgrade): This custom evaluator exists because published 0.3.x\n // GeoArrow callbacks are batch-oriented rather than deck.gl/json row-oriented. If\n // the next version aligns with deck.gl/json accessors, remove this compiler and\n // let the standard JSON conversion pipeline handle expressions.\n const accessor = ({\n index,\n data,\n target,\n }: {\n index: number;\n data: {data: {get: (i: number) => Record<string, unknown>}};\n target: number[];\n }) => {\n const batch = data.data as arrow.Table | arrow.RecordBatch;\n const args = bindings.map((binding) =>\n binding.columnName\n ? batch.getChild(binding.columnName)?.get(index)\n : undefined,\n );\n const result = evaluator(...args, target);\n return copyArrayLikeIntoTarget(result);\n };\n\n Object.defineProperty(accessor, GEOARROW_COMPILED_ACCESSOR, {\n value: true,\n enumerable: false,\n });\n\n return accessor;\n}\n\nexport function isCompiledGeoArrowAccessor(\n value: unknown,\n): value is (info: {\n index: number;\n data: {data: unknown};\n target: number[];\n}) => unknown {\n return (\n typeof value === 'function' &&\n Boolean(\n (value as {[GEOARROW_COMPILED_ACCESSOR]?: boolean})[\n GEOARROW_COMPILED_ACCESSOR\n ],\n )\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"createDeckJsonConfiguration.d.ts","sourceRoot":"","sources":["../../src/json/createDeckJsonConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAsB,wBAAwB,EAAC,MAAM,UAAU,CAAC;AAqB5E,KAAK,kCAAkC,GAAG;IACxC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IACxD,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAgCF,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,kCAAkC,qBAqH5C"}
1
+ {"version":3,"file":"createDeckJsonConfiguration.d.ts","sourceRoot":"","sources":["../../src/json/createDeckJsonConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAGhD,OAAO,KAAK,EAAoB,wBAAwB,EAAC,MAAM,UAAU,CAAC;AAkB1E,KAAK,kCAAkC,GAAG;IACxC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;IACxD,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAsHF,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,kCAAkC,qBA2G5C"}
@@ -1,44 +1,97 @@
1
1
  import { JSONConfiguration } from '@deck.gl/json';
2
- import { DEFAULT_DECK_JSON_CLASSES, DEFAULT_DECK_JSON_CONSTANTS, DEFAULT_DECK_JSON_ENUMERATIONS, } from './defaultClasses';
3
- import { getLayerCompatibility, isSupportedGeoArrowLayerType, } from './layerCompatibility';
4
- import { isManagedLayer, resolveColorScale, resolveDatasetId, resolveGeometryColumn, stripLayerExtensionProps, } from './layerConfig';
5
- import { rewriteGeoArrowAccessors } from './rewriteGeoArrowAccessors';
6
2
  import { wkbGeometryDecoder } from '../prepare/wkbDecoder';
3
+ import { createColorScaleMarker, getColorScale } from './colorScaleFunction';
7
4
  import { compileColorScale } from './compileColorScale';
5
+ import { DEFAULT_DECK_JSON_CLASSES, DEFAULT_DECK_JSON_CONSTANTS, DEFAULT_DECK_JSON_ENUMERATIONS, } from './defaultClasses';
6
+ import { getLayerCompatibility } from './layerCompatibility';
7
+ import { isManagedLayer, resolveConfiguredColumn, resolveDatasetId, resolveGeometryColumn, stripLayerExtensionProps, } from './layerConfig';
8
+ import { rewriteGeoArrowAccessors } from './rewriteGeoArrowAccessors';
8
9
  function getLayerName(Class) {
9
10
  const maybeClass = Class;
10
11
  return maybeClass.layerName ?? maybeClass.name ?? 'UnknownLayer';
11
12
  }
12
13
  function applyColorScale(options) {
13
- const { props, layerProps, table } = options;
14
- const colorScale = resolveColorScale(layerProps);
15
- if (!colorScale) {
16
- return props;
17
- }
18
- const targetProp = colorScale.prop ?? 'getFillColor';
19
- if (props[targetProp] !== undefined) {
14
+ const { props, table } = options;
15
+ const resolved = getColorScale(props);
16
+ if (!resolved) {
20
17
  return props;
21
18
  }
19
+ const { propName, colorScale } = resolved;
20
+ const updateTriggers = props.updateTriggers &&
21
+ typeof props.updateTriggers === 'object' &&
22
+ !Array.isArray(props.updateTriggers)
23
+ ? props.updateTriggers
24
+ : {};
22
25
  return {
23
26
  ...props,
24
- [targetProp]: compileColorScale({
27
+ [propName]: compileColorScale({
25
28
  table,
26
29
  colorScale,
27
30
  }),
31
+ updateTriggers: {
32
+ ...updateTriggers,
33
+ [propName]: JSON.stringify(colorScale),
34
+ },
28
35
  };
29
36
  }
37
+ function resolveGeoArrowBindings(options) {
38
+ const { layerName, compatibility, layerProps, prepared, props } = options;
39
+ let table = prepared.table;
40
+ const boundProps = {};
41
+ for (const binding of compatibility.bindings) {
42
+ if (props[binding.prop] !== undefined) {
43
+ continue;
44
+ }
45
+ if (binding.kind === 'geometry') {
46
+ const columnName = resolveConfiguredColumn(layerProps, binding.configKey);
47
+ if (binding.required && !columnName) {
48
+ throw new Error(`Layer "${layerName}" requires _sqlroomsBinding.${binding.configKey}.`);
49
+ }
50
+ const resolvedGeometry = prepared.resolveGeometry(columnName);
51
+ if (!resolvedGeometry.nativeGeoArrow) {
52
+ if (!compatibility.allowGeoArrowPromotion ||
53
+ !wkbGeometryDecoder.supportsGeoArrowPromotion(layerName, resolvedGeometry.encoding, prepared.table, resolvedGeometry.columnName)) {
54
+ throw new Error(`Layer "${layerName}" cannot render geometry encoding "${resolvedGeometry.encoding}" for dataset "${prepared.datasetId}".`);
55
+ }
56
+ }
57
+ const layerData = prepared.getGeoArrowLayerData(columnName);
58
+ if (table !== prepared.table && table !== layerData.table) {
59
+ throw new Error(`Layer "${layerName}" cannot combine promoted geometry columns from different prepared tables.`);
60
+ }
61
+ table = layerData.table;
62
+ boundProps[binding.prop] = layerData.geometryColumn;
63
+ continue;
64
+ }
65
+ const columnName = resolveConfiguredColumn(layerProps, binding.configKey);
66
+ if (!columnName) {
67
+ if (binding.required) {
68
+ throw new Error(`Layer "${layerName}" requires _sqlroomsBinding.${binding.configKey}.`);
69
+ }
70
+ continue;
71
+ }
72
+ const vector = table.getChild(columnName) ?? prepared.table.getChild(columnName);
73
+ if (!vector) {
74
+ throw new Error(`Layer "${layerName}" references unknown column "${columnName}" for ${binding.prop}.`);
75
+ }
76
+ boundProps[binding.prop] = vector;
77
+ }
78
+ return { table, boundProps };
79
+ }
30
80
  export function createDeckJsonConfiguration(options) {
31
81
  const { datasetStates, datasetIds } = options;
32
82
  return new JSONConfiguration({
33
83
  classes: DEFAULT_DECK_JSON_CLASSES,
34
84
  enumerations: DEFAULT_DECK_JSON_ENUMERATIONS,
35
85
  constants: DEFAULT_DECK_JSON_CONSTANTS,
86
+ functions: {
87
+ colorScale: (props) => createColorScaleMarker(props),
88
+ },
36
89
  // TODO(geoarrow-upgrade): In 0.3.x we preserve raw `@@=` strings here because
37
90
  // `@deck.gl/json` would otherwise eagerly compile them into row-based accessors
38
91
  // before `preProcessClassProps` can rewrite them for GeoArrow. If the next
39
92
  // GeoArrow version can consume deck.gl/json's converted accessors directly, or
40
93
  // exposes a cleaner injection seam, remove this shim.
41
- convertFunction: (expression) => `@@=${expression}`,
94
+ convertFunction: ((expression) => `@@=${expression}`),
42
95
  preProcessClassProps: (Class, props) => {
43
96
  const layerName = getLayerName(Class);
44
97
  const compatibility = getLayerCompatibility(layerName);
@@ -54,7 +107,7 @@ export function createDeckJsonConfiguration(options) {
54
107
  return props;
55
108
  }
56
109
  if (!datasetId) {
57
- throw new Error(`Layer "${layerName}" must declare _sqlrooms.dataset when multiple datasets are available.`);
110
+ throw new Error(`Layer "${layerName}" must declare _sqlroomsBinding.dataset when multiple datasets are available.`);
58
111
  }
59
112
  const datasetState = datasetStates[datasetId];
60
113
  if (!datasetState) {
@@ -65,36 +118,36 @@ export function createDeckJsonConfiguration(options) {
65
118
  }
66
119
  const prepared = datasetState.prepared;
67
120
  const geometryColumn = resolveGeometryColumn(extensionProps);
68
- const baseProps = applyColorScale({
69
- props: stripLayerExtensionProps(layerProps),
70
- layerProps: extensionProps,
71
- table: prepared.table,
72
- });
121
+ const strippedProps = stripLayerExtensionProps(layerProps);
73
122
  if (compatibility.representation === 'geojson') {
123
+ const baseProps = applyColorScale({
124
+ props: strippedProps,
125
+ table: prepared.table,
126
+ });
74
127
  return {
75
128
  ...baseProps,
76
129
  data: prepared.getGeoJsonBinaryData(geometryColumn),
77
130
  };
78
131
  }
79
- const resolvedGeometry = prepared.resolveGeometry(geometryColumn);
80
- if (!resolvedGeometry.nativeGeoArrow &&
81
- !(isSupportedGeoArrowLayerType(layerName) &&
82
- wkbGeometryDecoder.supportsGeoArrowPromotion(layerName, resolvedGeometry.encoding, prepared.table, resolvedGeometry.columnName))) {
83
- throw new Error(`Layer "${layerName}" cannot render geometry encoding "${resolvedGeometry.encoding}" for dataset "${datasetId}".`);
84
- }
85
- const geoArrowLayerData = prepared.getGeoArrowLayerData(geometryColumn);
132
+ const { table, boundProps } = resolveGeoArrowBindings({
133
+ layerName,
134
+ compatibility,
135
+ layerProps: extensionProps,
136
+ prepared,
137
+ props: strippedProps,
138
+ });
139
+ const baseProps = applyColorScale({
140
+ props: strippedProps,
141
+ table,
142
+ });
86
143
  const nextProps = {
87
144
  ...baseProps,
88
- // TODO(geoarrow-upgrade): 0.3.x expects `data` as an Arrow Table and the
89
- // geometry accessor as an Arrow Vector. Re-check this payload contract when
90
- // upgrading; newer GeoArrow code may prefer RecordBatch/Data chunks instead.
91
- data: geoArrowLayerData.table,
92
- [compatibility.geometryProp]: baseProps[compatibility.geometryProp] ??
93
- geoArrowLayerData.geometryColumn,
145
+ data: table,
146
+ ...boundProps,
94
147
  };
95
148
  return rewriteGeoArrowAccessors({
96
149
  props: nextProps,
97
- table: geoArrowLayerData.table,
150
+ table,
98
151
  layerName,
99
152
  });
100
153
  },
@@ -1 +1 @@
1
- {"version":3,"file":"createDeckJsonConfiguration.js","sourceRoot":"","sources":["../../src/json/createDeck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CAAC;YAEF,OAAO,wBAAwB,CAAC;gBAC9B,KAAK,EAAE,SAAS;gBAChB,KAAK,EAAE,iBAAiB,CAAC,KAAK;gBAC9B,SAAS;aACV,CAAC,CAAC;QACL,CAAC;QACD,wBAAwB,EAAE,CAAC,IAAa,EAAE,EAAE;YAC1C,IACE,IAAI;gBACJ,OAAO,IAAI,KAAK,QAAQ;gBACxB,QAAQ,IAAI,IAAI;gBAChB,KAAK,CAAC,OAAO,CAAE,IAA6B,CAAC,MAAM,CAAC,EACpD,CAAC;gBACA,IAA4B,CAAC,MAAM,GAClC,IACD,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC3B,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {JSONConfiguration} from '@deck.gl/json';\nimport type {LayerExtensionProps, PreparedDeckDatasetState} from '../types';\nimport {\n DEFAULT_DECK_JSON_CLASSES,\n DEFAULT_DECK_JSON_CONSTANTS,\n DEFAULT_DECK_JSON_ENUMERATIONS,\n} from './defaultClasses';\nimport {\n getLayerCompatibility,\n isSupportedGeoArrowLayerType,\n} from './layerCompatibility';\nimport {\n isManagedLayer,\n resolveColorScale,\n resolveDatasetId,\n resolveGeometryColumn,\n stripLayerExtensionProps,\n} from './layerConfig';\nimport {rewriteGeoArrowAccessors} from './rewriteGeoArrowAccessors';\nimport {wkbGeometryDecoder} from '../prepare/wkbDecoder';\nimport {compileColorScale} from './compileColorScale';\n\ntype CreateDeckJsonConfigurationOptions = {\n datasetStates: Record<string, PreparedDeckDatasetState>;\n datasetIds: string[];\n};\n\nfunction getLayerName(Class: unknown) {\n const maybeClass = Class as {layerName?: string; name?: string};\n return maybeClass.layerName ?? maybeClass.name ?? 'UnknownLayer';\n}\n\nfunction applyColorScale(options: {\n props: Record<string, unknown>;\n layerProps: LayerExtensionProps & Record<string, unknown>;\n table: import('apache-arrow').Table;\n}) {\n const {props, layerProps, table} = options;\n const colorScale = resolveColorScale(layerProps);\n if (!colorScale) {\n return props;\n }\n\n const targetProp = colorScale.prop ?? 'getFillColor';\n if (props[targetProp] !== undefined) {\n return props;\n }\n\n return {\n ...props,\n [targetProp]: compileColorScale({\n table,\n colorScale,\n }),\n };\n}\n\nexport function createDeckJsonConfiguration(\n options: CreateDeckJsonConfigurationOptions,\n) {\n const {datasetStates, datasetIds} = options;\n\n return new JSONConfiguration({\n classes: DEFAULT_DECK_JSON_CLASSES,\n enumerations: DEFAULT_DECK_JSON_ENUMERATIONS,\n constants: DEFAULT_DECK_JSON_CONSTANTS,\n // TODO(geoarrow-upgrade): In 0.3.x we preserve raw `@@=` strings here because\n // `@deck.gl/json` would otherwise eagerly compile them into row-based accessors\n // before `preProcessClassProps` can rewrite them for GeoArrow. If the next\n // GeoArrow version can consume deck.gl/json's converted accessors directly, or\n // exposes a cleaner injection seam, remove this shim.\n convertFunction: (expression: string) => `@@=${expression}`,\n preProcessClassProps: (Class: unknown, props: unknown) => {\n const layerName = getLayerName(Class);\n const compatibility = getLayerCompatibility(layerName);\n\n if (!compatibility) {\n return props;\n }\n\n const layerProps = props as Record<string, unknown>;\n const extensionProps = layerProps as typeof layerProps &\n LayerExtensionProps;\n const datasetId = resolveDatasetId(extensionProps, datasetIds);\n const managed =\n isManagedLayer(extensionProps, datasetIds) ||\n (datasetIds.length > 1 && layerProps.data === undefined);\n\n if (!managed) {\n return props;\n }\n\n if (!datasetId) {\n throw new Error(\n `Layer \"${layerName}\" must declare _sqlrooms.dataset when multiple datasets are available.`,\n );\n }\n\n const datasetState = datasetStates[datasetId];\n if (!datasetState) {\n throw new Error(\n `Layer \"${layerName}\" references unknown dataset \"${datasetId}\".`,\n );\n }\n\n if (datasetState.status !== 'ready') {\n return stripLayerExtensionProps(layerProps);\n }\n\n const prepared = datasetState.prepared;\n const geometryColumn = resolveGeometryColumn(extensionProps);\n const baseProps = applyColorScale({\n props: stripLayerExtensionProps(layerProps),\n layerProps: extensionProps,\n table: prepared.table,\n });\n\n if (compatibility.representation === 'geojson') {\n return {\n ...baseProps,\n data: prepared.getGeoJsonBinaryData(geometryColumn),\n };\n }\n\n const resolvedGeometry = prepared.resolveGeometry(geometryColumn);\n if (\n !resolvedGeometry.nativeGeoArrow &&\n !(\n isSupportedGeoArrowLayerType(layerName) &&\n wkbGeometryDecoder.supportsGeoArrowPromotion(\n layerName,\n resolvedGeometry.encoding,\n prepared.table,\n resolvedGeometry.columnName,\n )\n )\n ) {\n throw new Error(\n `Layer \"${layerName}\" cannot render geometry encoding \"${resolvedGeometry.encoding}\" for dataset \"${datasetId}\".`,\n );\n }\n\n const geoArrowLayerData = prepared.getGeoArrowLayerData(geometryColumn);\n const nextProps = {\n ...baseProps,\n // TODO(geoarrow-upgrade): 0.3.x expects `data` as an Arrow Table and the\n // geometry accessor as an Arrow Vector. Re-check this payload contract when\n // upgrading; newer GeoArrow code may prefer RecordBatch/Data chunks instead.\n data: geoArrowLayerData.table,\n [compatibility.geometryProp]:\n baseProps[compatibility.geometryProp] ??\n geoArrowLayerData.geometryColumn,\n };\n\n return rewriteGeoArrowAccessors({\n props: nextProps,\n table: geoArrowLayerData.table,\n layerName,\n });\n },\n postProcessConvertedJson: (json: unknown) => {\n if (\n json &&\n typeof json === 'object' &&\n 'layers' in json &&\n Array.isArray((json as {layers?: unknown[]}).layers)\n ) {\n (json as {layers: unknown[]}).layers = (\n json as {layers: unknown[]}\n ).layers.filter(Boolean);\n }\n\n return json;\n },\n });\n}\n"]}
1
+ {"version":3,"file":"createDeckJsonConfiguration.js","sourceRoot":"","sources":["../../src/json/createDeckJsonConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAC,sBAAsB,EAAE,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,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import {wkbGeometryDecoder} from '../prepare/wkbDecoder';\nimport type {LayerBindingProps, PreparedDeckDatasetState} from '../types';\nimport {createColorScaleMarker, getColorScale} from './colorScaleFunction';\nimport {compileColorScale} from './compileColorScale';\nimport {\n DEFAULT_DECK_JSON_CLASSES,\n DEFAULT_DECK_JSON_CONSTANTS,\n DEFAULT_DECK_JSON_ENUMERATIONS,\n} from './defaultClasses';\nimport {getLayerCompatibility} from './layerCompatibility';\nimport {\n isManagedLayer,\n resolveConfiguredColumn,\n resolveDatasetId,\n resolveGeometryColumn,\n stripLayerExtensionProps,\n} from './layerConfig';\nimport {rewriteGeoArrowAccessors} from './rewriteGeoArrowAccessors';\n\ntype CreateDeckJsonConfigurationOptions = {\n datasetStates: Record<string, PreparedDeckDatasetState>;\n datasetIds: string[];\n};\n\nfunction getLayerName(Class: unknown) {\n const maybeClass = Class as {layerName?: string; name?: string};\n return maybeClass.layerName ?? maybeClass.name ?? 'UnknownLayer';\n}\n\nfunction applyColorScale(options: {\n props: Record<string, unknown>;\n table: import('apache-arrow').Table;\n}) {\n const {props, table} = options;\n const resolved = getColorScale(props);\n if (!resolved) {\n return props;\n }\n\n const {propName, colorScale} = resolved;\n\n const updateTriggers =\n props.updateTriggers &&\n typeof props.updateTriggers === 'object' &&\n !Array.isArray(props.updateTriggers)\n ? (props.updateTriggers as Record<string, unknown>)\n : {};\n\n return {\n ...props,\n [propName]: compileColorScale({\n table,\n colorScale,\n }),\n updateTriggers: {\n ...updateTriggers,\n [propName]: JSON.stringify(colorScale),\n },\n };\n}\n\nfunction resolveGeoArrowBindings(options: {\n layerName: string;\n compatibility: NonNullable<ReturnType<typeof getLayerCompatibility>> & {\n representation: 'geoarrow';\n };\n layerProps: LayerBindingProps & Record<string, unknown>;\n prepared: Extract<PreparedDeckDatasetState, {status: 'ready'}>['prepared'];\n props: Record<string, unknown>;\n}) {\n const {layerName, compatibility, layerProps, prepared, props} = options;\n let table = prepared.table;\n const boundProps: Record<string, unknown> = {};\n\n for (const binding of compatibility.bindings) {\n if (props[binding.prop] !== undefined) {\n continue;\n }\n\n if (binding.kind === 'geometry') {\n const columnName = resolveConfiguredColumn(layerProps, binding.configKey);\n if (binding.required && !columnName) {\n throw new Error(\n `Layer \"${layerName}\" requires _sqlroomsBinding.${binding.configKey}.`,\n );\n }\n\n const resolvedGeometry = prepared.resolveGeometry(columnName);\n if (!resolvedGeometry.nativeGeoArrow) {\n if (\n !compatibility.allowGeoArrowPromotion ||\n !wkbGeometryDecoder.supportsGeoArrowPromotion(\n layerName,\n resolvedGeometry.encoding,\n prepared.table,\n resolvedGeometry.columnName,\n )\n ) {\n throw new Error(\n `Layer \"${layerName}\" cannot render geometry encoding \"${resolvedGeometry.encoding}\" for dataset \"${prepared.datasetId}\".`,\n );\n }\n }\n\n const layerData = prepared.getGeoArrowLayerData(columnName);\n if (table !== prepared.table && table !== layerData.table) {\n throw new Error(\n `Layer \"${layerName}\" cannot combine promoted geometry columns from different prepared tables.`,\n );\n }\n\n table = layerData.table;\n boundProps[binding.prop] = layerData.geometryColumn;\n continue;\n }\n\n const columnName = resolveConfiguredColumn(layerProps, binding.configKey);\n if (!columnName) {\n if (binding.required) {\n throw new Error(\n `Layer \"${layerName}\" requires _sqlroomsBinding.${binding.configKey}.`,\n );\n }\n continue;\n }\n\n const vector =\n table.getChild(columnName) ?? prepared.table.getChild(columnName);\n if (!vector) {\n throw new Error(\n `Layer \"${layerName}\" references unknown column \"${columnName}\" for ${binding.prop}.`,\n );\n }\n\n boundProps[binding.prop] = vector;\n }\n\n return {table, boundProps};\n}\n\nexport function createDeckJsonConfiguration(\n options: CreateDeckJsonConfigurationOptions,\n) {\n const {datasetStates, datasetIds} = options;\n\n return new JSONConfiguration({\n classes: DEFAULT_DECK_JSON_CLASSES,\n enumerations: DEFAULT_DECK_JSON_ENUMERATIONS,\n constants: DEFAULT_DECK_JSON_CONSTANTS,\n functions: {\n colorScale: (props: ColorScaleConfig) => createColorScaleMarker(props),\n },\n // TODO(geoarrow-upgrade): In 0.3.x we preserve raw `@@=` strings here because\n // `@deck.gl/json` would otherwise eagerly compile them into row-based accessors\n // before `preProcessClassProps` can rewrite them for GeoArrow. If the next\n // GeoArrow version can consume deck.gl/json's converted accessors directly, or\n // exposes a cleaner injection seam, remove this shim.\n convertFunction: ((expression: string) => `@@=${expression}`) as never,\n preProcessClassProps: (Class: unknown, props: Record<string, unknown>) => {\n const layerName = getLayerName(Class);\n const compatibility = getLayerCompatibility(layerName);\n\n if (!compatibility) {\n return props;\n }\n\n const layerProps = props as Record<string, unknown>;\n const extensionProps = layerProps as typeof layerProps &\n LayerBindingProps;\n const datasetId = resolveDatasetId(extensionProps, datasetIds);\n const managed =\n isManagedLayer(extensionProps, datasetIds) ||\n (datasetIds.length > 1 && layerProps.data === undefined);\n\n if (!managed) {\n return props;\n }\n\n if (!datasetId) {\n throw new Error(\n `Layer \"${layerName}\" must declare _sqlroomsBinding.dataset when multiple datasets are available.`,\n );\n }\n\n const datasetState = datasetStates[datasetId];\n if (!datasetState) {\n throw new Error(\n `Layer \"${layerName}\" references unknown dataset \"${datasetId}\".`,\n );\n }\n\n if (datasetState.status !== 'ready') {\n return stripLayerExtensionProps(layerProps);\n }\n\n const prepared = datasetState.prepared;\n const geometryColumn = resolveGeometryColumn(extensionProps);\n const strippedProps = stripLayerExtensionProps(layerProps);\n\n if (compatibility.representation === 'geojson') {\n const baseProps = applyColorScale({\n props: strippedProps,\n table: prepared.table,\n });\n return {\n ...baseProps,\n data: prepared.getGeoJsonBinaryData(geometryColumn),\n };\n }\n\n const {table, boundProps} = resolveGeoArrowBindings({\n layerName,\n compatibility,\n layerProps: extensionProps,\n prepared,\n props: strippedProps,\n });\n const baseProps = applyColorScale({\n props: strippedProps,\n table,\n });\n const nextProps = {\n ...baseProps,\n data: table,\n ...boundProps,\n };\n\n return rewriteGeoArrowAccessors({\n props: nextProps,\n table,\n layerName,\n });\n },\n postProcessConvertedJson: (json: unknown) => {\n if (\n json &&\n typeof json === 'object' &&\n 'layers' in json &&\n Array.isArray((json as {layers?: unknown[]}).layers)\n ) {\n (json as {layers: unknown[]}).layers = (\n json as {layers: unknown[]}\n ).layers.filter(Boolean);\n }\n\n return json;\n },\n });\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { FirstPersonView, MapView, OrbitView, OrthographicView } from '@deck.gl/core';
2
2
  import { GeoJsonLayer } from '@deck.gl/layers';
3
- import { GeoArrowPathLayer, GeoArrowScatterplotLayer, GeoArrowSolidPolygonLayer } from '@geoarrow/deck.gl-layers';
3
+ import { GeoArrowArcLayer, GeoArrowColumnLayer, _GeoArrowH3HexagonLayer as GeoArrowH3HexagonLayer, GeoArrowHeatmapLayer, GeoArrowPathLayer, GeoArrowPolygonLayer, GeoArrowScatterplotLayer, GeoArrowSolidPolygonLayer, GeoArrowTripsLayer } from '@geoarrow/deck.gl-layers';
4
4
  export declare const DEFAULT_DECK_JSON_CLASSES: {
5
5
  MapView: typeof MapView;
6
6
  FirstPersonView: typeof FirstPersonView;
@@ -8,16 +8,22 @@ export declare const DEFAULT_DECK_JSON_CLASSES: {
8
8
  OrthographicView: typeof OrthographicView;
9
9
  GeoJsonLayer: typeof GeoJsonLayer;
10
10
  GeoArrowScatterplotLayer: typeof GeoArrowScatterplotLayer;
11
+ GeoArrowHeatmapLayer: typeof GeoArrowHeatmapLayer;
12
+ GeoArrowColumnLayer: typeof GeoArrowColumnLayer;
11
13
  GeoArrowPathLayer: typeof GeoArrowPathLayer;
14
+ GeoArrowPolygonLayer: typeof GeoArrowPolygonLayer;
12
15
  GeoArrowSolidPolygonLayer: typeof GeoArrowSolidPolygonLayer;
16
+ GeoArrowArcLayer: typeof GeoArrowArcLayer;
17
+ GeoArrowTripsLayer: typeof GeoArrowTripsLayer;
18
+ GeoArrowH3HexagonLayer: typeof GeoArrowH3HexagonLayer;
13
19
  };
14
20
  export declare const DEFAULT_DECK_JSON_ENUMERATIONS: {
15
21
  COORDINATE_SYSTEM: {
16
- readonly DEFAULT: -1;
17
- readonly LNGLAT: 1;
18
- readonly METER_OFFSETS: 2;
19
- readonly LNGLAT_OFFSETS: 3;
20
- readonly CARTESIAN: 0;
22
+ readonly DEFAULT: "default";
23
+ readonly LNGLAT: "lnglat";
24
+ readonly METER_OFFSETS: "meter-offsets";
25
+ readonly LNGLAT_OFFSETS: "lnglat-offsets";
26
+ readonly CARTESIAN: "cartesian";
21
27
  };
22
28
  };
23
29
  export declare const DEFAULT_DECK_JSON_CONSTANTS: {};
@@ -1 +1 @@
1
- {"version":3,"file":"defaultClasses.d.ts","sourceRoot":"","sources":["../../src/json/defaultClasses.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EACf,OAAO,EACP,SAAS,EACT,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,0BAA0B,CAAC;AAKlC,eAAO,MAAM,yBAAyB;;;;;;;;;CASrC,CAAC;AAEF,eAAO,MAAM,8BAA8B;;;;;;;;CAE1C,CAAC;AAEF,eAAO,MAAM,2BAA2B,IAAK,CAAC"}
1
+ {"version":3,"file":"defaultClasses.d.ts","sourceRoot":"","sources":["../../src/json/defaultClasses.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EACf,OAAO,EACP,SAAS,EACT,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,IAAI,sBAAsB,EACjD,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAKlC,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;CAerC,CAAC;AAEF,eAAO,MAAM,8BAA8B;;;;;;;;CAE1C,CAAC;AAEF,eAAO,MAAM,2BAA2B,IAAK,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { COORDINATE_SYSTEM, FirstPersonView, MapView, OrbitView, OrthographicView, } from '@deck.gl/core';
2
2
  import { GeoJsonLayer } from '@deck.gl/layers';
3
- import { GeoArrowPathLayer, GeoArrowScatterplotLayer, GeoArrowSolidPolygonLayer, } from '@geoarrow/deck.gl-layers';
3
+ import { GeoArrowArcLayer, GeoArrowColumnLayer, _GeoArrowH3HexagonLayer as GeoArrowH3HexagonLayer, GeoArrowHeatmapLayer, GeoArrowPathLayer, GeoArrowPolygonLayer, GeoArrowScatterplotLayer, GeoArrowSolidPolygonLayer, GeoArrowTripsLayer, } from '@geoarrow/deck.gl-layers';
4
4
  // TODO(geoarrow-upgrade): Revisit this import surface on the next GeoArrow bump.
5
5
  // Published 0.3.x uses `@geoarrow/deck.gl-layers`; newer lines may rename the package
6
6
  // and/or move the exported layer classes.
@@ -11,8 +11,14 @@ export const DEFAULT_DECK_JSON_CLASSES = {
11
11
  OrthographicView,
12
12
  GeoJsonLayer,
13
13
  GeoArrowScatterplotLayer,
14
+ GeoArrowHeatmapLayer,
15
+ GeoArrowColumnLayer,
14
16
  GeoArrowPathLayer,
17
+ GeoArrowPolygonLayer,
15
18
  GeoArrowSolidPolygonLayer,
19
+ GeoArrowArcLayer,
20
+ GeoArrowTripsLayer,
21
+ GeoArrowH3HexagonLayer,
16
22
  };
17
23
  export const DEFAULT_DECK_JSON_ENUMERATIONS = {
18
24
  COORDINATE_SYSTEM,
@@ -1 +1 @@
1
- {"version":3,"file":"defaultClasses.js","sourceRoot":"","sources":["../../src/json/defaultClasses.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,OAAO,EACP,SAAS,EACT,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,yBAAyB,GAC1B,MAAM,0BAA0B,CAAC;AAElC,iFAAiF;AACjF,sFAAsF;AACtF,0CAA0C;AAC1C,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,OAAO;IACP,eAAe;IACf,SAAS;IACT,gBAAgB;IAChB,YAAY;IACZ,wBAAwB;IACxB,iBAAiB;IACjB,yBAAyB;CAC1B,CAAC;AAEF,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,iBAAiB;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC","sourcesContent":["import {\n COORDINATE_SYSTEM,\n FirstPersonView,\n MapView,\n OrbitView,\n OrthographicView,\n} from '@deck.gl/core';\nimport {GeoJsonLayer} from '@deck.gl/layers';\nimport {\n GeoArrowPathLayer,\n GeoArrowScatterplotLayer,\n GeoArrowSolidPolygonLayer,\n} from '@geoarrow/deck.gl-layers';\n\n// TODO(geoarrow-upgrade): Revisit this import surface on the next GeoArrow bump.\n// Published 0.3.x uses `@geoarrow/deck.gl-layers`; newer lines may rename the package\n// and/or move the exported layer classes.\nexport const DEFAULT_DECK_JSON_CLASSES = {\n MapView,\n FirstPersonView,\n OrbitView,\n OrthographicView,\n GeoJsonLayer,\n GeoArrowScatterplotLayer,\n GeoArrowPathLayer,\n GeoArrowSolidPolygonLayer,\n};\n\nexport const DEFAULT_DECK_JSON_ENUMERATIONS = {\n COORDINATE_SYSTEM,\n};\n\nexport const DEFAULT_DECK_JSON_CONSTANTS = {};\n"]}
1
+ {"version":3,"file":"defaultClasses.js","sourceRoot":"","sources":["../../src/json/defaultClasses.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,OAAO,EACP,SAAS,EACT,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,IAAI,sBAAsB,EACjD,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAElC,iFAAiF;AACjF,sFAAsF;AACtF,0CAA0C;AAC1C,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,OAAO;IACP,eAAe;IACf,SAAS;IACT,gBAAgB;IAChB,YAAY;IACZ,wBAAwB;IACxB,oBAAoB;IACpB,mBAAmB;IACnB,iBAAiB;IACjB,oBAAoB;IACpB,yBAAyB;IACzB,gBAAgB;IAChB,kBAAkB;IAClB,sBAAsB;CACvB,CAAC;AAEF,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,iBAAiB;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAC","sourcesContent":["import {\n COORDINATE_SYSTEM,\n FirstPersonView,\n MapView,\n OrbitView,\n OrthographicView,\n} from '@deck.gl/core';\nimport {GeoJsonLayer} from '@deck.gl/layers';\nimport {\n GeoArrowArcLayer,\n GeoArrowColumnLayer,\n _GeoArrowH3HexagonLayer as GeoArrowH3HexagonLayer,\n GeoArrowHeatmapLayer,\n GeoArrowPathLayer,\n GeoArrowPolygonLayer,\n GeoArrowScatterplotLayer,\n GeoArrowSolidPolygonLayer,\n GeoArrowTripsLayer,\n} from '@geoarrow/deck.gl-layers';\n\n// TODO(geoarrow-upgrade): Revisit this import surface on the next GeoArrow bump.\n// Published 0.3.x uses `@geoarrow/deck.gl-layers`; newer lines may rename the package\n// and/or move the exported layer classes.\nexport const DEFAULT_DECK_JSON_CLASSES = {\n MapView,\n FirstPersonView,\n OrbitView,\n OrthographicView,\n GeoJsonLayer,\n GeoArrowScatterplotLayer,\n GeoArrowHeatmapLayer,\n GeoArrowColumnLayer,\n GeoArrowPathLayer,\n GeoArrowPolygonLayer,\n GeoArrowSolidPolygonLayer,\n GeoArrowArcLayer,\n GeoArrowTripsLayer,\n GeoArrowH3HexagonLayer,\n};\n\nexport const DEFAULT_DECK_JSON_ENUMERATIONS = {\n COORDINATE_SYSTEM,\n};\n\nexport const DEFAULT_DECK_JSON_CONSTANTS = {};\n"]}
@@ -1,5 +1,5 @@
1
+ import type { ResolvedColorLegend } from '@sqlrooms/color-scales';
1
2
  import type { PreparedDeckDatasetState } from '../types';
2
- import { type ResolvedColorLegend } from './compileColorScale';
3
3
  export declare function extractColorScaleLegends(options: {
4
4
  spec: Record<string, unknown> | null;
5
5
  datasetIds: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"extractColorScaleLegends.d.ts","sourceRoot":"","sources":["../../src/json/extractColorScaleLegends.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAsB,wBAAwB,EAAC,MAAM,UAAU,CAAC;AAC5E,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAuB7B,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACrC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;CACzD,yBA4CA"}
1
+ {"version":3,"file":"extractColorScaleLegends.d.ts","sourceRoot":"","sources":["../../src/json/extractColorScaleLegends.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAoB,wBAAwB,EAAC,MAAM,UAAU,CAAC;AAuB1E,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IACrC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAC;CACzD,yBA4CA"}
@@ -1,7 +1,9 @@
1
- import { buildColorScaleLegend, } from './compileColorScale';
2
- import { resolveColorLegend, resolveColorScale, resolveDatasetId, } from './layerConfig';
1
+ import { getColorScale } from './colorScaleFunction';
2
+ import { buildColorScaleLegend } from './compileColorScale';
3
+ import { resolveColorLegend, resolveDatasetId } from './layerConfig';
3
4
  function resolveLegendTitle(layerProps, fallbackField) {
4
- const legend = resolveColorLegend(layerProps);
5
+ const legend = resolveColorLegend(layerProps, 'getFillColor') ??
6
+ resolveColorLegend(layerProps, 'getLineColor');
5
7
  if (legend &&
6
8
  typeof legend === 'object' &&
7
9
  typeof legend.title === 'string') {
@@ -21,11 +23,11 @@ export function extractColorScaleLegends(options) {
21
23
  }
22
24
  const layerProps = layer;
23
25
  const extensionProps = layerProps;
24
- const colorScale = resolveColorScale(extensionProps);
25
- const legend = resolveColorLegend(extensionProps);
26
- if (!colorScale || legend === false) {
26
+ const resolvedColorScale = getColorScale(layerProps);
27
+ if (!resolvedColorScale) {
27
28
  continue;
28
29
  }
30
+ const { colorScale } = resolvedColorScale;
29
31
  const datasetId = resolveDatasetId(layerProps, datasetIds);
30
32
  if (!datasetId) {
31
33
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"extractColorScaleLegends.js","sourceRoot":"","sources":["../../src/json/extractColorScaleLegends.ts"],"names":[],"mappings":"AACA,OAAO,EACL,qBAAqB,GAEtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,SAAS,kBAAkB,CACzB,UAAmC,EACnC,aAAqB;IAErB,MAAM,MAAM,GAAG,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAC9C,IACE,MAAM;QACN,OAAO,MAAM,KAAK,QAAQ;QAC1B,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,EAChC,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;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CAAC;QAC/B,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type {LayerExtensionProps, PreparedDeckDatasetState} from '../types';\nimport {\n buildColorScaleLegend,\n type ResolvedColorLegend,\n} from './compileColorScale';\nimport {\n resolveColorLegend,\n resolveColorScale,\n resolveDatasetId,\n} from './layerConfig';\n\nfunction resolveLegendTitle(\n layerProps: Record<string, unknown>,\n fallbackField: string,\n) {\n const legend = resolveColorLegend(layerProps);\n if (\n legend &&\n typeof legend === 'object' &&\n typeof legend.title === 'string'\n ) {\n return legend.title;\n }\n\n return fallbackField;\n}\n\nexport function extractColorScaleLegends(options: {\n spec: Record<string, unknown> | null;\n datasetIds: string[];\n datasetStates: Record<string, PreparedDeckDatasetState>;\n}) {\n const {spec, datasetIds, datasetStates} = options;\n if (!spec || !Array.isArray(spec.layers)) {\n return [] as ResolvedColorLegend[];\n }\n\n const legends: ResolvedColorLegend[] = [];\n\n for (const layer of spec.layers) {\n if (!layer || typeof layer !== 'object') {\n continue;\n }\n\n const layerProps = layer as Record<string, unknown>;\n const extensionProps = layerProps as LayerExtensionProps &\n Record<string, unknown>;\n const colorScale = resolveColorScale(extensionProps);\n const legend = resolveColorLegend(extensionProps);\n if (!colorScale || legend === false) {\n continue;\n }\n\n const datasetId = resolveDatasetId(layerProps, datasetIds);\n if (!datasetId) {\n continue;\n }\n\n const datasetState = datasetStates[datasetId];\n if (!datasetState || datasetState.status !== 'ready') {\n continue;\n }\n\n const resolvedLegend = buildColorScaleLegend({\n table: datasetState.prepared.table,\n colorScale,\n title: resolveLegendTitle(layerProps, colorScale.field),\n });\n\n if (resolvedLegend) {\n legends.push(resolvedLegend);\n }\n }\n\n return legends;\n}\n"]}
1
+ {"version":3,"file":"extractColorScaleLegends.js","sourceRoot":"","sources":["../../src/json/extractColorScaleLegends.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAC,qB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QACX,CAAC;QAED,MAAM,YAAY,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,CAAC,YAAY,IAAI,YAAY,CAAC,MAAM,KAAK,OAAO,EAAE,CAAC;YACrD,SAAS;QACX,CAAC;QAED,MAAM,cAAc,GAAG,qBAAqB,CAAC;YAC3C,KAAK,EAAE,YAAY,CAAC,QAAQ,CAAC,KAAK;YAClC,UAAU;YACV,KAAK,EAAE,kBAAkB,CAAC,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC;SACxD,CAAC,CAAC;QAEH,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import type {ResolvedColorLegend} from '@sqlrooms/color-scales';\nimport type {LayerBindingProps, PreparedDeckDatasetState} from '../types';\nimport {getColorScale} from './colorScaleFunction';\nimport {buildColorScaleLegend} from './compileColorScale';\nimport {resolveColorLegend, resolveDatasetId} from './layerConfig';\n\nfunction resolveLegendTitle(\n layerProps: Record<string, unknown>,\n fallbackField: string,\n) {\n const legend =\n resolveColorLegend(layerProps, 'getFillColor') ??\n resolveColorLegend(layerProps, 'getLineColor');\n if (\n legend &&\n typeof legend === 'object' &&\n typeof legend.title === 'string'\n ) {\n return legend.title;\n }\n\n return fallbackField;\n}\n\nexport function extractColorScaleLegends(options: {\n spec: Record<string, unknown> | null;\n datasetIds: string[];\n datasetStates: Record<string, PreparedDeckDatasetState>;\n}) {\n const {spec, datasetIds, datasetStates} = options;\n if (!spec || !Array.isArray(spec.layers)) {\n return [] as ResolvedColorLegend[];\n }\n\n const legends: ResolvedColorLegend[] = [];\n\n for (const layer of spec.layers) {\n if (!layer || typeof layer !== 'object') {\n continue;\n }\n\n const layerProps = layer as Record<string, unknown>;\n const extensionProps = layerProps as LayerBindingProps &\n Record<string, unknown>;\n const resolvedColorScale = getColorScale(layerProps);\n if (!resolvedColorScale) {\n continue;\n }\n const {colorScale} = resolvedColorScale;\n\n const datasetId = resolveDatasetId(layerProps, datasetIds);\n if (!datasetId) {\n continue;\n }\n\n const datasetState = datasetStates[datasetId];\n if (!datasetState || datasetState.status !== 'ready') {\n continue;\n }\n\n const resolvedLegend = buildColorScaleLegend({\n table: datasetState.prepared.table,\n colorScale,\n title: resolveLegendTitle(layerProps, colorScale.field),\n });\n\n if (resolvedLegend) {\n legends.push(resolvedLegend);\n }\n }\n\n return legends;\n}\n"]}
@@ -1,15 +1,21 @@
1
- import type { SupportedGeoArrowLayerType } from '../prepare/geometryDecoder';
1
+ import type { LayerConfigColumnKey } from './layerConfig';
2
2
  type GeoJsonCompatibility = {
3
3
  representation: 'geojson';
4
4
  vectorAccessorProps: string[];
5
5
  };
6
+ type GeoArrowBinding = {
7
+ prop: string;
8
+ kind: 'geometry' | 'column';
9
+ configKey: LayerConfigColumnKey;
10
+ required?: boolean;
11
+ };
6
12
  type GeoArrowCompatibility = {
7
13
  representation: 'geoarrow';
8
- geometryProp: string;
14
+ bindings: GeoArrowBinding[];
9
15
  vectorAccessorProps: string[];
16
+ allowGeoArrowPromotion?: boolean;
10
17
  };
11
18
  type LayerCompatibility = GeoJsonCompatibility | GeoArrowCompatibility;
12
19
  export declare function getLayerCompatibility(layerName: string): LayerCompatibility | undefined;
13
- export declare function isSupportedGeoArrowLayerType(layerName: string): layerName is SupportedGeoArrowLayerType;
14
20
  export {};
15
21
  //# sourceMappingURL=layerCompatibility.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"layerCompatibility.d.ts","sourceRoot":"","sources":["../../src/json/layerCompatibility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,0BAA0B,EAAC,MAAM,4BAA4B,CAAC;AAE3E,KAAK,oBAAoB,GAAG;IAC1B,cAAc,EAAE,SAAS,CAAC;IAC1B,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B,CAAC;AAEF,KAAK,qBAAqB,GAAG;I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