@plaudit/webpack-extensions 2.60.1 → 2.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -104,11 +104,11 @@ class ExtensionsConfigFileGeneratorPlugin {
|
|
|
104
104
|
finalExtensionsDest = "/" + finalExtensionsDest;
|
|
105
105
|
}
|
|
106
106
|
writer
|
|
107
|
-
.use("Plaudit\\
|
|
107
|
+
.use("Plaudit\\Common\\Lib\\GutenbergUtils")
|
|
108
108
|
.withScope(writer => writer
|
|
109
109
|
.assign("$filePathPrefix", new php_writer_1.Expr(`__DIR__.${php_writer_1.Expr.convertJsonToPHP(finalExtensionsDest)}`))
|
|
110
110
|
.call("plaudit_webpack_extensions__resolve_base_uri", [new php_writer_1.Expr("$filePathPrefix")], { assignTo: "$fileUriPrefix" })
|
|
111
|
-
.call("
|
|
111
|
+
.call("GutenbergUtils::loadExtensionsV2", [
|
|
112
112
|
new php_writer_1.Expr(`__DIR__.${php_writer_1.Expr.convertJsonToPHP(finalExtensionsDest + "mapping.config.php")}`),
|
|
113
113
|
new php_writer_1.Expr(`$filePathPrefix`), new php_writer_1.Expr("$fileUriPrefix"),
|
|
114
114
|
`${this.config.plainEntrypointsHandlePrefix || node_path_1.default.basename(process.cwd())}_extension_`
|
|
@@ -134,8 +134,8 @@ class ExtensionsConfigFileGeneratorPlugin {
|
|
|
134
134
|
compilation.hooks.processAssets.tap({ name: `${this.constructor.name}_UnifiedLoaderGeneratorIntegration`, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_DERIVED }, () => {
|
|
135
135
|
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, { group: `extensions-config-v1-${this.extensionsDest}`, requiresBaseURI: false, action: writer => {
|
|
136
136
|
writer
|
|
137
|
-
.use("Plaudit\\
|
|
138
|
-
.call("
|
|
137
|
+
.use("Plaudit\\Common\\Lib\\GutenbergUtils")
|
|
138
|
+
.call("GutenbergUtils::installExtensionsSupport", [new php_writer_1.Expr(`__DIR__.${php_writer_1.Expr.convertJsonToPHP(this.extensionsDest)}`)]);
|
|
139
139
|
} });
|
|
140
140
|
});
|
|
141
141
|
compilation.hooks.afterProcessAssets.tap(`${this.constructor.name}_AfterProcessAssets`, this.makeVersionOneAfterProcessAssets(compilation));
|
|
@@ -25,12 +25,13 @@ export declare class PHPWriter {
|
|
|
25
25
|
private readonly scopeStack;
|
|
26
26
|
private readonly useList;
|
|
27
27
|
private readonly allocatedGeneratedFunctionNames;
|
|
28
|
+
private readonly isSubwriter;
|
|
28
29
|
private printingInPHP;
|
|
29
30
|
private buffer;
|
|
30
31
|
private indentation;
|
|
31
32
|
private fileNamespace;
|
|
32
33
|
private myOpenedScopes;
|
|
33
|
-
constructor(inlineFirstLine?: boolean, scopeStack?: string[][], useList?: string[], allocatedGeneratedFunctionNames?: Set<string>, printingInPHP?: boolean, initialIndentation?: number);
|
|
34
|
+
constructor(inlineFirstLine?: boolean, scopeStack?: string[][], useList?: string[], allocatedGeneratedFunctionNames?: Set<string>, isSubwriter?: boolean, printingInPHP?: boolean, initialIndentation?: number);
|
|
34
35
|
createSubwriter(): PHPWriter;
|
|
35
36
|
indent(): this;
|
|
36
37
|
outdent(): this;
|
|
@@ -85,6 +86,7 @@ export declare class PHPWriter {
|
|
|
85
86
|
}): this;
|
|
86
87
|
toString(args?: {
|
|
87
88
|
includeOpenPHP?: boolean;
|
|
89
|
+
includeNamespaceAndUse?: boolean;
|
|
88
90
|
}): string;
|
|
89
91
|
emitAsset(compilation: Compilation, file: string, assetInfo?: AssetInfo): void;
|
|
90
92
|
}
|
|
@@ -25,21 +25,23 @@ class PHPWriter {
|
|
|
25
25
|
scopeStack;
|
|
26
26
|
useList;
|
|
27
27
|
allocatedGeneratedFunctionNames;
|
|
28
|
+
isSubwriter;
|
|
28
29
|
printingInPHP;
|
|
29
30
|
buffer = [];
|
|
30
31
|
indentation;
|
|
31
32
|
fileNamespace = "";
|
|
32
33
|
myOpenedScopes = 0;
|
|
33
|
-
constructor(inlineFirstLine = false, scopeStack = [], useList = [], allocatedGeneratedFunctionNames = new Set(), printingInPHP = true, initialIndentation = 0) {
|
|
34
|
+
constructor(inlineFirstLine = false, scopeStack = [], useList = [], allocatedGeneratedFunctionNames = new Set(), isSubwriter = false, printingInPHP = true, initialIndentation = 0) {
|
|
34
35
|
this.inlineFirstLine = inlineFirstLine;
|
|
35
36
|
this.scopeStack = scopeStack;
|
|
36
37
|
this.useList = useList;
|
|
37
38
|
this.allocatedGeneratedFunctionNames = allocatedGeneratedFunctionNames;
|
|
39
|
+
this.isSubwriter = isSubwriter;
|
|
38
40
|
this.printingInPHP = printingInPHP;
|
|
39
41
|
this.indentation = "\t".repeat(initialIndentation);
|
|
40
42
|
}
|
|
41
43
|
createSubwriter() {
|
|
42
|
-
return new PHPWriter(false, this.scopeStack, this.useList, this.allocatedGeneratedFunctionNames, this.printingInPHP, this.indentation.length)
|
|
44
|
+
return new PHPWriter(false, this.scopeStack, this.useList, this.allocatedGeneratedFunctionNames, true, this.printingInPHP, this.indentation.length)
|
|
43
45
|
.setIndentation(this.indentation.length);
|
|
44
46
|
}
|
|
45
47
|
indent() {
|
|
@@ -127,13 +129,13 @@ class PHPWriter {
|
|
|
127
129
|
}
|
|
128
130
|
this.openPHP().openScope();
|
|
129
131
|
const functionName = functionWriter.function(true, functionArgParameters, contents, { useVars, scopeActionDescription: `closing the function call for the ${name} ${type}.`, assignToName: true });
|
|
130
|
-
this.append(functionWriter.toString(
|
|
132
|
+
this.append(functionWriter.toString().trim());
|
|
131
133
|
declarationFunctionText = functionName + "(...)";
|
|
132
134
|
this.if(`doing_${type}(${Expr.convertJsonToPHP(name)})`).call(functionName, accountForAlreadyDoing === true ? [] : accountForAlreadyDoing);
|
|
133
135
|
}
|
|
134
136
|
else {
|
|
135
137
|
functionWriter.function(false, functionArgParameters, contents, { useVars, scopeActionDescription: `closing the function call for the ${name} ${type}.` });
|
|
136
|
-
declarationFunctionText = functionWriter.toString(
|
|
138
|
+
declarationFunctionText = functionWriter.toString().trim();
|
|
137
139
|
}
|
|
138
140
|
// The trailing comma inside the first item is necessary
|
|
139
141
|
const declarationComponents = [`${Expr.convertJsonToPHP(name)}`, declarationFunctionText];
|
|
@@ -307,19 +309,21 @@ class PHPWriter {
|
|
|
307
309
|
}
|
|
308
310
|
return this;
|
|
309
311
|
}
|
|
310
|
-
toString(args = {}) {
|
|
312
|
+
toString(args = this.isSubwriter ? { includeOpenPHP: false, includeNamespaceAndUse: false } : {}) {
|
|
311
313
|
if (this.myOpenedScopes) {
|
|
312
314
|
console.trace("toString() was called on a PHPWriter that has a dangling scope");
|
|
313
315
|
}
|
|
314
316
|
const fileContents = [];
|
|
315
317
|
let canInline = true;
|
|
316
|
-
if (
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
318
|
+
if (args.includeNamespaceAndUse !== false) {
|
|
319
|
+
if (this.fileNamespace) {
|
|
320
|
+
canInline = false;
|
|
321
|
+
fileContents.push(`namespace ${this.fileNamespace};`);
|
|
322
|
+
}
|
|
323
|
+
if (this.useList.length) {
|
|
324
|
+
canInline = false;
|
|
325
|
+
fileContents.push(...this.useList.map(use => `use ${use};`));
|
|
326
|
+
}
|
|
323
327
|
}
|
|
324
328
|
fileContents.push(...this.buffer);
|
|
325
329
|
if (args.includeOpenPHP === false) {
|