@moostjs/vite 0.5.1 → 0.5.2
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/dist/index.cjs +57 -2
- package/dist/index.mjs +58 -3
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -26,6 +26,60 @@ function createAdapterDetector(adapter, onInit) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
function flattenItem(item) {
|
|
30
|
+
return `${item.eventName}||${item.classConstructor.name}||${item.method}`;
|
|
31
|
+
}
|
|
32
|
+
class LogsStorage {
|
|
33
|
+
constructor() {
|
|
34
|
+
this.oldMap = new Map();
|
|
35
|
+
this.newItems = [];
|
|
36
|
+
this.isFirstRun = true;
|
|
37
|
+
}
|
|
38
|
+
startRecording() {
|
|
39
|
+
this.newItems = [];
|
|
40
|
+
}
|
|
41
|
+
record(item) {
|
|
42
|
+
const flat = flattenItem(item);
|
|
43
|
+
this.newItems.push(item);
|
|
44
|
+
return !this.oldMap.has(flat);
|
|
45
|
+
}
|
|
46
|
+
endRecording(logRemovedItem) {
|
|
47
|
+
const newMap = new Map();
|
|
48
|
+
for (const item of this.newItems) {
|
|
49
|
+
const flat = flattenItem(item);
|
|
50
|
+
newMap.set(flat, item);
|
|
51
|
+
}
|
|
52
|
+
for (const [flat, item] of this.oldMap.entries()) {
|
|
53
|
+
if (!newMap.has(flat)) {
|
|
54
|
+
logRemovedItem(item);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
this.oldMap = newMap;
|
|
58
|
+
this.newItems = [];
|
|
59
|
+
this.isFirstRun = false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
let logsStorage;
|
|
63
|
+
function patchMoostHandlerLogging() {
|
|
64
|
+
const origInit = moost.Moost.prototype.init;
|
|
65
|
+
moost.Moost.prototype.init = async function init() {
|
|
66
|
+
if (!logsStorage) {
|
|
67
|
+
logsStorage = new LogsStorage();
|
|
68
|
+
}
|
|
69
|
+
logsStorage.startRecording();
|
|
70
|
+
await origInit.call(this);
|
|
71
|
+
logsStorage.endRecording((item) => {
|
|
72
|
+
origLogMappedHandler.call(this, item.eventName, item.classConstructor, item.method, true, '✖️ ');
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
const origLogMappedHandler = moost.Moost.prototype.logMappedHandler;
|
|
76
|
+
moost.Moost.prototype.logMappedHandler = function logMappedHandler(eventName, classConstructor, method) {
|
|
77
|
+
if (logsStorage.record({ eventName, classConstructor, method })) {
|
|
78
|
+
origLogMappedHandler.call(this, eventName, classConstructor, method, false, logsStorage.isFirstRun ? '' : '➕ ');
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
29
83
|
const PLUGIN_NAME = 'moost-vite-dev';
|
|
30
84
|
function gatherAllImporters(moduleNode, visited = new Set()) {
|
|
31
85
|
if (!moduleNode) {
|
|
@@ -42,7 +96,7 @@ function gatherAllImporters(moduleNode, visited = new Set()) {
|
|
|
42
96
|
}
|
|
43
97
|
return visited;
|
|
44
98
|
}
|
|
45
|
-
const logger = new moost.EventLogger('', { level: 99 }).createTopic(PLUGIN_NAME);
|
|
99
|
+
const logger = new moost.EventLogger('', { level: 99 }).createTopic('[2m' + '[36m' + PLUGIN_NAME);
|
|
46
100
|
function getLogger() {
|
|
47
101
|
return logger;
|
|
48
102
|
}
|
|
@@ -84,7 +138,7 @@ function moostRestartCleanup(adapters, onEject, cleanupInstances) {
|
|
|
84
138
|
infact.registry = registry;
|
|
85
139
|
}
|
|
86
140
|
moost.getMoostMate()._cleanup();
|
|
87
|
-
moost.
|
|
141
|
+
moost.clearGlobalWooks();
|
|
88
142
|
}
|
|
89
143
|
function clearDependantRegistry(registry, onEject) {
|
|
90
144
|
const logger = getLogger();
|
|
@@ -148,6 +202,7 @@ function moostViteDev(options) {
|
|
|
148
202
|
];
|
|
149
203
|
const logger = getLogger();
|
|
150
204
|
let reloadRequired = false;
|
|
205
|
+
patchMoostHandlerLogging();
|
|
151
206
|
return {
|
|
152
207
|
name: PLUGIN_NAME,
|
|
153
208
|
apply: 'serve',
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventLogger, getMoostInfact, getMoostMate,
|
|
1
|
+
import { Moost, EventLogger, getMoostInfact, getMoostMate, clearGlobalWooks } from 'moost';
|
|
2
2
|
|
|
3
3
|
function createAdapterDetector(adapter, onInit) {
|
|
4
4
|
return {
|
|
@@ -24,6 +24,60 @@ function createAdapterDetector(adapter, onInit) {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
function flattenItem(item) {
|
|
28
|
+
return `${item.eventName}||${item.classConstructor.name}||${item.method}`;
|
|
29
|
+
}
|
|
30
|
+
class LogsStorage {
|
|
31
|
+
constructor() {
|
|
32
|
+
this.oldMap = new Map();
|
|
33
|
+
this.newItems = [];
|
|
34
|
+
this.isFirstRun = true;
|
|
35
|
+
}
|
|
36
|
+
startRecording() {
|
|
37
|
+
this.newItems = [];
|
|
38
|
+
}
|
|
39
|
+
record(item) {
|
|
40
|
+
const flat = flattenItem(item);
|
|
41
|
+
this.newItems.push(item);
|
|
42
|
+
return !this.oldMap.has(flat);
|
|
43
|
+
}
|
|
44
|
+
endRecording(logRemovedItem) {
|
|
45
|
+
const newMap = new Map();
|
|
46
|
+
for (const item of this.newItems) {
|
|
47
|
+
const flat = flattenItem(item);
|
|
48
|
+
newMap.set(flat, item);
|
|
49
|
+
}
|
|
50
|
+
for (const [flat, item] of this.oldMap.entries()) {
|
|
51
|
+
if (!newMap.has(flat)) {
|
|
52
|
+
logRemovedItem(item);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
this.oldMap = newMap;
|
|
56
|
+
this.newItems = [];
|
|
57
|
+
this.isFirstRun = false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
let logsStorage;
|
|
61
|
+
function patchMoostHandlerLogging() {
|
|
62
|
+
const origInit = Moost.prototype.init;
|
|
63
|
+
Moost.prototype.init = async function init() {
|
|
64
|
+
if (!logsStorage) {
|
|
65
|
+
logsStorage = new LogsStorage();
|
|
66
|
+
}
|
|
67
|
+
logsStorage.startRecording();
|
|
68
|
+
await origInit.call(this);
|
|
69
|
+
logsStorage.endRecording((item) => {
|
|
70
|
+
origLogMappedHandler.call(this, item.eventName, item.classConstructor, item.method, true, '✖️ ');
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const origLogMappedHandler = Moost.prototype.logMappedHandler;
|
|
74
|
+
Moost.prototype.logMappedHandler = function logMappedHandler(eventName, classConstructor, method) {
|
|
75
|
+
if (logsStorage.record({ eventName, classConstructor, method })) {
|
|
76
|
+
origLogMappedHandler.call(this, eventName, classConstructor, method, false, logsStorage.isFirstRun ? '' : '➕ ');
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
27
81
|
const PLUGIN_NAME = 'moost-vite-dev';
|
|
28
82
|
function gatherAllImporters(moduleNode, visited = new Set()) {
|
|
29
83
|
if (!moduleNode) {
|
|
@@ -40,7 +94,7 @@ function gatherAllImporters(moduleNode, visited = new Set()) {
|
|
|
40
94
|
}
|
|
41
95
|
return visited;
|
|
42
96
|
}
|
|
43
|
-
const logger = new EventLogger('', { level: 99 }).createTopic(PLUGIN_NAME);
|
|
97
|
+
const logger = new EventLogger('', { level: 99 }).createTopic('[2m' + '[36m' + PLUGIN_NAME);
|
|
44
98
|
function getLogger() {
|
|
45
99
|
return logger;
|
|
46
100
|
}
|
|
@@ -82,7 +136,7 @@ function moostRestartCleanup(adapters, onEject, cleanupInstances) {
|
|
|
82
136
|
infact.registry = registry;
|
|
83
137
|
}
|
|
84
138
|
getMoostMate()._cleanup();
|
|
85
|
-
|
|
139
|
+
clearGlobalWooks();
|
|
86
140
|
}
|
|
87
141
|
function clearDependantRegistry(registry, onEject) {
|
|
88
142
|
const logger = getLogger();
|
|
@@ -146,6 +200,7 @@ function moostViteDev(options) {
|
|
|
146
200
|
];
|
|
147
201
|
const logger = getLogger();
|
|
148
202
|
let reloadRequired = false;
|
|
203
|
+
patchMoostHandlerLogging();
|
|
149
204
|
return {
|
|
150
205
|
name: PLUGIN_NAME,
|
|
151
206
|
apply: 'serve',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moostjs/vite",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Vite Dev plugin for moostjs",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/moostjs/moostjs/tree/main/packages/vite#readme",
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"moost": "0.5.
|
|
42
|
-
"@moostjs/event-http": "0.5.
|
|
41
|
+
"moost": "0.5.2",
|
|
42
|
+
"@moostjs/event-http": "0.5.2",
|
|
43
43
|
"vite": "^6.0.5"
|
|
44
44
|
}
|
|
45
45
|
}
|