native-document 1.0.269 → 1.0.271
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 +26 -4
- package/devtools/index.js +1 -3
- package/devtools/{transformers/nd-vite-devtools.js → nd-vite-devtools.js} +13 -9
- package/devtools/src/templates/hrm.hook.template.js +56 -0
- package/devtools/src/transformers/timerSourceCode.js +22 -0
- package/devtools/src/transformers/transformForHrm.js +158 -0
- package/devtools/src/transformers/transformNdForHrm.js +7 -0
- package/devtools/src/utils.js +59 -0
- package/index.hrm.js +22 -0
- package/package.json +1 -1
- package/src/core/data/Observable.hrm.js +58 -0
- package/src/core/data/Observable.js +1 -0
- package/src/core/data/ObservableItem.js +0 -1
- package/types/observable.d.ts +1 -1
- package/devtools/plugin/dev-tools-plugin.js +0 -15
- package/devtools/transformers/src/transformComponentForHrm.js +0 -73
- package/devtools/transformers/src/transformJsFile.js +0 -9
- package/devtools/transformers/src/utils.js +0 -79
- package/devtools/transformers/templates/hrm.hook.template.js +0 -46
- package/devtools/transformers/templates/hrm.orbservable.hook.template.js +0 -76
- package/devtools/widget/Widget.js +0 -49
- package/devtools/widget/widget.css +0 -81
- package/devtools/widget.js +0 -23
|
@@ -4,6 +4,7 @@ import DebugManager from "../src/core/utils/debug-manager";
|
|
|
4
4
|
|
|
5
5
|
const ComponentRegistry = (function() {
|
|
6
6
|
const registry = new Map();
|
|
7
|
+
const timerRegistry = new Map();
|
|
7
8
|
|
|
8
9
|
const attachLocalExtensions = (instance, factoryInstance) => {
|
|
9
10
|
if(!factoryInstance.$localExtensions) {
|
|
@@ -47,12 +48,14 @@ const ComponentRegistry = (function() {
|
|
|
47
48
|
}
|
|
48
49
|
const anchor = Anchor(factoryName);
|
|
49
50
|
const instance = {
|
|
51
|
+
__hrm: true,
|
|
50
52
|
anchor,
|
|
53
|
+
id,
|
|
51
54
|
extensions: null,
|
|
52
55
|
context: {
|
|
53
56
|
args,
|
|
54
57
|
states: new Map()
|
|
55
|
-
}
|
|
58
|
+
},
|
|
56
59
|
};
|
|
57
60
|
const factoryInstance = factory(...args, instance);
|
|
58
61
|
anchor.setContent(factoryInstance);
|
|
@@ -61,7 +64,7 @@ const ComponentRegistry = (function() {
|
|
|
61
64
|
attachLocalExtensions(instance, factoryInstance);
|
|
62
65
|
return anchor;
|
|
63
66
|
};
|
|
64
|
-
}
|
|
67
|
+
};
|
|
65
68
|
|
|
66
69
|
return {
|
|
67
70
|
/**
|
|
@@ -76,12 +79,12 @@ const ComponentRegistry = (function() {
|
|
|
76
79
|
instances: new Set(),
|
|
77
80
|
metadata,
|
|
78
81
|
states: {},
|
|
79
|
-
version: 0
|
|
82
|
+
version: 0,
|
|
80
83
|
});
|
|
81
84
|
}
|
|
82
85
|
return wrapper(id, factory, metadata, registry.get(id));
|
|
83
86
|
},
|
|
84
|
-
update(id, newFactory) {
|
|
87
|
+
update(id, newFactory, globalId) {
|
|
85
88
|
const component = registry.get(id);
|
|
86
89
|
if(!component) {
|
|
87
90
|
DebugManager.warn(`[HMR] Component ${id} not found`);
|
|
@@ -107,6 +110,25 @@ const ComponentRegistry = (function() {
|
|
|
107
110
|
updateInstance(instance, newFactory) {
|
|
108
111
|
return newFactory({ __instance: instance });
|
|
109
112
|
},
|
|
113
|
+
registerTimer(id, timerId, cleaner) {
|
|
114
|
+
const timers = timerRegistry.get(id);
|
|
115
|
+
console.log({ timers, id, cleaner })
|
|
116
|
+
if (!timers) {
|
|
117
|
+
timerRegistry.set(id, [{timerId, cleaner}]);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
timers.push({ timerId, cleaner });
|
|
121
|
+
},
|
|
122
|
+
cleanTimer(id) {
|
|
123
|
+
const timers = timerRegistry.get(id);
|
|
124
|
+
console.log({ timers });
|
|
125
|
+
if (!timers) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
for(const item in timers) {
|
|
129
|
+
item.cleaner(item.timerId);
|
|
130
|
+
}
|
|
131
|
+
},
|
|
110
132
|
};
|
|
111
133
|
}());
|
|
112
134
|
|
package/devtools/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import NdViteDevtools from "./
|
|
2
|
-
import transformComponentForHrm from "./transformers/src/transformComponentForHrm.js";
|
|
1
|
+
import NdViteDevtools from "./nd-vite-devtools.js";
|
|
3
2
|
|
|
4
3
|
export {
|
|
5
|
-
transformComponentForHrm,
|
|
6
4
|
NdViteDevtools,
|
|
7
5
|
};
|
|
8
6
|
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import transformComponentForHrm from "./src/transformComponentForHrm.js";
|
|
2
|
-
import {isFileMustBeModified} from
|
|
3
|
-
import
|
|
1
|
+
// import transformComponentForHrm from "./_old/transformers/src/transformComponentForHrm.js";
|
|
2
|
+
import {isFileMustBeModified} from './src/utils.js';
|
|
3
|
+
import transformForHrm from './src/transformers/transformForHrm.js';
|
|
4
|
+
import transformNdForHrm from './src/transformers/transformNdForHrm.js';
|
|
5
|
+
// import transformJsFile from "./_old/transformers/src/transformJsFile.js";
|
|
4
6
|
|
|
5
7
|
export default function NdViteDevtools(options) {
|
|
6
8
|
const {
|
|
7
9
|
include = /\.nd\.js$/,
|
|
8
|
-
preserveState = true
|
|
10
|
+
preserveState = true,
|
|
9
11
|
} = options;
|
|
10
12
|
|
|
11
13
|
return {
|
|
@@ -25,7 +27,7 @@ export default function NdViteDevtools(options) {
|
|
|
25
27
|
server.ws.send({
|
|
26
28
|
type: 'nd-hmr-file',
|
|
27
29
|
event: 'nd:update',
|
|
28
|
-
data: { file, msg: 'The content has changed' }
|
|
30
|
+
data: { file, msg: 'The content has changed' },
|
|
29
31
|
});
|
|
30
32
|
|
|
31
33
|
// We will manage all manually
|
|
@@ -34,14 +36,16 @@ export default function NdViteDevtools(options) {
|
|
|
34
36
|
transform(code, id) {
|
|
35
37
|
if (!include.test(id)) {
|
|
36
38
|
if(isFileMustBeModified(id)) {
|
|
37
|
-
return
|
|
39
|
+
return transformForHrm(code, id, { preserveState, ...options});
|
|
38
40
|
}
|
|
39
41
|
return null;
|
|
40
42
|
}
|
|
41
|
-
if (id.includes('node_modules'))
|
|
43
|
+
if (id.includes('node_modules')) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
42
46
|
|
|
43
47
|
try {
|
|
44
|
-
return
|
|
48
|
+
return transformNdForHrm(code, id, { preserveState, ...options });
|
|
45
49
|
} catch (error) {
|
|
46
50
|
console.error(`[NativeDocument] Transform error in ${id}:`, error);
|
|
47
51
|
return null;
|
|
@@ -50,6 +54,6 @@ export default function NdViteDevtools(options) {
|
|
|
50
54
|
|
|
51
55
|
configResolved() {
|
|
52
56
|
console.log('[NativeDocument] HMR Plugin loaded ✓');
|
|
53
|
-
}
|
|
57
|
+
},
|
|
54
58
|
};
|
|
55
59
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
if (import.meta.hot) {
|
|
3
|
+
const componentIds = ${componentIds};
|
|
4
|
+
import.meta.hot.accept((newModule) => {
|
|
5
|
+
// console.log('[HMR Browser] Update accepted for ${id}');
|
|
6
|
+
|
|
7
|
+
if (!newModule) {
|
|
8
|
+
// console.error('[HMR Browser] newModule is undefined!');
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
if (typeof window === 'undefined') {
|
|
14
|
+
// console.error('[HMR Browser] window is undefined!');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (!ComponentRegistry) {
|
|
22
|
+
// console.error('[HMR Browser] ComponentRegistry not found!');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
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
|
+
|
|
33
|
+
for(const componentId of componentIds) {
|
|
34
|
+
// console.log('[HMR Browser] ComponentId : '+componentId);
|
|
35
|
+
ComponentRegistry.update(componentId, newModule.default, '${id}');
|
|
36
|
+
}
|
|
37
|
+
ComponentRegistry.update('${id}', newModule.default, '${id}');
|
|
38
|
+
// console.log('[HMR Browser] ✓ Update successful');
|
|
39
|
+
} catch (error) {
|
|
40
|
+
// console.error('[HMR Browser] ✗ Update failed:', error);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
import.meta.hot.on('vite:error', (payload) => {
|
|
45
|
+
console.error('[HMR Browser] Vite error:', payload);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
import.meta.hot.on('nd:update', (payload) => {
|
|
50
|
+
console.error('[HMR Browser] ND:Update:', payload);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
import.meta.hot.dispose(() => {
|
|
54
|
+
console.log('[HMR Browser] Disposing ${id}');
|
|
55
|
+
});
|
|
56
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
export const timerSourceCode = () => {
|
|
4
|
+
|
|
5
|
+
return 'const customSetTimeout = (contextId, targetId, , callback, delay, ...args) => {\n' +
|
|
6
|
+
' const timerId = window.setTimeout(callback, delay, ...args)' +
|
|
7
|
+
' ComponentRegistry.registerTimer(contextId, timerId, clearTimeout);\n' +
|
|
8
|
+
' return timerId;\n' +
|
|
9
|
+
'};\n' +
|
|
10
|
+
'\n' +
|
|
11
|
+
'const setTimeout = customSetTimeout;',
|
|
12
|
+
'\n',
|
|
13
|
+
'\n',
|
|
14
|
+
'const customSetInterval = (contextId, targetId, callback, delay, ...args) => {\n' +
|
|
15
|
+
'console.log({ targetId, callback, delay })\n' +
|
|
16
|
+
' const timerId = window.setInterval(callback, delay, ...args);\n' +
|
|
17
|
+
' ComponentRegistry.registerTimer(contextId, timerId, clearInterval);\n' +
|
|
18
|
+
' return timerId\n' +
|
|
19
|
+
'};\n' +
|
|
20
|
+
'\n' +
|
|
21
|
+
'const setInterval = customSetInterval;';
|
|
22
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import {template, transformObservableDeclarations, transformObservableImports} from '../utils.js';
|
|
2
|
+
import { parse } from '@babel/parser';
|
|
3
|
+
import { default as traverse } from '@babel/traverse';
|
|
4
|
+
import generate from '@babel/generator';
|
|
5
|
+
import * as t from '@babel/types';
|
|
6
|
+
import fs from 'node:fs';
|
|
7
|
+
import {fileURLToPath} from 'node:url';
|
|
8
|
+
import path from 'node:path';
|
|
9
|
+
import {timerSourceCode} from './timerSourceCode.js';
|
|
10
|
+
|
|
11
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
12
|
+
const __dirname = path.dirname(__filename);
|
|
13
|
+
|
|
14
|
+
export default function transformForHrm(code, id, options = {}) {
|
|
15
|
+
|
|
16
|
+
let output = transformObservableImports(code);
|
|
17
|
+
output = transformObservableDeclarations(output, id);
|
|
18
|
+
|
|
19
|
+
const hrmHookTemplate = fs.readFileSync(__dirname + '/../templates/hrm.hook.template.js', 'utf8');
|
|
20
|
+
|
|
21
|
+
const codeParsed = parse(output, {
|
|
22
|
+
sourceType: 'module',
|
|
23
|
+
plugins: [],
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const componentIds = [];
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
traverse.default(codeParsed, {
|
|
30
|
+
FunctionDeclaration(path) {
|
|
31
|
+
if(!path.node.id || path.node.__isWrapped) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const fnName = path.node.id.name;
|
|
35
|
+
if(!/^[A-Z]/.test(fnName)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const componentId = `${id}::${fnName}`;
|
|
39
|
+
componentIds.push(componentId);
|
|
40
|
+
|
|
41
|
+
const wrappedCall = t.callExpression(
|
|
42
|
+
t.memberExpression(
|
|
43
|
+
t.identifier('ComponentRegistry'),
|
|
44
|
+
t.identifier('register')
|
|
45
|
+
),
|
|
46
|
+
[
|
|
47
|
+
t.stringLiteral(componentId),
|
|
48
|
+
t.functionExpression(
|
|
49
|
+
t.identifier(fnName),
|
|
50
|
+
path.node.params,
|
|
51
|
+
path.node.body,
|
|
52
|
+
),
|
|
53
|
+
]
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
// Cas — export default function HomePage() {}
|
|
57
|
+
if(path.parent.type === 'ExportDefaultDeclaration') {
|
|
58
|
+
// Remplacer uniquement la déclaration par l'expression wrappée
|
|
59
|
+
path.replaceWith(wrappedCall);
|
|
60
|
+
path.skip();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Cas — function HomePage() {}
|
|
65
|
+
const varDeclaration = t.variableDeclaration('const', [
|
|
66
|
+
t.variableDeclarator(t.identifier(fnName), wrappedCall),
|
|
67
|
+
]);
|
|
68
|
+
|
|
69
|
+
path.replaceWith(varDeclaration);
|
|
70
|
+
// path.skip();
|
|
71
|
+
},
|
|
72
|
+
VariableDeclarator(path) {
|
|
73
|
+
const init = path.node.init;
|
|
74
|
+
const isFunction = init && (init.type === 'ArrowFunctionExpression' || init.type === 'FunctionExpression');
|
|
75
|
+
|
|
76
|
+
if (!(isFunction && path.node.id.type === 'Identifier')) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const fnName = path.node.id.name;
|
|
80
|
+
const isComponent = /^[A-Z]/.test(fnName);
|
|
81
|
+
if (!isComponent) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if(init.__isWrapped) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const componentId = `${id}::${fnName}`;
|
|
88
|
+
componentIds.push(componentId);
|
|
89
|
+
|
|
90
|
+
const wrappedCall = t.callExpression(
|
|
91
|
+
t.memberExpression(
|
|
92
|
+
t.identifier('ComponentRegistry'),
|
|
93
|
+
t.identifier('register')
|
|
94
|
+
),
|
|
95
|
+
[
|
|
96
|
+
t.stringLiteral(componentId),
|
|
97
|
+
init,
|
|
98
|
+
],
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
wrappedCall.__isWrapped = true;
|
|
102
|
+
path.node.init = wrappedCall;
|
|
103
|
+
// path.skip();
|
|
104
|
+
},
|
|
105
|
+
CallExpression(path) {
|
|
106
|
+
const callee = path.node.callee;
|
|
107
|
+
|
|
108
|
+
if (t.isIdentifier(callee) && ['setInterval', 'setTimeout'].includes(callee.name)) {
|
|
109
|
+
if (path.node.__timerInjected) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const parentFn = path.findParent((p) => p.isFunctionDeclaration() || p.isVariableDeclarator());
|
|
113
|
+
let scopeName = 'global';
|
|
114
|
+
|
|
115
|
+
if (parentFn) {
|
|
116
|
+
if (parentFn.isFunctionDeclaration() && parentFn.node.id) {
|
|
117
|
+
scopeName = parentFn.node.id.name;
|
|
118
|
+
} else if (parentFn.isVariableDeclarator() && parentFn.node.id.type === 'Identifier') {
|
|
119
|
+
scopeName = parentFn.node.id.name;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
const contextId = `${id}::${scopeName}`;
|
|
125
|
+
const timerContextId = `${id}::${scopeName}`;
|
|
126
|
+
// if (path.parent.type === 'VariableDeclarator' && path.parent.id.type === 'Identifier') {
|
|
127
|
+
// timerContextId += '::'+path.parent.id.name;
|
|
128
|
+
// }
|
|
129
|
+
|
|
130
|
+
path.node.arguments.unshift(
|
|
131
|
+
t.stringLiteral(timerContextId),
|
|
132
|
+
t.stringLiteral(contextId),
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
path.node.__timerInjected = true;
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const { code: transformedCode } = generate.default(codeParsed);
|
|
141
|
+
const hrmHookTemplateFormatted = template(hrmHookTemplate, {
|
|
142
|
+
id,
|
|
143
|
+
componentIds: JSON.stringify(componentIds),
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
const timerCodeFormatted = template(timerSourceCode(), {
|
|
147
|
+
id,
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
return [
|
|
151
|
+
'import ComponentRegistry from \'native-document/devtools/ComponentRegistry\'',
|
|
152
|
+
transformedCode,
|
|
153
|
+
'\n',
|
|
154
|
+
hrmHookTemplateFormatted,
|
|
155
|
+
timerCodeFormatted,
|
|
156
|
+
// `console.log('${id}', 'Code injectable', ${JSON.stringify(options, null, 2)});`,
|
|
157
|
+
].join(";");
|
|
158
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
|
|
9
|
+
export function template(code, params) {
|
|
10
|
+
let codeFormatted = code;
|
|
11
|
+
for(const key in params) {
|
|
12
|
+
codeFormatted = codeFormatted.replace(new RegExp("\\$\{"+key+"}", 'ig'), params[key]);
|
|
13
|
+
}
|
|
14
|
+
return codeFormatted;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function renameImportedObservables(content, match) {
|
|
18
|
+
let isObservableFound = false;
|
|
19
|
+
match.split(',').map(item => {
|
|
20
|
+
const trimmed = item.trim();
|
|
21
|
+
|
|
22
|
+
if (trimmed === 'Observable') {
|
|
23
|
+
isObservableFound = true;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (trimmed === '$') {
|
|
27
|
+
isObservableFound = true;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
if(isObservableFound) {
|
|
31
|
+
return `import {${match} } from 'native-document/index.hrm'`;
|
|
32
|
+
}
|
|
33
|
+
return content;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function transformObservableImports(code, params = {}) {
|
|
37
|
+
return code.replace(/import\s+\{([^}]+?)\}\s+from\s+['"]native-document['"]/g, renameImportedObservables);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function transformObservableDeclarations(code, id) {
|
|
41
|
+
const regex = /(const|let|var)\s+([\w$]+)\s*=\s*(\$|Observable)(\.(?:init|array|json|ref|resource|object))?\s*\(/g;
|
|
42
|
+
|
|
43
|
+
return code.replace(regex, (match, varType, varName, caller, method) => {
|
|
44
|
+
const obsName = method ? `${caller}${method}` : caller;
|
|
45
|
+
return `${varType} ${varName} = ${obsName}('${varName}', '${id}', (typeof arguments !== 'undefined') ? Array.from(arguments).at(-1) : null, `;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function isFileMustBeModified(file) {
|
|
50
|
+
if(!/labs\/live\/src/.test(file)) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
54
|
+
const isContainObservableImport = /import\s+\{([^}]+?)\}\s+from\s+['"]native-document['"]/g.test(content);
|
|
55
|
+
if(isContainObservableImport) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
return /(const|let|var)\s+([\w$]+)\s*=\s*(\$|Observable)(\.(?:init|array|json|ref|resource|object))?\s*\(/g.test(content);
|
|
59
|
+
}
|
package/index.hrm.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { default as HtmlElementWrapper, createTextNode } from './src/core/wrappers/HtmlElementWrapper';
|
|
2
|
+
export { ElementCreator } from './src/core/wrappers/ElementCreator';
|
|
3
|
+
export { NDElement } from './src/core/wrappers/NDElement';
|
|
4
|
+
export { TemplateCloner, useCache } from './src/core/wrappers/template-cloner/TemplateCloner';
|
|
5
|
+
export { SingletonView, useSingleton } from './src/core/wrappers/SingletonView';
|
|
6
|
+
export { default as PluginsManager } from './src/core/utils/plugins-manager';
|
|
7
|
+
export { default as Validator } from './src/core/utils/validator';
|
|
8
|
+
|
|
9
|
+
export { Formatters } from './src/core/utils/formatters';
|
|
10
|
+
export {default as ShortcutManager} from './src/core/utils/shortcut-manager';
|
|
11
|
+
|
|
12
|
+
export * from './src/core/utils/property-accumulator';
|
|
13
|
+
export * from './src/core/utils/args-types';
|
|
14
|
+
export * from './src/core/utils/memoize';
|
|
15
|
+
export * from './src/core/data/Observable.hrm';
|
|
16
|
+
export * from './src/core/data/Store';
|
|
17
|
+
|
|
18
|
+
import * as elements from './elements';
|
|
19
|
+
import * as router from './router';
|
|
20
|
+
import * as utils from './utils';
|
|
21
|
+
|
|
22
|
+
export { elements, router, utils };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "native-document",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.271",
|
|
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",
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {Observable as ObservableOriginal} from './Observable';
|
|
2
|
+
|
|
3
|
+
const HrmGlobakObservableRegistry = new Map();
|
|
4
|
+
|
|
5
|
+
const overrideMethods = ['array', 'init', 'object', 'json', 'ref', 'resource'];
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const override = (callback) => {
|
|
9
|
+
return function(name, id, scope, value, configs = null) {
|
|
10
|
+
if(!scope?.__hrm) {
|
|
11
|
+
scope = null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if(scope === null) {
|
|
15
|
+
const fullId = id+':'+name;
|
|
16
|
+
const existing = HrmGlobakObservableRegistry.get(fullId);
|
|
17
|
+
if(existing) {
|
|
18
|
+
if(existing.value !== value) {
|
|
19
|
+
existing.value = value;
|
|
20
|
+
existing.observable.set(value);
|
|
21
|
+
}
|
|
22
|
+
return existing.observable;
|
|
23
|
+
}
|
|
24
|
+
const observable = callback(value, configs);
|
|
25
|
+
HrmGlobakObservableRegistry.set(fullId, {
|
|
26
|
+
value,
|
|
27
|
+
observable
|
|
28
|
+
});
|
|
29
|
+
return observable;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if(scope.context.states.has(name)) {
|
|
33
|
+
const item = scope.context.states.get(name);
|
|
34
|
+
if(item.value !== value) {
|
|
35
|
+
item.value = value;
|
|
36
|
+
item.observable.set(value);
|
|
37
|
+
}
|
|
38
|
+
return item.observable;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const observable = callback(value, configs);
|
|
42
|
+
scope.context.states.set(name, {
|
|
43
|
+
observable,
|
|
44
|
+
value,
|
|
45
|
+
});
|
|
46
|
+
return observable;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const Observable = override(ObservableOriginal);
|
|
51
|
+
|
|
52
|
+
export const $ = Observable;
|
|
53
|
+
|
|
54
|
+
overrideMethods.forEach(method => {
|
|
55
|
+
|
|
56
|
+
Observable[method] = override(ObservableOriginal[method]);
|
|
57
|
+
|
|
58
|
+
});
|
|
@@ -5,7 +5,6 @@ import PluginsManager from '../../core/utils/plugins-manager';
|
|
|
5
5
|
import Validator from '../../core/utils/validator';
|
|
6
6
|
import {deepClone} from '../utils/helpers';
|
|
7
7
|
import {$getFromStorage, $saveToStorage} from '../utils/localstorage';
|
|
8
|
-
import {value} from 'happy-dom/lib/PropertySymbol';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Reactive primitive value container.
|
package/types/observable.d.ts
CHANGED
|
@@ -264,7 +264,7 @@ export type ObservableObject<T extends Record<string, any>> = ObservableItem<T>
|
|
|
264
264
|
$updateWith(values: Partial<T>): void;
|
|
265
265
|
update(values: Partial<T>): void;
|
|
266
266
|
reset(): void;
|
|
267
|
-
setOrReset(): void;
|
|
267
|
+
setOrReset(value: any): void;
|
|
268
268
|
clone(): ObservableObject<T>;
|
|
269
269
|
$clone(): ObservableObject<T>;
|
|
270
270
|
keys(): string[];
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import {Observable} from "../../src/core/data/Observable";
|
|
2
|
-
|
|
3
|
-
export const DevToolService = {
|
|
4
|
-
createdObservable: Observable(0),
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export const DevToolsPlugin = {
|
|
9
|
-
$name: 'DevTools',
|
|
10
|
-
name: 'DevTools',
|
|
11
|
-
onCreateObservable(observable) {
|
|
12
|
-
DevToolService.createdObservable.set((last) => ++last);
|
|
13
|
-
// console.log('Création Capturé', observable.$value);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import MagicString from 'magic-string';
|
|
4
|
-
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
6
|
-
import { parse } from '@babel/parser';
|
|
7
|
-
import { default as traverse } from '@babel/traverse';
|
|
8
|
-
|
|
9
|
-
import { transformObservableImports, transformObservableDeclarations, template } from './utils.js';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
13
|
-
const __dirname = path.dirname(__filename);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export default function transformComponentForHrm(id, code, options) {
|
|
17
|
-
let hasDefaultExport = false;
|
|
18
|
-
let componentName = null;
|
|
19
|
-
let exportStart = 0;
|
|
20
|
-
let exportEnd = 0;
|
|
21
|
-
// TODO: move this line outside the function
|
|
22
|
-
const hrmHookTemplate = fs.readFileSync(__dirname + '/../templates/hrm.hook.template.js', 'utf8');
|
|
23
|
-
const formattedCode = transformObservableDeclarations(
|
|
24
|
-
transformObservableImports(code, { id, ...options }),
|
|
25
|
-
);
|
|
26
|
-
const s = new MagicString(formattedCode);
|
|
27
|
-
const codeParsed = parse(formattedCode, {
|
|
28
|
-
sourceType: 'module',
|
|
29
|
-
plugins: []
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
traverse.default(codeParsed, {
|
|
33
|
-
ExportDefaultDeclaration(path) {
|
|
34
|
-
hasDefaultExport = true;
|
|
35
|
-
const declaration = path.node.declaration;
|
|
36
|
-
|
|
37
|
-
if (declaration.id) {
|
|
38
|
-
componentName = declaration.id.name;
|
|
39
|
-
} else if (declaration.type === 'Identifier') {
|
|
40
|
-
componentName = declaration.name;
|
|
41
|
-
} else {
|
|
42
|
-
componentName = 'AnonymousComponent';
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
exportStart = path.node.start;
|
|
46
|
-
exportEnd = path.node.end;
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
if (!hasDefaultExport) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const originalExport = formattedCode.slice(exportStart, exportEnd);
|
|
54
|
-
const hrmComponentName = `__HRM_${componentName}__`;
|
|
55
|
-
const newExport = originalExport.replace(
|
|
56
|
-
'export default',
|
|
57
|
-
`const ${hrmComponentName} =`
|
|
58
|
-
);
|
|
59
|
-
s.overwrite(exportStart, exportEnd, newExport);
|
|
60
|
-
|
|
61
|
-
const hrmHookTemplateFormatted = template(hrmHookTemplate, {
|
|
62
|
-
id
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
s.prepend('import ComponentRegistry from "native-document/devtools/ComponentRegistry";');
|
|
66
|
-
s.append(`export default ComponentRegistry.register('${id}', ${hrmComponentName}, { preserveState: ${options.preserveState} });`);
|
|
67
|
-
s.append(hrmHookTemplateFormatted);
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
code: s.toString(),
|
|
71
|
-
map: s.generateMap({ source: id, hires: true })
|
|
72
|
-
};
|
|
73
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import MagicString from 'magic-string';
|
|
4
|
-
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
6
|
-
|
|
7
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
-
const __dirname = path.dirname(__filename);
|
|
9
|
-
|
|
10
|
-
export function template(code, params) {
|
|
11
|
-
let codeFormatted = code;
|
|
12
|
-
for(const key in params) {
|
|
13
|
-
codeFormatted = codeFormatted.replace(new RegExp("\\$\{"+key+"}", 'ig'), params[key]);
|
|
14
|
-
}
|
|
15
|
-
return codeFormatted;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function renameImportedObservables(content, match) {
|
|
19
|
-
let isObservableFound = false;
|
|
20
|
-
let isObservableShortFound = false;
|
|
21
|
-
const transformedContentArray = match.split(',').map(item => {
|
|
22
|
-
let trimmed = item.trim();
|
|
23
|
-
|
|
24
|
-
if (trimmed === 'Observable') {
|
|
25
|
-
isObservableFound = true;
|
|
26
|
-
return 'Observable as __OriginalObservable__';
|
|
27
|
-
}
|
|
28
|
-
if (trimmed === '$') {
|
|
29
|
-
isObservableShortFound = true;
|
|
30
|
-
return '$ as __$__';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return ` ${trimmed}`;
|
|
34
|
-
});
|
|
35
|
-
if(!isObservableFound && isObservableShortFound) {
|
|
36
|
-
transformedContentArray.push('Observable as __OriginalObservable__')
|
|
37
|
-
}
|
|
38
|
-
const transformedContent = transformedContentArray.join(', ');
|
|
39
|
-
|
|
40
|
-
return `import {${transformedContent} } from 'native-document'`;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function transformObservableImports(code, params) {
|
|
44
|
-
const renameImportationCode = code.replace(/import\s+\{([^}]+?)\}\s+from\s+['"]native-document['"]/g, renameImportedObservables);
|
|
45
|
-
const isRenamed = renameImportationCode !== code;
|
|
46
|
-
|
|
47
|
-
const s = new MagicString(renameImportationCode);
|
|
48
|
-
if(isRenamed) {
|
|
49
|
-
//Todo: move this code outside the function
|
|
50
|
-
const hrmObservableHookTemplate = fs.readFileSync(__dirname + '/../templates/hrm.orbservable.hook.template.js', 'utf8');
|
|
51
|
-
s.append(template(
|
|
52
|
-
hrmObservableHookTemplate,
|
|
53
|
-
params ?? {}
|
|
54
|
-
));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return s.toString();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function transformObservableDeclarations(code) {
|
|
61
|
-
const regex = /(const|let|var)\s+([\w$]+)\s*=\s*(\$|Observable)(\.(?:init|array|json))?\s*\(/g;
|
|
62
|
-
|
|
63
|
-
return code.replace(regex, (match, varType, varName, caller, method) => {
|
|
64
|
-
const obsName = method ? `${caller}${method}` : 'Observable';
|
|
65
|
-
return `${varType} ${varName} = ${obsName}('${varName}', arguments[arguments.length - 1], `;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function isFileMustBeModified(file) {
|
|
70
|
-
if(!/labs\/live\/src/.test(file)) {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
const content = fs.readFileSync(file, 'utf-8');
|
|
74
|
-
const isContainObservableImport = /import\s+\{([^}]+?)\}\s+from\s+['"]native-document['"]/g.test(content);
|
|
75
|
-
if(isContainObservableImport) {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
return /(const|let|var)\s+([\w$]+)\s*=\s*(\$|Observable)(\.(?:init|array|json))?\s*\(/g.test(content);
|
|
79
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
if (import.meta.hot) {
|
|
3
|
-
import.meta.hot.accept((newModule) => {
|
|
4
|
-
console.log('[HMR Browser] Update accepted for ${id}');
|
|
5
|
-
|
|
6
|
-
if (!newModule) {
|
|
7
|
-
console.error('[HMR Browser] newModule is undefined!');
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
if (typeof window === 'undefined') {
|
|
13
|
-
console.error('[HMR Browser] window is undefined!');
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
} catch (e) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (!ComponentRegistry) {
|
|
21
|
-
console.error('[HMR Browser] ComponentRegistry not found!');
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
console.log('[HMR Browser] Calling ComponentRegistry.update()');
|
|
26
|
-
try {
|
|
27
|
-
ComponentRegistry.update('${id}', newModule.default);
|
|
28
|
-
console.log('[HMR Browser] ✓ Update successful');
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.error('[HMR Browser] ✗ Update failed:', error);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
import.meta.hot.on('vite:error', (payload) => {
|
|
35
|
-
console.error('[HMR Browser] Vite error:', payload);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
import.meta.hot.on('nd:update', (payload) => {
|
|
40
|
-
console.error('[HMR Browser] ND:Update:', payload);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
import.meta.hot.dispose(() => {
|
|
44
|
-
console.log('[HMR Browser] Disposing ${id}');
|
|
45
|
-
});
|
|
46
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
function Observable(name, instance, value, ...args) {
|
|
3
|
-
if(value === undefined) {
|
|
4
|
-
value = name;
|
|
5
|
-
name = 'unknown';
|
|
6
|
-
}
|
|
7
|
-
if(!instance?.context) {
|
|
8
|
-
return __OriginalObservable__(value, ...args);
|
|
9
|
-
}
|
|
10
|
-
if(instance.context.states.has(name)) {
|
|
11
|
-
const item = instance.context.states.get(name);
|
|
12
|
-
if(item.value !== value) {
|
|
13
|
-
item.value = value;
|
|
14
|
-
item.observable.set(value);
|
|
15
|
-
}
|
|
16
|
-
return item.observable;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const observable = __OriginalObservable__(value, ...args);
|
|
20
|
-
instance.context.states.set(name, {
|
|
21
|
-
observable,
|
|
22
|
-
value
|
|
23
|
-
});
|
|
24
|
-
return observable;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
Observable.init = function(name, instance, value, ...args) {
|
|
28
|
-
if(value === undefined) {
|
|
29
|
-
value = name;
|
|
30
|
-
name = 'unknown';
|
|
31
|
-
}
|
|
32
|
-
if(!instance?.context) {
|
|
33
|
-
return __OriginalObservable__.init(value, ...args);
|
|
34
|
-
}
|
|
35
|
-
if(instance.context.states.has(name)) {
|
|
36
|
-
const item = instance.context.states.get(name);
|
|
37
|
-
|
|
38
|
-
if(item.value !== JSON.stringify(value)) {
|
|
39
|
-
item.value = value;
|
|
40
|
-
item.observable.set(value);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return item.observable;
|
|
44
|
-
}
|
|
45
|
-
const item = __OriginalObservable__.init(value, ...args);
|
|
46
|
-
instance.context.states.set(name, {
|
|
47
|
-
item,
|
|
48
|
-
value: JSON.stringify(value)
|
|
49
|
-
});
|
|
50
|
-
return item;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
Observable.array = function(name, instance, value, ...args) {
|
|
54
|
-
if(!instance?.context) {
|
|
55
|
-
return __OriginalObservable__.array(value, ...args);
|
|
56
|
-
}
|
|
57
|
-
if(instance.context.states.has(name)) {
|
|
58
|
-
const item = instance.context.states.get(name);
|
|
59
|
-
if(item.value !== JSON.stringify(value)) {
|
|
60
|
-
item.value = value;
|
|
61
|
-
item.observable.set(value);
|
|
62
|
-
}
|
|
63
|
-
return item.observable;
|
|
64
|
-
}
|
|
65
|
-
const item = __OriginalObservable__.array(value, ...args);
|
|
66
|
-
instance.context.states.set(name, {
|
|
67
|
-
item,
|
|
68
|
-
value: JSON.stringify(value)
|
|
69
|
-
});
|
|
70
|
-
return item;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
Observable.object = __OriginalObservable__.init;
|
|
74
|
-
Observable.json = __OriginalObservable__.init;
|
|
75
|
-
Observable.computed = __OriginalObservable__.computed;
|
|
76
|
-
const $ = Observable;
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {Observable} from "../../src/core/data/Observable";
|
|
2
|
-
import {Button, Div, ShowIf, Switch} from "../../elements";
|
|
3
|
-
|
|
4
|
-
import './widget.css';
|
|
5
|
-
|
|
6
|
-
export default function Widget() {
|
|
7
|
-
|
|
8
|
-
const $isNotMinimize = Observable(false);
|
|
9
|
-
const $isMaximize = Observable(false);
|
|
10
|
-
|
|
11
|
-
const toggleMinimize = () => {
|
|
12
|
-
$isNotMinimize.toggle();
|
|
13
|
-
}
|
|
14
|
-
const toggleMaximize = () => {
|
|
15
|
-
$isNotMinimize.set(true);
|
|
16
|
-
$isMaximize.toggle();
|
|
17
|
-
}
|
|
18
|
-
const close = () => {}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return Div({
|
|
22
|
-
class: {
|
|
23
|
-
'nd-dev-tools-widget': true,
|
|
24
|
-
'nd-dev-tools-widget-maximize': $isMaximize,
|
|
25
|
-
'nd-dev-tools-widget-not-minimize': $isNotMinimize,
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
[
|
|
29
|
-
Div({ class: 'nd-dev-tools-widget-header'},[
|
|
30
|
-
Switch(
|
|
31
|
-
$isNotMinimize,
|
|
32
|
-
Div({ class: 'nd-dev-tools-widget-header-title'}, 'DevTools'),
|
|
33
|
-
Div({ class: 'nd-dev-notification-badge' }, 100)
|
|
34
|
-
),
|
|
35
|
-
Div({ class: 'nd-dev-tools-widget-header-options'}, [
|
|
36
|
-
Button({ class: 'nd-dev-tools-widget-header-option btn-close'}).nd.onClick(close),
|
|
37
|
-
Button({ class: 'nd-dev-tools-widget-header-option btn-maximize'}).nd.onClick(toggleMaximize),
|
|
38
|
-
Button({ class: 'nd-dev-tools-widget-header-option btn-minimize'}).nd.onClick(toggleMinimize),
|
|
39
|
-
])
|
|
40
|
-
]),
|
|
41
|
-
ShowIf(
|
|
42
|
-
$isNotMinimize,
|
|
43
|
-
Div({ class: 'nd-dev-tools-widget-content'}, [
|
|
44
|
-
'Show me sometghings'
|
|
45
|
-
])
|
|
46
|
-
)
|
|
47
|
-
]
|
|
48
|
-
);
|
|
49
|
-
}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
:root {
|
|
2
|
-
--nd-dev-background: #16181f;
|
|
3
|
-
--nd-dev-text-color: #e2e8f0;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
.nd-dev-tools-widget {
|
|
8
|
-
position: fixed;
|
|
9
|
-
top: 10px;
|
|
10
|
-
right: 10px;
|
|
11
|
-
background: var(--nd-dev-background);
|
|
12
|
-
color: var(--nd-dev-text-color);
|
|
13
|
-
border-radius: 5px;
|
|
14
|
-
box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
|
|
15
|
-
min-width: 100px;
|
|
16
|
-
min-height: unset;
|
|
17
|
-
z-index: 2147483647;
|
|
18
|
-
&.nd-dev-tools-widget-not-minimize {
|
|
19
|
-
min-width: 300px;
|
|
20
|
-
min-height: 200px;
|
|
21
|
-
&.nd-dev-tools-widget-maximize {
|
|
22
|
-
width: calc(100dvw - 10px*2);
|
|
23
|
-
height: calc(100dvh - 10px*2);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
.nd-dev-tools-widget-header {
|
|
28
|
-
display: flex;
|
|
29
|
-
justify-content: space-between;
|
|
30
|
-
align-items: center;
|
|
31
|
-
padding: .5rem 1.5rem;
|
|
32
|
-
column-gap: 3rem;
|
|
33
|
-
cursor: move;
|
|
34
|
-
}
|
|
35
|
-
.nd-dev-notification-badge {
|
|
36
|
-
display: flex;
|
|
37
|
-
justify-content: center;
|
|
38
|
-
align-items: center;
|
|
39
|
-
align-content: center;
|
|
40
|
-
width: 1.5rem;
|
|
41
|
-
height: 1.5rem;
|
|
42
|
-
border-radius: 50%;
|
|
43
|
-
background-color: #ff5f57;
|
|
44
|
-
font-size: .75rem;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.nd-dev-tools-widget-header-title {
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.nd-dev-tools-widget-header-options {
|
|
52
|
-
display: flex;
|
|
53
|
-
justify-content: flex-end;
|
|
54
|
-
align-items: center;
|
|
55
|
-
column-gap: 5px;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.nd-dev-tools-widget-header-option {
|
|
59
|
-
display: inline-block;
|
|
60
|
-
width: 10px;
|
|
61
|
-
height: 10px;
|
|
62
|
-
border-radius: 50%;
|
|
63
|
-
border: none;
|
|
64
|
-
cursor: pointer;
|
|
65
|
-
&.btn-close {
|
|
66
|
-
background-color: #ff5f57
|
|
67
|
-
}
|
|
68
|
-
&.btn-minimize {
|
|
69
|
-
background-color: #febc2e;
|
|
70
|
-
}
|
|
71
|
-
&.btn-maximize {
|
|
72
|
-
background-color: #28c840;
|
|
73
|
-
}
|
|
74
|
-
&:hover {
|
|
75
|
-
box-shadow: 0 0 0 2px #fff;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.nd-dev-tools-widget-content {
|
|
80
|
-
padding: .5rem;
|
|
81
|
-
}
|
package/devtools/widget.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import Widget from './widget/Widget';
|
|
2
|
-
import PluginsManager from "../types/plugins-manager";
|
|
3
|
-
// import { DevToolsPlugin } from "./plugin/dev-tools-plugin";
|
|
4
|
-
|
|
5
|
-
// PluginsManager.add(DevToolsPlugin, 'Devtools');
|
|
6
|
-
|
|
7
|
-
const Devtools = (function () {
|
|
8
|
-
|
|
9
|
-
return {
|
|
10
|
-
config() {
|
|
11
|
-
console.log('devtool init configuratzion');
|
|
12
|
-
},
|
|
13
|
-
rootApp() {
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
init() {
|
|
17
|
-
const app = Widget();
|
|
18
|
-
document.body.parentNode.appendChild(app);
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
}());
|
|
22
|
-
|
|
23
|
-
export default Devtools;
|