ph-utils 0.13.0 → 0.13.2

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/lib/dom.d.ts CHANGED
@@ -21,7 +21,7 @@ export declare function $(selector: string | HTMLElement, dom?: DocumentContext)
21
21
  /**
22
22
  * 创建一个 HTML 元素,支持通过标签名或 HTML 字符串创建。
23
23
  * @param tag - 元素标签名或 HTML 字符串。
24
- * @param option - 元素的属性、样式、文本内容等配置。
24
+ * @param option - 元素的属性、样式、文本内容等配置。所有不是指定的属性,都会通过 setAttribute 设置
25
25
  * @param ctx - 元素的父级文档上下文。
26
26
  * @returns 创建的 HTML 元素。
27
27
  */
package/lib/dom.js CHANGED
@@ -18,7 +18,7 @@ export function $(selector, dom) {
18
18
  /**
19
19
  * 创建一个 HTML 元素,支持通过标签名或 HTML 字符串创建。
20
20
  * @param tag - 元素标签名或 HTML 字符串。
21
- * @param option - 元素的属性、样式、文本内容等配置。
21
+ * @param option - 元素的属性、样式、文本内容等配置。所有不是指定的属性,都会通过 setAttribute 设置
22
22
  * @param ctx - 元素的父级文档上下文。
23
23
  * @returns 创建的 HTML 元素。
24
24
  */
@@ -454,22 +454,25 @@ export function transition(el, nameOrProperties, dir = "enter", finish) {
454
454
  }
455
455
  if (dir === "enter") {
456
456
  if (nameClass) {
457
- el.classList.add(nameClass, activeClass);
457
+ el.classList.add(nameClass);
458
+ setTimeout(() => {
459
+ el.classList.add(activeClass);
460
+ requestAnimationFrame(() => {
461
+ el.classList.remove(nameClass);
462
+ });
463
+ }, 0);
458
464
  }
459
465
  else {
460
466
  toggleCssProperty(el, nameOrProperties, "set");
461
- if (trans.length > 0) {
462
- el.style.setProperty("transition", trans.join(", "));
463
- }
467
+ setTimeout(() => {
468
+ if (trans.length > 0) {
469
+ el.style.setProperty("transition", trans.join(", "));
470
+ }
471
+ requestAnimationFrame(() => {
472
+ toggleCssProperty(el, nameOrProperties, "remove");
473
+ });
474
+ }, 0);
464
475
  }
465
- requestAnimationFrame(() => {
466
- if (nameClass) {
467
- el.classList.remove(nameClass);
468
- }
469
- else {
470
- toggleCssProperty(el, nameOrProperties, "remove");
471
- }
472
- });
473
476
  }
474
477
  else {
475
478
  if (nameClass) {
package/lib/server.d.ts CHANGED
@@ -35,4 +35,4 @@ export declare function exec(command: string, args?: string[], options?: SpawnOp
35
35
  *
36
36
  * @returns
37
37
  */
38
- export declare function parseEnvs(): Record<string, string>;
38
+ export declare function parseEnvs(envFiles?: string[]): Record<string, string>;
package/lib/server.js CHANGED
@@ -47,9 +47,9 @@ export function exec(command, ...params) {
47
47
  *
48
48
  * @returns
49
49
  */
50
- export function parseEnvs() {
50
+ export function parseEnvs(envFiles = [".env", ".env.local"]) {
51
51
  // development, test, production
52
- const files = [".env", ".env.local"];
52
+ const files = [...envFiles];
53
53
  let nodeEnv = process.env.NODE_ENV;
54
54
  const { values } = parseArgs({
55
55
  options: {
@@ -67,20 +67,23 @@ export function parseEnvs() {
67
67
  nodeEnv = "production";
68
68
  }
69
69
  process.env.NODE_ENV = nodeEnv;
70
- files.push(`.env.${nodeEnv}`);
70
+ const envFile = `.env.${nodeEnv}`;
71
+ if (!files.includes(envFile)) {
72
+ files.push(envFile);
73
+ }
71
74
  let envParsed = {};
72
75
  for (let i = 0, len = files.length; i < len; i++) {
73
76
  const file = files[i];
74
77
  try {
75
78
  const envContent = readFileSync(file, { encoding: "utf-8" });
76
79
  const envValue = parseEnv(envContent);
77
- envParsed = { ...envParsed, ...envValue };
80
+ for (const key in envValue) {
81
+ process.env[key] = envValue[key];
82
+ envParsed[key] = envValue[key];
83
+ }
78
84
  // eslint-disable-next-line
79
85
  }
80
86
  catch (err) { }
81
87
  }
82
- for (const key in envParsed) {
83
- process.env[key] = envParsed[key];
84
- }
85
88
  return envParsed;
86
89
  }
package/package.json CHANGED
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "./*": "./lib/*"
70
70
  },
71
- "version": "0.13.0",
71
+ "version": "0.13.2",
72
72
  "type": "module",
73
73
  "repository": {
74
74
  "type": "git",