source: imaps-frontend/node_modules/webpack/lib/dependencies/CssImportDependency.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 3.4 KB
RevLine 
[79a0317]1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Ivan Kopeykin @vankop
4*/
5
6"use strict";
7
8const makeSerializable = require("../util/makeSerializable");
9const ModuleDependency = require("./ModuleDependency");
10
11/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
12/** @typedef {import("../ChunkGraph")} ChunkGraph */
13/** @typedef {import("../Dependency")} Dependency */
14/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
15/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
16/** @typedef {import("../Module")} Module */
17/** @typedef {import("../ModuleGraph")} ModuleGraph */
18/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
19/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
20/** @typedef {import("../css/CssParser").Range} Range */
21/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
22/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
23/** @typedef {import("../util/Hash")} Hash */
24/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
25
26class CssImportDependency extends ModuleDependency {
27 /**
28 * Example of dependency:
29 * \@import url("landscape.css") layer(forms) screen and (orientation: landscape) screen and (orientation: landscape);
30 * @param {string} request request
31 * @param {Range} range range of the argument
32 * @param {string | undefined} layer layer
33 * @param {string | undefined} supports list of supports conditions
34 * @param {string | undefined} media list of media conditions
35 */
36 constructor(request, range, layer, supports, media) {
37 super(request);
38 this.range = range;
39 this.layer = layer;
40 this.supports = supports;
41 this.media = media;
42 }
43
44 get type() {
45 return "css @import";
46 }
47
48 get category() {
49 return "css-import";
50 }
51
52 /**
53 * @returns {string | null} an identifier to merge equal requests
54 */
55 getResourceIdentifier() {
56 let str = `context${this._context || ""}|module${this.request}`;
57
58 if (this.layer) {
59 str += `|layer${this.layer}`;
60 }
61
62 if (this.supports) {
63 str += `|supports${this.supports}`;
64 }
65
66 if (this.media) {
67 str += `|media${this.media}`;
68 }
69
70 return str;
71 }
72
73 /**
74 * @param {ObjectSerializerContext} context context
75 */
76 serialize(context) {
77 const { write } = context;
78 write(this.layer);
79 write(this.supports);
80 write(this.media);
81 super.serialize(context);
82 }
83
84 /**
85 * @param {ObjectDeserializerContext} context context
86 */
87 deserialize(context) {
88 const { read } = context;
89 this.layer = read();
90 this.supports = read();
91 this.media = read();
92 super.deserialize(context);
93 }
94}
95
96CssImportDependency.Template = class CssImportDependencyTemplate extends (
97 ModuleDependency.Template
98) {
99 /**
100 * @param {Dependency} dependency the dependency for which the template should be applied
101 * @param {ReplaceSource} source the current replace source which can be modified
102 * @param {DependencyTemplateContext} templateContext the context object
103 * @returns {void}
104 */
105 apply(dependency, source, templateContext) {
106 const dep = /** @type {CssImportDependency} */ (dependency);
107
108 source.replace(dep.range[0], dep.range[1] - 1, "");
109 }
110};
111
112makeSerializable(
113 CssImportDependency,
114 "webpack/lib/dependencies/CssImportDependency"
115);
116
117module.exports = CssImportDependency;
Note: See TracBrowser for help on using the repository browser.