Conexio amb la api
This commit is contained in:
parent
207c0ba819
commit
b12369cb47
48513 changed files with 7391639 additions and 7 deletions
61
node_modules/webpack/lib/runtime/CreateScriptUrlRuntimeModule.js
generated
vendored
Executable file
61
node_modules/webpack/lib/runtime/CreateScriptUrlRuntimeModule.js
generated
vendored
Executable file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const RuntimeGlobals = require("../RuntimeGlobals");
|
||||
const Template = require("../Template");
|
||||
const HelperRuntimeModule = require("./HelperRuntimeModule");
|
||||
|
||||
class CreateScriptUrlRuntimeModule extends HelperRuntimeModule {
|
||||
constructor() {
|
||||
super("trusted types");
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string} runtime code
|
||||
*/
|
||||
generate() {
|
||||
const { compilation } = this;
|
||||
const { runtimeTemplate, outputOptions } = compilation;
|
||||
const { trustedTypes } = outputOptions;
|
||||
const fn = RuntimeGlobals.createScriptUrl;
|
||||
|
||||
if (!trustedTypes) {
|
||||
// Skip Trusted Types logic.
|
||||
return Template.asString([
|
||||
`${fn} = ${runtimeTemplate.returningFunction("url", "url")};`
|
||||
]);
|
||||
}
|
||||
|
||||
return Template.asString([
|
||||
"var policy;",
|
||||
`${fn} = ${runtimeTemplate.basicFunction("url", [
|
||||
"// Create Trusted Type policy if Trusted Types are available and the policy doesn't exist yet.",
|
||||
"if (policy === undefined) {",
|
||||
Template.indent([
|
||||
"policy = {",
|
||||
Template.indent([
|
||||
`createScriptURL: ${runtimeTemplate.returningFunction(
|
||||
"url",
|
||||
"url"
|
||||
)}`
|
||||
]),
|
||||
"};",
|
||||
'if (typeof trustedTypes !== "undefined" && trustedTypes.createPolicy) {',
|
||||
Template.indent([
|
||||
`policy = trustedTypes.createPolicy(${JSON.stringify(
|
||||
trustedTypes.policyName
|
||||
)}, policy);`
|
||||
]),
|
||||
"}"
|
||||
]),
|
||||
"}",
|
||||
"return policy.createScriptURL(url);"
|
||||
])};`
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CreateScriptUrlRuntimeModule;
|
||||
Loading…
Add table
Add a link
Reference in a new issue