webpb 0.0.24 → 0.0.26

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/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function s(e,t,o=[]){if(!(!e||!t||typeof e!="object"||typeof t!="object"))for(const[r,n]of Object.entries(e))n!==void 0&&o.indexOf(r)<0&&(t[r]=n)}function l(e,t){if(e==null||typeof e!="object")return null;for(const o of t.split("."))if(e=e[o],e==null)return null;return e}function y(e,t){const o=[];for(const[r,n]of Object.entries(t)){if(n==null||typeof n=="function")continue;let i;Array.isArray(n)?i=n.join(","):typeof n=="object"?i=Object.entries(n).filter(([f])=>f!=="").map(([f,c])=>`${f},${c}`).join(";"):i=String(n);const u=encodeURIComponent(i);u&&o.push(`${r}=${u}`)}return o.length?`${e}${o.join("&")}`:""}function j(e,t){if(!e||typeof e!="object"||Array.isArray(e))return e;const o={};for(const[r,n]of Object.entries(e)){const i=n==null?void 0:n.toAlias;typeof i=="function"?o[r]=i():t&&t[r]?o[t[r]]=n:o[r]=n}return o}function p(e,t){return Object.entries(e).reduce((o,[r,n])=>(o[r]=t(n),o),{})}exports.assign=s;exports.getter=l;exports.mapValues=p;exports.query=y;exports.toAlias=j;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){if(typeof e!=`object`||!e||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function t(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function n(e){if(!t(e))return;let n=e;if(typeof n.toAlias==`function`)return n.toAlias.bind(e);if(typeof n.toWebpbAlias==`function`)return n.toWebpbAlias.bind(e)}function r(e){return n(e)!==void 0}function i(e){let t=n(e);return t?t():e}function a(n,r,i=[]){if(!e(n)||!t(r))return;let a=new Set(i);for(let[e,t]of Object.entries(n))t!==void 0&&!a.has(e)&&(r[e]=t)}function o(e,n){if(e==null)return null;let r=n.split(`.`).filter(e=>e.length>0);if(r.length===0)return e;let i=e;for(let e of r)if(!t(i)||(i=i[e],i==null))return null;return i}function s(t,n){let r=[],i=(e,t)=>{e&&t&&r.push(`${e}=${encodeURIComponent(t)}`)};for(let[t,r]of Object.entries(n))if(!(r==null||typeof r==`function`)){if(Array.isArray(r)){r.length>0&&i(t,r.join(`,`));continue}if(e(r)){for(let e of Object.keys(r)){let n=r[e];n==null||n===``?e&&i(t,e):e&&i(t,`${e},${n}`)}continue}i(t,String(r))}return r.length?`${t}${r.join(`&`)}`:``}function c(t,n){if(!e(t))return t;let a={};for(let[e,o]of Object.entries(t))r(o)?a[e]=i(o):n[e]?a[n[e]]=o:a[e]=o;return a}function l(t,n){return e(t)?Object.entries(t).reduce((e,[t,r])=>(e[t]=n(r),e),{}):{}}exports.assign=a,exports.getter=o,exports.mapValues=l,exports.query=s,exports.toAlias=c;
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  export type Constructor<T> = {
4
4
  new (): T;
5
- fromAlias<T, D>(this: Constructor<T>, data: Partial<D>): T;
5
+ fromAlias(data?: unknown): T;
6
6
  };
7
7
  export type AnyObject = Record<string | number, unknown>;
8
8
  export interface WebpbMessage {
@@ -15,7 +15,7 @@ export interface WebpbMeta {
15
15
  context: string;
16
16
  path: string;
17
17
  }
18
- export declare function assign(src: unknown, dest: unknown, excludes?: string[]): void;
18
+ export declare function assign(src: unknown, dest: unknown, excludes?: readonly string[]): void;
19
19
  export declare function getter(data: unknown, path: string): unknown;
20
20
  export declare function query(pre: string, params: {
21
21
  [key: string]: unknown;
@@ -23,6 +23,6 @@ export declare function query(pre: string, params: {
23
23
  export declare function toAlias(data: unknown, aliases: {
24
24
  [key: string]: string;
25
25
  }): unknown;
26
- export declare function mapValues(record: AnyObject, mapping: (v: unknown) => unknown): AnyObject;
26
+ export declare function mapValues(record: AnyObject | null | undefined, mapping: (v: unknown) => unknown): AnyObject;
27
27
 
28
28
  export {};
package/dist/index.mjs CHANGED
@@ -1,45 +1,66 @@
1
- function l(e, t, o = []) {
2
- if (!(!e || !t || typeof e != "object" || typeof t != "object"))
3
- for (const [r, n] of Object.entries(e))
4
- n !== void 0 && o.indexOf(r) < 0 && (t[r] = n);
5
- }
6
- function s(e, t) {
7
- if (e == null || typeof e != "object")
8
- return null;
9
- for (const o of t.split("."))
10
- if (e = e[o], e == null)
11
- return null;
12
- return e;
13
- }
14
- function y(e, t) {
15
- const o = [];
16
- for (const [r, n] of Object.entries(t)) {
17
- if (n == null || typeof n == "function")
18
- continue;
19
- let i;
20
- Array.isArray(n) ? i = n.join(",") : typeof n == "object" ? i = Object.entries(n).filter(([f]) => f !== "").map(([f, c]) => `${f},${c}`).join(";") : i = String(n);
21
- const u = encodeURIComponent(i);
22
- u && o.push(`${r}=${u}`);
23
- }
24
- return o.length ? `${e}${o.join("&")}` : "";
25
- }
26
- function j(e, t) {
27
- if (!e || typeof e != "object" || Array.isArray(e))
28
- return e;
29
- const o = {};
30
- for (const [r, n] of Object.entries(e)) {
31
- const i = n == null ? void 0 : n.toAlias;
32
- typeof i == "function" ? o[r] = i() : t && t[r] ? o[t[r]] = n : o[r] = n;
33
- }
34
- return o;
35
- }
36
- function p(e, t) {
37
- return Object.entries(e).reduce((o, [r, n]) => (o[r] = t(n), o), {});
38
- }
39
- export {
40
- l as assign,
41
- s as getter,
42
- p as mapValues,
43
- y as query,
44
- j as toAlias
45
- };
1
+ //#region src/index.ts
2
+ function e(e) {
3
+ if (typeof e != "object" || !e || Array.isArray(e)) return !1;
4
+ let t = Object.getPrototypeOf(e);
5
+ return t === null || t === Object.prototype;
6
+ }
7
+ function t(e) {
8
+ return typeof e == "object" && !!e && !Array.isArray(e);
9
+ }
10
+ function n(e) {
11
+ if (!t(e)) return;
12
+ let n = e;
13
+ if (typeof n.toAlias == "function") return n.toAlias.bind(e);
14
+ if (typeof n.toWebpbAlias == "function") return n.toWebpbAlias.bind(e);
15
+ }
16
+ function r(e) {
17
+ return n(e) !== void 0;
18
+ }
19
+ function i(e) {
20
+ let t = n(e);
21
+ return t ? t() : e;
22
+ }
23
+ function a(n, r, i = []) {
24
+ if (!e(n) || !t(r)) return;
25
+ let a = new Set(i);
26
+ for (let [e, t] of Object.entries(n)) t !== void 0 && !a.has(e) && (r[e] = t);
27
+ }
28
+ function o(e, n) {
29
+ if (e == null) return null;
30
+ let r = n.split(".").filter((e) => e.length > 0);
31
+ if (r.length === 0) return e;
32
+ let i = e;
33
+ for (let e of r) if (!t(i) || (i = i[e], i == null)) return null;
34
+ return i;
35
+ }
36
+ function s(t, n) {
37
+ let r = [], i = (e, t) => {
38
+ e && t && r.push(`${e}=${encodeURIComponent(t)}`);
39
+ };
40
+ for (let [t, r] of Object.entries(n)) if (!(r == null || typeof r == "function")) {
41
+ if (Array.isArray(r)) {
42
+ r.length > 0 && i(t, r.join(","));
43
+ continue;
44
+ }
45
+ if (e(r)) {
46
+ for (let e of Object.keys(r)) {
47
+ let n = r[e];
48
+ n == null || n === "" ? e && i(t, e) : e && i(t, `${e},${n}`);
49
+ }
50
+ continue;
51
+ }
52
+ i(t, String(r));
53
+ }
54
+ return r.length ? `${t}${r.join("&")}` : "";
55
+ }
56
+ function c(t, n) {
57
+ if (!e(t)) return t;
58
+ let a = {};
59
+ for (let [e, o] of Object.entries(t)) r(o) ? a[e] = i(o) : n[e] ? a[n[e]] = o : a[e] = o;
60
+ return a;
61
+ }
62
+ function l(t, n) {
63
+ return e(t) ? Object.entries(t).reduce((e, [t, r]) => (e[t] = n(r), e), {}) : {};
64
+ }
65
+ //#endregion
66
+ export { a as assign, o as getter, l as mapValues, s as query, c as toAlias };
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "webpb",
3
- "version": "0.0.24",
3
+ "version": "0.0.26",
4
4
  "description": "The webpb runtime library",
5
5
  "scripts": {
6
- "build": "rimraf build/**/* && tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.ts && copyfiles ./README.md ./package.json build",
6
+ "build": "rimraf build/**/* && tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.cjs && copyfiles ./README.md ./package.json build",
7
7
  "check": "npm run lint && npm run test",
8
8
  "lint": "eslint --quiet src/**/*.ts",
9
9
  "lint:fix": "eslint --fix src/**/*.ts",
10
10
  "deploy": "npm run check && npm run build && npm publish ./build --access public",
11
+ "publish": "npm run sync-version && npm run build && npm publish ./build --access public",
12
+ "sync-version": "node scripts/sync-version.mjs",
11
13
  "test": "vitest --coverage"
12
14
  },
13
15
  "author": "jinganix@gmail.com",
@@ -21,41 +23,40 @@
21
23
  "url": "https://github.com/jinganix/webpb"
22
24
  },
23
25
  "type": "module",
26
+ "sideEffects": false,
24
27
  "main": "./dist/index.cjs",
25
28
  "module": "./dist/index.mjs",
26
29
  "types": "./dist/index.d.ts",
27
30
  "exports": {
28
- ".": [
29
- {
30
- "types": "./dist/index.d.ts",
31
- "import": "./dist/index.mjs",
32
- "require": "./dist/index.cjs"
33
- },
34
- "./dist/index.cjs"
35
- ]
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.mjs",
34
+ "require": "./dist/index.cjs"
35
+ }
36
36
  },
37
37
  "devDependencies": {
38
- "@eslint/compat": "^1.2.4",
39
- "@types/node": "^22.10.2",
40
- "@typescript-eslint/eslint-plugin": "^8.18.2",
41
- "@typescript-eslint/parser": "^8.18.2",
42
- "@vitest/coverage-v8": "^2.1.8",
38
+ "@eslint/js": "^10.0.1",
39
+ "@types/node": "^25.9.3",
40
+ "@typescript-eslint/eslint-plugin": "^8.59.4",
41
+ "@typescript-eslint/parser": "^8.59.4",
42
+ "@vitest/coverage-v8": "^4.1.7",
43
43
  "copyfiles": "^2.4.1",
44
44
  "dts-bundle-generator": "^9.5.1",
45
- "eslint": "^9.17.0",
46
- "eslint-config-prettier": "^9.1.0",
47
- "eslint-plugin-import": "^2.31.0",
45
+ "eslint": "^10.4.1",
46
+ "eslint-config-prettier": "^10.1.8",
48
47
  "eslint-plugin-import-quotes": "^0.0.1",
48
+ "eslint-plugin-import-x": "^4.16.2",
49
49
  "eslint-plugin-no-null": "^1.0.2",
50
- "eslint-plugin-prettier": "^5.2.1",
51
- "eslint-plugin-sort-keys-fix": "^1.1.2",
52
- "prettier": "^3.4.2",
53
- "pretty-quick": "^4.0.0",
54
- "rimraf": "^6.0.1",
50
+ "eslint-plugin-perfectionist": "^4.15.0",
51
+ "eslint-plugin-prettier": "^5.5.5",
52
+ "globals": "^14.0.0",
53
+ "prettier": "^3.8.4",
54
+ "pretty-quick": "^4.2.2",
55
+ "rimraf": "^6.1.3",
55
56
  "ts-node": "^10.9.2",
56
- "typescript": "^5.7.2",
57
- "typescript-eslint": "^8.18.2",
58
- "vite": "^6.0.5",
59
- "vitest": "^2.1.8"
57
+ "typescript": "^6.0.3",
58
+ "typescript-eslint": "^8.59.4",
59
+ "vite": "^8.0.14",
60
+ "vitest": "^4.1.7"
60
61
  }
61
62
  }