@akinon/pz-theme 2.0.146-rc.0 → 2.0.147-beta.0

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +21 -35
  2. package/package.json +4 -4
  3. package/readme.md +121 -0
package/CHANGELOG.md CHANGED
@@ -1,40 +1,26 @@
1
1
  # @akinon/pz-theme
2
2
 
3
- ## 2.0.146-rc.0
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [86187b1c2]
8
- - Updated dependencies [0cf9ea239]
9
- - Updated dependencies [324f97d55]
10
- - Updated dependencies [51ea06888]
11
- - Updated dependencies
12
- - Updated dependencies [2fea41430]
13
- - Updated dependencies [b55acb768]
14
- - Updated dependencies [760258c1c]
15
- - Updated dependencies [143be2b9d]
16
- - Updated dependencies [7889b08fe]
17
- - Updated dependencies [9f8cd3bc5]
18
- - Updated dependencies [bfafa3f49]
19
- - Updated dependencies [57d7eb305]
20
- - Updated dependencies [d99a6a7d5]
21
- - Updated dependencies [9db81a714]
22
- - Updated dependencies [591e345e1]
23
- - Updated dependencies [4de5303c5]
24
- - Updated dependencies [95b139dc1]
25
- - Updated dependencies [1d00f2d06]
26
- - Updated dependencies [4ac7b2a1e]
27
- - Updated dependencies [e9598c71d]
28
- - Updated dependencies [4998a9631]
29
- - Updated dependencies [804d2bd6c]
30
- - Updated dependencies [3909d3224]
31
- - Updated dependencies [6a3d8a631]
32
- - Updated dependencies [e18836b20]
33
- - Updated dependencies [b1111d7b1]
34
- - Updated dependencies [1595d458e]
35
- - Updated dependencies [dca128112]
36
- - @akinon/next@2.0.146-rc.0
37
- - @akinon/theme-contract@2.0.146-rc.0
3
+ ## 2.0.147-beta.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [cbbbfd757]
8
+ - @akinon/next@2.0.147-beta.0
9
+ - @akinon/theme-contract@2.0.147-beta.0
10
+
11
+ ## 2.0.146
12
+
13
+ ### Patch Changes
14
+
15
+ - 7db9912: ZERO-5209: Document pz-theme on the v1 line and guard the composable-auth codemod
16
+
17
+ - The `@akinon/pz-theme` readme states the v1 compatibility policy: one release line from main, the versions that build on `@akinon/next` 1.x (2.0.106 and later), the core versions some editor features need, the setup a v1 brand needs, and the rules that keep the package buildable on v1. The `@akinon/theme-contract` readme points v1 storefronts there.
18
+ - `projectzero codemod --codemod=composable-auth` leaves a project without `@akinon/pz-theme`, or with one older than 2.0.41, untouched instead of writing a login layout whose import cannot resolve.
19
+ - `projectzero --plugins` offers List Hover Image (`pz-list-hover-image`), which its readme already told brands to install from there.
20
+
21
+ - Updated dependencies [7db9912]
22
+ - @akinon/theme-contract@2.0.146
23
+ - @akinon/next@2.0.146
38
24
 
39
25
  ## 2.0.145
40
26
 
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@akinon/pz-theme",
3
3
  "description": "Theme package for Project Zero Next — ThemePlaceholder system and theme editor infrastructure",
4
- "version": "2.0.146-rc.0",
4
+ "version": "2.0.147-beta.0",
5
5
  "license": "MIT",
6
6
  "main": "src/index.ts",
7
7
  "scripts": {
8
8
  "test": "jest"
9
9
  },
10
10
  "peerDependencies": {
11
- "@akinon/next": "2.0.146-rc.0",
11
+ "@akinon/next": "2.0.147-beta.0",
12
12
  "react": "^18.0.0 || ^19.0.0",
13
13
  "react-dom": "^18.0.0 || ^19.0.0"
14
14
  },
15
15
  "dependencies": {
16
- "@akinon/theme-contract": "2.0.146-rc.0",
16
+ "@akinon/theme-contract": "2.0.147-beta.0",
17
17
  "clsx": "2.1.1",
18
18
  "lottie-web": "^5.13.0",
19
19
  "react-multi-carousel": "2.8.4",
@@ -21,7 +21,7 @@
21
21
  "zod": "4.4.1"
22
22
  },
23
23
  "devDependencies": {
24
- "@akinon/next": "2.0.146-rc.0",
24
+ "@akinon/next": "2.0.147-beta.0",
25
25
  "@testing-library/jest-dom": "5.16.4",
26
26
  "@testing-library/react": "16.3.2",
27
27
  "@testing-library/user-event": "14.1.1",
package/readme.md CHANGED
@@ -25,3 +25,124 @@ export default async function Page() {
25
25
  ### Custom sections and blocks
26
26
 
27
27
  Developer-authored sections and blocks are written against `@akinon/pz-theme/src/custom` — see [`src/custom/README.md`](./src/custom/README.md) and [`src/custom/README-sections.md`](./src/custom/README-sections.md). Reference examples live in `examples/header/` at the root of the pz-next repository; they are not shipped in the npm package.
28
+
29
+ ## Using pz-theme on the v1 line
30
+
31
+ `@akinon/pz-theme` and `@akinon/theme-contract` have a single release line. They are developed on `main` and published with the 2.x packages; the `v1` branch has no copy of them and publishes no 1.x version. A brand still on v1 (Next 14.2, React 18, `@akinon/next` 1.x) installs the same releases as a v2 brand.
32
+
33
+ ### Which version
34
+
35
+ | `@akinon/pz-theme` | On `@akinon/next` 1.x |
36
+ | --- | --- |
37
+ | 2.0.106 and later | Builds. Take the latest. |
38
+ | 2.0.98 – 2.0.105 | Does not build on any v1 brand: `theme-fonts-link` writes a `precedence` prop that React 18's types do not declare (ZERO-5078). |
39
+ | 2.0.94 – 2.0.97 | Builds only on 1.121.0 and later: the reset password block imports a query older cores do not export. |
40
+ | 2.0.93 and earlier | Builds on 1.105.0 and later, without any of the later fixes. Older cores lack the `Modal` prop the image gallery passes. |
41
+
42
+ Pin an exact version, as for every `@akinon` package. `@akinon/theme-contract` is a dependency of pz-theme and arrives with it at the same version, so it does not go in the brand's `package.json`.
43
+
44
+ 2.0.106 was checked on `@akinon/next` 1.91.0 (ZERO-5078). 2.0.143 was checked in a v1 brand on `@akinon/next` 1.126.16, Next 14.2.25 and `@types/react` 18: every source file of both packages type-checks and the brand builds.
45
+
46
+ Two theme editor features also need a minimum core:
47
+
48
+ | Feature | `@akinon/next` 1.x |
49
+ | --- | --- |
50
+ | `withPzConfig` transpiles pz-theme and theme-contract, and `pz-postinstall` keeps pz-theme installed | 1.126.17 (ZERO-5209). Older cores: step 3 below. |
51
+ | Named previews ("View on site", the mobile QR code) | 1.126.15 (ZERO-5149), and only on the `[pz]` route segment |
52
+
53
+ ### Setting up a v1 brand
54
+
55
+ 1. Run `yarn add @akinon/pz-theme@<version> --exact`. Yarn then warns that pz-theme `has incorrect peer dependency "@akinon/next@<version>"`. The peer names the 2.x core the release was published with, so on v1 the warning is expected. npm 7 and later refuse the install instead, so install with Yarn.
56
+ 2. Let Tailwind see pz-theme. Its sections and blocks are styled with Tailwind classes that the brand's build generates, so add its sources to `content` in `tailwind.config.js`, as the 2.x app template does:
57
+
58
+ ```js
59
+ module.exports = {
60
+ content: [
61
+ // ...the brand's own globs
62
+ './node_modules/@akinon/pz-theme/src/**/*.{js,ts,jsx,tsx}'
63
+ ]
64
+ };
65
+ ```
66
+
67
+ A `'pz-theme'` entry in `src/plugins.js` has the same effect, because `getAkinonNextContent(plugins)` adds a glob for every entry.
68
+
69
+ 3. On a core older than 1.126.17, do two more things:
70
+
71
+ - Add `'pz-theme'` to `src/plugins.js`. Otherwise `pz-postinstall` removes the package on the next install.
72
+ - Append both packages to `transpilePackages` after `withPzConfig`. Declared inside `nextConfig`, the array would replace the core's list instead of extending it.
73
+
74
+ ```js
75
+ const config = withPzConfig(nextConfig);
76
+
77
+ export default {
78
+ ...config,
79
+ transpilePackages: [
80
+ ...(config.transpilePackages ?? []),
81
+ '@akinon/pz-theme',
82
+ '@akinon/theme-contract'
83
+ ]
84
+ };
85
+ ```
86
+
87
+ On 1.126.17 and later the `transpilePackages` override can go. Keep the `src/plugins.js` entry unless step 2's glob is in `tailwind.config.js`.
88
+
89
+ 4. Let the editor frame the storefront. The 1.x core's `Content-Security-Policy` allows `frame-ancestors` only for `'self'` and the akifast and akinoncloud origins. The 2.x core also allows Omnitron (`https://*.akinon.net`) and the local editor (`http://localhost:5174`). Add the same origins by rewriting the directive in the header `withPzConfig` emits; do not add a second header. Browsers enforce every CSP header, so a second one can only narrow the policy.
90
+
91
+ ```js
92
+ const EDITOR_ANCESTORS =
93
+ 'https://*.akinon.net *.akinon.net http://localhost:5174 localhost:5174';
94
+
95
+ const withEditorFraming = (config) => ({
96
+ ...config,
97
+ headers: async () =>
98
+ ((await config.headers?.()) ?? []).map((group) => ({
99
+ ...group,
100
+ headers: (group.headers ?? []).map((header) =>
101
+ header.key.toLowerCase() === 'content-security-policy'
102
+ ? {
103
+ ...header,
104
+ value: header.value.replace(
105
+ /frame-ancestors[^;]*/,
106
+ (directive) => `${directive} ${EDITOR_ANCESTORS}`
107
+ )
108
+ }
109
+ : header
110
+ )
111
+ }))
112
+ });
113
+ ```
114
+
115
+ 5. Set `NEXT_PUBLIC_THEME_EDITOR_ORIGINS` for production builds, as on v2 (see `@akinon/theme-contract`). The 1.x core does not serve `/theme-editor/health`, so the editor cannot name a missing variable. It treats the storefront as unknown and carries on, and without the variable the storefront ignores every edit.
116
+ 6. Mount the slots as a v2 brand does. For the login screen run `npx @akinon/projectzero@v1-latest --codemod=composable-auth`. It leaves a project without pz-theme untouched.
117
+
118
+ ### Keeping it buildable on v1
119
+
120
+ Nothing in CI builds a v1 brand, so this compatibility holds only while every change to pz-theme keeps to these rules:
121
+
122
+ - Never import, by name, a core export that only the 2.x core has. Read it off the module object and fall back when it is missing, as `load-placeholder-sections.ts` (`getWidgetSchemaData`, `getCollectionWidgetData`), `chrome/preview-snapshot-source.ts` (`getPreviewSnapshot`) and `blocks/reset-password-token-check.ts` do.
123
+ - Never write a JSX prop that only React 19's types declare. Spread it from a `Record`, as `chrome/theme-fonts-link.tsx` does for `precedence`.
124
+ - Code for the React 18 and RTK 1.9.7 runtime too. React 18 escapes `<style>` text children, so server-rendered CSS goes through `dangerouslySetInnerHTML` (`utils/css-safety.ts`). RTK 1.9.7 cannot seed its cache before the first render (`chrome/menu-seed-source.ts`).
125
+ - Announce new storefront behaviour to the editor by name (`action-capabilities.ts`). Do not assume every storefront runs the latest pz-theme: a v1 brand stays on the release it pinned.
126
+
127
+ Before releasing a change that touches core imports or JSX types, type-check the whole package in a v1 brand with the change installed. A tsconfig like this one, next to the brand's own, covers every source file, not only the ones the brand imports:
128
+
129
+ ```json
130
+ {
131
+ "extends": "./tsconfig.json",
132
+ "compilerOptions": { "incremental": false },
133
+ "include": [
134
+ "*.d.ts",
135
+ "src/**/*.d.ts",
136
+ "node_modules/@akinon/pz-theme/src/**/*.ts",
137
+ "node_modules/@akinon/pz-theme/src/**/*.tsx",
138
+ "node_modules/@akinon/theme-contract/src/**/*.ts"
139
+ ],
140
+ "exclude": [
141
+ "node_modules/**/__tests__/**",
142
+ "node_modules/**/*.test.ts",
143
+ "node_modules/**/*.test.tsx"
144
+ ]
145
+ }
146
+ ```
147
+
148
+ `npx tsc --noEmit -p <that file>` must report no error under `node_modules/@akinon`.