seitu 0.14.0 → 0.14.1

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.
@@ -123,12 +123,11 @@ function tryParseJson(value) {
123
123
  //#endregion
124
124
  //#region src/validate.ts
125
125
  function validateSchema(schema, value, options) {
126
- const parsed = tryParseJson(value);
127
- const result = schema["~standard"].validate(parsed);
126
+ const result = schema["~standard"].validate(value);
128
127
  if (result instanceof Promise) throw new TypeError(`[${options.label}] Validation schema should not return a Promise.`);
129
128
  if (!result.issues) return result.value;
130
129
  if (options.onError) {
131
- const corrected = options.onError(result.issues, parsed);
130
+ const corrected = options.onError(result.issues, value);
132
131
  if (corrected !== void 0) {
133
132
  const validated = schema["~standard"].validate(corrected);
134
133
  if (validated instanceof Promise) throw new TypeError(`[${options.label}] Validation schema should not return a Promise.`);
@@ -161,7 +160,7 @@ function validateSchema(schema, value, options) {
161
160
  function createSchemaStore(options) {
162
161
  const store = createStore(options.defaultValue);
163
162
  const get = () => {
164
- const stored = store.get();
163
+ const stored = tryParseJson(store.get());
165
164
  return validateSchema(options.schema, stored, {
166
165
  defaultValue: options.defaultValue,
167
166
  label: "createSchemaStore",
package/dist/core.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { c as createDebounced, d as createSubscription, i as createSchemaStore, l as createComputed, n as createThrottled, r as createStore, s as createDebouncedFn, t as createThrottledFn, u as createReadableSubscription } from "./core-BKImMfak.mjs";
1
+ import { c as createDebounced, d as createSubscription, i as createSchemaStore, l as createComputed, n as createThrottled, r as createStore, s as createDebouncedFn, t as createThrottledFn, u as createReadableSubscription } from "./core-CwV8yAwb.mjs";
2
2
  export { createComputed, createDebounced, createDebouncedFn, createReadableSubscription, createSchemaStore, createStore, createSubscription, createThrottled, createThrottledFn };
package/dist/web.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as validateSchema, d as createSubscription, o as tryParseJson, u as createReadableSubscription } from "./core-BKImMfak.mjs";
1
+ import { a as validateSchema, d as createSubscription, o as tryParseJson, u as createReadableSubscription } from "./core-CwV8yAwb.mjs";
2
2
  import { t as repairValueObjectWithDefault } from "./validation-B8XxyKZ0.mjs";
3
3
  //#region src/web/is-online.ts
4
4
  /**
@@ -322,7 +322,7 @@ function createWebStorage(options) {
322
322
  for (const key of keys) {
323
323
  const raw = currentRaws[key];
324
324
  if (raw === null) output[key] = options.defaultValues[key];
325
- else output[key] = validateSchema(options.schemas[key], raw, {
325
+ else output[key] = validateSchema(options.schemas[key], tryParseJson(raw), {
326
326
  defaultValue: options.defaultValues[key],
327
327
  label: `createWebStorage:${String(key)}`,
328
328
  onError: options.onValidationError ? (issues, parsed) => options.onValidationError({
@@ -345,7 +345,7 @@ function createWebStorage(options) {
345
345
  const resolvedValue = typeof value === "function" ? value(get()) : value;
346
346
  const storage = window[options.type];
347
347
  Object.entries(resolvedValue).forEach(([key, value]) => {
348
- const storageValue = typeof value === "string" ? value : JSON.stringify(value);
348
+ const storageValue = JSON.stringify(value);
349
349
  storage.setItem(options.keyTransform ? options.keyTransform(key) : key, storageValue);
350
350
  window.dispatchEvent(new StorageEvent("storage", {
351
351
  key: options.keyTransform ? options.keyTransform(key) : key,
@@ -442,7 +442,7 @@ function createWebStorageValue(options) {
442
442
  if (typeof window === "undefined") return;
443
443
  const storage = window[type];
444
444
  const newValue = typeof value === "function" ? value(get()) : value;
445
- const storageValue = typeof newValue === "string" ? newValue : JSON.stringify(newValue);
445
+ const storageValue = JSON.stringify(newValue);
446
446
  storage.setItem(options.key, storageValue);
447
447
  window.dispatchEvent(new StorageEvent("storage", {
448
448
  key: options.key,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "seitu",
3
3
  "displayName": "Seitu",
4
4
  "type": "module",
5
- "version": "0.14.0",
5
+ "version": "0.14.1",
6
6
  "private": false,
7
7
  "author": "Valerii Strilets",
8
8
  "license": "MIT",