@valbuild/next 0.79.1 → 0.79.3

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.
@@ -19,6 +19,7 @@ export { ValProvider } from "./ValProvider.js";
19
19
  export { ValImage, type ValImageProps } from "./ValImage.js";
20
20
  export { ValApp } from "./ValApp.js";
21
21
  export type * as t from "./ValTypes.js";
22
+ export type { DecodeVal } from "./raw.js";
22
23
  export declare const Internal: {
23
24
  VERSION: {
24
25
  next: string | null;
@@ -0,0 +1,3 @@
1
+ import type { GenericSelector, SelectorOf, SelectorSource } from "@valbuild/core";
2
+ import { type StegaOfSource } from "@valbuild/react/stega";
3
+ export declare function getUnpatchedUnencodedVal<T extends SelectorSource>(selector: T): SelectorOf<T> extends GenericSelector<infer S> ? StegaOfSource<S> : never;
@@ -1,11 +1,25 @@
1
1
  import { type ValConfig, type InitVal, type ValConstructor, ValModule, SelectorSource, Json } from "@valbuild/core";
2
2
  import { raw } from "./raw.js";
3
+ import { getUnpatchedUnencodedVal } from "./getUnpatchedUnencodedVal.js";
3
4
  import { decodeValPathOfString } from "./decodeValPathOfString.js";
4
5
  type ValAttrs = {
5
6
  "data-val-path"?: string;
6
7
  };
7
8
  export declare const initVal: (config?: ValConfig) => InitVal & {
8
9
  val: ValConstructor & {
10
+ /**
11
+ * Returns the original module data, without any applied patches or stega encoding.
12
+ *
13
+ * This represents the raw, canonical state of the module as it was initially defined.
14
+ * NOTE: images and files, will be transformed (and will therefore) include the url property.
15
+ *
16
+ * ⚠️ Prefer using `fetchVal` (in React Server Components) or `useVal` (in React Client Components)
17
+ * for most application logic.
18
+ *
19
+ * This method is primarily intended for tooling and other advanced use cases
20
+ * outside of the actual application.
21
+ */
22
+ unstable_getUnpatchedUnencodedVal: typeof getUnpatchedUnencodedVal;
9
23
  raw: typeof raw;
10
24
  attrs: <T extends ValModule<SelectorSource> | Json>(target: T) => ValAttrs;
11
25
  unstable_decodeValPathOfString: typeof decodeValPathOfString;
@@ -1,2 +1,8 @@
1
- import { ValEncodedString } from "@valbuild/react/stega";
2
- export declare function raw(encodedString: ValEncodedString): string;
1
+ import { type RichTextSource, type RawString } from "@valbuild/core";
2
+ import { type RichText, type StegaOfRichTextSource, type ValEncodedString } from "@valbuild/react/stega";
3
+ export type DecodeVal<T> = T extends ValEncodedString | RawString ? string : T extends RichText<infer Options> ? StegaOfRichTextSource<RichTextSource<Options>> : T extends (a: infer A) => infer R ? (a: DecodeVal<A>) => DecodeVal<R> : T extends (a: infer A, b: infer B) => infer R ? (a: DecodeVal<A>, b: DecodeVal<B>) => DecodeVal<R> : T extends (a: infer A, b: infer B, c: infer C) => infer R ? (a: DecodeVal<A>, b: DecodeVal<B>, c: DecodeVal<C>) => DecodeVal<R> : T extends (a: infer A, b: infer B, c: infer C, d: infer D) => infer R ? (a: DecodeVal<A>, b: DecodeVal<B>, c: DecodeVal<C>, d: DecodeVal<D>) => DecodeVal<R> : T extends (a: infer A, b: infer B, c: infer C, d: infer D, e: infer E) => infer R ? (a: DecodeVal<A>, b: DecodeVal<B>, c: DecodeVal<C>, d: DecodeVal<D>, e: DecodeVal<E>) => DecodeVal<R> : T extends (...args: infer P) => infer R ? (...args: DecodeVal<P>) => DecodeVal<R> : T extends {
4
+ [key: string]: unknown;
5
+ } ? {
6
+ [K in keyof T]: DecodeVal<T[K]>;
7
+ } : T extends Array<infer U> ? DecodeVal<U>[] : T;
8
+ export declare function raw<T>(val: T): DecodeVal<T>;
@@ -45,8 +45,33 @@ function _typeof(o) {
45
45
  }, _typeof(o);
46
46
  }
47
47
 
48
- function raw(encodedString) {
49
- return stega.stegaClean(encodedString);
48
+ function raw(val) {
49
+ if (typeof val === "string") {
50
+ return stega.stegaClean(val);
51
+ }
52
+ if (Array.isArray(val)) {
53
+ return val.map(function (item) {
54
+ return raw(item);
55
+ });
56
+ }
57
+ if (_typeof(val) === "object" && val !== null) {
58
+ var result = {};
59
+ for (var _key in val) {
60
+ if (Object.prototype.hasOwnProperty.call(val, _key)) {
61
+ result[_key] = raw(val[_key]);
62
+ }
63
+ }
64
+ return result;
65
+ }
66
+ return val;
67
+ }
68
+
69
+ function getUnpatchedUnencodedVal(selector) {
70
+ // It is weird to use stega encode here since we never actually should stega encode,
71
+ // however, this is a workaround, since if it is disabled, it will behave as we want
72
+ return stega.stegaEncode(selector, {
73
+ disabled: true
74
+ });
50
75
  }
51
76
 
52
77
  function decodeValPathOfString(encodedString) {
@@ -86,7 +111,8 @@ var initVal = function initVal(config) {
86
111
  return {};
87
112
  },
88
113
  unstable_decodeValPathOfString: decodeValPathOfString,
89
- raw: raw
114
+ raw: raw,
115
+ unstable_getUnpatchedUnencodedVal: getUnpatchedUnencodedVal
90
116
  }),
91
117
  config: currentConfig
92
118
  };
@@ -45,8 +45,33 @@ function _typeof(o) {
45
45
  }, _typeof(o);
46
46
  }
47
47
 
48
- function raw(encodedString) {
49
- return stega.stegaClean(encodedString);
48
+ function raw(val) {
49
+ if (typeof val === "string") {
50
+ return stega.stegaClean(val);
51
+ }
52
+ if (Array.isArray(val)) {
53
+ return val.map(function (item) {
54
+ return raw(item);
55
+ });
56
+ }
57
+ if (_typeof(val) === "object" && val !== null) {
58
+ var result = {};
59
+ for (var _key in val) {
60
+ if (Object.prototype.hasOwnProperty.call(val, _key)) {
61
+ result[_key] = raw(val[_key]);
62
+ }
63
+ }
64
+ return result;
65
+ }
66
+ return val;
67
+ }
68
+
69
+ function getUnpatchedUnencodedVal(selector) {
70
+ // It is weird to use stega encode here since we never actually should stega encode,
71
+ // however, this is a workaround, since if it is disabled, it will behave as we want
72
+ return stega.stegaEncode(selector, {
73
+ disabled: true
74
+ });
50
75
  }
51
76
 
52
77
  function decodeValPathOfString(encodedString) {
@@ -86,7 +111,8 @@ var initVal = function initVal(config) {
86
111
  return {};
87
112
  },
88
113
  unstable_decodeValPathOfString: decodeValPathOfString,
89
- raw: raw
114
+ raw: raw,
115
+ unstable_getUnpatchedUnencodedVal: getUnpatchedUnencodedVal
90
116
  }),
91
117
  config: currentConfig
92
118
  };
@@ -3,7 +3,7 @@ import { initVal as initVal$1, Internal as Internal$1 } from '@valbuild/core';
3
3
  import * as core from '@valbuild/core';
4
4
  export { core as expr };
5
5
  export { FILE_REF_PROP, GenericSelector, Schema, VAL_EXTENSION, derefPatch, modules } from '@valbuild/core';
6
- import { stegaClean, stegaDecodeString, autoTagJSX } from '@valbuild/react/stega';
6
+ import { stegaClean, stegaEncode, stegaDecodeString, autoTagJSX } from '@valbuild/react/stega';
7
7
  export { ValRichText } from '@valbuild/react/internal';
8
8
  import { ValNextProvider } from './ValNextProvider-5f8b7338.esm.js';
9
9
  import NextImage from 'next/image';
@@ -21,8 +21,33 @@ function _typeof(o) {
21
21
  }, _typeof(o);
22
22
  }
23
23
 
24
- function raw(encodedString) {
25
- return stegaClean(encodedString);
24
+ function raw(val) {
25
+ if (typeof val === "string") {
26
+ return stegaClean(val);
27
+ }
28
+ if (Array.isArray(val)) {
29
+ return val.map(function (item) {
30
+ return raw(item);
31
+ });
32
+ }
33
+ if (_typeof(val) === "object" && val !== null) {
34
+ var result = {};
35
+ for (var _key in val) {
36
+ if (Object.prototype.hasOwnProperty.call(val, _key)) {
37
+ result[_key] = raw(val[_key]);
38
+ }
39
+ }
40
+ return result;
41
+ }
42
+ return val;
43
+ }
44
+
45
+ function getUnpatchedUnencodedVal(selector) {
46
+ // It is weird to use stega encode here since we never actually should stega encode,
47
+ // however, this is a workaround, since if it is disabled, it will behave as we want
48
+ return stegaEncode(selector, {
49
+ disabled: true
50
+ });
26
51
  }
27
52
 
28
53
  function decodeValPathOfString(encodedString) {
@@ -62,7 +87,8 @@ var initVal = function initVal(config) {
62
87
  return {};
63
88
  },
64
89
  unstable_decodeValPathOfString: decodeValPathOfString,
65
- raw: raw
90
+ raw: raw,
91
+ unstable_getUnpatchedUnencodedVal: getUnpatchedUnencodedVal
66
92
  }),
67
93
  config: currentConfig
68
94
  };
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "next",
9
9
  "react"
10
10
  ],
11
- "version": "0.79.1",
11
+ "version": "0.79.3",
12
12
  "scripts": {
13
13
  "typecheck": "tsc --noEmit",
14
14
  "test": "jest"
@@ -45,11 +45,11 @@
45
45
  "exports": true
46
46
  },
47
47
  "dependencies": {
48
- "@valbuild/core": "~0.79.1",
49
- "@valbuild/react": "~0.79.1",
50
- "@valbuild/server": "~0.79.1",
51
- "@valbuild/shared": "~0.79.1",
52
- "@valbuild/ui": "~0.79.1",
48
+ "@valbuild/core": "~0.79.3",
49
+ "@valbuild/react": "~0.79.3",
50
+ "@valbuild/server": "~0.79.3",
51
+ "@valbuild/shared": "~0.79.3",
52
+ "@valbuild/ui": "~0.79.3",
53
53
  "client-only": "^0.0.1",
54
54
  "server-only": "^0.0.1"
55
55
  },