@rsmax/shared 1.0.1
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/CHANGELOG.md +8 -0
- package/LICENSE +22 -0
- package/cjs/index.d.ts +4 -0
- package/cjs/index.js +27 -0
- package/cjs/nativeComponent/getAssets.d.ts +2 -0
- package/cjs/nativeComponent/getAssets.js +23 -0
- package/cjs/nativeComponent/helpers.d.ts +6 -0
- package/cjs/nativeComponent/helpers.js +61 -0
- package/cjs/nativeComponent/jsHelper.d.ts +2 -0
- package/cjs/nativeComponent/jsHelper.js +83 -0
- package/cjs/nativeComponent/json.d.ts +1 -0
- package/cjs/nativeComponent/json.js +14 -0
- package/cjs/nativeComponent/modules.d.ts +2 -0
- package/cjs/nativeComponent/modules.js +78 -0
- package/cjs/nativeComponent/style.d.ts +3 -0
- package/cjs/nativeComponent/style.js +38 -0
- package/cjs/nativeComponent/template.d.ts +3 -0
- package/cjs/nativeComponent/template.js +61 -0
- package/cjs/nativeComponent/usingComponents.d.ts +2 -0
- package/cjs/nativeComponent/usingComponents.js +46 -0
- package/cjs/path.d.ts +1 -0
- package/cjs/path.js +10 -0
- package/cjs/unique.d.ts +1 -0
- package/cjs/unique.js +7 -0
- package/esm/index.d.ts +4 -0
- package/esm/index.js +4 -0
- package/esm/nativeComponent/getAssets.d.ts +2 -0
- package/esm/nativeComponent/getAssets.js +17 -0
- package/esm/nativeComponent/helpers.d.ts +6 -0
- package/esm/nativeComponent/helpers.js +29 -0
- package/esm/nativeComponent/jsHelper.d.ts +2 -0
- package/esm/nativeComponent/jsHelper.js +54 -0
- package/esm/nativeComponent/json.d.ts +1 -0
- package/esm/nativeComponent/json.js +11 -0
- package/esm/nativeComponent/modules.d.ts +2 -0
- package/esm/nativeComponent/modules.js +49 -0
- package/esm/nativeComponent/style.d.ts +3 -0
- package/esm/nativeComponent/style.js +30 -0
- package/esm/nativeComponent/template.d.ts +3 -0
- package/esm/nativeComponent/template.js +30 -0
- package/esm/nativeComponent/usingComponents.d.ts +2 -0
- package/esm/nativeComponent/usingComponents.js +40 -0
- package/esm/path.d.ts +1 -0
- package/esm/path.js +6 -0
- package/esm/unique.d.ts +1 -0
- package/esm/unique.js +3 -0
- package/package.json +47 -0
- package/vitest.config.js +7 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 当轩
|
|
4
|
+
Copyright (c) 2019 - present Weizhu <yesmeck@gmail.com>
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/cjs/index.d.ts
ADDED
package/cjs/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.getNativeComponentAssets = exports.getNativeEntryAssetOutputPath = exports.isNativeComponent = void 0;
|
|
21
|
+
__exportStar(require("./path"), exports);
|
|
22
|
+
__exportStar(require("./unique"), exports);
|
|
23
|
+
var helpers_1 = require("./nativeComponent/helpers");
|
|
24
|
+
Object.defineProperty(exports, "isNativeComponent", { enumerable: true, get: function () { return helpers_1.isNativeComponent; } });
|
|
25
|
+
Object.defineProperty(exports, "getNativeEntryAssetOutputPath", { enumerable: true, get: function () { return helpers_1.getNativeEntryAssetOutputPath; } });
|
|
26
|
+
var getAssets_1 = require("./nativeComponent/getAssets");
|
|
27
|
+
Object.defineProperty(exports, "getNativeComponentAssets", { enumerable: true, get: function () { return __importDefault(getAssets_1).default; } });
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const jsHelper_1 = __importDefault(require("./jsHelper"));
|
|
7
|
+
const modules_1 = __importDefault(require("./modules"));
|
|
8
|
+
const style_1 = __importDefault(require("./style"));
|
|
9
|
+
const json_1 = __importDefault(require("./json"));
|
|
10
|
+
const template_1 = __importDefault(require("./template"));
|
|
11
|
+
const usingComponents_1 = __importDefault(require("./usingComponents"));
|
|
12
|
+
function getAssets(platformConfig, resourcePath, options) {
|
|
13
|
+
const assets = [
|
|
14
|
+
...(0, modules_1.default)(options, resourcePath),
|
|
15
|
+
...(0, jsHelper_1.default)(platformConfig, resourcePath),
|
|
16
|
+
...(0, style_1.default)(platformConfig, resourcePath),
|
|
17
|
+
...(0, json_1.default)(resourcePath),
|
|
18
|
+
...(0, template_1.default)(platformConfig, options, resourcePath),
|
|
19
|
+
...(0, usingComponents_1.default)(resourcePath, options).reduce((acc, id) => [...acc, ...getAssets(platformConfig, id, options)], []),
|
|
20
|
+
];
|
|
21
|
+
return assets;
|
|
22
|
+
}
|
|
23
|
+
exports.default = getAssets;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const isNativeComponent: (sourcePath: string | null) => boolean;
|
|
2
|
+
export declare const getPath: (from: string, to: string) => string;
|
|
3
|
+
export declare function getNativeEntryAssetOutputPath(sourcePath: string, options: {
|
|
4
|
+
cwd: string;
|
|
5
|
+
rootDir: string;
|
|
6
|
+
}): string;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.getNativeEntryAssetOutputPath = exports.getPath = exports.isNativeComponent = void 0;
|
|
30
|
+
const fs = __importStar(require("fs"));
|
|
31
|
+
const path_1 = __importDefault(require("path"));
|
|
32
|
+
const path_2 = require("../path");
|
|
33
|
+
const isNativeComponent = (sourcePath) => {
|
|
34
|
+
if (!sourcePath) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
if (path_1.default.extname(sourcePath) !== '.js') {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
const sourceJsonPath = sourcePath.replace(/\.js$/, '.json');
|
|
41
|
+
if (!fs.existsSync(sourceJsonPath)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
return require(sourceJsonPath).component;
|
|
45
|
+
};
|
|
46
|
+
exports.isNativeComponent = isNativeComponent;
|
|
47
|
+
const getPath = (from, to) => {
|
|
48
|
+
return (0, path_2.slash)(path_1.default.resolve(path_1.default.dirname(from), to));
|
|
49
|
+
};
|
|
50
|
+
exports.getPath = getPath;
|
|
51
|
+
const NATIVE_COMPONENT_OUTPUT_DIR = 'remaxVendors';
|
|
52
|
+
function getNativeEntryAssetOutputPath(sourcePath, options) {
|
|
53
|
+
return (NATIVE_COMPONENT_OUTPUT_DIR +
|
|
54
|
+
'/' +
|
|
55
|
+
(0, path_2.slash)(sourcePath)
|
|
56
|
+
.replace((0, path_2.slash)(options.cwd) + '/', '')
|
|
57
|
+
.replace((0, path_2.slash)(options.rootDir) + '/', '')
|
|
58
|
+
.replace(/@/g, '_')
|
|
59
|
+
.replace(/node_modules/g, 'npm'));
|
|
60
|
+
}
|
|
61
|
+
exports.getNativeEntryAssetOutputPath = getNativeEntryAssetOutputPath;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const fs_1 = __importDefault(require("fs"));
|
|
30
|
+
const babelParser = __importStar(require("@babel/parser"));
|
|
31
|
+
const traverse_1 = __importDefault(require("@babel/traverse"));
|
|
32
|
+
const htmlparser2 = __importStar(require("htmlparser2"));
|
|
33
|
+
const lodash_1 = require("lodash");
|
|
34
|
+
const helpers_1 = require("./helpers");
|
|
35
|
+
const walk = (jsHelperPath, jsHelpers) => {
|
|
36
|
+
const jsHelperContent = fs_1.default.readFileSync(jsHelperPath).toString();
|
|
37
|
+
const ast = babelParser.parse(jsHelperContent, {
|
|
38
|
+
sourceType: 'module',
|
|
39
|
+
});
|
|
40
|
+
const extract = ({ node }) => {
|
|
41
|
+
const importPath = ((0, lodash_1.get)(node, 'callee.name') === 'require' ? (0, lodash_1.get)(node, 'arguments[0].value') : '') || (0, lodash_1.get)(node, 'source.value');
|
|
42
|
+
if (!importPath) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const absolutePath = (0, helpers_1.getPath)(jsHelperPath, importPath);
|
|
46
|
+
jsHelpers.add(absolutePath);
|
|
47
|
+
walk(absolutePath, jsHelpers);
|
|
48
|
+
};
|
|
49
|
+
(0, traverse_1.default)(ast, {
|
|
50
|
+
CallExpression: extract,
|
|
51
|
+
ImportDeclaration: extract,
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const parseTemplate = (filePath, jsHelpers, jsHelper) => {
|
|
55
|
+
const parser = new htmlparser2.Parser({});
|
|
56
|
+
const { tag, src } = jsHelper;
|
|
57
|
+
const content = fs_1.default.readFileSync(filePath).toString();
|
|
58
|
+
parser._cbs.onopentag = (name, attrs) => {
|
|
59
|
+
if (name === tag && attrs[src]) {
|
|
60
|
+
const jsHelperPath = (0, helpers_1.getPath)(filePath, attrs[src]);
|
|
61
|
+
if (!fs_1.default.existsSync(jsHelperPath)) {
|
|
62
|
+
console.error(`文件 ${jsHelperPath} 不存在`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
walk(jsHelperPath, jsHelpers);
|
|
66
|
+
jsHelpers.add(jsHelperPath);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
parser.reset();
|
|
70
|
+
parser.write(content);
|
|
71
|
+
parser.end();
|
|
72
|
+
};
|
|
73
|
+
function jsHelper(platformConfig, id) {
|
|
74
|
+
const jsHelpers = new Set();
|
|
75
|
+
const { jsHelper, template } = platformConfig;
|
|
76
|
+
if (!jsHelper) {
|
|
77
|
+
return [];
|
|
78
|
+
}
|
|
79
|
+
const templatePath = id.replace(/\.js$/, template.extension);
|
|
80
|
+
parseTemplate(templatePath, jsHelpers, jsHelper);
|
|
81
|
+
return Array.from(jsHelpers);
|
|
82
|
+
}
|
|
83
|
+
exports.default = jsHelper;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function json(id: string): string[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fs_1 = require("fs");
|
|
4
|
+
function json(id) {
|
|
5
|
+
const filePath = id.replace(/\.js$/, '.json');
|
|
6
|
+
const jsonPaths = new Set();
|
|
7
|
+
if (!(0, fs_1.existsSync)(filePath)) {
|
|
8
|
+
console.error(`文件 ${filePath} 不存在`);
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
jsonPaths.add(filePath);
|
|
12
|
+
return Array.from(jsonPaths);
|
|
13
|
+
}
|
|
14
|
+
exports.default = json;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const fs = __importStar(require("fs"));
|
|
30
|
+
const babelParser = __importStar(require("@babel/parser"));
|
|
31
|
+
const traverse_1 = __importDefault(require("@babel/traverse"));
|
|
32
|
+
const lodash_1 = require("lodash");
|
|
33
|
+
const resolve_1 = __importDefault(require("resolve"));
|
|
34
|
+
const helpers_1 = require("./helpers");
|
|
35
|
+
const walk = (jsPath, modules, options) => {
|
|
36
|
+
const jsContent = fs.readFileSync(jsPath).toString();
|
|
37
|
+
const ast = babelParser.parse(jsContent, {
|
|
38
|
+
sourceType: 'module',
|
|
39
|
+
});
|
|
40
|
+
const extract = ({ node }) => {
|
|
41
|
+
let importPath = ((0, lodash_1.get)(node, 'callee.name') === 'require' ? (0, lodash_1.get)(node, 'arguments[0].value') : '') || (0, lodash_1.get)(node, 'source.value');
|
|
42
|
+
if (!importPath) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
// 尝试 resolve,失败跳过
|
|
47
|
+
importPath = resolve_1.default.sync(importPath, { basedir: options.cwd });
|
|
48
|
+
}
|
|
49
|
+
catch (_a) {
|
|
50
|
+
// ignore
|
|
51
|
+
}
|
|
52
|
+
const absoluteId = (0, helpers_1.getPath)(jsPath, importPath);
|
|
53
|
+
let absolutePath = /.js$/.test(absoluteId) ? absoluteId : absoluteId + '.js';
|
|
54
|
+
if (!fs.existsSync(absolutePath)) {
|
|
55
|
+
absolutePath = absoluteId + '/index.js';
|
|
56
|
+
}
|
|
57
|
+
if (!fs.existsSync(absolutePath)) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
modules.add(absolutePath);
|
|
61
|
+
walk(absolutePath, modules, options);
|
|
62
|
+
};
|
|
63
|
+
(0, traverse_1.default)(ast, {
|
|
64
|
+
CallExpression: extract,
|
|
65
|
+
ImportDeclaration: extract,
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
const parseTemplate = (filePath, modules, options) => {
|
|
69
|
+
walk(filePath, modules, options);
|
|
70
|
+
modules.add(filePath);
|
|
71
|
+
};
|
|
72
|
+
function jsModule(options, id) {
|
|
73
|
+
const templatePath = id;
|
|
74
|
+
const modules = new Set();
|
|
75
|
+
parseTemplate(templatePath, modules, options);
|
|
76
|
+
return Array.from(modules);
|
|
77
|
+
}
|
|
78
|
+
exports.default = jsModule;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.walk = void 0;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const postcss_1 = __importDefault(require("postcss"));
|
|
9
|
+
const helpers_1 = require("./helpers");
|
|
10
|
+
const walk = (filePath, cssPaths) => {
|
|
11
|
+
if (!(0, fs_1.existsSync)(filePath)) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
cssPaths.add(filePath);
|
|
15
|
+
const content = (0, fs_1.readFileSync)(filePath);
|
|
16
|
+
const ast = postcss_1.default.parse(content);
|
|
17
|
+
if (!ast.nodes) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
ast.nodes.forEach(node => {
|
|
21
|
+
if (node.type === 'atrule' && node.name === 'import') {
|
|
22
|
+
const file = (0, helpers_1.getPath)(filePath, node.params.replace(/'|"/g, ''));
|
|
23
|
+
if (!(0, fs_1.existsSync)(file)) {
|
|
24
|
+
console.error(`文件 ${file} 不存在`);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
(0, exports.walk)(file, cssPaths);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
exports.walk = walk;
|
|
32
|
+
function style(platformConfig, id) {
|
|
33
|
+
const cssPaths = new Set();
|
|
34
|
+
const filePath = id.replace(/\.js$/, platformConfig.style);
|
|
35
|
+
(0, exports.walk)(filePath, cssPaths);
|
|
36
|
+
return Array.from(cssPaths);
|
|
37
|
+
}
|
|
38
|
+
exports.default = style;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.walk = void 0;
|
|
30
|
+
const htmlparser2 = __importStar(require("htmlparser2"));
|
|
31
|
+
const fs_1 = __importDefault(require("fs"));
|
|
32
|
+
const helpers_1 = require("./helpers");
|
|
33
|
+
function walk(platformConfig, filePath, templatePaths, options) {
|
|
34
|
+
if (!fs_1.default.existsSync(filePath)) {
|
|
35
|
+
console.error(`文件 ${filePath} 不存在`, options.notify);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const { tag, src } = platformConfig.template;
|
|
39
|
+
templatePaths.add(filePath);
|
|
40
|
+
const content = fs_1.default.readFileSync(filePath).toString();
|
|
41
|
+
const parser = new htmlparser2.Parser({});
|
|
42
|
+
parser._cbs.onopentag = (name, attrs) => {
|
|
43
|
+
if (name === tag && attrs[src]) {
|
|
44
|
+
walk(platformConfig, (0, helpers_1.getPath)(filePath, attrs[src]), templatePaths, options);
|
|
45
|
+
}
|
|
46
|
+
else if (['include', 'import'].includes(name) && attrs.src) {
|
|
47
|
+
walk(platformConfig, (0, helpers_1.getPath)(filePath, attrs.src), templatePaths, options);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
parser.reset();
|
|
51
|
+
parser.write(content);
|
|
52
|
+
parser.end();
|
|
53
|
+
}
|
|
54
|
+
exports.walk = walk;
|
|
55
|
+
function template(platformConfig, options, id) {
|
|
56
|
+
const templatePaths = new Set();
|
|
57
|
+
const filePath = id.replace(/\.js$/, platformConfig.template.extension);
|
|
58
|
+
walk(platformConfig, filePath, templatePaths, options);
|
|
59
|
+
return Array.from(templatePaths);
|
|
60
|
+
}
|
|
61
|
+
exports.default = template;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const resolve_1 = __importDefault(require("resolve"));
|
|
8
|
+
const helpers_1 = require("./helpers");
|
|
9
|
+
const runWalk = (filePath, components, options) => {
|
|
10
|
+
const walk = (filePath) => {
|
|
11
|
+
const { usingComponents = {} } = require(filePath);
|
|
12
|
+
Object.values(usingComponents).forEach(value => {
|
|
13
|
+
let componentJsPath = '';
|
|
14
|
+
let componentJsonPath = '';
|
|
15
|
+
if (!componentJsPath) {
|
|
16
|
+
const componentPath = (0, helpers_1.getPath)(filePath, value);
|
|
17
|
+
componentJsPath = `${componentPath}.js`;
|
|
18
|
+
componentJsonPath = `${componentPath}.json`;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
componentJsPath = resolve_1.default.sync(value, { basedir: options.cwd });
|
|
22
|
+
componentJsonPath = componentJsPath.replace(/\.js/, '.json');
|
|
23
|
+
}
|
|
24
|
+
catch (_a) {
|
|
25
|
+
// ignore
|
|
26
|
+
}
|
|
27
|
+
if (!(0, fs_1.existsSync)(componentJsPath) || !(0, fs_1.existsSync)(componentJsonPath)) {
|
|
28
|
+
console.error(`${componentJsPath} 或 ${componentJsonPath} 不存在`);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
components.add(componentJsPath);
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
walk(filePath);
|
|
35
|
+
};
|
|
36
|
+
function usingComponents(id, options) {
|
|
37
|
+
const components = new Set();
|
|
38
|
+
const filePath = id.replace(/\.js$/, '.json');
|
|
39
|
+
if (!(0, fs_1.existsSync)(filePath)) {
|
|
40
|
+
console.error(`文件 ${filePath} 不存在`);
|
|
41
|
+
return Array.from(components);
|
|
42
|
+
}
|
|
43
|
+
runWalk(filePath, components, options);
|
|
44
|
+
return Array.from(components);
|
|
45
|
+
}
|
|
46
|
+
exports.default = usingComponents;
|
package/cjs/path.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function slash(path: string): string;
|
package/cjs/path.js
ADDED
package/cjs/unique.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function unique<T>(arr: T[]): T[];
|
package/cjs/unique.js
ADDED
package/esm/index.d.ts
ADDED
package/esm/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import jsHelper from './jsHelper';
|
|
2
|
+
import jsModule from './modules';
|
|
3
|
+
import style from './style';
|
|
4
|
+
import json from './json';
|
|
5
|
+
import template from './template';
|
|
6
|
+
import usingComponents from './usingComponents';
|
|
7
|
+
export default function getAssets(platformConfig, resourcePath, options) {
|
|
8
|
+
const assets = [
|
|
9
|
+
...jsModule(options, resourcePath),
|
|
10
|
+
...jsHelper(platformConfig, resourcePath),
|
|
11
|
+
...style(platformConfig, resourcePath),
|
|
12
|
+
...json(resourcePath),
|
|
13
|
+
...template(platformConfig, options, resourcePath),
|
|
14
|
+
...usingComponents(resourcePath, options).reduce((acc, id) => [...acc, ...getAssets(platformConfig, id, options)], []),
|
|
15
|
+
];
|
|
16
|
+
return assets;
|
|
17
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const isNativeComponent: (sourcePath: string | null) => boolean;
|
|
2
|
+
export declare const getPath: (from: string, to: string) => string;
|
|
3
|
+
export declare function getNativeEntryAssetOutputPath(sourcePath: string, options: {
|
|
4
|
+
cwd: string;
|
|
5
|
+
rootDir: string;
|
|
6
|
+
}): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { slash } from '../path';
|
|
4
|
+
export const isNativeComponent = (sourcePath) => {
|
|
5
|
+
if (!sourcePath) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
if (path.extname(sourcePath) !== '.js') {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const sourceJsonPath = sourcePath.replace(/\.js$/, '.json');
|
|
12
|
+
if (!fs.existsSync(sourceJsonPath)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return require(sourceJsonPath).component;
|
|
16
|
+
};
|
|
17
|
+
export const getPath = (from, to) => {
|
|
18
|
+
return slash(path.resolve(path.dirname(from), to));
|
|
19
|
+
};
|
|
20
|
+
const NATIVE_COMPONENT_OUTPUT_DIR = 'remaxVendors';
|
|
21
|
+
export function getNativeEntryAssetOutputPath(sourcePath, options) {
|
|
22
|
+
return (NATIVE_COMPONENT_OUTPUT_DIR +
|
|
23
|
+
'/' +
|
|
24
|
+
slash(sourcePath)
|
|
25
|
+
.replace(slash(options.cwd) + '/', '')
|
|
26
|
+
.replace(slash(options.rootDir) + '/', '')
|
|
27
|
+
.replace(/@/g, '_')
|
|
28
|
+
.replace(/node_modules/g, 'npm'));
|
|
29
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import * as babelParser from '@babel/parser';
|
|
3
|
+
import traverse from '@babel/traverse';
|
|
4
|
+
import * as htmlparser2 from 'htmlparser2';
|
|
5
|
+
import { get } from 'lodash';
|
|
6
|
+
import { getPath } from './helpers';
|
|
7
|
+
const walk = (jsHelperPath, jsHelpers) => {
|
|
8
|
+
const jsHelperContent = fs.readFileSync(jsHelperPath).toString();
|
|
9
|
+
const ast = babelParser.parse(jsHelperContent, {
|
|
10
|
+
sourceType: 'module',
|
|
11
|
+
});
|
|
12
|
+
const extract = ({ node }) => {
|
|
13
|
+
const importPath = (get(node, 'callee.name') === 'require' ? get(node, 'arguments[0].value') : '') || get(node, 'source.value');
|
|
14
|
+
if (!importPath) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const absolutePath = getPath(jsHelperPath, importPath);
|
|
18
|
+
jsHelpers.add(absolutePath);
|
|
19
|
+
walk(absolutePath, jsHelpers);
|
|
20
|
+
};
|
|
21
|
+
traverse(ast, {
|
|
22
|
+
CallExpression: extract,
|
|
23
|
+
ImportDeclaration: extract,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
const parseTemplate = (filePath, jsHelpers, jsHelper) => {
|
|
27
|
+
const parser = new htmlparser2.Parser({});
|
|
28
|
+
const { tag, src } = jsHelper;
|
|
29
|
+
const content = fs.readFileSync(filePath).toString();
|
|
30
|
+
parser._cbs.onopentag = (name, attrs) => {
|
|
31
|
+
if (name === tag && attrs[src]) {
|
|
32
|
+
const jsHelperPath = getPath(filePath, attrs[src]);
|
|
33
|
+
if (!fs.existsSync(jsHelperPath)) {
|
|
34
|
+
console.error(`文件 ${jsHelperPath} 不存在`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
walk(jsHelperPath, jsHelpers);
|
|
38
|
+
jsHelpers.add(jsHelperPath);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
parser.reset();
|
|
42
|
+
parser.write(content);
|
|
43
|
+
parser.end();
|
|
44
|
+
};
|
|
45
|
+
export default function jsHelper(platformConfig, id) {
|
|
46
|
+
const jsHelpers = new Set();
|
|
47
|
+
const { jsHelper, template } = platformConfig;
|
|
48
|
+
if (!jsHelper) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
const templatePath = id.replace(/\.js$/, template.extension);
|
|
52
|
+
parseTemplate(templatePath, jsHelpers, jsHelper);
|
|
53
|
+
return Array.from(jsHelpers);
|
|
54
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function json(id: string): string[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
export default function json(id) {
|
|
3
|
+
const filePath = id.replace(/\.js$/, '.json');
|
|
4
|
+
const jsonPaths = new Set();
|
|
5
|
+
if (!existsSync(filePath)) {
|
|
6
|
+
console.error(`文件 ${filePath} 不存在`);
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
jsonPaths.add(filePath);
|
|
10
|
+
return Array.from(jsonPaths);
|
|
11
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as babelParser from '@babel/parser';
|
|
3
|
+
import traverse from '@babel/traverse';
|
|
4
|
+
import { get } from 'lodash';
|
|
5
|
+
import resolve from 'resolve';
|
|
6
|
+
import { getPath } from './helpers';
|
|
7
|
+
const walk = (jsPath, modules, options) => {
|
|
8
|
+
const jsContent = fs.readFileSync(jsPath).toString();
|
|
9
|
+
const ast = babelParser.parse(jsContent, {
|
|
10
|
+
sourceType: 'module',
|
|
11
|
+
});
|
|
12
|
+
const extract = ({ node }) => {
|
|
13
|
+
let importPath = (get(node, 'callee.name') === 'require' ? get(node, 'arguments[0].value') : '') || get(node, 'source.value');
|
|
14
|
+
if (!importPath) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
// 尝试 resolve,失败跳过
|
|
19
|
+
importPath = resolve.sync(importPath, { basedir: options.cwd });
|
|
20
|
+
}
|
|
21
|
+
catch (_a) {
|
|
22
|
+
// ignore
|
|
23
|
+
}
|
|
24
|
+
const absoluteId = getPath(jsPath, importPath);
|
|
25
|
+
let absolutePath = /.js$/.test(absoluteId) ? absoluteId : absoluteId + '.js';
|
|
26
|
+
if (!fs.existsSync(absolutePath)) {
|
|
27
|
+
absolutePath = absoluteId + '/index.js';
|
|
28
|
+
}
|
|
29
|
+
if (!fs.existsSync(absolutePath)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
modules.add(absolutePath);
|
|
33
|
+
walk(absolutePath, modules, options);
|
|
34
|
+
};
|
|
35
|
+
traverse(ast, {
|
|
36
|
+
CallExpression: extract,
|
|
37
|
+
ImportDeclaration: extract,
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
const parseTemplate = (filePath, modules, options) => {
|
|
41
|
+
walk(filePath, modules, options);
|
|
42
|
+
modules.add(filePath);
|
|
43
|
+
};
|
|
44
|
+
export default function jsModule(options, id) {
|
|
45
|
+
const templatePath = id;
|
|
46
|
+
const modules = new Set();
|
|
47
|
+
parseTemplate(templatePath, modules, options);
|
|
48
|
+
return Array.from(modules);
|
|
49
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'fs';
|
|
2
|
+
import postcss from 'postcss';
|
|
3
|
+
import { getPath } from './helpers';
|
|
4
|
+
export const walk = (filePath, cssPaths) => {
|
|
5
|
+
if (!existsSync(filePath)) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
cssPaths.add(filePath);
|
|
9
|
+
const content = readFileSync(filePath);
|
|
10
|
+
const ast = postcss.parse(content);
|
|
11
|
+
if (!ast.nodes) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
ast.nodes.forEach(node => {
|
|
15
|
+
if (node.type === 'atrule' && node.name === 'import') {
|
|
16
|
+
const file = getPath(filePath, node.params.replace(/'|"/g, ''));
|
|
17
|
+
if (!existsSync(file)) {
|
|
18
|
+
console.error(`文件 ${file} 不存在`);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
walk(file, cssPaths);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export default function style(platformConfig, id) {
|
|
26
|
+
const cssPaths = new Set();
|
|
27
|
+
const filePath = id.replace(/\.js$/, platformConfig.style);
|
|
28
|
+
walk(filePath, cssPaths);
|
|
29
|
+
return Array.from(cssPaths);
|
|
30
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as htmlparser2 from 'htmlparser2';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { getPath } from './helpers';
|
|
4
|
+
export function walk(platformConfig, filePath, templatePaths, options) {
|
|
5
|
+
if (!fs.existsSync(filePath)) {
|
|
6
|
+
console.error(`文件 ${filePath} 不存在`, options.notify);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const { tag, src } = platformConfig.template;
|
|
10
|
+
templatePaths.add(filePath);
|
|
11
|
+
const content = fs.readFileSync(filePath).toString();
|
|
12
|
+
const parser = new htmlparser2.Parser({});
|
|
13
|
+
parser._cbs.onopentag = (name, attrs) => {
|
|
14
|
+
if (name === tag && attrs[src]) {
|
|
15
|
+
walk(platformConfig, getPath(filePath, attrs[src]), templatePaths, options);
|
|
16
|
+
}
|
|
17
|
+
else if (['include', 'import'].includes(name) && attrs.src) {
|
|
18
|
+
walk(platformConfig, getPath(filePath, attrs.src), templatePaths, options);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
parser.reset();
|
|
22
|
+
parser.write(content);
|
|
23
|
+
parser.end();
|
|
24
|
+
}
|
|
25
|
+
export default function template(platformConfig, options, id) {
|
|
26
|
+
const templatePaths = new Set();
|
|
27
|
+
const filePath = id.replace(/\.js$/, platformConfig.template.extension);
|
|
28
|
+
walk(platformConfig, filePath, templatePaths, options);
|
|
29
|
+
return Array.from(templatePaths);
|
|
30
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
import resolve from 'resolve';
|
|
3
|
+
import { getPath } from './helpers';
|
|
4
|
+
const runWalk = (filePath, components, options) => {
|
|
5
|
+
const walk = (filePath) => {
|
|
6
|
+
const { usingComponents = {} } = require(filePath);
|
|
7
|
+
Object.values(usingComponents).forEach(value => {
|
|
8
|
+
let componentJsPath = '';
|
|
9
|
+
let componentJsonPath = '';
|
|
10
|
+
if (!componentJsPath) {
|
|
11
|
+
const componentPath = getPath(filePath, value);
|
|
12
|
+
componentJsPath = `${componentPath}.js`;
|
|
13
|
+
componentJsonPath = `${componentPath}.json`;
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
componentJsPath = resolve.sync(value, { basedir: options.cwd });
|
|
17
|
+
componentJsonPath = componentJsPath.replace(/\.js/, '.json');
|
|
18
|
+
}
|
|
19
|
+
catch (_a) {
|
|
20
|
+
// ignore
|
|
21
|
+
}
|
|
22
|
+
if (!existsSync(componentJsPath) || !existsSync(componentJsonPath)) {
|
|
23
|
+
console.error(`${componentJsPath} 或 ${componentJsonPath} 不存在`);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
components.add(componentJsPath);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
walk(filePath);
|
|
30
|
+
};
|
|
31
|
+
export default function usingComponents(id, options) {
|
|
32
|
+
const components = new Set();
|
|
33
|
+
const filePath = id.replace(/\.js$/, '.json');
|
|
34
|
+
if (!existsSync(filePath)) {
|
|
35
|
+
console.error(`文件 ${filePath} 不存在`);
|
|
36
|
+
return Array.from(components);
|
|
37
|
+
}
|
|
38
|
+
runWalk(filePath, components, options);
|
|
39
|
+
return Array.from(components);
|
|
40
|
+
}
|
package/esm/path.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function slash(path: string): string;
|
package/esm/path.js
ADDED
package/esm/unique.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function unique<T>(arr: T[]): T[];
|
package/esm/unique.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rsmax/shared",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Rsmax Shared",
|
|
5
|
+
"main": "cjs/index.js",
|
|
6
|
+
"module": "esm/index.js",
|
|
7
|
+
"types": "esm/index.d.ts",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/remaxjs/remax.git"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://remaxjs.org",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"clean": "rimraf esm cjs tsconfig.tsbuildinfo",
|
|
16
|
+
"prebuild": "npm run clean",
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"build:cjs": "tsc --module CommonJS --outDir cjs",
|
|
19
|
+
"test": "vitest run"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"react": "^18.3.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@rsmax/types": "1.0.1",
|
|
29
|
+
"@types/babel__traverse": "^7.0.8",
|
|
30
|
+
"@types/htmlparser2": "^3.10.1",
|
|
31
|
+
"@types/lodash": "^4.14.135",
|
|
32
|
+
"@types/react": "^17.0.70",
|
|
33
|
+
"@types/react-test-renderer": "^16.9.2",
|
|
34
|
+
"@types/resolve": "^1.14.0",
|
|
35
|
+
"postcss": "^7.0.27",
|
|
36
|
+
"react": "^18.3.0",
|
|
37
|
+
"react-test-renderer": "^18.3.0"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@babel/parser": "^7.11.4",
|
|
41
|
+
"@babel/traverse": "^7.11.0",
|
|
42
|
+
"htmlparser2": "^4.1.0",
|
|
43
|
+
"lodash": "^4.17.11",
|
|
44
|
+
"resolve": "^1.12.0"
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "d2ff644810449152d124a9da76218bcd9fdfff46"
|
|
47
|
+
}
|