namespace.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. if (typeof b !== "function" && b !== null)
  11. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12. extendStatics(d, b);
  13. function __() { this.constructor = d; }
  14. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15. };
  16. })();
  17. var __importDefault = (this && this.__importDefault) || function (mod) {
  18. return (mod && mod.__esModule) ? mod : { "default": mod };
  19. };
  20. Object.defineProperty(exports, "__esModule", { value: true });
  21. var cssesc_1 = __importDefault(require("cssesc"));
  22. var util_1 = require("../util");
  23. var node_1 = __importDefault(require("./node"));
  24. var Namespace = /** @class */ (function (_super) {
  25. __extends(Namespace, _super);
  26. function Namespace() {
  27. return _super !== null && _super.apply(this, arguments) || this;
  28. }
  29. Object.defineProperty(Namespace.prototype, "namespace", {
  30. get: function () {
  31. return this._namespace;
  32. },
  33. set: function (namespace) {
  34. if (namespace === true || namespace === "*" || namespace === "&") {
  35. this._namespace = namespace;
  36. if (this.raws) {
  37. delete this.raws.namespace;
  38. }
  39. return;
  40. }
  41. var escaped = (0, cssesc_1.default)(namespace, { isIdentifier: true });
  42. this._namespace = namespace;
  43. if (escaped !== namespace) {
  44. (0, util_1.ensureObject)(this, "raws");
  45. this.raws.namespace = escaped;
  46. }
  47. else if (this.raws) {
  48. delete this.raws.namespace;
  49. }
  50. },
  51. enumerable: false,
  52. configurable: true
  53. });
  54. Object.defineProperty(Namespace.prototype, "ns", {
  55. get: function () {
  56. return this._namespace;
  57. },
  58. set: function (namespace) {
  59. this.namespace = namespace;
  60. },
  61. enumerable: false,
  62. configurable: true
  63. });
  64. Object.defineProperty(Namespace.prototype, "namespaceString", {
  65. get: function () {
  66. if (this.namespace) {
  67. var ns = this.stringifyProperty("namespace");
  68. if (ns === true) {
  69. return "";
  70. }
  71. else {
  72. return ns;
  73. }
  74. }
  75. else {
  76. return "";
  77. }
  78. },
  79. enumerable: false,
  80. configurable: true
  81. });
  82. Namespace.prototype.qualifiedName = function (value) {
  83. if (this.namespace) {
  84. return "".concat(this.namespaceString, "|").concat(value);
  85. }
  86. else {
  87. return value;
  88. }
  89. };
  90. Namespace.prototype.valueToString = function () {
  91. return this.qualifiedName(_super.prototype.valueToString.call(this));
  92. };
  93. return Namespace;
  94. }(node_1.default));
  95. exports.default = Namespace;
  96. //# sourceMappingURL=namespace.js.map