webpb 0.0.25 → 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,r,o=[]){if(!(!e||!r||typeof e!="object"||typeof r!="object"))for(const[i,n]of Object.entries(e))n!==void 0&&o.indexOf(i)<0&&(r[i]=n)}function c(e,r){if(e==null||typeof e!="object")return null;for(const o of r.split("."))if(e=e[o],e==null)return null;return e}function l(e,r){const o=[],i=(n,t)=>{n&&t&&o.push(`${n}=${encodeURIComponent(t)}`)};for(const[n,t]of Object.entries(r))if(!(t==null||typeof t=="function"))if(Array.isArray(t))i(n,t.join(","));else if(typeof t=="object")for(const u of Object.keys(t)){const f=t[u];u&&i(n,f?u+","+f:u)}else i(n,String(t));return o.length?`${e}${o.join("&")}`:""}function y(e,r){if(!e||typeof e!="object"||Array.isArray(e))return e;const o={};for(const[i,n]of Object.entries(e)){const t=n?.toAlias;typeof t=="function"?o[i]=t():r&&r[i]?o[r[i]]=n:o[i]=n}return o}function p(e,r){return Object.entries(e).reduce((o,[i,n])=>(o[i]=r(n),o),{})}exports.assign=s;exports.getter=c;exports.mapValues=p;exports.query=l;exports.toAlias=y;
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,50 +1,66 @@
1
- function c(e, r, o = []) {
2
- if (!(!e || !r || typeof e != "object" || typeof r != "object"))
3
- for (const [i, n] of Object.entries(e))
4
- n !== void 0 && o.indexOf(i) < 0 && (r[i] = n);
5
- }
6
- function s(e, r) {
7
- if (e == null || typeof e != "object")
8
- return null;
9
- for (const o of r.split("."))
10
- if (e = e[o], e == null)
11
- return null;
12
- return e;
13
- }
14
- function l(e, r) {
15
- const o = [], i = (n, t) => {
16
- n && t && o.push(`${n}=${encodeURIComponent(t)}`);
17
- };
18
- for (const [n, t] of Object.entries(r))
19
- if (!(t == null || typeof t == "function"))
20
- if (Array.isArray(t))
21
- i(n, t.join(","));
22
- else if (typeof t == "object")
23
- for (const f of Object.keys(t)) {
24
- const u = t[f];
25
- f && i(n, u ? f + "," + u : f);
26
- }
27
- else
28
- i(n, String(t));
29
- return o.length ? `${e}${o.join("&")}` : "";
30
- }
31
- function y(e, r) {
32
- if (!e || typeof e != "object" || Array.isArray(e))
33
- return e;
34
- const o = {};
35
- for (const [i, n] of Object.entries(e)) {
36
- const t = n?.toAlias;
37
- typeof t == "function" ? o[i] = t() : r && r[i] ? o[r[i]] = n : o[i] = n;
38
- }
39
- return o;
40
- }
41
- function p(e, r) {
42
- return Object.entries(e).reduce((o, [i, n]) => (o[i] = r(n), o), {});
43
- }
44
- export {
45
- c as assign,
46
- s as getter,
47
- p as mapValues,
48
- l as query,
49
- y as toAlias
50
- };
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,6 +1,6 @@
1
1
  {
2
2
  "name": "webpb",
3
- "version": "0.0.25",
3
+ "version": "0.0.26",
4
4
  "description": "The webpb runtime library",
5
5
  "scripts": {
6
6
  "build": "rimraf build/**/* && tsc && vite build && dts-bundle-generator --config ./dts-bundle-generator.config.cjs && copyfiles ./README.md ./package.json build",
@@ -8,6 +8,8 @@
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": "^2.0.2",
39
- "@types/node": "^25.1.0",
40
- "@typescript-eslint/eslint-plugin": "^8.54.0",
41
- "@typescript-eslint/parser": "^8.54.0",
42
- "@vitest/coverage-v8": "^4.0.18",
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.39.2",
45
+ "eslint": "^10.4.1",
46
46
  "eslint-config-prettier": "^10.1.8",
47
- "eslint-plugin-import": "^2.32.0",
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-perfectionist": "^4.15.0",
50
51
  "eslint-plugin-prettier": "^5.5.5",
51
- "eslint-plugin-sort-keys-fix": "^1.1.2",
52
- "prettier": "^3.8.1",
52
+ "globals": "^14.0.0",
53
+ "prettier": "^3.8.4",
53
54
  "pretty-quick": "^4.2.2",
54
- "rimraf": "^6.1.2",
55
+ "rimraf": "^6.1.3",
55
56
  "ts-node": "^10.9.2",
56
- "typescript": "^5.9.3",
57
- "typescript-eslint": "^8.54.0",
58
- "vite": "^7.3.1",
59
- "vitest": "^4.0.18"
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
  }