@angular/platform-server 16.0.0-next.4 → 16.0.0-next.6

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 (50) hide show
  1. package/{fesm2020/platform-server.mjs → esm2022/src/bundled-domino.mjs} +140 -4632
  2. package/esm2022/src/http.mjs +26 -0
  3. package/{esm2020 → esm2022}/src/location.mjs +4 -4
  4. package/{esm2020 → esm2022}/src/platform_state.mjs +4 -4
  5. package/{esm2020 → esm2022}/src/server.mjs +5 -5
  6. package/esm2022/src/server_events.mjs +32 -0
  7. package/esm2022/src/server_renderer.mjs +279 -0
  8. package/{esm2020 → esm2022}/src/tokens.mjs +1 -1
  9. package/esm2022/src/transfer_state.mjs +59 -0
  10. package/esm2022/src/utils.mjs +146 -0
  11. package/{esm2020 → esm2022}/src/version.mjs +1 -1
  12. package/{esm2020 → esm2022}/testing/src/server.mjs +5 -5
  13. package/{fesm2015 → fesm2022}/init.mjs +1 -1
  14. package/{esm2020/src/bundled-domino.mjs → fesm2022/platform-server.mjs} +1065 -3732
  15. package/fesm2022/platform-server.mjs.map +1 -0
  16. package/{fesm2020 → fesm2022}/testing.mjs +5 -5
  17. package/{fesm2015 → fesm2022}/testing.mjs.map +1 -1
  18. package/index.d.ts +9 -1
  19. package/init/index.d.ts +1 -1
  20. package/package.json +19 -30
  21. package/testing/index.d.ts +1 -1
  22. package/esm2020/src/http.mjs +0 -125
  23. package/esm2020/src/server_events.mjs +0 -40
  24. package/esm2020/src/server_renderer.mjs +0 -282
  25. package/esm2020/src/transfer_state.mjs +0 -60
  26. package/esm2020/src/utils.mjs +0 -145
  27. package/fesm2015/platform-server.mjs +0 -21143
  28. package/fesm2015/platform-server.mjs.map +0 -1
  29. package/fesm2015/testing.mjs +0 -58
  30. package/fesm2020/init.mjs +0 -35
  31. package/fesm2020/init.mjs.map +0 -1
  32. package/fesm2020/platform-server.mjs.map +0 -1
  33. package/fesm2020/testing.mjs.map +0 -1
  34. /package/{esm2020 → esm2022}/index.mjs +0 -0
  35. /package/{esm2020 → esm2022}/init/index.mjs +0 -0
  36. /package/{esm2020 → esm2022}/init/init.mjs +0 -0
  37. /package/{esm2020 → esm2022}/init/public_api.mjs +0 -0
  38. /package/{esm2020 → esm2022}/init/src/init.mjs +0 -0
  39. /package/{esm2020 → esm2022}/init/src/shims.mjs +0 -0
  40. /package/{esm2020 → esm2022}/platform-server.mjs +0 -0
  41. /package/{esm2020 → esm2022}/public_api.mjs +0 -0
  42. /package/{esm2020 → esm2022}/src/domino_adapter.mjs +0 -0
  43. /package/{esm2020 → esm2022}/src/platform-server.mjs +0 -0
  44. /package/{esm2020 → esm2022}/src/private_export.mjs +0 -0
  45. /package/{esm2020 → esm2022}/src/provide_server.mjs +0 -0
  46. /package/{esm2020 → esm2022}/testing/index.mjs +0 -0
  47. /package/{esm2020 → esm2022}/testing/public_api.mjs +0 -0
  48. /package/{esm2020 → esm2022}/testing/src/testing.mjs +0 -0
  49. /package/{esm2020 → esm2022}/testing/testing.mjs +0 -0
  50. /package/{fesm2015 → fesm2022}/init.mjs.map +0 -0
@@ -1,3 +1,24 @@
1
+ /**
2
+ * @license Angular v16.0.0-next.6
3
+ * (c) 2010-2022 Google LLC. https://angular.io/
4
+ * License: MIT
5
+ */
6
+
7
+ import { ɵsetRootDomAdapter, DOCUMENT, XhrFactory, ɵgetDOM, ɵPLATFORM_SERVER_ID, PlatformLocation, ViewportScroller, ɵNullViewportScroller } from '@angular/common';
8
+ import * as i0 from '@angular/core';
9
+ import { Injectable, Inject, InjectionToken, Optional, ViewEncapsulation, APP_ID, RendererStyleFlags2, TransferState, ɵescapeTransferStateContent, NgModule, Injector, PLATFORM_ID, PLATFORM_INITIALIZER, ɵALLOW_MULTIPLE_PLATFORMS, RendererFactory2, NgZone, Testability, ɵTESTABILITY, ɵsetDocument, createPlatformFactory, platformCore, makeEnvironmentProviders, Renderer2, ApplicationRef, ɵInitialRenderPendingTasks, ɵIS_HYDRATION_FEATURE_ENABLED, ɵannotateForHydration, ɵisPromise, Version } from '@angular/core';
10
+ import * as i1 from '@angular/platform-browser';
11
+ import { ɵBrowserDomAdapter, ɵshimStyles, ɵNAMESPACE_URIS, ɵshimContentAttribute, ɵshimHostAttribute, EVENT_MANAGER_PLUGINS, BrowserModule } from '@angular/platform-browser';
12
+ import { HttpClientModule, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
13
+ import { ɵAnimationRendererFactory, NoopAnimationsModule, provideNoopAnimations } from '@angular/platform-browser/animations';
14
+ import { ɵAnimationEngine } from '@angular/animations/browser';
15
+ import { ɵplatformCoreDynamic } from '@angular/platform-browser-dynamic';
16
+ import * as xhr2 from 'xhr2';
17
+ import { Subject } from 'rxjs';
18
+ import * as url from 'url';
19
+ import { DomElementSchemaRegistry } from '@angular/compiler';
20
+ import { first } from 'rxjs/operators';
21
+
1
22
  var __getOwnPropNames = Object.getOwnPropertyNames;
2
23
  var __commonJS = (cb, mod) => function __require() {
3
24
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
@@ -876,6 +897,13 @@ var require_Node = __commonJS({
876
897
  set: function(v) {
877
898
  }
878
899
  },
900
+ innerText: {
901
+ get: function() {
902
+ return null;
903
+ },
904
+ set: function(v) {
905
+ }
906
+ },
879
907
  _countChildrenOfType: { value: function(type) {
880
908
  var sum = 0;
881
909
  for (var kid = this.firstChild; kid !== null; kid = kid.nextSibling) {
@@ -2903,6 +2931,19 @@ var require_Element = __commonJS({
2903
2931
  }
2904
2932
  }
2905
2933
  },
2934
+ innerText: {
2935
+ get: function() {
2936
+ var strings = [];
2937
+ recursiveGetText(this, strings);
2938
+ return strings.join("").replace(/[ \t\n\f\r]+/g, " ").trim();
2939
+ },
2940
+ set: function(newtext) {
2941
+ this.removeChildren();
2942
+ if (newtext !== null && newtext !== void 0 && newtext !== "") {
2943
+ this._appendChild(this.ownerDocument.createTextNode(newtext));
2944
+ }
2945
+ }
2946
+ },
2906
2947
  innerHTML: {
2907
2948
  get: function() {
2908
2949
  return this.serialize();
@@ -3606,6 +3647,17 @@ var require_Element = __commonJS({
3606
3647
  }
3607
3648
  this.value = v;
3608
3649
  }
3650
+ },
3651
+ innerText: {
3652
+ get: function() {
3653
+ return this.value;
3654
+ },
3655
+ set: function(v) {
3656
+ if (v === null || v === void 0) {
3657
+ v = "";
3658
+ }
3659
+ this.value = v;
3660
+ }
3609
3661
  }
3610
3662
  });
3611
3663
  Element._Attr = Attr;
@@ -3873,6 +3925,7 @@ var require_Text = __commonJS({
3873
3925
  nodeName: { value: "#text" },
3874
3926
  nodeValue,
3875
3927
  textContent: nodeValue,
3928
+ innerText: nodeValue,
3876
3929
  data: {
3877
3930
  get: nodeValue.get,
3878
3931
  set: function(v) {
@@ -3939,6 +3992,7 @@ var require_Comment = __commonJS({
3939
3992
  nodeName: { value: "#comment" },
3940
3993
  nodeValue,
3941
3994
  textContent: nodeValue,
3995
+ innerText: nodeValue,
3942
3996
  data: {
3943
3997
  get: nodeValue.get,
3944
3998
  set: function(v) {
@@ -3978,6 +4032,7 @@ var require_DocumentFragment = __commonJS({
3978
4032
  }
3979
4033
  },
3980
4034
  textContent: Object.getOwnPropertyDescriptor(Element.prototype, "textContent"),
4035
+ innerText: Object.getOwnPropertyDescriptor(Element.prototype, "innerText"),
3981
4036
  querySelector: { value: function(selector) {
3982
4037
  var nodes = this.querySelectorAll(selector);
3983
4038
  return nodes.length ? nodes[0] : null;
@@ -4047,6 +4102,7 @@ var require_ProcessingInstruction = __commonJS({
4047
4102
  } },
4048
4103
  nodeValue,
4049
4104
  textContent: nodeValue,
4105
+ innerText: nodeValue,
4050
4106
  data: {
4051
4107
  get: nodeValue.get,
4052
4108
  set: function(v) {
@@ -4649,3715 +4705,162 @@ var require_URL = __commonJS({
4649
4705
  if (!r.path) {
4650
4706
  t.path = base.path;
4651
4707
  if (r.query !== void 0)
4652
- t.query = r.query;
4653
- else
4654
- t.query = base.query;
4655
- } else {
4656
- if (r.path.charAt(0) === "/") {
4657
- t.path = remove_dot_segments(r.path);
4658
- } else {
4659
- t.path = merge(base.path, r.path);
4660
- t.path = remove_dot_segments(t.path);
4661
- }
4662
- t.query = r.query;
4663
- }
4664
- }
4665
- }
4666
- t.fragment = r.fragment;
4667
- return t.toString();
4668
- function merge(basepath, refpath) {
4669
- if (base.host !== void 0 && !base.path)
4670
- return "/" + refpath;
4671
- var lastslash = basepath.lastIndexOf("/");
4672
- if (lastslash === -1)
4673
- return refpath;
4674
- else
4675
- return basepath.substring(0, lastslash + 1) + refpath;
4676
- }
4677
- function remove_dot_segments(path) {
4678
- if (!path)
4679
- return path;
4680
- var output = "";
4681
- while (path.length > 0) {
4682
- if (path === "." || path === "..") {
4683
- path = "";
4684
- break;
4685
- }
4686
- var twochars = path.substring(0, 2);
4687
- var threechars = path.substring(0, 3);
4688
- var fourchars = path.substring(0, 4);
4689
- if (threechars === "../") {
4690
- path = path.substring(3);
4691
- } else if (twochars === "./") {
4692
- path = path.substring(2);
4693
- } else if (threechars === "/./") {
4694
- path = "/" + path.substring(3);
4695
- } else if (twochars === "/." && path.length === 2) {
4696
- path = "/";
4697
- } else if (fourchars === "/../" || threechars === "/.." && path.length === 3) {
4698
- path = "/" + path.substring(4);
4699
- output = output.replace(/\/?[^\/]*$/, "");
4700
- } else {
4701
- var segment = path.match(/(\/?([^\/]*))/)[0];
4702
- output += segment;
4703
- path = path.substring(segment.length);
4704
- }
4705
- }
4706
- return output;
4707
- }
4708
- }
4709
- };
4710
- }
4711
- });
4712
-
4713
- // external/npm/node_modules/domino/lib/CustomEvent.js
4714
- var require_CustomEvent = __commonJS({
4715
- "external/npm/node_modules/domino/lib/CustomEvent.js"(exports, module) {
4716
- "use strict";
4717
- module.exports = CustomEvent;
4718
- var Event = require_Event();
4719
- function CustomEvent(type, dictionary) {
4720
- Event.call(this, type, dictionary);
4721
- }
4722
- CustomEvent.prototype = Object.create(Event.prototype, {
4723
- constructor: { value: CustomEvent }
4724
- });
4725
- }
4726
- });
4727
-
4728
- // external/npm/node_modules/domino/lib/events.js
4729
- var require_events = __commonJS({
4730
- "external/npm/node_modules/domino/lib/events.js"(exports, module) {
4731
- "use strict";
4732
- module.exports = {
4733
- Event: require_Event(),
4734
- UIEvent: require_UIEvent(),
4735
- MouseEvent: require_MouseEvent(),
4736
- CustomEvent: require_CustomEvent()
4737
- };
4738
- }
4739
- });
4740
-
4741
- // external/npm/node_modules/domino/lib/cssparser.js
4742
- var require_cssparser = __commonJS({
4743
- "external/npm/node_modules/domino/lib/cssparser.js"(exports) {
4744
- "use strict";
4745
- var parserlib = /* @__PURE__ */ Object.create(null);
4746
- (function() {
4747
- function EventTarget() {
4748
- this._listeners = /* @__PURE__ */ Object.create(null);
4749
- }
4750
- EventTarget.prototype = {
4751
- constructor: EventTarget,
4752
- addListener: function(type, listener) {
4753
- if (!this._listeners[type]) {
4754
- this._listeners[type] = [];
4755
- }
4756
- this._listeners[type].push(listener);
4757
- },
4758
- fire: function(event) {
4759
- if (typeof event === "string") {
4760
- event = { type: event };
4761
- }
4762
- if (typeof event.target !== "undefined") {
4763
- event.target = this;
4764
- }
4765
- if (typeof event.type === "undefined") {
4766
- throw new Error("Event object missing 'type' property.");
4767
- }
4768
- if (this._listeners[event.type]) {
4769
- var listeners = this._listeners[event.type].concat();
4770
- for (var i = 0, len = listeners.length; i < len; i++) {
4771
- listeners[i].call(this, event);
4772
- }
4773
- }
4774
- },
4775
- removeListener: function(type, listener) {
4776
- if (this._listeners[type]) {
4777
- var listeners = this._listeners[type];
4778
- for (var i = 0, len = listeners.length; i < len; i++) {
4779
- if (listeners[i] === listener) {
4780
- listeners.splice(i, 1);
4781
- break;
4782
- }
4783
- }
4784
- }
4785
- }
4786
- };
4787
- function StringReader(text) {
4788
- this._input = text.replace(/(\r|\n){1,2}/g, "\n");
4789
- this._line = 1;
4790
- this._col = 1;
4791
- this._cursor = 0;
4792
- }
4793
- StringReader.prototype = {
4794
- constructor: StringReader,
4795
- getCol: function() {
4796
- return this._col;
4797
- },
4798
- getLine: function() {
4799
- return this._line;
4800
- },
4801
- eof: function() {
4802
- return this._cursor === this._input.length;
4803
- },
4804
- peek: function(count) {
4805
- var c = null;
4806
- count = typeof count === "undefined" ? 1 : count;
4807
- if (this._cursor < this._input.length) {
4808
- c = this._input.charAt(this._cursor + count - 1);
4809
- }
4810
- return c;
4811
- },
4812
- read: function() {
4813
- var c = null;
4814
- if (this._cursor < this._input.length) {
4815
- if (this._input.charAt(this._cursor) === "\n") {
4816
- this._line++;
4817
- this._col = 1;
4818
- } else {
4819
- this._col++;
4820
- }
4821
- c = this._input.charAt(this._cursor++);
4822
- }
4823
- return c;
4824
- },
4825
- mark: function() {
4826
- this._bookmark = {
4827
- cursor: this._cursor,
4828
- line: this._line,
4829
- col: this._col
4830
- };
4831
- },
4832
- reset: function() {
4833
- if (this._bookmark) {
4834
- this._cursor = this._bookmark.cursor;
4835
- this._line = this._bookmark.line;
4836
- this._col = this._bookmark.col;
4837
- delete this._bookmark;
4838
- }
4839
- },
4840
- readTo: function(pattern) {
4841
- var buffer = "", c;
4842
- while (buffer.length < pattern.length || buffer.lastIndexOf(pattern) !== buffer.length - pattern.length) {
4843
- c = this.read();
4844
- if (c) {
4845
- buffer += c;
4846
- } else {
4847
- throw new Error('Expected "' + pattern + '" at line ' + this._line + ", col " + this._col + ".");
4848
- }
4849
- }
4850
- return buffer;
4851
- },
4852
- readWhile: function(filter) {
4853
- var buffer = "", c = this.read();
4854
- while (c !== null && filter(c)) {
4855
- buffer += c;
4856
- c = this.read();
4857
- }
4858
- return buffer;
4859
- },
4860
- readMatch: function(matcher) {
4861
- var source = this._input.substring(this._cursor), value = null;
4862
- if (typeof matcher === "string") {
4863
- if (source.indexOf(matcher) === 0) {
4864
- value = this.readCount(matcher.length);
4865
- }
4866
- } else if (matcher instanceof RegExp) {
4867
- if (matcher.test(source)) {
4868
- value = this.readCount(RegExp.lastMatch.length);
4869
- }
4870
- }
4871
- return value;
4872
- },
4873
- readCount: function(count) {
4874
- var buffer = "";
4875
- while (count--) {
4876
- buffer += this.read();
4877
- }
4878
- return buffer;
4879
- }
4880
- };
4881
- function SyntaxError2(message, line, col) {
4882
- Error.call(this);
4883
- this.name = this.constructor.name;
4884
- this.col = col;
4885
- this.line = line;
4886
- this.message = message;
4887
- }
4888
- SyntaxError2.prototype = Object.create(Error.prototype);
4889
- SyntaxError2.prototype.constructor = SyntaxError2;
4890
- function SyntaxUnit(text, line, col, type) {
4891
- this.col = col;
4892
- this.line = line;
4893
- this.text = text;
4894
- this.type = type;
4895
- }
4896
- SyntaxUnit.fromToken = function(token) {
4897
- return new SyntaxUnit(token.value, token.startLine, token.startCol);
4898
- };
4899
- SyntaxUnit.prototype = {
4900
- constructor: SyntaxUnit,
4901
- valueOf: function() {
4902
- return this.toString();
4903
- },
4904
- toString: function() {
4905
- return this.text;
4906
- }
4907
- };
4908
- function TokenStreamBase(input, tokenData) {
4909
- this._reader = input ? new StringReader(input.toString()) : null;
4910
- this._token = null;
4911
- this._tokenData = tokenData;
4912
- this._lt = [];
4913
- this._ltIndex = 0;
4914
- this._ltIndexCache = [];
4915
- }
4916
- TokenStreamBase.createTokenData = function(tokens) {
4917
- var nameMap = [], typeMap = /* @__PURE__ */ Object.create(null), tokenData = tokens.concat([]), i = 0, len = tokenData.length + 1;
4918
- tokenData.UNKNOWN = -1;
4919
- tokenData.unshift({ name: "EOF" });
4920
- for (; i < len; i++) {
4921
- nameMap.push(tokenData[i].name);
4922
- tokenData[tokenData[i].name] = i;
4923
- if (tokenData[i].text) {
4924
- typeMap[tokenData[i].text] = i;
4925
- }
4926
- }
4927
- tokenData.name = function(tt) {
4928
- return nameMap[tt];
4929
- };
4930
- tokenData.type = function(c) {
4931
- return typeMap[c];
4932
- };
4933
- return tokenData;
4934
- };
4935
- TokenStreamBase.prototype = {
4936
- constructor: TokenStreamBase,
4937
- match: function(tokenTypes, channel) {
4938
- if (!(tokenTypes instanceof Array)) {
4939
- tokenTypes = [tokenTypes];
4940
- }
4941
- var tt = this.get(channel), i = 0, len = tokenTypes.length;
4942
- while (i < len) {
4943
- if (tt === tokenTypes[i++]) {
4944
- return true;
4945
- }
4946
- }
4947
- this.unget();
4948
- return false;
4949
- },
4950
- mustMatch: function(tokenTypes, channel) {
4951
- var token;
4952
- if (!(tokenTypes instanceof Array)) {
4953
- tokenTypes = [tokenTypes];
4954
- }
4955
- if (!this.match.apply(this, arguments)) {
4956
- token = this.LT(1);
4957
- throw new SyntaxError2("Expected " + this._tokenData[tokenTypes[0]].name + " at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
4958
- }
4959
- },
4960
- advance: function(tokenTypes, channel) {
4961
- while (this.LA(0) !== 0 && !this.match(tokenTypes, channel)) {
4962
- this.get();
4963
- }
4964
- return this.LA(0);
4965
- },
4966
- get: function(channel) {
4967
- var tokenInfo = this._tokenData, i = 0, token, info;
4968
- if (this._lt.length && this._ltIndex >= 0 && this._ltIndex < this._lt.length) {
4969
- i++;
4970
- this._token = this._lt[this._ltIndex++];
4971
- info = tokenInfo[this._token.type];
4972
- while (info.channel !== void 0 && channel !== info.channel && this._ltIndex < this._lt.length) {
4973
- this._token = this._lt[this._ltIndex++];
4974
- info = tokenInfo[this._token.type];
4975
- i++;
4976
- }
4977
- if ((info.channel === void 0 || channel === info.channel) && this._ltIndex <= this._lt.length) {
4978
- this._ltIndexCache.push(i);
4979
- return this._token.type;
4980
- }
4981
- }
4982
- token = this._getToken();
4983
- if (token.type > -1 && !tokenInfo[token.type].hide) {
4984
- token.channel = tokenInfo[token.type].channel;
4985
- this._token = token;
4986
- this._lt.push(token);
4987
- this._ltIndexCache.push(this._lt.length - this._ltIndex + i);
4988
- if (this._lt.length > 5) {
4989
- this._lt.shift();
4990
- }
4991
- if (this._ltIndexCache.length > 5) {
4992
- this._ltIndexCache.shift();
4993
- }
4994
- this._ltIndex = this._lt.length;
4995
- }
4996
- info = tokenInfo[token.type];
4997
- if (info && (info.hide || info.channel !== void 0 && channel !== info.channel)) {
4998
- return this.get(channel);
4999
- } else {
5000
- return token.type;
5001
- }
5002
- },
5003
- LA: function(index) {
5004
- var total = index, tt;
5005
- if (index > 0) {
5006
- if (index > 5) {
5007
- throw new Error("Too much lookahead.");
5008
- }
5009
- while (total) {
5010
- tt = this.get();
5011
- total--;
5012
- }
5013
- while (total < index) {
5014
- this.unget();
5015
- total++;
5016
- }
5017
- } else if (index < 0) {
5018
- if (this._lt[this._ltIndex + index]) {
5019
- tt = this._lt[this._ltIndex + index].type;
5020
- } else {
5021
- throw new Error("Too much lookbehind.");
5022
- }
5023
- } else {
5024
- tt = this._token.type;
5025
- }
5026
- return tt;
5027
- },
5028
- LT: function(index) {
5029
- this.LA(index);
5030
- return this._lt[this._ltIndex + index - 1];
5031
- },
5032
- peek: function() {
5033
- return this.LA(1);
5034
- },
5035
- token: function() {
5036
- return this._token;
5037
- },
5038
- tokenName: function(tokenType) {
5039
- if (tokenType < 0 || tokenType > this._tokenData.length) {
5040
- return "UNKNOWN_TOKEN";
5041
- } else {
5042
- return this._tokenData[tokenType].name;
5043
- }
5044
- },
5045
- tokenType: function(tokenName) {
5046
- return this._tokenData[tokenName] || -1;
5047
- },
5048
- unget: function() {
5049
- if (this._ltIndexCache.length) {
5050
- this._ltIndex -= this._ltIndexCache.pop();
5051
- this._token = this._lt[this._ltIndex - 1];
5052
- } else {
5053
- throw new Error("Too much lookahead.");
5054
- }
5055
- }
5056
- };
5057
- parserlib.util = {
5058
- __proto__: null,
5059
- StringReader,
5060
- SyntaxError: SyntaxError2,
5061
- SyntaxUnit,
5062
- EventTarget,
5063
- TokenStreamBase
5064
- };
5065
- })();
5066
- (function() {
5067
- var EventTarget = parserlib.util.EventTarget, TokenStreamBase = parserlib.util.TokenStreamBase, StringReader = parserlib.util.StringReader, SyntaxError2 = parserlib.util.SyntaxError, SyntaxUnit = parserlib.util.SyntaxUnit;
5068
- var Colors = {
5069
- __proto__: null,
5070
- aliceblue: "#f0f8ff",
5071
- antiquewhite: "#faebd7",
5072
- aqua: "#00ffff",
5073
- aquamarine: "#7fffd4",
5074
- azure: "#f0ffff",
5075
- beige: "#f5f5dc",
5076
- bisque: "#ffe4c4",
5077
- black: "#000000",
5078
- blanchedalmond: "#ffebcd",
5079
- blue: "#0000ff",
5080
- blueviolet: "#8a2be2",
5081
- brown: "#a52a2a",
5082
- burlywood: "#deb887",
5083
- cadetblue: "#5f9ea0",
5084
- chartreuse: "#7fff00",
5085
- chocolate: "#d2691e",
5086
- coral: "#ff7f50",
5087
- cornflowerblue: "#6495ed",
5088
- cornsilk: "#fff8dc",
5089
- crimson: "#dc143c",
5090
- cyan: "#00ffff",
5091
- darkblue: "#00008b",
5092
- darkcyan: "#008b8b",
5093
- darkgoldenrod: "#b8860b",
5094
- darkgray: "#a9a9a9",
5095
- darkgrey: "#a9a9a9",
5096
- darkgreen: "#006400",
5097
- darkkhaki: "#bdb76b",
5098
- darkmagenta: "#8b008b",
5099
- darkolivegreen: "#556b2f",
5100
- darkorange: "#ff8c00",
5101
- darkorchid: "#9932cc",
5102
- darkred: "#8b0000",
5103
- darksalmon: "#e9967a",
5104
- darkseagreen: "#8fbc8f",
5105
- darkslateblue: "#483d8b",
5106
- darkslategray: "#2f4f4f",
5107
- darkslategrey: "#2f4f4f",
5108
- darkturquoise: "#00ced1",
5109
- darkviolet: "#9400d3",
5110
- deeppink: "#ff1493",
5111
- deepskyblue: "#00bfff",
5112
- dimgray: "#696969",
5113
- dimgrey: "#696969",
5114
- dodgerblue: "#1e90ff",
5115
- firebrick: "#b22222",
5116
- floralwhite: "#fffaf0",
5117
- forestgreen: "#228b22",
5118
- fuchsia: "#ff00ff",
5119
- gainsboro: "#dcdcdc",
5120
- ghostwhite: "#f8f8ff",
5121
- gold: "#ffd700",
5122
- goldenrod: "#daa520",
5123
- gray: "#808080",
5124
- grey: "#808080",
5125
- green: "#008000",
5126
- greenyellow: "#adff2f",
5127
- honeydew: "#f0fff0",
5128
- hotpink: "#ff69b4",
5129
- indianred: "#cd5c5c",
5130
- indigo: "#4b0082",
5131
- ivory: "#fffff0",
5132
- khaki: "#f0e68c",
5133
- lavender: "#e6e6fa",
5134
- lavenderblush: "#fff0f5",
5135
- lawngreen: "#7cfc00",
5136
- lemonchiffon: "#fffacd",
5137
- lightblue: "#add8e6",
5138
- lightcoral: "#f08080",
5139
- lightcyan: "#e0ffff",
5140
- lightgoldenrodyellow: "#fafad2",
5141
- lightgray: "#d3d3d3",
5142
- lightgrey: "#d3d3d3",
5143
- lightgreen: "#90ee90",
5144
- lightpink: "#ffb6c1",
5145
- lightsalmon: "#ffa07a",
5146
- lightseagreen: "#20b2aa",
5147
- lightskyblue: "#87cefa",
5148
- lightslategray: "#778899",
5149
- lightslategrey: "#778899",
5150
- lightsteelblue: "#b0c4de",
5151
- lightyellow: "#ffffe0",
5152
- lime: "#00ff00",
5153
- limegreen: "#32cd32",
5154
- linen: "#faf0e6",
5155
- magenta: "#ff00ff",
5156
- maroon: "#800000",
5157
- mediumaquamarine: "#66cdaa",
5158
- mediumblue: "#0000cd",
5159
- mediumorchid: "#ba55d3",
5160
- mediumpurple: "#9370d8",
5161
- mediumseagreen: "#3cb371",
5162
- mediumslateblue: "#7b68ee",
5163
- mediumspringgreen: "#00fa9a",
5164
- mediumturquoise: "#48d1cc",
5165
- mediumvioletred: "#c71585",
5166
- midnightblue: "#191970",
5167
- mintcream: "#f5fffa",
5168
- mistyrose: "#ffe4e1",
5169
- moccasin: "#ffe4b5",
5170
- navajowhite: "#ffdead",
5171
- navy: "#000080",
5172
- oldlace: "#fdf5e6",
5173
- olive: "#808000",
5174
- olivedrab: "#6b8e23",
5175
- orange: "#ffa500",
5176
- orangered: "#ff4500",
5177
- orchid: "#da70d6",
5178
- palegoldenrod: "#eee8aa",
5179
- palegreen: "#98fb98",
5180
- paleturquoise: "#afeeee",
5181
- palevioletred: "#d87093",
5182
- papayawhip: "#ffefd5",
5183
- peachpuff: "#ffdab9",
5184
- peru: "#cd853f",
5185
- pink: "#ffc0cb",
5186
- plum: "#dda0dd",
5187
- powderblue: "#b0e0e6",
5188
- purple: "#800080",
5189
- red: "#ff0000",
5190
- rosybrown: "#bc8f8f",
5191
- royalblue: "#4169e1",
5192
- saddlebrown: "#8b4513",
5193
- salmon: "#fa8072",
5194
- sandybrown: "#f4a460",
5195
- seagreen: "#2e8b57",
5196
- seashell: "#fff5ee",
5197
- sienna: "#a0522d",
5198
- silver: "#c0c0c0",
5199
- skyblue: "#87ceeb",
5200
- slateblue: "#6a5acd",
5201
- slategray: "#708090",
5202
- slategrey: "#708090",
5203
- snow: "#fffafa",
5204
- springgreen: "#00ff7f",
5205
- steelblue: "#4682b4",
5206
- tan: "#d2b48c",
5207
- teal: "#008080",
5208
- thistle: "#d8bfd8",
5209
- tomato: "#ff6347",
5210
- turquoise: "#40e0d0",
5211
- violet: "#ee82ee",
5212
- wheat: "#f5deb3",
5213
- white: "#ffffff",
5214
- whitesmoke: "#f5f5f5",
5215
- yellow: "#ffff00",
5216
- yellowgreen: "#9acd32",
5217
- currentColor: "The value of the 'color' property.",
5218
- activeBorder: "Active window border.",
5219
- activecaption: "Active window caption.",
5220
- appworkspace: "Background color of multiple document interface.",
5221
- background: "Desktop background.",
5222
- buttonface: "The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.",
5223
- buttonhighlight: "The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
5224
- buttonshadow: "The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.",
5225
- buttontext: "Text on push buttons.",
5226
- captiontext: "Text in caption, size box, and scrollbar arrow box.",
5227
- graytext: "Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.",
5228
- greytext: "Greyed (disabled) text. This color is set to #000 if the current display driver does not support a solid grey color.",
5229
- highlight: "Item(s) selected in a control.",
5230
- highlighttext: "Text of item(s) selected in a control.",
5231
- inactiveborder: "Inactive window border.",
5232
- inactivecaption: "Inactive window caption.",
5233
- inactivecaptiontext: "Color of text in an inactive caption.",
5234
- infobackground: "Background color for tooltip controls.",
5235
- infotext: "Text color for tooltip controls.",
5236
- menu: "Menu background.",
5237
- menutext: "Text in menus.",
5238
- scrollbar: "Scroll bar gray area.",
5239
- threeddarkshadow: "The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
5240
- threedface: "The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
5241
- threedhighlight: "The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
5242
- threedlightshadow: "The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
5243
- threedshadow: "The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.",
5244
- window: "Window background.",
5245
- windowframe: "Window frame.",
5246
- windowtext: "Text in windows."
5247
- };
5248
- function Combinator(text, line, col) {
5249
- SyntaxUnit.call(this, text, line, col, Parser.COMBINATOR_TYPE);
5250
- this.type = "unknown";
5251
- if (/^\s+$/.test(text)) {
5252
- this.type = "descendant";
5253
- } else if (text === ">") {
5254
- this.type = "child";
5255
- } else if (text === "+") {
5256
- this.type = "adjacent-sibling";
5257
- } else if (text === "~") {
5258
- this.type = "sibling";
5259
- }
5260
- }
5261
- Combinator.prototype = new SyntaxUnit();
5262
- Combinator.prototype.constructor = Combinator;
5263
- function MediaFeature(name, value) {
5264
- SyntaxUnit.call(this, "(" + name + (value !== null ? ":" + value : "") + ")", name.startLine, name.startCol, Parser.MEDIA_FEATURE_TYPE);
5265
- this.name = name;
5266
- this.value = value;
5267
- }
5268
- MediaFeature.prototype = new SyntaxUnit();
5269
- MediaFeature.prototype.constructor = MediaFeature;
5270
- function MediaQuery(modifier, mediaType, features, line, col) {
5271
- SyntaxUnit.call(this, (modifier ? modifier + " " : "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE);
5272
- this.modifier = modifier;
5273
- this.mediaType = mediaType;
5274
- this.features = features;
5275
- }
5276
- MediaQuery.prototype = new SyntaxUnit();
5277
- MediaQuery.prototype.constructor = MediaQuery;
5278
- function Parser(options) {
5279
- EventTarget.call(this);
5280
- this.options = options || {};
5281
- this._tokenStream = null;
5282
- }
5283
- Parser.DEFAULT_TYPE = 0;
5284
- Parser.COMBINATOR_TYPE = 1;
5285
- Parser.MEDIA_FEATURE_TYPE = 2;
5286
- Parser.MEDIA_QUERY_TYPE = 3;
5287
- Parser.PROPERTY_NAME_TYPE = 4;
5288
- Parser.PROPERTY_VALUE_TYPE = 5;
5289
- Parser.PROPERTY_VALUE_PART_TYPE = 6;
5290
- Parser.SELECTOR_TYPE = 7;
5291
- Parser.SELECTOR_PART_TYPE = 8;
5292
- Parser.SELECTOR_SUB_PART_TYPE = 9;
5293
- Parser.prototype = function() {
5294
- var proto = new EventTarget(), prop, additions = {
5295
- __proto__: null,
5296
- constructor: Parser,
5297
- DEFAULT_TYPE: 0,
5298
- COMBINATOR_TYPE: 1,
5299
- MEDIA_FEATURE_TYPE: 2,
5300
- MEDIA_QUERY_TYPE: 3,
5301
- PROPERTY_NAME_TYPE: 4,
5302
- PROPERTY_VALUE_TYPE: 5,
5303
- PROPERTY_VALUE_PART_TYPE: 6,
5304
- SELECTOR_TYPE: 7,
5305
- SELECTOR_PART_TYPE: 8,
5306
- SELECTOR_SUB_PART_TYPE: 9,
5307
- _stylesheet: function() {
5308
- var tokenStream = this._tokenStream, count, token, tt;
5309
- this.fire("startstylesheet");
5310
- this._charset();
5311
- this._skipCruft();
5312
- while (tokenStream.peek() === Tokens.IMPORT_SYM) {
5313
- this._import();
5314
- this._skipCruft();
5315
- }
5316
- while (tokenStream.peek() === Tokens.NAMESPACE_SYM) {
5317
- this._namespace();
5318
- this._skipCruft();
5319
- }
5320
- tt = tokenStream.peek();
5321
- while (tt > Tokens.EOF) {
5322
- try {
5323
- switch (tt) {
5324
- case Tokens.MEDIA_SYM:
5325
- this._media();
5326
- this._skipCruft();
5327
- break;
5328
- case Tokens.PAGE_SYM:
5329
- this._page();
5330
- this._skipCruft();
5331
- break;
5332
- case Tokens.FONT_FACE_SYM:
5333
- this._font_face();
5334
- this._skipCruft();
5335
- break;
5336
- case Tokens.KEYFRAMES_SYM:
5337
- this._keyframes();
5338
- this._skipCruft();
5339
- break;
5340
- case Tokens.VIEWPORT_SYM:
5341
- this._viewport();
5342
- this._skipCruft();
5343
- break;
5344
- case Tokens.DOCUMENT_SYM:
5345
- this._document();
5346
- this._skipCruft();
5347
- break;
5348
- case Tokens.UNKNOWN_SYM:
5349
- tokenStream.get();
5350
- if (!this.options.strict) {
5351
- this.fire({
5352
- type: "error",
5353
- error: null,
5354
- message: "Unknown @ rule: " + tokenStream.LT(0).value + ".",
5355
- line: tokenStream.LT(0).startLine,
5356
- col: tokenStream.LT(0).startCol
5357
- });
5358
- count = 0;
5359
- while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) === Tokens.LBRACE) {
5360
- count++;
5361
- }
5362
- while (count) {
5363
- tokenStream.advance([Tokens.RBRACE]);
5364
- count--;
5365
- }
5366
- } else {
5367
- throw new SyntaxError2("Unknown @ rule.", tokenStream.LT(0).startLine, tokenStream.LT(0).startCol);
5368
- }
5369
- break;
5370
- case Tokens.S:
5371
- this._readWhitespace();
5372
- break;
5373
- default:
5374
- if (!this._ruleset()) {
5375
- switch (tt) {
5376
- case Tokens.CHARSET_SYM:
5377
- token = tokenStream.LT(1);
5378
- this._charset(false);
5379
- throw new SyntaxError2("@charset not allowed here.", token.startLine, token.startCol);
5380
- case Tokens.IMPORT_SYM:
5381
- token = tokenStream.LT(1);
5382
- this._import(false);
5383
- throw new SyntaxError2("@import not allowed here.", token.startLine, token.startCol);
5384
- case Tokens.NAMESPACE_SYM:
5385
- token = tokenStream.LT(1);
5386
- this._namespace(false);
5387
- throw new SyntaxError2("@namespace not allowed here.", token.startLine, token.startCol);
5388
- default:
5389
- tokenStream.get();
5390
- this._unexpectedToken(tokenStream.token());
5391
- }
5392
- }
5393
- }
5394
- } catch (ex) {
5395
- if (ex instanceof SyntaxError2 && !this.options.strict) {
5396
- this.fire({
5397
- type: "error",
5398
- error: ex,
5399
- message: ex.message,
5400
- line: ex.line,
5401
- col: ex.col
5402
- });
5403
- } else {
5404
- throw ex;
5405
- }
5406
- }
5407
- tt = tokenStream.peek();
5408
- }
5409
- if (tt !== Tokens.EOF) {
5410
- this._unexpectedToken(tokenStream.token());
5411
- }
5412
- this.fire("endstylesheet");
5413
- },
5414
- _charset: function(emit) {
5415
- var tokenStream = this._tokenStream, charset, token, line, col;
5416
- if (tokenStream.match(Tokens.CHARSET_SYM)) {
5417
- line = tokenStream.token().startLine;
5418
- col = tokenStream.token().startCol;
5419
- this._readWhitespace();
5420
- tokenStream.mustMatch(Tokens.STRING);
5421
- token = tokenStream.token();
5422
- charset = token.value;
5423
- this._readWhitespace();
5424
- tokenStream.mustMatch(Tokens.SEMICOLON);
5425
- if (emit !== false) {
5426
- this.fire({
5427
- type: "charset",
5428
- charset,
5429
- line,
5430
- col
5431
- });
5432
- }
5433
- }
5434
- },
5435
- _import: function(emit) {
5436
- var tokenStream = this._tokenStream, uri, importToken, mediaList = [];
5437
- tokenStream.mustMatch(Tokens.IMPORT_SYM);
5438
- importToken = tokenStream.token();
5439
- this._readWhitespace();
5440
- tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
5441
- uri = tokenStream.token().value.replace(/^(?:url\()?["']?([^"']+?)["']?\)?$/, "$1");
5442
- this._readWhitespace();
5443
- mediaList = this._media_query_list();
5444
- tokenStream.mustMatch(Tokens.SEMICOLON);
5445
- this._readWhitespace();
5446
- if (emit !== false) {
5447
- this.fire({
5448
- type: "import",
5449
- uri,
5450
- media: mediaList,
5451
- line: importToken.startLine,
5452
- col: importToken.startCol
5453
- });
5454
- }
5455
- },
5456
- _namespace: function(emit) {
5457
- var tokenStream = this._tokenStream, line, col, prefix, uri;
5458
- tokenStream.mustMatch(Tokens.NAMESPACE_SYM);
5459
- line = tokenStream.token().startLine;
5460
- col = tokenStream.token().startCol;
5461
- this._readWhitespace();
5462
- if (tokenStream.match(Tokens.IDENT)) {
5463
- prefix = tokenStream.token().value;
5464
- this._readWhitespace();
5465
- }
5466
- tokenStream.mustMatch([Tokens.STRING, Tokens.URI]);
5467
- uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1");
5468
- this._readWhitespace();
5469
- tokenStream.mustMatch(Tokens.SEMICOLON);
5470
- this._readWhitespace();
5471
- if (emit !== false) {
5472
- this.fire({
5473
- type: "namespace",
5474
- prefix,
5475
- uri,
5476
- line,
5477
- col
5478
- });
5479
- }
5480
- },
5481
- _media: function() {
5482
- var tokenStream = this._tokenStream, line, col, mediaList;
5483
- tokenStream.mustMatch(Tokens.MEDIA_SYM);
5484
- line = tokenStream.token().startLine;
5485
- col = tokenStream.token().startCol;
5486
- this._readWhitespace();
5487
- mediaList = this._media_query_list();
5488
- tokenStream.mustMatch(Tokens.LBRACE);
5489
- this._readWhitespace();
5490
- this.fire({
5491
- type: "startmedia",
5492
- media: mediaList,
5493
- line,
5494
- col
5495
- });
5496
- while (true) {
5497
- if (tokenStream.peek() === Tokens.PAGE_SYM) {
5498
- this._page();
5499
- } else if (tokenStream.peek() === Tokens.FONT_FACE_SYM) {
5500
- this._font_face();
5501
- } else if (tokenStream.peek() === Tokens.VIEWPORT_SYM) {
5502
- this._viewport();
5503
- } else if (tokenStream.peek() === Tokens.DOCUMENT_SYM) {
5504
- this._document();
5505
- } else if (!this._ruleset()) {
5506
- break;
5507
- }
5508
- }
5509
- tokenStream.mustMatch(Tokens.RBRACE);
5510
- this._readWhitespace();
5511
- this.fire({
5512
- type: "endmedia",
5513
- media: mediaList,
5514
- line,
5515
- col
5516
- });
5517
- },
5518
- _media_query_list: function() {
5519
- var tokenStream = this._tokenStream, mediaList = [];
5520
- this._readWhitespace();
5521
- if (tokenStream.peek() === Tokens.IDENT || tokenStream.peek() === Tokens.LPAREN) {
5522
- mediaList.push(this._media_query());
5523
- }
5524
- while (tokenStream.match(Tokens.COMMA)) {
5525
- this._readWhitespace();
5526
- mediaList.push(this._media_query());
5527
- }
5528
- return mediaList;
5529
- },
5530
- _media_query: function() {
5531
- var tokenStream = this._tokenStream, type = null, ident = null, token = null, expressions = [];
5532
- if (tokenStream.match(Tokens.IDENT)) {
5533
- ident = tokenStream.token().value.toLowerCase();
5534
- if (ident !== "only" && ident !== "not") {
5535
- tokenStream.unget();
5536
- ident = null;
5537
- } else {
5538
- token = tokenStream.token();
5539
- }
5540
- }
5541
- this._readWhitespace();
5542
- if (tokenStream.peek() === Tokens.IDENT) {
5543
- type = this._media_type();
5544
- if (token === null) {
5545
- token = tokenStream.token();
5546
- }
5547
- } else if (tokenStream.peek() === Tokens.LPAREN) {
5548
- if (token === null) {
5549
- token = tokenStream.LT(1);
5550
- }
5551
- expressions.push(this._media_expression());
5552
- }
5553
- if (type === null && expressions.length === 0) {
5554
- return null;
5555
- } else {
5556
- this._readWhitespace();
5557
- while (tokenStream.match(Tokens.IDENT)) {
5558
- if (tokenStream.token().value.toLowerCase() !== "and") {
5559
- this._unexpectedToken(tokenStream.token());
5560
- }
5561
- this._readWhitespace();
5562
- expressions.push(this._media_expression());
5563
- }
5564
- }
5565
- return new MediaQuery(ident, type, expressions, token.startLine, token.startCol);
5566
- },
5567
- _media_type: function() {
5568
- return this._media_feature();
5569
- },
5570
- _media_expression: function() {
5571
- var tokenStream = this._tokenStream, feature = null, token, expression = null;
5572
- tokenStream.mustMatch(Tokens.LPAREN);
5573
- feature = this._media_feature();
5574
- this._readWhitespace();
5575
- if (tokenStream.match(Tokens.COLON)) {
5576
- this._readWhitespace();
5577
- token = tokenStream.LT(1);
5578
- expression = this._expression();
5579
- }
5580
- tokenStream.mustMatch(Tokens.RPAREN);
5581
- this._readWhitespace();
5582
- return new MediaFeature(feature, expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null);
5583
- },
5584
- _media_feature: function() {
5585
- var tokenStream = this._tokenStream;
5586
- this._readWhitespace();
5587
- tokenStream.mustMatch(Tokens.IDENT);
5588
- return SyntaxUnit.fromToken(tokenStream.token());
5589
- },
5590
- _page: function() {
5591
- var tokenStream = this._tokenStream, line, col, identifier = null, pseudoPage = null;
5592
- tokenStream.mustMatch(Tokens.PAGE_SYM);
5593
- line = tokenStream.token().startLine;
5594
- col = tokenStream.token().startCol;
5595
- this._readWhitespace();
5596
- if (tokenStream.match(Tokens.IDENT)) {
5597
- identifier = tokenStream.token().value;
5598
- if (identifier.toLowerCase() === "auto") {
5599
- this._unexpectedToken(tokenStream.token());
5600
- }
5601
- }
5602
- if (tokenStream.peek() === Tokens.COLON) {
5603
- pseudoPage = this._pseudo_page();
5604
- }
5605
- this._readWhitespace();
5606
- this.fire({
5607
- type: "startpage",
5608
- id: identifier,
5609
- pseudo: pseudoPage,
5610
- line,
5611
- col
5612
- });
5613
- this._readDeclarations(true, true);
5614
- this.fire({
5615
- type: "endpage",
5616
- id: identifier,
5617
- pseudo: pseudoPage,
5618
- line,
5619
- col
5620
- });
5621
- },
5622
- _margin: function() {
5623
- var tokenStream = this._tokenStream, line, col, marginSym = this._margin_sym();
5624
- if (marginSym) {
5625
- line = tokenStream.token().startLine;
5626
- col = tokenStream.token().startCol;
5627
- this.fire({
5628
- type: "startpagemargin",
5629
- margin: marginSym,
5630
- line,
5631
- col
5632
- });
5633
- this._readDeclarations(true);
5634
- this.fire({
5635
- type: "endpagemargin",
5636
- margin: marginSym,
5637
- line,
5638
- col
5639
- });
5640
- return true;
5641
- } else {
5642
- return false;
5643
- }
5644
- },
5645
- _margin_sym: function() {
5646
- var tokenStream = this._tokenStream;
5647
- if (tokenStream.match([
5648
- Tokens.TOPLEFTCORNER_SYM,
5649
- Tokens.TOPLEFT_SYM,
5650
- Tokens.TOPCENTER_SYM,
5651
- Tokens.TOPRIGHT_SYM,
5652
- Tokens.TOPRIGHTCORNER_SYM,
5653
- Tokens.BOTTOMLEFTCORNER_SYM,
5654
- Tokens.BOTTOMLEFT_SYM,
5655
- Tokens.BOTTOMCENTER_SYM,
5656
- Tokens.BOTTOMRIGHT_SYM,
5657
- Tokens.BOTTOMRIGHTCORNER_SYM,
5658
- Tokens.LEFTTOP_SYM,
5659
- Tokens.LEFTMIDDLE_SYM,
5660
- Tokens.LEFTBOTTOM_SYM,
5661
- Tokens.RIGHTTOP_SYM,
5662
- Tokens.RIGHTMIDDLE_SYM,
5663
- Tokens.RIGHTBOTTOM_SYM
5664
- ])) {
5665
- return SyntaxUnit.fromToken(tokenStream.token());
5666
- } else {
5667
- return null;
5668
- }
5669
- },
5670
- _pseudo_page: function() {
5671
- var tokenStream = this._tokenStream;
5672
- tokenStream.mustMatch(Tokens.COLON);
5673
- tokenStream.mustMatch(Tokens.IDENT);
5674
- return tokenStream.token().value;
5675
- },
5676
- _font_face: function() {
5677
- var tokenStream = this._tokenStream, line, col;
5678
- tokenStream.mustMatch(Tokens.FONT_FACE_SYM);
5679
- line = tokenStream.token().startLine;
5680
- col = tokenStream.token().startCol;
5681
- this._readWhitespace();
5682
- this.fire({
5683
- type: "startfontface",
5684
- line,
5685
- col
5686
- });
5687
- this._readDeclarations(true);
5688
- this.fire({
5689
- type: "endfontface",
5690
- line,
5691
- col
5692
- });
5693
- },
5694
- _viewport: function() {
5695
- var tokenStream = this._tokenStream, line, col;
5696
- tokenStream.mustMatch(Tokens.VIEWPORT_SYM);
5697
- line = tokenStream.token().startLine;
5698
- col = tokenStream.token().startCol;
5699
- this._readWhitespace();
5700
- this.fire({
5701
- type: "startviewport",
5702
- line,
5703
- col
5704
- });
5705
- this._readDeclarations(true);
5706
- this.fire({
5707
- type: "endviewport",
5708
- line,
5709
- col
5710
- });
5711
- },
5712
- _document: function() {
5713
- var tokenStream = this._tokenStream, token, functions = [], prefix = "";
5714
- tokenStream.mustMatch(Tokens.DOCUMENT_SYM);
5715
- token = tokenStream.token();
5716
- if (/^@\-([^\-]+)\-/.test(token.value)) {
5717
- prefix = RegExp.$1;
5718
- }
5719
- this._readWhitespace();
5720
- functions.push(this._document_function());
5721
- while (tokenStream.match(Tokens.COMMA)) {
5722
- this._readWhitespace();
5723
- functions.push(this._document_function());
5724
- }
5725
- tokenStream.mustMatch(Tokens.LBRACE);
5726
- this._readWhitespace();
5727
- this.fire({
5728
- type: "startdocument",
5729
- functions,
5730
- prefix,
5731
- line: token.startLine,
5732
- col: token.startCol
5733
- });
5734
- while (true) {
5735
- if (tokenStream.peek() === Tokens.PAGE_SYM) {
5736
- this._page();
5737
- } else if (tokenStream.peek() === Tokens.FONT_FACE_SYM) {
5738
- this._font_face();
5739
- } else if (tokenStream.peek() === Tokens.VIEWPORT_SYM) {
5740
- this._viewport();
5741
- } else if (tokenStream.peek() === Tokens.MEDIA_SYM) {
5742
- this._media();
5743
- } else if (!this._ruleset()) {
5744
- break;
5745
- }
5746
- }
5747
- tokenStream.mustMatch(Tokens.RBRACE);
5748
- this._readWhitespace();
5749
- this.fire({
5750
- type: "enddocument",
5751
- functions,
5752
- prefix,
5753
- line: token.startLine,
5754
- col: token.startCol
5755
- });
5756
- },
5757
- _document_function: function() {
5758
- var tokenStream = this._tokenStream, value;
5759
- if (tokenStream.match(Tokens.URI)) {
5760
- value = tokenStream.token().value;
5761
- this._readWhitespace();
5762
- } else {
5763
- value = this._function();
5764
- }
5765
- return value;
5766
- },
5767
- _operator: function(inFunction) {
5768
- var tokenStream = this._tokenStream, token = null;
5769
- if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) || inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS])) {
5770
- token = tokenStream.token();
5771
- this._readWhitespace();
5772
- }
5773
- return token ? PropertyValuePart.fromToken(token) : null;
5774
- },
5775
- _combinator: function() {
5776
- var tokenStream = this._tokenStream, value = null, token;
5777
- if (tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])) {
5778
- token = tokenStream.token();
5779
- value = new Combinator(token.value, token.startLine, token.startCol);
5780
- this._readWhitespace();
5781
- }
5782
- return value;
5783
- },
5784
- _unary_operator: function() {
5785
- var tokenStream = this._tokenStream;
5786
- if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])) {
5787
- return tokenStream.token().value;
5788
- } else {
5789
- return null;
5790
- }
5791
- },
5792
- _property: function() {
5793
- var tokenStream = this._tokenStream, value = null, hack = null, tokenValue, token, line, col;
5794
- if (tokenStream.peek() === Tokens.STAR && this.options.starHack) {
5795
- tokenStream.get();
5796
- token = tokenStream.token();
5797
- hack = token.value;
5798
- line = token.startLine;
5799
- col = token.startCol;
5800
- }
5801
- if (tokenStream.match(Tokens.IDENT)) {
5802
- token = tokenStream.token();
5803
- tokenValue = token.value;
5804
- if (tokenValue.charAt(0) === "_" && this.options.underscoreHack) {
5805
- hack = "_";
5806
- tokenValue = tokenValue.substring(1);
5807
- }
5808
- value = new PropertyName(tokenValue, hack, line || token.startLine, col || token.startCol);
5809
- this._readWhitespace();
5810
- }
5811
- return value;
5812
- },
5813
- _ruleset: function() {
5814
- var tokenStream = this._tokenStream, tt, selectors;
5815
- try {
5816
- selectors = this._selectors_group();
5817
- } catch (ex) {
5818
- if (ex instanceof SyntaxError2 && !this.options.strict) {
5819
- this.fire({
5820
- type: "error",
5821
- error: ex,
5822
- message: ex.message,
5823
- line: ex.line,
5824
- col: ex.col
5825
- });
5826
- tt = tokenStream.advance([Tokens.RBRACE]);
5827
- if (tt === Tokens.RBRACE) {
5828
- } else {
5829
- throw ex;
5830
- }
5831
- } else {
5832
- throw ex;
5833
- }
5834
- return true;
5835
- }
5836
- if (selectors) {
5837
- this.fire({
5838
- type: "startrule",
5839
- selectors,
5840
- line: selectors[0].line,
5841
- col: selectors[0].col
5842
- });
5843
- this._readDeclarations(true);
5844
- this.fire({
5845
- type: "endrule",
5846
- selectors,
5847
- line: selectors[0].line,
5848
- col: selectors[0].col
5849
- });
5850
- }
5851
- return selectors;
5852
- },
5853
- _selectors_group: function() {
5854
- var tokenStream = this._tokenStream, selectors = [], selector;
5855
- selector = this._selector();
5856
- if (selector !== null) {
5857
- selectors.push(selector);
5858
- while (tokenStream.match(Tokens.COMMA)) {
5859
- this._readWhitespace();
5860
- selector = this._selector();
5861
- if (selector !== null) {
5862
- selectors.push(selector);
5863
- } else {
5864
- this._unexpectedToken(tokenStream.LT(1));
5865
- }
5866
- }
5867
- }
5868
- return selectors.length ? selectors : null;
5869
- },
5870
- _selector: function() {
5871
- var tokenStream = this._tokenStream, selector = [], nextSelector = null, combinator = null, ws = null;
5872
- nextSelector = this._simple_selector_sequence();
5873
- if (nextSelector === null) {
5874
- return null;
5875
- }
5876
- selector.push(nextSelector);
5877
- do {
5878
- combinator = this._combinator();
5879
- if (combinator !== null) {
5880
- selector.push(combinator);
5881
- nextSelector = this._simple_selector_sequence();
5882
- if (nextSelector === null) {
5883
- this._unexpectedToken(tokenStream.LT(1));
5884
- } else {
5885
- selector.push(nextSelector);
5886
- }
5887
- } else {
5888
- if (this._readWhitespace()) {
5889
- ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol);
5890
- combinator = this._combinator();
5891
- nextSelector = this._simple_selector_sequence();
5892
- if (nextSelector === null) {
5893
- if (combinator !== null) {
5894
- this._unexpectedToken(tokenStream.LT(1));
5895
- }
5896
- } else {
5897
- if (combinator !== null) {
5898
- selector.push(combinator);
5899
- } else {
5900
- selector.push(ws);
5901
- }
5902
- selector.push(nextSelector);
5903
- }
5904
- } else {
5905
- break;
5906
- }
5907
- }
5908
- } while (true);
5909
- return new Selector(selector, selector[0].line, selector[0].col);
5910
- },
5911
- _simple_selector_sequence: function() {
5912
- var tokenStream = this._tokenStream, elementName = null, modifiers = [], selectorText = "", components = [
5913
- function() {
5914
- return tokenStream.match(Tokens.HASH) ? new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) : null;
5915
- },
5916
- this._class,
5917
- this._attrib,
5918
- this._pseudo,
5919
- this._negation
5920
- ], i = 0, len = components.length, component = null, line, col;
5921
- line = tokenStream.LT(1).startLine;
5922
- col = tokenStream.LT(1).startCol;
5923
- elementName = this._type_selector();
5924
- if (!elementName) {
5925
- elementName = this._universal();
5926
- }
5927
- if (elementName !== null) {
5928
- selectorText += elementName;
5929
- }
5930
- while (true) {
5931
- if (tokenStream.peek() === Tokens.S) {
5932
- break;
5933
- }
5934
- while (i < len && component === null) {
5935
- component = components[i++].call(this);
5936
- }
5937
- if (component === null) {
5938
- if (selectorText === "") {
5939
- return null;
5940
- } else {
5941
- break;
5942
- }
5943
- } else {
5944
- i = 0;
5945
- modifiers.push(component);
5946
- selectorText += component.toString();
5947
- component = null;
5948
- }
5949
- }
5950
- return selectorText !== "" ? new SelectorPart(elementName, modifiers, selectorText, line, col) : null;
5951
- },
5952
- _type_selector: function() {
5953
- var tokenStream = this._tokenStream, ns = this._namespace_prefix(), elementName = this._element_name();
5954
- if (!elementName) {
5955
- if (ns) {
5956
- tokenStream.unget();
5957
- if (ns.length > 1) {
5958
- tokenStream.unget();
5959
- }
5960
- }
5961
- return null;
5962
- } else {
5963
- if (ns) {
5964
- elementName.text = ns + elementName.text;
5965
- elementName.col -= ns.length;
5966
- }
5967
- return elementName;
5968
- }
5969
- },
5970
- _class: function() {
5971
- var tokenStream = this._tokenStream, token;
5972
- if (tokenStream.match(Tokens.DOT)) {
5973
- tokenStream.mustMatch(Tokens.IDENT);
5974
- token = tokenStream.token();
5975
- return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1);
5976
- } else {
5977
- return null;
5978
- }
5979
- },
5980
- _element_name: function() {
5981
- var tokenStream = this._tokenStream, token;
5982
- if (tokenStream.match(Tokens.IDENT)) {
5983
- token = tokenStream.token();
5984
- return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol);
5985
- } else {
5986
- return null;
5987
- }
5988
- },
5989
- _namespace_prefix: function() {
5990
- var tokenStream = this._tokenStream, value = "";
5991
- if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE) {
5992
- if (tokenStream.match([Tokens.IDENT, Tokens.STAR])) {
5993
- value += tokenStream.token().value;
5994
- }
5995
- tokenStream.mustMatch(Tokens.PIPE);
5996
- value += "|";
5997
- }
5998
- return value.length ? value : null;
5999
- },
6000
- _universal: function() {
6001
- var tokenStream = this._tokenStream, value = "", ns;
6002
- ns = this._namespace_prefix();
6003
- if (ns) {
6004
- value += ns;
6005
- }
6006
- if (tokenStream.match(Tokens.STAR)) {
6007
- value += "*";
6008
- }
6009
- return value.length ? value : null;
6010
- },
6011
- _attrib: function() {
6012
- var tokenStream = this._tokenStream, value = null, ns, token;
6013
- if (tokenStream.match(Tokens.LBRACKET)) {
6014
- token = tokenStream.token();
6015
- value = token.value;
6016
- value += this._readWhitespace();
6017
- ns = this._namespace_prefix();
6018
- if (ns) {
6019
- value += ns;
6020
- }
6021
- tokenStream.mustMatch(Tokens.IDENT);
6022
- value += tokenStream.token().value;
6023
- value += this._readWhitespace();
6024
- if (tokenStream.match([
6025
- Tokens.PREFIXMATCH,
6026
- Tokens.SUFFIXMATCH,
6027
- Tokens.SUBSTRINGMATCH,
6028
- Tokens.EQUALS,
6029
- Tokens.INCLUDES,
6030
- Tokens.DASHMATCH
6031
- ])) {
6032
- value += tokenStream.token().value;
6033
- value += this._readWhitespace();
6034
- tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
6035
- value += tokenStream.token().value;
6036
- value += this._readWhitespace();
6037
- }
6038
- tokenStream.mustMatch(Tokens.RBRACKET);
6039
- return new SelectorSubPart(value + "]", "attribute", token.startLine, token.startCol);
6040
- } else {
6041
- return null;
6042
- }
6043
- },
6044
- _pseudo: function() {
6045
- var tokenStream = this._tokenStream, pseudo = null, colons = ":", line, col;
6046
- if (tokenStream.match(Tokens.COLON)) {
6047
- if (tokenStream.match(Tokens.COLON)) {
6048
- colons += ":";
6049
- }
6050
- if (tokenStream.match(Tokens.IDENT)) {
6051
- pseudo = tokenStream.token().value;
6052
- line = tokenStream.token().startLine;
6053
- col = tokenStream.token().startCol - colons.length;
6054
- } else if (tokenStream.peek() === Tokens.FUNCTION) {
6055
- line = tokenStream.LT(1).startLine;
6056
- col = tokenStream.LT(1).startCol - colons.length;
6057
- pseudo = this._functional_pseudo();
6058
- }
6059
- if (pseudo) {
6060
- pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col);
6061
- }
6062
- }
6063
- return pseudo;
6064
- },
6065
- _functional_pseudo: function() {
6066
- var tokenStream = this._tokenStream, value = null;
6067
- if (tokenStream.match(Tokens.FUNCTION)) {
6068
- value = tokenStream.token().value;
6069
- value += this._readWhitespace();
6070
- value += this._expression();
6071
- tokenStream.mustMatch(Tokens.RPAREN);
6072
- value += ")";
6073
- }
6074
- return value;
6075
- },
6076
- _expression: function() {
6077
- var tokenStream = this._tokenStream, value = "";
6078
- while (tokenStream.match([
6079
- Tokens.PLUS,
6080
- Tokens.MINUS,
6081
- Tokens.DIMENSION,
6082
- Tokens.NUMBER,
6083
- Tokens.STRING,
6084
- Tokens.IDENT,
6085
- Tokens.LENGTH,
6086
- Tokens.FREQ,
6087
- Tokens.ANGLE,
6088
- Tokens.TIME,
6089
- Tokens.RESOLUTION,
6090
- Tokens.SLASH
6091
- ])) {
6092
- value += tokenStream.token().value;
6093
- value += this._readWhitespace();
6094
- }
6095
- return value.length ? value : null;
6096
- },
6097
- _negation: function() {
6098
- var tokenStream = this._tokenStream, line, col, value = "", arg, subpart = null;
6099
- if (tokenStream.match(Tokens.NOT)) {
6100
- value = tokenStream.token().value;
6101
- line = tokenStream.token().startLine;
6102
- col = tokenStream.token().startCol;
6103
- value += this._readWhitespace();
6104
- arg = this._negation_arg();
6105
- value += arg;
6106
- value += this._readWhitespace();
6107
- tokenStream.match(Tokens.RPAREN);
6108
- value += tokenStream.token().value;
6109
- subpart = new SelectorSubPart(value, "not", line, col);
6110
- subpart.args.push(arg);
6111
- }
6112
- return subpart;
6113
- },
6114
- _negation_arg: function() {
6115
- var tokenStream = this._tokenStream, args = [
6116
- this._type_selector,
6117
- this._universal,
6118
- function() {
6119
- return tokenStream.match(Tokens.HASH) ? new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) : null;
6120
- },
6121
- this._class,
6122
- this._attrib,
6123
- this._pseudo
6124
- ], arg = null, i = 0, len = args.length, line, col, part;
6125
- line = tokenStream.LT(1).startLine;
6126
- col = tokenStream.LT(1).startCol;
6127
- while (i < len && arg === null) {
6128
- arg = args[i].call(this);
6129
- i++;
6130
- }
6131
- if (arg === null) {
6132
- this._unexpectedToken(tokenStream.LT(1));
6133
- }
6134
- if (arg.type === "elementName") {
6135
- part = new SelectorPart(arg, [], arg.toString(), line, col);
6136
- } else {
6137
- part = new SelectorPart(null, [arg], arg.toString(), line, col);
6138
- }
6139
- return part;
6140
- },
6141
- _declaration: function() {
6142
- var tokenStream = this._tokenStream, property = null, expr = null, prio = null, invalid = null, propertyName = "";
6143
- property = this._property();
6144
- if (property !== null) {
6145
- tokenStream.mustMatch(Tokens.COLON);
6146
- this._readWhitespace();
6147
- expr = this._expr();
6148
- if (!expr || expr.length === 0) {
6149
- this._unexpectedToken(tokenStream.LT(1));
6150
- }
6151
- prio = this._prio();
6152
- propertyName = property.toString();
6153
- if (this.options.starHack && property.hack === "*" || this.options.underscoreHack && property.hack === "_") {
6154
- propertyName = property.text;
6155
- }
6156
- try {
6157
- this._validateProperty(propertyName, expr);
6158
- } catch (ex) {
6159
- invalid = ex;
6160
- }
6161
- this.fire({
6162
- type: "property",
6163
- property,
6164
- value: expr,
6165
- important: prio,
6166
- line: property.line,
6167
- col: property.col,
6168
- invalid
6169
- });
6170
- return true;
6171
- } else {
6172
- return false;
6173
- }
6174
- },
6175
- _prio: function() {
6176
- var tokenStream = this._tokenStream, result = tokenStream.match(Tokens.IMPORTANT_SYM);
6177
- this._readWhitespace();
6178
- return result;
6179
- },
6180
- _expr: function(inFunction) {
6181
- var values = [], value = null, operator = null;
6182
- value = this._term(inFunction);
6183
- if (value !== null) {
6184
- values.push(value);
6185
- do {
6186
- operator = this._operator(inFunction);
6187
- if (operator) {
6188
- values.push(operator);
6189
- }
6190
- value = this._term(inFunction);
6191
- if (value === null) {
6192
- break;
6193
- } else {
6194
- values.push(value);
6195
- }
6196
- } while (true);
6197
- }
6198
- return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null;
6199
- },
6200
- _term: function(inFunction) {
6201
- var tokenStream = this._tokenStream, unary = null, value = null, endChar = null, token, line, col;
6202
- unary = this._unary_operator();
6203
- if (unary !== null) {
6204
- line = tokenStream.token().startLine;
6205
- col = tokenStream.token().startCol;
6206
- }
6207
- if (tokenStream.peek() === Tokens.IE_FUNCTION && this.options.ieFilters) {
6208
- value = this._ie_function();
6209
- if (unary === null) {
6210
- line = tokenStream.token().startLine;
6211
- col = tokenStream.token().startCol;
6212
- }
6213
- } else if (inFunction && tokenStream.match([Tokens.LPAREN, Tokens.LBRACE, Tokens.LBRACKET])) {
6214
- token = tokenStream.token();
6215
- endChar = token.endChar;
6216
- value = token.value + this._expr(inFunction).text;
6217
- if (unary === null) {
6218
- line = tokenStream.token().startLine;
6219
- col = tokenStream.token().startCol;
6220
- }
6221
- tokenStream.mustMatch(Tokens.type(endChar));
6222
- value += endChar;
6223
- this._readWhitespace();
6224
- } else if (tokenStream.match([
6225
- Tokens.NUMBER,
6226
- Tokens.PERCENTAGE,
6227
- Tokens.LENGTH,
6228
- Tokens.ANGLE,
6229
- Tokens.TIME,
6230
- Tokens.FREQ,
6231
- Tokens.STRING,
6232
- Tokens.IDENT,
6233
- Tokens.URI,
6234
- Tokens.UNICODE_RANGE
6235
- ])) {
6236
- value = tokenStream.token().value;
6237
- if (unary === null) {
6238
- line = tokenStream.token().startLine;
6239
- col = tokenStream.token().startCol;
6240
- }
6241
- this._readWhitespace();
6242
- } else {
6243
- token = this._hexcolor();
6244
- if (token === null) {
6245
- if (unary === null) {
6246
- line = tokenStream.LT(1).startLine;
6247
- col = tokenStream.LT(1).startCol;
6248
- }
6249
- if (value === null) {
6250
- if (tokenStream.LA(3) === Tokens.EQUALS && this.options.ieFilters) {
6251
- value = this._ie_function();
6252
- } else {
6253
- value = this._function();
6254
- }
6255
- }
6256
- } else {
6257
- value = token.value;
6258
- if (unary === null) {
6259
- line = token.startLine;
6260
- col = token.startCol;
6261
- }
6262
- }
6263
- }
6264
- return value !== null ? new PropertyValuePart(unary !== null ? unary + value : value, line, col) : null;
6265
- },
6266
- _function: function() {
6267
- var tokenStream = this._tokenStream, functionText = null, expr = null, lt;
6268
- if (tokenStream.match(Tokens.FUNCTION)) {
6269
- functionText = tokenStream.token().value;
6270
- this._readWhitespace();
6271
- expr = this._expr(true);
6272
- functionText += expr;
6273
- if (this.options.ieFilters && tokenStream.peek() === Tokens.EQUALS) {
6274
- do {
6275
- if (this._readWhitespace()) {
6276
- functionText += tokenStream.token().value;
6277
- }
6278
- if (tokenStream.LA(0) === Tokens.COMMA) {
6279
- functionText += tokenStream.token().value;
6280
- }
6281
- tokenStream.match(Tokens.IDENT);
6282
- functionText += tokenStream.token().value;
6283
- tokenStream.match(Tokens.EQUALS);
6284
- functionText += tokenStream.token().value;
6285
- lt = tokenStream.peek();
6286
- while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) {
6287
- tokenStream.get();
6288
- functionText += tokenStream.token().value;
6289
- lt = tokenStream.peek();
6290
- }
6291
- } while (tokenStream.match([Tokens.COMMA, Tokens.S]));
6292
- }
6293
- tokenStream.match(Tokens.RPAREN);
6294
- functionText += ")";
6295
- this._readWhitespace();
6296
- }
6297
- return functionText;
6298
- },
6299
- _ie_function: function() {
6300
- var tokenStream = this._tokenStream, functionText = null, lt;
6301
- if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])) {
6302
- functionText = tokenStream.token().value;
6303
- do {
6304
- if (this._readWhitespace()) {
6305
- functionText += tokenStream.token().value;
6306
- }
6307
- if (tokenStream.LA(0) === Tokens.COMMA) {
6308
- functionText += tokenStream.token().value;
6309
- }
6310
- tokenStream.match(Tokens.IDENT);
6311
- functionText += tokenStream.token().value;
6312
- tokenStream.match(Tokens.EQUALS);
6313
- functionText += tokenStream.token().value;
6314
- lt = tokenStream.peek();
6315
- while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) {
6316
- tokenStream.get();
6317
- functionText += tokenStream.token().value;
6318
- lt = tokenStream.peek();
6319
- }
6320
- } while (tokenStream.match([Tokens.COMMA, Tokens.S]));
6321
- tokenStream.match(Tokens.RPAREN);
6322
- functionText += ")";
6323
- this._readWhitespace();
6324
- }
6325
- return functionText;
6326
- },
6327
- _hexcolor: function() {
6328
- var tokenStream = this._tokenStream, token = null, color;
6329
- if (tokenStream.match(Tokens.HASH)) {
6330
- token = tokenStream.token();
6331
- color = token.value;
6332
- if (!/#[a-f0-9]{3,6}/i.test(color)) {
6333
- throw new SyntaxError2("Expected a hex color but found '" + color + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
6334
- }
6335
- this._readWhitespace();
6336
- }
6337
- return token;
6338
- },
6339
- _keyframes: function() {
6340
- var tokenStream = this._tokenStream, token, tt, name, prefix = "";
6341
- tokenStream.mustMatch(Tokens.KEYFRAMES_SYM);
6342
- token = tokenStream.token();
6343
- if (/^@\-([^\-]+)\-/.test(token.value)) {
6344
- prefix = RegExp.$1;
6345
- }
6346
- this._readWhitespace();
6347
- name = this._keyframe_name();
6348
- this._readWhitespace();
6349
- tokenStream.mustMatch(Tokens.LBRACE);
6350
- this.fire({
6351
- type: "startkeyframes",
6352
- name,
6353
- prefix,
6354
- line: token.startLine,
6355
- col: token.startCol
6356
- });
6357
- this._readWhitespace();
6358
- tt = tokenStream.peek();
6359
- while (tt === Tokens.IDENT || tt === Tokens.PERCENTAGE) {
6360
- this._keyframe_rule();
6361
- this._readWhitespace();
6362
- tt = tokenStream.peek();
6363
- }
6364
- this.fire({
6365
- type: "endkeyframes",
6366
- name,
6367
- prefix,
6368
- line: token.startLine,
6369
- col: token.startCol
6370
- });
6371
- this._readWhitespace();
6372
- tokenStream.mustMatch(Tokens.RBRACE);
6373
- },
6374
- _keyframe_name: function() {
6375
- var tokenStream = this._tokenStream;
6376
- tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]);
6377
- return SyntaxUnit.fromToken(tokenStream.token());
6378
- },
6379
- _keyframe_rule: function() {
6380
- var keyList = this._key_list();
6381
- this.fire({
6382
- type: "startkeyframerule",
6383
- keys: keyList,
6384
- line: keyList[0].line,
6385
- col: keyList[0].col
6386
- });
6387
- this._readDeclarations(true);
6388
- this.fire({
6389
- type: "endkeyframerule",
6390
- keys: keyList,
6391
- line: keyList[0].line,
6392
- col: keyList[0].col
6393
- });
6394
- },
6395
- _key_list: function() {
6396
- var tokenStream = this._tokenStream, keyList = [];
6397
- keyList.push(this._key());
6398
- this._readWhitespace();
6399
- while (tokenStream.match(Tokens.COMMA)) {
6400
- this._readWhitespace();
6401
- keyList.push(this._key());
6402
- this._readWhitespace();
6403
- }
6404
- return keyList;
6405
- },
6406
- _key: function() {
6407
- var tokenStream = this._tokenStream, token;
6408
- if (tokenStream.match(Tokens.PERCENTAGE)) {
6409
- return SyntaxUnit.fromToken(tokenStream.token());
6410
- } else if (tokenStream.match(Tokens.IDENT)) {
6411
- token = tokenStream.token();
6412
- if (/from|to/i.test(token.value)) {
6413
- return SyntaxUnit.fromToken(token);
6414
- }
6415
- tokenStream.unget();
6416
- }
6417
- this._unexpectedToken(tokenStream.LT(1));
6418
- },
6419
- _skipCruft: function() {
6420
- while (this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])) {
6421
- }
6422
- },
6423
- _readDeclarations: function(checkStart, readMargins) {
6424
- var tokenStream = this._tokenStream, tt;
6425
- this._readWhitespace();
6426
- if (checkStart) {
6427
- tokenStream.mustMatch(Tokens.LBRACE);
6428
- }
6429
- this._readWhitespace();
6430
- try {
6431
- while (true) {
6432
- if (tokenStream.match(Tokens.SEMICOLON) || readMargins && this._margin()) {
6433
- } else if (this._declaration()) {
6434
- if (!tokenStream.match(Tokens.SEMICOLON)) {
6435
- break;
6436
- }
6437
- } else {
6438
- break;
6439
- }
6440
- this._readWhitespace();
6441
- }
6442
- tokenStream.mustMatch(Tokens.RBRACE);
6443
- this._readWhitespace();
6444
- } catch (ex) {
6445
- if (ex instanceof SyntaxError2 && !this.options.strict) {
6446
- this.fire({
6447
- type: "error",
6448
- error: ex,
6449
- message: ex.message,
6450
- line: ex.line,
6451
- col: ex.col
6452
- });
6453
- tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]);
6454
- if (tt === Tokens.SEMICOLON) {
6455
- this._readDeclarations(false, readMargins);
6456
- } else if (tt !== Tokens.RBRACE) {
6457
- throw ex;
6458
- }
6459
- } else {
6460
- throw ex;
6461
- }
6462
- }
6463
- },
6464
- _readWhitespace: function() {
6465
- var tokenStream = this._tokenStream, ws = "";
6466
- while (tokenStream.match(Tokens.S)) {
6467
- ws += tokenStream.token().value;
6468
- }
6469
- return ws;
6470
- },
6471
- _unexpectedToken: function(token) {
6472
- throw new SyntaxError2("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol);
6473
- },
6474
- _verifyEnd: function() {
6475
- if (this._tokenStream.LA(1) !== Tokens.EOF) {
6476
- this._unexpectedToken(this._tokenStream.LT(1));
6477
- }
6478
- },
6479
- _validateProperty: function(property, value) {
6480
- Validation.validate(property, value);
6481
- },
6482
- parse: function(input) {
6483
- this._tokenStream = new TokenStream(input, Tokens);
6484
- this._stylesheet();
6485
- },
6486
- parseStyleSheet: function(input) {
6487
- return this.parse(input);
6488
- },
6489
- parseMediaQuery: function(input) {
6490
- this._tokenStream = new TokenStream(input, Tokens);
6491
- var result = this._media_query();
6492
- this._verifyEnd();
6493
- return result;
6494
- },
6495
- parsePropertyValue: function(input) {
6496
- this._tokenStream = new TokenStream(input, Tokens);
6497
- this._readWhitespace();
6498
- var result = this._expr();
6499
- this._readWhitespace();
6500
- this._verifyEnd();
6501
- return result;
6502
- },
6503
- parseRule: function(input) {
6504
- this._tokenStream = new TokenStream(input, Tokens);
6505
- this._readWhitespace();
6506
- var result = this._ruleset();
6507
- this._readWhitespace();
6508
- this._verifyEnd();
6509
- return result;
6510
- },
6511
- parseSelector: function(input) {
6512
- this._tokenStream = new TokenStream(input, Tokens);
6513
- this._readWhitespace();
6514
- var result = this._selector();
6515
- this._readWhitespace();
6516
- this._verifyEnd();
6517
- return result;
6518
- },
6519
- parseStyleAttribute: function(input) {
6520
- input += "}";
6521
- this._tokenStream = new TokenStream(input, Tokens);
6522
- this._readDeclarations();
6523
- }
6524
- };
6525
- for (prop in additions) {
6526
- if (Object.prototype.hasOwnProperty.call(additions, prop)) {
6527
- proto[prop] = additions[prop];
6528
- }
6529
- }
6530
- return proto;
6531
- }();
6532
- var Properties = {
6533
- __proto__: null,
6534
- "align-items": "flex-start | flex-end | center | baseline | stretch",
6535
- "align-content": "flex-start | flex-end | center | space-between | space-around | stretch",
6536
- "align-self": "auto | flex-start | flex-end | center | baseline | stretch",
6537
- "-webkit-align-items": "flex-start | flex-end | center | baseline | stretch",
6538
- "-webkit-align-content": "flex-start | flex-end | center | space-between | space-around | stretch",
6539
- "-webkit-align-self": "auto | flex-start | flex-end | center | baseline | stretch",
6540
- "alignment-adjust": "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | <percentage> | <length>",
6541
- "alignment-baseline": "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
6542
- "animation": 1,
6543
- "animation-delay": { multi: "<time>", comma: true },
6544
- "animation-direction": { multi: "normal | alternate", comma: true },
6545
- "animation-duration": { multi: "<time>", comma: true },
6546
- "animation-fill-mode": { multi: "none | forwards | backwards | both", comma: true },
6547
- "animation-iteration-count": { multi: "<number> | infinite", comma: true },
6548
- "animation-name": { multi: "none | <ident>", comma: true },
6549
- "animation-play-state": { multi: "running | paused", comma: true },
6550
- "animation-timing-function": 1,
6551
- "-moz-animation-delay": { multi: "<time>", comma: true },
6552
- "-moz-animation-direction": { multi: "normal | alternate", comma: true },
6553
- "-moz-animation-duration": { multi: "<time>", comma: true },
6554
- "-moz-animation-iteration-count": { multi: "<number> | infinite", comma: true },
6555
- "-moz-animation-name": { multi: "none | <ident>", comma: true },
6556
- "-moz-animation-play-state": { multi: "running | paused", comma: true },
6557
- "-ms-animation-delay": { multi: "<time>", comma: true },
6558
- "-ms-animation-direction": { multi: "normal | alternate", comma: true },
6559
- "-ms-animation-duration": { multi: "<time>", comma: true },
6560
- "-ms-animation-iteration-count": { multi: "<number> | infinite", comma: true },
6561
- "-ms-animation-name": { multi: "none | <ident>", comma: true },
6562
- "-ms-animation-play-state": { multi: "running | paused", comma: true },
6563
- "-webkit-animation-delay": { multi: "<time>", comma: true },
6564
- "-webkit-animation-direction": { multi: "normal | alternate", comma: true },
6565
- "-webkit-animation-duration": { multi: "<time>", comma: true },
6566
- "-webkit-animation-fill-mode": { multi: "none | forwards | backwards | both", comma: true },
6567
- "-webkit-animation-iteration-count": { multi: "<number> | infinite", comma: true },
6568
- "-webkit-animation-name": { multi: "none | <ident>", comma: true },
6569
- "-webkit-animation-play-state": { multi: "running | paused", comma: true },
6570
- "-o-animation-delay": { multi: "<time>", comma: true },
6571
- "-o-animation-direction": { multi: "normal | alternate", comma: true },
6572
- "-o-animation-duration": { multi: "<time>", comma: true },
6573
- "-o-animation-iteration-count": { multi: "<number> | infinite", comma: true },
6574
- "-o-animation-name": { multi: "none | <ident>", comma: true },
6575
- "-o-animation-play-state": { multi: "running | paused", comma: true },
6576
- "appearance": "icon | window | desktop | workspace | document | tooltip | dialog | button | push-button | hyperlink | radio | radio-button | checkbox | menu-item | tab | menu | menubar | pull-down-menu | pop-up-menu | list-menu | radio-group | checkbox-group | outline-tree | range | field | combo-box | signature | password | normal | none | inherit",
6577
- "azimuth": function(expression) {
6578
- var simple = "<angle> | leftwards | rightwards | inherit", direction = "left-side | far-left | left | center-left | center | center-right | right | far-right | right-side", behind = false, valid = false, part;
6579
- if (!ValidationTypes.isAny(expression, simple)) {
6580
- if (ValidationTypes.isAny(expression, "behind")) {
6581
- behind = true;
6582
- valid = true;
6583
- }
6584
- if (ValidationTypes.isAny(expression, direction)) {
6585
- valid = true;
6586
- if (!behind) {
6587
- ValidationTypes.isAny(expression, "behind");
6588
- }
6589
- }
6590
- }
6591
- if (expression.hasNext()) {
6592
- part = expression.next();
6593
- if (valid) {
6594
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
6595
- } else {
6596
- throw new ValidationError("Expected (<'azimuth'>) but found '" + part + "'.", part.line, part.col);
6597
- }
6598
- }
6599
- },
6600
- "backface-visibility": "visible | hidden",
6601
- "background": 1,
6602
- "background-attachment": { multi: "<attachment>", comma: true },
6603
- "background-clip": { multi: "<box>", comma: true },
6604
- "background-color": "<color> | inherit",
6605
- "background-image": { multi: "<bg-image>", comma: true },
6606
- "background-origin": { multi: "<box>", comma: true },
6607
- "background-position": { multi: "<bg-position>", comma: true },
6608
- "background-repeat": { multi: "<repeat-style>" },
6609
- "background-size": { multi: "<bg-size>", comma: true },
6610
- "baseline-shift": "baseline | sub | super | <percentage> | <length>",
6611
- "behavior": 1,
6612
- "binding": 1,
6613
- "bleed": "<length>",
6614
- "bookmark-label": "<content> | <attr> | <string>",
6615
- "bookmark-level": "none | <integer>",
6616
- "bookmark-state": "open | closed",
6617
- "bookmark-target": "none | <uri> | <attr>",
6618
- "border": "<border-width> || <border-style> || <color>",
6619
- "border-bottom": "<border-width> || <border-style> || <color>",
6620
- "border-bottom-color": "<color> | inherit",
6621
- "border-bottom-left-radius": "<x-one-radius>",
6622
- "border-bottom-right-radius": "<x-one-radius>",
6623
- "border-bottom-style": "<border-style>",
6624
- "border-bottom-width": "<border-width>",
6625
- "border-collapse": "collapse | separate | inherit",
6626
- "border-color": { multi: "<color> | inherit", max: 4 },
6627
- "border-image": 1,
6628
- "border-image-outset": { multi: "<length> | <number>", max: 4 },
6629
- "border-image-repeat": { multi: "stretch | repeat | round", max: 2 },
6630
- "border-image-slice": function(expression) {
6631
- var valid = false, numeric = "<number> | <percentage>", fill = false, count = 0, max = 4, part;
6632
- if (ValidationTypes.isAny(expression, "fill")) {
6633
- fill = true;
6634
- valid = true;
6635
- }
6636
- while (expression.hasNext() && count < max) {
6637
- valid = ValidationTypes.isAny(expression, numeric);
6638
- if (!valid) {
6639
- break;
6640
- }
6641
- count++;
6642
- }
6643
- if (!fill) {
6644
- ValidationTypes.isAny(expression, "fill");
6645
- } else {
6646
- valid = true;
6647
- }
6648
- if (expression.hasNext()) {
6649
- part = expression.next();
6650
- if (valid) {
6651
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
6652
- } else {
6653
- throw new ValidationError("Expected ([<number> | <percentage>]{1,4} && fill?) but found '" + part + "'.", part.line, part.col);
6654
- }
6655
- }
6656
- },
6657
- "border-image-source": "<image> | none",
6658
- "border-image-width": { multi: "<length> | <percentage> | <number> | auto", max: 4 },
6659
- "border-left": "<border-width> || <border-style> || <color>",
6660
- "border-left-color": "<color> | inherit",
6661
- "border-left-style": "<border-style>",
6662
- "border-left-width": "<border-width>",
6663
- "border-radius": function(expression) {
6664
- var valid = false, simple = "<length> | <percentage> | inherit", slash = false, count = 0, max = 8, part;
6665
- while (expression.hasNext() && count < max) {
6666
- valid = ValidationTypes.isAny(expression, simple);
6667
- if (!valid) {
6668
- if (String(expression.peek()) === "/" && count > 0 && !slash) {
6669
- slash = true;
6670
- max = count + 5;
6671
- expression.next();
6672
- } else {
6673
- break;
6674
- }
6675
- }
6676
- count++;
6677
- }
6678
- if (expression.hasNext()) {
6679
- part = expression.next();
6680
- if (valid) {
6681
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
6682
- } else {
6683
- throw new ValidationError("Expected (<'border-radius'>) but found '" + part + "'.", part.line, part.col);
6684
- }
6685
- }
6686
- },
6687
- "border-right": "<border-width> || <border-style> || <color>",
6688
- "border-right-color": "<color> | inherit",
6689
- "border-right-style": "<border-style>",
6690
- "border-right-width": "<border-width>",
6691
- "border-spacing": { multi: "<length> | inherit", max: 2 },
6692
- "border-style": { multi: "<border-style>", max: 4 },
6693
- "border-top": "<border-width> || <border-style> || <color>",
6694
- "border-top-color": "<color> | inherit",
6695
- "border-top-left-radius": "<x-one-radius>",
6696
- "border-top-right-radius": "<x-one-radius>",
6697
- "border-top-style": "<border-style>",
6698
- "border-top-width": "<border-width>",
6699
- "border-width": { multi: "<border-width>", max: 4 },
6700
- "bottom": "<margin-width> | inherit",
6701
- "-moz-box-align": "start | end | center | baseline | stretch",
6702
- "-moz-box-decoration-break": "slice |clone",
6703
- "-moz-box-direction": "normal | reverse | inherit",
6704
- "-moz-box-flex": "<number>",
6705
- "-moz-box-flex-group": "<integer>",
6706
- "-moz-box-lines": "single | multiple",
6707
- "-moz-box-ordinal-group": "<integer>",
6708
- "-moz-box-orient": "horizontal | vertical | inline-axis | block-axis | inherit",
6709
- "-moz-box-pack": "start | end | center | justify",
6710
- "-o-box-decoration-break": "slice | clone",
6711
- "-webkit-box-align": "start | end | center | baseline | stretch",
6712
- "-webkit-box-decoration-break": "slice |clone",
6713
- "-webkit-box-direction": "normal | reverse | inherit",
6714
- "-webkit-box-flex": "<number>",
6715
- "-webkit-box-flex-group": "<integer>",
6716
- "-webkit-box-lines": "single | multiple",
6717
- "-webkit-box-ordinal-group": "<integer>",
6718
- "-webkit-box-orient": "horizontal | vertical | inline-axis | block-axis | inherit",
6719
- "-webkit-box-pack": "start | end | center | justify",
6720
- "box-decoration-break": "slice | clone",
6721
- "box-shadow": function(expression) {
6722
- var part;
6723
- if (!ValidationTypes.isAny(expression, "none")) {
6724
- Validation.multiProperty("<shadow>", expression, true, Infinity);
6725
- } else {
6726
- if (expression.hasNext()) {
6727
- part = expression.next();
6728
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
6729
- }
6730
- }
6731
- },
6732
- "box-sizing": "content-box | border-box | inherit",
6733
- "break-after": "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
6734
- "break-before": "auto | always | avoid | left | right | page | column | avoid-page | avoid-column",
6735
- "break-inside": "auto | avoid | avoid-page | avoid-column",
6736
- "caption-side": "top | bottom | inherit",
6737
- "clear": "none | right | left | both | inherit",
6738
- "clip": 1,
6739
- "color": "<color> | inherit",
6740
- "color-profile": 1,
6741
- "column-count": "<integer> | auto",
6742
- "column-fill": "auto | balance",
6743
- "column-gap": "<length> | normal",
6744
- "column-rule": "<border-width> || <border-style> || <color>",
6745
- "column-rule-color": "<color>",
6746
- "column-rule-style": "<border-style>",
6747
- "column-rule-width": "<border-width>",
6748
- "column-span": "none | all",
6749
- "column-width": "<length> | auto",
6750
- "columns": 1,
6751
- "content": 1,
6752
- "counter-increment": 1,
6753
- "counter-reset": 1,
6754
- "crop": "<shape> | auto",
6755
- "cue": "cue-after | cue-before | inherit",
6756
- "cue-after": 1,
6757
- "cue-before": 1,
6758
- "cursor": 1,
6759
- "direction": "ltr | rtl | inherit",
6760
- "display": "inline | block | list-item | inline-block | table | inline-table | table-row-group | table-header-group | table-footer-group | table-row | table-column-group | table-column | table-cell | table-caption | grid | inline-grid | run-in | ruby | ruby-base | ruby-text | ruby-base-container | ruby-text-container | contents | none | inherit | -moz-box | -moz-inline-block | -moz-inline-box | -moz-inline-grid | -moz-inline-stack | -moz-inline-table | -moz-grid | -moz-grid-group | -moz-grid-line | -moz-groupbox | -moz-deck | -moz-popup | -moz-stack | -moz-marker | -webkit-box | -webkit-inline-box | -ms-flexbox | -ms-inline-flexbox | flex | -webkit-flex | inline-flex | -webkit-inline-flex",
6761
- "dominant-baseline": 1,
6762
- "drop-initial-after-adjust": "central | middle | after-edge | text-after-edge | ideographic | alphabetic | mathematical | <percentage> | <length>",
6763
- "drop-initial-after-align": "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
6764
- "drop-initial-before-adjust": "before-edge | text-before-edge | central | middle | hanging | mathematical | <percentage> | <length>",
6765
- "drop-initial-before-align": "caps-height | baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical",
6766
- "drop-initial-size": "auto | line | <length> | <percentage>",
6767
- "drop-initial-value": "initial | <integer>",
6768
- "elevation": "<angle> | below | level | above | higher | lower | inherit",
6769
- "empty-cells": "show | hide | inherit",
6770
- "filter": 1,
6771
- "fit": "fill | hidden | meet | slice",
6772
- "fit-position": 1,
6773
- "flex": "<flex>",
6774
- "flex-basis": "<width>",
6775
- "flex-direction": "row | row-reverse | column | column-reverse",
6776
- "flex-flow": "<flex-direction> || <flex-wrap>",
6777
- "flex-grow": "<number>",
6778
- "flex-shrink": "<number>",
6779
- "flex-wrap": "nowrap | wrap | wrap-reverse",
6780
- "-webkit-flex": "<flex>",
6781
- "-webkit-flex-basis": "<width>",
6782
- "-webkit-flex-direction": "row | row-reverse | column | column-reverse",
6783
- "-webkit-flex-flow": "<flex-direction> || <flex-wrap>",
6784
- "-webkit-flex-grow": "<number>",
6785
- "-webkit-flex-shrink": "<number>",
6786
- "-webkit-flex-wrap": "nowrap | wrap | wrap-reverse",
6787
- "-ms-flex": "<flex>",
6788
- "-ms-flex-align": "start | end | center | stretch | baseline",
6789
- "-ms-flex-direction": "row | row-reverse | column | column-reverse | inherit",
6790
- "-ms-flex-order": "<number>",
6791
- "-ms-flex-pack": "start | end | center | justify",
6792
- "-ms-flex-wrap": "nowrap | wrap | wrap-reverse",
6793
- "float": "left | right | none | inherit",
6794
- "float-offset": 1,
6795
- "font": 1,
6796
- "font-family": 1,
6797
- "font-feature-settings": "<feature-tag-value> | normal | inherit",
6798
- "font-kerning": "auto | normal | none | initial | inherit | unset",
6799
- "font-size": "<absolute-size> | <relative-size> | <length> | <percentage> | inherit",
6800
- "font-size-adjust": "<number> | none | inherit",
6801
- "font-stretch": "normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | inherit",
6802
- "font-style": "normal | italic | oblique | inherit",
6803
- "font-variant": "normal | small-caps | inherit",
6804
- "font-variant-caps": "normal | small-caps | all-small-caps | petite-caps | all-petite-caps | unicase | titling-caps",
6805
- "font-variant-position": "normal | sub | super | inherit | initial | unset",
6806
- "font-weight": "normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit",
6807
- "grid": 1,
6808
- "grid-area": 1,
6809
- "grid-auto-columns": 1,
6810
- "grid-auto-flow": 1,
6811
- "grid-auto-position": 1,
6812
- "grid-auto-rows": 1,
6813
- "grid-cell-stacking": "columns | rows | layer",
6814
- "grid-column": 1,
6815
- "grid-columns": 1,
6816
- "grid-column-align": "start | end | center | stretch",
6817
- "grid-column-sizing": 1,
6818
- "grid-column-start": 1,
6819
- "grid-column-end": 1,
6820
- "grid-column-span": "<integer>",
6821
- "grid-flow": "none | rows | columns",
6822
- "grid-layer": "<integer>",
6823
- "grid-row": 1,
6824
- "grid-rows": 1,
6825
- "grid-row-align": "start | end | center | stretch",
6826
- "grid-row-start": 1,
6827
- "grid-row-end": 1,
6828
- "grid-row-span": "<integer>",
6829
- "grid-row-sizing": 1,
6830
- "grid-template": 1,
6831
- "grid-template-areas": 1,
6832
- "grid-template-columns": 1,
6833
- "grid-template-rows": 1,
6834
- "hanging-punctuation": 1,
6835
- "height": "<margin-width> | <content-sizing> | inherit",
6836
- "hyphenate-after": "<integer> | auto",
6837
- "hyphenate-before": "<integer> | auto",
6838
- "hyphenate-character": "<string> | auto",
6839
- "hyphenate-lines": "no-limit | <integer>",
6840
- "hyphenate-resource": 1,
6841
- "hyphens": "none | manual | auto",
6842
- "icon": 1,
6843
- "image-orientation": "angle | auto",
6844
- "image-rendering": 1,
6845
- "image-resolution": 1,
6846
- "ime-mode": "auto | normal | active | inactive | disabled | inherit",
6847
- "inline-box-align": "initial | last | <integer>",
6848
- "justify-content": "flex-start | flex-end | center | space-between | space-around",
6849
- "-webkit-justify-content": "flex-start | flex-end | center | space-between | space-around",
6850
- "left": "<margin-width> | inherit",
6851
- "letter-spacing": "<length> | normal | inherit",
6852
- "line-height": "<number> | <length> | <percentage> | normal | inherit",
6853
- "line-break": "auto | loose | normal | strict",
6854
- "line-stacking": 1,
6855
- "line-stacking-ruby": "exclude-ruby | include-ruby",
6856
- "line-stacking-shift": "consider-shifts | disregard-shifts",
6857
- "line-stacking-strategy": "inline-line-height | block-line-height | max-height | grid-height",
6858
- "list-style": 1,
6859
- "list-style-image": "<uri> | none | inherit",
6860
- "list-style-position": "inside | outside | inherit",
6861
- "list-style-type": "disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | lower-alpha | upper-alpha | none | inherit",
6862
- "margin": { multi: "<margin-width> | inherit", max: 4 },
6863
- "margin-bottom": "<margin-width> | inherit",
6864
- "margin-left": "<margin-width> | inherit",
6865
- "margin-right": "<margin-width> | inherit",
6866
- "margin-top": "<margin-width> | inherit",
6867
- "mark": 1,
6868
- "mark-after": 1,
6869
- "mark-before": 1,
6870
- "marks": 1,
6871
- "marquee-direction": 1,
6872
- "marquee-play-count": 1,
6873
- "marquee-speed": 1,
6874
- "marquee-style": 1,
6875
- "max-height": "<length> | <percentage> | <content-sizing> | none | inherit",
6876
- "max-width": "<length> | <percentage> | <content-sizing> | none | inherit",
6877
- "min-height": "<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats | inherit",
6878
- "min-width": "<length> | <percentage> | <content-sizing> | contain-floats | -moz-contain-floats | -webkit-contain-floats | inherit",
6879
- "move-to": 1,
6880
- "nav-down": 1,
6881
- "nav-index": 1,
6882
- "nav-left": 1,
6883
- "nav-right": 1,
6884
- "nav-up": 1,
6885
- "object-fit": "fill | contain | cover | none | scale-down",
6886
- "object-position": "<bg-position>",
6887
- "opacity": "<number> | inherit",
6888
- "order": "<integer>",
6889
- "-webkit-order": "<integer>",
6890
- "orphans": "<integer> | inherit",
6891
- "outline": 1,
6892
- "outline-color": "<color> | invert | inherit",
6893
- "outline-offset": 1,
6894
- "outline-style": "<border-style> | inherit",
6895
- "outline-width": "<border-width> | inherit",
6896
- "overflow": "visible | hidden | scroll | auto | inherit",
6897
- "overflow-style": 1,
6898
- "overflow-wrap": "normal | break-word",
6899
- "overflow-x": 1,
6900
- "overflow-y": 1,
6901
- "padding": { multi: "<padding-width> | inherit", max: 4 },
6902
- "padding-bottom": "<padding-width> | inherit",
6903
- "padding-left": "<padding-width> | inherit",
6904
- "padding-right": "<padding-width> | inherit",
6905
- "padding-top": "<padding-width> | inherit",
6906
- "page": 1,
6907
- "page-break-after": "auto | always | avoid | left | right | inherit",
6908
- "page-break-before": "auto | always | avoid | left | right | inherit",
6909
- "page-break-inside": "auto | avoid | inherit",
6910
- "page-policy": 1,
6911
- "pause": 1,
6912
- "pause-after": 1,
6913
- "pause-before": 1,
6914
- "perspective": 1,
6915
- "perspective-origin": 1,
6916
- "phonemes": 1,
6917
- "pitch": 1,
6918
- "pitch-range": 1,
6919
- "play-during": 1,
6920
- "pointer-events": "auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | inherit",
6921
- "position": "static | relative | absolute | fixed | inherit",
6922
- "presentation-level": 1,
6923
- "punctuation-trim": 1,
6924
- "quotes": 1,
6925
- "rendering-intent": 1,
6926
- "resize": 1,
6927
- "rest": 1,
6928
- "rest-after": 1,
6929
- "rest-before": 1,
6930
- "richness": 1,
6931
- "right": "<margin-width> | inherit",
6932
- "rotation": 1,
6933
- "rotation-point": 1,
6934
- "ruby-align": 1,
6935
- "ruby-overhang": 1,
6936
- "ruby-position": 1,
6937
- "ruby-span": 1,
6938
- "size": 1,
6939
- "speak": "normal | none | spell-out | inherit",
6940
- "speak-header": "once | always | inherit",
6941
- "speak-numeral": "digits | continuous | inherit",
6942
- "speak-punctuation": "code | none | inherit",
6943
- "speech-rate": 1,
6944
- "src": 1,
6945
- "stress": 1,
6946
- "string-set": 1,
6947
- "table-layout": "auto | fixed | inherit",
6948
- "tab-size": "<integer> | <length>",
6949
- "target": 1,
6950
- "target-name": 1,
6951
- "target-new": 1,
6952
- "target-position": 1,
6953
- "text-align": "left | right | center | justify | match-parent | start | end | inherit",
6954
- "text-align-last": 1,
6955
- "text-decoration": 1,
6956
- "text-emphasis": 1,
6957
- "text-height": 1,
6958
- "text-indent": "<length> | <percentage> | inherit",
6959
- "text-justify": "auto | none | inter-word | inter-ideograph | inter-cluster | distribute | kashida",
6960
- "text-outline": 1,
6961
- "text-overflow": 1,
6962
- "text-rendering": "auto | optimizeSpeed | optimizeLegibility | geometricPrecision | inherit",
6963
- "text-shadow": 1,
6964
- "text-transform": "capitalize | uppercase | lowercase | none | inherit",
6965
- "text-wrap": "normal | none | avoid",
6966
- "top": "<margin-width> | inherit",
6967
- "-ms-touch-action": "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",
6968
- "touch-action": "auto | none | pan-x | pan-y | pan-left | pan-right | pan-up | pan-down | manipulation",
6969
- "transform": 1,
6970
- "transform-origin": 1,
6971
- "transform-style": 1,
6972
- "transition": 1,
6973
- "transition-delay": 1,
6974
- "transition-duration": 1,
6975
- "transition-property": 1,
6976
- "transition-timing-function": 1,
6977
- "unicode-bidi": "normal | embed | isolate | bidi-override | isolate-override | plaintext | inherit",
6978
- "user-modify": "read-only | read-write | write-only | inherit",
6979
- "user-select": "none | text | toggle | element | elements | all | inherit",
6980
- "vertical-align": "auto | use-script | baseline | sub | super | top | text-top | central | middle | bottom | text-bottom | <percentage> | <length> | inherit",
6981
- "visibility": "visible | hidden | collapse | inherit",
6982
- "voice-balance": 1,
6983
- "voice-duration": 1,
6984
- "voice-family": 1,
6985
- "voice-pitch": 1,
6986
- "voice-pitch-range": 1,
6987
- "voice-rate": 1,
6988
- "voice-stress": 1,
6989
- "voice-volume": 1,
6990
- "volume": 1,
6991
- "white-space": "normal | pre | nowrap | pre-wrap | pre-line | inherit | -pre-wrap | -o-pre-wrap | -moz-pre-wrap | -hp-pre-wrap",
6992
- "white-space-collapse": 1,
6993
- "widows": "<integer> | inherit",
6994
- "width": "<length> | <percentage> | <content-sizing> | auto | inherit",
6995
- "will-change": { multi: "<ident>", comma: true },
6996
- "word-break": "normal | keep-all | break-all",
6997
- "word-spacing": "<length> | normal | inherit",
6998
- "word-wrap": "normal | break-word",
6999
- "writing-mode": "horizontal-tb | vertical-rl | vertical-lr | lr-tb | rl-tb | tb-rl | bt-rl | tb-lr | bt-lr | lr-bt | rl-bt | lr | rl | tb | inherit",
7000
- "z-index": "<integer> | auto | inherit",
7001
- "zoom": "<number> | <percentage> | normal"
7002
- };
7003
- function PropertyName(text, hack, line, col) {
7004
- SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_NAME_TYPE);
7005
- this.hack = hack;
7006
- }
7007
- PropertyName.prototype = new SyntaxUnit();
7008
- PropertyName.prototype.constructor = PropertyName;
7009
- PropertyName.prototype.toString = function() {
7010
- return (this.hack ? this.hack : "") + this.text;
7011
- };
7012
- function PropertyValue(parts, line, col) {
7013
- SyntaxUnit.call(this, parts.join(" "), line, col, Parser.PROPERTY_VALUE_TYPE);
7014
- this.parts = parts;
7015
- }
7016
- PropertyValue.prototype = new SyntaxUnit();
7017
- PropertyValue.prototype.constructor = PropertyValue;
7018
- function PropertyValueIterator(value) {
7019
- this._i = 0;
7020
- this._parts = value.parts;
7021
- this._marks = [];
7022
- this.value = value;
7023
- }
7024
- PropertyValueIterator.prototype.count = function() {
7025
- return this._parts.length;
7026
- };
7027
- PropertyValueIterator.prototype.isFirst = function() {
7028
- return this._i === 0;
7029
- };
7030
- PropertyValueIterator.prototype.hasNext = function() {
7031
- return this._i < this._parts.length;
7032
- };
7033
- PropertyValueIterator.prototype.mark = function() {
7034
- this._marks.push(this._i);
7035
- };
7036
- PropertyValueIterator.prototype.peek = function(count) {
7037
- return this.hasNext() ? this._parts[this._i + (count || 0)] : null;
7038
- };
7039
- PropertyValueIterator.prototype.next = function() {
7040
- return this.hasNext() ? this._parts[this._i++] : null;
7041
- };
7042
- PropertyValueIterator.prototype.previous = function() {
7043
- return this._i > 0 ? this._parts[--this._i] : null;
7044
- };
7045
- PropertyValueIterator.prototype.restore = function() {
7046
- if (this._marks.length) {
7047
- this._i = this._marks.pop();
7048
- }
7049
- };
7050
- function PropertyValuePart(text, line, col) {
7051
- SyntaxUnit.call(this, text, line, col, Parser.PROPERTY_VALUE_PART_TYPE);
7052
- this.type = "unknown";
7053
- var temp;
7054
- if (/^([+\-]?[\d\.]+)([a-z]+)$/i.test(text)) {
7055
- this.type = "dimension";
7056
- this.value = +RegExp.$1;
7057
- this.units = RegExp.$2;
7058
- switch (this.units.toLowerCase()) {
7059
- case "em":
7060
- case "rem":
7061
- case "ex":
7062
- case "px":
7063
- case "cm":
7064
- case "mm":
7065
- case "in":
7066
- case "pt":
7067
- case "pc":
7068
- case "ch":
7069
- case "vh":
7070
- case "vw":
7071
- case "vmax":
7072
- case "vmin":
7073
- this.type = "length";
7074
- break;
7075
- case "fr":
7076
- this.type = "grid";
7077
- break;
7078
- case "deg":
7079
- case "rad":
7080
- case "grad":
7081
- this.type = "angle";
7082
- break;
7083
- case "ms":
7084
- case "s":
7085
- this.type = "time";
7086
- break;
7087
- case "hz":
7088
- case "khz":
7089
- this.type = "frequency";
7090
- break;
7091
- case "dpi":
7092
- case "dpcm":
7093
- this.type = "resolution";
7094
- break;
7095
- }
7096
- } else if (/^([+\-]?[\d\.]+)%$/i.test(text)) {
7097
- this.type = "percentage";
7098
- this.value = +RegExp.$1;
7099
- } else if (/^([+\-]?\d+)$/i.test(text)) {
7100
- this.type = "integer";
7101
- this.value = +RegExp.$1;
7102
- } else if (/^([+\-]?[\d\.]+)$/i.test(text)) {
7103
- this.type = "number";
7104
- this.value = +RegExp.$1;
7105
- } else if (/^#([a-f0-9]{3,6})/i.test(text)) {
7106
- this.type = "color";
7107
- temp = RegExp.$1;
7108
- if (temp.length === 3) {
7109
- this.red = parseInt(temp.charAt(0) + temp.charAt(0), 16);
7110
- this.green = parseInt(temp.charAt(1) + temp.charAt(1), 16);
7111
- this.blue = parseInt(temp.charAt(2) + temp.charAt(2), 16);
7112
- } else {
7113
- this.red = parseInt(temp.substring(0, 2), 16);
7114
- this.green = parseInt(temp.substring(2, 4), 16);
7115
- this.blue = parseInt(temp.substring(4, 6), 16);
7116
- }
7117
- } else if (/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i.test(text)) {
7118
- this.type = "color";
7119
- this.red = +RegExp.$1;
7120
- this.green = +RegExp.$2;
7121
- this.blue = +RegExp.$3;
7122
- } else if (/^rgb\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)) {
7123
- this.type = "color";
7124
- this.red = +RegExp.$1 * 255 / 100;
7125
- this.green = +RegExp.$2 * 255 / 100;
7126
- this.blue = +RegExp.$3 * 255 / 100;
7127
- } else if (/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d\.]+)\s*\)/i.test(text)) {
7128
- this.type = "color";
7129
- this.red = +RegExp.$1;
7130
- this.green = +RegExp.$2;
7131
- this.blue = +RegExp.$3;
7132
- this.alpha = +RegExp.$4;
7133
- } else if (/^rgba\(\s*(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)) {
7134
- this.type = "color";
7135
- this.red = +RegExp.$1 * 255 / 100;
7136
- this.green = +RegExp.$2 * 255 / 100;
7137
- this.blue = +RegExp.$3 * 255 / 100;
7138
- this.alpha = +RegExp.$4;
7139
- } else if (/^hsl\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*\)/i.test(text)) {
7140
- this.type = "color";
7141
- this.hue = +RegExp.$1;
7142
- this.saturation = +RegExp.$2 / 100;
7143
- this.lightness = +RegExp.$3 / 100;
7144
- } else if (/^hsla\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*,\s*([\d\.]+)\s*\)/i.test(text)) {
7145
- this.type = "color";
7146
- this.hue = +RegExp.$1;
7147
- this.saturation = +RegExp.$2 / 100;
7148
- this.lightness = +RegExp.$3 / 100;
7149
- this.alpha = +RegExp.$4;
7150
- } else if (/^url\(["']?([^\)"']+)["']?\)/i.test(text)) {
7151
- this.type = "uri";
7152
- this.uri = RegExp.$1;
7153
- } else if (/^([^\(]+)\(/i.test(text)) {
7154
- this.type = "function";
7155
- this.name = RegExp.$1;
7156
- this.value = text;
7157
- } else if (/^"([^\n\r\f\\"]|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*"/i.test(text)) {
7158
- this.type = "string";
7159
- this.value = PropertyValuePart.parseString(text);
7160
- } else if (/^'([^\n\r\f\\']|\\\r\n|\\[^\r0-9a-f]|\\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)*'/i.test(text)) {
7161
- this.type = "string";
7162
- this.value = PropertyValuePart.parseString(text);
7163
- } else if (Colors[text.toLowerCase()]) {
7164
- this.type = "color";
7165
- temp = Colors[text.toLowerCase()].substring(1);
7166
- this.red = parseInt(temp.substring(0, 2), 16);
7167
- this.green = parseInt(temp.substring(2, 4), 16);
7168
- this.blue = parseInt(temp.substring(4, 6), 16);
7169
- } else if (/^[\,\/]$/.test(text)) {
7170
- this.type = "operator";
7171
- this.value = text;
7172
- } else if (/^[a-z\-_\u0080-\uFFFF][a-z0-9\-_\u0080-\uFFFF]*$/i.test(text)) {
7173
- this.type = "identifier";
7174
- this.value = text;
7175
- }
7176
- }
7177
- PropertyValuePart.prototype = new SyntaxUnit();
7178
- PropertyValuePart.prototype.constructor = PropertyValuePart;
7179
- PropertyValuePart.parseString = function(str) {
7180
- str = str.slice(1, -1);
7181
- var replacer = function(match, esc) {
7182
- if (/^(\n|\r\n|\r|\f)$/.test(esc)) {
7183
- return "";
7184
- }
7185
- var m = /^[0-9a-f]{1,6}/i.exec(esc);
7186
- if (m) {
7187
- var codePoint = parseInt(m[0], 16);
7188
- if (String.fromCodePoint) {
7189
- return String.fromCodePoint(codePoint);
7190
- } else {
7191
- return String.fromCharCode(codePoint);
7192
- }
7193
- }
7194
- return esc;
7195
- };
7196
- return str.replace(
7197
- /\\(\r\n|[^\r0-9a-f]|[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?)/ig,
7198
- replacer
7199
- );
7200
- };
7201
- PropertyValuePart.serializeString = function(value) {
7202
- var replacer = function(match, c) {
7203
- if (c === '"') {
7204
- return "\\" + c;
7205
- }
7206
- var cp = String.codePointAt ? String.codePointAt(0) : String.charCodeAt(0);
7207
- return "\\" + cp.toString(16) + " ";
7208
- };
7209
- return '"' + value.replace(/["\r\n\f]/g, replacer) + '"';
7210
- };
7211
- PropertyValuePart.fromToken = function(token) {
7212
- return new PropertyValuePart(token.value, token.startLine, token.startCol);
7213
- };
7214
- var Pseudos = {
7215
- __proto__: null,
7216
- ":first-letter": 1,
7217
- ":first-line": 1,
7218
- ":before": 1,
7219
- ":after": 1
7220
- };
7221
- Pseudos.ELEMENT = 1;
7222
- Pseudos.CLASS = 2;
7223
- Pseudos.isElement = function(pseudo) {
7224
- return pseudo.indexOf("::") === 0 || Pseudos[pseudo.toLowerCase()] === Pseudos.ELEMENT;
7225
- };
7226
- function Selector(parts, line, col) {
7227
- SyntaxUnit.call(this, parts.join(" "), line, col, Parser.SELECTOR_TYPE);
7228
- this.parts = parts;
7229
- this.specificity = Specificity.calculate(this);
7230
- }
7231
- Selector.prototype = new SyntaxUnit();
7232
- Selector.prototype.constructor = Selector;
7233
- function SelectorPart(elementName, modifiers, text, line, col) {
7234
- SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_PART_TYPE);
7235
- this.elementName = elementName;
7236
- this.modifiers = modifiers;
7237
- }
7238
- SelectorPart.prototype = new SyntaxUnit();
7239
- SelectorPart.prototype.constructor = SelectorPart;
7240
- function SelectorSubPart(text, type, line, col) {
7241
- SyntaxUnit.call(this, text, line, col, Parser.SELECTOR_SUB_PART_TYPE);
7242
- this.type = type;
7243
- this.args = [];
7244
- }
7245
- SelectorSubPart.prototype = new SyntaxUnit();
7246
- SelectorSubPart.prototype.constructor = SelectorSubPart;
7247
- function Specificity(a, b, c, d) {
7248
- this.a = a;
7249
- this.b = b;
7250
- this.c = c;
7251
- this.d = d;
7252
- }
7253
- Specificity.prototype = {
7254
- constructor: Specificity,
7255
- compare: function(other) {
7256
- var comps = ["a", "b", "c", "d"], i, len;
7257
- for (i = 0, len = comps.length; i < len; i++) {
7258
- if (this[comps[i]] < other[comps[i]]) {
7259
- return -1;
7260
- } else if (this[comps[i]] > other[comps[i]]) {
7261
- return 1;
7262
- }
7263
- }
7264
- return 0;
7265
- },
7266
- valueOf: function() {
7267
- return this.a * 1e3 + this.b * 100 + this.c * 10 + this.d;
7268
- },
7269
- toString: function() {
7270
- return this.a + "," + this.b + "," + this.c + "," + this.d;
7271
- }
7272
- };
7273
- Specificity.calculate = function(selector) {
7274
- var i, len, part, b = 0, c = 0, d = 0;
7275
- function updateValues(part2) {
7276
- var i2, j, len2, num, elementName = part2.elementName ? part2.elementName.text : "", modifier;
7277
- if (elementName && elementName.charAt(elementName.length - 1) !== "*") {
7278
- d++;
7279
- }
7280
- for (i2 = 0, len2 = part2.modifiers.length; i2 < len2; i2++) {
7281
- modifier = part2.modifiers[i2];
7282
- switch (modifier.type) {
7283
- case "class":
7284
- case "attribute":
7285
- c++;
7286
- break;
7287
- case "id":
7288
- b++;
7289
- break;
7290
- case "pseudo":
7291
- if (Pseudos.isElement(modifier.text)) {
7292
- d++;
7293
- } else {
7294
- c++;
7295
- }
7296
- break;
7297
- case "not":
7298
- for (j = 0, num = modifier.args.length; j < num; j++) {
7299
- updateValues(modifier.args[j]);
7300
- }
7301
- }
7302
- }
7303
- }
7304
- for (i = 0, len = selector.parts.length; i < len; i++) {
7305
- part = selector.parts[i];
7306
- if (part instanceof SelectorPart) {
7307
- updateValues(part);
7308
- }
7309
- }
7310
- return new Specificity(0, b, c, d);
7311
- };
7312
- var h = /^[0-9a-fA-F]$/, nl = /\n|\r\n|\r|\f/;
7313
- function isHexDigit(c) {
7314
- return c !== null && h.test(c);
7315
- }
7316
- function isDigit(c) {
7317
- return c !== null && /\d/.test(c);
7318
- }
7319
- function isWhitespace(c) {
7320
- return c !== null && /\s/.test(c);
7321
- }
7322
- function isNewLine(c) {
7323
- return c !== null && nl.test(c);
7324
- }
7325
- function isNameStart(c) {
7326
- return c !== null && /[a-z_\u0080-\uFFFF\\]/i.test(c);
7327
- }
7328
- function isNameChar(c) {
7329
- return c !== null && (isNameStart(c) || /[0-9\-\\]/.test(c));
7330
- }
7331
- function isIdentStart(c) {
7332
- return c !== null && (isNameStart(c) || /\-\\/.test(c));
7333
- }
7334
- function mix(receiver, supplier) {
7335
- for (var prop in supplier) {
7336
- if (Object.prototype.hasOwnProperty.call(supplier, prop)) {
7337
- receiver[prop] = supplier[prop];
7338
- }
7339
- }
7340
- return receiver;
7341
- }
7342
- function TokenStream(input) {
7343
- TokenStreamBase.call(this, input, Tokens);
7344
- }
7345
- TokenStream.prototype = mix(new TokenStreamBase(), {
7346
- _getToken: function(channel) {
7347
- var c, reader = this._reader, token = null, startLine = reader.getLine(), startCol = reader.getCol();
7348
- c = reader.read();
7349
- while (c) {
7350
- switch (c) {
7351
- case "/":
7352
- if (reader.peek() === "*") {
7353
- token = this.commentToken(c, startLine, startCol);
7354
- } else {
7355
- token = this.charToken(c, startLine, startCol);
7356
- }
7357
- break;
7358
- case "|":
7359
- case "~":
7360
- case "^":
7361
- case "$":
7362
- case "*":
7363
- if (reader.peek() === "=") {
7364
- token = this.comparisonToken(c, startLine, startCol);
7365
- } else {
7366
- token = this.charToken(c, startLine, startCol);
7367
- }
7368
- break;
7369
- case '"':
7370
- case "'":
7371
- token = this.stringToken(c, startLine, startCol);
7372
- break;
7373
- case "#":
7374
- if (isNameChar(reader.peek())) {
7375
- token = this.hashToken(c, startLine, startCol);
7376
- } else {
7377
- token = this.charToken(c, startLine, startCol);
7378
- }
7379
- break;
7380
- case ".":
7381
- if (isDigit(reader.peek())) {
7382
- token = this.numberToken(c, startLine, startCol);
7383
- } else {
7384
- token = this.charToken(c, startLine, startCol);
7385
- }
7386
- break;
7387
- case "-":
7388
- if (reader.peek() === "-") {
7389
- token = this.htmlCommentEndToken(c, startLine, startCol);
7390
- } else if (isNameStart(reader.peek())) {
7391
- token = this.identOrFunctionToken(c, startLine, startCol);
7392
- } else {
7393
- token = this.charToken(c, startLine, startCol);
7394
- }
7395
- break;
7396
- case "!":
7397
- token = this.importantToken(c, startLine, startCol);
7398
- break;
7399
- case "@":
7400
- token = this.atRuleToken(c, startLine, startCol);
7401
- break;
7402
- case ":":
7403
- token = this.notToken(c, startLine, startCol);
7404
- break;
7405
- case "<":
7406
- token = this.htmlCommentStartToken(c, startLine, startCol);
7407
- break;
7408
- case "U":
7409
- case "u":
7410
- if (reader.peek() === "+") {
7411
- token = this.unicodeRangeToken(c, startLine, startCol);
7412
- break;
7413
- }
7414
- default:
7415
- if (isDigit(c)) {
7416
- token = this.numberToken(c, startLine, startCol);
7417
- } else if (isWhitespace(c)) {
7418
- token = this.whitespaceToken(c, startLine, startCol);
7419
- } else if (isIdentStart(c)) {
7420
- token = this.identOrFunctionToken(c, startLine, startCol);
7421
- } else {
7422
- token = this.charToken(c, startLine, startCol);
7423
- }
7424
- }
7425
- break;
7426
- }
7427
- if (!token && c === null) {
7428
- token = this.createToken(Tokens.EOF, null, startLine, startCol);
7429
- }
7430
- return token;
7431
- },
7432
- createToken: function(tt, value, startLine, startCol, options) {
7433
- var reader = this._reader;
7434
- options = options || {};
7435
- return {
7436
- value,
7437
- type: tt,
7438
- channel: options.channel,
7439
- endChar: options.endChar,
7440
- hide: options.hide || false,
7441
- startLine,
7442
- startCol,
7443
- endLine: reader.getLine(),
7444
- endCol: reader.getCol()
7445
- };
7446
- },
7447
- atRuleToken: function(first, startLine, startCol) {
7448
- var rule = first, reader = this._reader, tt = Tokens.CHAR, ident;
7449
- reader.mark();
7450
- ident = this.readName();
7451
- rule = first + ident;
7452
- tt = Tokens.type(rule.toLowerCase());
7453
- if (tt === Tokens.CHAR || tt === Tokens.UNKNOWN) {
7454
- if (rule.length > 1) {
7455
- tt = Tokens.UNKNOWN_SYM;
7456
- } else {
7457
- tt = Tokens.CHAR;
7458
- rule = first;
7459
- reader.reset();
7460
- }
7461
- }
7462
- return this.createToken(tt, rule, startLine, startCol);
7463
- },
7464
- charToken: function(c, startLine, startCol) {
7465
- var tt = Tokens.type(c);
7466
- var opts = {};
7467
- if (tt === -1) {
7468
- tt = Tokens.CHAR;
7469
- } else {
7470
- opts.endChar = Tokens[tt].endChar;
7471
- }
7472
- return this.createToken(tt, c, startLine, startCol, opts);
7473
- },
7474
- commentToken: function(first, startLine, startCol) {
7475
- var comment = this.readComment(first);
7476
- return this.createToken(Tokens.COMMENT, comment, startLine, startCol);
7477
- },
7478
- comparisonToken: function(c, startLine, startCol) {
7479
- var reader = this._reader, comparison = c + reader.read(), tt = Tokens.type(comparison) || Tokens.CHAR;
7480
- return this.createToken(tt, comparison, startLine, startCol);
7481
- },
7482
- hashToken: function(first, startLine, startCol) {
7483
- var name = this.readName(first);
7484
- return this.createToken(Tokens.HASH, name, startLine, startCol);
7485
- },
7486
- htmlCommentStartToken: function(first, startLine, startCol) {
7487
- var reader = this._reader, text = first;
7488
- reader.mark();
7489
- text += reader.readCount(3);
7490
- if (text === "<!--") {
7491
- return this.createToken(Tokens.CDO, text, startLine, startCol);
7492
- } else {
7493
- reader.reset();
7494
- return this.charToken(first, startLine, startCol);
7495
- }
7496
- },
7497
- htmlCommentEndToken: function(first, startLine, startCol) {
7498
- var reader = this._reader, text = first;
7499
- reader.mark();
7500
- text += reader.readCount(2);
7501
- if (text === "-->") {
7502
- return this.createToken(Tokens.CDC, text, startLine, startCol);
7503
- } else {
7504
- reader.reset();
7505
- return this.charToken(first, startLine, startCol);
7506
- }
7507
- },
7508
- identOrFunctionToken: function(first, startLine, startCol) {
7509
- var reader = this._reader, ident = this.readName(first), tt = Tokens.IDENT, uriFns = ["url(", "url-prefix(", "domain("];
7510
- if (reader.peek() === "(") {
7511
- ident += reader.read();
7512
- if (uriFns.indexOf(ident.toLowerCase()) > -1) {
7513
- tt = Tokens.URI;
7514
- ident = this.readURI(ident);
7515
- if (uriFns.indexOf(ident.toLowerCase()) > -1) {
7516
- tt = Tokens.FUNCTION;
7517
- }
7518
- } else {
7519
- tt = Tokens.FUNCTION;
7520
- }
7521
- } else if (reader.peek() === ":") {
7522
- if (ident.toLowerCase() === "progid") {
7523
- ident += reader.readTo("(");
7524
- tt = Tokens.IE_FUNCTION;
7525
- }
7526
- }
7527
- return this.createToken(tt, ident, startLine, startCol);
7528
- },
7529
- importantToken: function(first, startLine, startCol) {
7530
- var reader = this._reader, important = first, tt = Tokens.CHAR, temp, c;
7531
- reader.mark();
7532
- c = reader.read();
7533
- while (c) {
7534
- if (c === "/") {
7535
- if (reader.peek() !== "*") {
7536
- break;
7537
- } else {
7538
- temp = this.readComment(c);
7539
- if (temp === "") {
7540
- break;
7541
- }
7542
- }
7543
- } else if (isWhitespace(c)) {
7544
- important += c + this.readWhitespace();
7545
- } else if (/i/i.test(c)) {
7546
- temp = reader.readCount(8);
7547
- if (/mportant/i.test(temp)) {
7548
- important += c + temp;
7549
- tt = Tokens.IMPORTANT_SYM;
7550
- }
7551
- break;
7552
- } else {
7553
- break;
7554
- }
7555
- c = reader.read();
7556
- }
7557
- if (tt === Tokens.CHAR) {
7558
- reader.reset();
7559
- return this.charToken(first, startLine, startCol);
7560
- } else {
7561
- return this.createToken(tt, important, startLine, startCol);
7562
- }
7563
- },
7564
- notToken: function(first, startLine, startCol) {
7565
- var reader = this._reader, text = first;
7566
- reader.mark();
7567
- text += reader.readCount(4);
7568
- if (text.toLowerCase() === ":not(") {
7569
- return this.createToken(Tokens.NOT, text, startLine, startCol);
7570
- } else {
7571
- reader.reset();
7572
- return this.charToken(first, startLine, startCol);
7573
- }
7574
- },
7575
- numberToken: function(first, startLine, startCol) {
7576
- var reader = this._reader, value = this.readNumber(first), ident, tt = Tokens.NUMBER, c = reader.peek();
7577
- if (isIdentStart(c)) {
7578
- ident = this.readName(reader.read());
7579
- value += ident;
7580
- if (/^em$|^ex$|^px$|^gd$|^rem$|^vw$|^vh$|^vmax$|^vmin$|^ch$|^cm$|^mm$|^in$|^pt$|^pc$/i.test(ident)) {
7581
- tt = Tokens.LENGTH;
7582
- } else if (/^deg|^rad$|^grad$/i.test(ident)) {
7583
- tt = Tokens.ANGLE;
7584
- } else if (/^ms$|^s$/i.test(ident)) {
7585
- tt = Tokens.TIME;
7586
- } else if (/^hz$|^khz$/i.test(ident)) {
7587
- tt = Tokens.FREQ;
7588
- } else if (/^dpi$|^dpcm$/i.test(ident)) {
7589
- tt = Tokens.RESOLUTION;
7590
- } else {
7591
- tt = Tokens.DIMENSION;
7592
- }
7593
- } else if (c === "%") {
7594
- value += reader.read();
7595
- tt = Tokens.PERCENTAGE;
7596
- }
7597
- return this.createToken(tt, value, startLine, startCol);
7598
- },
7599
- stringToken: function(first, startLine, startCol) {
7600
- var delim = first, string = first, reader = this._reader, prev = first, tt = Tokens.STRING, c = reader.read();
7601
- while (c) {
7602
- string += c;
7603
- if (c === delim && prev !== "\\") {
7604
- break;
7605
- }
7606
- if (isNewLine(reader.peek()) && c !== "\\") {
7607
- tt = Tokens.INVALID;
7608
- break;
7609
- }
7610
- prev = c;
7611
- c = reader.read();
7612
- }
7613
- if (c === null) {
7614
- tt = Tokens.INVALID;
7615
- }
7616
- return this.createToken(tt, string, startLine, startCol);
7617
- },
7618
- unicodeRangeToken: function(first, startLine, startCol) {
7619
- var reader = this._reader, value = first, temp, tt = Tokens.CHAR;
7620
- if (reader.peek() === "+") {
7621
- reader.mark();
7622
- value += reader.read();
7623
- value += this.readUnicodeRangePart(true);
7624
- if (value.length === 2) {
7625
- reader.reset();
7626
- } else {
7627
- tt = Tokens.UNICODE_RANGE;
7628
- if (value.indexOf("?") === -1) {
7629
- if (reader.peek() === "-") {
7630
- reader.mark();
7631
- temp = reader.read();
7632
- temp += this.readUnicodeRangePart(false);
7633
- if (temp.length === 1) {
7634
- reader.reset();
7635
- } else {
7636
- value += temp;
7637
- }
7638
- }
7639
- }
7640
- }
7641
- }
7642
- return this.createToken(tt, value, startLine, startCol);
7643
- },
7644
- whitespaceToken: function(first, startLine, startCol) {
7645
- var value = first + this.readWhitespace();
7646
- return this.createToken(Tokens.S, value, startLine, startCol);
7647
- },
7648
- readUnicodeRangePart: function(allowQuestionMark) {
7649
- var reader = this._reader, part = "", c = reader.peek();
7650
- while (isHexDigit(c) && part.length < 6) {
7651
- reader.read();
7652
- part += c;
7653
- c = reader.peek();
7654
- }
7655
- if (allowQuestionMark) {
7656
- while (c === "?" && part.length < 6) {
7657
- reader.read();
7658
- part += c;
7659
- c = reader.peek();
7660
- }
7661
- }
7662
- return part;
7663
- },
7664
- readWhitespace: function() {
7665
- var reader = this._reader, whitespace = "", c = reader.peek();
7666
- while (isWhitespace(c)) {
7667
- reader.read();
7668
- whitespace += c;
7669
- c = reader.peek();
7670
- }
7671
- return whitespace;
7672
- },
7673
- readNumber: function(first) {
7674
- var reader = this._reader, number = first, hasDot = first === ".", c = reader.peek();
7675
- while (c) {
7676
- if (isDigit(c)) {
7677
- number += reader.read();
7678
- } else if (c === ".") {
7679
- if (hasDot) {
7680
- break;
7681
- } else {
7682
- hasDot = true;
7683
- number += reader.read();
7684
- }
7685
- } else {
7686
- break;
7687
- }
7688
- c = reader.peek();
7689
- }
7690
- return number;
7691
- },
7692
- readString: function() {
7693
- var reader = this._reader, delim = reader.read(), string = delim, prev = delim, c = reader.peek();
7694
- while (c) {
7695
- c = reader.read();
7696
- string += c;
7697
- if (c === delim && prev !== "\\") {
7698
- break;
7699
- }
7700
- if (isNewLine(reader.peek()) && c !== "\\") {
7701
- string = "";
7702
- break;
7703
- }
7704
- prev = c;
7705
- c = reader.peek();
7706
- }
7707
- if (c === null) {
7708
- string = "";
7709
- }
7710
- return string;
7711
- },
7712
- readURI: function(first) {
7713
- var reader = this._reader, uri = first, inner = "", c = reader.peek();
7714
- reader.mark();
7715
- while (c && isWhitespace(c)) {
7716
- reader.read();
7717
- c = reader.peek();
7718
- }
7719
- if (c === "'" || c === '"') {
7720
- inner = this.readString();
7721
- } else {
7722
- inner = this.readURL();
7723
- }
7724
- c = reader.peek();
7725
- while (c && isWhitespace(c)) {
7726
- reader.read();
7727
- c = reader.peek();
7728
- }
7729
- if (inner === "" || c !== ")") {
7730
- uri = first;
7731
- reader.reset();
7732
- } else {
7733
- uri += inner + reader.read();
7734
- }
7735
- return uri;
7736
- },
7737
- readURL: function() {
7738
- var reader = this._reader, url = "", c = reader.peek();
7739
- while (/^[!#$%&\\*-~]$/.test(c)) {
7740
- url += reader.read();
7741
- c = reader.peek();
7742
- }
7743
- return url;
7744
- },
7745
- readName: function(first) {
7746
- var reader = this._reader, ident = first || "", c = reader.peek();
7747
- while (true) {
7748
- if (c === "\\") {
7749
- ident += this.readEscape(reader.read());
7750
- c = reader.peek();
7751
- } else if (c && isNameChar(c)) {
7752
- ident += reader.read();
7753
- c = reader.peek();
7754
- } else {
7755
- break;
7756
- }
7757
- }
7758
- return ident;
7759
- },
7760
- readEscape: function(first) {
7761
- var reader = this._reader, cssEscape = first || "", i = 0, c = reader.peek();
7762
- if (isHexDigit(c)) {
7763
- do {
7764
- cssEscape += reader.read();
7765
- c = reader.peek();
7766
- } while (c && isHexDigit(c) && ++i < 6);
7767
- }
7768
- if (cssEscape.length === 3 && /\s/.test(c) || cssEscape.length === 7 || cssEscape.length === 1) {
7769
- reader.read();
7770
- } else {
7771
- c = "";
7772
- }
7773
- return cssEscape + c;
7774
- },
7775
- readComment: function(first) {
7776
- var reader = this._reader, comment = first || "", c = reader.read();
7777
- if (c === "*") {
7778
- while (c) {
7779
- comment += c;
7780
- if (comment.length > 2 && c === "*" && reader.peek() === "/") {
7781
- comment += reader.read();
7782
- break;
7783
- }
7784
- c = reader.read();
7785
- }
7786
- return comment;
7787
- } else {
7788
- return "";
7789
- }
7790
- }
7791
- });
7792
- var Tokens = [
7793
- { name: "CDO" },
7794
- { name: "CDC" },
7795
- { name: "S", whitespace: true },
7796
- { name: "COMMENT", comment: true, hide: true, channel: "comment" },
7797
- { name: "INCLUDES", text: "~=" },
7798
- { name: "DASHMATCH", text: "|=" },
7799
- { name: "PREFIXMATCH", text: "^=" },
7800
- { name: "SUFFIXMATCH", text: "$=" },
7801
- { name: "SUBSTRINGMATCH", text: "*=" },
7802
- { name: "STRING" },
7803
- { name: "IDENT" },
7804
- { name: "HASH" },
7805
- { name: "IMPORT_SYM", text: "@import" },
7806
- { name: "PAGE_SYM", text: "@page" },
7807
- { name: "MEDIA_SYM", text: "@media" },
7808
- { name: "FONT_FACE_SYM", text: "@font-face" },
7809
- { name: "CHARSET_SYM", text: "@charset" },
7810
- { name: "NAMESPACE_SYM", text: "@namespace" },
7811
- { name: "VIEWPORT_SYM", text: ["@viewport", "@-ms-viewport", "@-o-viewport"] },
7812
- { name: "DOCUMENT_SYM", text: ["@document", "@-moz-document"] },
7813
- { name: "UNKNOWN_SYM" },
7814
- { name: "KEYFRAMES_SYM", text: ["@keyframes", "@-webkit-keyframes", "@-moz-keyframes", "@-o-keyframes"] },
7815
- { name: "IMPORTANT_SYM" },
7816
- { name: "LENGTH" },
7817
- { name: "ANGLE" },
7818
- { name: "TIME" },
7819
- { name: "FREQ" },
7820
- { name: "DIMENSION" },
7821
- { name: "PERCENTAGE" },
7822
- { name: "NUMBER" },
7823
- { name: "URI" },
7824
- { name: "FUNCTION" },
7825
- { name: "UNICODE_RANGE" },
7826
- { name: "INVALID" },
7827
- { name: "PLUS", text: "+" },
7828
- { name: "GREATER", text: ">" },
7829
- { name: "COMMA", text: "," },
7830
- { name: "TILDE", text: "~" },
7831
- { name: "NOT" },
7832
- { name: "TOPLEFTCORNER_SYM", text: "@top-left-corner" },
7833
- { name: "TOPLEFT_SYM", text: "@top-left" },
7834
- { name: "TOPCENTER_SYM", text: "@top-center" },
7835
- { name: "TOPRIGHT_SYM", text: "@top-right" },
7836
- { name: "TOPRIGHTCORNER_SYM", text: "@top-right-corner" },
7837
- { name: "BOTTOMLEFTCORNER_SYM", text: "@bottom-left-corner" },
7838
- { name: "BOTTOMLEFT_SYM", text: "@bottom-left" },
7839
- { name: "BOTTOMCENTER_SYM", text: "@bottom-center" },
7840
- { name: "BOTTOMRIGHT_SYM", text: "@bottom-right" },
7841
- { name: "BOTTOMRIGHTCORNER_SYM", text: "@bottom-right-corner" },
7842
- { name: "LEFTTOP_SYM", text: "@left-top" },
7843
- { name: "LEFTMIDDLE_SYM", text: "@left-middle" },
7844
- { name: "LEFTBOTTOM_SYM", text: "@left-bottom" },
7845
- { name: "RIGHTTOP_SYM", text: "@right-top" },
7846
- { name: "RIGHTMIDDLE_SYM", text: "@right-middle" },
7847
- { name: "RIGHTBOTTOM_SYM", text: "@right-bottom" },
7848
- { name: "RESOLUTION", state: "media" },
7849
- { name: "IE_FUNCTION" },
7850
- { name: "CHAR" },
7851
- {
7852
- name: "PIPE",
7853
- text: "|"
7854
- },
7855
- {
7856
- name: "SLASH",
7857
- text: "/"
7858
- },
7859
- {
7860
- name: "MINUS",
7861
- text: "-"
7862
- },
7863
- {
7864
- name: "STAR",
7865
- text: "*"
7866
- },
7867
- {
7868
- name: "LBRACE",
7869
- endChar: "}",
7870
- text: "{"
7871
- },
7872
- {
7873
- name: "RBRACE",
7874
- text: "}"
7875
- },
7876
- {
7877
- name: "LBRACKET",
7878
- endChar: "]",
7879
- text: "["
7880
- },
7881
- {
7882
- name: "RBRACKET",
7883
- text: "]"
7884
- },
7885
- {
7886
- name: "EQUALS",
7887
- text: "="
7888
- },
7889
- {
7890
- name: "COLON",
7891
- text: ":"
7892
- },
7893
- {
7894
- name: "SEMICOLON",
7895
- text: ";"
7896
- },
7897
- {
7898
- name: "LPAREN",
7899
- endChar: ")",
7900
- text: "("
7901
- },
7902
- {
7903
- name: "RPAREN",
7904
- text: ")"
7905
- },
7906
- {
7907
- name: "DOT",
7908
- text: "."
7909
- }
7910
- ];
7911
- (function() {
7912
- var nameMap = [], typeMap = /* @__PURE__ */ Object.create(null);
7913
- Tokens.UNKNOWN = -1;
7914
- Tokens.unshift({ name: "EOF" });
7915
- for (var i = 0, len = Tokens.length; i < len; i++) {
7916
- nameMap.push(Tokens[i].name);
7917
- Tokens[Tokens[i].name] = i;
7918
- if (Tokens[i].text) {
7919
- if (Tokens[i].text instanceof Array) {
7920
- for (var j = 0; j < Tokens[i].text.length; j++) {
7921
- typeMap[Tokens[i].text[j]] = i;
7922
- }
7923
- } else {
7924
- typeMap[Tokens[i].text] = i;
7925
- }
7926
- }
7927
- }
7928
- Tokens.name = function(tt) {
7929
- return nameMap[tt];
7930
- };
7931
- Tokens.type = function(c) {
7932
- return typeMap[c] || -1;
7933
- };
7934
- })();
7935
- var Validation = {
7936
- validate: function(property, value) {
7937
- var name = property.toString().toLowerCase(), expression = new PropertyValueIterator(value), spec = Properties[name];
7938
- if (!spec) {
7939
- if (name.indexOf("-") !== 0) {
7940
- throw new ValidationError("Unknown property '" + property + "'.", property.line, property.col);
7941
- }
7942
- } else if (typeof spec !== "number") {
7943
- if (typeof spec === "string") {
7944
- if (spec.indexOf("||") > -1) {
7945
- this.groupProperty(spec, expression);
7946
- } else {
7947
- this.singleProperty(spec, expression, 1);
7948
- }
7949
- } else if (spec.multi) {
7950
- this.multiProperty(spec.multi, expression, spec.comma, spec.max || Infinity);
7951
- } else if (typeof spec === "function") {
7952
- spec(expression);
7953
- }
7954
- }
7955
- },
7956
- singleProperty: function(types, expression, max, partial) {
7957
- var result = false, value = expression.value, count = 0, part;
7958
- while (expression.hasNext() && count < max) {
7959
- result = ValidationTypes.isAny(expression, types);
7960
- if (!result) {
7961
- break;
7962
- }
7963
- count++;
7964
- }
7965
- if (!result) {
7966
- if (expression.hasNext() && !expression.isFirst()) {
7967
- part = expression.peek();
7968
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
7969
- } else {
7970
- throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
7971
- }
7972
- } else if (expression.hasNext()) {
7973
- part = expression.next();
7974
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
7975
- }
7976
- },
7977
- multiProperty: function(types, expression, comma, max) {
7978
- var result = false, value = expression.value, count = 0, part;
7979
- while (expression.hasNext() && !result && count < max) {
7980
- if (ValidationTypes.isAny(expression, types)) {
7981
- count++;
7982
- if (!expression.hasNext()) {
7983
- result = true;
7984
- } else if (comma) {
7985
- if (String(expression.peek()) === ",") {
7986
- part = expression.next();
7987
- } else {
7988
- break;
7989
- }
7990
- }
7991
- } else {
7992
- break;
7993
- }
7994
- }
7995
- if (!result) {
7996
- if (expression.hasNext() && !expression.isFirst()) {
7997
- part = expression.peek();
7998
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
7999
- } else {
8000
- part = expression.previous();
8001
- if (comma && String(part) === ",") {
8002
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
8003
- } else {
8004
- throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
8005
- }
8006
- }
8007
- } else if (expression.hasNext()) {
8008
- part = expression.next();
8009
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
8010
- }
8011
- },
8012
- groupProperty: function(types, expression, comma) {
8013
- var result = false, value = expression.value, typeCount = types.split("||").length, groups = { count: 0 }, partial = false, name, part;
8014
- while (expression.hasNext() && !result) {
8015
- name = ValidationTypes.isAnyOfGroup(expression, types);
8016
- if (name) {
8017
- if (groups[name]) {
8018
- break;
8019
- } else {
8020
- groups[name] = 1;
8021
- groups.count++;
8022
- partial = true;
8023
- if (groups.count === typeCount || !expression.hasNext()) {
8024
- result = true;
8025
- }
8026
- }
8027
- } else {
8028
- break;
8029
- }
8030
- }
8031
- if (!result) {
8032
- if (partial && expression.hasNext()) {
8033
- part = expression.peek();
8034
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
8035
- } else {
8036
- throw new ValidationError("Expected (" + types + ") but found '" + value + "'.", value.line, value.col);
8037
- }
8038
- } else if (expression.hasNext()) {
8039
- part = expression.next();
8040
- throw new ValidationError("Expected end of value but found '" + part + "'.", part.line, part.col);
8041
- }
8042
- }
8043
- };
8044
- function ValidationError(message, line, col) {
8045
- this.col = col;
8046
- this.line = line;
8047
- this.message = message;
8048
- }
8049
- ValidationError.prototype = new Error();
8050
- var ValidationTypes = {
8051
- isLiteral: function(part, literals) {
8052
- var text = part.text.toString().toLowerCase(), args = literals.split(" | "), i, len, found = false;
8053
- for (i = 0, len = args.length; i < len && !found; i++) {
8054
- if (text === args[i].toLowerCase()) {
8055
- found = true;
8056
- }
8057
- }
8058
- return found;
8059
- },
8060
- isSimple: function(type) {
8061
- return !!this.simple[type];
8062
- },
8063
- isComplex: function(type) {
8064
- return !!this.complex[type];
8065
- },
8066
- isAny: function(expression, types) {
8067
- var args = types.split(" | "), i, len, found = false;
8068
- for (i = 0, len = args.length; i < len && !found && expression.hasNext(); i++) {
8069
- found = this.isType(expression, args[i]);
8070
- }
8071
- return found;
8072
- },
8073
- isAnyOfGroup: function(expression, types) {
8074
- var args = types.split(" || "), i, len, found = false;
8075
- for (i = 0, len = args.length; i < len && !found; i++) {
8076
- found = this.isType(expression, args[i]);
8077
- }
8078
- return found ? args[i - 1] : false;
8079
- },
8080
- isType: function(expression, type) {
8081
- var part = expression.peek(), result = false;
8082
- if (type.charAt(0) !== "<") {
8083
- result = this.isLiteral(part, type);
8084
- if (result) {
8085
- expression.next();
8086
- }
8087
- } else if (this.simple[type]) {
8088
- result = this.simple[type](part);
8089
- if (result) {
8090
- expression.next();
8091
- }
8092
- } else {
8093
- result = this.complex[type](expression);
8094
- }
8095
- return result;
8096
- },
8097
- simple: {
8098
- __proto__: null,
8099
- "<absolute-size>": function(part) {
8100
- return ValidationTypes.isLiteral(part, "xx-small | x-small | small | medium | large | x-large | xx-large");
8101
- },
8102
- "<attachment>": function(part) {
8103
- return ValidationTypes.isLiteral(part, "scroll | fixed | local");
8104
- },
8105
- "<attr>": function(part) {
8106
- return part.type === "function" && part.name === "attr";
8107
- },
8108
- "<bg-image>": function(part) {
8109
- return this["<image>"](part) || this["<gradient>"](part) || String(part) === "none";
8110
- },
8111
- "<gradient>": function(part) {
8112
- return part.type === "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?(?:repeating\-)?(?:radial\-|linear\-)?gradient/i.test(part);
8113
- },
8114
- "<box>": function(part) {
8115
- return ValidationTypes.isLiteral(part, "padding-box | border-box | content-box");
8116
- },
8117
- "<content>": function(part) {
8118
- return part.type === "function" && part.name === "content";
8119
- },
8120
- "<relative-size>": function(part) {
8121
- return ValidationTypes.isLiteral(part, "smaller | larger");
8122
- },
8123
- "<ident>": function(part) {
8124
- return part.type === "identifier";
8125
- },
8126
- "<length>": function(part) {
8127
- if (part.type === "function" && /^(?:\-(?:ms|moz|o|webkit)\-)?calc/i.test(part)) {
8128
- return true;
8129
- } else {
8130
- return part.type === "length" || part.type === "number" || part.type === "integer" || String(part) === "0";
8131
- }
8132
- },
8133
- "<color>": function(part) {
8134
- return part.type === "color" || String(part) === "transparent" || String(part) === "currentColor";
8135
- },
8136
- "<number>": function(part) {
8137
- return part.type === "number" || this["<integer>"](part);
8138
- },
8139
- "<integer>": function(part) {
8140
- return part.type === "integer";
8141
- },
8142
- "<line>": function(part) {
8143
- return part.type === "integer";
8144
- },
8145
- "<angle>": function(part) {
8146
- return part.type === "angle";
8147
- },
8148
- "<uri>": function(part) {
8149
- return part.type === "uri";
8150
- },
8151
- "<image>": function(part) {
8152
- return this["<uri>"](part);
8153
- },
8154
- "<percentage>": function(part) {
8155
- return part.type === "percentage" || String(part) === "0";
8156
- },
8157
- "<border-width>": function(part) {
8158
- return this["<length>"](part) || ValidationTypes.isLiteral(part, "thin | medium | thick");
8159
- },
8160
- "<border-style>": function(part) {
8161
- return ValidationTypes.isLiteral(part, "none | hidden | dotted | dashed | solid | double | groove | ridge | inset | outset");
8162
- },
8163
- "<content-sizing>": function(part) {
8164
- return ValidationTypes.isLiteral(part, "fill-available | -moz-available | -webkit-fill-available | max-content | -moz-max-content | -webkit-max-content | min-content | -moz-min-content | -webkit-min-content | fit-content | -moz-fit-content | -webkit-fit-content");
8165
- },
8166
- "<margin-width>": function(part) {
8167
- return this["<length>"](part) || this["<percentage>"](part) || ValidationTypes.isLiteral(part, "auto");
8168
- },
8169
- "<padding-width>": function(part) {
8170
- return this["<length>"](part) || this["<percentage>"](part);
8171
- },
8172
- "<shape>": function(part) {
8173
- return part.type === "function" && (part.name === "rect" || part.name === "inset-rect");
8174
- },
8175
- "<time>": function(part) {
8176
- return part.type === "time";
8177
- },
8178
- "<flex-grow>": function(part) {
8179
- return this["<number>"](part);
8180
- },
8181
- "<flex-shrink>": function(part) {
8182
- return this["<number>"](part);
8183
- },
8184
- "<width>": function(part) {
8185
- return this["<margin-width>"](part);
8186
- },
8187
- "<flex-basis>": function(part) {
8188
- return this["<width>"](part);
8189
- },
8190
- "<flex-direction>": function(part) {
8191
- return ValidationTypes.isLiteral(part, "row | row-reverse | column | column-reverse");
8192
- },
8193
- "<flex-wrap>": function(part) {
8194
- return ValidationTypes.isLiteral(part, "nowrap | wrap | wrap-reverse");
8195
- },
8196
- "<feature-tag-value>": function(part) {
8197
- return part.type === "function" && /^[A-Z0-9]{4}$/i.test(part);
8198
- }
8199
- },
8200
- complex: {
8201
- __proto__: null,
8202
- "<bg-position>": function(expression) {
8203
- var result = false, numeric = "<percentage> | <length>", xDir = "left | right", yDir = "top | bottom", count = 0;
8204
- while (expression.peek(count) && expression.peek(count).text !== ",") {
8205
- count++;
8206
- }
8207
- if (count < 3) {
8208
- if (ValidationTypes.isAny(expression, xDir + " | center | " + numeric)) {
8209
- result = true;
8210
- ValidationTypes.isAny(expression, yDir + " | center | " + numeric);
8211
- } else if (ValidationTypes.isAny(expression, yDir)) {
8212
- result = true;
8213
- ValidationTypes.isAny(expression, xDir + " | center");
8214
- }
4708
+ t.query = r.query;
4709
+ else
4710
+ t.query = base.query;
8215
4711
  } else {
8216
- if (ValidationTypes.isAny(expression, xDir)) {
8217
- if (ValidationTypes.isAny(expression, yDir)) {
8218
- result = true;
8219
- ValidationTypes.isAny(expression, numeric);
8220
- } else if (ValidationTypes.isAny(expression, numeric)) {
8221
- if (ValidationTypes.isAny(expression, yDir)) {
8222
- result = true;
8223
- ValidationTypes.isAny(expression, numeric);
8224
- } else if (ValidationTypes.isAny(expression, "center")) {
8225
- result = true;
8226
- }
8227
- }
8228
- } else if (ValidationTypes.isAny(expression, yDir)) {
8229
- if (ValidationTypes.isAny(expression, xDir)) {
8230
- result = true;
8231
- ValidationTypes.isAny(expression, numeric);
8232
- } else if (ValidationTypes.isAny(expression, numeric)) {
8233
- if (ValidationTypes.isAny(expression, xDir)) {
8234
- result = true;
8235
- ValidationTypes.isAny(expression, numeric);
8236
- } else if (ValidationTypes.isAny(expression, "center")) {
8237
- result = true;
8238
- }
8239
- }
8240
- } else if (ValidationTypes.isAny(expression, "center")) {
8241
- if (ValidationTypes.isAny(expression, xDir + " | " + yDir)) {
8242
- result = true;
8243
- ValidationTypes.isAny(expression, numeric);
8244
- }
4712
+ if (r.path.charAt(0) === "/") {
4713
+ t.path = remove_dot_segments(r.path);
4714
+ } else {
4715
+ t.path = merge(base.path, r.path);
4716
+ t.path = remove_dot_segments(t.path);
8245
4717
  }
4718
+ t.query = r.query;
8246
4719
  }
8247
- return result;
8248
- },
8249
- "<bg-size>": function(expression) {
8250
- var result = false, numeric = "<percentage> | <length> | auto";
8251
- if (ValidationTypes.isAny(expression, "cover | contain")) {
8252
- result = true;
8253
- } else if (ValidationTypes.isAny(expression, numeric)) {
8254
- result = true;
8255
- ValidationTypes.isAny(expression, numeric);
4720
+ }
4721
+ }
4722
+ t.fragment = r.fragment;
4723
+ return t.toString();
4724
+ function merge(basepath, refpath) {
4725
+ if (base.host !== void 0 && !base.path)
4726
+ return "/" + refpath;
4727
+ var lastslash = basepath.lastIndexOf("/");
4728
+ if (lastslash === -1)
4729
+ return refpath;
4730
+ else
4731
+ return basepath.substring(0, lastslash + 1) + refpath;
4732
+ }
4733
+ function remove_dot_segments(path) {
4734
+ if (!path)
4735
+ return path;
4736
+ var output = "";
4737
+ while (path.length > 0) {
4738
+ if (path === "." || path === "..") {
4739
+ path = "";
4740
+ break;
8256
4741
  }
8257
- return result;
8258
- },
8259
- "<repeat-style>": function(expression) {
8260
- var result = false, values = "repeat | space | round | no-repeat", part;
8261
- if (expression.hasNext()) {
8262
- part = expression.next();
8263
- if (ValidationTypes.isLiteral(part, "repeat-x | repeat-y")) {
8264
- result = true;
8265
- } else if (ValidationTypes.isLiteral(part, values)) {
8266
- result = true;
8267
- if (expression.hasNext() && ValidationTypes.isLiteral(expression.peek(), values)) {
8268
- expression.next();
8269
- }
8270
- }
4742
+ var twochars = path.substring(0, 2);
4743
+ var threechars = path.substring(0, 3);
4744
+ var fourchars = path.substring(0, 4);
4745
+ if (threechars === "../") {
4746
+ path = path.substring(3);
4747
+ } else if (twochars === "./") {
4748
+ path = path.substring(2);
4749
+ } else if (threechars === "/./") {
4750
+ path = "/" + path.substring(3);
4751
+ } else if (twochars === "/." && path.length === 2) {
4752
+ path = "/";
4753
+ } else if (fourchars === "/../" || threechars === "/.." && path.length === 3) {
4754
+ path = "/" + path.substring(4);
4755
+ output = output.replace(/\/?[^\/]*$/, "");
4756
+ } else {
4757
+ var segment = path.match(/(\/?([^\/]*))/)[0];
4758
+ output += segment;
4759
+ path = path.substring(segment.length);
8271
4760
  }
8272
- return result;
8273
- },
8274
- "<shadow>": function(expression) {
8275
- var result = false, count = 0, inset = false, color = false;
8276
- if (expression.hasNext()) {
8277
- if (ValidationTypes.isAny(expression, "inset")) {
8278
- inset = true;
8279
- }
8280
- if (ValidationTypes.isAny(expression, "<color>")) {
8281
- color = true;
8282
- }
8283
- while (ValidationTypes.isAny(expression, "<length>") && count < 4) {
8284
- count++;
8285
- }
8286
- if (expression.hasNext()) {
8287
- if (!color) {
8288
- ValidationTypes.isAny(expression, "<color>");
8289
- }
8290
- if (!inset) {
8291
- ValidationTypes.isAny(expression, "inset");
8292
- }
8293
- }
8294
- result = count >= 2 && count <= 4;
4761
+ }
4762
+ return output;
4763
+ }
4764
+ }
4765
+ };
4766
+ }
4767
+ });
4768
+
4769
+ // external/npm/node_modules/domino/lib/CustomEvent.js
4770
+ var require_CustomEvent = __commonJS({
4771
+ "external/npm/node_modules/domino/lib/CustomEvent.js"(exports, module) {
4772
+ "use strict";
4773
+ module.exports = CustomEvent;
4774
+ var Event = require_Event();
4775
+ function CustomEvent(type, dictionary) {
4776
+ Event.call(this, type, dictionary);
4777
+ }
4778
+ CustomEvent.prototype = Object.create(Event.prototype, {
4779
+ constructor: { value: CustomEvent }
4780
+ });
4781
+ }
4782
+ });
4783
+
4784
+ // external/npm/node_modules/domino/lib/events.js
4785
+ var require_events = __commonJS({
4786
+ "external/npm/node_modules/domino/lib/events.js"(exports, module) {
4787
+ "use strict";
4788
+ module.exports = {
4789
+ Event: require_Event(),
4790
+ UIEvent: require_UIEvent(),
4791
+ MouseEvent: require_MouseEvent(),
4792
+ CustomEvent: require_CustomEvent()
4793
+ };
4794
+ }
4795
+ });
4796
+
4797
+ // external/npm/node_modules/domino/lib/style_parser.js
4798
+ var require_style_parser = __commonJS({
4799
+ "external/npm/node_modules/domino/lib/style_parser.js"(exports) {
4800
+ "use strict";
4801
+ Object.defineProperty(exports, "__esModule", { value: true });
4802
+ exports.hyphenate = exports.parse = void 0;
4803
+ function parse(value) {
4804
+ const styles = [];
4805
+ let i = 0;
4806
+ let parenDepth = 0;
4807
+ let quote = 0;
4808
+ let valueStart = 0;
4809
+ let propStart = 0;
4810
+ let currentProp = null;
4811
+ while (i < value.length) {
4812
+ const token = value.charCodeAt(i++);
4813
+ switch (token) {
4814
+ case 40:
4815
+ parenDepth++;
4816
+ break;
4817
+ case 41:
4818
+ parenDepth--;
4819
+ break;
4820
+ case 39:
4821
+ if (quote === 0) {
4822
+ quote = 39;
4823
+ } else if (quote === 39 && value.charCodeAt(i - 1) !== 92) {
4824
+ quote = 0;
8295
4825
  }
8296
- return result;
8297
- },
8298
- "<x-one-radius>": function(expression) {
8299
- var result = false, simple = "<length> | <percentage> | inherit";
8300
- if (ValidationTypes.isAny(expression, simple)) {
8301
- result = true;
8302
- ValidationTypes.isAny(expression, simple);
4826
+ break;
4827
+ case 34:
4828
+ if (quote === 0) {
4829
+ quote = 34;
4830
+ } else if (quote === 34 && value.charCodeAt(i - 1) !== 92) {
4831
+ quote = 0;
8303
4832
  }
8304
- return result;
8305
- },
8306
- "<flex>": function(expression) {
8307
- var part, result = false;
8308
- if (ValidationTypes.isAny(expression, "none | inherit")) {
8309
- result = true;
8310
- } else {
8311
- if (ValidationTypes.isType(expression, "<flex-grow>")) {
8312
- if (expression.peek()) {
8313
- if (ValidationTypes.isType(expression, "<flex-shrink>")) {
8314
- if (expression.peek()) {
8315
- result = ValidationTypes.isType(expression, "<flex-basis>");
8316
- } else {
8317
- result = true;
8318
- }
8319
- } else if (ValidationTypes.isType(expression, "<flex-basis>")) {
8320
- result = expression.peek() === null;
8321
- }
8322
- } else {
8323
- result = true;
8324
- }
8325
- } else if (ValidationTypes.isType(expression, "<flex-basis>")) {
8326
- result = true;
8327
- }
4833
+ break;
4834
+ case 58:
4835
+ if (!currentProp && parenDepth === 0 && quote === 0) {
4836
+ currentProp = hyphenate(value.substring(propStart, i - 1).trim());
4837
+ valueStart = i;
8328
4838
  }
8329
- if (!result) {
8330
- part = expression.peek();
8331
- throw new ValidationError("Expected (none | [ <flex-grow> <flex-shrink>? || <flex-basis> ]) but found '" + expression.value.text + "'.", part.line, part.col);
4839
+ break;
4840
+ case 59:
4841
+ if (currentProp && valueStart > 0 && parenDepth === 0 && quote === 0) {
4842
+ const styleVal = value.substring(valueStart, i - 1).trim();
4843
+ styles.push(currentProp, styleVal);
4844
+ propStart = i;
4845
+ valueStart = 0;
4846
+ currentProp = null;
8332
4847
  }
8333
- return result;
8334
- }
4848
+ break;
8335
4849
  }
8336
- };
8337
- parserlib.css = {
8338
- __proto__: null,
8339
- Colors,
8340
- Combinator,
8341
- Parser,
8342
- PropertyName,
8343
- PropertyValue,
8344
- PropertyValuePart,
8345
- MediaFeature,
8346
- MediaQuery,
8347
- Selector,
8348
- SelectorPart,
8349
- SelectorSubPart,
8350
- Specificity,
8351
- TokenStream,
8352
- Tokens,
8353
- ValidationError
8354
- };
8355
- })();
8356
- (function() {
8357
- for (var prop in parserlib) {
8358
- exports[prop] = parserlib[prop];
8359
4850
  }
8360
- })();
4851
+ if (currentProp && valueStart) {
4852
+ const styleVal = value.slice(valueStart).trim();
4853
+ styles.push(currentProp, styleVal);
4854
+ }
4855
+ return styles;
4856
+ }
4857
+ exports.parse = parse;
4858
+ function hyphenate(value) {
4859
+ return value.replace(/[a-z][A-Z]/g, (v) => {
4860
+ return v.charAt(0) + "-" + v.charAt(1);
4861
+ }).toLowerCase();
4862
+ }
4863
+ exports.hyphenate = hyphenate;
8361
4864
  }
8362
4865
  });
8363
4866
 
@@ -8365,23 +4868,33 @@ var require_cssparser = __commonJS({
8365
4868
  var require_CSSStyleDeclaration = __commonJS({
8366
4869
  "external/npm/node_modules/domino/lib/CSSStyleDeclaration.js"(exports, module) {
8367
4870
  "use strict";
8368
- var parserlib = require_cssparser();
4871
+ var { parse } = require_style_parser();
8369
4872
  module.exports = CSSStyleDeclaration;
8370
4873
  function CSSStyleDeclaration(elt) {
8371
4874
  this._element = elt;
8372
4875
  }
8373
- function parseStyles(s) {
8374
- var parser = new parserlib.css.Parser();
8375
- var result = { property: /* @__PURE__ */ Object.create(null), priority: /* @__PURE__ */ Object.create(null) };
8376
- parser.addListener("property", function(e) {
8377
- if (e.invalid)
8378
- return;
8379
- result.property[e.property.text] = e.value.text;
8380
- if (e.important)
8381
- result.priority[e.property.text] = "important";
8382
- });
8383
- s = ("" + s).replace(/^;/, "");
8384
- parser.parseStyleAttribute(s);
4876
+ var IMPORTANT_BANG = "!important";
4877
+ function parseStyles(value) {
4878
+ const result = {
4879
+ property: {},
4880
+ priority: {}
4881
+ };
4882
+ if (!value) {
4883
+ return result;
4884
+ }
4885
+ const styleValues = parse(value);
4886
+ if (styleValues.length < 2) {
4887
+ return result;
4888
+ }
4889
+ for (let i = 0; i < styleValues.length; i += 2) {
4890
+ const name = styleValues[i];
4891
+ let value2 = styleValues[i + 1];
4892
+ if (value2.endsWith(IMPORTANT_BANG)) {
4893
+ result.priority[name] = "important";
4894
+ value2 = value2.slice(0, -IMPORTANT_BANG.length).trim();
4895
+ }
4896
+ result.property[name] = value2;
4897
+ }
8385
4898
  return result;
8386
4899
  }
8387
4900
  var NO_CHANGE = {};
@@ -8448,6 +4961,7 @@ var require_CSSStyleDeclaration = __commonJS({
8448
4961
  if (value !== NO_CHANGE) {
8449
4962
  value = "" + value;
8450
4963
  }
4964
+ value = value.trim();
8451
4965
  if (value === "") {
8452
4966
  this.removeProperty(property);
8453
4967
  return;
@@ -19937,28 +16451,847 @@ var require_lib = __commonJS({
19937
16451
  exports.impl = impl;
19938
16452
  }
19939
16453
  });
19940
- export default require_lib();
19941
- /*!
19942
- Parser-Lib
19943
- Copyright (c) 2009-2011 Nicholas C. Zakas. All rights reserved.
16454
+ var domino = require_lib();
16455
+
16456
+ function setDomTypes() {
16457
+ // Make all Domino types available in the global env.
16458
+ Object.assign(global, domino.impl);
16459
+ global['KeyboardEvent'] = domino.impl.Event;
16460
+ }
16461
+ /**
16462
+ * Parses a document string to a Document object.
16463
+ */
16464
+ function parseDocument(html, url = '/') {
16465
+ let window = domino.createWindow(html, url);
16466
+ let doc = window.document;
16467
+ return doc;
16468
+ }
16469
+ /**
16470
+ * Serializes a document to string.
16471
+ */
16472
+ function serializeDocument(doc) {
16473
+ return doc.serialize();
16474
+ }
16475
+ /**
16476
+ * DOM Adapter for the server platform based on https://github.com/fgnass/domino.
16477
+ */
16478
+ class DominoAdapter extends ɵBrowserDomAdapter {
16479
+ constructor() {
16480
+ super(...arguments);
16481
+ this.supportsDOMEvents = false;
16482
+ }
16483
+ static makeCurrent() {
16484
+ setDomTypes();
16485
+ ɵsetRootDomAdapter(new DominoAdapter());
16486
+ }
16487
+ createHtmlDocument() {
16488
+ return parseDocument('<html><head><title>fakeTitle</title></head><body></body></html>');
16489
+ }
16490
+ getDefaultDocument() {
16491
+ if (!DominoAdapter.defaultDoc) {
16492
+ DominoAdapter.defaultDoc = domino.createDocument();
16493
+ }
16494
+ return DominoAdapter.defaultDoc;
16495
+ }
16496
+ isElementNode(node) {
16497
+ return node ? node.nodeType === DominoAdapter.defaultDoc.ELEMENT_NODE : false;
16498
+ }
16499
+ isShadowRoot(node) {
16500
+ return node.shadowRoot == node;
16501
+ }
16502
+ /** @deprecated No longer being used in Ivy code. To be removed in version 14. */
16503
+ getGlobalEventTarget(doc, target) {
16504
+ if (target === 'window') {
16505
+ return doc.defaultView;
16506
+ }
16507
+ if (target === 'document') {
16508
+ return doc;
16509
+ }
16510
+ if (target === 'body') {
16511
+ return doc.body;
16512
+ }
16513
+ return null;
16514
+ }
16515
+ getBaseHref(doc) {
16516
+ // TODO(alxhub): Need relative path logic from BrowserDomAdapter here?
16517
+ return doc.documentElement.querySelector('base')?.getAttribute('href') || '';
16518
+ }
16519
+ dispatchEvent(el, evt) {
16520
+ el.dispatchEvent(evt);
16521
+ // Dispatch the event to the window also.
16522
+ const doc = el.ownerDocument || el;
16523
+ const win = doc.defaultView;
16524
+ if (win) {
16525
+ win.dispatchEvent(evt);
16526
+ }
16527
+ }
16528
+ getUserAgent() {
16529
+ return 'Fake user agent';
16530
+ }
16531
+ getCookie(name) {
16532
+ throw new Error('getCookie has not been implemented');
16533
+ }
16534
+ }
16535
+
16536
+ /**
16537
+ * Representation of the current platform state.
16538
+ *
16539
+ * @publicApi
16540
+ */
16541
+ class PlatformState {
16542
+ constructor(_doc) {
16543
+ this._doc = _doc;
16544
+ }
16545
+ /**
16546
+ * Renders the current state of the platform to string.
16547
+ */
16548
+ renderToString() {
16549
+ return serializeDocument(this._doc);
16550
+ }
16551
+ /**
16552
+ * Returns the current DOM state.
16553
+ */
16554
+ getDocument() {
16555
+ return this._doc;
16556
+ }
16557
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: PlatformState, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
16558
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: PlatformState }); }
16559
+ }
16560
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: PlatformState, decorators: [{
16561
+ type: Injectable
16562
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
16563
+ type: Inject,
16564
+ args: [DOCUMENT]
16565
+ }] }]; } });
16566
+
16567
+ class ServerXhr {
16568
+ build() {
16569
+ return new xhr2.XMLHttpRequest();
16570
+ }
16571
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerXhr, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
16572
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerXhr }); }
16573
+ }
16574
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerXhr, decorators: [{
16575
+ type: Injectable
16576
+ }] });
16577
+ const SERVER_HTTP_PROVIDERS = [
16578
+ { provide: XhrFactory, useClass: ServerXhr },
16579
+ ];
16580
+
16581
+ /**
16582
+ * The DI token for setting the initial config for the platform.
16583
+ *
16584
+ * @publicApi
16585
+ */
16586
+ const INITIAL_CONFIG = new InjectionToken('Server.INITIAL_CONFIG');
16587
+ /**
16588
+ * A function that will be executed when calling `renderApplication` or
16589
+ * `renderModule` just before current platform state is rendered to string.
16590
+ *
16591
+ * @publicApi
16592
+ */
16593
+ const BEFORE_APP_SERIALIZED = new InjectionToken('Server.RENDER_MODULE_HOOK');
16594
+
16595
+ function parseUrl(urlStr) {
16596
+ const parsedUrl = url.parse(urlStr);
16597
+ return {
16598
+ hostname: parsedUrl.hostname || '',
16599
+ protocol: parsedUrl.protocol || '',
16600
+ port: parsedUrl.port || '',
16601
+ pathname: parsedUrl.pathname || '',
16602
+ search: parsedUrl.search || '',
16603
+ hash: parsedUrl.hash || '',
16604
+ };
16605
+ }
16606
+ /**
16607
+ * Server-side implementation of URL state. Implements `pathname`, `search`, and `hash`
16608
+ * but not the state stack.
16609
+ */
16610
+ class ServerPlatformLocation {
16611
+ constructor(_doc, _config) {
16612
+ this._doc = _doc;
16613
+ this.href = '/';
16614
+ this.hostname = '/';
16615
+ this.protocol = '/';
16616
+ this.port = '/';
16617
+ this.pathname = '/';
16618
+ this.search = '';
16619
+ this.hash = '';
16620
+ this._hashUpdate = new Subject();
16621
+ const config = _config;
16622
+ if (!config) {
16623
+ return;
16624
+ }
16625
+ if (config.url) {
16626
+ const url = parseUrl(config.url);
16627
+ this.protocol = url.protocol;
16628
+ this.hostname = url.hostname;
16629
+ this.port = url.port;
16630
+ this.pathname = url.pathname;
16631
+ this.search = url.search;
16632
+ this.hash = url.hash;
16633
+ this.href = _doc.location.href;
16634
+ }
16635
+ if (config.useAbsoluteUrl) {
16636
+ if (!config.baseUrl) {
16637
+ throw new Error(`"PlatformConfig.baseUrl" must be set if "useAbsoluteUrl" is true`);
16638
+ }
16639
+ const url = parseUrl(config.baseUrl);
16640
+ this.protocol = url.protocol;
16641
+ this.hostname = url.hostname;
16642
+ this.port = url.port;
16643
+ }
16644
+ }
16645
+ getBaseHrefFromDOM() {
16646
+ return ɵgetDOM().getBaseHref(this._doc);
16647
+ }
16648
+ onPopState(fn) {
16649
+ // No-op: a state stack is not implemented, so
16650
+ // no events will ever come.
16651
+ return () => { };
16652
+ }
16653
+ onHashChange(fn) {
16654
+ const subscription = this._hashUpdate.subscribe(fn);
16655
+ return () => subscription.unsubscribe();
16656
+ }
16657
+ get url() {
16658
+ return `${this.pathname}${this.search}${this.hash}`;
16659
+ }
16660
+ setHash(value, oldUrl) {
16661
+ if (this.hash === value) {
16662
+ // Don't fire events if the hash has not changed.
16663
+ return;
16664
+ }
16665
+ this.hash = value;
16666
+ const newUrl = this.url;
16667
+ scheduleMicroTask(() => this._hashUpdate.next({ type: 'hashchange', state: null, oldUrl, newUrl }));
16668
+ }
16669
+ replaceState(state, title, newUrl) {
16670
+ const oldUrl = this.url;
16671
+ const parsedUrl = parseUrl(newUrl);
16672
+ this.pathname = parsedUrl.pathname;
16673
+ this.search = parsedUrl.search;
16674
+ this.setHash(parsedUrl.hash, oldUrl);
16675
+ }
16676
+ pushState(state, title, newUrl) {
16677
+ this.replaceState(state, title, newUrl);
16678
+ }
16679
+ forward() {
16680
+ throw new Error('Not implemented');
16681
+ }
16682
+ back() {
16683
+ throw new Error('Not implemented');
16684
+ }
16685
+ // History API isn't available on server, therefore return undefined
16686
+ getState() {
16687
+ return undefined;
16688
+ }
16689
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerPlatformLocation, deps: [{ token: DOCUMENT }, { token: INITIAL_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
16690
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerPlatformLocation }); }
16691
+ }
16692
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerPlatformLocation, decorators: [{
16693
+ type: Injectable
16694
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
16695
+ type: Inject,
16696
+ args: [DOCUMENT]
16697
+ }] }, { type: undefined, decorators: [{
16698
+ type: Optional
16699
+ }, {
16700
+ type: Inject,
16701
+ args: [INITIAL_CONFIG]
16702
+ }] }]; } });
16703
+ function scheduleMicroTask(fn) {
16704
+ Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
16705
+ }
16706
+
16707
+ class ServerEventManagerPlugin /* extends EventManagerPlugin which is private */ {
16708
+ constructor(doc) {
16709
+ this.doc = doc;
16710
+ }
16711
+ // Handle all events on the server.
16712
+ supports(eventName) {
16713
+ return true;
16714
+ }
16715
+ addEventListener(element, eventName, handler) {
16716
+ return ɵgetDOM().onAndCancel(element, eventName, handler);
16717
+ }
16718
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerEventManagerPlugin /* extends EventManagerPlugin which is private */, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
16719
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerEventManagerPlugin /* extends EventManagerPlugin which is private */ }); }
16720
+ }
16721
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerEventManagerPlugin /* extends EventManagerPlugin which is private */, decorators: [{
16722
+ type: Injectable
16723
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
16724
+ type: Inject,
16725
+ args: [DOCUMENT]
16726
+ }] }]; } });
16727
+
16728
+ const EMPTY_ARRAY = [];
16729
+ const DEFAULT_SCHEMA = new DomElementSchemaRegistry();
16730
+ class ServerRendererFactory2 {
16731
+ constructor(eventManager, ngZone, document, sharedStylesHost, appId) {
16732
+ this.eventManager = eventManager;
16733
+ this.ngZone = ngZone;
16734
+ this.document = document;
16735
+ this.sharedStylesHost = sharedStylesHost;
16736
+ this.appId = appId;
16737
+ this.rendererByCompId = new Map();
16738
+ this.schema = DEFAULT_SCHEMA;
16739
+ this.defaultRenderer = new DefaultServerRenderer2(eventManager, document, ngZone, this.schema);
16740
+ }
16741
+ createRenderer(element, type) {
16742
+ if (!element || !type) {
16743
+ return this.defaultRenderer;
16744
+ }
16745
+ switch (type.encapsulation) {
16746
+ case ViewEncapsulation.Emulated: {
16747
+ let renderer = this.rendererByCompId.get(type.id);
16748
+ if (!renderer) {
16749
+ renderer = new EmulatedEncapsulationServerRenderer2(this.eventManager, this.document, this.ngZone, this.sharedStylesHost, this.schema, type, this.appId);
16750
+ this.rendererByCompId.set(type.id, renderer);
16751
+ }
16752
+ renderer.applyToHost(element);
16753
+ return renderer;
16754
+ }
16755
+ default: {
16756
+ if (!this.rendererByCompId.has(type.id)) {
16757
+ const styles = ɵshimStyles(type.id, type.styles);
16758
+ this.sharedStylesHost.addStyles(styles);
16759
+ this.rendererByCompId.set(type.id, this.defaultRenderer);
16760
+ }
16761
+ return this.defaultRenderer;
16762
+ }
16763
+ }
16764
+ }
16765
+ begin() { }
16766
+ end() { }
16767
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerRendererFactory2, deps: [{ token: i1.EventManager }, { token: i0.NgZone }, { token: DOCUMENT }, { token: i1.ɵSharedStylesHost }, { token: APP_ID }], target: i0.ɵɵFactoryTarget.Injectable }); }
16768
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerRendererFactory2 }); }
16769
+ }
16770
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerRendererFactory2, decorators: [{
16771
+ type: Injectable
16772
+ }], ctorParameters: function () { return [{ type: i1.EventManager }, { type: i0.NgZone }, { type: Document, decorators: [{
16773
+ type: Inject,
16774
+ args: [DOCUMENT]
16775
+ }] }, { type: i1.ɵSharedStylesHost }, { type: undefined, decorators: [{
16776
+ type: Inject,
16777
+ args: [APP_ID]
16778
+ }] }]; } });
16779
+ class DefaultServerRenderer2 {
16780
+ constructor(eventManager, document, ngZone, schema) {
16781
+ this.eventManager = eventManager;
16782
+ this.document = document;
16783
+ this.ngZone = ngZone;
16784
+ this.schema = schema;
16785
+ this.data = Object.create(null);
16786
+ this.destroyNode = null;
16787
+ }
16788
+ destroy() { }
16789
+ createElement(name, namespace) {
16790
+ if (namespace) {
16791
+ const doc = this.document || ɵgetDOM().getDefaultDocument();
16792
+ return doc.createElementNS(ɵNAMESPACE_URIS[namespace], name);
16793
+ }
16794
+ return ɵgetDOM().createElement(name, this.document);
16795
+ }
16796
+ createComment(value) {
16797
+ return ɵgetDOM().getDefaultDocument().createComment(value);
16798
+ }
16799
+ createText(value) {
16800
+ const doc = ɵgetDOM().getDefaultDocument();
16801
+ return doc.createTextNode(value);
16802
+ }
16803
+ appendChild(parent, newChild) {
16804
+ const targetParent = isTemplateNode(parent) ? parent.content : parent;
16805
+ targetParent.appendChild(newChild);
16806
+ }
16807
+ insertBefore(parent, newChild, refChild) {
16808
+ if (parent) {
16809
+ const targetParent = isTemplateNode(parent) ? parent.content : parent;
16810
+ targetParent.insertBefore(newChild, refChild);
16811
+ }
16812
+ }
16813
+ removeChild(parent, oldChild) {
16814
+ if (parent) {
16815
+ parent.removeChild(oldChild);
16816
+ }
16817
+ }
16818
+ selectRootElement(selectorOrNode, preserveContent) {
16819
+ const el = typeof selectorOrNode === 'string' ? this.document.querySelector(selectorOrNode) :
16820
+ selectorOrNode;
16821
+ if (!el) {
16822
+ throw new Error(`The selector "${selectorOrNode}" did not match any elements`);
16823
+ }
16824
+ if (!preserveContent) {
16825
+ while (el.firstChild) {
16826
+ el.removeChild(el.firstChild);
16827
+ }
16828
+ }
16829
+ return el;
16830
+ }
16831
+ parentNode(node) {
16832
+ return node.parentNode;
16833
+ }
16834
+ nextSibling(node) {
16835
+ return node.nextSibling;
16836
+ }
16837
+ setAttribute(el, name, value, namespace) {
16838
+ if (namespace) {
16839
+ el.setAttributeNS(ɵNAMESPACE_URIS[namespace], namespace + ':' + name, value);
16840
+ }
16841
+ else {
16842
+ el.setAttribute(name, value);
16843
+ }
16844
+ }
16845
+ removeAttribute(el, name, namespace) {
16846
+ if (namespace) {
16847
+ el.removeAttributeNS(ɵNAMESPACE_URIS[namespace], name);
16848
+ }
16849
+ else {
16850
+ el.removeAttribute(name);
16851
+ }
16852
+ }
16853
+ addClass(el, name) {
16854
+ el.classList.add(name);
16855
+ }
16856
+ removeClass(el, name) {
16857
+ el.classList.remove(name);
16858
+ }
16859
+ setStyle(el, style, value, flags) {
16860
+ style = style.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
16861
+ value = value == null ? '' : `${value}`.trim();
16862
+ const styleMap = _readStyleAttribute(el);
16863
+ if (flags & RendererStyleFlags2.Important) {
16864
+ value += ' !important';
16865
+ }
16866
+ styleMap[style] = value;
16867
+ _writeStyleAttribute(el, styleMap);
16868
+ }
16869
+ removeStyle(el, style, flags) {
16870
+ // IE requires '' instead of null
16871
+ // see https://github.com/angular/angular/issues/7916
16872
+ this.setStyle(el, style, '', flags);
16873
+ }
16874
+ // The value was validated already as a property binding, against the property name.
16875
+ // To know this value is safe to use as an attribute, the security context of the
16876
+ // attribute with the given name is checked against that security context of the
16877
+ // property.
16878
+ _isSafeToReflectProperty(tagName, propertyName) {
16879
+ return this.schema.securityContext(tagName, propertyName, true) ===
16880
+ this.schema.securityContext(tagName, propertyName, false);
16881
+ }
16882
+ setProperty(el, name, value) {
16883
+ checkNoSyntheticProp(name, 'property');
16884
+ if (name === 'innerText') {
16885
+ // Domino does not support innerText. Just map it to textContent.
16886
+ el.textContent = value;
16887
+ }
16888
+ el[name] = value;
16889
+ // Mirror property values for known HTML element properties in the attributes.
16890
+ // Skip `innerhtml` which is conservatively marked as an attribute for security
16891
+ // purposes but is not actually an attribute.
16892
+ const tagName = el.tagName.toLowerCase();
16893
+ if (value != null && (typeof value === 'number' || typeof value == 'string') &&
16894
+ name.toLowerCase() !== 'innerhtml' && this.schema.hasElement(tagName, EMPTY_ARRAY) &&
16895
+ this.schema.hasProperty(tagName, name, EMPTY_ARRAY) &&
16896
+ this._isSafeToReflectProperty(tagName, name)) {
16897
+ this.setAttribute(el, name, value.toString());
16898
+ }
16899
+ }
16900
+ setValue(node, value) {
16901
+ node.textContent = value;
16902
+ }
16903
+ listen(target, eventName, callback) {
16904
+ checkNoSyntheticProp(eventName, 'listener');
16905
+ return this.eventManager.addEventListener(target, eventName, this.decoratePreventDefault(callback));
16906
+ }
16907
+ decoratePreventDefault(eventHandler) {
16908
+ return (event) => {
16909
+ // Ivy uses `Function` as a special token that allows us to unwrap the function
16910
+ // so that it can be invoked programmatically by `DebugNode.triggerEventHandler`.
16911
+ if (event === Function) {
16912
+ return eventHandler;
16913
+ }
16914
+ // Run the event handler inside the ngZone because event handlers are not patched
16915
+ // by Zone on the server. This is required only for tests.
16916
+ const allowDefaultBehavior = this.ngZone.runGuarded(() => eventHandler(event));
16917
+ if (allowDefaultBehavior === false) {
16918
+ event.preventDefault();
16919
+ event.returnValue = false;
16920
+ }
16921
+ return undefined;
16922
+ };
16923
+ }
16924
+ }
16925
+ const AT_CHARCODE = '@'.charCodeAt(0);
16926
+ function checkNoSyntheticProp(name, nameKind) {
16927
+ if (name.charCodeAt(0) === AT_CHARCODE) {
16928
+ throw new Error(`Unexpected synthetic ${nameKind} ${name} found. Please make sure that:
16929
+ - Either \`BrowserAnimationsModule\` or \`NoopAnimationsModule\` are imported in your application.
16930
+ - There is corresponding configuration for the animation named \`${name}\` defined in the \`animations\` field of the \`@Component\` decorator (see https://angular.io/api/core/Component#animations).`);
16931
+ }
16932
+ }
16933
+ function isTemplateNode(node) {
16934
+ return node.tagName === 'TEMPLATE' && node.content !== undefined;
16935
+ }
16936
+ class EmulatedEncapsulationServerRenderer2 extends DefaultServerRenderer2 {
16937
+ constructor(eventManager, document, ngZone, sharedStylesHost, schema, component, appId) {
16938
+ super(eventManager, document, ngZone, schema);
16939
+ this.component = component;
16940
+ const componentShortId = appId + '-' + this.component.id;
16941
+ const styles = ɵshimStyles(componentShortId, this.component.styles);
16942
+ sharedStylesHost.addStyles(styles);
16943
+ this.contentAttr = ɵshimContentAttribute(componentShortId);
16944
+ this.hostAttr = ɵshimHostAttribute(componentShortId);
16945
+ }
16946
+ applyToHost(element) {
16947
+ super.setAttribute(element, this.hostAttr, '');
16948
+ }
16949
+ createElement(parent, name) {
16950
+ const el = super.createElement(parent, name);
16951
+ super.setAttribute(el, this.contentAttr, '');
16952
+ return el;
16953
+ }
16954
+ }
16955
+ function _readStyleAttribute(element) {
16956
+ const styleMap = {};
16957
+ const styleAttribute = element.getAttribute('style');
16958
+ if (styleAttribute) {
16959
+ const styleList = styleAttribute.split(/;+/g);
16960
+ for (let i = 0; i < styleList.length; i++) {
16961
+ const style = styleList[i].trim();
16962
+ if (style.length > 0) {
16963
+ const colonIndex = style.indexOf(':');
16964
+ if (colonIndex === -1) {
16965
+ throw new Error(`Invalid CSS style: ${style}`);
16966
+ }
16967
+ const name = style.slice(0, colonIndex).trim();
16968
+ styleMap[name] = style.slice(colonIndex + 1).trim();
16969
+ }
16970
+ }
16971
+ }
16972
+ return styleMap;
16973
+ }
16974
+ function _writeStyleAttribute(element, styleMap) {
16975
+ // We have to construct the `style` attribute ourselves, instead of going through
16976
+ // `element.style.setProperty` like the other renderers, because `setProperty` won't
16977
+ // write newer CSS properties that Domino doesn't know about like `clip-path`.
16978
+ let styleAttrValue = '';
16979
+ for (const key in styleMap) {
16980
+ const newValue = styleMap[key];
16981
+ if (newValue != null && newValue !== '') {
16982
+ styleAttrValue += key + ':' + newValue + ';';
16983
+ }
16984
+ }
16985
+ if (styleAttrValue) {
16986
+ element.setAttribute('style', styleAttrValue);
16987
+ }
16988
+ else {
16989
+ element.removeAttribute('style');
16990
+ }
16991
+ }
16992
+
16993
+ const TRANSFER_STATE_SERIALIZATION_PROVIDERS = [{
16994
+ provide: BEFORE_APP_SERIALIZED,
16995
+ useFactory: serializeTransferStateFactory,
16996
+ deps: [DOCUMENT, APP_ID, TransferState],
16997
+ multi: true,
16998
+ }];
16999
+ function serializeTransferStateFactory(doc, appId, transferStore) {
17000
+ return () => {
17001
+ // The `.toJSON` here causes the `onSerialize` callbacks to be called.
17002
+ // These callbacks can be used to provide the value for a given key.
17003
+ const content = transferStore.toJson();
17004
+ if (transferStore.isEmpty) {
17005
+ // The state is empty, nothing to transfer,
17006
+ // avoid creating an extra `<script>` tag in this case.
17007
+ return;
17008
+ }
17009
+ const script = doc.createElement('script');
17010
+ script.id = appId + '-state';
17011
+ script.setAttribute('type', 'application/json');
17012
+ script.textContent = ɵescapeTransferStateContent(content);
17013
+ // It is intentional that we add the script at the very bottom. Angular CLI script tags for
17014
+ // bundles are always `type="module"`. These are deferred by default and cause the transfer
17015
+ // transfer data to be queried only after the browser has finished parsing the DOM.
17016
+ doc.body.appendChild(script);
17017
+ };
17018
+ }
17019
+ /**
17020
+ * NgModule to install on the server side while using the `TransferState` to transfer state from
17021
+ * server to client.
17022
+ *
17023
+ * Note: this module is not needed if the `renderApplication` function is used.
17024
+ * The `renderApplication` makes all providers from this module available in the application.
17025
+ *
17026
+ * @publicApi
17027
+ * @deprecated no longer needed, you can inject the `TransferState` in an app without providing
17028
+ * this module.
17029
+ */
17030
+ class ServerTransferStateModule {
17031
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerTransferStateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
17032
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerTransferStateModule }); }
17033
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerTransferStateModule }); }
17034
+ }
17035
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerTransferStateModule, decorators: [{
17036
+ type: NgModule,
17037
+ args: [{}]
17038
+ }] });
17039
+
17040
+ const INTERNAL_SERVER_PLATFORM_PROVIDERS = [
17041
+ { provide: DOCUMENT, useFactory: _document, deps: [Injector] },
17042
+ { provide: PLATFORM_ID, useValue: ɵPLATFORM_SERVER_ID },
17043
+ { provide: PLATFORM_INITIALIZER, useFactory: initDominoAdapter, multi: true }, {
17044
+ provide: PlatformLocation,
17045
+ useClass: ServerPlatformLocation,
17046
+ deps: [DOCUMENT, [Optional, INITIAL_CONFIG]]
17047
+ },
17048
+ { provide: PlatformState, deps: [DOCUMENT] },
17049
+ // Add special provider that allows multiple instances of platformServer* to be created.
17050
+ { provide: ɵALLOW_MULTIPLE_PLATFORMS, useValue: true }
17051
+ ];
17052
+ function initDominoAdapter() {
17053
+ return () => {
17054
+ DominoAdapter.makeCurrent();
17055
+ };
17056
+ }
17057
+ function instantiateServerRendererFactory(renderer, engine, zone) {
17058
+ return new ɵAnimationRendererFactory(renderer, engine, zone);
17059
+ }
17060
+ const SERVER_RENDER_PROVIDERS = [
17061
+ ServerRendererFactory2,
17062
+ {
17063
+ provide: RendererFactory2,
17064
+ useFactory: instantiateServerRendererFactory,
17065
+ deps: [ServerRendererFactory2, ɵAnimationEngine, NgZone]
17066
+ },
17067
+ { provide: EVENT_MANAGER_PLUGINS, multi: true, useClass: ServerEventManagerPlugin },
17068
+ ];
17069
+ const PLATFORM_SERVER_PROVIDERS = [
17070
+ TRANSFER_STATE_SERIALIZATION_PROVIDERS,
17071
+ SERVER_RENDER_PROVIDERS,
17072
+ SERVER_HTTP_PROVIDERS,
17073
+ { provide: Testability, useValue: null },
17074
+ { provide: ɵTESTABILITY, useValue: null },
17075
+ { provide: ViewportScroller, useClass: ɵNullViewportScroller },
17076
+ ];
17077
+ /**
17078
+ * The ng module for the server.
17079
+ *
17080
+ * @publicApi
17081
+ */
17082
+ class ServerModule {
17083
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
17084
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerModule, imports: [HttpClientModule, NoopAnimationsModule], exports: [BrowserModule] }); }
17085
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerModule, providers: PLATFORM_SERVER_PROVIDERS, imports: [HttpClientModule, NoopAnimationsModule, BrowserModule] }); }
17086
+ }
17087
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0-next.6", ngImport: i0, type: ServerModule, decorators: [{
17088
+ type: NgModule,
17089
+ args: [{
17090
+ exports: [BrowserModule],
17091
+ imports: [HttpClientModule, NoopAnimationsModule],
17092
+ providers: PLATFORM_SERVER_PROVIDERS,
17093
+ }]
17094
+ }] });
17095
+ function _document(injector) {
17096
+ const config = injector.get(INITIAL_CONFIG, null);
17097
+ let document;
17098
+ if (config && config.document) {
17099
+ document = typeof config.document === 'string' ? parseDocument(config.document, config.url) :
17100
+ config.document;
17101
+ }
17102
+ else {
17103
+ document = ɵgetDOM().createHtmlDocument();
17104
+ }
17105
+ // Tell ivy about the global document
17106
+ ɵsetDocument(document);
17107
+ return document;
17108
+ }
17109
+ /**
17110
+ * @publicApi
17111
+ */
17112
+ const platformServer = createPlatformFactory(platformCore, 'server', INTERNAL_SERVER_PLATFORM_PROVIDERS);
17113
+ /**
17114
+ * The server platform that supports the runtime compiler.
17115
+ *
17116
+ * @publicApi
17117
+ */
17118
+ const platformDynamicServer = createPlatformFactory(ɵplatformCoreDynamic, 'serverDynamic', INTERNAL_SERVER_PLATFORM_PROVIDERS);
17119
+
17120
+ /**
17121
+ * Sets up providers necessary to enable server rendering functionality for the application.
17122
+ *
17123
+ * @usageNotes
17124
+ *
17125
+ * Basic example of how you can add server support to your application:
17126
+ * ```ts
17127
+ * bootstrapApplication(AppComponent, {
17128
+ * providers: [provideServerSupport()]
17129
+ * });
17130
+ * ```
17131
+ *
17132
+ * @publicApi
17133
+ * @returns A set of providers to setup the server.
17134
+ */
17135
+ function provideServerSupport() {
17136
+ return makeEnvironmentProviders([
17137
+ provideHttpClient(withInterceptorsFromDi()),
17138
+ provideNoopAnimations(),
17139
+ ...PLATFORM_SERVER_PROVIDERS,
17140
+ ]);
17141
+ }
17142
+
17143
+ function _getPlatform(platformFactory, options) {
17144
+ const extraProviders = options.platformProviders ?? [];
17145
+ return platformFactory([
17146
+ { provide: INITIAL_CONFIG, useValue: { document: options.document, url: options.url } },
17147
+ extraProviders
17148
+ ]);
17149
+ }
17150
+ /**
17151
+ * Adds the `ng-server-context` attribute to host elements of all bootstrapped components
17152
+ * within a given application.
17153
+ */
17154
+ function appendServerContextInfo(serverContext, applicationRef) {
17155
+ applicationRef.components.forEach(componentRef => {
17156
+ const renderer = componentRef.injector.get(Renderer2);
17157
+ const element = componentRef.location.nativeElement;
17158
+ if (element) {
17159
+ renderer.setAttribute(element, 'ng-server-context', serverContext);
17160
+ }
17161
+ });
17162
+ }
17163
+ function _render(platform, bootstrapPromise) {
17164
+ return bootstrapPromise.then((moduleOrApplicationRef) => {
17165
+ const environmentInjector = moduleOrApplicationRef.injector;
17166
+ const applicationRef = moduleOrApplicationRef instanceof ApplicationRef ?
17167
+ moduleOrApplicationRef :
17168
+ environmentInjector.get(ApplicationRef);
17169
+ const serverContext = sanitizeServerContext(environmentInjector.get(SERVER_CONTEXT, DEFAULT_SERVER_CONTEXT));
17170
+ const isStablePromise = applicationRef.isStable.pipe((first((isStable) => isStable))).toPromise();
17171
+ const pendingTasks = environmentInjector.get(ɵInitialRenderPendingTasks);
17172
+ const pendingTasksPromise = pendingTasks.whenAllTasksComplete;
17173
+ return Promise.allSettled([isStablePromise, pendingTasksPromise]).then(() => {
17174
+ appendServerContextInfo(serverContext, applicationRef);
17175
+ const platformState = platform.injector.get(PlatformState);
17176
+ const asyncPromises = [];
17177
+ if (applicationRef.injector.get(ɵIS_HYDRATION_FEATURE_ENABLED, false)) {
17178
+ ɵannotateForHydration(applicationRef, platformState.getDocument());
17179
+ }
17180
+ // Run any BEFORE_APP_SERIALIZED callbacks just before rendering to string.
17181
+ const callbacks = environmentInjector.get(BEFORE_APP_SERIALIZED, null);
17182
+ if (callbacks) {
17183
+ for (const callback of callbacks) {
17184
+ try {
17185
+ const callbackResult = callback();
17186
+ if (ɵisPromise(callbackResult)) {
17187
+ // TODO: in TS3.7, callbackResult is void.
17188
+ asyncPromises.push(callbackResult);
17189
+ }
17190
+ }
17191
+ catch (e) {
17192
+ // Ignore exceptions.
17193
+ console.warn('Ignoring BEFORE_APP_SERIALIZED Exception: ', e);
17194
+ }
17195
+ }
17196
+ }
17197
+ const complete = () => {
17198
+ const output = platformState.renderToString();
17199
+ platform.destroy();
17200
+ return output;
17201
+ };
17202
+ if (asyncPromises.length === 0) {
17203
+ return complete();
17204
+ }
17205
+ return Promise
17206
+ .all(asyncPromises.map(asyncPromise => {
17207
+ return asyncPromise.catch(e => {
17208
+ console.warn('Ignoring BEFORE_APP_SERIALIZED Exception: ', e);
17209
+ });
17210
+ }))
17211
+ .then(complete);
17212
+ });
17213
+ });
17214
+ }
17215
+ /**
17216
+ * Specifies the value that should be used if no server context value has been provided.
17217
+ */
17218
+ const DEFAULT_SERVER_CONTEXT = 'other';
17219
+ /**
17220
+ * An internal token that allows providing extra information about the server context
17221
+ * (e.g. whether SSR or SSG was used). The value is a string and characters other
17222
+ * than [a-zA-Z0-9\-] are removed. See the default value in `DEFAULT_SERVER_CONTEXT` const.
17223
+ */
17224
+ const SERVER_CONTEXT = new InjectionToken('SERVER_CONTEXT');
17225
+ /**
17226
+ * Sanitizes provided server context:
17227
+ * - removes all characters other than a-z, A-Z, 0-9 and `-`
17228
+ * - returns `other` if nothing is provided or the string is empty after sanitization
17229
+ */
17230
+ function sanitizeServerContext(serverContext) {
17231
+ const context = serverContext.replace(/[^a-zA-Z0-9\-]/g, '');
17232
+ return context.length > 0 ? context : DEFAULT_SERVER_CONTEXT;
17233
+ }
17234
+ /**
17235
+ * Bootstraps an application using provided NgModule and serializes the page content to string.
17236
+ *
17237
+ * @param moduleType A reference to an NgModule that should be used for bootstrap.
17238
+ * @param options Additional configuration for the render operation:
17239
+ * - `document` - the document of the page to render, either as an HTML string or
17240
+ * as a reference to the `document` instance.
17241
+ * - `url` - the URL for the current render request.
17242
+ * - `extraProviders` - set of platform level providers for the current render request.
17243
+ *
17244
+ * @publicApi
17245
+ */
17246
+ function renderModule(moduleType, options) {
17247
+ const { document, url, extraProviders: platformProviders } = options;
17248
+ const platform = _getPlatform(platformDynamicServer, { document, url, platformProviders });
17249
+ return _render(platform, platform.bootstrapModule(moduleType));
17250
+ }
17251
+ /**
17252
+ * Bootstraps an instance of an Angular application and renders it to a string.
17253
+
17254
+ * ```typescript
17255
+ * const bootstrap = () => bootstrapApplication(RootComponent, appConfig);
17256
+ * const output: string = await renderApplication(bootstrap);
17257
+ * ```
17258
+ *
17259
+ * @param bootstrap A method that when invoked returns a promise that returns an `ApplicationRef`
17260
+ * instance once resolved.
17261
+ * @param options Additional configuration for the render operation:
17262
+ * - `document` - the document of the page to render, either as an HTML string or
17263
+ * as a reference to the `document` instance.
17264
+ * - `url` - the URL for the current render request.
17265
+ * - `platformProviders` - the platform level providers for the current render request.
17266
+ *
17267
+ * @returns A Promise, that returns serialized (to a string) rendered page, once resolved.
17268
+ *
17269
+ * @publicApi
17270
+ * @developerPreview
17271
+ */
17272
+ function renderApplication(bootstrap, options) {
17273
+ const platform = _getPlatform(platformDynamicServer, options);
17274
+ return _render(platform, bootstrap());
17275
+ }
17276
+
17277
+ /**
17278
+ * @module
17279
+ * @description
17280
+ * Entry point for all public APIs of the platform-server package.
17281
+ */
17282
+ /**
17283
+ * @publicApi
17284
+ */
17285
+ const VERSION = new Version('16.0.0-next.6');
19944
17286
 
19945
- Permission is hereby granted, free of charge, to any person obtaining a copy
19946
- of this software and associated documentation files (the "Software"), to deal
19947
- in the Software without restriction, including without limitation the rights
19948
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19949
- copies of the Software, and to permit persons to whom the Software is
19950
- furnished to do so, subject to the following conditions:
17287
+ /// <reference types="node" />
17288
+ // This file only reexports content of the `src` folder. Keep it that way.
19951
17289
 
19952
- The above copyright notice and this permission notice shall be included in
19953
- all copies or substantial portions of the Software.
17290
+ // This file is not used to build this module. It is only used during editing
19954
17291
 
19955
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19956
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19957
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19958
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19959
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19960
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19961
- THE SOFTWARE.
17292
+ /**
17293
+ * Generated bundle index. Do not edit.
17294
+ */
19962
17295
 
19963
- */
19964
- //# sourceMappingURL=bundled-domino.mjs.map
17296
+ export { BEFORE_APP_SERIALIZED, INITIAL_CONFIG, PlatformState, ServerModule, ServerTransferStateModule, VERSION, platformDynamicServer, platformServer, provideServerSupport, renderApplication, renderModule, INTERNAL_SERVER_PLATFORM_PROVIDERS as ɵINTERNAL_SERVER_PLATFORM_PROVIDERS, SERVER_CONTEXT as ɵSERVER_CONTEXT, SERVER_RENDER_PROVIDERS as ɵSERVER_RENDER_PROVIDERS, ServerRendererFactory2 as ɵServerRendererFactory2, setDomTypes as ɵsetDomTypes };
17297
+ //# sourceMappingURL=platform-server.mjs.map