@fumari/stf 1.0.3 → 1.0.5

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.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { t as FieldKey } from "./types-Do_aTV5I.js";
2
2
  import { ReactNode } from "react";
3
- import * as react_jsx_runtime0 from "react/jsx-runtime";
3
+ import * as _$react_jsx_runtime0 from "react/jsx-runtime";
4
4
 
5
5
  //#region src/lib/data-engine.d.ts
6
6
  type DefaultValue<T = unknown> = T | (() => T);
@@ -87,7 +87,7 @@ declare function StfProvider({
87
87
  }: {
88
88
  value: Stf;
89
89
  children: ReactNode;
90
- }): react_jsx_runtime0.JSX.Element;
90
+ }): _$react_jsx_runtime0.JSX.Element;
91
91
  declare function useStf(options: {
92
92
  /**
93
93
  * Note: the passed object will be modified in place, use `structuredClone()` to keep the original object unchanged.
package/dist/index.js CHANGED
@@ -1,9 +1,7 @@
1
- 'use client';
2
-
1
+ "use client";
3
2
  import { deepEqual, fieldKeyStartsWith, isPlainObject, objectGet, objectSet, stringifyFieldKey } from "./lib/utils.js";
4
3
  import { createContext, use, useEffect, useMemo, useRef, useState } from "react";
5
4
  import { jsx } from "react/jsx-runtime";
6
-
7
5
  //#region src/lib/data-engine.ts
8
6
  function getDefaultValue(defaultValue) {
9
7
  return typeof defaultValue === "function" ? defaultValue() : defaultValue;
@@ -106,7 +104,7 @@ var DataEngine = class DataEngine {
106
104
  } else {
107
105
  parentKey.push(key);
108
106
  this.listeners.onUpdate(parentKey, parentUpdateCtx);
109
- console.warn(`the original value of field ${parentKey.join(".")} is overidden, this might be unexpected.`);
107
+ console.warn(`the original value of field ${parentKey.join(".")} is overridden, this might be unexpected.`);
110
108
  }
111
109
  }
112
110
  }
@@ -176,7 +174,6 @@ var DataEngine = class DataEngine {
176
174
  for (const { engine, reset } of this.namespaces.values()) reset?.({ engine });
177
175
  }
178
176
  };
179
-
180
177
  //#endregion
181
178
  //#region src/lib/stf.tsx
182
179
  const Context = createContext(null);
@@ -346,6 +343,5 @@ function useNamespace(options) {
346
343
  engine.update([], getDefaultValue(initial));
347
344
  } });
348
345
  }
349
-
350
346
  //#endregion
351
- export { DataEngine, StfProvider, getDefaultValue, useArray, useDataEngine, useFieldValue, useListener, useNamespace, useObject, useStf };
347
+ export { DataEngine, StfProvider, getDefaultValue, useArray, useDataEngine, useFieldValue, useListener, useNamespace, useObject, useStf };
@@ -17,6 +17,10 @@ declare function stringifyFieldKey(fieldKey: FieldKey): string;
17
17
  * @returns if `a` starts with `b`.
18
18
  */
19
19
  declare function fieldKeyStartsWith(a: string, b: string): boolean;
20
+ /**
21
+ * @returns if `a` starts with `b`.
22
+ */
23
+ declare function arrayStartsWith(a: FieldKey, b: FieldKey): boolean;
20
24
  declare function isPlainObject(value: unknown): value is Record<string, unknown>;
21
25
  //#endregion
22
- export { deepEqual, fieldKeyStartsWith, isPlainObject, objectGet, objectSet, stringifyFieldKey };
26
+ export { arrayStartsWith, deepEqual, fieldKeyStartsWith, isPlainObject, objectGet, objectSet, stringifyFieldKey };
package/dist/lib/utils.js CHANGED
@@ -47,11 +47,19 @@ function stringifyFieldKey(fieldKey) {
47
47
  function fieldKeyStartsWith(a, b) {
48
48
  return b.length === 0 || a === b || a.startsWith(b + ".");
49
49
  }
50
+ /**
51
+ * @returns if `a` starts with `b`.
52
+ */
53
+ function arrayStartsWith(a, b) {
54
+ if (b.length === 0) return true;
55
+ if (a.length < b.length) return false;
56
+ for (let i = 0; i < b.length; i++) if (a[i] !== b[i]) return false;
57
+ return true;
58
+ }
50
59
  function isPlainObject(value) {
51
60
  if (typeof value !== "object" || value === null) return false;
52
61
  const prototype = Object.getPrototypeOf(value);
53
62
  return prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null;
54
63
  }
55
-
56
64
  //#endregion
57
- export { deepEqual, fieldKeyStartsWith, isPlainObject, objectGet, objectSet, stringifyFieldKey };
65
+ export { arrayStartsWith, deepEqual, fieldKeyStartsWith, isPlainObject, objectGet, objectSet, stringifyFieldKey };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fumari/stf",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Schema to Form.",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -19,10 +19,9 @@
19
19
  "access": "public"
20
20
  },
21
21
  "devDependencies": {
22
- "@types/node": "25.3.3",
22
+ "@types/node": "25.6.0",
23
23
  "@types/react": "^19.2.14",
24
- "tsdown": "0.20.3",
25
- "eslint-config-custom": "0.0.0",
24
+ "tsdown": "0.21.7",
26
25
  "tsconfig": "0.0.0"
27
26
  },
28
27
  "peerDependencies": {
@@ -39,7 +38,7 @@
39
38
  "build": "tsdown",
40
39
  "clean": "rimraf dist",
41
40
  "dev": "tsdown --watch",
42
- "lint": "eslint .",
41
+ "lint": "oxlint .",
43
42
  "types:check": "tsc --noEmit"
44
43
  }
45
44
  }