@lwrjs/shared-utils 0.8.0-alpha.1 → 0.8.0-alpha.11
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/build/cjs/env.cjs +8 -1
- package/build/cjs/identity.cjs +1 -1
- package/build/cjs/index.cjs +1 -0
- package/build/cjs/logger.cjs +81 -9
- package/build/cjs/lwr-app-observer.cjs +82 -0
- package/build/cjs/tasks.cjs +6 -9
- package/build/cjs/typescript.cjs +1 -0
- package/build/es/env.js +11 -1
- package/build/es/identity.d.ts +1 -1
- package/build/es/identity.js +1 -1
- package/build/es/index.d.ts +1 -0
- package/build/es/index.js +1 -0
- package/build/es/logger.d.ts +16 -2
- package/build/es/logger.js +77 -8
- package/build/es/lwr-app-observer.d.ts +21 -0
- package/build/es/lwr-app-observer.js +55 -0
- package/build/es/tasks.d.ts +3 -4
- package/build/es/tasks.js +7 -16
- package/build/es/typescript.js +1 -0
- package/package.json +5 -4
package/build/cjs/env.cjs
CHANGED
|
@@ -11,7 +11,14 @@ __export(exports, {
|
|
|
11
11
|
getFeatureFlags: () => getFeatureFlags
|
|
12
12
|
});
|
|
13
13
|
function getFeatureFlags() {
|
|
14
|
+
let legacyLoader = process.env.LEGACY_LOADER !== void 0 && process.env.LEGACY_LOADER === "true" ? true : false;
|
|
15
|
+
try {
|
|
16
|
+
if (LWR) {
|
|
17
|
+
legacyLoader = LWR.LEGACY_LOADER;
|
|
18
|
+
}
|
|
19
|
+
} catch (e) {
|
|
20
|
+
}
|
|
14
21
|
return {
|
|
15
|
-
LEGACY_LOADER:
|
|
22
|
+
LEGACY_LOADER: legacyLoader
|
|
16
23
|
};
|
|
17
24
|
}
|
package/build/cjs/identity.cjs
CHANGED
package/build/cjs/index.cjs
CHANGED
|
@@ -34,3 +34,4 @@ __exportStar(exports, __toModule(require("./mappings.cjs")));
|
|
|
34
34
|
__exportStar(exports, __toModule(require("./urls.cjs")));
|
|
35
35
|
__exportStar(exports, __toModule(require("./env.cjs")));
|
|
36
36
|
__exportStar(exports, __toModule(require("./logger.cjs")));
|
|
37
|
+
__exportStar(exports, __toModule(require("./lwr-app-observer.cjs")));
|
package/build/cjs/logger.cjs
CHANGED
|
@@ -24,13 +24,85 @@ var __toModule = (module2) => {
|
|
|
24
24
|
// packages/@lwrjs/shared-utils/src/logger.ts
|
|
25
25
|
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
format: import_winston.default.format.json(),
|
|
35
|
-
transports: [new import_winston.default.transports.Console()]
|
|
27
|
+
DEBUG: () => DEBUG,
|
|
28
|
+
ERROR: () => ERROR,
|
|
29
|
+
INFO: () => INFO,
|
|
30
|
+
VERBOSE: () => VERBOSE,
|
|
31
|
+
WARN: () => WARN,
|
|
32
|
+
logger: () => logger,
|
|
33
|
+
stringifyError: () => stringifyError
|
|
36
34
|
});
|
|
35
|
+
var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
|
|
36
|
+
var VERBOSE = "verbose";
|
|
37
|
+
var DEBUG = "debug";
|
|
38
|
+
var INFO = "info";
|
|
39
|
+
var WARN = "warn";
|
|
40
|
+
var ERROR = "error";
|
|
41
|
+
var currentLevel = process.env.LOG_LEVEL || INFO;
|
|
42
|
+
var log = (level, message, additionalInfo) => {
|
|
43
|
+
const LOG_LEVEL = process.env.LOG_LEVEL || INFO;
|
|
44
|
+
if (currentLevel !== LOG_LEVEL) {
|
|
45
|
+
currentLevel = LOG_LEVEL;
|
|
46
|
+
console.log(`LOG_LEVEL: ${LOG_LEVEL}`);
|
|
47
|
+
}
|
|
48
|
+
let shouldLog = false;
|
|
49
|
+
switch (level) {
|
|
50
|
+
case VERBOSE:
|
|
51
|
+
shouldLog = LOG_LEVEL == VERBOSE;
|
|
52
|
+
break;
|
|
53
|
+
case DEBUG:
|
|
54
|
+
shouldLog = LOG_LEVEL == VERBOSE || LOG_LEVEL == DEBUG;
|
|
55
|
+
break;
|
|
56
|
+
case INFO:
|
|
57
|
+
shouldLog = LOG_LEVEL == VERBOSE || LOG_LEVEL == DEBUG || LOG_LEVEL == INFO;
|
|
58
|
+
break;
|
|
59
|
+
case WARN:
|
|
60
|
+
shouldLog = LOG_LEVEL == VERBOSE || LOG_LEVEL == DEBUG || LOG_LEVEL == INFO || LOG_LEVEL == WARN;
|
|
61
|
+
break;
|
|
62
|
+
case ERROR:
|
|
63
|
+
shouldLog = true;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
if (shouldLog) {
|
|
67
|
+
let logMethod;
|
|
68
|
+
if (level == ERROR) {
|
|
69
|
+
logMethod = console.error;
|
|
70
|
+
} else {
|
|
71
|
+
logMethod = console.log;
|
|
72
|
+
}
|
|
73
|
+
if (additionalInfo) {
|
|
74
|
+
logMethod(`[${level}] : ${message}
|
|
75
|
+
Additional Info: ${JSON.stringify(additionalInfo)}`);
|
|
76
|
+
} else {
|
|
77
|
+
logMethod(`[${level}] : ${message}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
var stringifyError = (error) => {
|
|
82
|
+
if (error instanceof import_diagnostics.DiagnosticsError) {
|
|
83
|
+
return JSON.stringify({
|
|
84
|
+
message: error.message,
|
|
85
|
+
diagnostics: error.diagnostics,
|
|
86
|
+
stack: error.stack
|
|
87
|
+
});
|
|
88
|
+
} else if (typeof error === "string" || error instanceof String) {
|
|
89
|
+
return error;
|
|
90
|
+
} else {
|
|
91
|
+
const propertyNames = Object.getOwnPropertyNames(error);
|
|
92
|
+
const retObj = {};
|
|
93
|
+
for (let property, i = 0, len = propertyNames.length; i < len; ++i) {
|
|
94
|
+
property = propertyNames[i];
|
|
95
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, property);
|
|
96
|
+
retObj[property] = descriptor?.value;
|
|
97
|
+
}
|
|
98
|
+
return JSON.stringify(retObj);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
var logger = {
|
|
102
|
+
verbose: (message, additionalInfo) => log(VERBOSE, message, additionalInfo),
|
|
103
|
+
debug: (message, additionalInfo) => log(DEBUG, message, additionalInfo),
|
|
104
|
+
info: (message, additionalInfo) => log(INFO, message, additionalInfo),
|
|
105
|
+
warn: (message, additionalInfo) => log(WARN, message, additionalInfo),
|
|
106
|
+
error: (error, additionalInfo) => log(ERROR, stringifyError(error), additionalInfo),
|
|
107
|
+
log
|
|
108
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
};
|
|
12
|
+
var __exportStar = (target, module2, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
+
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toModule = (module2) => {
|
|
21
|
+
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// packages/@lwrjs/shared-utils/src/lwr-app-observer.ts
|
|
25
|
+
__markAsModule(exports);
|
|
26
|
+
__export(exports, {
|
|
27
|
+
LwrApplicationObserver: () => LwrApplicationObserver
|
|
28
|
+
});
|
|
29
|
+
var import_events = __toModule(require("events"));
|
|
30
|
+
var MODULE_DEF_CHANGED_EVENT = "module_definition_changed";
|
|
31
|
+
var MODULE_SOURCE_CHANGED_EVENT = "module_source_changed";
|
|
32
|
+
var VIEW_SOURCE_CHANGED_EVENT = "view_source_changed";
|
|
33
|
+
var ASSET_SOURCE_CHANGED_EVENT = "asset_source_changed";
|
|
34
|
+
var LwrEmitter = class {
|
|
35
|
+
constructor(observer) {
|
|
36
|
+
this.observer = observer;
|
|
37
|
+
}
|
|
38
|
+
notifyAssetSourceChanged(payload) {
|
|
39
|
+
this.observer.emit(ASSET_SOURCE_CHANGED_EVENT, {
|
|
40
|
+
eventType: ASSET_SOURCE_CHANGED_EVENT,
|
|
41
|
+
payload
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
notifyViewSourceChanged(payload) {
|
|
45
|
+
this.observer.emit(VIEW_SOURCE_CHANGED_EVENT, {
|
|
46
|
+
eventType: VIEW_SOURCE_CHANGED_EVENT,
|
|
47
|
+
payload
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
notifyModuleDefinitionChanged(payload) {
|
|
51
|
+
this.observer.emit(MODULE_DEF_CHANGED_EVENT, {
|
|
52
|
+
eventType: MODULE_DEF_CHANGED_EVENT,
|
|
53
|
+
payload
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
notifyModuleSourceChanged(payload) {
|
|
57
|
+
this.observer.emit(MODULE_SOURCE_CHANGED_EVENT, {
|
|
58
|
+
eventType: MODULE_SOURCE_CHANGED_EVENT,
|
|
59
|
+
payload
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
var LwrApplicationObserver = class extends import_events.EventEmitter {
|
|
64
|
+
constructor() {
|
|
65
|
+
super();
|
|
66
|
+
}
|
|
67
|
+
onModuleDefinitionChange(listener) {
|
|
68
|
+
this.on(MODULE_DEF_CHANGED_EVENT, listener);
|
|
69
|
+
}
|
|
70
|
+
onModuleSourceChange(listener) {
|
|
71
|
+
this.on(MODULE_SOURCE_CHANGED_EVENT, listener);
|
|
72
|
+
}
|
|
73
|
+
onViewSourceChange(listener) {
|
|
74
|
+
this.on(VIEW_SOURCE_CHANGED_EVENT, listener);
|
|
75
|
+
}
|
|
76
|
+
onAssetSourceChange(listener) {
|
|
77
|
+
this.on(ASSET_SOURCE_CHANGED_EVENT, listener);
|
|
78
|
+
}
|
|
79
|
+
createLwrEmitter() {
|
|
80
|
+
return new LwrEmitter(this);
|
|
81
|
+
}
|
|
82
|
+
};
|
package/build/cjs/tasks.cjs
CHANGED
|
@@ -58,15 +58,12 @@ var InflightTasks = class {
|
|
|
58
58
|
constructor() {
|
|
59
59
|
this.tasks = new Map();
|
|
60
60
|
}
|
|
61
|
-
execute(id,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
this.tasks.delete(id);
|
|
67
|
-
});
|
|
68
|
-
this.tasks.set(id, job);
|
|
69
|
-
return job;
|
|
61
|
+
execute(id, fn) {
|
|
62
|
+
let promise = this.tasks.get(id);
|
|
63
|
+
if (!promise) {
|
|
64
|
+
promise = fn().finally(() => this.tasks.delete(id));
|
|
65
|
+
this.tasks.set(id, promise);
|
|
70
66
|
}
|
|
67
|
+
return promise;
|
|
71
68
|
}
|
|
72
69
|
};
|
package/build/cjs/typescript.cjs
CHANGED
package/build/es/env.js
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
export function getFeatureFlags() {
|
|
2
|
+
let legacyLoader = process.env.LEGACY_LOADER !== undefined && process.env.LEGACY_LOADER === 'true' ? true : false;
|
|
3
|
+
try {
|
|
4
|
+
// Use the Shim for MRT since we don't have access to managing environment variables
|
|
5
|
+
if (LWR) {
|
|
6
|
+
legacyLoader = LWR.LEGACY_LOADER;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
// No shim, ignore error
|
|
11
|
+
}
|
|
2
12
|
return {
|
|
3
13
|
// DEFAULT LEGACY_LOADER = false;
|
|
4
|
-
LEGACY_LOADER:
|
|
14
|
+
LEGACY_LOADER: legacyLoader,
|
|
5
15
|
};
|
|
6
16
|
}
|
|
7
17
|
//# sourceMappingURL=env.js.map
|
package/build/es/identity.d.ts
CHANGED
package/build/es/identity.js
CHANGED
package/build/es/index.d.ts
CHANGED
package/build/es/index.js
CHANGED
package/build/es/logger.d.ts
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const
|
|
1
|
+
declare type LEVEL = 'verbose' | 'debug' | 'info' | 'warn' | 'error';
|
|
2
|
+
export declare const VERBOSE: LEVEL;
|
|
3
|
+
export declare const DEBUG: LEVEL;
|
|
4
|
+
export declare const INFO: LEVEL;
|
|
5
|
+
export declare const WARN: LEVEL;
|
|
6
|
+
export declare const ERROR: LEVEL;
|
|
7
|
+
export declare const stringifyError: (error: any) => string;
|
|
8
|
+
export declare const logger: {
|
|
9
|
+
verbose: (message: string, additionalInfo?: any) => void;
|
|
10
|
+
debug: (message: string, additionalInfo?: any) => void;
|
|
11
|
+
info: (message: string, additionalInfo?: any) => void;
|
|
12
|
+
warn: (message: string, additionalInfo?: any) => void;
|
|
13
|
+
error: (error: any, additionalInfo?: any) => void;
|
|
14
|
+
log: (level: string, message: string, additionalInfo?: any) => void;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
3
17
|
//# sourceMappingURL=logger.d.ts.map
|
package/build/es/logger.js
CHANGED
|
@@ -1,9 +1,78 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { DiagnosticsError } from '@lwrjs/diagnostics';
|
|
2
|
+
export const VERBOSE = 'verbose';
|
|
3
|
+
export const DEBUG = 'debug';
|
|
4
|
+
export const INFO = 'info';
|
|
5
|
+
export const WARN = 'warn';
|
|
6
|
+
export const ERROR = 'error';
|
|
7
|
+
let currentLevel = process.env.LOG_LEVEL || INFO;
|
|
8
|
+
const log = (level, message, additionalInfo) => {
|
|
9
|
+
const LOG_LEVEL = process.env.LOG_LEVEL || INFO;
|
|
10
|
+
if (currentLevel !== LOG_LEVEL) {
|
|
11
|
+
currentLevel = LOG_LEVEL;
|
|
12
|
+
console.log(`LOG_LEVEL: ${LOG_LEVEL}`);
|
|
13
|
+
}
|
|
14
|
+
let shouldLog = false;
|
|
15
|
+
switch (level) {
|
|
16
|
+
case VERBOSE:
|
|
17
|
+
shouldLog = LOG_LEVEL == VERBOSE;
|
|
18
|
+
break;
|
|
19
|
+
case DEBUG:
|
|
20
|
+
shouldLog = LOG_LEVEL == VERBOSE || LOG_LEVEL == DEBUG;
|
|
21
|
+
break;
|
|
22
|
+
case INFO:
|
|
23
|
+
shouldLog = LOG_LEVEL == VERBOSE || LOG_LEVEL == DEBUG || LOG_LEVEL == INFO;
|
|
24
|
+
break;
|
|
25
|
+
case WARN:
|
|
26
|
+
shouldLog = LOG_LEVEL == VERBOSE || LOG_LEVEL == DEBUG || LOG_LEVEL == INFO || LOG_LEVEL == WARN;
|
|
27
|
+
break;
|
|
28
|
+
case ERROR:
|
|
29
|
+
shouldLog = true;
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
if (shouldLog) {
|
|
33
|
+
let logMethod;
|
|
34
|
+
if (level == ERROR) {
|
|
35
|
+
logMethod = console.error;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
logMethod = console.log;
|
|
39
|
+
}
|
|
40
|
+
if (additionalInfo) {
|
|
41
|
+
logMethod(`[${level}] : ${message} \nAdditional Info: ${JSON.stringify(additionalInfo)}`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
logMethod(`[${level}] : ${message}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
export const stringifyError = (error) => {
|
|
49
|
+
if (error instanceof DiagnosticsError) {
|
|
50
|
+
return JSON.stringify({
|
|
51
|
+
message: error.message,
|
|
52
|
+
diagnostics: error.diagnostics,
|
|
53
|
+
stack: error.stack,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else if (typeof error === 'string' || error instanceof String) {
|
|
57
|
+
return error;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const propertyNames = Object.getOwnPropertyNames(error);
|
|
61
|
+
const retObj = {};
|
|
62
|
+
for (let property, i = 0, len = propertyNames.length; i < len; ++i) {
|
|
63
|
+
property = propertyNames[i];
|
|
64
|
+
const descriptor = Object.getOwnPropertyDescriptor(error, property);
|
|
65
|
+
retObj[property] = descriptor?.value;
|
|
66
|
+
}
|
|
67
|
+
return JSON.stringify(retObj);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
export const logger = {
|
|
71
|
+
verbose: (message, additionalInfo) => log(VERBOSE, message, additionalInfo),
|
|
72
|
+
debug: (message, additionalInfo) => log(DEBUG, message, additionalInfo),
|
|
73
|
+
info: (message, additionalInfo) => log(INFO, message, additionalInfo),
|
|
74
|
+
warn: (message, additionalInfo) => log(WARN, message, additionalInfo),
|
|
75
|
+
error: (error, additionalInfo) => log(ERROR, stringifyError(error), additionalInfo),
|
|
76
|
+
log,
|
|
77
|
+
};
|
|
9
78
|
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { ModuleCompiled, LwrAppEmitter, LwrAppObserver, ModuleDefinitionChangedEvent, ModuleSourceChangedEvent, CompiledView, AssetSource, AssetSourceChangedEvent, ViewSourceChangedEvent } from '@lwrjs/types';
|
|
4
|
+
declare class LwrEmitter implements LwrAppEmitter {
|
|
5
|
+
observer: LwrApplicationObserver;
|
|
6
|
+
constructor(observer: LwrApplicationObserver);
|
|
7
|
+
notifyAssetSourceChanged(payload: AssetSource): void;
|
|
8
|
+
notifyViewSourceChanged(payload: CompiledView): void;
|
|
9
|
+
notifyModuleDefinitionChanged(payload: ModuleCompiled): void;
|
|
10
|
+
notifyModuleSourceChanged(payload: ModuleCompiled): void;
|
|
11
|
+
}
|
|
12
|
+
export declare class LwrApplicationObserver extends EventEmitter implements LwrAppObserver {
|
|
13
|
+
constructor();
|
|
14
|
+
onModuleDefinitionChange(listener: (event: ModuleDefinitionChangedEvent) => void): void;
|
|
15
|
+
onModuleSourceChange(listener: (event: ModuleSourceChangedEvent) => void): void;
|
|
16
|
+
onViewSourceChange(listener: (event: ViewSourceChangedEvent) => void): void;
|
|
17
|
+
onAssetSourceChange(listener: (event: AssetSourceChangedEvent) => void): void;
|
|
18
|
+
createLwrEmitter(): LwrEmitter;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=lwr-app-observer.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
const MODULE_DEF_CHANGED_EVENT = 'module_definition_changed';
|
|
3
|
+
const MODULE_SOURCE_CHANGED_EVENT = 'module_source_changed';
|
|
4
|
+
const VIEW_SOURCE_CHANGED_EVENT = 'view_source_changed';
|
|
5
|
+
const ASSET_SOURCE_CHANGED_EVENT = 'asset_source_changed';
|
|
6
|
+
class LwrEmitter {
|
|
7
|
+
constructor(observer) {
|
|
8
|
+
this.observer = observer;
|
|
9
|
+
}
|
|
10
|
+
notifyAssetSourceChanged(payload) {
|
|
11
|
+
this.observer.emit(ASSET_SOURCE_CHANGED_EVENT, {
|
|
12
|
+
eventType: ASSET_SOURCE_CHANGED_EVENT,
|
|
13
|
+
payload,
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
notifyViewSourceChanged(payload) {
|
|
17
|
+
this.observer.emit(VIEW_SOURCE_CHANGED_EVENT, {
|
|
18
|
+
eventType: VIEW_SOURCE_CHANGED_EVENT,
|
|
19
|
+
payload,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
notifyModuleDefinitionChanged(payload) {
|
|
23
|
+
this.observer.emit(MODULE_DEF_CHANGED_EVENT, {
|
|
24
|
+
eventType: MODULE_DEF_CHANGED_EVENT,
|
|
25
|
+
payload,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
notifyModuleSourceChanged(payload) {
|
|
29
|
+
this.observer.emit(MODULE_SOURCE_CHANGED_EVENT, {
|
|
30
|
+
eventType: MODULE_SOURCE_CHANGED_EVENT,
|
|
31
|
+
payload,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class LwrApplicationObserver extends EventEmitter {
|
|
36
|
+
constructor() {
|
|
37
|
+
super();
|
|
38
|
+
}
|
|
39
|
+
onModuleDefinitionChange(listener) {
|
|
40
|
+
this.on(MODULE_DEF_CHANGED_EVENT, listener);
|
|
41
|
+
}
|
|
42
|
+
onModuleSourceChange(listener) {
|
|
43
|
+
this.on(MODULE_SOURCE_CHANGED_EVENT, listener);
|
|
44
|
+
}
|
|
45
|
+
onViewSourceChange(listener) {
|
|
46
|
+
this.on(VIEW_SOURCE_CHANGED_EVENT, listener);
|
|
47
|
+
}
|
|
48
|
+
onAssetSourceChange(listener) {
|
|
49
|
+
this.on(ASSET_SOURCE_CHANGED_EVENT, listener);
|
|
50
|
+
}
|
|
51
|
+
createLwrEmitter() {
|
|
52
|
+
return new LwrEmitter(this);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=lwr-app-observer.js.map
|
package/build/es/tasks.d.ts
CHANGED
|
@@ -23,16 +23,15 @@ export declare class TaskPool {
|
|
|
23
23
|
* Calls to execute with the id of a task in progress returns the running tasks
|
|
24
24
|
* If no task of that id is running a new task is created
|
|
25
25
|
*/
|
|
26
|
-
export declare class InflightTasks<
|
|
26
|
+
export declare class InflightTasks<Value> {
|
|
27
27
|
private tasks;
|
|
28
28
|
/**
|
|
29
29
|
* Return a promise per id. If one is already in flight return the promise.
|
|
30
30
|
* If not use the constructor to create a new
|
|
31
31
|
*
|
|
32
32
|
* @param id - Unique id for promise in question
|
|
33
|
-
* @param
|
|
34
|
-
* @param caller - The closer to use when calling the constructor
|
|
33
|
+
* @param fn - Function that create a promise for the id if needed
|
|
35
34
|
*/
|
|
36
|
-
execute(id: string,
|
|
35
|
+
execute(id: string, fn: () => Promise<Value>): Promise<Value>;
|
|
37
36
|
}
|
|
38
37
|
//# sourceMappingURL=tasks.d.ts.map
|
package/build/es/tasks.js
CHANGED
|
@@ -75,24 +75,15 @@ export class InflightTasks {
|
|
|
75
75
|
* If not use the constructor to create a new
|
|
76
76
|
*
|
|
77
77
|
* @param id - Unique id for promise in question
|
|
78
|
-
* @param
|
|
79
|
-
* @param caller - The closer to use when calling the constructor
|
|
78
|
+
* @param fn - Function that create a promise for the id if needed
|
|
80
79
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
else {
|
|
87
|
-
const job = taskCtor
|
|
88
|
-
.bind(caller || this)()
|
|
89
|
-
.finally(() => {
|
|
90
|
-
// Once fulfilled remove form active jobs
|
|
91
|
-
this.tasks.delete(id);
|
|
92
|
-
});
|
|
93
|
-
this.tasks.set(id, job);
|
|
94
|
-
return job;
|
|
80
|
+
execute(id, fn) {
|
|
81
|
+
let promise = this.tasks.get(id);
|
|
82
|
+
if (!promise) {
|
|
83
|
+
promise = fn().finally(() => this.tasks.delete(id));
|
|
84
|
+
this.tasks.set(id, promise);
|
|
95
85
|
}
|
|
86
|
+
return promise;
|
|
96
87
|
}
|
|
97
88
|
}
|
|
98
89
|
//# sourceMappingURL=tasks.js.map
|
package/build/es/typescript.js
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.8.0-alpha.
|
|
7
|
+
"version": "0.8.0-alpha.11",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -40,17 +40,18 @@
|
|
|
40
40
|
"magic-string": "^0.25.7",
|
|
41
41
|
"mime-types": "^2.1.33",
|
|
42
42
|
"parse5-sax-parser": "^6.0.1",
|
|
43
|
+
"path-to-regexp": "^6.2.0",
|
|
43
44
|
"slugify": "^1.4.5",
|
|
44
45
|
"winston": "^3.7.2"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@lwrjs/diagnostics": "0.8.0-alpha.
|
|
48
|
-
"@lwrjs/types": "0.8.0-alpha.
|
|
48
|
+
"@lwrjs/diagnostics": "0.8.0-alpha.11",
|
|
49
|
+
"@lwrjs/types": "0.8.0-alpha.11",
|
|
49
50
|
"@types/mime-types": "2.1.1",
|
|
50
51
|
"@types/path-to-regexp": "^1.7.0"
|
|
51
52
|
},
|
|
52
53
|
"engines": {
|
|
53
54
|
"node": ">=14.15.4 <19"
|
|
54
55
|
},
|
|
55
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "e8a2c6811e4a52227219f2d94648e0eae9800fbc"
|
|
56
57
|
}
|