Skip to content

Commit

Permalink
feat: update core&next package to next15 and react19. build fail: mis…
Browse files Browse the repository at this point in the history
…matching types in vite-react
  • Loading branch information
jacobdubail committed Dec 3, 2024
1 parent 3d543e4 commit 5dd0feb
Show file tree
Hide file tree
Showing 8 changed files with 1,138 additions and 1,285 deletions.
2,120 changes: 980 additions & 1,140 deletions package-lock.json

Large diffs are not rendered by default.

180 changes: 90 additions & 90 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,92 +1,92 @@
{
"name": "@headstartwp/core",
"version": "1.5.0-next.7",
"description": "`@headstartwp/core` is the core package that houses framework-agnostic components and utilities for building headless sites with WordPress.",
"homepage": "https://github.com/10up/headstartwp/blob/develop/packages/core/README.md",
"license": "MIT",
"author": "10up <[email protected]> (https://10up.com/)",
"main": "dist/cjs/index.js",
"source": "src/index.ts",
"types": "dist/mjs/index.d.ts",
"typedocMain": "src/docs-entry-point.ts",
"publishConfig": {
"access": "public"
},
"exports": {
".": {
"require": "./dist/cjs/index.js",
"import": "./dist/mjs/index.js",
"types": "./dist/mjs/index.d.ts"
},
"./utils": {
"require": "./dist/cjs/utils/index.js",
"import": "./dist/mjs/utils/index.js",
"types": "./dist/mjs/utils/index.d.ts"
},
"./react": {
"react-server": {
"import": "./dist/mjs/rsc/index.js",
"require": "./dist/cjs/rsc/index.js",
"types": "./dist/mjs/rsc/index.d.ts"
},
"require": "./dist/cjs/react/index.js",
"import": "./dist/mjs/react/index.js",
"types": "./dist/mjs/react/index.d.ts"
},
"./rsc": {
"import": "./dist/mjs/rsc/index.js",
"require": "./dist/cjs/rsc/index.js",
"types": "./dist/mjs/rsc/index.d.ts"
},
"./test": "./test/server.ts"
},
"files": [
"dist",
"react.d.ts",
"react.js",
"test.d.ts",
"utils.d.ts",
"utils.js"
],
"sideEffects": false,
"scripts": {
"postbuild": "tsc-esm-fix --target dist/mjs && node ../../scripts/package.js",
"build": "npm run ts && npm run ts:cjs",
"ts:cjs": "tsc -b tsconfig-cjs.json",
"ts": "tsc -b",
"dev": "concurrently \"npm run watch:ts:cjs\" \"npm run watch:ts\"",
"watch:ts:cjs": "npm run ts:cjs -- --watch",
"watch:ts": "npm run ts -- --watch",
"test": "jest",
"test:watch": "jest --watch",
"lint": "eslint src/"
},
"devDependencies": {
"@testing-library/dom": "^10.3.1",
"@testing-library/react": "^16.0.0",
"@types/jest": "^29.0.3",
"@types/node-fetch": "^2.5.3",
"expect-type": "^0.15.0",
"jest": "^29.3.1",
"msw": "^0.35.0",
"ts-jest": "^29.0.3",
"typescript": "^5.5.3",
"isomorphic-fetch": "^3.0.0",
"tsc-esm-fix": "^2.20.27",
"@types/react": "^18",
"@types/react-dom": "^18"
},
"dependencies": {
"@justinribeiro/lite-youtube": "^1.3.1",
"html-react-parser": "^3.0.4",
"path-to-regexp": "^6.2.0",
"react-inspector": "^6.0.1",
"swr": "^2.2.5",
"xss": "^1.0.15",
"deepmerge": "^4.3.1",
"schema-dts": "^1.1.2"
},
"peerDependencies": {
"react": ">= 17.0.2"
}
"name": "@headstartwp/core",
"version": "1.5.0-next.7",
"description": "`@headstartwp/core` is the core package that houses framework-agnostic components and utilities for building headless sites with WordPress.",
"homepage": "https://github.com/10up/headstartwp/blob/develop/packages/core/README.md",
"license": "MIT",
"author": "10up <[email protected]> (https://10up.com/)",
"main": "dist/cjs/index.js",
"source": "src/index.ts",
"types": "dist/mjs/index.d.ts",
"typedocMain": "src/docs-entry-point.ts",
"publishConfig": {
"access": "public"
},
"exports": {
".": {
"require": "./dist/cjs/index.js",
"import": "./dist/mjs/index.js",
"types": "./dist/mjs/index.d.ts"
},
"./utils": {
"require": "./dist/cjs/utils/index.js",
"import": "./dist/mjs/utils/index.js",
"types": "./dist/mjs/utils/index.d.ts"
},
"./react": {
"react-server": {
"import": "./dist/mjs/rsc/index.js",
"require": "./dist/cjs/rsc/index.js",
"types": "./dist/mjs/rsc/index.d.ts"
},
"require": "./dist/cjs/react/index.js",
"import": "./dist/mjs/react/index.js",
"types": "./dist/mjs/react/index.d.ts"
},
"./rsc": {
"import": "./dist/mjs/rsc/index.js",
"require": "./dist/cjs/rsc/index.js",
"types": "./dist/mjs/rsc/index.d.ts"
},
"./test": "./test/server.ts"
},
"files": [
"dist",
"react.d.ts",
"react.js",
"test.d.ts",
"utils.d.ts",
"utils.js"
],
"sideEffects": false,
"scripts": {
"postbuild": "tsc-esm-fix --target dist/mjs && node ../../scripts/package.js",
"build": "npm run ts && npm run ts:cjs",
"ts:cjs": "tsc -b tsconfig-cjs.json",
"ts": "tsc -b",
"dev": "concurrently \"npm run watch:ts:cjs\" \"npm run watch:ts\"",
"watch:ts:cjs": "npm run ts:cjs -- --watch",
"watch:ts": "npm run ts -- --watch",
"test": "jest",
"test:watch": "jest --watch",
"lint": "eslint src/"
},
"devDependencies": {
"@testing-library/dom": "^10.3.1",
"@testing-library/react": "^16.0.0",
"@types/jest": "^29.0.3",
"@types/node-fetch": "^2.5.3",
"expect-type": "^0.15.0",
"jest": "^29.3.1",
"msw": "^0.35.0",
"ts-jest": "^29.0.3",
"typescript": "^5.5.3",
"isomorphic-fetch": "^3.0.0",
"tsc-esm-fix": "^2.20.27",
"@types/react": "npm:[email protected]",
"@types/react-dom": "npm:[email protected]"
},
"dependencies": {
"@justinribeiro/lite-youtube": "^1.3.1",
"html-react-parser": "^3.0.4",
"path-to-regexp": "^6.2.0",
"react-inspector": "^6.0.1",
"swr": "^2.2.5",
"xss": "^1.0.15",
"deepmerge": "^4.3.1",
"schema-dts": "^1.1.2"
},
"peerDependencies": {
"react": ">= 19.0.0"
}
}
17 changes: 12 additions & 5 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@
"@headstartwp/core": "^1.5.0-next.6",
"loader-utils": "^3.2.0",
"schema-utils": "^4.0.0",
"@isaacs/ttlcache": "^1.4.1"
"@isaacs/ttlcache": "^1.4.1",
"next": "15.0.3",
"react": "19.0.0-rc-66855b96-20241106",
"react-dom": "19.0.0-rc-66855b96-20241106"
},
"devDependencies": {
"@testing-library/dom": "^10.3.1",
Expand All @@ -77,11 +80,15 @@
"isomorphic-fetch": "^3.0.0",
"jest-fetch-mock": "^3.0.3",
"tsc-esm-fix": "^2.20.27",
"@types/react": "^18",
"@types/react-dom": "^18"
"@types/react": "npm:[email protected]",
"@types/react-dom": "npm:[email protected]"
},
"peerDependencies": {
"next": ">= 12.0.0",
"react": ">= 17.0.2"
"next": "15.0.3",
"react": "19.0.0-rc-66855b96-20241106"
},
"overrides": {
"@types/react": "npm:[email protected]",
"@types/react-dom": "npm:[email protected]"
}
}
9 changes: 6 additions & 3 deletions packages/next/src/rsc/actions/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { redirect } from 'next/navigation';
import { COOKIE_NAME } from '../handlers/previewRouteHandler';

export async function disableDraftMode() {
const currentUrl = headers().get('x-headstartwp-current-url') ?? '/';
draftMode().disable();
cookies().delete(COOKIE_NAME);
const cookieStore = await cookies();
const headerStore = await headers();
const draftmode = await draftMode();
const currentUrl = headerStore.get('x-headstartwp-current-url') ?? '/';
draftmode.disable();
cookieStore.delete(COOKIE_NAME);
redirect(currentUrl);
}
4 changes: 2 additions & 2 deletions packages/next/src/rsc/components/PreviewIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ export type PreviewIndicatorProps = {
className?: string;
};

export const PreviewIndicator: React.FC<PreviewIndicatorProps> = ({ className }) => {
const { isEnabled } = draftMode();
export const PreviewIndicator: React.FC<PreviewIndicatorProps> = async ({ className }) => {
const { isEnabled } = await draftMode();

if (!isEnabled) {
return null;
Expand Down
9 changes: 5 additions & 4 deletions packages/next/src/rsc/data/queries/queryPost.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ export async function queryPost<
const { config, handleError, ...query } = prepareQuery<P>(nextQuery, _config);

try {
const { isEnabled } = draftMode();
const { isEnabled, disable } = await draftMode();
const cookieStore = await cookies();

if (isEnabled) {
// the cookie will only exist for the previewed path
if (cookies().has(COOKIE_NAME)) {
if (cookieStore.has(COOKIE_NAME)) {
const previewData: PreviewData = JSON.parse(
cookies().get(COOKIE_NAME)?.value ?? '{}',
cookieStore.get(COOKIE_NAME)?.value ?? '{}',
);

if (!query.params) {
Expand All @@ -49,7 +50,7 @@ export async function queryPost<
}
} else {
// if draft mode was enabled but no preview cookie was found, disable draft mode
draftMode().disable();
disable();
}
}

Expand Down
6 changes: 4 additions & 2 deletions packages/next/src/rsc/handlers/previewRouteHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ export async function previewRouteHandler(
const is_revision = searchParams.get('is_revision');
const token = searchParams.get('token');
const locale = searchParams.get('locale');
const cookieStore = await cookies();
const draftmode = await draftMode();

// check if post_id, post_type and token is set
if (!post_id || !token || !post_type) {
Expand Down Expand Up @@ -214,14 +216,14 @@ export async function previewRouteHandler(
})
: defaultRedirectPath;

cookies().set(COOKIE_NAME, JSON.stringify(previewData), {
cookieStore.set(COOKIE_NAME, JSON.stringify(previewData), {
maxAge: 5 * 60,
// remove trailing slash
path: redirectPath.replace(/\/$/, ''),
httpOnly: true,
});

draftMode().enable();
draftmode.enable();

if (typeof options.onRedirect === 'function') {
options.onRedirect({
Expand Down
78 changes: 39 additions & 39 deletions projects/wp-multisite-i18n-nextjs/package.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
{
"name": "@10up/wp-multisite-i18n-nextjs",
"version": "0.2.0",
"description": "This is a [Next.js](https://nextjs.org/) project bootstrapped with 10up's Headless Framework.",
"homepage": "https://github.com/10up/headstartwp/blob/develop/projects/wp-multisite-i18n-nextjs/README.md",
"license": "GPL-2.0-or-later",
"author": "10up <[email protected]> (https://10up.com/)",
"private": true,
"scripts": {
"dev": "next dev -p 3002",
"build": "next build",
"build:analyze": "ANALYZE=true next build",
"start": "next start",
"lint": "eslint ."
},
"dependencies": {
"@headstartwp/core": "^1.5.0-next.7",
"@headstartwp/next": "^1.5.0-next.7",
"@linaria/core": "^6.2.0",
"@linaria/react": "^6.2.1",
"clsx": "^1.1.1",
"next": "^14.2.5",
"nprogress": "^0.2.0",
"prop-types": "^15.7.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@wyw-in-js/babel-preset": "0.5.4",
"@wyw-in-js/webpack-loader": "^0.5.4",
"@10up/eslint-config": "^4.0.0",
"@next/bundle-analyzer": "^12.1.0",
"@types/react": "^18",
"@types/react-dom": "^18"
},
"engineStrict": true,
"engines": {
"node": ">=18.0.0",
"npm": ">=9.0.0"
}
"name": "@10up/wp-multisite-i18n-nextjs",
"version": "0.2.0",
"description": "This is a [Next.js](https://nextjs.org/) project bootstrapped with 10up's Headless Framework.",
"homepage": "https://github.com/10up/headstartwp/blob/develop/projects/wp-multisite-i18n-nextjs/README.md",
"license": "GPL-2.0-or-later",
"author": "10up <[email protected]> (https://10up.com/)",
"private": true,
"scripts": {
"dev": "next dev -p 3002",
"build": "next build",
"build:analyze": "ANALYZE=true next build",
"start": "next start",
"lint": "eslint ."
},
"dependencies": {
"@headstartwp/core": "^1.5.0-next.7",
"@headstartwp/next": "^1.5.0-next.7",
"@linaria/core": "^6.2.0",
"@linaria/react": "^6.2.1",
"clsx": "^1.1.1",
"next": "^14.2.5",
"nprogress": "^0.2.0",
"prop-types": "^15.7.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@wyw-in-js/babel-preset": "0.5.4",
"@wyw-in-js/webpack-loader": "^0.5.4",
"@10up/eslint-config": "^4.0.0",
"@next/bundle-analyzer": "^12.1.0",
"@types/react": "npm:[email protected]",
"@types/react-dom": "npm:[email protected]"
},
"engineStrict": true,
"engines": {
"node": ">=18.0.0",
"npm": ">=9.0.0"
}
}

0 comments on commit 5dd0feb

Please sign in to comment.