@plaudit/webpack-extensions 2.70.1 → 2.72.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.
@@ -1,634 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PHPWriter = exports.Constants = exports.Assignment = exports.validPHPLabel = exports.FirstClassCallable = exports.Parameter = exports.Call = exports.ObjectAccess = exports.ArrayAccess = exports.Access = exports.Not = exports.Op = exports.Var = exports.EnclosableLiteral = exports.EnclosedLiteral = exports.Literal = exports.EnclosedExpression = exports.ParenthesesEnclosableExpression = exports.AbstractEnclosableExpression = exports.Expr = void 0;
7
- exports.isEnclosableExpression = isEnclosableExpression;
8
- exports.isPotentiallyWriteableExpression = isPotentiallyWriteableExpression;
9
- const json_to_php_but_with____injection_1 = __importDefault(require("./json-to-php-but-with-__-injection"));
10
- const webpack_1 = require("webpack");
11
- class Expr {
12
- static jsonToPHPConverter = json_to_php_but_with____injection_1.default.make({ shortArraySyntax: true });
13
- static convertJsonToPHP = (obj) => obj instanceof Expr ? obj.toString() : Expr.jsonToPHPConverter(obj);
14
- constructor() { }
15
- // noinspection JSUnusedGlobalSymbols - this technically-unused method is necessary for TypeScript to differentiate subclasses of Expr from any
16
- typeName() {
17
- return this.constructor.name;
18
- }
19
- static isset(...checks) {
20
- return Expr.call("isset", checks);
21
- }
22
- static call(name, args) {
23
- return new Call(Literal.name(name), args);
24
- }
25
- }
26
- exports.Expr = Expr;
27
- function isEnclosableExpression(a) {
28
- return a instanceof Expr && 'toEnclosedForm' in a && typeof a.toEnclosedForm === 'function';
29
- }
30
- function isPotentiallyWriteableExpression(a) {
31
- return isEnclosableExpression(a) && 'potentiallyWritable' in a && a.potentiallyWritable === true;
32
- }
33
- class AbstractEnclosableExpression extends Expr {
34
- static closers = Object.freeze({ "(": ")", "[": "]", "{": "}" });
35
- not() {
36
- return new Not(this);
37
- }
38
- }
39
- exports.AbstractEnclosableExpression = AbstractEnclosableExpression;
40
- class ParenthesesEnclosableExpression extends AbstractEnclosableExpression {
41
- toEnclosedForm() {
42
- return "(" + this.toString() + ")";
43
- }
44
- }
45
- exports.ParenthesesEnclosableExpression = ParenthesesEnclosableExpression;
46
- class EnclosedExpression extends AbstractEnclosableExpression {
47
- toEnclosedForm() {
48
- return this.toString();
49
- }
50
- }
51
- exports.EnclosedExpression = EnclosedExpression;
52
- class Literal extends Expr {
53
- expression;
54
- constructor(expression) {
55
- super();
56
- this.expression = expression;
57
- }
58
- toString() {
59
- return this.expression;
60
- }
61
- static of(expression, enclosed = false, enclosureClose) {
62
- if (expression instanceof PHPWriter) {
63
- expression = expression.toString({ includeOpenPHP: false, includeNamespaceAndUse: false }).trim();
64
- }
65
- if (typeof enclosed === 'string') {
66
- return new EnclosableLiteral(expression, enclosed, enclosureClose ?? AbstractEnclosableExpression.closers[enclosed] ?? enclosed);
67
- }
68
- if (enclosed) {
69
- return new EnclosedLiteral(expression);
70
- }
71
- return new Literal(expression);
72
- }
73
- static name(expression) {
74
- return new EnclosedLiteral(expression);
75
- }
76
- }
77
- exports.Literal = Literal;
78
- class EnclosedLiteral extends Literal {
79
- constructor(expression) {
80
- super(expression);
81
- }
82
- toEnclosedForm() {
83
- return this.toString();
84
- }
85
- not() {
86
- return new Not(this);
87
- }
88
- }
89
- exports.EnclosedLiteral = EnclosedLiteral;
90
- class EnclosableLiteral extends Literal {
91
- enclosureOpen;
92
- enclosureClose;
93
- constructor(expression, enclosureOpen, enclosureClose) {
94
- super(expression);
95
- this.enclosureOpen = enclosureOpen;
96
- this.enclosureClose = enclosureClose;
97
- }
98
- toEnclosedForm() {
99
- return this.enclosureOpen + this.toString() + this.enclosureClose;
100
- }
101
- not() {
102
- return new Not(this);
103
- }
104
- }
105
- exports.EnclosableLiteral = EnclosableLiteral;
106
- class Var extends EnclosedExpression {
107
- name;
108
- potentiallyWritable = true;
109
- constructor(name) {
110
- super();
111
- this.name = name;
112
- }
113
- toString() {
114
- return "$" + this.name;
115
- }
116
- }
117
- exports.Var = Var;
118
- class Op extends ParenthesesEnclosableExpression {
119
- operator;
120
- args;
121
- constructor(operator, ...args) {
122
- super();
123
- this.operator = operator;
124
- this.args = args;
125
- }
126
- toString() {
127
- return this.args
128
- .map(a => isEnclosableExpression(a) ? a.toEnclosedForm() : Expr.convertJsonToPHP(a))
129
- .join(this.operator);
130
- }
131
- static binary(left, operator, right) {
132
- return new Op(operator, left, right);
133
- }
134
- static concat(...args) {
135
- return new Op(".", ...args);
136
- }
137
- }
138
- exports.Op = Op;
139
- class Not extends ParenthesesEnclosableExpression {
140
- expression;
141
- constructor(expression) {
142
- super();
143
- this.expression = expression;
144
- }
145
- toString() {
146
- return "!" + this.expression.toEnclosedForm();
147
- }
148
- }
149
- exports.Not = Not;
150
- class Access extends EnclosedExpression {
151
- target;
152
- potentiallyWritable = true;
153
- accesses;
154
- constructor(target, accesses) {
155
- super();
156
- this.target = target;
157
- this.accesses = Array.isArray(accesses) ? accesses : [accesses];
158
- }
159
- }
160
- exports.Access = Access;
161
- class ArrayAccess extends Access {
162
- toString() {
163
- return this.target.toEnclosedForm() + this.accesses.map(a => `[${Expr.convertJsonToPHP(a)}]`).join("");
164
- }
165
- endsWithCall() {
166
- return false;
167
- }
168
- endsWithPotentiallyWritableExpression() {
169
- return true;
170
- }
171
- }
172
- exports.ArrayAccess = ArrayAccess;
173
- class ObjectAccess extends Access {
174
- static validObjectKey = /^[a-zA-Z_][a-zA-Z_0-9]*$/;
175
- toString() {
176
- return [this.target.toString(), ...this.accesses.map(a => {
177
- if ((typeof a === 'string' && ObjectAccess.validObjectKey.test(a)) || a instanceof Var || a instanceof Call) {
178
- return a;
179
- }
180
- return "{" + Expr.convertJsonToPHP(a) + "}";
181
- })].join("->");
182
- }
183
- endsWithCall() {
184
- return this.accesses[this.accesses.length - 1] instanceof Call;
185
- }
186
- endsWithPotentiallyWritableExpression() {
187
- return isPotentiallyWriteableExpression(this.accesses[this.accesses.length - 1]);
188
- }
189
- }
190
- exports.ObjectAccess = ObjectAccess;
191
- class Call extends EnclosedExpression {
192
- callee;
193
- args;
194
- potentiallyWritable = true;
195
- constructor(callee, args) {
196
- super();
197
- this.callee = callee;
198
- this.args = args;
199
- }
200
- toString() {
201
- const callee = typeof this.callee === 'string' ? Expr.convertJsonToPHP(this.callee) : this.callee.toEnclosedForm();
202
- return `${callee}(${this.args.map(Expr.convertJsonToPHP).join(", ")})`;
203
- }
204
- }
205
- exports.Call = Call;
206
- class Parameter extends Expr {
207
- value;
208
- name;
209
- constructor(value, name) {
210
- super();
211
- this.value = value;
212
- this.name = name;
213
- }
214
- toString() {
215
- return this.name ? `${this.name}: ${Expr.convertJsonToPHP(this.value)}` : Expr.convertJsonToPHP(this.value);
216
- }
217
- }
218
- exports.Parameter = Parameter;
219
- class FirstClassCallable extends ParenthesesEnclosableExpression {
220
- name;
221
- constructor(name) {
222
- super();
223
- this.name = name;
224
- }
225
- static from(literal) {
226
- return new FirstClassCallable(Literal.name(literal));
227
- }
228
- toString() {
229
- return this.name.toEnclosedForm() + "(...)";
230
- }
231
- }
232
- exports.FirstClassCallable = FirstClassCallable;
233
- exports.validPHPLabel = /^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/; // This is from https://www.php.net/manual/en/functions.user-defined.php
234
- class Assignment extends ParenthesesEnclosableExpression {
235
- value;
236
- push;
237
- assignees;
238
- constructor(assignees, value, push = false) {
239
- super();
240
- this.value = value;
241
- this.push = push;
242
- this.assignees = Array.isArray(assignees) ? assignees : [assignees];
243
- if (this.assignees.some(a => a instanceof Access && !a.endsWithPotentiallyWritableExpression())) {
244
- throw new Error("Cannot assign a value to an access chain that does not end in a writable state");
245
- }
246
- if (!this.push && this.assignees.some(a => a instanceof Call || (a instanceof Access && a.endsWithCall()))) {
247
- throw new Error("Cannot assign a value to an access chain that ends in a function call unless that 'assignment' is a push");
248
- }
249
- }
250
- toString() {
251
- if (this.push) {
252
- return this.assignees[0].toEnclosedForm() + "[] = " + Expr.convertJsonToPHP(this.value);
253
- }
254
- return [...this.assignees.map(t => t.toEnclosedForm()), Expr.convertJsonToPHP(this.value)].join(" = ");
255
- }
256
- }
257
- exports.Assignment = Assignment;
258
- class Constants {
259
- static __FILE__ = Literal.name("__FILE__");
260
- static __DIR__ = Literal.name("__DIR__");
261
- static ABSPATH = Literal.name("ABSPATH");
262
- }
263
- exports.Constants = Constants;
264
- class PHPWriter {
265
- inlineFirstLine;
266
- scopeStack;
267
- useList;
268
- allocatedGeneratedFunctionNames;
269
- isSubwriter;
270
- printingInPHP;
271
- buffer = [];
272
- indentation;
273
- fileNamespace = "";
274
- myOpenedScopes = 0;
275
- constructor(inlineFirstLine = false, scopeStack = [], useList = [], allocatedGeneratedFunctionNames = new Set(), isSubwriter = false, printingInPHP = true, initialIndentation = 0) {
276
- this.inlineFirstLine = inlineFirstLine;
277
- this.scopeStack = scopeStack;
278
- this.useList = useList;
279
- this.allocatedGeneratedFunctionNames = allocatedGeneratedFunctionNames;
280
- this.isSubwriter = isSubwriter;
281
- this.printingInPHP = printingInPHP;
282
- this.indentation = "\t".repeat(initialIndentation);
283
- }
284
- createSubwriter() {
285
- return new PHPWriter(false, this.scopeStack, this.useList, this.allocatedGeneratedFunctionNames, true, this.printingInPHP, this.indentation.length)
286
- .setIndentation(this.indentation.length);
287
- }
288
- indent() {
289
- this.indentation += "\t";
290
- return this;
291
- }
292
- outdent() {
293
- this.indentation = this.indentation.slice(0, -1);
294
- return this;
295
- }
296
- setIndentation(level) {
297
- this.indentation = "\t".repeat(level);
298
- return this;
299
- }
300
- /**
301
- * @param lines These are treated as literal *regardless of their types*
302
- */
303
- append(...lines) {
304
- for (const line of lines) {
305
- this.buffer.push(`${this.indentation}${line}`);
306
- }
307
- return this;
308
- }
309
- /**
310
- * @param expr This is treated as literal *regardless of its type*
311
- * @param opts flags to add additional markup around the expression
312
- */
313
- appendExpr(expr, opts = {}) {
314
- let expression;
315
- if (isEnclosableExpression(expr)) {
316
- expression = opts.chain ? expr.toEnclosedForm() : expr.toString();
317
- }
318
- else if (opts.chain && expr instanceof Expr) {
319
- throw new Error(`Cannot chain non-enclosable expressions`);
320
- }
321
- else {
322
- expression = expr.toString();
323
- }
324
- if (opts.chain && expr instanceof Expr && !isEnclosableExpression(expr)) {
325
- throw new Error(`Cannot chain non-enclosable expressions`);
326
- }
327
- const res = (opts.return ? "return " : "") + expression;
328
- return this.append(!opts.chain ? res + ';' : res);
329
- }
330
- assign(assignee, expression, opts = {}) {
331
- if (typeof assignee === 'string') {
332
- assignee = new Var(assignee);
333
- }
334
- if (Array.isArray(assignee)) {
335
- if (this.scopeStack.length > 0) {
336
- this.scopeStack[this.scopeStack.length - 1].push(...assignee.filter(v => v instanceof Var).map(v => v.name));
337
- }
338
- }
339
- else {
340
- if (this.scopeStack.length > 0 && assignee instanceof Var) {
341
- this.scopeStack[this.scopeStack.length - 1].push(assignee.name);
342
- }
343
- }
344
- return this.appendExpr(new Assignment(assignee, expression), opts);
345
- }
346
- return(expression) {
347
- return this.appendExpr(Expr.convertJsonToPHP(expression), { return: true });
348
- }
349
- static(variable, opts = {}) {
350
- if (typeof variable === 'string') {
351
- variable = new Var(variable);
352
- }
353
- const initializer = opts.initializer ? Expr.convertJsonToPHP(opts.initializer) : "null";
354
- this.append(`static ${variable.toEnclosedForm()} = ${initializer};`);
355
- if (opts.withTest) {
356
- this.if(Op.binary(variable, "!==", new Literal(initializer)))
357
- .append(`return ${Expr.convertJsonToPHP(variable)};`);
358
- if (opts.withTest !== 'chainable') {
359
- this.endIf();
360
- }
361
- }
362
- return this;
363
- }
364
- linebreak() {
365
- this.buffer.push("");
366
- return this;
367
- }
368
- /**
369
- * @param func This is treated as literal *regardless of its type*
370
- * @param args
371
- * @param opts
372
- */
373
- call(func, args, opts = {}) {
374
- const functionCall = new Call(typeof func === 'string' ? Literal.name(func) : func, args);
375
- if (opts.assignTo) {
376
- return this.assign(opts.assignTo, functionCall, opts);
377
- }
378
- return this.appendExpr(functionCall, opts);
379
- }
380
- action(name, contents, args = {}) {
381
- return this.actionOrFilter('action', name, contents, args);
382
- }
383
- filter(name, contents, args = {}) {
384
- return this.actionOrFilter('filter', name, contents, args);
385
- }
386
- actionOrFilter(type, name, contents, args) {
387
- const { priority = 10, functionArgParameters = [], useVars = [], accountForAlreadyDoing } = args;
388
- const functionWriter = this.createSubwriter();
389
- let declarationFunction;
390
- if (accountForAlreadyDoing) {
391
- if (functionArgParameters.length > 0 && accountForAlreadyDoing === true) {
392
- console.trace(`The accountForAlreadyDoing flag must be set to a list of default parameters when applied to ${type}s that take arguments`);
393
- }
394
- this.openPHP().openScope();
395
- const functionName = functionWriter.function(true, functionArgParameters, contents, { useVars, scopeActionDescription: `closing the function call for the ${name} ${type}.`, assignToName: true });
396
- this.append(functionWriter.toString().trim());
397
- declarationFunction = new FirstClassCallable(functionName);
398
- this.if(Expr.call(`doing_${type}`, [name]))
399
- .call(functionName, accountForAlreadyDoing === true ? [] : accountForAlreadyDoing);
400
- }
401
- else {
402
- functionWriter.function(false, functionArgParameters, contents, { useVars, scopeActionDescription: `closing the function call for the ${name} ${type}.` });
403
- declarationFunction = Literal.of(functionWriter);
404
- }
405
- // The trailing comma inside the first item is necessary
406
- const additionArgs = [name, declarationFunction];
407
- const accepted_args = Math.max(functionArgParameters.length, 1); // This avoids us unnecessarily setting the accepted_args value to 0 for actions
408
- if (priority !== 10) {
409
- additionArgs.push(priority);
410
- if (accepted_args !== 1) {
411
- additionArgs.push(accepted_args);
412
- }
413
- }
414
- else if (accepted_args !== 1) {
415
- additionArgs.push(new Parameter(accepted_args, "accepted_args"));
416
- }
417
- const line = Expr.call(`add_${type}`, additionArgs);
418
- if (accountForAlreadyDoing) {
419
- return this
420
- .else()
421
- .appendExpr(line)
422
- .endIf()
423
- .closeScope();
424
- }
425
- return this.openPHP().appendExpr(line);
426
- }
427
- if(condition) {
428
- return this.openPHP().append(`if (${condition}) {`).indent();
429
- }
430
- elseIf(condition) {
431
- return this.openPHP().outdent().append(`} else if (${condition}) {`).indent();
432
- }
433
- else() {
434
- return this.openPHP().outdent().append(`} else {`).indent();
435
- }
436
- endIf() {
437
- return this.openPHP().outdent().append("}");
438
- }
439
- function(name, parameters, body, args = {}) {
440
- if (name === false) {
441
- if (args.includeExistenceCheck) {
442
- console.trace('Anonymous functions cannot have their existence checked for');
443
- }
444
- if (args.assignToName) {
445
- console.trace('Anonymous functions cannot be assigned to a name');
446
- }
447
- }
448
- if (typeof name === 'string') {
449
- if (!exports.validPHPLabel.test(name)) {
450
- throw new Error(`'${name}' is not a valid function name. Please see https://www.php.net/manual/en/functions.user-defined.php for what constitutes one`);
451
- }
452
- }
453
- const returningString = name === true;
454
- if (name === true) {
455
- name = this.generateFunctionName(args.assignToName);
456
- }
457
- if (args.includeExistenceCheck) {
458
- this.if(Expr.call('function_exists', [name]).not());
459
- }
460
- else {
461
- this.openPHP();
462
- }
463
- if (name instanceof Var) {
464
- if (this.scopeStack.length > 0) {
465
- this.scopeStack[this.scopeStack.length - 1].push(name.name);
466
- }
467
- }
468
- const declarationComponents = name === false ? [] : (name instanceof Var ? [name, '='] : ["function"]);
469
- let nameAndParameters = `${!name || name instanceof Var ? 'function' : name}(${parameters.join(", ")})`;
470
- if (args.useVars?.length) {
471
- let useVars = `use (${args.useVars.join(", ")})`;
472
- if (args.returnType) {
473
- useVars += `: ${args.returnType}`;
474
- }
475
- declarationComponents.push(nameAndParameters, useVars);
476
- }
477
- else {
478
- if (args.returnType) {
479
- nameAndParameters += `: ${args.returnType}`;
480
- }
481
- declarationComponents.push(nameAndParameters);
482
- }
483
- declarationComponents.push("{");
484
- this.append(declarationComponents.join(' '));
485
- this.indent();
486
- // We start a new scope here just in case this was called within an existing scope
487
- // We pop the scope instead of closing it because we don't actually want to unset any variables that were created within the function
488
- this.withScope(body, { actionDescription: args.scopeActionDescription ?? `closing the "${name || "anonymous"}" function`, usePopScopeInstead: true });
489
- this.openPHP().outdent().append(name !== false && args.assignToName ? "};" : "}");
490
- if (args.includeExistenceCheck) {
491
- this.endIf();
492
- }
493
- return returningString ? name : this;
494
- }
495
- generateFunctionName(asVariable = false) {
496
- let count = 0;
497
- let name;
498
- do {
499
- name = `plaudit_webpack_extensions__generated_function__${count++}`;
500
- } while (this.allocatedGeneratedFunctionNames.has(name));
501
- this.allocatedGeneratedFunctionNames.add(name);
502
- return asVariable ? new Var(name) : name;
503
- }
504
- closePHP() {
505
- if (!this.printingInPHP) {
506
- return this;
507
- }
508
- this.printingInPHP = false;
509
- return this.append("?>");
510
- }
511
- openPHP() {
512
- if (this.printingInPHP) {
513
- return this;
514
- }
515
- this.printingInPHP = true;
516
- return this.append("<?php");
517
- }
518
- namespace(namespace) {
519
- this.fileNamespace = namespace;
520
- return this;
521
- }
522
- use(...uses) {
523
- for (const use of uses) {
524
- if (!this.useList.find(u => u.toLowerCase() === use.toLowerCase())) {
525
- this.useList.push(use);
526
- }
527
- }
528
- return this;
529
- }
530
- require(filePath, args = {}) {
531
- return this.requireOrInclude('require', filePath, args);
532
- }
533
- include(filePath, args = {}) {
534
- return this.requireOrInclude('include', filePath, args);
535
- }
536
- requireOrInclude(type, filePath, args) {
537
- const command = args.once ? `${type}_once` : type;
538
- if (args.dirRelative && typeof filePath === 'string' && !filePath.startsWith("/")) {
539
- filePath = "/" + filePath;
540
- }
541
- const path = args.dirRelative ? Op.concat(Constants.__DIR__, filePath) : Expr.convertJsonToPHP(filePath);
542
- return this.appendExpr(`${command} ${path}`, args);
543
- }
544
- /**
545
- * Starts a scope that, when paired with {@link #closeScope()}, allows for automating unset calls.
546
- * All scopes started MUST be paired with either an {@link #closeScope()} or {@link #popScope()} call.
547
- */
548
- openScope() {
549
- this.scopeStack.push([]);
550
- this.myOpenedScopes++;
551
- return this;
552
- }
553
- /**
554
- * Pops the top scope from the stack AND unsets all variables that were assigned within it
555
- */
556
- closeScope() {
557
- if (!this.myOpenedScopes) {
558
- return this;
559
- }
560
- this.myOpenedScopes--;
561
- const scope = this.scopeStack.pop();
562
- if (!scope?.length) {
563
- return this;
564
- }
565
- const uniquenessSet = new Set();
566
- const uniqueScopeItems = scope.filter(si => !uniquenessSet.has(si) && uniquenessSet.add(si));
567
- for (const scopeItem of uniqueScopeItems) {
568
- this.allocatedGeneratedFunctionNames.delete(scopeItem);
569
- }
570
- // This is equivalent to calling this.call("unset", scope.map(v => new Var(v))), but creates fewer objects
571
- return this.append(`unset(${uniqueScopeItems.map(usi => "$" + usi).join(", ")});`);
572
- }
573
- /**
574
- * Pops the top scope from the stack WITHOUT calling unset for the variables that were assigned within it.
575
- * This is used to allow function bodies to be safely created without disrupting their containing scope.
576
- */
577
- popScope() {
578
- if (this.myOpenedScopes) {
579
- this.scopeStack.pop();
580
- this.myOpenedScopes--;
581
- }
582
- return this;
583
- }
584
- withScope(code, opts = {}) {
585
- const expectedScopeCount = this.scopeStack.length;
586
- this.openScope();
587
- code(this);
588
- if (opts.usePopScopeInstead) {
589
- this.popScope();
590
- }
591
- else {
592
- this.closeScope();
593
- }
594
- if (expectedScopeCount !== this.scopeStack.length) {
595
- console.trace(`Encountered an unexpected number of scopes (saw: ${this.scopeStack.length}, expected: ${expectedScopeCount})`, `while ${opts.actionDescription ?? "ending an encapsulating scope"}.`);
596
- }
597
- return this;
598
- }
599
- toString(args = this.isSubwriter ? { includeOpenPHP: false, includeNamespaceAndUse: false } : {}) {
600
- if (this.myOpenedScopes) {
601
- console.trace("toString() was called on a PHPWriter that has a dangling scope");
602
- }
603
- const fileContents = [];
604
- let canInline = true;
605
- if (args.includeNamespaceAndUse !== false) {
606
- if (this.fileNamespace) {
607
- canInline = false;
608
- fileContents.push(`namespace ${this.fileNamespace};`);
609
- }
610
- if (this.useList.length) {
611
- canInline = false;
612
- fileContents.push(...this.useList.map(use => `use ${use};`));
613
- }
614
- }
615
- fileContents.push(...this.buffer);
616
- if (args.includeOpenPHP === false) {
617
- return fileContents.join("\n");
618
- }
619
- if (this.inlineFirstLine && canInline) {
620
- return `<?php ${fileContents.join("\n")}`;
621
- }
622
- else if (fileContents.find(line => line.length > 0)) {
623
- return "<?php\n" + fileContents.join("\n");
624
- }
625
- else {
626
- return "<?php";
627
- }
628
- }
629
- emitAsset(compilation, file, assetInfo) {
630
- const contents = this.toString() + "\n";
631
- compilation[file in compilation.assets ? 'updateAsset' : 'emitAsset'](file, new webpack_1.sources.RawSource(contents), { size: Buffer.byteLength(contents), ...assetInfo });
632
- }
633
- }
634
- exports.PHPWriter = PHPWriter;