@mapbox/mapbox-gl-style-spec 14.21.0 → 14.22.0

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/index.es.js CHANGED
@@ -20756,12 +20756,15 @@ function derefLayers(layers) {
20756
20756
  layers = layers.slice();
20757
20757
  const map = /* @__PURE__ */
20758
20758
  Object.create(null);
20759
- for (let i = 0; i < layers.length; i++) {
20760
- map[layers[i].id] = layers[i];
20759
+ for (const layer of layers) {
20760
+ map[layer.id] = layer;
20761
20761
  }
20762
20762
  for (let i = 0; i < layers.length; i++) {
20763
- if ('ref' in layers[i]) {
20764
- layers[i] = deref(layers[i], map[layers[i].ref]);
20763
+ const layer = layers[i];
20764
+ if (layer && 'ref' in layer) {
20765
+ const parent = map[layer.ref];
20766
+ if (parent)
20767
+ layers[i] = deref(layer, parent);
20765
20768
  }
20766
20769
  }
20767
20770
  return layers;
@@ -22956,1086 +22959,137 @@ function sortErrors(errors) {
22956
22959
  return errors.slice().sort((a, b) => a.line && b.line ? a.line - b.line : 0);
22957
22960
  }
22958
22961
 
22959
- function commonjsRequire(path) {
22960
- throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
22961
- }
22962
-
22963
- var jsonlint$1 = {};
22964
-
22965
- /* parser generated by jison 0.4.15 */
22966
-
22967
- var hasRequiredJsonlint;
22968
-
22969
- function requireJsonlint () {
22970
- if (hasRequiredJsonlint) return jsonlint$1;
22971
- hasRequiredJsonlint = 1;
22972
- (function (exports$1) {
22973
- /*
22974
- Returns a Parser object of the following structure:
22975
-
22976
- Parser: {
22977
- yy: {}
22978
- }
22979
-
22980
- Parser.prototype: {
22981
- yy: {},
22982
- trace: function(),
22983
- symbols_: {associative list: name ==> number},
22984
- terminals_: {associative list: number ==> name},
22985
- productions_: [...],
22986
- performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
22987
- table: [...],
22988
- defaultActions: {...},
22989
- parseError: function(str, hash),
22990
- parse: function(input),
22991
-
22992
- lexer: {
22993
- EOF: 1,
22994
- parseError: function(str, hash),
22995
- setInput: function(input),
22996
- input: function(),
22997
- unput: function(str),
22998
- more: function(),
22999
- less: function(n),
23000
- pastInput: function(),
23001
- upcomingInput: function(),
23002
- showPosition: function(),
23003
- test_match: function(regex_match_array, rule_index),
23004
- next: function(),
23005
- lex: function(),
23006
- begin: function(condition),
23007
- popState: function(),
23008
- _currentRules: function(),
23009
- topState: function(),
23010
- pushState: function(condition),
23011
-
23012
- options: {
23013
- ranges: boolean (optional: true ==> token location info will include a .range[] member)
23014
- flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
23015
- backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
23016
- },
23017
-
23018
- performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
23019
- rules: [...],
23020
- conditions: {associative list: name ==> set},
23021
- }
23022
- }
23023
-
23024
-
23025
- token location info (@$, _$, etc.): {
23026
- first_line: n,
23027
- last_line: n,
23028
- first_column: n,
23029
- last_column: n,
23030
- range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
23031
- }
23032
-
23033
-
23034
- the parseError function receives a 'hash' object with these members for lexer and parser errors: {
23035
- text: (matched text)
23036
- token: (the produced terminal token, if any)
23037
- line: (yylineno)
23038
- }
23039
- while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
23040
- loc: (yylloc)
23041
- expected: (string describing the set of expected tokens)
23042
- recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
23043
- }
23044
- */
23045
- var parser = (function () {
23046
- var o = function (k, v, o, l) {
23047
- for (o = o || {}, l = k.length; l--; o[k[l]] = v);
23048
- return o;
23049
- }, $V0 = [
23050
- 1,
23051
- 12
23052
- ], $V1 = [
23053
- 1,
23054
- 13
23055
- ], $V2 = [
23056
- 1,
23057
- 9
23058
- ], $V3 = [
23059
- 1,
23060
- 10
23061
- ], $V4 = [
23062
- 1,
23063
- 11
23064
- ], $V5 = [
23065
- 1,
23066
- 14
23067
- ], $V6 = [
23068
- 1,
23069
- 15
23070
- ], $V7 = [
23071
- 14,
23072
- 18,
23073
- 22,
23074
- 24
23075
- ], $V8 = [
23076
- 18,
23077
- 22
23078
- ], $V9 = [
23079
- 22,
23080
- 24
23081
- ];
23082
- var parser = {
23083
- trace: function trace() {
23084
- },
23085
- yy: {},
23086
- symbols_: {
23087
- 'error': 2,
23088
- 'JSONString': 3,
23089
- 'STRING': 4,
23090
- 'JSONNumber': 5,
23091
- 'NUMBER': 6,
23092
- 'JSONNullLiteral': 7,
23093
- 'NULL': 8,
23094
- 'JSONBooleanLiteral': 9,
23095
- 'TRUE': 10,
23096
- 'FALSE': 11,
23097
- 'JSONText': 12,
23098
- 'JSONValue': 13,
23099
- 'EOF': 14,
23100
- 'JSONObject': 15,
23101
- 'JSONArray': 16,
23102
- '{': 17,
23103
- '}': 18,
23104
- 'JSONMemberList': 19,
23105
- 'JSONMember': 20,
23106
- ':': 21,
23107
- ',': 22,
23108
- '[': 23,
23109
- ']': 24,
23110
- 'JSONElementList': 25,
23111
- '$accept': 0,
23112
- '$end': 1
23113
- },
23114
- terminals_: {
23115
- 2: 'error',
23116
- 4: 'STRING',
23117
- 6: 'NUMBER',
23118
- 8: 'NULL',
23119
- 10: 'TRUE',
23120
- 11: 'FALSE',
23121
- 14: 'EOF',
23122
- 17: '{',
23123
- 18: '}',
23124
- 21: ':',
23125
- 22: ',',
23126
- 23: '[',
23127
- 24: ']'
23128
- },
23129
- productions_: [
23130
- 0,
23131
- [
23132
- 3,
23133
- 1
23134
- ],
23135
- [
23136
- 5,
23137
- 1
23138
- ],
23139
- [
23140
- 7,
23141
- 1
23142
- ],
23143
- [
23144
- 9,
23145
- 1
23146
- ],
23147
- [
23148
- 9,
23149
- 1
23150
- ],
23151
- [
23152
- 12,
23153
- 2
23154
- ],
23155
- [
23156
- 13,
23157
- 1
23158
- ],
23159
- [
23160
- 13,
23161
- 1
23162
- ],
23163
- [
23164
- 13,
23165
- 1
23166
- ],
23167
- [
23168
- 13,
23169
- 1
23170
- ],
23171
- [
23172
- 13,
23173
- 1
23174
- ],
23175
- [
23176
- 13,
23177
- 1
23178
- ],
23179
- [
23180
- 15,
23181
- 2
23182
- ],
23183
- [
23184
- 15,
23185
- 3
23186
- ],
23187
- [
23188
- 20,
23189
- 3
23190
- ],
23191
- [
23192
- 19,
23193
- 1
23194
- ],
23195
- [
23196
- 19,
23197
- 3
23198
- ],
23199
- [
23200
- 16,
23201
- 2
23202
- ],
23203
- [
23204
- 16,
23205
- 3
23206
- ],
23207
- [
23208
- 25,
23209
- 1
23210
- ],
23211
- [
23212
- 25,
23213
- 3
23214
- ]
23215
- ],
23216
- performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
23217
- /* this == yyval */
23218
- var $0 = $$.length - 1;
23219
- switch (yystate) {
23220
- case 1:
23221
- // replace escaped characters with actual character
23222
- this.$ = new String(yytext.replace(/\\(\\|")/g, '$' + '1').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\t/g, '\t').replace(/\\v/g, '\x0B').replace(/\\f/g, '\f').replace(/\\b/g, '\b'));
23223
- this.$.__line__ = this._$.first_line;
23224
- break;
23225
- case 2:
23226
- this.$ = new Number(yytext);
23227
- this.$.__line__ = this._$.first_line;
23228
- break;
23229
- case 3:
23230
- this.$ = null;
23231
- break;
23232
- case 4:
23233
- this.$ = new Boolean(true);
23234
- this.$.__line__ = this._$.first_line;
23235
- break;
23236
- case 5:
23237
- this.$ = new Boolean(false);
23238
- this.$.__line__ = this._$.first_line;
23239
- break;
23240
- case 6:
23241
- return this.$ = $$[$0 - 1];
23242
- case 13:
23243
- this.$ = {};
23244
- Object.defineProperty(this.$, '__line__', {
23245
- value: this._$.first_line,
23246
- enumerable: false
23247
- });
23248
- break;
23249
- case 14:
23250
- case 19:
23251
- this.$ = $$[$0 - 1];
23252
- Object.defineProperty(this.$, '__line__', {
23253
- value: this._$.first_line,
23254
- enumerable: false
23255
- });
23256
- break;
23257
- case 15:
23258
- this.$ = [
23259
- $$[$0 - 2],
23260
- $$[$0]
23261
- ];
23262
- break;
23263
- case 16:
23264
- this.$ = {};
23265
- this.$[$$[$0][0]] = $$[$0][1];
23266
- break;
23267
- case 17:
23268
- this.$ = $$[$0 - 2];
23269
- $$[$0 - 2][$$[$0][0]] = $$[$0][1];
23270
- break;
23271
- case 18:
23272
- this.$ = [];
23273
- Object.defineProperty(this.$, '__line__', {
23274
- value: this._$.first_line,
23275
- enumerable: false
23276
- });
23277
- break;
23278
- case 20:
23279
- this.$ = [$$[$0]];
23280
- break;
23281
- case 21:
23282
- this.$ = $$[$0 - 2];
23283
- $$[$0 - 2].push($$[$0]);
23284
- break;
23285
- }
23286
- },
23287
- table: [
23288
- {
23289
- 3: 5,
23290
- 4: $V0,
23291
- 5: 6,
23292
- 6: $V1,
23293
- 7: 3,
23294
- 8: $V2,
23295
- 9: 4,
23296
- 10: $V3,
23297
- 11: $V4,
23298
- 12: 1,
23299
- 13: 2,
23300
- 15: 7,
23301
- 16: 8,
23302
- 17: $V5,
23303
- 23: $V6
23304
- },
23305
- { 1: [3] },
23306
- {
23307
- 14: [
23308
- 1,
23309
- 16
23310
- ]
23311
- },
23312
- o($V7, [
23313
- 2,
23314
- 7
23315
- ]),
23316
- o($V7, [
23317
- 2,
23318
- 8
23319
- ]),
23320
- o($V7, [
23321
- 2,
23322
- 9
23323
- ]),
23324
- o($V7, [
23325
- 2,
23326
- 10
23327
- ]),
23328
- o($V7, [
23329
- 2,
23330
- 11
23331
- ]),
23332
- o($V7, [
23333
- 2,
23334
- 12
23335
- ]),
23336
- o($V7, [
23337
- 2,
23338
- 3
23339
- ]),
23340
- o($V7, [
23341
- 2,
23342
- 4
23343
- ]),
23344
- o($V7, [
23345
- 2,
23346
- 5
23347
- ]),
23348
- o([
23349
- 14,
23350
- 18,
23351
- 21,
23352
- 22,
23353
- 24
23354
- ], [
23355
- 2,
23356
- 1
23357
- ]),
23358
- o($V7, [
23359
- 2,
23360
- 2
23361
- ]),
23362
- {
23363
- 3: 20,
23364
- 4: $V0,
23365
- 18: [
23366
- 1,
23367
- 17
23368
- ],
23369
- 19: 18,
23370
- 20: 19
23371
- },
23372
- {
23373
- 3: 5,
23374
- 4: $V0,
23375
- 5: 6,
23376
- 6: $V1,
23377
- 7: 3,
23378
- 8: $V2,
23379
- 9: 4,
23380
- 10: $V3,
23381
- 11: $V4,
23382
- 13: 23,
23383
- 15: 7,
23384
- 16: 8,
23385
- 17: $V5,
23386
- 23: $V6,
23387
- 24: [
23388
- 1,
23389
- 21
23390
- ],
23391
- 25: 22
23392
- },
23393
- {
23394
- 1: [
23395
- 2,
23396
- 6
23397
- ]
23398
- },
23399
- o($V7, [
23400
- 2,
23401
- 13
23402
- ]),
23403
- {
23404
- 18: [
23405
- 1,
23406
- 24
23407
- ],
23408
- 22: [
23409
- 1,
23410
- 25
23411
- ]
23412
- },
23413
- o($V8, [
23414
- 2,
23415
- 16
23416
- ]),
23417
- {
23418
- 21: [
23419
- 1,
23420
- 26
23421
- ]
23422
- },
23423
- o($V7, [
23424
- 2,
23425
- 18
23426
- ]),
23427
- {
23428
- 22: [
23429
- 1,
23430
- 28
23431
- ],
23432
- 24: [
23433
- 1,
23434
- 27
23435
- ]
23436
- },
23437
- o($V9, [
23438
- 2,
23439
- 20
23440
- ]),
23441
- o($V7, [
23442
- 2,
23443
- 14
23444
- ]),
23445
- {
23446
- 3: 20,
23447
- 4: $V0,
23448
- 20: 29
23449
- },
23450
- {
23451
- 3: 5,
23452
- 4: $V0,
23453
- 5: 6,
23454
- 6: $V1,
23455
- 7: 3,
23456
- 8: $V2,
23457
- 9: 4,
23458
- 10: $V3,
23459
- 11: $V4,
23460
- 13: 30,
23461
- 15: 7,
23462
- 16: 8,
23463
- 17: $V5,
23464
- 23: $V6
23465
- },
23466
- o($V7, [
23467
- 2,
23468
- 19
23469
- ]),
23470
- {
23471
- 3: 5,
23472
- 4: $V0,
23473
- 5: 6,
23474
- 6: $V1,
23475
- 7: 3,
23476
- 8: $V2,
23477
- 9: 4,
23478
- 10: $V3,
23479
- 11: $V4,
23480
- 13: 31,
23481
- 15: 7,
23482
- 16: 8,
23483
- 17: $V5,
23484
- 23: $V6
23485
- },
23486
- o($V8, [
23487
- 2,
23488
- 17
23489
- ]),
23490
- o($V8, [
23491
- 2,
23492
- 15
23493
- ]),
23494
- o($V9, [
23495
- 2,
23496
- 21
23497
- ])
23498
- ],
23499
- defaultActions: {
23500
- 16: [
23501
- 2,
23502
- 6
23503
- ]
23504
- },
23505
- parseError: function parseError(str, hash) {
23506
- if (hash.recoverable) {
23507
- this.trace(str);
23508
- } else {
23509
- throw new Error(str);
23510
- }
23511
- },
23512
- parse: function parse(input) {
23513
- var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
23514
- var args = lstack.slice.call(arguments, 1);
23515
- var lexer = Object.create(this.lexer);
23516
- var sharedState = { yy: {} };
23517
- for (var k in this.yy) {
23518
- if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
23519
- sharedState.yy[k] = this.yy[k];
23520
- }
23521
- }
23522
- lexer.setInput(input, sharedState.yy);
23523
- sharedState.yy.lexer = lexer;
23524
- sharedState.yy.parser = this;
23525
- if (typeof lexer.yylloc == 'undefined') {
23526
- lexer.yylloc = {};
23527
- }
23528
- var yyloc = lexer.yylloc;
23529
- lstack.push(yyloc);
23530
- var ranges = lexer.options && lexer.options.ranges;
23531
- if (typeof sharedState.yy.parseError === 'function') {
23532
- this.parseError = sharedState.yy.parseError;
23533
- } else {
23534
- this.parseError = Object.getPrototypeOf(this).parseError;
23535
- }
23536
- function lex() {
23537
- var token;
23538
- token = lexer.lex() || EOF;
23539
- if (typeof token !== 'number') {
23540
- token = self.symbols_[token] || token;
23541
- }
23542
- return token;
23543
- }
23544
- var symbol, state, action, r, yyval = {}, p, len, newState, expected;
23545
- while (true) {
23546
- state = stack[stack.length - 1];
23547
- if (this.defaultActions[state]) {
23548
- action = this.defaultActions[state];
23549
- } else {
23550
- if (symbol === null || typeof symbol == 'undefined') {
23551
- symbol = lex();
23552
- }
23553
- action = table[state] && table[state][symbol];
23554
- }
23555
- if (typeof action === 'undefined' || !action.length || !action[0]) {
23556
- var errStr = '';
23557
- expected = [];
23558
- for (p in table[state]) {
23559
- if (this.terminals_[p] && p > TERROR) {
23560
- expected.push('\'' + this.terminals_[p] + '\'');
23561
- }
23562
- }
23563
- if (lexer.showPosition) {
23564
- errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'';
23565
- } else {
23566
- errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'');
23567
- }
23568
- this.parseError(errStr, {
23569
- text: lexer.match,
23570
- token: this.terminals_[symbol] || symbol,
23571
- line: lexer.yylineno,
23572
- loc: yyloc,
23573
- expected: expected
23574
- });
23575
- }
23576
- if (action[0] instanceof Array && action.length > 1) {
23577
- throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
23578
- }
23579
- switch (action[0]) {
23580
- case 1:
23581
- stack.push(symbol);
23582
- vstack.push(lexer.yytext);
23583
- lstack.push(lexer.yylloc);
23584
- stack.push(action[1]);
23585
- symbol = null;
23586
- {
23587
- yyleng = lexer.yyleng;
23588
- yytext = lexer.yytext;
23589
- yylineno = lexer.yylineno;
23590
- yyloc = lexer.yylloc;
23591
- }
23592
- break;
23593
- case 2:
23594
- len = this.productions_[action[1]][1];
23595
- yyval.$ = vstack[vstack.length - len];
23596
- yyval._$ = {
23597
- first_line: lstack[lstack.length - (len || 1)].first_line,
23598
- last_line: lstack[lstack.length - 1].last_line,
23599
- first_column: lstack[lstack.length - (len || 1)].first_column,
23600
- last_column: lstack[lstack.length - 1].last_column
23601
- };
23602
- if (ranges) {
23603
- yyval._$.range = [
23604
- lstack[lstack.length - (len || 1)].range[0],
23605
- lstack[lstack.length - 1].range[1]
23606
- ];
23607
- }
23608
- r = this.performAction.apply(yyval, [
23609
- yytext,
23610
- yyleng,
23611
- yylineno,
23612
- sharedState.yy,
23613
- action[1],
23614
- vstack,
23615
- lstack
23616
- ].concat(args));
23617
- if (typeof r !== 'undefined') {
23618
- return r;
23619
- }
23620
- if (len) {
23621
- stack = stack.slice(0, -1 * len * 2);
23622
- vstack = vstack.slice(0, -1 * len);
23623
- lstack = lstack.slice(0, -1 * len);
23624
- }
23625
- stack.push(this.productions_[action[1]][0]);
23626
- vstack.push(yyval.$);
23627
- lstack.push(yyval._$);
23628
- newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
23629
- stack.push(newState);
23630
- break;
23631
- case 3:
23632
- return true;
23633
- }
23634
- }
23635
- return true;
23636
- }
23637
- };
23638
- /* generated by jison-lex 0.3.4 */
23639
- var lexer = (function () {
23640
- var lexer = {
23641
- EOF: 1,
23642
- parseError: function parseError(str, hash) {
23643
- if (this.yy.parser) {
23644
- this.yy.parser.parseError(str, hash);
23645
- } else {
23646
- throw new Error(str);
23647
- }
23648
- },
23649
- // resets the lexer, sets new input
23650
- setInput: function (input, yy) {
23651
- this.yy = yy || this.yy || {};
23652
- this._input = input;
23653
- this._more = this._backtrack = this.done = false;
23654
- this.yylineno = this.yyleng = 0;
23655
- this.yytext = this.matched = this.match = '';
23656
- this.conditionStack = ['INITIAL'];
23657
- this.yylloc = {
23658
- first_line: 1,
23659
- first_column: 0,
23660
- last_line: 1,
23661
- last_column: 0
23662
- };
23663
- if (this.options.ranges) {
23664
- this.yylloc.range = [
23665
- 0,
23666
- 0
23667
- ];
23668
- }
23669
- this.offset = 0;
23670
- return this;
23671
- },
23672
- // consumes and returns one char from the input
23673
- input: function () {
23674
- var ch = this._input[0];
23675
- this.yytext += ch;
23676
- this.yyleng++;
23677
- this.offset++;
23678
- this.match += ch;
23679
- this.matched += ch;
23680
- var lines = ch.match(/(?:\r\n?|\n).*/g);
23681
- if (lines) {
23682
- this.yylineno++;
23683
- this.yylloc.last_line++;
23684
- } else {
23685
- this.yylloc.last_column++;
23686
- }
23687
- if (this.options.ranges) {
23688
- this.yylloc.range[1]++;
23689
- }
23690
- this._input = this._input.slice(1);
23691
- return ch;
23692
- },
23693
- // unshifts one char (or a string) into the input
23694
- unput: function (ch) {
23695
- var len = ch.length;
23696
- var lines = ch.split(/(?:\r\n?|\n)/g);
23697
- this._input = ch + this._input;
23698
- this.yytext = this.yytext.substr(0, this.yytext.length - len);
23699
- //this.yyleng -= len;
23700
- this.offset -= len;
23701
- var oldLines = this.match.split(/(?:\r\n?|\n)/g);
23702
- this.match = this.match.substr(0, this.match.length - 1);
23703
- this.matched = this.matched.substr(0, this.matched.length - 1);
23704
- if (lines.length - 1) {
23705
- this.yylineno -= lines.length - 1;
23706
- }
23707
- var r = this.yylloc.range;
23708
- this.yylloc = {
23709
- first_line: this.yylloc.first_line,
23710
- last_line: this.yylineno + 1,
23711
- first_column: this.yylloc.first_column,
23712
- last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len
23713
- };
23714
- if (this.options.ranges) {
23715
- this.yylloc.range = [
23716
- r[0],
23717
- r[0] + this.yyleng - len
23718
- ];
23719
- }
23720
- this.yyleng = this.yytext.length;
23721
- return this;
23722
- },
23723
- // When called from action, caches matched text and appends it on next action
23724
- more: function () {
23725
- this._more = true;
23726
- return this;
23727
- },
23728
- // When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
23729
- reject: function () {
23730
- if (this.options.backtrack_lexer) {
23731
- this._backtrack = true;
23732
- } else {
23733
- return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
23734
- text: '',
23735
- token: null,
23736
- line: this.yylineno
23737
- });
23738
- }
23739
- return this;
23740
- },
23741
- // retain first n characters of the match
23742
- less: function (n) {
23743
- this.unput(this.match.slice(n));
23744
- },
23745
- // displays already matched input, i.e. for error messages
23746
- pastInput: function () {
23747
- var past = this.matched.substr(0, this.matched.length - this.match.length);
23748
- return (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, '');
23749
- },
23750
- // displays upcoming input, i.e. for error messages
23751
- upcomingInput: function () {
23752
- var next = this.match;
23753
- if (next.length < 20) {
23754
- next += this._input.substr(0, 20 - next.length);
23755
- }
23756
- return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\n/g, '');
23757
- },
23758
- // displays the character position where the lexing error occurred, i.e. for error messages
23759
- showPosition: function () {
23760
- var pre = this.pastInput();
23761
- var c = new Array(pre.length + 1).join('-');
23762
- return pre + this.upcomingInput() + '\n' + c + '^';
23763
- },
23764
- // test the lexed token: return FALSE when not a match, otherwise return token
23765
- test_match: function (match, indexed_rule) {
23766
- var token, lines, backup;
23767
- if (this.options.backtrack_lexer) {
23768
- // save context
23769
- backup = {
23770
- yylineno: this.yylineno,
23771
- yylloc: {
23772
- first_line: this.yylloc.first_line,
23773
- last_line: this.last_line,
23774
- first_column: this.yylloc.first_column,
23775
- last_column: this.yylloc.last_column
23776
- },
23777
- yytext: this.yytext,
23778
- match: this.match,
23779
- matches: this.matches,
23780
- matched: this.matched,
23781
- yyleng: this.yyleng,
23782
- offset: this.offset,
23783
- _more: this._more,
23784
- _input: this._input,
23785
- yy: this.yy,
23786
- conditionStack: this.conditionStack.slice(0),
23787
- done: this.done
23788
- };
23789
- if (this.options.ranges) {
23790
- backup.yylloc.range = this.yylloc.range.slice(0);
23791
- }
23792
- }
23793
- lines = match[0].match(/(?:\r\n?|\n).*/g);
23794
- if (lines) {
23795
- this.yylineno += lines.length;
23796
- }
23797
- this.yylloc = {
23798
- first_line: this.yylloc.last_line,
23799
- last_line: this.yylineno + 1,
23800
- first_column: this.yylloc.last_column,
23801
- last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
23802
- };
23803
- this.yytext += match[0];
23804
- this.match += match[0];
23805
- this.matches = match;
23806
- this.yyleng = this.yytext.length;
23807
- if (this.options.ranges) {
23808
- this.yylloc.range = [
23809
- this.offset,
23810
- this.offset += this.yyleng
23811
- ];
23812
- }
23813
- this._more = false;
23814
- this._backtrack = false;
23815
- this._input = this._input.slice(match[0].length);
23816
- this.matched += match[0];
23817
- token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
23818
- if (this.done && this._input) {
23819
- this.done = false;
23820
- }
23821
- if (token) {
23822
- return token;
23823
- } else if (this._backtrack) {
23824
- // recover context
23825
- for (var k in backup) {
23826
- this[k] = backup[k];
23827
- }
23828
- return false; // rule action called reject() implying the next rule should be tested instead.
23829
- }
23830
- return false;
23831
- },
23832
- // return next match in input
23833
- next: function () {
23834
- if (this.done) {
23835
- return this.EOF;
23836
- }
23837
- if (!this._input) {
23838
- this.done = true;
23839
- }
23840
- var token, match, tempMatch, index;
23841
- if (!this._more) {
23842
- this.yytext = '';
23843
- this.match = '';
23844
- }
23845
- var rules = this._currentRules();
23846
- for (var i = 0; i < rules.length; i++) {
23847
- tempMatch = this._input.match(this.rules[rules[i]]);
23848
- if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
23849
- match = tempMatch;
23850
- index = i;
23851
- if (this.options.backtrack_lexer) {
23852
- token = this.test_match(tempMatch, rules[i]);
23853
- if (token !== false) {
23854
- return token;
23855
- } else if (this._backtrack) {
23856
- match = false;
23857
- continue; // rule action called reject() implying a rule MISmatch.
23858
- } else {
23859
- // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
23860
- return false;
23861
- }
23862
- } else if (!this.options.flex) {
23863
- break;
23864
- }
23865
- }
23866
- }
23867
- if (match) {
23868
- token = this.test_match(match, rules[index]);
23869
- if (token !== false) {
23870
- return token;
23871
- }
23872
- // else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
23873
- return false;
23874
- }
23875
- if (this._input === '') {
23876
- return this.EOF;
23877
- } else {
23878
- return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
23879
- text: '',
23880
- token: null,
23881
- line: this.yylineno
23882
- });
23883
- }
23884
- },
23885
- // return next match that has a token
23886
- lex: function lex() {
23887
- var r = this.next();
23888
- if (r) {
23889
- return r;
23890
- } else {
23891
- return this.lex();
23892
- }
23893
- },
23894
- // activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
23895
- begin: function begin(condition) {
23896
- this.conditionStack.push(condition);
23897
- },
23898
- // pop the previously active lexer condition state off the condition stack
23899
- popState: function popState() {
23900
- var n = this.conditionStack.length - 1;
23901
- if (n > 0) {
23902
- return this.conditionStack.pop();
23903
- } else {
23904
- return this.conditionStack[0];
23905
- }
23906
- },
23907
- // produce the lexer rule set which is active for the currently active lexer condition state
23908
- _currentRules: function _currentRules() {
23909
- if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
23910
- return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
23911
- } else {
23912
- return this.conditions['INITIAL'].rules;
23913
- }
23914
- },
23915
- // return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
23916
- topState: function topState(n) {
23917
- n = this.conditionStack.length - 1 - Math.abs(n || 0);
23918
- if (n >= 0) {
23919
- return this.conditionStack[n];
23920
- } else {
23921
- return 'INITIAL';
23922
- }
23923
- },
23924
- // alias for begin(condition)
23925
- pushState: function pushState(condition) {
23926
- this.begin(condition);
23927
- },
23928
- // return the number of states currently on the stack
23929
- stateStackSize: function stateStackSize() {
23930
- return this.conditionStack.length;
23931
- },
23932
- options: {},
23933
- performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
23934
- switch ($avoiding_name_collisions) {
23935
- case 0:
23936
- /* skip whitespace */
23937
- break;
23938
- case 1:
23939
- return 6;
23940
- case 2:
23941
- yy_.yytext = yy_.yytext.substr(1, yy_.yyleng - 2);
23942
- return 4;
23943
- case 3:
23944
- return 17;
23945
- case 4:
23946
- return 18;
23947
- case 5:
23948
- return 23;
23949
- case 6:
23950
- return 24;
23951
- case 7:
23952
- return 22;
23953
- case 8:
23954
- return 21;
23955
- case 9:
23956
- return 10;
23957
- case 10:
23958
- return 11;
23959
- case 11:
23960
- return 8;
23961
- case 12:
23962
- return 14;
23963
- case 13:
23964
- return 'INVALID';
23965
- }
23966
- },
23967
- rules: [
23968
- /^(?:\s+)/,
23969
- /^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/,
23970
- /^(?:"(?:\\[\\"bfnrt/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/,
23971
- /^(?:\{)/,
23972
- /^(?:\})/,
23973
- /^(?:\[)/,
23974
- /^(?:\])/,
23975
- /^(?:,)/,
23976
- /^(?::)/,
23977
- /^(?:true\b)/,
23978
- /^(?:false\b)/,
23979
- /^(?:null\b)/,
23980
- /^(?:$)/,
23981
- /^(?:.)/
23982
- ],
23983
- conditions: {
23984
- 'INITIAL': {
23985
- 'rules': [
23986
- 0,
23987
- 1,
23988
- 2,
23989
- 3,
23990
- 4,
23991
- 5,
23992
- 6,
23993
- 7,
23994
- 8,
23995
- 9,
23996
- 10,
23997
- 11,
23998
- 12,
23999
- 13
24000
- ],
24001
- 'inclusive': true
24002
- }
24003
- }
24004
- };
24005
- return lexer;
24006
- }());
24007
- parser.lexer = lexer;
24008
- function Parser() {
24009
- this.yy = {};
24010
- }
24011
- Parser.prototype = parser;
24012
- parser.Parser = Parser;
24013
- return new Parser();
24014
- }());
24015
- if (typeof commonjsRequire !== 'undefined' && 'object' !== 'undefined') {
24016
- exports$1.parser = parser;
24017
- exports$1.Parser = parser.Parser;
24018
- exports$1.parse = function () {
24019
- return parser.parse.apply(parser, arguments);
24020
- };
24021
- }
24022
- } (jsonlint$1));
24023
- return jsonlint$1;
24024
- }
24025
-
24026
- var jsonlintExports = requireJsonlint();
24027
- var jsonlint = /*@__PURE__*/getDefaultExportFromCjs(jsonlintExports);
24028
-
24029
22962
  function readStyle(style) {
24030
22963
  if (style instanceof String || typeof style === 'string' || ArrayBuffer.isView(style)) {
24031
22964
  try {
24032
- return jsonlint.parse(style.toString());
22965
+ const str = style.toString();
22966
+ JSON.parse(str);
22967
+ return parse(str);
24033
22968
  } catch (e) {
24034
22969
  throw new ParsingError(e);
24035
22970
  }
24036
22971
  }
24037
22972
  return style;
24038
22973
  }
22974
+ const LBRACE = 0;
22975
+ const RBRACE = 1;
22976
+ const LBRACKET = 2;
22977
+ const RBRACKET = 3;
22978
+ const STRING = 4;
22979
+ const NUMBER = 5;
22980
+ const TRUE = 6;
22981
+ const FALSE = 7;
22982
+ const NULL = 8;
22983
+ function tokenize(s) {
22984
+ const tokens = [];
22985
+ let pos = 0;
22986
+ const len = s.length;
22987
+ while (pos < len) {
22988
+ const c = s.charCodeAt(pos);
22989
+ if (c === 32 || c === 9 || c === 10 || c === 13 || c === 58 || c === 44) {
22990
+ pos++;
22991
+ continue;
22992
+ }
22993
+ const start = pos;
22994
+ if (c === 123)
22995
+ tokens.push(LBRACE, start, ++pos);
22996
+ else if (c === 125)
22997
+ tokens.push(RBRACE, start, ++pos);
22998
+ else if (c === 91)
22999
+ tokens.push(LBRACKET, start, ++pos);
23000
+ else if (c === 93)
23001
+ tokens.push(RBRACKET, start, ++pos);
23002
+ else if (c === 34) {
23003
+ pos++;
23004
+ while (pos < len) {
23005
+ const ch = s.charCodeAt(pos);
23006
+ if (ch === 92)
23007
+ pos += s.charCodeAt(pos + 1) === 117 ? 6 : 2;
23008
+ else if (ch === 34)
23009
+ break;
23010
+ else
23011
+ pos++;
23012
+ }
23013
+ tokens.push(STRING, start, ++pos);
23014
+ } else if (c === 116)
23015
+ tokens.push(TRUE, start, pos += 4);
23016
+ else if (c === 102)
23017
+ tokens.push(FALSE, start, pos += 5);
23018
+ else if (c === 110)
23019
+ tokens.push(NULL, start, pos += 4);
23020
+ else {
23021
+ while (pos < len) {
23022
+ const ch = s.charCodeAt(pos);
23023
+ if (ch >= 48 && ch <= 57 || ch === 45 || ch === 43 || ch === 46 || ch === 101 || ch === 69)
23024
+ pos++;
23025
+ else
23026
+ break;
23027
+ }
23028
+ tokens.push(NUMBER, start, pos);
23029
+ }
23030
+ }
23031
+ return tokens;
23032
+ }
23033
+ function parseTokens(s, tokens) {
23034
+ let i = 0;
23035
+ const lineOffsets = [0];
23036
+ for (let j = 0; j < s.length; j++) {
23037
+ if (s.charCodeAt(j) === 10)
23038
+ lineOffsets.push(j + 1);
23039
+ }
23040
+ function lineNum(pos) {
23041
+ let lo = 0, hi = lineOffsets.length - 1;
23042
+ while (lo < hi) {
23043
+ const mid = lo + hi + 1 >> 1;
23044
+ if (lineOffsets[mid] <= pos)
23045
+ lo = mid;
23046
+ else
23047
+ hi = mid - 1;
23048
+ }
23049
+ return lo + 1;
23050
+ }
23051
+ function setLine(obj, line) {
23052
+ Object.defineProperty(obj, '__line__', { value: line });
23053
+ return obj;
23054
+ }
23055
+ function parseValue() {
23056
+ const type = tokens[i];
23057
+ const start = tokens[i + 1];
23058
+ const end = tokens[i + 2];
23059
+ i += 3;
23060
+ const line = lineNum(start);
23061
+ if (type === LBRACE) {
23062
+ const obj = setLine({}, line);
23063
+ while (tokens[i] !== RBRACE) {
23064
+ const key = JSON.parse(s.slice(tokens[i + 1], tokens[i + 2]));
23065
+ i += 3;
23066
+ obj[key] = parseValue();
23067
+ }
23068
+ i += 3;
23069
+ return obj;
23070
+ }
23071
+ if (type === LBRACKET) {
23072
+ const arr = setLine([], line);
23073
+ while (tokens[i] !== RBRACKET)
23074
+ arr.push(parseValue());
23075
+ i += 3;
23076
+ return arr;
23077
+ }
23078
+ if (type === STRING)
23079
+ return setLine(new String(JSON.parse(s.slice(start, end))), line);
23080
+ if (type === NUMBER)
23081
+ return setLine(new Number(+s.slice(start, end)), line);
23082
+ if (type === TRUE)
23083
+ return setLine(new Boolean(true), line);
23084
+ if (type === FALSE)
23085
+ return setLine(new Boolean(false), line);
23086
+ return null;
23087
+ }
23088
+ return parseValue();
23089
+ }
23090
+ function parse(s) {
23091
+ return parseTokens(s, tokenize(s));
23092
+ }
24039
23093
 
24040
23094
  function validateStyle(style, styleSpec = v8) {
24041
23095
  let s = style;