jsbox-cview 1.6.5 → 1.6.7
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/README.md +4 -0
- package/dist/components/alert/input-alert.d.ts +22 -0
- package/dist/components/alert/input-alert.js +1 -2
- package/dist/components/alert/login-alert.d.ts +21 -0
- package/dist/components/alert/login-alert.js +1 -2
- package/dist/components/alert/plain-alert.d.ts +15 -0
- package/dist/components/alert/plain-alert.js +1 -2
- package/dist/components/alert/uialert.d.ts +29 -0
- package/{components/base.ts → dist/components/base.d.ts} +9 -28
- package/dist/components/custom-navigation-bar.d.ts +117 -0
- package/dist/components/custom-navigation-bar.js +7 -1
- package/dist/components/dialogs/dialog-sheet.d.ts +46 -0
- package/dist/components/dialogs/dialog-sheet.js +3 -1
- package/dist/components/dialogs/form-dialog.d.ts +15 -0
- package/dist/components/dialogs/form-dialog.js +1 -2
- package/dist/components/dialogs/list-dialog.d.ts +23 -0
- package/dist/components/dialogs/list-dialog.js +2 -3
- package/dist/components/dialogs/text-dialog.d.ts +13 -0
- package/dist/components/dialogs/text-dialog.js +1 -2
- package/dist/components/dynamic-contextmenu-view.d.ts +40 -0
- package/dist/components/dynamic-contextmenu-view.js +5 -1
- package/dist/components/dynamic-itemsize-matrix.d.ts +79 -0
- package/dist/components/dynamic-itemsize-matrix.js +18 -15
- package/dist/components/dynamic-itemsize-section-matrix.d.ts +115 -0
- package/dist/components/dynamic-itemsize-section-matrix.js +293 -0
- package/dist/components/dynamic-preference-listview.d.ts +63 -0
- package/dist/components/dynamic-preference-listview.js +25 -16
- package/dist/components/dynamic-rowheight-list.d.ts +38 -0
- package/dist/components/dynamic-rowheight-list.js +10 -3
- package/dist/components/enhanced-imageview.d.ts +41 -0
- package/dist/components/enhanced-imageview.js +1 -1
- package/dist/components/flowlayout.d.ts +63 -0
- package/dist/components/flowlayout.js +10 -13
- package/dist/components/image-pager.d.ts +49 -0
- package/dist/components/image-pager.js +6 -1
- package/dist/components/oc-webview.d.ts +64 -0
- package/dist/components/oc-webview.js +13 -5
- package/dist/components/page-control.d.ts +45 -0
- package/dist/components/page-control.js +2 -13
- package/dist/components/pageviewer-titlebar.d.ts +48 -0
- package/dist/components/pageviewer-titlebar.js +7 -13
- package/dist/components/pageviewer.d.ts +41 -0
- package/dist/components/pageviewer.js +4 -1
- package/dist/components/refresh-button.d.ts +25 -0
- package/dist/components/refresh-button.js +3 -4
- package/dist/components/rotating-view.d.ts +45 -0
- package/dist/components/rotating-view.js +10 -2
- package/dist/components/searchbar.d.ts +118 -0
- package/dist/components/searchbar.js +8 -1
- package/dist/components/sheet.d.ts +42 -0
- package/dist/components/single-views.d.ts +289 -0
- package/dist/components/single-views.js +11 -4
- package/dist/components/spinners/loading-dual-ring.d.ts +18 -0
- package/dist/components/spinners/loading-wedges.d.ts +15 -0
- package/dist/components/spinners/spinner-androidstyle.d.ts +30 -0
- package/dist/components/spinners/spinner-androidstyle.js +7 -1
- package/dist/components/static-preference-listview.d.ts +389 -0
- package/dist/components/static-preference-listview.js +13 -10
- package/dist/components/symbol-button.d.ts +39 -0
- package/dist/components/symbol-button.js +8 -1
- package/dist/components/tabbar.d.ts +140 -0
- package/dist/components/tabbar.js +8 -1
- package/dist/controller/base-controller.d.ts +125 -0
- package/dist/controller/base-controller.js +11 -11
- package/dist/controller/controller-router.d.ts +48 -0
- package/dist/controller/pageviewer-controller.d.ts +38 -0
- package/dist/controller/pageviewer-controller.js +4 -1
- package/dist/controller/presented-page-controller.d.ts +41 -0
- package/dist/controller/presented-page-controller.js +7 -9
- package/dist/controller/splitview-controller.d.ts +90 -0
- package/dist/controller/splitview-controller.js +27 -11
- package/dist/controller/tabbar-controller.d.ts +49 -0
- package/dist/controller/tabbar-controller.js +12 -15
- package/{index.ts → dist/index.d.ts} +2 -0
- package/dist/index.js +2 -0
- package/dist/utils/colors.d.ts +7 -0
- package/dist/utils/cvid.d.ts +11 -0
- package/dist/utils/l10n.d.ts +1 -0
- package/dist/utils/l10n.js +1 -2
- package/dist/utils/path.d.ts +8 -0
- package/dist/utils/path.js +8 -9
- package/dist/utils/rect.d.ts +38 -0
- package/dist/utils/rect.js +8 -9
- package/dist/utils/uitools.d.ts +75 -0
- package/dist/utils/uitools.js +6 -6
- package/package.json +20 -5
- package/.prettierignore +0 -6
- package/.prettierrc +0 -3
- package/components/alert/input-alert.ts +0 -64
- package/components/alert/login-alert.ts +0 -66
- package/components/alert/plain-alert.ts +0 -39
- package/components/alert/uialert.ts +0 -107
- package/components/custom-navigation-bar.ts +0 -579
- package/components/dialogs/dialog-sheet.ts +0 -111
- package/components/dialogs/form-dialog.ts +0 -63
- package/components/dialogs/list-dialog.ts +0 -119
- package/components/dialogs/text-dialog.ts +0 -44
- package/components/dynamic-contextmenu-view.ts +0 -115
- package/components/dynamic-itemsize-matrix.ts +0 -206
- package/components/dynamic-preference-listview.ts +0 -684
- package/components/dynamic-rowheight-list.ts +0 -77
- package/components/enhanced-imageview.ts +0 -132
- package/components/flowlayout.ts +0 -248
- package/components/image-pager.ts +0 -180
- package/components/oc-webview.ts +0 -177
- package/components/page-control.ts +0 -93
- package/components/pageviewer-titlebar.ts +0 -166
- package/components/pageviewer.ts +0 -125
- package/components/refresh-button.ts +0 -83
- package/components/rotating-view.ts +0 -133
- package/components/searchbar.ts +0 -398
- package/components/sheet.ts +0 -104
- package/components/single-views.ts +0 -956
- package/components/spinners/loading-dual-ring.ts +0 -97
- package/components/spinners/loading-wedges.ts +0 -106
- package/components/spinners/spinner-androidstyle.ts +0 -269
- package/components/static-preference-listview.ts +0 -1282
- package/components/symbol-button.ts +0 -108
- package/components/tabbar.ts +0 -453
- package/controller/base-controller.ts +0 -214
- package/controller/controller-router.ts +0 -73
- package/controller/pageviewer-controller.ts +0 -93
- package/controller/presented-page-controller.ts +0 -76
- package/controller/splitview-controller.ts +0 -359
- package/controller/tabbar-controller.ts +0 -131
- package/dist/test/custom-navigation-bar.js +0 -40
- package/dist/test/dialog-sheet.js +0 -40
- package/dist/test/dynamic-contextmenu-view.js +0 -66
- package/dist/test/dynamic-itemsize-matrix.js +0 -74
- package/dist/test/dynamic-preference-listview.js +0 -150
- package/dist/test/flowlayout.js +0 -76
- package/dist/test/form-dialog.js +0 -51
- package/dist/test/oc-webview.js +0 -195
- package/dist/test/pageviewer-controller.js +0 -20
- package/dist/test/pageviewer-titlebar.js +0 -18
- package/dist/test/pageviewer.js +0 -32
- package/dist/test/refresh-button.js +0 -26
- package/dist/test/searchbar.js +0 -36
- package/dist/test/splitview-controller.js +0 -41
- package/dist/test/static-preference-listview.js +0 -143
- package/dist/test/tabbar-controller.js +0 -48
- package/test/custom-navigation-bar.ts +0 -40
- package/test/dialog-sheet.ts +0 -40
- package/test/dynamic-contextmenu-view.ts +0 -67
- package/test/dynamic-itemsize-matrix.ts +0 -74
- package/test/dynamic-preference-listview.ts +0 -151
- package/test/flowlayout.ts +0 -79
- package/test/form-dialog.ts +0 -48
- package/test/oc-webview.ts +0 -197
- package/test/pageviewer-controller.ts +0 -21
- package/test/pageviewer-titlebar.ts +0 -18
- package/test/pageviewer.ts +0 -31
- package/test/refresh-button.ts +0 -26
- package/test/searchbar.ts +0 -38
- package/test/splitview-controller.ts +0 -42
- package/test/static-preference-listview.ts +0 -142
- package/test/tabbar-controller.ts +0 -49
- package/tsconfig.json +0 -122
- package/utils/colors.ts +0 -17
- package/utils/cvid.ts +0 -32
- package/utils/l10n.ts +0 -42
- package/utils/path.ts +0 -97
- package/utils/rect.ts +0 -90
- package/utils/uitools.ts +0 -122
package/tsconfig.json
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
-
|
|
5
|
-
/* Projects */
|
|
6
|
-
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
-
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
-
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
-
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
-
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
-
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
-
|
|
13
|
-
/* Language and Environment */
|
|
14
|
-
"target": "es2017", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
|
-
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
-
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
-
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
18
|
-
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
19
|
-
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
20
|
-
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
21
|
-
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
22
|
-
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
23
|
-
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
24
|
-
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
|
-
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
|
-
|
|
27
|
-
/* Modules */
|
|
28
|
-
"module": "CommonJS", /* Specify what module code is generated. */
|
|
29
|
-
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
30
|
-
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
31
|
-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
32
|
-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
|
-
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
|
-
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
35
|
-
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
36
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
|
-
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
38
|
-
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
39
|
-
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
40
|
-
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
41
|
-
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
42
|
-
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
43
|
-
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
44
|
-
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
45
|
-
|
|
46
|
-
/* JavaScript Support */
|
|
47
|
-
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
48
|
-
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
49
|
-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
50
|
-
|
|
51
|
-
/* Emit */
|
|
52
|
-
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
53
|
-
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
54
|
-
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
55
|
-
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
56
|
-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
57
|
-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
58
|
-
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
|
59
|
-
// "removeComments": true, /* Disable emitting comments. */
|
|
60
|
-
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
62
|
-
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
63
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
64
|
-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
65
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
66
|
-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
67
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
68
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
69
|
-
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
70
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
71
|
-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
72
|
-
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
73
|
-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
74
|
-
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
75
|
-
|
|
76
|
-
/* Interop Constraints */
|
|
77
|
-
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
78
|
-
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
79
|
-
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
80
|
-
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
81
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
82
|
-
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
83
|
-
|
|
84
|
-
/* Type Checking */
|
|
85
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
86
|
-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
87
|
-
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
88
|
-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
89
|
-
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
90
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
91
|
-
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
92
|
-
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
93
|
-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
94
|
-
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
95
|
-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
96
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
97
|
-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
98
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
99
|
-
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
100
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
101
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
102
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
103
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
104
|
-
|
|
105
|
-
/* Completeness */
|
|
106
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
107
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
108
|
-
},
|
|
109
|
-
"include": [
|
|
110
|
-
"node_modules/jsbox-types/index.d.ts",
|
|
111
|
-
"test.ts",
|
|
112
|
-
"index.ts",
|
|
113
|
-
"utils/*.ts",
|
|
114
|
-
"components/*.ts",
|
|
115
|
-
"components/*/*.ts",
|
|
116
|
-
"controller/*.ts",
|
|
117
|
-
"test/*.ts"
|
|
118
|
-
],
|
|
119
|
-
"files": [
|
|
120
|
-
"index.ts"
|
|
121
|
-
]
|
|
122
|
-
}
|
package/utils/colors.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// 自定义的语义化颜色
|
|
2
|
-
|
|
3
|
-
export const sheetNavBarColor = $color("tint", $color("tertiarySurface"));
|
|
4
|
-
export const footBarDefaultSegmentColor = $color("#b7bec6", "#6e6e6e");
|
|
5
|
-
export const searchBarSymbolColor = $color("#777", "#aaa");
|
|
6
|
-
export const searchBarBgcolor = $color("backgroundColor", "secondarySurface");
|
|
7
|
-
export const gold = $color("#ffd700");
|
|
8
|
-
export const sectionHeaderColor = $color({
|
|
9
|
-
light: "#666666",
|
|
10
|
-
dark: "#acacac",
|
|
11
|
-
black: "#ababab",
|
|
12
|
-
});
|
|
13
|
-
export const sliderMaxColor = $color({
|
|
14
|
-
light: "#E4E4E6",
|
|
15
|
-
dark: "#38373B",
|
|
16
|
-
black: "#2B2A2E",
|
|
17
|
-
});
|
package/utils/cvid.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// cvid 用于生成唯一的 id
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 生成指定长度的随机字符串
|
|
5
|
-
*/
|
|
6
|
-
function makeid(length: number) {
|
|
7
|
-
let result = "";
|
|
8
|
-
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
9
|
-
var charactersLength = characters.length;
|
|
10
|
-
for (let i = 0; i < length; i++) {
|
|
11
|
-
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
|
12
|
-
}
|
|
13
|
-
return result;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
class CVID {
|
|
17
|
-
_prefix: string;
|
|
18
|
-
_index: number;
|
|
19
|
-
|
|
20
|
-
constructor({ prefix = "id_", startIndex = 0 } = {}) {
|
|
21
|
-
this._prefix = prefix;
|
|
22
|
-
this._index = startIndex;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
get newId() {
|
|
26
|
-
const id = this._prefix + this._index;
|
|
27
|
-
this._index++;
|
|
28
|
-
return id;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const cvid = new CVID({ prefix: makeid(8) + "_" });
|
package/utils/l10n.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// 用于自定义的国际化支持
|
|
2
|
-
|
|
3
|
-
const language = $device.info.language;
|
|
4
|
-
|
|
5
|
-
const strings: Record<string, Record<string, string>> = {
|
|
6
|
-
"zh-Hans": {
|
|
7
|
-
DUPLICATE_VALUES: "取值重复",
|
|
8
|
-
DONE: "完成",
|
|
9
|
-
ADD: "添加",
|
|
10
|
-
SEARCH: "搜索",
|
|
11
|
-
PREVIOUS: "上一步",
|
|
12
|
-
NEXT: "下一步",
|
|
13
|
-
REMOVE: "移除",
|
|
14
|
-
EDIT: "编辑",
|
|
15
|
-
FINISHED: "完成",
|
|
16
|
-
INVALID_VALUES: "取值不合法",
|
|
17
|
-
CANCEL: "取消",
|
|
18
|
-
CLIPBOARD: "剪贴板",
|
|
19
|
-
OK: "好的",
|
|
20
|
-
},
|
|
21
|
-
en: {
|
|
22
|
-
DUPLICATE_VALUES: "Duplicate values",
|
|
23
|
-
DONE: "Done",
|
|
24
|
-
ADD: "Add",
|
|
25
|
-
SEARCH: "Search",
|
|
26
|
-
PREVIOUS: "Previous",
|
|
27
|
-
NEXT: "Next",
|
|
28
|
-
REMOVE: "Remove",
|
|
29
|
-
EDIT: "Edit",
|
|
30
|
-
FINISHED: "Finished",
|
|
31
|
-
INVALID_VALUES: "Invalid values",
|
|
32
|
-
CANCEL: "Cancel",
|
|
33
|
-
CLIPBOARD: "Clipboard",
|
|
34
|
-
OK: "OK",
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export function l10n(key: string) {
|
|
39
|
-
if (!strings[language]) return key;
|
|
40
|
-
const value = strings[language][key];
|
|
41
|
-
return value || key;
|
|
42
|
-
}
|
package/utils/path.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
// 用于处理路径的工具函数
|
|
2
|
-
|
|
3
|
-
function _splitProtocol(path: string): [string, string] {
|
|
4
|
-
const regex = /^\w+:\/\//;
|
|
5
|
-
const result = regex.exec(path);
|
|
6
|
-
if (result) {
|
|
7
|
-
const protocol = result[0];
|
|
8
|
-
return [protocol, path.slice(protocol.length)];
|
|
9
|
-
} else {
|
|
10
|
-
return ["", path];
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// 正规化
|
|
15
|
-
function _normalize(path: string): string {
|
|
16
|
-
if (!path) return "";
|
|
17
|
-
path = path.trim();
|
|
18
|
-
if (!path) return "";
|
|
19
|
-
const [protocol, remainingPath] = _splitProtocol(path);
|
|
20
|
-
return protocol + remainingPath.replace(/\/{2,}/g, "/");
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function split(path: string): [string, string] {
|
|
24
|
-
path = _normalize(path);
|
|
25
|
-
const [protocol, remainingPath] = _splitProtocol(path);
|
|
26
|
-
const lastIndex = remainingPath.lastIndexOf("/");
|
|
27
|
-
if (lastIndex === -1) {
|
|
28
|
-
return [protocol, remainingPath];
|
|
29
|
-
} else if (lastIndex === 0) {
|
|
30
|
-
return [protocol + "/", remainingPath.slice(1)];
|
|
31
|
-
} else {
|
|
32
|
-
return [protocol + remainingPath.slice(0, lastIndex), remainingPath.slice(lastIndex + 1)];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function dirname(path: string): string {
|
|
37
|
-
return split(path)[0];
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function basename(path: string): string {
|
|
41
|
-
return split(path)[1];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function extname(path: string): string {
|
|
45
|
-
const _basename = basename(path);
|
|
46
|
-
if (!_basename) return "";
|
|
47
|
-
const components = _basename.split(".");
|
|
48
|
-
if (components.length === 1) {
|
|
49
|
-
return "";
|
|
50
|
-
} else {
|
|
51
|
-
return "." + components.slice(-1)[0];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// 拼接目录
|
|
56
|
-
export function join(...args: string[]): string {
|
|
57
|
-
return args
|
|
58
|
-
.map((part, i) => {
|
|
59
|
-
if (i === 0) {
|
|
60
|
-
return part.trim().replace(/[/]*$/g, "");
|
|
61
|
-
} else {
|
|
62
|
-
return part.trim().replace(/(^[/]*|[/]*$)/g, "");
|
|
63
|
-
}
|
|
64
|
-
})
|
|
65
|
-
.filter((x) => x.length)
|
|
66
|
-
.join("/");
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function _getAttributes(path: string): {
|
|
70
|
-
NSFileCreationDate?: Date;
|
|
71
|
-
NSFileModificationDate?: Date;
|
|
72
|
-
NSFileSize?: number;
|
|
73
|
-
} {
|
|
74
|
-
if (!$file.exists(path)) throw new Error("invalid path");
|
|
75
|
-
path = $file.absolutePath(path);
|
|
76
|
-
const attributesOfItemAtPath = $objc("NSFileManager")
|
|
77
|
-
.invoke("defaultManager")
|
|
78
|
-
.invoke("attributesOfItemAtPath:error", path, null);
|
|
79
|
-
return attributesOfItemAtPath.jsValue();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function getCreationDate(path: string): number {
|
|
83
|
-
const { NSFileCreationDate } = _getAttributes(path);
|
|
84
|
-
if (!NSFileCreationDate) return 0;
|
|
85
|
-
return NSFileCreationDate.getTime();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function getModificationDate(path: string): number {
|
|
89
|
-
const { NSFileModificationDate } = _getAttributes(path);
|
|
90
|
-
if (!NSFileModificationDate) return 0;
|
|
91
|
-
return NSFileModificationDate.getTime();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export function getFileSize(path: string): number {
|
|
95
|
-
const { NSFileSize } = _getAttributes(path);
|
|
96
|
-
return NSFileSize || 0;
|
|
97
|
-
}
|
package/utils/rect.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// 用于处理矩形的工具函数
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* When called without arguments, return the center of the rectangle.
|
|
5
|
-
* When a Point is passed as an argument, the rectangle’s x and y values
|
|
6
|
-
* are adjusted, so that the new center of the rectangle is p.
|
|
7
|
-
*/
|
|
8
|
-
export function center(rect: JBRect, point?: JBPoint): JBPoint {
|
|
9
|
-
const { x = 0, y = 0, width: w, height: h } = rect;
|
|
10
|
-
if (!point) return $point(x + w / 2, y + h / 2);
|
|
11
|
-
const { x: px, y: py } = point;
|
|
12
|
-
rect.x = px - w / 2;
|
|
13
|
-
rect.y = py - h / 2;
|
|
14
|
-
return point;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Return true if the given point lies within the bounds of the rectangle,
|
|
19
|
-
* false otherwise.
|
|
20
|
-
*/
|
|
21
|
-
export function containsPoint(rect: JBRect, point: JBPoint): boolean {
|
|
22
|
-
const { x, y, width: w, height: h } = rect;
|
|
23
|
-
const { x: px, y: py } = point;
|
|
24
|
-
return x <= px && px <= x + w && y <= py && py <= y + h;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Return true if the given rectangle lies entirely within the bounds of
|
|
29
|
-
* this rectangle, false otherwise.
|
|
30
|
-
*/
|
|
31
|
-
export function containsRect(rect: JBRect, otherRect: JBRect): boolean {
|
|
32
|
-
const { x, y, width: w, height: h } = rect;
|
|
33
|
-
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
34
|
-
return x <= x1 && y <= y1 && x1 + w1 <= x + w && y1 + h1 <= y + h;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Return true if this rectangle intersects with the other rectangle,
|
|
39
|
-
* false otherwise.
|
|
40
|
-
*/
|
|
41
|
-
export function intersects(rect: JBRect, otherRect: JBRect): boolean {
|
|
42
|
-
const { x, y, width: w, height: h } = rect;
|
|
43
|
-
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
44
|
-
return x < x1 + w1 && x1 < x + w && y < y1 + h1 && y1 < y + h;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Return a $rect that corresponds to the intersection of this rectangle with
|
|
49
|
-
* the other one.
|
|
50
|
-
*/
|
|
51
|
-
export function intersection(rect: JBRect, otherRect: JBRect): JBRect {
|
|
52
|
-
const { x, y, width: w, height: h } = rect;
|
|
53
|
-
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
54
|
-
const nx = Math.max(x, x1);
|
|
55
|
-
const nw = Math.min(x + w, x1 + w1) - nx;
|
|
56
|
-
const ny = Math.max(y, y1);
|
|
57
|
-
const nh = Math.min(y + h, y1 + h1) - ny;
|
|
58
|
-
return $rect(nx, ny, nw, nh);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Return the smallest $rect that encloses both rectangles.
|
|
63
|
-
*/
|
|
64
|
-
export function union(rect: JBRect, otherRect: JBRect): JBRect {
|
|
65
|
-
const { x, y, width: w, height: h } = rect;
|
|
66
|
-
const { x: x1, y: y1, width: w1, height: h1 } = otherRect;
|
|
67
|
-
const nx = Math.min(x, x1);
|
|
68
|
-
const nw = Math.max(x + w, x1 + w1) - nx;
|
|
69
|
-
const ny = Math.min(y, y1);
|
|
70
|
-
const nh = Math.max(y + h, y1 + h1) - ny;
|
|
71
|
-
return $rect(nx, ny, nw, nh);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Equivalent to $rect(r.x + x, r.y + y, r.w, r.h)
|
|
76
|
-
*/
|
|
77
|
-
export function translate(rect: JBRect, point: JBPoint): JBRect {
|
|
78
|
-
const { x, y, width, height } = rect;
|
|
79
|
-
const { x: x1, y: y1 } = point;
|
|
80
|
-
return $rect(x + x1, y + y1, width, height);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Return a $rect that is adjusted by the given edge insets.
|
|
85
|
-
*/
|
|
86
|
-
export function inset(rect: JBRect, insets: JBInsets): JBRect {
|
|
87
|
-
const { x, y, width, height } = rect;
|
|
88
|
-
const { top, left, bottom, right } = insets;
|
|
89
|
-
return $rect(x + left, y + top, width - left - right, height - top - bottom);
|
|
90
|
-
}
|
package/utils/uitools.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
// 用于UI相关的工具函数
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 立即获得window size
|
|
5
|
-
*/
|
|
6
|
-
export function getWindowSize(): JBSize {
|
|
7
|
-
const window = $objc("UIWindow").$keyWindow().jsValue();
|
|
8
|
-
return window.size;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 获取单行字符串应有的宽度
|
|
13
|
-
* 默认额外添加3 inset
|
|
14
|
-
*/
|
|
15
|
-
export function getTextWidth(text: string, { font = $font(17), inset = 3 } = {}): number {
|
|
16
|
-
return (
|
|
17
|
-
Math.ceil(
|
|
18
|
-
$text.sizeThatFits({
|
|
19
|
-
text,
|
|
20
|
-
width: 10000,
|
|
21
|
-
font,
|
|
22
|
-
lineSpacing: 0,
|
|
23
|
-
}).width,
|
|
24
|
-
) + inset
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 获取字符串指定宽度后应有的高度
|
|
30
|
-
* 默认额外添加3 inset
|
|
31
|
-
*/
|
|
32
|
-
export function getTextHeight(
|
|
33
|
-
text: string,
|
|
34
|
-
{ width = 300, font = $font(17), inset = 3, lineSpacing = 0 } = {},
|
|
35
|
-
): number {
|
|
36
|
-
return (
|
|
37
|
-
Math.ceil(
|
|
38
|
-
$text.sizeThatFits({
|
|
39
|
-
text,
|
|
40
|
-
width,
|
|
41
|
-
font,
|
|
42
|
-
lineSpacing,
|
|
43
|
-
}).height,
|
|
44
|
-
) + inset
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* 计算某个view在某个上级view(若不指定则为UIWindow)上的绝对frame
|
|
50
|
-
* 此方法不考虑旋转变形等特殊情况
|
|
51
|
-
*/
|
|
52
|
-
export function absoluteFrame(view: AllUIView, endView?: AllUIView): JBRect {
|
|
53
|
-
const frame = view.frame;
|
|
54
|
-
let superView = view.super;
|
|
55
|
-
while (superView) {
|
|
56
|
-
frame.x += superView.frame.x - superView.bounds.x;
|
|
57
|
-
frame.y += superView.frame.y - superView.bounds.y;
|
|
58
|
-
if (endView && superView === endView) break;
|
|
59
|
-
superView = superView.super;
|
|
60
|
-
}
|
|
61
|
-
return frame;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export const layerCommonOptions = {
|
|
65
|
-
none: {
|
|
66
|
-
cornerRadius: 0,
|
|
67
|
-
shadowRadius: 0,
|
|
68
|
-
shadowOpacity: 0,
|
|
69
|
-
shadowOffset: $size(0, 0),
|
|
70
|
-
shadowColor: $color("clear"),
|
|
71
|
-
},
|
|
72
|
-
roundedShadow: {
|
|
73
|
-
cornerRadius: 12,
|
|
74
|
-
shadowRadius: 10,
|
|
75
|
-
shadowOpacity: 1,
|
|
76
|
-
shadowOffset: $size(0, 0),
|
|
77
|
-
shadowColor: $color("black"),
|
|
78
|
-
},
|
|
79
|
-
textShadow: {
|
|
80
|
-
cornerRadius: 0,
|
|
81
|
-
shadowRadius: 1.2,
|
|
82
|
-
shadowOpacity: 1,
|
|
83
|
-
shadowOffset: $size(0, 1),
|
|
84
|
-
shadowColor: $color("black"),
|
|
85
|
-
},
|
|
86
|
-
circleViewShadow: {
|
|
87
|
-
cornerRadius: 25,
|
|
88
|
-
shadowRadius: 3,
|
|
89
|
-
shadowOpacity: 0.6,
|
|
90
|
-
shadowOffset: $size(0, 3),
|
|
91
|
-
shadowColor: $color("black"),
|
|
92
|
-
},
|
|
93
|
-
toastShadows: {
|
|
94
|
-
cornerRadius: 15,
|
|
95
|
-
shadowRadius: 8,
|
|
96
|
-
shadowOpacity: 0.35,
|
|
97
|
-
shadowOffset: $size(0, 0),
|
|
98
|
-
shadowColor: $color("black"),
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* 在layout中使用
|
|
104
|
-
* 所应用的view不可以指定radius和clipTobounds,否则无效
|
|
105
|
-
*/
|
|
106
|
-
export function setLayer(
|
|
107
|
-
view: AllUIView,
|
|
108
|
-
{
|
|
109
|
-
cornerRadius = 0,
|
|
110
|
-
shadowRadius = 0,
|
|
111
|
-
shadowOpacity = 0,
|
|
112
|
-
shadowOffset = $size(0, 0),
|
|
113
|
-
shadowColor = $color("clear"),
|
|
114
|
-
} = {},
|
|
115
|
-
): void {
|
|
116
|
-
const layer = view.ocValue().invoke("layer");
|
|
117
|
-
layer.invoke("setCornerRadius", cornerRadius);
|
|
118
|
-
layer.invoke("setShadowRadius", shadowRadius);
|
|
119
|
-
layer.invoke("setShadowOpacity", shadowOpacity);
|
|
120
|
-
layer.invoke("setShadowOffset", shadowOffset);
|
|
121
|
-
layer.invoke("setShadowColor", shadowColor.ocValue().invoke("CGColor"));
|
|
122
|
-
}
|