@nhtio/encoder 0.1.0-master-258fa72f → 0.1.0-master-cf69c10e

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/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { i as isObject, a as isArray, b as isSet, c as isMap, d as isLuxonSystemZone, e as isLuxonInterval, f as isLuxonDuration, g as isLuxonDateTime, D as DateTime, h as isPhoneObject, j as isTypedArray, k as isBigIntTypedArray, l as isPrimitive, m as isUniterableObject, n as isError, o as isBigInt, p as isUnsafeInteger, q as isNegativeInfinity, r as isPositiveInfinity, s as isNegativeZero, I as Info, t as Interval, u as Duration, P as Phone } from "./type_guards-UkDoe__i.mjs";
1
+ import { i as isObject, a as isArray, b as isSet, c as isMap, d as isLuxonSystemZone, e as isLuxonInterval, f as isLuxonDuration, g as isLuxonDateTime, h as isPhoneObject, j as isTypedArray, k as isBigIntTypedArray, l as isPrimitive, m as isUniterableObject, n as isError, o as isBigInt, p as isUnsafeInteger, q as isNegativeInfinity, r as isPositiveInfinity, s as isNegativeZero, I as Info, t as Interval, D as DateTime, u as Duration, P as Phone } from "./type_guards-UkDoe__i.mjs";
2
2
  import { FunctionSerializer } from "./function_serializer.mjs";
3
- import { E as E_UNENCODABLE_VALUE, a as E_CIRCULAR_REFERENCE, b as E_ENCODING_FAILED, B as BaseException, c as E_UNDECODABLE_VALUE, d as E_NOT_AN_ENCODED_VALUE, e as E_INVALID_VERSION, f as E_INCOMPATIBLE_VERSION } from "./exceptions-DsdZSw0_.mjs";
3
+ import { E as E_UNENCODABLE_VALUE, a as E_CIRCULAR_REFERENCE, b as E_ENCODING_FAILED, B as BaseException, c as E_UNDECODABLE_VALUE, d as E_NOT_AN_ENCODED_VALUE, e as E_INVALID_VERSION, f as E_INCOMPATIBLE_VERSION } from "./exceptions-B6LwiRSz.mjs";
4
4
  var re = { exports: {} };
5
5
  var constants;
6
6
  var hasRequiredConstants;
@@ -3025,14 +3025,12 @@ const toStructuredData = (value, seen = /* @__PURE__ */ new WeakSet()) => {
3025
3025
  throw new E_CIRCULAR_REFERENCE();
3026
3026
  }
3027
3027
  seen.add(value);
3028
- const dto = value instanceof DateTime ? value : DateTime.fromObject(value.c, { zone: value.zone }).setLocale(
3029
- value.loc.locale
3030
- );
3028
+ const dto = value;
3031
3029
  return {
3032
3030
  _t: "luxon:DateTime",
3033
3031
  _s: toStructuredData(
3034
3032
  {
3035
- v: dto.toRFC2822(),
3033
+ v: dto.toMillis(),
3036
3034
  z: dto.zoneName,
3037
3035
  l: dto.locale,
3038
3036
  c: dto.outputCalendar,
@@ -3224,13 +3222,16 @@ const fromStructuredData = (data) => {
3224
3222
  }
3225
3223
  case "luxon:DateTime": {
3226
3224
  const obj = fromStructuredData(data._s);
3227
- return DateTime.fromRFC2822(obj.v, {
3228
- // setZone: true,
3225
+ const options2 = {
3229
3226
  zone: obj.z,
3230
3227
  locale: obj.l,
3231
3228
  outputCalendar: obj.c,
3232
3229
  numberingSystem: obj.n
3233
- });
3230
+ };
3231
+ if (typeof obj.v !== "number") {
3232
+ return DateTime.fromRFC2822(obj.v, options2);
3233
+ }
3234
+ return DateTime.fromMillis(obj.v, options2);
3234
3235
  }
3235
3236
  case "luxon:Duration": {
3236
3237
  const obj = fromStructuredData(data._s);
@@ -3267,11 +3268,11 @@ const { parse: $parse, stringify: $stringify } = JSON;
3267
3268
  const options = { json: true, lossy: true };
3268
3269
  const parse = (str) => deserialize($parse(str));
3269
3270
  const stringify = (any) => $stringify(serialize(any, options));
3270
- const version = "0.1.0-master-258fa72f";
3271
+ const version = "0.1.0-master-cf69c10e";
3271
3272
  const encode = (what) => {
3272
3273
  const structured = toStructuredData(what);
3273
3274
  const serialized = serialize(structured, { lossy: true, json: true });
3274
- const json = stringify({ version: "0.1.0-master-258fa72f", serialized });
3275
+ const json = stringify({ version: "0.1.0-master-cf69c10e", serialized });
3275
3276
  return utoa(json);
3276
3277
  };
3277
3278
  const decode = (base64) => {
@@ -3282,11 +3283,11 @@ const decode = (base64) => {
3282
3283
  throw new E_NOT_AN_ENCODED_VALUE(base64);
3283
3284
  }
3284
3285
  const { version: payloadVersion, serialized } = parsed;
3285
- if (semverExports.valid("0.1.0-master-258fa72f")) {
3286
+ if (semverExports.valid("0.1.0-master-cf69c10e")) {
3286
3287
  if (!semverExports.valid(semverExports.coerce(payloadVersion))) {
3287
3288
  throw new E_INVALID_VERSION(payloadVersion);
3288
3289
  }
3289
- if (semverExports.gt(semverExports.coerce(payloadVersion), "0.1.0-master-258fa72f")) {
3290
+ if (semverExports.gt(semverExports.coerce(payloadVersion), "0.1.0-master-cf69c10e")) {
3290
3291
  throw new E_INCOMPATIBLE_VERSION(payloadVersion);
3291
3292
  }
3292
3293
  }