deck.gl 9.2.7 → 9.2.8
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.
- package/dist/dist.dev.js +172 -15
- package/dist.min.js +225 -225
- package/package.json +15 -15
package/dist/dist.dev.js
CHANGED
|
@@ -40208,30 +40208,187 @@ void main() {
|
|
|
40208
40208
|
};
|
|
40209
40209
|
|
|
40210
40210
|
// ../core/src/utils/positions.ts
|
|
40211
|
-
var
|
|
40211
|
+
var NUMBER_REGEX = /^(?:\d+\.?\d*|\.\d+)$/;
|
|
40212
40212
|
function parsePosition(value) {
|
|
40213
40213
|
switch (typeof value) {
|
|
40214
40214
|
case "number":
|
|
40215
|
-
|
|
40216
|
-
position
|
|
40217
|
-
|
|
40218
|
-
};
|
|
40215
|
+
if (!Number.isFinite(value)) {
|
|
40216
|
+
throw new Error(`Could not parse position string ${value}`);
|
|
40217
|
+
}
|
|
40218
|
+
return { type: "literal", value };
|
|
40219
40219
|
case "string":
|
|
40220
|
-
|
|
40221
|
-
|
|
40222
|
-
const
|
|
40223
|
-
|
|
40224
|
-
|
|
40225
|
-
|
|
40226
|
-
|
|
40227
|
-
};
|
|
40220
|
+
try {
|
|
40221
|
+
const tokens = tokenize(value);
|
|
40222
|
+
const parser = new LayoutExpressionParser(tokens);
|
|
40223
|
+
return parser.parseExpression();
|
|
40224
|
+
} catch (error) {
|
|
40225
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
40226
|
+
throw new Error(`Could not parse position string ${value}: ${reason}`);
|
|
40228
40227
|
}
|
|
40229
40228
|
default:
|
|
40230
40229
|
throw new Error(`Could not parse position string ${value}`);
|
|
40231
40230
|
}
|
|
40232
40231
|
}
|
|
40233
|
-
function
|
|
40234
|
-
|
|
40232
|
+
function evaluateLayoutExpression(expression, extent) {
|
|
40233
|
+
switch (expression.type) {
|
|
40234
|
+
case "literal":
|
|
40235
|
+
return expression.value;
|
|
40236
|
+
case "percentage":
|
|
40237
|
+
return Math.round(expression.value * extent);
|
|
40238
|
+
case "binary":
|
|
40239
|
+
const left = evaluateLayoutExpression(expression.left, extent);
|
|
40240
|
+
const right = evaluateLayoutExpression(expression.right, extent);
|
|
40241
|
+
return expression.operator === "+" ? left + right : left - right;
|
|
40242
|
+
default:
|
|
40243
|
+
throw new Error("Unknown layout expression type");
|
|
40244
|
+
}
|
|
40245
|
+
}
|
|
40246
|
+
function getPosition(expression, extent) {
|
|
40247
|
+
return evaluateLayoutExpression(expression, extent);
|
|
40248
|
+
}
|
|
40249
|
+
function tokenize(input) {
|
|
40250
|
+
const tokens = [];
|
|
40251
|
+
let index = 0;
|
|
40252
|
+
while (index < input.length) {
|
|
40253
|
+
const char = input[index];
|
|
40254
|
+
if (/\s/.test(char)) {
|
|
40255
|
+
index++;
|
|
40256
|
+
continue;
|
|
40257
|
+
}
|
|
40258
|
+
if (char === "+" || char === "-" || char === "(" || char === ")" || char === "%") {
|
|
40259
|
+
tokens.push({ type: "symbol", value: char });
|
|
40260
|
+
index++;
|
|
40261
|
+
continue;
|
|
40262
|
+
}
|
|
40263
|
+
if (isDigit(char) || char === ".") {
|
|
40264
|
+
const start = index;
|
|
40265
|
+
let hasDecimal = char === ".";
|
|
40266
|
+
index++;
|
|
40267
|
+
while (index < input.length) {
|
|
40268
|
+
const next = input[index];
|
|
40269
|
+
if (isDigit(next)) {
|
|
40270
|
+
index++;
|
|
40271
|
+
continue;
|
|
40272
|
+
}
|
|
40273
|
+
if (next === "." && !hasDecimal) {
|
|
40274
|
+
hasDecimal = true;
|
|
40275
|
+
index++;
|
|
40276
|
+
continue;
|
|
40277
|
+
}
|
|
40278
|
+
break;
|
|
40279
|
+
}
|
|
40280
|
+
const numberString = input.slice(start, index);
|
|
40281
|
+
if (!NUMBER_REGEX.test(numberString)) {
|
|
40282
|
+
throw new Error("Invalid number token");
|
|
40283
|
+
}
|
|
40284
|
+
tokens.push({ type: "number", value: parseFloat(numberString) });
|
|
40285
|
+
continue;
|
|
40286
|
+
}
|
|
40287
|
+
if (isAlpha(char)) {
|
|
40288
|
+
const start = index;
|
|
40289
|
+
while (index < input.length && isAlpha(input[index])) {
|
|
40290
|
+
index++;
|
|
40291
|
+
}
|
|
40292
|
+
const word = input.slice(start, index).toLowerCase();
|
|
40293
|
+
tokens.push({ type: "word", value: word });
|
|
40294
|
+
continue;
|
|
40295
|
+
}
|
|
40296
|
+
throw new Error("Invalid token in position string");
|
|
40297
|
+
}
|
|
40298
|
+
return tokens;
|
|
40299
|
+
}
|
|
40300
|
+
var LayoutExpressionParser = class {
|
|
40301
|
+
constructor(tokens) {
|
|
40302
|
+
this.index = 0;
|
|
40303
|
+
this.tokens = tokens;
|
|
40304
|
+
}
|
|
40305
|
+
parseExpression() {
|
|
40306
|
+
const expression = this.parseBinaryExpression();
|
|
40307
|
+
if (this.index < this.tokens.length) {
|
|
40308
|
+
throw new Error("Unexpected token at end of expression");
|
|
40309
|
+
}
|
|
40310
|
+
return expression;
|
|
40311
|
+
}
|
|
40312
|
+
parseBinaryExpression() {
|
|
40313
|
+
let expression = this.parseFactor();
|
|
40314
|
+
let token = this.peek();
|
|
40315
|
+
while (isAddSubSymbol(token)) {
|
|
40316
|
+
this.index++;
|
|
40317
|
+
const right = this.parseFactor();
|
|
40318
|
+
expression = { type: "binary", operator: token.value, left: expression, right };
|
|
40319
|
+
token = this.peek();
|
|
40320
|
+
}
|
|
40321
|
+
return expression;
|
|
40322
|
+
}
|
|
40323
|
+
parseFactor() {
|
|
40324
|
+
const token = this.peek();
|
|
40325
|
+
if (!token) {
|
|
40326
|
+
throw new Error("Unexpected end of expression");
|
|
40327
|
+
}
|
|
40328
|
+
if (token.type === "symbol" && token.value === "+") {
|
|
40329
|
+
this.index++;
|
|
40330
|
+
return this.parseFactor();
|
|
40331
|
+
}
|
|
40332
|
+
if (token.type === "symbol" && token.value === "-") {
|
|
40333
|
+
this.index++;
|
|
40334
|
+
const factor = this.parseFactor();
|
|
40335
|
+
return { type: "binary", operator: "-", left: { type: "literal", value: 0 }, right: factor };
|
|
40336
|
+
}
|
|
40337
|
+
if (token.type === "symbol" && token.value === "(") {
|
|
40338
|
+
this.index++;
|
|
40339
|
+
const expression = this.parseBinaryExpression();
|
|
40340
|
+
if (!this.consumeSymbol(")")) {
|
|
40341
|
+
throw new Error("Missing closing parenthesis");
|
|
40342
|
+
}
|
|
40343
|
+
return expression;
|
|
40344
|
+
}
|
|
40345
|
+
if (token.type === "word" && token.value === "calc") {
|
|
40346
|
+
this.index++;
|
|
40347
|
+
if (!this.consumeSymbol("(")) {
|
|
40348
|
+
throw new Error("Missing opening parenthesis after calc");
|
|
40349
|
+
}
|
|
40350
|
+
const expression = this.parseBinaryExpression();
|
|
40351
|
+
if (!this.consumeSymbol(")")) {
|
|
40352
|
+
throw new Error("Missing closing parenthesis");
|
|
40353
|
+
}
|
|
40354
|
+
return expression;
|
|
40355
|
+
}
|
|
40356
|
+
if (token.type === "number") {
|
|
40357
|
+
this.index++;
|
|
40358
|
+
const numberValue = token.value;
|
|
40359
|
+
const nextToken = this.peek();
|
|
40360
|
+
if (nextToken && nextToken.type === "symbol" && nextToken.value === "%") {
|
|
40361
|
+
this.index++;
|
|
40362
|
+
return { type: "percentage", value: numberValue / 100 };
|
|
40363
|
+
}
|
|
40364
|
+
if (nextToken && nextToken.type === "word" && nextToken.value === "px") {
|
|
40365
|
+
this.index++;
|
|
40366
|
+
return { type: "literal", value: numberValue };
|
|
40367
|
+
}
|
|
40368
|
+
return { type: "literal", value: numberValue };
|
|
40369
|
+
}
|
|
40370
|
+
throw new Error("Unexpected token in expression");
|
|
40371
|
+
}
|
|
40372
|
+
consumeSymbol(value) {
|
|
40373
|
+
const token = this.peek();
|
|
40374
|
+
if (token && token.type === "symbol" && token.value === value) {
|
|
40375
|
+
this.index++;
|
|
40376
|
+
return true;
|
|
40377
|
+
}
|
|
40378
|
+
return false;
|
|
40379
|
+
}
|
|
40380
|
+
peek() {
|
|
40381
|
+
return this.tokens[this.index] || null;
|
|
40382
|
+
}
|
|
40383
|
+
};
|
|
40384
|
+
function isDigit(char) {
|
|
40385
|
+
return char >= "0" && char <= "9";
|
|
40386
|
+
}
|
|
40387
|
+
function isAlpha(char) {
|
|
40388
|
+
return char >= "a" && char <= "z" || char >= "A" && char <= "Z";
|
|
40389
|
+
}
|
|
40390
|
+
function isAddSubSymbol(token) {
|
|
40391
|
+
return Boolean(token && token.type === "symbol" && (token.value === "+" || token.value === "-"));
|
|
40235
40392
|
}
|
|
40236
40393
|
|
|
40237
40394
|
// ../core/src/views/view.ts
|