web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
3.3 KiB

  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _webpack = _interopRequireDefault(require("webpack"));
  7. var _utils = require("./utils");
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. const TYPES = new Set([_utils.MODULE_TYPE]);
  10. const CODE_GENERATION_RESULT = {
  11. sources: new Map(),
  12. runtimeRequirements: new Set()
  13. };
  14. class CssModule extends _webpack.default.Module {
  15. constructor({
  16. context,
  17. identifier,
  18. identifierIndex,
  19. content,
  20. media,
  21. sourceMap
  22. }) {
  23. super(_utils.MODULE_TYPE, context);
  24. this.id = '';
  25. this._context = context;
  26. this._identifier = identifier;
  27. this._identifierIndex = identifierIndex;
  28. this.content = content;
  29. this.media = media;
  30. this.sourceMap = sourceMap;
  31. this.buildInfo = {};
  32. this.buildMeta = {};
  33. } // no source() so webpack 4 doesn't do add stuff to the bundle
  34. size() {
  35. return this.content.length;
  36. }
  37. identifier() {
  38. return `css ${this._identifier} ${this._identifierIndex}`;
  39. }
  40. readableIdentifier(requestShortener) {
  41. return `css ${requestShortener.shorten(this._identifier)}${this._identifierIndex ? ` (${this._identifierIndex})` : ''}`;
  42. } // eslint-disable-next-line class-methods-use-this
  43. getSourceTypes() {
  44. return TYPES;
  45. } // eslint-disable-next-line class-methods-use-this
  46. codeGeneration() {
  47. return CODE_GENERATION_RESULT;
  48. }
  49. nameForCondition() {
  50. const resource = this._identifier.split('!').pop();
  51. const idx = resource.indexOf('?');
  52. if (idx >= 0) {
  53. return resource.substring(0, idx);
  54. }
  55. return resource;
  56. }
  57. updateCacheModule(module) {
  58. this.content = module.content;
  59. this.media = module.media;
  60. this.sourceMap = module.sourceMap;
  61. } // eslint-disable-next-line class-methods-use-this
  62. needRebuild() {
  63. return true;
  64. } // eslint-disable-next-line class-methods-use-this
  65. needBuild(context, callback) {
  66. callback(null, false);
  67. }
  68. build(options, compilation, resolver, fileSystem, callback) {
  69. this.buildInfo = {};
  70. this.buildMeta = {};
  71. callback();
  72. }
  73. updateHash(hash, context) {
  74. super.updateHash(hash, context);
  75. hash.update(this.content);
  76. hash.update(this.media || '');
  77. hash.update(this.sourceMap ? JSON.stringify(this.sourceMap) : '');
  78. }
  79. serialize(context) {
  80. const {
  81. write
  82. } = context;
  83. write(this._context);
  84. write(this._identifier);
  85. write(this._identifierIndex);
  86. write(this.content);
  87. write(this.media);
  88. write(this.sourceMap);
  89. super.serialize(context);
  90. }
  91. deserialize(context) {
  92. super.deserialize(context);
  93. }
  94. }
  95. if (_webpack.default.util && _webpack.default.util.serialization) {
  96. _webpack.default.util.serialization.register(CssModule, 'mini-css-extract-plugin/dist/CssModule', null, {
  97. serialize(instance, context) {
  98. instance.serialize(context);
  99. },
  100. deserialize(context) {
  101. const {
  102. read
  103. } = context;
  104. const dep = new CssModule({
  105. context: read(),
  106. identifier: read(),
  107. identifierIndex: read(),
  108. content: read(),
  109. media: read(),
  110. sourceMap: read()
  111. });
  112. dep.deserialize(context);
  113. return dep;
  114. }
  115. });
  116. }
  117. var _default = CssModule;
  118. exports.default = _default;