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

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

F4 Finalna Verzija

  • Property mode set to 100644
File size: 3.6 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Alexander Akait @alexander-akait
4*/
5
6"use strict";
7
8const makeSerializable = require("../util/makeSerializable");
9const NullDependency = require("./NullDependency");
10
11/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
12/** @typedef {import("../Dependency")} Dependency */
13/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
14/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
15/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
16/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
17/** @typedef {import("../ModuleGraph")} ModuleGraph */
18/** @typedef {import("../css/CssParser").Range} Range */
19/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
20/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
21/** @typedef {import("../util/Hash")} Hash */
22/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
23
24class CssIcssSymbolDependency extends NullDependency {
25 /**
26 * @param {string} name name
27 * @param {string} value value
28 * @param {Range} range range
29 */
30 constructor(name, value, range) {
31 super();
32 this.name = name;
33 this.value = value;
34 this.range = range;
35 this._hashUpdate = undefined;
36 }
37
38 get type() {
39 return "css @value identifier";
40 }
41
42 get category() {
43 return "self";
44 }
45
46 /**
47 * Update the hash
48 * @param {Hash} hash hash to be updated
49 * @param {UpdateHashContext} context context
50 * @returns {void}
51 */
52 updateHash(hash, context) {
53 if (this._hashUpdate === undefined) {
54 this._hashUpdate = `${this.range}${this.name}${this.value}`;
55 }
56 hash.update(this._hashUpdate);
57 }
58
59 /**
60 * Returns the exported names
61 * @param {ModuleGraph} moduleGraph module graph
62 * @returns {ExportsSpec | undefined} export names
63 */
64 getExports(moduleGraph) {
65 return {
66 exports: [
67 {
68 name: this.name,
69 canMangle: true
70 }
71 ],
72 dependencies: undefined
73 };
74 }
75
76 /**
77 * Returns list of exports referenced by this dependency
78 * @param {ModuleGraph} moduleGraph module graph
79 * @param {RuntimeSpec} runtime the runtime for which the module is analysed
80 * @returns {(string[] | ReferencedExport)[]} referenced exports
81 */
82 getReferencedExports(moduleGraph, runtime) {
83 return [[this.name]];
84 }
85
86 /**
87 * @param {ObjectSerializerContext} context context
88 */
89 serialize(context) {
90 const { write } = context;
91 write(this.name);
92 write(this.value);
93 write(this.range);
94 super.serialize(context);
95 }
96
97 /**
98 * @param {ObjectDeserializerContext} context context
99 */
100 deserialize(context) {
101 const { read } = context;
102 this.name = read();
103 this.value = read();
104 this.range = read();
105 super.deserialize(context);
106 }
107}
108
109CssIcssSymbolDependency.Template = class CssValueAtRuleDependencyTemplate extends (
110 NullDependency.Template
111) {
112 /**
113 * @param {Dependency} dependency the dependency for which the template should be applied
114 * @param {ReplaceSource} source the current replace source which can be modified
115 * @param {DependencyTemplateContext} templateContext the context object
116 * @returns {void}
117 */
118 apply(dependency, source, { cssData }) {
119 const dep = /** @type {CssIcssSymbolDependency} */ (dependency);
120
121 source.replace(dep.range[0], dep.range[1] - 1, dep.value);
122
123 cssData.exports.set(dep.name, dep.value);
124 }
125};
126
127makeSerializable(
128 CssIcssSymbolDependency,
129 "webpack/lib/dependencies/CssIcssSymbolDependency"
130);
131
132module.exports = CssIcssSymbolDependency;
Note: See TracBrowser for help on using the repository browser.