webpb 0.0.19 → 0.0.20
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/{index.d.ts → dist/index.d.ts} +14 -11
- package/dist/webpb.iife.js +1 -0
- package/dist/webpb.js +51 -0
- package/package.json +18 -5
- package/index.js +0 -84
|
@@ -1,25 +1,28 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
1
3
|
export type Constructor<T> = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
+
new (): T;
|
|
5
|
+
fromAlias<T, D>(this: Constructor<T>, data: Partial<D>): T;
|
|
4
6
|
};
|
|
5
|
-
type AnyObject = Record<string | number, unknown>;
|
|
7
|
+
export type AnyObject = Record<string | number, unknown>;
|
|
6
8
|
export interface WebpbMessage {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
webpbMeta(): WebpbMeta;
|
|
10
|
+
toWebpbAlias(): unknown;
|
|
9
11
|
}
|
|
10
12
|
export interface WebpbMeta {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
class: string;
|
|
14
|
+
method: string;
|
|
15
|
+
context: string;
|
|
16
|
+
path: string;
|
|
15
17
|
}
|
|
16
18
|
export declare function assign(src: unknown, dest: unknown, excludes?: string[]): void;
|
|
17
19
|
export declare function getter(data: unknown, path: string): unknown;
|
|
18
20
|
export declare function query(pre: string, params: {
|
|
19
|
-
|
|
21
|
+
[key: string]: unknown;
|
|
20
22
|
}): string;
|
|
21
23
|
export declare function toAlias(data: unknown, aliases: {
|
|
22
|
-
|
|
24
|
+
[key: string]: string;
|
|
23
25
|
}): unknown;
|
|
24
26
|
export declare function mapValues(record: AnyObject, mapping: (v: unknown) => unknown): AnyObject;
|
|
27
|
+
|
|
25
28
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var webpb=function(i){"use strict";function u(e,o,n){if(!(!e||!o||typeof e!="object"||typeof o!="object"))for(const[r,t]of Object.entries(e))t!==void 0&&!c(r,n)&&(o[r]=t)}function c(e,o){if(!o)return!1;for(const n of o)if(n===e)return!0;return!1}function l(e,o){if(e==null||typeof e!="object")return null;for(const n of o.split("."))if(e=e[n],e==null)return e;return e}function s(e,o){const n=[];for(const[r,t]of Object.entries(o)){if(t==null||typeof t=="function")continue;const f=encodeURIComponent(String(t));f&&n.push(`${r}=${f}`)}return n.length?`${e}${n.join("&")}`:""}function y(e,o){if(!e||typeof e!="object"||Array.isArray(e))return e;const n={};for(const[r,t]of Object.entries(e)){const f=t==null?void 0:t.toAlias;typeof f=="function"?n[r]=f():o&&o[r]?n[o[r]]=t:n[r]=t}return n}function b(e,o){return Object.entries(e).reduce((n,[r,t])=>(n[r]=o(t),n),{})}return i.assign=u,i.getter=l,i.mapValues=b,i.query=s,i.toAlias=y,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}),i}({});
|
package/dist/webpb.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
function u(e, o, n) {
|
|
2
|
+
if (!(!e || !o || typeof e != "object" || typeof o != "object"))
|
|
3
|
+
for (const [r, t] of Object.entries(e))
|
|
4
|
+
t !== void 0 && !i(r, n) && (o[r] = t);
|
|
5
|
+
}
|
|
6
|
+
function i(e, o) {
|
|
7
|
+
if (!o)
|
|
8
|
+
return !1;
|
|
9
|
+
for (const n of o)
|
|
10
|
+
if (n === e)
|
|
11
|
+
return !0;
|
|
12
|
+
return !1;
|
|
13
|
+
}
|
|
14
|
+
function c(e, o) {
|
|
15
|
+
if (e == null || typeof e != "object")
|
|
16
|
+
return null;
|
|
17
|
+
for (const n of o.split("."))
|
|
18
|
+
if (e = e[n], e == null)
|
|
19
|
+
return e;
|
|
20
|
+
return e;
|
|
21
|
+
}
|
|
22
|
+
function s(e, o) {
|
|
23
|
+
const n = [];
|
|
24
|
+
for (const [r, t] of Object.entries(o)) {
|
|
25
|
+
if (t == null || typeof t == "function")
|
|
26
|
+
continue;
|
|
27
|
+
const f = encodeURIComponent(String(t));
|
|
28
|
+
f && n.push(`${r}=${f}`);
|
|
29
|
+
}
|
|
30
|
+
return n.length ? `${e}${n.join("&")}` : "";
|
|
31
|
+
}
|
|
32
|
+
function l(e, o) {
|
|
33
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
34
|
+
return e;
|
|
35
|
+
const n = {};
|
|
36
|
+
for (const [r, t] of Object.entries(e)) {
|
|
37
|
+
const f = t == null ? void 0 : t.toAlias;
|
|
38
|
+
typeof f == "function" ? n[r] = f() : o && o[r] ? n[o[r]] = t : n[r] = t;
|
|
39
|
+
}
|
|
40
|
+
return n;
|
|
41
|
+
}
|
|
42
|
+
function y(e, o) {
|
|
43
|
+
return Object.entries(e).reduce((n, [r, t]) => (n[r] = o(t), n), {});
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
u as assign,
|
|
47
|
+
c as getter,
|
|
48
|
+
y as mapValues,
|
|
49
|
+
s as query,
|
|
50
|
+
l as toAlias
|
|
51
|
+
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webpb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"description": "The webpb runtime library",
|
|
5
|
-
"
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
7
6
|
"scripts": {
|
|
8
|
-
"build": "tsc &&
|
|
7
|
+
"build": "rimraf build/**/* && tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.ts && copyfiles ./README.md ./package.json build",
|
|
9
8
|
"check": "npm run lint && npm run test",
|
|
10
9
|
"lint": "eslint --quiet src/**/*.ts",
|
|
11
10
|
"lint:fix": "eslint --fix src/**/*.ts",
|
|
@@ -22,12 +21,23 @@
|
|
|
22
21
|
"type": "git",
|
|
23
22
|
"url": "https://github.com/jinganix/webpb"
|
|
24
23
|
},
|
|
24
|
+
"module": "./dist/webpb.js",
|
|
25
|
+
"type": "module",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"import": "./dist/webpb.js"
|
|
29
|
+
},
|
|
30
|
+
"./dist/": {
|
|
31
|
+
"import": "./dist/"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
25
34
|
"devDependencies": {
|
|
26
35
|
"@eslint/compat": "^1.2.4",
|
|
27
36
|
"@types/jest": "^29.5.14",
|
|
28
37
|
"@types/node": "^22.10.1",
|
|
29
38
|
"@typescript-eslint/eslint-plugin": "^8.17.0",
|
|
30
39
|
"@typescript-eslint/parser": "^8.17.0",
|
|
40
|
+
"dts-bundle-generator": "^9.5.1",
|
|
31
41
|
"eslint": "^9.16.0",
|
|
32
42
|
"eslint-config-prettier": "^9.1.0",
|
|
33
43
|
"eslint-plugin-import": "^2.31.0",
|
|
@@ -38,9 +48,12 @@
|
|
|
38
48
|
"jest": "^29.7.0",
|
|
39
49
|
"prettier": "^3.4.2",
|
|
40
50
|
"pretty-quick": "^4.0.0",
|
|
51
|
+
"rimraf": "^6.0.1",
|
|
52
|
+
"copyfiles": "^2.4.1",
|
|
41
53
|
"ts-jest": "^29.2.5",
|
|
42
54
|
"ts-node": "^10.9.2",
|
|
43
55
|
"typescript": "^5.7.2",
|
|
44
|
-
"typescript-eslint": "^8.17.0"
|
|
56
|
+
"typescript-eslint": "^8.17.0",
|
|
57
|
+
"vite": "^6.0.3"
|
|
45
58
|
}
|
|
46
59
|
}
|
package/index.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assign = assign;
|
|
4
|
-
exports.getter = getter;
|
|
5
|
-
exports.query = query;
|
|
6
|
-
exports.toAlias = toAlias;
|
|
7
|
-
exports.mapValues = mapValues;
|
|
8
|
-
function assign(src, dest, excludes) {
|
|
9
|
-
if (!src || !dest || typeof src !== "object" || typeof dest !== "object") {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
for (var _i = 0, _a = Object.entries(src); _i < _a.length; _i++) {
|
|
13
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
14
|
-
if (value !== undefined && !isExcluded(key, excludes)) {
|
|
15
|
-
dest[key] = value;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function isExcluded(k, excludes) {
|
|
20
|
-
if (!excludes) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
for (var _i = 0, excludes_1 = excludes; _i < excludes_1.length; _i++) {
|
|
24
|
-
var o = excludes_1[_i];
|
|
25
|
-
if (o === k) {
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
function getter(data, path) {
|
|
32
|
-
if (data === null || data === undefined || typeof data !== "object") {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
for (var _i = 0, _a = path.split("."); _i < _a.length; _i++) {
|
|
36
|
-
var key = _a[_i];
|
|
37
|
-
data = data[key];
|
|
38
|
-
if (data === null || data === undefined) {
|
|
39
|
-
return data;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return data;
|
|
43
|
-
}
|
|
44
|
-
function query(pre, params) {
|
|
45
|
-
var queries = [];
|
|
46
|
-
for (var _i = 0, _a = Object.entries(params); _i < _a.length; _i++) {
|
|
47
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
48
|
-
if (value === null || value === undefined || typeof value === "function") {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
var encoded = encodeURIComponent(String(value));
|
|
52
|
-
if (encoded) {
|
|
53
|
-
queries.push("".concat(key, "=").concat(encoded));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
return queries.length ? "".concat(pre).concat(queries.join("&")) : "";
|
|
57
|
-
}
|
|
58
|
-
function toAlias(data, aliases) {
|
|
59
|
-
if (!data || typeof data !== "object" || Array.isArray(data)) {
|
|
60
|
-
return data;
|
|
61
|
-
}
|
|
62
|
-
var obj = {};
|
|
63
|
-
for (var _i = 0, _a = Object.entries(data); _i < _a.length; _i++) {
|
|
64
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
65
|
-
var toAlias_1 = value === null || value === void 0 ? void 0 : value.toAlias;
|
|
66
|
-
if (typeof toAlias_1 === "function") {
|
|
67
|
-
obj[key] = toAlias_1();
|
|
68
|
-
}
|
|
69
|
-
else if (aliases && aliases[key]) {
|
|
70
|
-
obj[aliases[key]] = value;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
obj[key] = value;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return obj;
|
|
77
|
-
}
|
|
78
|
-
function mapValues(record, mapping) {
|
|
79
|
-
return Object.entries(record).reduce(function (acc, _a) {
|
|
80
|
-
var key = _a[0], value = _a[1];
|
|
81
|
-
acc[key] = mapping(value);
|
|
82
|
-
return acc;
|
|
83
|
-
}, {});
|
|
84
|
-
}
|