remix-typedjson
Advanced tools
Comparing version 0.4.1 to 0.5.1-pre.0
@@ -19,20 +19,17 @@ import { jsx as _jsx } from "react/jsx-runtime"; | ||
// resolved data and add the meta to the response | ||
Object.entries(data).forEach(([key, value]) => { | ||
let d = data; | ||
Object.entries(d).forEach(([key, value]) => { | ||
if (value instanceof Promise) { | ||
; | ||
data[key] = value.then(resolvedData => { | ||
const { meta } = _typedjson.serialize(resolvedData); | ||
d[key] = value.then(resolvedData => { | ||
let rd = resolvedData; | ||
const { meta } = _typedjson.serialize(rd); | ||
if (meta) { | ||
; | ||
resolvedData['$$meta'] = meta; | ||
rd['$$meta'] = meta; | ||
} | ||
return resolvedData; | ||
return rd; | ||
}); | ||
} | ||
else { | ||
const { meta } = _typedjson.serialize(data); | ||
if (meta) { | ||
; | ||
data['$$meta'] = meta; | ||
} | ||
const { meta } = _typedjson.serialize(data); | ||
if (meta) { | ||
d['$$meta'] = meta; | ||
} | ||
@@ -99,5 +96,5 @@ }); | ||
// handle object with $$meta key | ||
// remove before applying meta | ||
// no longer remove $$meta as Remix will stringify the data again | ||
// during defer and we will lose the type data | ||
const meta = data.$$meta; | ||
delete data.$$meta; | ||
return _typedjson.applyMeta(data, meta); | ||
@@ -104,0 +101,0 @@ } |
@@ -120,3 +120,9 @@ let customTypeMap = new Map(); | ||
} | ||
const json = JSON.stringify(data, replacer); | ||
let json = ''; | ||
if (Array.isArray(data)) { | ||
json = JSON.stringify(data.map(value => serialize(value))); | ||
} | ||
else { | ||
json = JSON.stringify(data, replacer); | ||
} | ||
return { | ||
@@ -123,0 +129,0 @@ json, |
{ | ||
"name": "remix-typedjson", | ||
"version": "0.4.1", | ||
"version": "0.5.1-pre.0", | ||
"description": "This package is a replacement for superjson to use in your Remix app. It handles a subset of types that `superjson` supports, but is faster and smaller.", | ||
"browser": "/dist/esm/index.js", | ||
"main": "./dist/index.js", | ||
"type": "module", | ||
"exports": { | ||
"require": "./dist/cjs/index.js", | ||
"import": "./dist/esm/index.js" | ||
}, | ||
"main": "./dist/cjs/index.js", | ||
"sideEffects": false, | ||
@@ -26,4 +30,4 @@ "author": "Michael J. Carter <kiliman@gmail.com> (https://kiliman.dev/)", | ||
"build": "npm run build:esm && npm run build:cjs", | ||
"build:esm": "tsc --project tsconfig.build.json --module ESNext --outDir ./dist/esm", | ||
"build:cjs": "tsc --project tsconfig.build.json --module CommonJS --outDir ./dist", | ||
"build:esm": "tsc --project tsconfig.build.json --module ESNext --outDir ./dist/esm && echo '{\"type\": \"module\"}' > ./dist/esm/package.json", | ||
"build:cjs": "tsc --project tsconfig.build.json --module CommonJS --outDir ./dist/csj && echo '{\"type\": \"commonjs\"}' > ./dist/csj/package.json", | ||
"typecheck": "tsc --project tsconfig.json --noEmit", | ||
@@ -53,2 +57,3 @@ "lint": "eslint --ext .ts,.tsx src/", | ||
"jest": "^29.7.0", | ||
"jest-environment-jsdom": "^29.7.0", | ||
"prettier": "^3.1.0", | ||
@@ -55,0 +60,0 @@ "react": "^18.2.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Yes
56754
22
1006
1