@tmagic/utils 1.0.0-beta.10 → 1.0.0-beta.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.
@@ -16,3 +16,5 @@ export declare const getNodePath: (id: number | string, data?: MNode[]) => MNode
16
16
  export declare const filterXSS: (str: string) => string;
17
17
  export declare const getUrlParam: (param: string, url?: string | undefined) => string;
18
18
  export declare const isPop: (node: MNode) => boolean;
19
+ export declare const isPage: (node: MNode) => boolean;
20
+ export declare const isNumber: (value: string) => boolean;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.0-beta.10",
2
+ "version": "1.0.0-beta.13",
3
3
  "name": "@tmagic/utils",
4
4
  "main": "dist/tmagic-utils.umd.js",
5
5
  "module": "dist/tmagic-utils.es.js",
@@ -10,8 +10,11 @@
10
10
  "require": "./dist/tmagic-utils.umd.js"
11
11
  }
12
12
  },
13
+ "license": "Apache-2.0",
13
14
  "scripts": {
14
- "build": "vite build"
15
+ "build": "vite build",
16
+ "test": "jest --maxWorkers=8",
17
+ "test:coverage": "jest --maxWorkers=16 --coverage"
15
18
  },
16
19
  "engines": {
17
20
  "node": ">=14"
@@ -20,11 +23,20 @@
20
23
  "type": "git",
21
24
  "url": "https://github.com/Tencent/tmagic-editor.git"
22
25
  },
26
+ "dependencies": {
27
+ "@tmagic/schema": "^1.0.0-beta.13",
28
+ "moment": "^2.29.2"
29
+ },
23
30
  "devDependencies": {
31
+ "@types/jest": "^26.0.23",
24
32
  "@types/node": "^15.12.4",
33
+ "jest": "^27.5.1",
34
+ "jest-serializer-vue": "^2.0.2",
35
+ "jest-transform-stub": "^2.0.0",
36
+ "ts-jest": "^27.1.4",
25
37
  "typescript": "^4.3.4",
26
38
  "vite": "^2.3.7",
27
39
  "vite-plugin-dts": "^0.9.6"
28
40
  },
29
- "gitHead": "fc39ecb4f5b117a4ebbfd115382887983cb8f9de"
41
+ "gitHead": "ca2b203614cbdaff580e5cb6f35630f50b827451"
30
42
  }
package/src/index.ts CHANGED
@@ -18,7 +18,7 @@
18
18
 
19
19
  import moment from 'moment';
20
20
 
21
- import { MNode } from '@tmagic/schema';
21
+ import { MNode, NodeType } from '@tmagic/schema';
22
22
 
23
23
  export const sleep = (ms: number): Promise<void> =>
24
24
  new Promise((resolve) => {
@@ -204,3 +204,7 @@ export const getUrlParam = (param: string, url?: string) => {
204
204
  };
205
205
 
206
206
  export const isPop = (node: MNode): boolean => Boolean(node.type?.toLowerCase().endsWith('pop'));
207
+
208
+ export const isPage = (node: MNode): boolean => Boolean(node.type?.toLowerCase() === NodeType.PAGE);
209
+
210
+ export const isNumber = (value: string) => /^(-?\d+)(\.\d+)?$/.test(value);
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "baseUrl": "../..",
5
- },
6
- "exclude": [
7
- "**/dist/**/*"
8
- ],
9
- }
package/vite.config.ts DELETED
@@ -1,45 +0,0 @@
1
- /*
2
- * Tencent is pleased to support the open source community by making TMagicEditor available.
3
- *
4
- * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- import { defineConfig } from 'vite';
20
- import dts from 'vite-plugin-dts';
21
-
22
- export default defineConfig({
23
- plugins: [
24
- dts({
25
- outputDir: 'dist/types',
26
- include: ['src/**/*'],
27
- staticImport: true,
28
- insertTypesEntry: true,
29
- logDiagnostics: true,
30
- }),
31
- ],
32
-
33
- build: {
34
- cssCodeSplit: false,
35
- sourcemap: true,
36
- minify: false,
37
- target: 'esnext',
38
-
39
- lib: {
40
- entry: 'src/index.ts',
41
- name: 'TMagicUtils',
42
- fileName: 'tmagic-utils',
43
- },
44
- },
45
- });