native-document 1.0.273 → 1.0.275
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.
|
@@ -55,13 +55,17 @@ export default function transformForHrm(code, id, options = {}) {
|
|
|
55
55
|
|
|
56
56
|
// Cas — export default function HomePage() {}
|
|
57
57
|
if(path.parent.type === 'ExportDefaultDeclaration') {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
const varDeclaration = t.variableDeclaration('const', [
|
|
59
|
+
t.variableDeclarator(t.identifier(fnName), wrappedCall),
|
|
60
|
+
]);
|
|
61
|
+
|
|
62
|
+
path.parentPath.replaceWithMultiple([
|
|
63
|
+
varDeclaration,
|
|
64
|
+
t.exportDefaultDeclaration(t.identifier(fnName)),
|
|
65
|
+
]);
|
|
61
66
|
return;
|
|
62
67
|
}
|
|
63
68
|
|
|
64
|
-
// Cas — function HomePage() {}
|
|
65
69
|
const varDeclaration = t.variableDeclaration('const', [
|
|
66
70
|
t.variableDeclarator(t.identifier(fnName), wrappedCall),
|
|
67
71
|
]);
|
package/devtools/src/utils.js
CHANGED
|
@@ -38,7 +38,7 @@ export function transformObservableImports(code, params = {}) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export function transformObservableDeclarations(code, id) {
|
|
41
|
-
const regex = /(const|let|var)\s+([\w$]+)\s*=\s*(\$|Observable)(\.(?:init|array|json|
|
|
41
|
+
const regex = /(const|let|var)\s+([\w$]+)\s*=\s*(\$|Observable)(\.(?:init|array|json|object))?\s*\(/g;
|
|
42
42
|
|
|
43
43
|
return code.replace(regex, (match, varType, varName, caller, method) => {
|
|
44
44
|
const obsName = method ? `${caller}${method}` : caller;
|
|
@@ -47,7 +47,7 @@ export function transformObservableDeclarations(code, id) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
export function isFileMustBeModified(file) {
|
|
50
|
-
if(
|
|
50
|
+
if(!file.includes('/src/') || file.includes('node_modules') || /\.test\.js$/.test(file)) {
|
|
51
51
|
return false;
|
|
52
52
|
}
|
|
53
53
|
const content = fs.readFileSync(file, 'utf-8');
|
|
@@ -55,5 +55,5 @@ export function isFileMustBeModified(file) {
|
|
|
55
55
|
if(isContainObservableImport) {
|
|
56
56
|
return true;
|
|
57
57
|
}
|
|
58
|
-
return /(const|let|var)\s+([\w$]+)\s*=\s*(\$|Observable)(\.(?:init|array|json|
|
|
58
|
+
return /(const|let|var)\s+([\w$]+)\s*=\s*(\$|Observable)(\.(?:init|array|json|object))?\s*\(/g.test(content);
|
|
59
59
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "native-document",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.275",
|
|
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",
|
|
@@ -2,7 +2,8 @@ import {Observable as ObservableOriginal} from './Observable';
|
|
|
2
2
|
|
|
3
3
|
const HrmGlobakObservableRegistry = new Map();
|
|
4
4
|
|
|
5
|
-
const overrideMethods = ['array', 'init', 'object', 'json'
|
|
5
|
+
const overrideMethods = ['array', 'init', 'object', 'json'];
|
|
6
|
+
const noObservableOverride = ['ref', 'resource'];
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
const override = (callback) => {
|
|
@@ -52,7 +53,9 @@ export const Observable = override(ObservableOriginal);
|
|
|
52
53
|
export const $ = Observable;
|
|
53
54
|
|
|
54
55
|
overrideMethods.forEach(method => {
|
|
55
|
-
|
|
56
56
|
Observable[method] = override(ObservableOriginal[method]);
|
|
57
|
-
|
|
58
57
|
});
|
|
58
|
+
|
|
59
|
+
noObservableOverride.forEach(method => {
|
|
60
|
+
Observable[method] = ObservableOriginal[method];
|
|
61
|
+
});
|