@rsmax/shared 1.3.11 → 1.3.13

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 CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.3.13](https://github.com/remaxjs/remax/compare/v1.3.12...v1.3.13) (2025-06-16)
7
+
8
+ **Note:** Version bump only for package @rsmax/shared
9
+
10
+ ## [1.3.12](https://github.com/remaxjs/remax/compare/v1.3.11...v1.3.12) (2025-06-08)
11
+
12
+ **Note:** Version bump only for package @rsmax/shared
13
+
6
14
  ## [1.3.11](https://github.com/remaxjs/remax/compare/v1.3.8...v1.3.11) (2025-06-04)
7
15
 
8
16
  **Note:** Version bump only for package @rsmax/shared
@@ -1,2 +1,2 @@
1
- import type { Options, Meta } from '@rsmax/types';
1
+ import type { Meta, Options } from '@rsmax/types';
2
2
  export default function getAssets(platformConfig: Meta, resourcePath: string, options: Options): string[];
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const jsHelper_1 = __importDefault(require("./jsHelper"));
7
+ const json_1 = __importDefault(require("./json"));
7
8
  const modules_1 = __importDefault(require("./modules"));
8
9
  const style_1 = __importDefault(require("./style"));
9
- const json_1 = __importDefault(require("./json"));
10
10
  const template_1 = __importDefault(require("./template"));
11
11
  const usingComponents_1 = __importDefault(require("./usingComponents"));
12
12
  function getAssets(platformConfig, resourcePath, options) {
@@ -27,14 +27,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
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");
30
+ const fs = __importStar(require("node:fs"));
31
+ const node_path_1 = __importDefault(require("node:path"));
32
+ const path_1 = require("../path");
33
33
  const isNativeComponent = (sourcePath) => {
34
34
  if (!sourcePath) {
35
35
  return false;
36
36
  }
37
- if (path_1.default.extname(sourcePath) !== '.js') {
37
+ if (node_path_1.default.extname(sourcePath) !== '.js') {
38
38
  return false;
39
39
  }
40
40
  const sourceJsonPath = sourcePath.replace(/\.js$/, '.json');
@@ -45,17 +45,15 @@ const isNativeComponent = (sourcePath) => {
45
45
  };
46
46
  exports.isNativeComponent = isNativeComponent;
47
47
  const getPath = (from, to) => {
48
- return (0, path_2.slash)(path_1.default.resolve(path_1.default.dirname(from), to));
48
+ return (0, path_1.slash)(node_path_1.default.resolve(node_path_1.default.dirname(from), to));
49
49
  };
50
50
  exports.getPath = getPath;
51
51
  const NATIVE_COMPONENT_OUTPUT_DIR = 'remaxVendors';
52
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'));
53
+ return `${NATIVE_COMPONENT_OUTPUT_DIR}/${(0, path_1.slash)(sourcePath)
54
+ .replace(`${(0, path_1.slash)(options.cwd)}/`, '')
55
+ .replace(`${(0, path_1.slash)(options.rootDir)}/`, '')
56
+ .replace(/@/g, '_')
57
+ .replace(/node_modules/g, 'npm')}`;
60
58
  }
61
59
  exports.getNativeEntryAssetOutputPath = getNativeEntryAssetOutputPath;
@@ -26,14 +26,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const fs_1 = __importDefault(require("fs"));
29
+ const node_fs_1 = __importDefault(require("node:fs"));
30
30
  const babelParser = __importStar(require("@babel/parser"));
31
31
  const traverse_1 = __importDefault(require("@babel/traverse"));
32
32
  const htmlparser2 = __importStar(require("htmlparser2"));
33
33
  const lodash_1 = require("lodash");
34
34
  const helpers_1 = require("./helpers");
35
35
  const walk = (jsHelperPath, jsHelpers) => {
36
- const jsHelperContent = fs_1.default.readFileSync(jsHelperPath).toString();
36
+ const jsHelperContent = node_fs_1.default.readFileSync(jsHelperPath).toString();
37
37
  const ast = babelParser.parse(jsHelperContent, {
38
38
  sourceType: 'module',
39
39
  });
@@ -54,11 +54,11 @@ const walk = (jsHelperPath, jsHelpers) => {
54
54
  const parseTemplate = (filePath, jsHelpers, jsHelper) => {
55
55
  const parser = new htmlparser2.Parser({});
56
56
  const { tag, src } = jsHelper;
57
- const content = fs_1.default.readFileSync(filePath).toString();
57
+ const content = node_fs_1.default.readFileSync(filePath).toString();
58
58
  parser._cbs.onopentag = (name, attrs) => {
59
59
  if (name === tag && attrs[src]) {
60
60
  const jsHelperPath = (0, helpers_1.getPath)(filePath, attrs[src]);
61
- if (!fs_1.default.existsSync(jsHelperPath)) {
61
+ if (!node_fs_1.default.existsSync(jsHelperPath)) {
62
62
  console.error(`文件 ${jsHelperPath} 不存在`);
63
63
  return;
64
64
  }
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const fs_1 = require("fs");
3
+ const node_fs_1 = require("node:fs");
4
4
  function json(id) {
5
5
  const filePath = id.replace(/\.js$/, '.json');
6
6
  const jsonPaths = new Set();
7
- if (!(0, fs_1.existsSync)(filePath)) {
7
+ if (!(0, node_fs_1.existsSync)(filePath)) {
8
8
  console.error(`文件 ${filePath} 不存在`);
9
9
  return [];
10
10
  }
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- const fs = __importStar(require("fs"));
29
+ const fs = __importStar(require("node:fs"));
30
30
  const babelParser = __importStar(require("@babel/parser"));
31
31
  const traverse_1 = __importDefault(require("@babel/traverse"));
32
32
  const lodash_1 = require("lodash");
@@ -50,9 +50,9 @@ const walk = (jsPath, modules, options) => {
50
50
  // ignore
51
51
  }
52
52
  const absoluteId = (0, helpers_1.getPath)(jsPath, importPath);
53
- let absolutePath = /.js$/.test(absoluteId) ? absoluteId : absoluteId + '.js';
53
+ let absolutePath = /.js$/.test(absoluteId) ? absoluteId : `${absoluteId}.js`;
54
54
  if (!fs.existsSync(absolutePath)) {
55
- absolutePath = absoluteId + '/index.js';
55
+ absolutePath = `${absoluteId}/index.js`;
56
56
  }
57
57
  if (!fs.existsSync(absolutePath)) {
58
58
  return;
@@ -4,15 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.walk = void 0;
7
- const fs_1 = require("fs");
7
+ const node_fs_1 = require("node:fs");
8
8
  const postcss_1 = __importDefault(require("postcss"));
9
9
  const helpers_1 = require("./helpers");
10
10
  const walk = (filePath, cssPaths) => {
11
- if (!(0, fs_1.existsSync)(filePath)) {
11
+ if (!(0, node_fs_1.existsSync)(filePath)) {
12
12
  return;
13
13
  }
14
14
  cssPaths.add(filePath);
15
- const content = (0, fs_1.readFileSync)(filePath);
15
+ const content = (0, node_fs_1.readFileSync)(filePath);
16
16
  const ast = postcss_1.default.parse(content);
17
17
  if (!ast.nodes) {
18
18
  return;
@@ -20,7 +20,7 @@ const walk = (filePath, cssPaths) => {
20
20
  ast.nodes.forEach(node => {
21
21
  if (node.type === 'atrule' && node.name === 'import') {
22
22
  const file = (0, helpers_1.getPath)(filePath, node.params.replace(/'|"/g, ''));
23
- if (!(0, fs_1.existsSync)(file)) {
23
+ if (!(0, node_fs_1.existsSync)(file)) {
24
24
  console.error(`文件 ${file} 不存在`);
25
25
  return;
26
26
  }
@@ -1,3 +1,3 @@
1
- import type { Options, Meta } from '@rsmax/types';
1
+ import type { Meta, Options } from '@rsmax/types';
2
2
  export declare function walk(platformConfig: Meta, filePath: string, templatePaths: Set<string>, options: Options): void;
3
3
  export default function template(platformConfig: Meta, options: Options, id: string): string[];
@@ -27,17 +27,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.walk = void 0;
30
+ const node_fs_1 = __importDefault(require("node:fs"));
30
31
  const htmlparser2 = __importStar(require("htmlparser2"));
31
- const fs_1 = __importDefault(require("fs"));
32
32
  const helpers_1 = require("./helpers");
33
33
  function walk(platformConfig, filePath, templatePaths, options) {
34
- if (!fs_1.default.existsSync(filePath)) {
34
+ if (!node_fs_1.default.existsSync(filePath)) {
35
35
  console.error(`文件 ${filePath} 不存在`, options.notify);
36
36
  return;
37
37
  }
38
38
  const { tag, src } = platformConfig.template;
39
39
  templatePaths.add(filePath);
40
- const content = fs_1.default.readFileSync(filePath).toString();
40
+ const content = node_fs_1.default.readFileSync(filePath).toString();
41
41
  const parser = new htmlparser2.Parser({});
42
42
  parser._cbs.onopentag = (name, attrs) => {
43
43
  if (name === tag && attrs[src]) {
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = require("fs");
6
+ const node_fs_1 = require("node:fs");
7
7
  const resolve_1 = __importDefault(require("resolve"));
8
8
  const helpers_1 = require("./helpers");
9
9
  const runWalk = (filePath, components, options) => {
@@ -24,7 +24,7 @@ const runWalk = (filePath, components, options) => {
24
24
  catch (_a) {
25
25
  // ignore
26
26
  }
27
- if (!(0, fs_1.existsSync)(componentJsPath) || !(0, fs_1.existsSync)(componentJsonPath)) {
27
+ if (!(0, node_fs_1.existsSync)(componentJsPath) || !(0, node_fs_1.existsSync)(componentJsonPath)) {
28
28
  console.error(`${componentJsPath} 或 ${componentJsonPath} 不存在`);
29
29
  return;
30
30
  }
@@ -36,7 +36,7 @@ const runWalk = (filePath, components, options) => {
36
36
  function usingComponents(id, options) {
37
37
  const components = new Set();
38
38
  const filePath = id.replace(/\.js$/, '.json');
39
- if (!(0, fs_1.existsSync)(filePath)) {
39
+ if (!(0, node_fs_1.existsSync)(filePath)) {
40
40
  console.error(`文件 ${filePath} 不存在`);
41
41
  return Array.from(components);
42
42
  }
package/cjs/path.js CHANGED
@@ -5,6 +5,6 @@ function slash(path) {
5
5
  if (!path) {
6
6
  return path;
7
7
  }
8
- return /^\\\\\?\\/.test(path) ? path : path.replace(/\\/g, `/`);
8
+ return /^\\\\\?\\/.test(path) ? path : path.replace(/\\/g, '/');
9
9
  }
10
10
  exports.slash = slash;
@@ -1,2 +1,2 @@
1
- import type { Options, Meta } from '@rsmax/types';
1
+ import type { Meta, Options } from '@rsmax/types';
2
2
  export default function getAssets(platformConfig: Meta, resourcePath: string, options: Options): string[];
@@ -1,7 +1,7 @@
1
1
  import jsHelper from './jsHelper';
2
+ import json from './json';
2
3
  import jsModule from './modules';
3
4
  import style from './style';
4
- import json from './json';
5
5
  import template from './template';
6
6
  import usingComponents from './usingComponents';
7
7
  export default function getAssets(platformConfig, resourcePath, options) {
@@ -1,5 +1,5 @@
1
- import * as fs from 'fs';
2
- import path from 'path';
1
+ import * as fs from 'node:fs';
2
+ import path from 'node:path';
3
3
  import { slash } from '../path';
4
4
  export const isNativeComponent = (sourcePath) => {
5
5
  if (!sourcePath) {
@@ -19,11 +19,9 @@ export const getPath = (from, to) => {
19
19
  };
20
20
  const NATIVE_COMPONENT_OUTPUT_DIR = 'remaxVendors';
21
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'));
22
+ return `${NATIVE_COMPONENT_OUTPUT_DIR}/${slash(sourcePath)
23
+ .replace(`${slash(options.cwd)}/`, '')
24
+ .replace(`${slash(options.rootDir)}/`, '')
25
+ .replace(/@/g, '_')
26
+ .replace(/node_modules/g, 'npm')}`;
29
27
  }
@@ -1,4 +1,4 @@
1
- import fs from 'fs';
1
+ import fs from 'node:fs';
2
2
  import * as babelParser from '@babel/parser';
3
3
  import traverse from '@babel/traverse';
4
4
  import * as htmlparser2 from 'htmlparser2';
@@ -1,4 +1,4 @@
1
- import { existsSync } from 'fs';
1
+ import { existsSync } from 'node:fs';
2
2
  export default function json(id) {
3
3
  const filePath = id.replace(/\.js$/, '.json');
4
4
  const jsonPaths = new Set();
@@ -1,4 +1,4 @@
1
- import * as fs from 'fs';
1
+ import * as fs from 'node:fs';
2
2
  import * as babelParser from '@babel/parser';
3
3
  import traverse from '@babel/traverse';
4
4
  import { get } from 'lodash';
@@ -22,9 +22,9 @@ const walk = (jsPath, modules, options) => {
22
22
  // ignore
23
23
  }
24
24
  const absoluteId = getPath(jsPath, importPath);
25
- let absolutePath = /.js$/.test(absoluteId) ? absoluteId : absoluteId + '.js';
25
+ let absolutePath = /.js$/.test(absoluteId) ? absoluteId : `${absoluteId}.js`;
26
26
  if (!fs.existsSync(absolutePath)) {
27
- absolutePath = absoluteId + '/index.js';
27
+ absolutePath = `${absoluteId}/index.js`;
28
28
  }
29
29
  if (!fs.existsSync(absolutePath)) {
30
30
  return;
@@ -1,4 +1,4 @@
1
- import { existsSync, readFileSync } from 'fs';
1
+ import { existsSync, readFileSync } from 'node:fs';
2
2
  import postcss from 'postcss';
3
3
  import { getPath } from './helpers';
4
4
  export const walk = (filePath, cssPaths) => {
@@ -1,3 +1,3 @@
1
- import type { Options, Meta } from '@rsmax/types';
1
+ import type { Meta, Options } from '@rsmax/types';
2
2
  export declare function walk(platformConfig: Meta, filePath: string, templatePaths: Set<string>, options: Options): void;
3
3
  export default function template(platformConfig: Meta, options: Options, id: string): string[];
@@ -1,5 +1,5 @@
1
+ import fs from 'node:fs';
1
2
  import * as htmlparser2 from 'htmlparser2';
2
- import fs from 'fs';
3
3
  import { getPath } from './helpers';
4
4
  export function walk(platformConfig, filePath, templatePaths, options) {
5
5
  if (!fs.existsSync(filePath)) {
@@ -1,4 +1,4 @@
1
- import { existsSync } from 'fs';
1
+ import { existsSync } from 'node:fs';
2
2
  import resolve from 'resolve';
3
3
  import { getPath } from './helpers';
4
4
  const runWalk = (filePath, components, options) => {
package/esm/path.js CHANGED
@@ -2,5 +2,5 @@ export function slash(path) {
2
2
  if (!path) {
3
3
  return path;
4
4
  }
5
- return /^\\\\\?\\/.test(path) ? path : path.replace(/\\/g, `/`);
5
+ return /^\\\\\?\\/.test(path) ? path : path.replace(/\\/g, '/');
6
6
  }
package/package.json CHANGED
@@ -1,28 +1,32 @@
1
1
  {
2
2
  "name": "@rsmax/shared",
3
- "version": "1.3.11",
3
+ "version": "1.3.13",
4
4
  "description": "Rsmax Shared",
5
- "main": "cjs/index.js",
6
- "module": "esm/index.js",
7
- "types": "esm/index.d.ts",
8
- "license": "MIT",
5
+ "homepage": "https://remax.wdchiphop.cn",
9
6
  "repository": {
10
7
  "type": "git",
11
8
  "url": "git+https://github.com/remaxjs/remax.git"
12
9
  },
13
- "homepage": "https://remaxjs.org",
10
+ "license": "MIT",
11
+ "main": "cjs/index.js",
12
+ "module": "esm/index.js",
13
+ "types": "esm/index.d.ts",
14
14
  "scripts": {
15
- "clean": "rimraf esm cjs tsconfig.tsbuildinfo",
16
15
  "prebuild": "npm run clean",
17
16
  "build": "tsc",
18
17
  "build:cjs": "tsc --module CommonJS --outDir cjs",
18
+ "clean": "rimraf esm cjs tsconfig.tsbuildinfo",
19
19
  "test": "vitest run"
20
20
  },
21
- "peerDependencies": {
22
- "react": "^18.3.0"
21
+ "dependencies": {
22
+ "@babel/parser": "^7.11.4",
23
+ "@babel/traverse": "^7.11.0",
24
+ "htmlparser2": "^4.1.0",
25
+ "lodash": "^4.17.11",
26
+ "resolve": "^1.12.0"
23
27
  },
24
28
  "devDependencies": {
25
- "@rsmax/types": "1.3.11",
29
+ "@rsmax/types": "1.3.13",
26
30
  "@types/babel__traverse": "^7.0.8",
27
31
  "@types/htmlparser2": "^3.10.1",
28
32
  "@types/lodash": "^4.14.135",
@@ -33,15 +37,11 @@
33
37
  "react": "^18.3.0",
34
38
  "react-test-renderer": "^18.3.0"
35
39
  },
36
- "dependencies": {
37
- "@babel/parser": "^7.11.4",
38
- "@babel/traverse": "^7.11.0",
39
- "htmlparser2": "^4.1.0",
40
- "lodash": "^4.17.11",
41
- "resolve": "^1.12.0"
40
+ "peerDependencies": {
41
+ "react": "^18.3.0"
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public"
45
45
  },
46
- "gitHead": "f7430582843aaab07f32ba74f81c47863bcd4a8b"
46
+ "gitHead": "ff3656307036567c5b9d9b62dcaa599f539d56b7"
47
47
  }