native-document 1.0.278 → 1.0.280
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/devtools/ComponentRegistry.js +10 -4
- package/devtools/nd-vite-devtools.js +14 -7
- package/devtools/src/templates/hrm.hook.template.js +11 -2
- package/devtools/src/transformers/timerSourceCode.js +2 -3
- package/devtools/src/utils.js +0 -2
- package/package.json +1 -1
- package/src/core/data/Observable.hrm.js +0 -1
|
@@ -46,7 +46,7 @@ const ComponentRegistry = (function() {
|
|
|
46
46
|
instance.anchor.setContent(newFactoryInstance);
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
-
const anchor = Anchor(factoryName);
|
|
49
|
+
const anchor = Anchor('Component : '+factoryName);
|
|
50
50
|
const instance = {
|
|
51
51
|
__hrm: true,
|
|
52
52
|
anchor,
|
|
@@ -62,7 +62,9 @@ const ComponentRegistry = (function() {
|
|
|
62
62
|
registryItem.instances.add(instance);
|
|
63
63
|
|
|
64
64
|
attachLocalExtensions(instance, factoryInstance);
|
|
65
|
-
factoryInstance.toNdElement = () =>
|
|
65
|
+
factoryInstance.toNdElement = () => {
|
|
66
|
+
return anchor;
|
|
67
|
+
};
|
|
66
68
|
return factoryInstance;
|
|
67
69
|
};
|
|
68
70
|
};
|
|
@@ -93,6 +95,10 @@ const ComponentRegistry = (function() {
|
|
|
93
95
|
}
|
|
94
96
|
DebugManager.log(`[HMR] Updating ${component.instances.size} instance(s) of ${id}`);
|
|
95
97
|
const oldFactory = component.factory;
|
|
98
|
+
if(typeof newFactory !== 'function') {
|
|
99
|
+
DebugManager.log('[HMR] Updating factory is not a function : ', newFactory);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
96
102
|
component.factory = newFactory;
|
|
97
103
|
component.version++;
|
|
98
104
|
const instances = Array.from(component.instances);
|
|
@@ -124,8 +130,8 @@ const ComponentRegistry = (function() {
|
|
|
124
130
|
if (!timers) {
|
|
125
131
|
return;
|
|
126
132
|
}
|
|
127
|
-
for(const item
|
|
128
|
-
item.cleaner(
|
|
133
|
+
for(const item of timers) {
|
|
134
|
+
item.cleaner();
|
|
129
135
|
}
|
|
130
136
|
},
|
|
131
137
|
};
|
|
@@ -7,6 +7,7 @@ import transformNdForHrm from './src/transformers/transformNdForHrm.js';
|
|
|
7
7
|
export default function NdViteDevtools(options) {
|
|
8
8
|
const {
|
|
9
9
|
include = /\.nd\.js$/,
|
|
10
|
+
includeCustomFile = /\.nd\.js$/,
|
|
10
11
|
preserveState = true,
|
|
11
12
|
} = options;
|
|
12
13
|
|
|
@@ -34,9 +35,13 @@ export default function NdViteDevtools(options) {
|
|
|
34
35
|
return modules.filter(Boolean);
|
|
35
36
|
},
|
|
36
37
|
transform(code, id) {
|
|
37
|
-
if (
|
|
38
|
+
if (include.test(id)) {
|
|
38
39
|
if(isFileMustBeModified(id)) {
|
|
39
|
-
|
|
40
|
+
try {
|
|
41
|
+
return transformForHrm(code, id, { preserveState, ...options});
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error(`[NativeDocument] Transform error in ${id}:`, error);
|
|
44
|
+
}
|
|
40
45
|
}
|
|
41
46
|
return null;
|
|
42
47
|
}
|
|
@@ -44,11 +49,13 @@ export default function NdViteDevtools(options) {
|
|
|
44
49
|
return null;
|
|
45
50
|
}
|
|
46
51
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
if (includeCustomFile.test(id)) {
|
|
53
|
+
try {
|
|
54
|
+
return transformNdForHrm(code, id, { preserveState, ...options });
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error(`[NativeDocument] Transform error in ${id}:`, error);
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
52
59
|
}
|
|
53
60
|
},
|
|
54
61
|
|
|
@@ -23,7 +23,16 @@ if (import.meta.hot) {
|
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
console.log('[HMR Browser] Calling ComponentRegistry.update()');
|
|
27
|
+
try {
|
|
28
|
+
for(const componentId of componentIds) {
|
|
29
|
+
ComponentRegistry.cleanTimer(componentId);
|
|
30
|
+
}
|
|
31
|
+
ComponentRegistry.cleanTimer('${id}')
|
|
32
|
+
console.log('[HMR Browser] ✓ Clean timer successful');
|
|
33
|
+
} catch (error) {
|
|
34
|
+
console.error('[HMR Browser] ✗ Clean timers failed:', error);
|
|
35
|
+
}
|
|
27
36
|
try {
|
|
28
37
|
for(const componentId of componentIds) {
|
|
29
38
|
ComponentRegistry.cleanTimer(componentId);
|
|
@@ -37,7 +46,7 @@ if (import.meta.hot) {
|
|
|
37
46
|
ComponentRegistry.update('${id}', newModule.default, '${id}');
|
|
38
47
|
// console.log('[HMR Browser] ✓ Update successful');
|
|
39
48
|
} catch (error) {
|
|
40
|
-
|
|
49
|
+
console.error('[HMR Browser] ✗ Update failed:', error);
|
|
41
50
|
}
|
|
42
51
|
});
|
|
43
52
|
|
|
@@ -4,7 +4,7 @@ export const timerSourceCode = () => {
|
|
|
4
4
|
|
|
5
5
|
return 'const customSetTimeout = (contextId, targetId, , callback, delay, ...args) => {\n' +
|
|
6
6
|
' const timerId = window.setTimeout(callback, delay, ...args)' +
|
|
7
|
-
' ComponentRegistry.registerTimer(contextId, timerId, clearTimeout);\n' +
|
|
7
|
+
' ComponentRegistry.registerTimer(contextId, timerId, () => clearTimeout(timerId));\n' +
|
|
8
8
|
' return timerId;\n' +
|
|
9
9
|
'};\n' +
|
|
10
10
|
'\n' +
|
|
@@ -12,9 +12,8 @@ export const timerSourceCode = () => {
|
|
|
12
12
|
'\n',
|
|
13
13
|
'\n',
|
|
14
14
|
'const customSetInterval = (contextId, targetId, callback, delay, ...args) => {\n' +
|
|
15
|
-
'console.log({ targetId, callback, delay })\n' +
|
|
16
15
|
' const timerId = window.setInterval(callback, delay, ...args);\n' +
|
|
17
|
-
' ComponentRegistry.registerTimer(contextId, timerId, clearInterval);\n' +
|
|
16
|
+
' ComponentRegistry.registerTimer(contextId, timerId, () => clearInterval(timerId));\n' +
|
|
18
17
|
' return timerId\n' +
|
|
19
18
|
'};\n' +
|
|
20
19
|
'\n' +
|
package/devtools/src/utils.js
CHANGED
|
@@ -7,8 +7,6 @@ import {TRANSFORMED_OBSERVABLE_ID} from '../constantes.js';
|
|
|
7
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
8
8
|
const __dirname = path.dirname(__filename);
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
10
|
export function template(code, params) {
|
|
13
11
|
let codeFormatted = code;
|
|
14
12
|
for(const key in params) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "native-document",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.280",
|
|
4
4
|
"description": "A reactive JavaScript framework that preserves native DOM simplicity without sacrificing modern features",
|
|
5
5
|
"author": "AfroCodeur <https://github.com/afrocodeur>",
|
|
6
6
|
"license": "MIT",
|