@e-mc/document 0.10.1 → 0.10.3

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.
package/LICENSE CHANGED
@@ -1,11 +1,11 @@
1
- Copyright 2024 An Pham
2
-
3
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
-
5
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
-
7
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
-
9
- 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
-
1
+ Copyright 2024 An Pham
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
11
  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,197 +1,197 @@
1
- # @e-mc/document
2
-
3
- * NodeJS 16
4
- * ES2020
5
-
6
- ## General Usage
7
-
8
- * [Read the Docs](https://e-mc.readthedocs.io)
9
-
10
- ## Interface
11
-
12
- * [View Source](https://www.unpkg.com/@e-mc/types@0.10.1/lib/index.d.ts)
13
-
14
- ```typescript
15
- import type { DataSource, ViewEngine } from "./squared";
16
-
17
- import type { IFileManager, IScopeOrigin } from "./index";
18
- import type { ExternalAsset, FileCommand, IFileThread, OutputFinalize } from "./asset";
19
- import type { HostInitConfig, IClient } from "./core";
20
- import type { AsSourceFileOptions, ConfigOrTransformer, CustomizeOptions, GenerateLintTableOptions, LintMessage, PluginConfig, SourceCode, SourceInput, SourceMap, SourceMapOptions, TransformAction, TransformCallback, TransformOutput, TransformResult, UpdateGradleOptions } from "./document";
21
- import type { PostFinalizeCallback } from "./filemanager";
22
- import type { LogComponent } from "./logger";
23
- import type { DocumentComponent, DocumentComponentOption, DocumentModule } from "./settings";
24
- import type { IFileGroup, WatchInitResult } from "./watch";
25
-
26
- interface IDocument extends IClient<IFileManager, DocumentModule, TransformCallback<IFileManager, ExternalAsset>> {
27
- Db: IDb | null;
28
- assets: ExternalAsset[];
29
- config: Record<string, any>;
30
- init(assets: ExternalAsset[], config?: HostInitConfig): this;
31
- customize(options?: CustomizeOptions): void;
32
- findConfig(data: object, name: string, type?: string): PluginConfig;
33
- loadConfig(data: object, name: string): ConfigOrTransformer | null | undefined;
34
- asSourceFile(value: string, cache: boolean): unknown;
35
- asSourceFile(value: string, options?: AsSourceFileOptions): unknown;
36
- findVersion(name: string | string[], fallback?: string): string;
37
- findSourceScope(uri: string, imports: Record<string, unknown>): Record<string, string | undefined>[];
38
- findSourceRoot(uri: string, imports?: Record<string, string | undefined>): string | undefined;
39
- resolveDir(name: string, ...paths: string[]): string | undefined;
40
- locateSourceFiles(file: ExternalAsset, code?: string, bundleContent?: string[]): ((imports?: Record<string, string | undefined>) => SourceInput | undefined);
41
- resolveSourceFile(file: ExternalAsset): ((code?: string, imports?: Record<string, string | undefined>) => SourceInput<string> | undefined);
42
- tryParse(source: string, format: string, options?: Record<string | number | symbol, unknown>): unknown;
43
- forDb(item: DataSource): boolean;
44
- hasEval(name: string): boolean;
45
- settingsOf(name: keyof DocumentComponent, option: keyof DocumentComponentOption): unknown;
46
- parseTemplate(viewEngine: ViewEngine | string, template: string, data: unknown[]): Promise<string | null>;
47
- transform(type: string, code: string, format: string | string[], options?: TransformOutput & TransformAction): Promise<TransformResult | void>;
48
- abort(err: Error): void;
49
- abort(name?: keyof DocumentComponent, reason?: unknown): void;
50
- restart(): void;
51
- using?(data: IFileThread): Promise<unknown>;
52
- setLocalUri?(file: ExternalAsset, replace?: boolean): void;
53
- resolveUri?(file: ExternalAsset, source: string): string;
54
- resolveUri?(file: ExternalAsset, source: string, trailing: string): [string, string];
55
- resolveImports?(file: ExternalAsset, code: string, baseFile?: string | ExternalAsset): string | undefined;
56
- replaceContent?(source: string, statement: RegExpExecArray | string, mimeType?: string): string | undefined;
57
- addCopy?(data: FileCommand<ExternalAsset>, saveAs: string, replace?: boolean): string | undefined;
58
- writeImage?(output: OutputFinalize<ExternalAsset>): boolean;
59
- cloudInit?(state: IScopeOrigin<IFileManager, ICloud>): void;
60
- cloudObject?(state: IScopeOrigin<IFileManager, ICloud>, file: ExternalAsset): boolean;
61
- cloudUpload?(state: IScopeOrigin<IFileManager, ICloud>, file: ExternalAsset, url: string, active: boolean): Promise<boolean>;
62
- cloudFinalize?(state: IScopeOrigin<IFileManager, ICloud>): Promise<unknown[]>;
63
- watchInit?(watch: IFileGroup<ExternalAsset>, assets: ExternalAsset[], sanitize?: boolean): WatchInitResult | undefined;
64
- watchModified?(watch: IFileGroup<ExternalAsset>, assets?: ExternalAsset[]): PostFinalizeCallback;
65
- set dataSource(value: DataSource[]);
66
- get dataSource(): DataSource[];
67
- set imports(value);
68
- get imports(): Record<string, string | undefined>;
69
- get watching(): boolean;
70
- }
71
-
72
- interface DocumentConstructor extends ModuleConstructor {
73
- finalize(this: IFileManager, instance: IDocument): Promise<unknown>;
74
- createSourceMap(code: string, remove: boolean): SourceMap;
75
- createSourceMap(code: string, uri?: string, remove?: boolean): SourceMap;
76
- writeSourceMap(uri: string, data: SourceCode, options?: SourceMapOptions): string | undefined;
77
- updateGradle(source: string, namespaces: string[], value: string, upgrade: boolean): string;
78
- updateGradle(source: string, namespaces: string[], value: string, options?: UpdateGradleOptions): string;
79
- generateLintTable(messages: LintMessage[], options: GenerateLintTableOptions): LogComponent[];
80
- cleanup?(this: IFileManager, instance: IDocument): Promise<unknown>;
81
- sanitizeAssets?(assets: ExternalAsset[], exclusions?: unknown[]): ExternalAsset[];
82
- readonly prototype: IDocument;
83
- new(module?: DocumentModule, ...args: unknown[]): IDocument;
84
- }
85
- ```
86
-
87
- ## Settings
88
-
89
- ```typescript
90
- import type { PermittedDirectories } from "./core";
91
- import type { DbModule, DbSettings, DocumentComponentOptions, PurgeComponent } from "./settings";
92
-
93
- interface DocumentModule {
94
- // handler: "@pi-r/chrome";
95
- extensions?: string[];
96
- db?: DbModule<DbSettings>;
97
- eval?: {
98
- function?: boolean;
99
- absolute?: boolean;
100
- template?: boolean;
101
- userconfig?: boolean;
102
- };
103
- format?: {
104
- uuid?: {
105
- dictionary?: string;
106
- pathname?: string;
107
- filename?: string;
108
- };
109
- };
110
- imports?: StringMap;
111
- settings?: {
112
- broadcast_id?: string | string[];
113
- users?: Record<string, {
114
- extensions?: string[] | null;
115
- imports?: StringMap;
116
- imports_strict?: boolean;
117
- pages?: unknown;
118
- transform?: unknown;
119
- view_engine?: unknown;
120
- }>;
121
- cache_dir?: string;
122
- imports_strict?: boolean;
123
- directory?: {
124
- template?: string;
125
- data?: string;
126
- export?: string;
127
- schema?: string;
128
- package?: string;
129
- };
130
- purge?: PurgeComponent;
131
- options?: DocumentComponentOptions<boolean | number>;
132
- pages?: Record<string, Record<string, unknown>>;
133
- transform?: {
134
- html?: Record<string, Record<string, unknown>>;
135
- css?: Record<string, Record<string, unknown>>;
136
- js?: Record<string, Record<string, unknown>>;
137
- };
138
- view_engine?: Record<string, Record<string, unknown>>;
139
- export?: Record<string, string | (...args: unknown[]) => unknown>;
140
- };
141
- permission?: PermittedDirectories;
142
- }
143
- ```
144
-
145
- ### Example usage
146
-
147
- ```javascript
148
- const Document = require("@e-mc/document"); // @pi-r/chrome
149
-
150
- const assets = [
151
- { pathname: "output", filename: "image1.png", uri: "http://hostname/path/document1.png" },
152
- { pathname: "output", filename: "image2.png", uri: "http://hostname/path/document2.png" }
153
- ];
154
-
155
- const instance = new Document({
156
- eval: {
157
- function: true,
158
- template: true
159
- },
160
- imports: {
161
- "http://hostname/path/": "build/"
162
- },
163
- settings: {
164
- imports_strict: true,
165
- users: {
166
- "nodejs-001": {
167
- imports_strict: false,
168
- imports: {
169
- "http://hostname/path": "build"
170
- }
171
- }
172
- },
173
- directory: {
174
- template: "../chrome/template" // ../chrome/template/users/nodejs-001
175
- }
176
- }
177
- });
178
- // instance.host = new Host();
179
- instance.init(assets);
180
- ```
181
-
182
- NOTE: **@e-mc/document** is an abstract base class and cannot be instantiated. **Document** is more commonly called through [@pi-r/chrome](https://www.npmjs.com/package/@pi-r/chrome).
183
-
184
- ## References
185
-
186
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/squared.d.ts
187
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/asset.d.ts
188
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/core.d.ts
189
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/document.d.ts
190
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/filemanager.d.ts
191
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/logger.d.ts
192
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/settings.d.ts
193
- - https://www.unpkg.com/@e-mc/types@0.10.1/lib/watch.d.ts
194
-
195
- ## LICENSE
196
-
1
+ # @e-mc/document
2
+
3
+ * NodeJS 16
4
+ * ES2020
5
+
6
+ ## General Usage
7
+
8
+ * [Read the Docs](https://e-mc.readthedocs.io)
9
+
10
+ ## Interface
11
+
12
+ * [View Source](https://www.unpkg.com/@e-mc/types@0.10.3/lib/index.d.ts)
13
+
14
+ ```typescript
15
+ import type { DataSource, ViewEngine } from "./squared";
16
+
17
+ import type { IFileManager, IScopeOrigin } from "./index";
18
+ import type { ExternalAsset, FileCommand, IFileThread, OutputFinalize } from "./asset";
19
+ import type { HostInitConfig, IClient } from "./core";
20
+ import type { AsSourceFileOptions, ConfigOrTransformer, CustomizeOptions, GenerateLintTableOptions, LintMessage, PluginConfig, SourceCode, SourceInput, SourceMap, SourceMapOptions, TransformAction, TransformCallback, TransformOutput, TransformResult, UpdateGradleOptions } from "./document";
21
+ import type { PostFinalizeCallback } from "./filemanager";
22
+ import type { LogComponent } from "./logger";
23
+ import type { DocumentComponent, DocumentComponentOption, DocumentModule } from "./settings";
24
+ import type { IFileGroup, WatchInitResult } from "./watch";
25
+
26
+ interface IDocument extends IClient<IFileManager, DocumentModule, TransformCallback<IFileManager, ExternalAsset>> {
27
+ Db: IDb | null;
28
+ assets: ExternalAsset[];
29
+ config: Record<string, any>;
30
+ init(assets: ExternalAsset[], config?: HostInitConfig): this;
31
+ customize(options?: CustomizeOptions): void;
32
+ findConfig(data: object, name: string, type?: string): PluginConfig;
33
+ loadConfig(data: object, name: string): ConfigOrTransformer | null | undefined;
34
+ asSourceFile(value: string, cache: boolean): unknown;
35
+ asSourceFile(value: string, options?: AsSourceFileOptions): unknown;
36
+ findVersion(name: string | string[], fallback?: string): string;
37
+ findSourceScope(uri: string, imports: Record<string, unknown>): Record<string, string | undefined>[];
38
+ findSourceRoot(uri: string, imports?: Record<string, string | undefined>): string | undefined;
39
+ resolveDir(name: string, ...paths: string[]): string | undefined;
40
+ locateSourceFiles(file: ExternalAsset, code?: string, bundleContent?: string[]): ((imports?: Record<string, string | undefined>) => SourceInput | undefined);
41
+ resolveSourceFile(file: ExternalAsset): ((code?: string, imports?: Record<string, string | undefined>) => SourceInput<string> | undefined);
42
+ tryParse(source: string, format: string, options?: Record<string | number | symbol, unknown>): unknown;
43
+ forDb(item: DataSource): boolean;
44
+ hasEval(name: string): boolean;
45
+ settingsOf(name: keyof DocumentComponent, option: keyof DocumentComponentOption): unknown;
46
+ parseTemplate(viewEngine: ViewEngine | string, template: string, data: unknown[]): Promise<string | null>;
47
+ transform(type: string, code: string, format: string | string[], options?: TransformOutput & TransformAction): Promise<TransformResult | void>;
48
+ abort(err: Error): void;
49
+ abort(name?: keyof DocumentComponent, reason?: unknown): void;
50
+ restart(): void;
51
+ using?(data: IFileThread): Promise<unknown>;
52
+ setLocalUri?(file: ExternalAsset, replace?: boolean): void;
53
+ resolveUri?(file: ExternalAsset, source: string): string;
54
+ resolveUri?(file: ExternalAsset, source: string, trailing: string): [string, string];
55
+ resolveImports?(file: ExternalAsset, code: string, baseFile?: string | ExternalAsset): string | undefined;
56
+ replaceContent?(source: string, statement: RegExpExecArray | string, mimeType?: string): string | undefined;
57
+ addCopy?(data: FileCommand<ExternalAsset>, saveAs: string, replace?: boolean): string | undefined;
58
+ writeImage?(output: OutputFinalize<ExternalAsset>): boolean;
59
+ cloudInit?(state: IScopeOrigin<IFileManager, ICloud>): void;
60
+ cloudObject?(state: IScopeOrigin<IFileManager, ICloud>, file: ExternalAsset): boolean;
61
+ cloudUpload?(state: IScopeOrigin<IFileManager, ICloud>, file: ExternalAsset, url: string, active: boolean): Promise<boolean>;
62
+ cloudFinalize?(state: IScopeOrigin<IFileManager, ICloud>): Promise<unknown[]>;
63
+ watchInit?(watch: IFileGroup<ExternalAsset>, assets: ExternalAsset[], sanitize?: boolean): WatchInitResult | undefined;
64
+ watchModified?(watch: IFileGroup<ExternalAsset>, assets?: ExternalAsset[]): PostFinalizeCallback;
65
+ set dataSource(value: DataSource[]);
66
+ get dataSource(): DataSource[];
67
+ set imports(value);
68
+ get imports(): Record<string, string | undefined>;
69
+ get watching(): boolean;
70
+ }
71
+
72
+ interface DocumentConstructor extends ModuleConstructor {
73
+ finalize(this: IFileManager, instance: IDocument): Promise<unknown>;
74
+ createSourceMap(code: string, remove: boolean): SourceMap;
75
+ createSourceMap(code: string, uri?: string, remove?: boolean): SourceMap;
76
+ writeSourceMap(uri: string, data: SourceCode, options?: SourceMapOptions): string | undefined;
77
+ updateGradle(source: string, namespaces: string[], value: string, upgrade: boolean): string;
78
+ updateGradle(source: string, namespaces: string[], value: string, options?: UpdateGradleOptions): string;
79
+ generateLintTable(messages: LintMessage[], options: GenerateLintTableOptions): LogComponent[];
80
+ cleanup?(this: IFileManager, instance: IDocument): Promise<unknown>;
81
+ sanitizeAssets?(assets: ExternalAsset[], exclusions?: unknown[]): ExternalAsset[];
82
+ readonly prototype: IDocument;
83
+ new(module?: DocumentModule, ...args: unknown[]): IDocument;
84
+ }
85
+ ```
86
+
87
+ ## Settings
88
+
89
+ ```typescript
90
+ import type { PermittedDirectories } from "./core";
91
+ import type { DbModule, DbSettings, DocumentComponentOptions, PurgeComponent } from "./settings";
92
+
93
+ interface DocumentModule {
94
+ // handler: "@pi-r/chrome";
95
+ extensions?: string[];
96
+ db?: DbModule<DbSettings>;
97
+ eval?: {
98
+ function?: boolean;
99
+ absolute?: boolean;
100
+ template?: boolean;
101
+ userconfig?: boolean;
102
+ };
103
+ format?: {
104
+ uuid?: {
105
+ dictionary?: string;
106
+ pathname?: string;
107
+ filename?: string;
108
+ };
109
+ };
110
+ imports?: StringMap;
111
+ settings?: {
112
+ broadcast_id?: string | string[];
113
+ users?: Record<string, {
114
+ extensions?: string[] | null;
115
+ imports?: StringMap;
116
+ imports_strict?: boolean;
117
+ pages?: unknown;
118
+ transform?: unknown;
119
+ view_engine?: unknown;
120
+ }>;
121
+ cache_dir?: string;
122
+ imports_strict?: boolean;
123
+ directory?: {
124
+ template?: string;
125
+ data?: string;
126
+ export?: string;
127
+ schema?: string;
128
+ package?: string;
129
+ };
130
+ purge?: PurgeComponent;
131
+ options?: DocumentComponentOptions<boolean | number>;
132
+ pages?: Record<string, Record<string, unknown>>;
133
+ transform?: {
134
+ html?: Record<string, Record<string, unknown>>;
135
+ css?: Record<string, Record<string, unknown>>;
136
+ js?: Record<string, Record<string, unknown>>;
137
+ };
138
+ view_engine?: Record<string, Record<string, unknown>>;
139
+ export?: Record<string, string | (...args: unknown[]) => unknown>;
140
+ };
141
+ permission?: PermittedDirectories;
142
+ }
143
+ ```
144
+
145
+ ### Example usage
146
+
147
+ ```javascript
148
+ const Document = require("@e-mc/document"); // @pi-r/chrome
149
+
150
+ const assets = [
151
+ { pathname: "output", filename: "image1.png", uri: "http://hostname/path/document1.png" },
152
+ { pathname: "output", filename: "image2.png", uri: "http://hostname/path/document2.png" }
153
+ ];
154
+
155
+ const instance = new Document({
156
+ eval: {
157
+ function: true,
158
+ template: true
159
+ },
160
+ imports: {
161
+ "http://hostname/path/": "build/"
162
+ },
163
+ settings: {
164
+ imports_strict: true,
165
+ users: {
166
+ "nodejs-001": {
167
+ imports_strict: false,
168
+ imports: {
169
+ "http://hostname/path": "build"
170
+ }
171
+ }
172
+ },
173
+ directory: {
174
+ template: "../chrome/template" // ../chrome/template/users/nodejs-001
175
+ }
176
+ }
177
+ });
178
+ // instance.host = new Host();
179
+ instance.init(assets);
180
+ ```
181
+
182
+ NOTE: **@e-mc/document** is an abstract base class and cannot be instantiated. **Document** is more commonly called through [@pi-r/chrome](https://www.npmjs.com/package/@pi-r/chrome).
183
+
184
+ ## References
185
+
186
+ - https://www.unpkg.com/@e-mc/types@0.10.3/lib/squared.d.ts
187
+ - https://www.unpkg.com/@e-mc/types@0.10.3/lib/asset.d.ts
188
+ - https://www.unpkg.com/@e-mc/types@0.10.3/lib/core.d.ts
189
+ - https://www.unpkg.com/@e-mc/types@0.10.3/lib/document.d.ts
190
+ - https://www.unpkg.com/@e-mc/types@0.10.3/lib/filemanager.d.ts
191
+ - https://www.unpkg.com/@e-mc/types@0.10.3/lib/logger.d.ts
192
+ - https://www.unpkg.com/@e-mc/types@0.10.3/lib/settings.d.ts
193
+ - https://www.unpkg.com/@e-mc/types@0.10.3/lib/watch.d.ts
194
+
195
+ ## LICENSE
196
+
197
197
  BSD 3-Clause
package/asset.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import type { ExternalAsset, InitialValue } from '../types/lib/asset';
2
-
3
- declare namespace asset {
4
- function isEqual(item: ExternalAsset, other: ExternalAsset): boolean;
5
- function setInitialValue(file: ExternalAsset, cacheable?: boolean): InitialValue;
6
- }
7
-
1
+ import type { ExternalAsset, InitialValue } from '@e-mc/types/lib/asset';
2
+
3
+ declare namespace asset {
4
+ function isEqual(item: ExternalAsset, other: ExternalAsset): boolean;
5
+ function setInitialValue(file: ExternalAsset, cacheable?: boolean): InitialValue;
6
+ }
7
+
8
8
  export = asset;
package/asset.js CHANGED
@@ -5,5 +5,5 @@ function isEqual(item, other) {
5
5
  return !!(item.id && item.id === other.id || item.uri === other.uri && item.pathname && item.filename && item.pathname === other.pathname && item.filename === other.filename);
6
6
  }
7
7
  function setInitialValue(file, cacheable = true) {
8
- return file.initialValue || (file.initialValue = { pathname: file.pathname, filename: file.filename, mimeType: file.mimeType, localUri: file.localUri, inlineFilename: file.inlineFilename, cacheable });
8
+ return file.initialValue ||= { pathname: file.pathname, filename: file.filename, mimeType: file.mimeType, localUri: file.localUri, inlineFilename: file.inlineFilename, cacheable };
9
9
  }
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import type { DocumentConstructor, IFileManager } from '../types/lib';
2
-
3
- declare const Document: DocumentConstructor<IFileManager>;
4
-
1
+ import type { DocumentConstructor, IFileManager } from '@e-mc/types/lib';
2
+
3
+ declare const Document: DocumentConstructor<IFileManager>;
4
+
5
5
  export = Document;
package/index.js CHANGED
@@ -273,8 +273,7 @@ class TransformConfig {
273
273
  return null;
274
274
  }
275
275
  useETag(cache, etag, uri) {
276
- var _a;
277
- const etagMap = CACHE_ETAG[_a = this.moduleName] || (CACHE_ETAG[_a] = {});
276
+ const etagMap = CACHE_ETAG[this.moduleName] ||= {};
278
277
  const stored = etagMap[uri];
279
278
  cache.formatType = 1;
280
279
  if (stored) {
@@ -290,27 +289,25 @@ class TransformConfig {
290
289
  return [];
291
290
  }
292
291
  useHash(cache, code) {
293
- var _a;
294
292
  let key;
295
293
  if (this.withinLimit(code, cache.encoding) && (key = core_1.Client.asHash(code, this.algorithm, { encoding: cache.encoding }))) {
296
- const hashMap = CACHE_HASH[_a = this.moduleName] || (CACHE_HASH[_a] = {});
294
+ const hashMap = CACHE_HASH[this.moduleName] ||= {};
297
295
  const stored = hashMap[key];
298
296
  let result;
299
- cache.formatType || (cache.formatType = 2);
297
+ cache.formatType ||= 2;
300
298
  cache.hashKey = key;
301
299
  if (stored && (result = cache.get(stored))) {
302
300
  this.resetSession(hashMap, key, stored);
303
- return [result, this.algorithm || (this.algorithm = 'sha256')];
301
+ return [result, this.algorithm ||= 'sha256'];
304
302
  }
305
303
  }
306
304
  return [];
307
305
  }
308
306
  useUri(cache, code, uri) {
309
- var _a;
310
307
  if (this.withinLimit(code, cache.encoding)) {
311
- const codeMap = CACHE_CODE[_a = this.moduleName] || (CACHE_CODE[_a] = {});
308
+ const codeMap = CACHE_CODE[this.moduleName] ||= {};
312
309
  const stored = codeMap[uri];
313
- cache.formatType || (cache.formatType = 3);
310
+ cache.formatType ||= 3;
314
311
  if (stored) {
315
312
  let result;
316
313
  if (stored.code !== code) {
@@ -403,7 +400,7 @@ class Document extends core_1.Client {
403
400
  if (options) {
404
401
  ({ file, sourceRoot, sourceMappingURL, hash, inlineMap, emptySources, mimeType } = options);
405
402
  }
406
- file || (file = path.basename(uri));
403
+ file ||= path.basename(uri);
407
404
  map.file = file;
408
405
  if (sourceRoot) {
409
406
  map.sourceRoot = sourceRoot;
@@ -493,7 +490,7 @@ class Document extends core_1.Client {
493
490
  ++i;
494
491
  }
495
492
  const newline = (0, util_1.getNewline)(source);
496
- ident || (ident = (0, util_1.getIndent)(source));
493
+ ident ||= (0, util_1.getIndent)(source);
497
494
  if (i === length) {
498
495
  const pattern = new RegExp(`\\b(${(0, types_1.escapePattern)(local[1])}` + (local[2] ? `\\(${util_1.PATTERN_PARENTHESIS}\\)` : '\\b' + (local[3] ? '\\s*=\\s*' : '\\s*') + `("[^"]+"|'[^']+'|\\(${util_1.PATTERN_PARENTHESIS}\\)|\\S+)?`) + ')' + (addendum ? '[^\\r\\n]*' : '[^\\w\\r\\n]*'), 'g');
499
496
  pattern.lastIndex = lastIndex;
@@ -617,7 +614,6 @@ class Document extends core_1.Client {
617
614
  }
618
615
  restart() { }
619
616
  init(assets, config) {
620
- var _a;
621
617
  let ignoreModules, ignoreExtensions;
622
618
  if (config) {
623
619
  let baseUrl;
@@ -677,7 +673,7 @@ class Document extends core_1.Client {
677
673
  }
678
674
  }
679
675
  if (this.dataSource.length > 0 && !ignoreModules?.includes('db')) {
680
- const db = (_a = this.module).db || (_a.db = {});
676
+ const db = this.module.db ||= {};
681
677
  const handler = db.handler;
682
678
  const database = this.dataSource.filter(this.forDb.bind(this));
683
679
  let instance;
@@ -732,7 +728,7 @@ class Document extends core_1.Client {
732
728
  }
733
729
  abort(name, reason) {
734
730
  if (name instanceof Error) {
735
- reason || (reason = name);
731
+ reason ||= name;
736
732
  }
737
733
  if (this.aborted || (0, types_1.isString)(name) && this.settingsOf(name, 'abort') !== true) {
738
734
  return;
@@ -742,7 +738,7 @@ class Document extends core_1.Client {
742
738
  customize(options) {
743
739
  const transform = options.transform;
744
740
  if (transform) {
745
- const config = this._transformConfig || (this._transformConfig = new TransformConfig(this.moduleName));
741
+ const config = this._transformConfig ||= new TransformConfig(this.moduleName);
746
742
  if (!config.init(transform)) {
747
743
  this._transformConfig = null;
748
744
  }
@@ -1003,7 +999,7 @@ class Document extends core_1.Client {
1003
999
  if (item.bundleIndex === 0) {
1004
1000
  const localUri = item.localUri;
1005
1001
  try {
1006
- source = fs.readFileSync(localUri, file.encoding || (file.encoding = 'utf-8'));
1002
+ source = fs.readFileSync(localUri, file.encoding ||= 'utf-8');
1007
1003
  if (this.resolveUri && (0, types_1.isArray)(file.trailingContent)) {
1008
1004
  let trailing;
1009
1005
  [source, trailing] = this.resolveUri(file, source, (0, util_1.concatString)(file.trailingContent));
@@ -1131,7 +1127,7 @@ class Document extends core_1.Client {
1131
1127
  }
1132
1128
  }
1133
1129
  const username = this.host?.username || '';
1134
- const cache = CACHE_TEMPLATE[name] || (CACHE_TEMPLATE[name] = {});
1130
+ const cache = CACHE_TEMPLATE[name] ||= {};
1135
1131
  const cacheKey = (username ? username + ':' : '') + (0, types_1.hashKey)(template + (compile ? core_1.Client.asString(compile) : ''));
1136
1132
  let result = '', render = cache[cacheKey], valid;
1137
1133
  if (!render) {
@@ -1151,7 +1147,7 @@ class Document extends core_1.Client {
1151
1147
  for (let i = 0, j = 0; i < length; ++i) {
1152
1148
  let row = data[i];
1153
1149
  if ((0, types_1.isPlainObject)(row)) {
1154
- row.__index__ ?? (row.__index__ = ++j);
1150
+ row.__index__ ??= ++j;
1155
1151
  if (output) {
1156
1152
  row = { ...output, ...row };
1157
1153
  }
@@ -1214,7 +1210,7 @@ class Document extends core_1.Client {
1214
1210
  }
1215
1211
  delete options.cacheData;
1216
1212
  }
1217
- const imports = transform.imports || (transform.imports = {});
1213
+ const imports = transform.imports ||= {};
1218
1214
  const series = new transform_1.TransformSeries(type, code, options);
1219
1215
  series.init(this, __dirname);
1220
1216
  let valid, excluded, userData, userImports, ignoreCache, storedLog, sourceFiles;
@@ -1265,7 +1261,7 @@ class Document extends core_1.Client {
1265
1261
  if (!baseSettings) {
1266
1262
  excluded = isExcluded(type, name, config, cacheData);
1267
1263
  }
1268
- outputConfig || (outputConfig = {});
1264
+ outputConfig ||= {};
1269
1265
  if (plugin && baseConfig) {
1270
1266
  series.outputConfig = outputConfig;
1271
1267
  const source = series.code;
@@ -1306,14 +1302,14 @@ class Document extends core_1.Client {
1306
1302
  out.logAppend.forEach(log => {
1307
1303
  this.addLog(log);
1308
1304
  });
1309
- (storedLog || (storedLog = [])).push(...out.logAppend);
1305
+ (storedLog ||= []).push(...out.logAppend);
1310
1306
  bypassLog = true;
1311
1307
  }
1312
1308
  if ((0, types_1.isArray)(out.logQueued)) {
1313
1309
  out.logQueued.forEach(log => {
1314
1310
  this.writeLog(log, true);
1315
1311
  });
1316
- (storedLog || (storedLog = [])).push(...out.logQueued);
1312
+ (storedLog ||= []).push(...out.logQueued);
1317
1313
  bypassLog = true;
1318
1314
  }
1319
1315
  if (i < length - 1) {