@payloadcms/next 3.39.0-internal.32c7661 → 3.39.0-internal.8827ce8
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/dist/auth/login.d.ts.map +1 -1
- package/dist/auth/login.js.map +1 -1
- package/dist/auth/logout.d.ts +4 -2
- package/dist/auth/logout.d.ts.map +1 -1
- package/dist/auth/logout.js +26 -7
- package/dist/auth/logout.js.map +1 -1
- package/dist/auth/refresh.d.ts +1 -3
- package/dist/auth/refresh.d.ts.map +1 -1
- package/dist/auth/refresh.js +24 -12
- package/dist/auth/refresh.js.map +1 -1
- package/dist/views/LivePreview/Device/index.d.ts.map +1 -1
- package/dist/views/LivePreview/Device/index.js +0 -2
- package/dist/views/LivePreview/Device/index.js.map +1 -1
- package/package.json +8 -7
package/dist/auth/login.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/auth/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/auth/login.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM7C,KAAK,cAAc,GAAG;IACpB,UAAU,EAAE,cAAc,CAAA;IAC1B,MAAM,EAAE,GAAG,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAA;CACjB,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,UAAU,EAAE,cAAc,CAAA;IAC1B,MAAM,EAAE,GAAG,CAAA;IACX,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AACD,KAAK,SAAS,GAAG,cAAc,GAAG,iBAAiB,CAAA;AAEnD,wBAAsB,KAAK,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,SAAS,GAAG,OAAO,CAAC;IACjG,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,GAAG,CAAA;CACV,CAAC,CAyDD"}
|
package/dist/auth/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","names":["getPayload","setPayloadAuthCookie","login","collection","config","email","password","username","payload","authConfig","collections","auth","Error","loginWithUsername","allowEmailLogin","loginData","result","data","token","cookiePrefix","removeTokenFromResponses","e","console","error"],"sources":["../../src/auth/login.ts"],"sourcesContent":["'use server'\n\nimport type { CollectionSlug } from 'payload'\n\nimport {
|
|
1
|
+
{"version":3,"file":"login.js","names":["getPayload","setPayloadAuthCookie","login","collection","config","email","password","username","payload","authConfig","collections","auth","Error","loginWithUsername","allowEmailLogin","loginData","result","data","token","cookiePrefix","removeTokenFromResponses","e","console","error"],"sources":["../../src/auth/login.ts"],"sourcesContent":["'use server'\n\nimport type { CollectionSlug } from 'payload'\n\nimport { getPayload } from 'payload'\n\nimport { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js'\n\ntype LoginWithEmail = {\n collection: CollectionSlug\n config: any\n email: string\n password: string\n username?: never\n}\n\ntype LoginWithUsername = {\n collection: CollectionSlug\n config: any\n email?: never\n password: string\n username: string\n}\ntype LoginArgs = LoginWithEmail | LoginWithUsername\n\nexport async function login({ collection, config, email, password, username }: LoginArgs): Promise<{\n token?: string\n user: any\n}> {\n const payload = await getPayload({ config })\n\n const authConfig = payload.collections[collection]?.config.auth\n if (!authConfig) {\n throw new Error(`No auth config found for collection: ${collection}`)\n }\n\n const loginWithUsername = authConfig?.loginWithUsername ?? false\n\n if (loginWithUsername) {\n if (loginWithUsername.allowEmailLogin) {\n if (!email && !username) {\n throw new Error('Email or username is required.')\n }\n } else {\n if (!username) {\n throw new Error('Username is required.')\n }\n }\n } else {\n if (!email) {\n throw new Error('Email is required.')\n }\n }\n\n let loginData\n\n if (loginWithUsername) {\n loginData = username ? { password, username } : { email, password }\n } else {\n loginData = { email, password }\n }\n\n try {\n const result = await payload.login({\n collection,\n data: loginData,\n })\n\n if (result.token) {\n await setPayloadAuthCookie({\n authConfig,\n cookiePrefix: payload.config.cookiePrefix,\n token: result.token,\n })\n }\n\n if ('removeTokenFromResponses' in config && config.removeTokenFromResponses) {\n delete result.token\n }\n\n return result\n } catch (e) {\n console.error('Login error:', e)\n throw new Error(`${e}`)\n }\n}\n"],"mappings":"AAAA;;AAIA,SAASA,UAAU,QAAQ;AAE3B,SAASC,oBAAoB,QAAQ;AAmBrC,OAAO,eAAeC,MAAM;EAAEC,UAAU;EAAEC,MAAM;EAAEC,KAAK;EAAEC,QAAQ;EAAEC;AAAQ,CAAa;EAItF,MAAMC,OAAA,GAAU,MAAMR,UAAA,CAAW;IAAEI;EAAO;EAE1C,MAAMK,UAAA,GAAaD,OAAA,CAAQE,WAAW,CAACP,UAAA,CAAW,EAAEC,MAAA,CAAOO,IAAA;EAC3D,IAAI,CAACF,UAAA,EAAY;IACf,MAAM,IAAIG,KAAA,CAAM,wCAAwCT,UAAA,EAAY;EACtE;EAEA,MAAMU,iBAAA,GAAoBJ,UAAA,EAAYI,iBAAA,IAAqB;EAE3D,IAAIA,iBAAA,EAAmB;IACrB,IAAIA,iBAAA,CAAkBC,eAAe,EAAE;MACrC,IAAI,CAACT,KAAA,IAAS,CAACE,QAAA,EAAU;QACvB,MAAM,IAAIK,KAAA,CAAM;MAClB;IACF,OAAO;MACL,IAAI,CAACL,QAAA,EAAU;QACb,MAAM,IAAIK,KAAA,CAAM;MAClB;IACF;EACF,OAAO;IACL,IAAI,CAACP,KAAA,EAAO;MACV,MAAM,IAAIO,KAAA,CAAM;IAClB;EACF;EAEA,IAAIG,SAAA;EAEJ,IAAIF,iBAAA,EAAmB;IACrBE,SAAA,GAAYR,QAAA,GAAW;MAAED,QAAA;MAAUC;IAAS,IAAI;MAAEF,KAAA;MAAOC;IAAS;EACpE,OAAO;IACLS,SAAA,GAAY;MAAEV,KAAA;MAAOC;IAAS;EAChC;EAEA,IAAI;IACF,MAAMU,MAAA,GAAS,MAAMR,OAAA,CAAQN,KAAK,CAAC;MACjCC,UAAA;MACAc,IAAA,EAAMF;IACR;IAEA,IAAIC,MAAA,CAAOE,KAAK,EAAE;MAChB,MAAMjB,oBAAA,CAAqB;QACzBQ,UAAA;QACAU,YAAA,EAAcX,OAAA,CAAQJ,MAAM,CAACe,YAAY;QACzCD,KAAA,EAAOF,MAAA,CAAOE;MAChB;IACF;IAEA,IAAI,8BAA8Bd,MAAA,IAAUA,MAAA,CAAOgB,wBAAwB,EAAE;MAC3E,OAAOJ,MAAA,CAAOE,KAAK;IACrB;IAEA,OAAOF,MAAA;EACT,EAAE,OAAOK,CAAA,EAAG;IACVC,OAAA,CAAQC,KAAK,CAAC,gBAAgBF,CAAA;IAC9B,MAAM,IAAIT,KAAA,CAAM,GAAGS,CAAA,EAAG;EACxB;AACF","ignoreList":[]}
|
package/dist/auth/logout.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { SanitizedConfig } from 'payload';
|
|
2
|
+
export declare function logout({ allSessions, config, }: {
|
|
3
|
+
allSessions?: boolean;
|
|
4
|
+
config: Promise<SanitizedConfig> | SanitizedConfig;
|
|
3
5
|
}): Promise<{
|
|
4
6
|
message: string;
|
|
5
7
|
success: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/auth/logout.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/auth/logout.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAO/C,wBAAsB,MAAM,CAAC,EAC3B,WAAmB,EACnB,MAAM,GACP,EAAE;IACD,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,eAAe,CAAA;CACnD;;;GAmCA"}
|
package/dist/auth/logout.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use server';
|
|
2
2
|
|
|
3
3
|
import { cookies as getCookies, headers as nextHeaders } from 'next/headers.js';
|
|
4
|
-
import { getPayload } from 'payload';
|
|
4
|
+
import { createLocalReq, getPayload, logoutOperation } from 'payload';
|
|
5
5
|
import { getExistingAuthToken } from '../utilities/getExistingAuthToken.js';
|
|
6
6
|
export async function logout({
|
|
7
|
+
allSessions = false,
|
|
7
8
|
config
|
|
8
9
|
}) {
|
|
9
10
|
try {
|
|
@@ -11,24 +12,42 @@ export async function logout({
|
|
|
11
12
|
config
|
|
12
13
|
});
|
|
13
14
|
const headers = await nextHeaders();
|
|
14
|
-
const
|
|
15
|
+
const authResult = await payload.auth({
|
|
15
16
|
headers
|
|
16
17
|
});
|
|
17
|
-
if (!
|
|
18
|
+
if (!authResult.user) {
|
|
18
19
|
return {
|
|
19
20
|
message: 'User already logged out',
|
|
20
21
|
success: true
|
|
21
22
|
};
|
|
22
23
|
}
|
|
24
|
+
const {
|
|
25
|
+
user
|
|
26
|
+
} = authResult;
|
|
27
|
+
const req = await createLocalReq({
|
|
28
|
+
user
|
|
29
|
+
}, payload);
|
|
30
|
+
const collection = payload.collections[user.collection];
|
|
31
|
+
const logoutResult = await logoutOperation({
|
|
32
|
+
allSessions,
|
|
33
|
+
collection,
|
|
34
|
+
req
|
|
35
|
+
});
|
|
36
|
+
if (!logoutResult) {
|
|
37
|
+
return {
|
|
38
|
+
message: 'Logout failed',
|
|
39
|
+
success: false
|
|
40
|
+
};
|
|
41
|
+
}
|
|
23
42
|
const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix);
|
|
24
43
|
if (existingCookie) {
|
|
25
44
|
const cookies = await getCookies();
|
|
26
45
|
cookies.delete(existingCookie.name);
|
|
27
|
-
return {
|
|
28
|
-
message: 'User logged out successfully',
|
|
29
|
-
success: true
|
|
30
|
-
};
|
|
31
46
|
}
|
|
47
|
+
return {
|
|
48
|
+
message: 'User logged out successfully',
|
|
49
|
+
success: true
|
|
50
|
+
};
|
|
32
51
|
} catch (e) {
|
|
33
52
|
console.error('Logout error:', e);
|
|
34
53
|
throw new Error(`${e}`);
|
package/dist/auth/logout.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","names":["cookies","getCookies","headers","nextHeaders","getPayload","getExistingAuthToken","logout","config","payload","
|
|
1
|
+
{"version":3,"file":"logout.js","names":["cookies","getCookies","headers","nextHeaders","createLocalReq","getPayload","logoutOperation","getExistingAuthToken","logout","allSessions","config","payload","authResult","auth","user","message","success","req","collection","collections","logoutResult","existingCookie","cookiePrefix","delete","name","e","console","error","Error"],"sources":["../../src/auth/logout.ts"],"sourcesContent":["'use server'\n\nimport type { SanitizedConfig } from 'payload';\n\nimport { cookies as getCookies, headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, logoutOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\n\nexport async function logout({\n allSessions = false,\n config,\n}: {\n allSessions?: boolean\n config: Promise<SanitizedConfig> | SanitizedConfig\n}) {\n try {\n const payload = await getPayload({ config })\n const headers = await nextHeaders()\n const authResult = await payload.auth({ headers })\n\n if (!authResult.user) {\n return { message: 'User already logged out', success: true }\n }\n\n const { user } = authResult\n const req = await createLocalReq({ user }, payload)\n const collection = payload.collections[user.collection]\n\n const logoutResult = await logoutOperation({\n allSessions,\n collection,\n req,\n })\n\n if (!logoutResult) {\n return { message: 'Logout failed', success: false }\n }\n\n const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix)\n if (existingCookie) {\n const cookies = await getCookies()\n cookies.delete(existingCookie.name)\n }\n\n return { message: 'User log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E,OAAOS,CAAA,EAAG;IACVC,OAAA,CAAQC,KAAK,CAAC,iBAAiBF,CAAA;IAC/B,MAAM,IAAIG,KAAA,CAAM,GAAGH,CAAA,EAAG;EACxB;AACF","ignoreList":[]}
|
package/dist/auth/refresh.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../src/auth/refresh.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../src/auth/refresh.ts"],"names":[],"mappings":"AAUA,wBAAsB,OAAO,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,GAAG,CAAA;CAAE;;;GA4CxD"}
|
package/dist/auth/refresh.js
CHANGED
|
@@ -1,38 +1,50 @@
|
|
|
1
1
|
'use server';
|
|
2
2
|
|
|
3
3
|
import { headers as nextHeaders } from 'next/headers.js';
|
|
4
|
-
import { getPayload } from 'payload';
|
|
4
|
+
import { createLocalReq, getPayload, refreshOperation } from 'payload';
|
|
5
5
|
import { getExistingAuthToken } from '../utilities/getExistingAuthToken.js';
|
|
6
6
|
import { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js';
|
|
7
7
|
export async function refresh({
|
|
8
|
-
collection,
|
|
9
8
|
config
|
|
10
9
|
}) {
|
|
11
10
|
try {
|
|
12
11
|
const payload = await getPayload({
|
|
13
12
|
config
|
|
14
13
|
});
|
|
15
|
-
const
|
|
16
|
-
|
|
14
|
+
const headers = await nextHeaders();
|
|
15
|
+
const result = await payload.auth({
|
|
16
|
+
headers
|
|
17
|
+
});
|
|
18
|
+
if (!result.user) {
|
|
19
|
+
throw new Error('Cannot refresh token: user not authenticated');
|
|
20
|
+
}
|
|
21
|
+
const collection = result.user.collection;
|
|
22
|
+
const collectionConfig = payload.collections[collection];
|
|
23
|
+
if (!collectionConfig?.config.auth) {
|
|
17
24
|
throw new Error(`No auth config found for collection: ${collection}`);
|
|
18
25
|
}
|
|
19
|
-
const {
|
|
20
|
-
user
|
|
21
|
-
}
|
|
22
|
-
|
|
26
|
+
const req = await createLocalReq({
|
|
27
|
+
user: result.user
|
|
28
|
+
}, payload);
|
|
29
|
+
const refreshResult = await refreshOperation({
|
|
30
|
+
collection: collectionConfig,
|
|
31
|
+
req
|
|
23
32
|
});
|
|
24
|
-
if (!
|
|
25
|
-
|
|
33
|
+
if (!refreshResult) {
|
|
34
|
+
return {
|
|
35
|
+
message: 'Token refresh failed',
|
|
36
|
+
success: false
|
|
37
|
+
};
|
|
26
38
|
}
|
|
27
39
|
const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix);
|
|
28
40
|
if (!existingCookie) {
|
|
29
41
|
return {
|
|
30
|
-
message: 'No valid token found',
|
|
42
|
+
message: 'No valid token found to refresh',
|
|
31
43
|
success: false
|
|
32
44
|
};
|
|
33
45
|
}
|
|
34
46
|
await setPayloadAuthCookie({
|
|
35
|
-
authConfig,
|
|
47
|
+
authConfig: collectionConfig.config.auth,
|
|
36
48
|
cookiePrefix: payload.config.cookiePrefix,
|
|
37
49
|
token: existingCookie.value
|
|
38
50
|
});
|
package/dist/auth/refresh.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.js","names":["headers","nextHeaders","getPayload","getExistingAuthToken","setPayloadAuthCookie","refresh","
|
|
1
|
+
{"version":3,"file":"refresh.js","names":["headers","nextHeaders","createLocalReq","getPayload","refreshOperation","getExistingAuthToken","setPayloadAuthCookie","refresh","config","payload","result","auth","user","Error","collection","collectionConfig","collections","req","refreshResult","message","success","existingCookie","cookiePrefix","authConfig","token","value","e","console","error"],"sources":["../../src/auth/refresh.ts"],"sourcesContent":["'use server'\n\nimport type { CollectionSlug } from 'payload'\n\nimport { headers as nextHeaders } from 'next/headers.js'\nimport { createLocalReq, getPayload, refreshOperation } from 'payload'\n\nimport { getExistingAuthToken } from '../utilities/getExistingAuthToken.js'\nimport { setPayloadAuthCookie } from '../utilities/setPayloadAuthCookie.js'\n\nexport async function refresh({ config }: { config: any }) {\n try {\n const payload = await getPayload({ config })\n const headers = await nextHeaders()\n const result = await payload.auth({ headers })\n\n if (!result.user) {\n throw new Error('Cannot refresh token: user not authenticated')\n }\n\n const collection: CollectionSlug | undefined = result.user.collection\n const collectionConfig = payload.collections[collection]\n\n if (!collectionConfig?.config.auth) {\n throw new Error(`No auth config found for collection: ${collection}`)\n }\n\n const req = await createLocalReq({ user: result.user }, payload)\n\n const refreshResult = await refreshOperation({\n collection: collectionConfig,\n req,\n })\n\n if (!refreshResult) {\n return { message: 'Token refresh failed', success: false }\n }\n\n const existingCookie = await getExistingAuthToken(payload.config.cookiePrefix)\n if (!existingCookie) {\n return { message: 'No valid token found to refresh', success: false }\n }\n\n await setPayloadAuthCookie({\n authConfig: collectionConfig.config.auth,\n cookiePrefix: payload.config.cookiePrefix,\n token: existingCookie.value,\n })\n\n return { message: 'Token refreshed successfully', success: true }\n } catch (e) {\n console.error('Refresh error:', e)\n throw new Error(`${e}`)\n }\n}\n"],"mappings":"AAAA;;AAIA,SAASA,OAAA,IAAWC,WAAW,QAAQ;AACvC,SAASC,cAAc,EAAEC,UAAU,EAAEC,gBAAgB,QAAQ;AAE7D,SAASC,oBAAoB,QAAQ;AACrC,SAASC,oBAAoB,QAAQ;AAErC,OAAO,eAAeC,QAAQ;EAAEC;AAAM,CAAmB;EACvD,IAAI;IACF,MAAMC,OAAA,GAAU,MAAMN,UAAA,CAAW;MAAEK;IAAO;IAC1C,MAAMR,OAAA,GAAU,MAAMC,WAAA;IACtB,MAAMS,MAAA,GAAS,MAAMD,OAAA,CAAQE,IAAI,CAAC;MAAEX;IAAQ;IAE5C,IAAI,CAACU,MAAA,CAAOE,IAAI,EAAE;MAChB,MAAM,IAAIC,KAAA,CAAM;IAClB;IAEA,MAAMC,UAAA,GAAyCJ,MAAA,CAAOE,IAAI,CAACE,UAAU;IACrE,MAAMC,gBAAA,GAAmBN,OAAA,CAAQO,WAAW,CAACF,UAAA,CAAW;IAExD,IAAI,CAACC,gBAAA,EAAkBP,MAAA,CAAOG,IAAA,EAAM;MAClC,MAAM,IAAIE,KAAA,CAAM,wCAAwCC,UAAA,EAAY;IACtE;IAEA,MAAMG,GAAA,GAAM,MAAMf,cAAA,CAAe;MAAEU,IAAA,EAAMF,MAAA,CAAOE;IAAK,GAAGH,OAAA;IAExD,MAAMS,aAAA,GAAgB,MAAMd,gBAAA,CAAiB;MAC3CU,UAAA,EAAYC,gBAAA;MACZE;IACF;IAEA,IAAI,CAACC,aAAA,EAAe;MAClB,OAAO;QAAEC,OAAA,EAAS;QAAwBC,OAAA,EAAS;MAAM;IAC3D;IAEA,MAAMC,cAAA,GAAiB,MAAMhB,oBAAA,CAAqBI,OAAA,CAAQD,MAAM,CAACc,YAAY;IAC7E,IAAI,CAACD,cAAA,EAAgB;MACnB,OAAO;QAAEF,OAAA,EAAS;QAAmCC,OAAA,EAAS;MAAM;IACtE;IAEA,MAAMd,oBAAA,CAAqB;MACzBiB,UAAA,EAAYR,gBAAA,CAAiBP,MAAM,CAACG,IAAI;MACxCW,YAAA,EAAcb,OAAA,CAAQD,MAAM,CAACc,YAAY;MACzCE,KAAA,EAAOH,cAAA,CAAeI;IACxB;IAEA,OAAO;MAAEN,OAAA,EAAS;MAAgCC,OAAA,EAAS;IAAK;EAClE,EAAE,OAAOM,CAAA,EAAG;IACVC,OAAA,CAAQC,KAAK,CAAC,kBAAkBF,CAAA;IAChC,MAAM,IAAIb,KAAA,CAAM,GAAGa,CAAA,EAAG;EACxB;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/LivePreview/Device/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoB,MAAM,OAAO,CAAA;AAIxC,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC;IACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/views/LivePreview/Device/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoB,MAAM,OAAO,CAAA;AAIxC,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC;IACrC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAiGA,CAAA"}
|
|
@@ -18,11 +18,9 @@ export const DeviceContainer = props => {
|
|
|
18
18
|
} = useLivePreviewContext();
|
|
19
19
|
// Keep an accurate measurement of the actual device size as it is truly rendered
|
|
20
20
|
// This is helpful when `sizes` are non-number units like percentages, etc.
|
|
21
|
-
// eslint-disable-next-line react-compiler/react-compiler -- TODO: fix
|
|
22
21
|
const {
|
|
23
22
|
size: measuredDeviceSize
|
|
24
23
|
} = useResize(deviceFrameRef.current);
|
|
25
|
-
// eslint-disable-next-line react-compiler/react-compiler -- TODO: fix
|
|
26
24
|
const {
|
|
27
25
|
size: outerFrameSize
|
|
28
26
|
} = useResize(outerFrameRef.current);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useResize","React","useEffect","useLivePreviewContext","DeviceContainer","props","children","deviceFrameRef","useRef","outerFrameRef","breakpoint","setMeasuredDeviceSize","size","desiredSize","zoom","measuredDeviceSize","current","outerFrameSize","deviceIsLargerThanFrame","x","margin","width","height","scaledDesiredWidth","scaledDeviceWidth","scaledDeviceDifferencePixels","differenceFromDeviceToFrame","_jsx","ref","style","transform"],"sources":["../../../../src/views/LivePreview/Device/index.tsx"],"sourcesContent":["'use client'\nimport { useResize } from '@payloadcms/ui'\nimport React, { useEffect } from 'react'\n\nimport { useLivePreviewContext } from '../Context/context.js'\n\nexport const DeviceContainer: React.FC<{\n children: React.ReactNode\n}> = (props) => {\n const { children } = props\n\n const deviceFrameRef = React.useRef<HTMLDivElement>(null)\n const outerFrameRef = React.useRef<HTMLDivElement>(null)\n\n const { breakpoint, setMeasuredDeviceSize, size: desiredSize, zoom } = useLivePreviewContext()\n\n // Keep an accurate measurement of the actual device size as it is truly rendered\n // This is helpful when `sizes` are non-number units like percentages, etc.\n
|
|
1
|
+
{"version":3,"file":"index.js","names":["useResize","React","useEffect","useLivePreviewContext","DeviceContainer","props","children","deviceFrameRef","useRef","outerFrameRef","breakpoint","setMeasuredDeviceSize","size","desiredSize","zoom","measuredDeviceSize","current","outerFrameSize","deviceIsLargerThanFrame","x","margin","width","height","scaledDesiredWidth","scaledDeviceWidth","scaledDeviceDifferencePixels","differenceFromDeviceToFrame","_jsx","ref","style","transform"],"sources":["../../../../src/views/LivePreview/Device/index.tsx"],"sourcesContent":["'use client'\nimport { useResize } from '@payloadcms/ui'\nimport React, { useEffect } from 'react'\n\nimport { useLivePreviewContext } from '../Context/context.js'\n\nexport const DeviceContainer: React.FC<{\n children: React.ReactNode\n}> = (props) => {\n const { children } = props\n\n const deviceFrameRef = React.useRef<HTMLDivElement>(null)\n const outerFrameRef = React.useRef<HTMLDivElement>(null)\n\n const { breakpoint, setMeasuredDeviceSize, size: desiredSize, zoom } = useLivePreviewContext()\n\n // Keep an accurate measurement of the actual device size as it is truly rendered\n // This is helpful when `sizes` are non-number units like percentages, etc.\n const { size: measuredDeviceSize } = useResize(deviceFrameRef.current)\n const { size: outerFrameSize } = useResize(outerFrameRef.current)\n\n let deviceIsLargerThanFrame: boolean = false\n\n // Sync the measured device size with the context so that other components can use it\n // This happens from the bottom up so that as this component mounts and unmounts,\n // its size is freshly populated again upon re-mounting, i.e. going from iframe->popup->iframe\n useEffect(() => {\n if (measuredDeviceSize) {\n setMeasuredDeviceSize(measuredDeviceSize)\n }\n }, [measuredDeviceSize, setMeasuredDeviceSize])\n\n let x = '0'\n let margin = '0'\n\n if (breakpoint && breakpoint !== 'responsive') {\n x = '-50%'\n\n if (\n desiredSize &&\n measuredDeviceSize &&\n typeof zoom === 'number' &&\n typeof desiredSize.width === 'number' &&\n typeof desiredSize.height === 'number' &&\n typeof measuredDeviceSize.width === 'number' &&\n typeof measuredDeviceSize.height === 'number'\n ) {\n margin = '0 auto'\n const scaledDesiredWidth = desiredSize.width / zoom\n const scaledDeviceWidth = measuredDeviceSize.width * zoom\n const scaledDeviceDifferencePixels = scaledDesiredWidth - desiredSize.width\n deviceIsLargerThanFrame = scaledDeviceWidth > outerFrameSize.width\n\n if (deviceIsLargerThanFrame) {\n if (zoom > 1) {\n const differenceFromDeviceToFrame = measuredDeviceSize.width - outerFrameSize.width\n if (differenceFromDeviceToFrame < 0) {\n x = `${differenceFromDeviceToFrame / 2}px`\n } else {\n x = '0'\n }\n } else {\n x = '0'\n }\n } else {\n if (zoom >= 1) {\n x = `${scaledDeviceDifferencePixels / 2}px`\n } else {\n const differenceFromDeviceToFrame = outerFrameSize.width - scaledDeviceWidth\n x = `${differenceFromDeviceToFrame / 2}px`\n margin = '0'\n }\n }\n }\n }\n\n let width = zoom ? `${100 / zoom}%` : '100%'\n let height = zoom ? `${100 / zoom}%` : '100%'\n\n if (breakpoint !== 'responsive') {\n width = `${desiredSize?.width / (typeof zoom === 'number' ? zoom : 1)}px`\n height = `${desiredSize?.height / (typeof zoom === 'number' ? zoom : 1)}px`\n }\n\n return (\n <div\n ref={outerFrameRef}\n style={{\n height: '100%',\n width: '100%',\n }}\n >\n <div\n ref={deviceFrameRef}\n style={{\n height,\n margin,\n transform: `translate3d(${x}, 0, 0)`,\n width,\n }}\n >\n {children}\n </div>\n </div>\n )\n}\n"],"mappings":"AAAA;;;AACA,SAASA,SAAS,QAAQ;AAC1B,OAAOC,KAAA,IAASC,SAAS,QAAQ;AAEjC,SAASC,qBAAqB,QAAQ;AAEtC,OAAO,MAAMC,eAAA,GAEPC,KAAA;EACJ,MAAM;IAAEC;EAAQ,CAAE,GAAGD,KAAA;EAErB,MAAME,cAAA,GAAiBN,KAAA,CAAMO,MAAM,CAAiB;EACpD,MAAMC,aAAA,GAAgBR,KAAA,CAAMO,MAAM,CAAiB;EAEnD,MAAM;IAAEE,UAAU;IAAEC,qB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,2BAAA,GAA8B,KAAK;UAC5C,OAAO;YACLP,CAAA,GAAI;UACN;QACF,OAAO;UACLA,CAAA,GAAI;QACN;MACF,OAAO;QACL,IAAIL,IAAA,IAAQ,GAAG;UACbK,CAAA,GAAI,GAAGM,4BAAA,GAA+B,KAAK;QAC7C,OAAO;UACL,MAAMC,6BAAA,GAA8BT,cAAA,CAAeI,KAAK,GAAGG,iBAAA;UAC3DL,CAAA,GAAI,GAAGO,6BAAA,GAA8B,KAAK;UAC1CN,MAAA,GAAS;QACX;MACF;IACF;EACF;EAEA,IAAIC,KAAA,GAAQP,IAAA,GAAO,GAAG,MAAMA,IAAA,GAAO,GAAG;EACtC,IAAIQ,MAAA,GAASR,IAAA,GAAO,GAAG,MAAMA,IAAA,GAAO,GAAG;EAEvC,IAAIJ,UAAA,KAAe,cAAc;IAC/BW,KAAA,GAAQ,GAAGR,WAAA,EAAaQ,KAAA,IAAS,OAAOP,IAAA,KAAS,WAAWA,IAAA,GAAO,MAAM;IACzEQ,MAAA,GAAS,GAAGT,WAAA,EAAaS,MAAA,IAAU,OAAOR,IAAA,KAAS,WAAWA,IAAA,GAAO,MAAM;EAC7E;EAEA,oBACEa,IAAA,CAAC;IACCC,GAAA,EAAKnB,aAAA;IACLoB,KAAA,EAAO;MACLP,MAAA,EAAQ;MACRD,KAAA,EAAO;IACT;cAEA,aAAAM,IAAA,CAAC;MACCC,GAAA,EAAKrB,cAAA;MACLsB,KAAA,EAAO;QACLP,MAAA;QACAF,MAAA;QACAU,SAAA,EAAW,eAAeX,CAAA,SAAU;QACpCE;MACF;gBAECf;;;AAIT","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/next",
|
|
3
|
-
"version": "3.39.0-internal.
|
|
3
|
+
"version": "3.39.0-internal.8827ce8",
|
|
4
4
|
"homepage": "https://payloadcms.com",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
"react-diff-viewer-continued": "4.0.5",
|
|
85
85
|
"sass": "1.77.4",
|
|
86
86
|
"uuid": "10.0.0",
|
|
87
|
-
"@payloadcms/
|
|
88
|
-
"@payloadcms/translations": "3.39.0-internal.
|
|
89
|
-
"@payloadcms/
|
|
87
|
+
"@payloadcms/graphql": "3.39.0-internal.8827ce8",
|
|
88
|
+
"@payloadcms/translations": "3.39.0-internal.8827ce8",
|
|
89
|
+
"@payloadcms/ui": "3.39.0-internal.8827ce8"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@babel/cli": "7.26.4",
|
|
@@ -102,14 +102,15 @@
|
|
|
102
102
|
"babel-plugin-react-compiler": "19.0.0-beta-e993439-20250405",
|
|
103
103
|
"esbuild": "0.24.2",
|
|
104
104
|
"esbuild-sass-plugin": "3.3.1",
|
|
105
|
+
"eslint-plugin-react-compiler": "19.0.0-beta-e993439-20250405",
|
|
105
106
|
"swc-plugin-transform-remove-imports": "3.1.0",
|
|
106
|
-
"
|
|
107
|
-
"
|
|
107
|
+
"@payloadcms/eslint-config": "3.28.0",
|
|
108
|
+
"payload": "3.39.0-internal.8827ce8"
|
|
108
109
|
},
|
|
109
110
|
"peerDependencies": {
|
|
110
111
|
"graphql": "^16.8.1",
|
|
111
112
|
"next": "^15.2.3",
|
|
112
|
-
"payload": "3.39.0-internal.
|
|
113
|
+
"payload": "3.39.0-internal.8827ce8"
|
|
113
114
|
},
|
|
114
115
|
"engines": {
|
|
115
116
|
"node": "^18.20.2 || >=20.9.0"
|