diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index dbd11d3..846396a 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -14,6 +14,16 @@ N.B. See changelogs for individual packages, where most change will occur:
This log covers the [monorepo](https://en.wikipedia.org/wiki/Monorepo).
+## [0.12.0] - 2025-09-30
+
+### Added
+
+- a `build:examples` script, for easy re-building of all examples
+
+### Fixed
+
+- added a `prepare-publish.mjs` script to prepare packages for npm publishing (moving `README.md` and `LICENSE` files into package roots), replacing the prior `shx` based solution, and adding [`transform-markdown-links`](https://github.com/gakimball/transform-markdown-links) to fix relative paths that otherwise incorrectly link on [npmjs.com](https://www.npmjs.com/)
+
## [0.11.0] - 2025-09-29
### Changed
diff --git a/examples/express/docs/CHANGELOG.md b/examples/express/docs/CHANGELOG.md
index a9d5d2c..be5cc5a 100644
--- a/examples/express/docs/CHANGELOG.md
+++ b/examples/express/docs/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [0.2.7] - 2025-09-30
+
+### Changed
+
+- move to use new `onVariantError` plugin hook over `logError` to consume [0.5.0](../../../packages/react-pointcuts/docs/CHANGELOG.md#040---2025-07-06) of `react-pointcuts` package.
+
## [0.2.6] - 2025-07-15
### Changed
diff --git a/examples/express/package.json b/examples/express/package.json
index 4894627..ecc5be4 100644
--- a/examples/express/package.json
+++ b/examples/express/package.json
@@ -1,6 +1,6 @@
{
"name": "web-toggle-point-express-example",
- "version": "0.2.6",
+ "version": "0.2.7",
"type": "module",
"engines": {
"node": ">=20.6.0"
diff --git a/examples/express/src/routes/config/togglePoint.js b/examples/express/src/routes/config/togglePoint.js
index abdcd3b..1ae5186 100644
--- a/examples/express/src/routes/config/togglePoint.js
+++ b/examples/express/src/routes/config/togglePoint.js
@@ -6,7 +6,11 @@ const { getFeatures: getActiveFeatures } = featuresStore;
const withTogglePoint = withTogglePointFactory({
getActiveFeatures,
variantKey: "size",
- logError: console.log
+ plugins: [
+ {
+ onVariantError: console.error
+ }
+ ]
});
export default withTogglePoint;
diff --git a/examples/next/docs/CHANGELOG.md b/examples/next/docs/CHANGELOG.md
index 48ab2d0..d96eb5c 100644
--- a/examples/next/docs/CHANGELOG.md
+++ b/examples/next/docs/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [0.3.1] - 2025-09-30
+
+### Changed
+
+- move to use new `onVariantError` plugin hook over `logError` to consume [0.5.0](../../../packages/react-pointcuts/docs/CHANGELOG.md#040---2025-07-06) of `react-pointcuts` package.
+
## [0.3.0] - 2025-09-29
### Added
diff --git a/examples/next/package.json b/examples/next/package.json
index 321755a..1e1b342 100644
--- a/examples/next/package.json
+++ b/examples/next/package.json
@@ -1,6 +1,6 @@
{
"name": "web-toggle-point-next-example",
- "version": "0.3.0",
+ "version": "0.3.1",
"private": true,
"type": "module",
"scripts": {
diff --git a/examples/next/src/app/fixtures/experiments/withTogglePoint.ts b/examples/next/src/app/fixtures/experiments/withTogglePoint.ts
index 89f046e..8e24104 100644
--- a/examples/next/src/app/fixtures/experiments/withTogglePoint.ts
+++ b/examples/next/src/app/fixtures/experiments/withTogglePoint.ts
@@ -8,9 +8,9 @@ const getActiveFeatures = () => getFeatures().decisions;
const withTogglePoint = withTogglePointFactory({
getActiveFeatures,
- logError: console.log,
plugins: [
{
+ onVariantError: console.error,
onCodeSelected: ({ matchedFeatures }) => {
if (matchedFeatures?.length) {
const [[feature]] = matchedFeatures;
diff --git a/package-lock.json b/package-lock.json
index 824b041..678d3f0 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "@asos/web-toggle-point",
- "version": "0.11.0",
+ "version": "0.12.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@asos/web-toggle-point",
- "version": "0.11.0",
+ "version": "0.12.0",
"license": "MIT",
"workspaces": [
"packages/features",
@@ -57,7 +57,7 @@
},
"examples/express": {
"name": "web-toggle-point-express-example",
- "version": "0.2.6",
+ "version": "0.2.7",
"dependencies": {
"@asos/web-toggle-point-features": "file:../../packages/features",
"@asos/web-toggle-point-react-pointcuts": "file:../../packages/react-pointcuts",
@@ -89,7 +89,7 @@
},
"examples/next": {
"name": "web-toggle-point-next-example",
- "version": "0.3.0",
+ "version": "0.3.1",
"dependencies": {
"@asos/web-toggle-point-features": "file:../../packages/features",
"@asos/web-toggle-point-react-pointcuts": "file:../../packages/react-pointcuts",
@@ -217,6 +217,7 @@
"node_modules/@babel/core": {
"version": "7.26.0",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@ampproject/remapping": "^2.2.0",
"@babel/code-frame": "^7.26.0",
@@ -245,6 +246,7 @@
"node_modules/@babel/eslint-parser": {
"version": "7.25.9",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1",
"eslint-visitor-keys": "^2.1.0",
@@ -1869,6 +1871,7 @@
"node_modules/@eslint/js": {
"version": "9.17.0",
"license": "MIT",
+ "peer": true,
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
}
@@ -3397,6 +3400,7 @@
"node_modules/@mdx-js/react": {
"version": "3.1.0",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@types/mdx": "^2.0.0"
},
@@ -3967,6 +3971,7 @@
"version": "3.6.0",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"@octokit/auth-token": "^2.4.4",
"@octokit/graphql": "^4.5.8",
@@ -4097,6 +4102,7 @@
"node_modules/@playwright/test": {
"version": "1.55.1",
"license": "Apache-2.0",
+ "peer": true,
"dependencies": {
"playwright": "1.55.1"
},
@@ -4330,7 +4336,6 @@
"node_modules/@stylistic/eslint-plugin-js": {
"version": "2.12.1",
"license": "MIT",
- "peer": true,
"dependencies": {
"eslint-visitor-keys": "^4.2.0",
"espree": "^10.3.0"
@@ -4345,7 +4350,6 @@
"node_modules/@stylistic/eslint-plugin-js/node_modules/eslint-visitor-keys": {
"version": "4.2.0",
"license": "Apache-2.0",
- "peer": true,
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
@@ -4459,13 +4463,13 @@
"node_modules/@types/aria-query": {
"version": "5.0.4",
"dev": true,
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/@types/babel__core": {
"version": "7.20.5",
"devOptional": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"@babel/parser": "^7.20.7",
"@babel/types": "^7.20.7",
@@ -4628,6 +4632,7 @@
"version": "14.1.2",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"@types/linkify-it": "^5",
"@types/mdurl": "^2"
@@ -5143,6 +5148,7 @@
"node_modules/acorn": {
"version": "8.14.0",
"license": "MIT",
+ "peer": true,
"bin": {
"acorn": "bin/acorn"
},
@@ -5191,6 +5197,7 @@
"node_modules/ajv": {
"version": "6.12.6",
"license": "MIT",
+ "peer": true,
"dependencies": {
"fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0",
@@ -5963,6 +5970,7 @@
}
],
"license": "MIT",
+ "peer": true,
"dependencies": {
"caniuse-lite": "^1.0.30001688",
"electron-to-chromium": "^1.5.73",
@@ -6696,6 +6704,7 @@
"version": "3.39.0",
"hasInstallScript": true,
"license": "MIT",
+ "peer": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/core-js"
@@ -6895,8 +6904,7 @@
},
"node_modules/csstype": {
"version": "3.1.3",
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/damerau-levenshtein": {
"version": "1.0.8",
@@ -7355,8 +7363,7 @@
"node_modules/dom-accessibility-api": {
"version": "0.5.16",
"dev": true,
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/dom-serializer": {
"version": "2.0.0",
@@ -7772,6 +7779,7 @@
"node_modules/eslint": {
"version": "9.17.0",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.12.1",
@@ -7859,6 +7867,7 @@
"node_modules/eslint-config-prettier": {
"version": "9.1.0",
"license": "MIT",
+ "peer": true,
"bin": {
"eslint-config-prettier": "bin/cli.js"
},
@@ -8021,7 +8030,6 @@
"node_modules/eslint-plugin-cypress": {
"version": "3.6.0",
"license": "MIT",
- "peer": true,
"dependencies": {
"globals": "^13.20.0"
},
@@ -8032,7 +8040,6 @@
"node_modules/eslint-plugin-cypress/node_modules/globals": {
"version": "13.24.0",
"license": "MIT",
- "peer": true,
"dependencies": {
"type-fest": "^0.20.2"
},
@@ -8046,7 +8053,6 @@
"node_modules/eslint-plugin-cypress/node_modules/type-fest": {
"version": "0.20.2",
"license": "(MIT OR CC0-1.0)",
- "peer": true,
"engines": {
"node": ">=10"
},
@@ -8057,6 +8063,7 @@
"node_modules/eslint-plugin-import": {
"version": "2.31.0",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@rtsao/scc": "^1.1.0",
"array-includes": "^3.1.8",
@@ -8095,6 +8102,7 @@
"node_modules/eslint-plugin-jest": {
"version": "28.10.0",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@typescript-eslint/utils": "^6.0.0 || ^7.0.0 || ^8.0.0"
},
@@ -8118,6 +8126,7 @@
"node_modules/eslint-plugin-jest-formatting": {
"version": "3.1.0",
"license": "MIT",
+ "peer": true,
"engines": {
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
@@ -8393,7 +8402,6 @@
"node_modules/eslint-plugin-playwright": {
"version": "1.8.3",
"license": "MIT",
- "peer": true,
"workspaces": [
"examples"
],
@@ -8416,7 +8424,6 @@
"node_modules/eslint-plugin-playwright/node_modules/globals": {
"version": "13.24.0",
"license": "MIT",
- "peer": true,
"dependencies": {
"type-fest": "^0.20.2"
},
@@ -8430,7 +8437,6 @@
"node_modules/eslint-plugin-playwright/node_modules/type-fest": {
"version": "0.20.2",
"license": "(MIT OR CC0-1.0)",
- "peer": true,
"engines": {
"node": ">=10"
},
@@ -8441,6 +8447,7 @@
"node_modules/eslint-plugin-prettier": {
"version": "5.2.1",
"license": "MIT",
+ "peer": true,
"dependencies": {
"prettier-linter-helpers": "^1.0.0",
"synckit": "^0.9.1"
@@ -8499,6 +8506,7 @@
"node_modules/eslint-plugin-react-hooks": {
"version": "5.1.0",
"license": "MIT",
+ "peer": true,
"engines": {
"node": ">=10"
},
@@ -8531,6 +8539,7 @@
"node_modules/eslint-plugin-testing-library": {
"version": "7.1.1",
"license": "MIT",
+ "peer": true,
"dependencies": {
"@typescript-eslint/scope-manager": "^8.15.0",
"@typescript-eslint/utils": "^8.15.0"
@@ -10715,6 +10724,7 @@
"version": "29.7.0",
"devOptional": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"@jest/core": "^29.7.0",
"@jest/types": "^29.6.3",
@@ -13720,7 +13730,6 @@
"version": "1.5.0",
"dev": true,
"license": "MIT",
- "peer": true,
"bin": {
"lz-string": "bin/bin.js"
}
@@ -13786,6 +13795,7 @@
"version": "14.1.0",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"argparse": "^2.0.1",
"entities": "^4.4.0",
@@ -16024,6 +16034,7 @@
}
],
"license": "MIT",
+ "peer": true,
"dependencies": {
"nanoid": "^3.3.7",
"picocolors": "^1.1.1",
@@ -16115,6 +16126,7 @@
"node_modules/prettier": {
"version": "3.4.2",
"license": "MIT",
+ "peer": true,
"bin": {
"prettier": "bin/prettier.cjs"
},
@@ -16139,7 +16151,6 @@
"version": "27.5.1",
"dev": true,
"license": "MIT",
- "peer": true,
"dependencies": {
"ansi-regex": "^5.0.1",
"ansi-styles": "^5.0.0",
@@ -16153,7 +16164,6 @@
"version": "5.0.1",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=8"
}
@@ -16162,7 +16172,6 @@
"version": "5.2.0",
"dev": true,
"license": "MIT",
- "peer": true,
"engines": {
"node": ">=10"
},
@@ -16400,6 +16409,7 @@
"node_modules/react": {
"version": "18.3.1",
"license": "MIT",
+ "peer": true,
"dependencies": {
"loose-envify": "^1.1.0"
},
@@ -16410,6 +16420,7 @@
"node_modules/react-dom": {
"version": "18.3.1",
"license": "MIT",
+ "peer": true,
"dependencies": {
"loose-envify": "^1.1.0",
"scheduler": "^0.23.2"
@@ -16421,8 +16432,7 @@
"node_modules/react-is": {
"version": "17.0.2",
"dev": true,
- "license": "MIT",
- "peer": true
+ "license": "MIT"
},
"node_modules/react-property": {
"version": "2.0.2",
@@ -17122,6 +17132,7 @@
"version": "3.29.5",
"dev": true,
"license": "MIT",
+ "peer": true,
"bin": {
"rollup": "dist/bin/rollup"
},
@@ -17365,6 +17376,7 @@
"version": "8.17.1",
"devOptional": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"fast-deep-equal": "^3.1.3",
"fast-uri": "^3.0.1",
@@ -18629,6 +18641,16 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/transform-markdown-links": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/transform-markdown-links/-/transform-markdown-links-2.1.0.tgz",
+ "integrity": "sha512-7HWQwQ9US+tJSMMzi1aP+KA3QwfjDs8sB4H5GBMRHFNBMQVdgoF6VfIFy2nJR/UHRTkYoGFwWh2pe+QIwSvfOA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=4"
+ }
+ },
"node_modules/tree-dump": {
"version": "1.0.2",
"dev": true,
@@ -18703,7 +18725,8 @@
},
"node_modules/tslib": {
"version": "2.8.1",
- "license": "0BSD"
+ "license": "0BSD",
+ "peer": true
},
"node_modules/turndown": {
"version": "7.2.1",
@@ -18836,7 +18859,6 @@
"node_modules/typescript": {
"version": "5.7.2",
"license": "Apache-2.0",
- "peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
@@ -19477,6 +19499,7 @@
"version": "5.97.1",
"devOptional": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"@types/eslint-scope": "^3.7.7",
"@types/estree": "^1.0.6",
@@ -19522,6 +19545,7 @@
"version": "4.10.0",
"dev": true,
"license": "MIT",
+ "peer": true,
"dependencies": {
"@discoveryjs/json-ext": "^0.5.0",
"@webpack-cli/configtest": "^1.2.0",
@@ -20099,7 +20123,7 @@
},
"packages/features": {
"name": "@asos/web-toggle-point-features",
- "version": "0.4.1",
+ "version": "0.4.2",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.26.0"
@@ -20127,7 +20151,8 @@
"react": "^18.3.1",
"rimraf": "^6.0.1",
"rollup-plugin-auto-external": "^2.0.0",
- "shx": "^0.4.0"
+ "shx": "^0.4.0",
+ "transform-markdown-links": "^2.1.0"
},
"peerDependencies": {
"@asos/web-toggle-point-ssr": "file:../ssr",
@@ -20148,7 +20173,7 @@
},
"packages/react-pointcuts": {
"name": "@asos/web-toggle-point-react-pointcuts",
- "version": "0.4.8",
+ "version": "0.5.0",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.26.0"
@@ -20174,7 +20199,8 @@
"react": "^18.3.1",
"rimraf": "^6.0.1",
"rollup-plugin-auto-external": "^2.0.0",
- "shx": "^0.4.0"
+ "shx": "^0.4.0",
+ "transform-markdown-links": "^2.1.0"
},
"peerDependencies": {
"@asos/web-toggle-point-features": "file:../features",
@@ -20185,7 +20211,7 @@
},
"packages/ssr": {
"name": "@asos/web-toggle-point-ssr",
- "version": "0.2.5",
+ "version": "0.2.6",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.26.0",
@@ -20212,7 +20238,8 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"rollup-plugin-auto-external": "^2.0.0",
- "shx": "^0.4.0"
+ "shx": "^0.4.0",
+ "transform-markdown-links": "^2.1.0"
},
"peerDependencies": {
"prop-types": "^15.7.2",
@@ -20222,7 +20249,7 @@
},
"packages/webpack": {
"name": "@asos/web-toggle-point-webpack",
- "version": "0.8.2",
+ "version": "0.8.3",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.26.0",
@@ -20245,6 +20272,7 @@
"rollup-plugin-copy": "^3.5.0",
"schema-utils": "^4.2.0",
"shx": "^0.4.0",
+ "transform-markdown-links": "^2.1.0",
"webpack": "^5.88.2",
"webpack-cli": "^4.10.0",
"webpack-test-utils": "^2.1.0"
diff --git a/package.json b/package.json
index eeea427..6f77d0d 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@asos/web-toggle-point",
- "version": "0.11.0",
+ "version": "0.12.0",
"repository": "git@github.com:asos/web-toggle-point.git",
"homepage": "https://asos.github.io/web-toggle-point/",
"license": "MIT",
@@ -10,6 +10,7 @@
},
"scripts": {
"build": "npm run build --workspace packages",
+ "build:examples": "npm run build --workspace examples",
"danger:local": "danger local --base main",
"danger:local:staged": "npm run danger:local --staged",
"docs": "rimraf ./docs/html/* && jsdoc ./packages/*/src -c ./docs/jsdoc.conf.js",
diff --git a/packages/eslint.config.mjs b/packages/eslint.config.mjs
index 732691f..53fd75f 100644
--- a/packages/eslint.config.mjs
+++ b/packages/eslint.config.mjs
@@ -17,6 +17,12 @@ export default [
globals: globals.node
}
},
+ {
+ files: ["prepare-publish.mjs"],
+ languageOptions: {
+ globals: globals.node
+ }
+ },
{
files: ["src/**/*.test.*", "build/**/*.js", "**/rollup.mjs"],
ignores: ["**/*.snap"],
diff --git a/packages/features/docs/CHANGELOG.md b/packages/features/docs/CHANGELOG.md
index 97c4079..5700eaf 100644
--- a/packages/features/docs/CHANGELOG.md
+++ b/packages/features/docs/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [0.4.2] - 2025-09-30
+
+### Fixed
+
+- Used the `prepare-publish.mjs` script provided by repo root version [0.12.0](../../../docs/CHANGELOG.md#0120---2025-09-30) to fix relative links in `README.md` on [npmjs.com](https://www.npmjs.com/) that were moved as part of [0.4.1](#041---2025-09-29)
+
## [0.4.1] - 2025-09-29
### Fixed
diff --git a/packages/features/package.json b/packages/features/package.json
index f21156a..a2c55b3 100644
--- a/packages/features/package.json
+++ b/packages/features/package.json
@@ -1,7 +1,7 @@
{
"name": "@asos/web-toggle-point-features",
"description": "toggle point features code, used to store toggle state",
- "version": "0.4.1",
+ "version": "0.4.2",
"license": "MIT",
"type": "module",
"main": "./lib/global.js",
@@ -43,7 +43,7 @@
"build": "npm run clean && npm run build:browser && npm run build:server && npm run build:eslint-import-backfill",
"build:browser": "cross-env BABEL_ENV=browser rollup -c build/rollup.mjs --config_isBrowser true",
"build:server": "rollup -c build/rollup.mjs --config_isBrowser false",
- "prepublishOnly": "shx cp docs/README.md ../../LICENSE . && npm run build",
+ "prepublishOnly": "node ../prepare-publish.mjs && npm run build",
"postpublish": "shx rm ./README.md LICENSE",
"build:eslint-import-backfill": "rollup -c build/eslint-import-backfill.rollup.mjs",
"clean": "rimraf ./lib",
@@ -80,7 +80,8 @@
"react": "^18.3.1",
"rimraf": "^6.0.1",
"rollup-plugin-auto-external": "^2.0.0",
- "shx": "^0.4.0"
+ "shx": "^0.4.0",
+ "transform-markdown-links": "^2.1.0"
},
"peerDependencies": {
"@asos/web-toggle-point-ssr": "file:../ssr",
diff --git a/packages/prepare-publish.mjs b/packages/prepare-publish.mjs
new file mode 100644
index 0000000..9a153b3
--- /dev/null
+++ b/packages/prepare-publish.mjs
@@ -0,0 +1,23 @@
+import transformLinks from "transform-markdown-links";
+import { copyFile, readFile, writeFile } from "node:fs/promises";
+import { join } from "node:path";
+
+const encoding = "utf8";
+
+(async function prePublish() {
+ const packageDirectory = process.cwd();
+
+ const sourceLicense = join(packageDirectory, "../../LICENSE");
+ const targetLicense = join(packageDirectory, "LICENSE");
+ await copyFile(sourceLicense, targetLicense);
+
+ const sourceReadme = join(packageDirectory, "./docs/README.md");
+ const targetReadme = join(packageDirectory, "README.md");
+ const readmeContent = await readFile(sourceReadme, encoding);
+ const transformedContent = transformLinks(readmeContent, (link) => {
+ if (link.startsWith("../")) {
+ return link.replace(/^\.\.\//, "");
+ }
+ });
+ await writeFile(targetReadme, transformedContent, encoding);
+})();
diff --git a/packages/react-pointcuts/docs/CHANGELOG.md b/packages/react-pointcuts/docs/CHANGELOG.md
index 8cc433a..d6c3303 100644
--- a/packages/react-pointcuts/docs/CHANGELOG.md
+++ b/packages/react-pointcuts/docs/CHANGELOG.md
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [0.5.0] - 2025-09-30
+
+### Changed
+
+- Removed `logError` parameter of the `withTogglePointFactory`, replacing with calling of `onVariantError` hook of supplied plugins
+
+### Fixed
+
+- Used the `prepare-publish.mjs` script provided by repo root version [0.12.0](../../../docs/CHANGELOG.md#0120---2025-09-30) to fix relative links in `README.md` on [npmjs.com](https://www.npmjs.com/) that were moved as part of [0.4.7](#047---2025-09-29)
+
## [0.4.8] - 2025-09-29
### Fixed
diff --git a/packages/react-pointcuts/package.json b/packages/react-pointcuts/package.json
index 585aca6..b331adb 100644
--- a/packages/react-pointcuts/package.json
+++ b/packages/react-pointcuts/package.json
@@ -1,7 +1,7 @@
{
"name": "@asos/web-toggle-point-react-pointcuts",
"description": "react pointcut code",
- "version": "0.4.8",
+ "version": "0.5.0",
"license": "MIT",
"type": "module",
"main": "./lib/main.es5.cjs",
@@ -37,7 +37,7 @@
"build": "npm run clean && npm run build:browser && npm run build:server",
"build:browser": "cross-env BABEL_ENV=browser rollup -c build/rollup.mjs --config_isClient true",
"build:server": "rollup -c build/rollup.mjs --config_isClient false",
- "prepublishOnly": "shx cp docs/README.md ../../LICENSE . && npm run build",
+ "prepublishOnly": "node ../prepare-publish.mjs && npm run build",
"postpublish": "shx rm ./README.md LICENSE",
"clean": "rimraf ./lib",
"docs": "rimraf ./docs/**/*.html && jsdoc -c ../jsdoc.conf.js",
@@ -69,7 +69,8 @@
"react": "^18.3.1",
"rimraf": "^6.0.1",
"rollup-plugin-auto-external": "^2.0.0",
- "shx": "^0.4.0"
+ "shx": "^0.4.0",
+ "transform-markdown-links": "^2.1.0"
},
"peerDependencies": {
"@asos/web-toggle-point-features": "file:../features",
diff --git a/packages/react-pointcuts/src/external.js b/packages/react-pointcuts/src/external.js
index d3834a4..a4b7ede 100644
--- a/packages/react-pointcuts/src/external.js
+++ b/packages/react-pointcuts/src/external.js
@@ -1,14 +1,3 @@
-/**
- * Code expected in the host application
- * @external HostApplication
- */
-/**
- * A delegate passed to log an error
- * @callback external:HostApplication.logError
- * @type {Function}
- * @param {string} message A message to log as an error
- */
-
/**
* React UI library
* @external React
diff --git a/packages/react-pointcuts/src/getCodeSelectionPlugins.test.js b/packages/react-pointcuts/src/getCodeSelectionPlugins.test.js
deleted file mode 100644
index 7d3f597..0000000
--- a/packages/react-pointcuts/src/getCodeSelectionPlugins.test.js
+++ /dev/null
@@ -1,31 +0,0 @@
-import getCodeSelectionPlugins from "./getCodeSelectionPlugins";
-
-describe("getCodeSelectionPlugins", () => {
- let result;
-
- describe("when no plugins are provided", () => {
- beforeEach(() => {
- result = getCodeSelectionPlugins();
- });
-
- it("should return null, and not error", () => {
- expect(result).toEqual(null);
- });
- });
-
- describe("when plugins are provided", () => {
- const plugins = [
- { onSomeOtherThing: () => {} },
- { onCodeSelected: jest.fn() },
- { onCodeSelected: jest.fn(), onSomeOtherThing: () => {} }
- ];
-
- beforeEach(() => {
- result = getCodeSelectionPlugins(plugins);
- });
-
- it("should return all plugins that have a binding to the 'onCodeSelected' hook", () => {
- expect(result).toEqual(plugins.slice(1));
- });
- });
-});
diff --git a/packages/react-pointcuts/src/getCodeSelectionPlugins.js b/packages/react-pointcuts/src/getHooksFromPlugins.js
similarity index 62%
rename from packages/react-pointcuts/src/getCodeSelectionPlugins.js
rename to packages/react-pointcuts/src/getHooksFromPlugins.js
index dda653e..3d83c47 100644
--- a/packages/react-pointcuts/src/getCodeSelectionPlugins.js
+++ b/packages/react-pointcuts/src/getHooksFromPlugins.js
@@ -3,9 +3,9 @@
* @typedef {object} module:web-toggle-point-react-pointcuts~plugin
* @property {string} name plugin name, used as a prefix when creating {@link https://legacy.reactjs.org/docs/higher-order-components.html|React Higher-Order-Components} when toggling
* @property {Function} onCodeSelected hook to be called when a code selection is made
+ * @property {Function} onVariantError hook to be called when a variant throws an error
*/
+const getHooksFromPlugins = (plugins = [], hook) =>
+ plugins.filter(({ [hook]: usedHook }) => !!usedHook);
-const getCodeSelectionPlugins = (plugins) =>
- plugins?.filter(({ onCodeSelected }) => !!onCodeSelected) ?? null;
-
-export default getCodeSelectionPlugins;
+export default getHooksFromPlugins;
diff --git a/packages/react-pointcuts/src/getHooksFromPlugins.test.js b/packages/react-pointcuts/src/getHooksFromPlugins.test.js
new file mode 100644
index 0000000..3a6bf5a
--- /dev/null
+++ b/packages/react-pointcuts/src/getHooksFromPlugins.test.js
@@ -0,0 +1,31 @@
+import getHooksFromPlugins from "./getHooksFromPlugins";
+
+describe("getHooksFromPlugins", () => {
+ let result;
+
+ describe("when provided some plugins", () => {
+ const plugins = [
+ { onSomeOtherThing: () => {} },
+ { onSomeThing: jest.fn() },
+ { onSomeThing: jest.fn(), onSomeOtherThing: () => {} }
+ ];
+
+ beforeEach(() => {
+ result = getHooksFromPlugins(plugins, "onSomeThing");
+ });
+
+ it("should return all plugins that have a binding to the supplied hook", () => {
+ expect(result).toEqual(plugins.slice(1));
+ });
+ });
+
+ describe("when provided no plugins", () => {
+ beforeEach(() => {
+ result = getHooksFromPlugins(undefined, "onSomeThing");
+ });
+
+ it("should return an empty array", () => {
+ expect(result).toEqual([]);
+ });
+ });
+});
diff --git a/packages/react-pointcuts/src/withTogglePointFactory/getComponent/index.js b/packages/react-pointcuts/src/withTogglePointFactory/getComponent/index.js
index 592d6d9..113a4da 100644
--- a/packages/react-pointcuts/src/withTogglePointFactory/getComponent/index.js
+++ b/packages/react-pointcuts/src/withTogglePointFactory/getComponent/index.js
@@ -1,11 +1,11 @@
-import withPlugins from "./withPlugins";
+import withCodeSelectionPlugins from "./withCodeSelectionPlugins";
import withErrorBoundary from "./withErrorBoundary";
import { forwardRef } from "react";
const getControlOrVariant = ({
matchedFeatures,
matchedVariant,
- logError,
+ onVariantError,
control
}) => {
if (!matchedFeatures.length) {
@@ -27,7 +27,7 @@ const getControlOrVariant = ({
Component = withErrorBoundary({
Variant,
- logError,
+ onVariantError,
fallback: control
});
}
@@ -35,13 +35,23 @@ const getControlOrVariant = ({
};
const getComponent = (params) => {
- let Component = getControlOrVariant(params);
+ const onVariantError = (error) => {
+ params.variantErrorPlugins.forEach(({ onVariantError }) => {
+ Promise.resolve().then(() => {
+ try {
+ onVariantError(error);
+ } catch {} // eslint-disable-line no-empty
+ });
+ });
+ };
+
+ let Component = getControlOrVariant({ ...params, onVariantError });
- const { plugins, ...rest } = params;
- if (plugins) {
- Component = withPlugins({
+ const { codeSelectionPlugins, ...rest } = params;
+ if (codeSelectionPlugins) {
+ Component = withCodeSelectionPlugins({
Component,
- plugins,
+ codeSelectionPlugins,
...rest
});
}
diff --git a/packages/react-pointcuts/src/withTogglePointFactory/getComponent/index.test.js b/packages/react-pointcuts/src/withTogglePointFactory/getComponent/index.test.js
index 401ad62..41ebf64 100644
--- a/packages/react-pointcuts/src/withTogglePointFactory/getComponent/index.test.js
+++ b/packages/react-pointcuts/src/withTogglePointFactory/getComponent/index.test.js
@@ -1,11 +1,11 @@
import getComponent from "./index";
import withErrorBoundary from "./withErrorBoundary";
-import withPlugins from "./withPlugins";
+import withCodeSelectionPlugins from "./withCodeSelectionPlugins";
import { render, screen } from "@testing-library/react";
import { createRef, forwardRef } from "react";
jest.mock("./withErrorBoundary", () => jest.fn());
-jest.mock("./withPlugins", () => jest.fn());
+jest.mock("./withCodeSelectionPlugins", () => jest.fn());
const mockVariantComponent = "test-variant-component";
const MockVariantComponent = forwardRef(
@@ -19,11 +19,18 @@ describe("getComponent", () => {
beforeEach(() => {
jest.clearAllMocks();
params = {
- logError: Symbol("test-error-logger"),
control: () => Symbol("test-base-component"),
- plugins: Symbol("test-plugins")
+ codeSelectionPlugins: Symbol("test-code-selection-plugins"),
+ variantErrorPlugins: [
+ {
+ onVariantError: jest.fn(() => {
+ throw "this errors";
+ })
+ },
+ { onVariantError: jest.fn() }
+ ]
};
- withPlugins.mockImplementation(({ Component }) => {
+ withCodeSelectionPlugins.mockImplementation(({ Component }) => {
Component[pluginMarker] = true;
return Component;
});
@@ -32,7 +39,7 @@ describe("getComponent", () => {
const makeCommonAssertions = () => {
it("should run plugins on the the matched features, passing the params that were passed to the component, in-case the plugins need them", () => {
const { plugins, ...rest } = params;
- expect(withPlugins).toHaveBeenCalledWith({
+ expect(withCodeSelectionPlugins).toHaveBeenCalledWith({
Component: result,
plugins,
...rest
@@ -110,7 +117,7 @@ describe("getComponent", () => {
it("should wrap the variant with an error boundary, to ensure errors in the variant result in falling back to the base/default component", () => {
const { control: Component } = params;
expect(withErrorBoundary).toHaveBeenCalledWith({
- logError: params.logError,
+ onVariantError: expect.any(Function),
Variant: expect.anything(),
fallback: Component
});
@@ -141,6 +148,28 @@ describe("getComponent", () => {
);
});
});
+
+ describe("when the variant throws an error, thus the error boundary calls the passed onVariantError method", () => {
+ const mockError = Symbol("test-error");
+ const syncMethod = jest.fn();
+
+ beforeEach(() => {
+ const [[{ onVariantError }]] = withErrorBoundary.mock.calls;
+ onVariantError(mockError);
+ syncMethod();
+ });
+
+ it("should call the onVariantError callbacks with the error, with the callbacks not holding up execution of the main thread and errors thrown not affecting subsequent callbacks", () => {
+ const [
+ { onVariantError: plugin1Callback },
+ { onVariantError: plugin2Callback }
+ ] = params.variantErrorPlugins;
+ expect(plugin1Callback).toHaveBeenCalledWith(mockError);
+ expect(plugin2Callback).toHaveBeenCalledWith(mockError);
+ expect(syncMethod).toHaveBeenCalledBefore(plugin1Callback);
+ expect(syncMethod).toHaveBeenCalledBefore(plugin2Callback);
+ });
+ });
});
});
});
diff --git a/packages/react-pointcuts/src/withTogglePointFactory/getComponent/withPlugins.js b/packages/react-pointcuts/src/withTogglePointFactory/getComponent/withCodeSelectionPlugins.js
similarity index 71%
rename from packages/react-pointcuts/src/withTogglePointFactory/getComponent/withPlugins.js
rename to packages/react-pointcuts/src/withTogglePointFactory/getComponent/withCodeSelectionPlugins.js
index 9d951d8..1ccf6a0 100644
--- a/packages/react-pointcuts/src/withTogglePointFactory/getComponent/withPlugins.js
+++ b/packages/react-pointcuts/src/withTogglePointFactory/getComponent/withCodeSelectionPlugins.js
@@ -14,8 +14,12 @@ const wrap = ({ Component, useHook, name }, rest) => {
return WithTogglePointPlugin;
};
-const withPlugins = ({ Component, plugins, ...rest }) => {
- for (const { onCodeSelected: useHook, name } of plugins) {
+const withCodeSelectionPlugins = ({
+ Component,
+ codeSelectionPlugins,
+ ...rest
+}) => {
+ for (const { onCodeSelected: useHook, name } of codeSelectionPlugins) {
Component = wrap(
{
Component,
@@ -29,4 +33,4 @@ const withPlugins = ({ Component, plugins, ...rest }) => {
return Component;
};
-export default withPlugins;
+export default withCodeSelectionPlugins;
diff --git a/packages/react-pointcuts/src/withTogglePointFactory/getComponent/withPlugins.test.js b/packages/react-pointcuts/src/withTogglePointFactory/getComponent/withCodeSelectionPlugins.test.js
similarity index 80%
rename from packages/react-pointcuts/src/withTogglePointFactory/getComponent/withPlugins.test.js
rename to packages/react-pointcuts/src/withTogglePointFactory/getComponent/withCodeSelectionPlugins.test.js
index 5238386..92426b7 100644
--- a/packages/react-pointcuts/src/withTogglePointFactory/getComponent/withPlugins.test.js
+++ b/packages/react-pointcuts/src/withTogglePointFactory/getComponent/withCodeSelectionPlugins.test.js
@@ -1,9 +1,9 @@
import { render } from "@testing-library/react";
-import withPlugins from "./withPlugins";
+import withCodeSelectionPlugins from "./withCodeSelectionPlugins";
import { forwardRef } from "react";
-describe("withPlugins", () => {
- const plugins = [
+describe("withCodeSelectionPlugins", () => {
+ const codeSelectionPlugins = [
{ name: "Plugin1", onCodeSelected: jest.fn() },
{ name: "Plugin2", onCodeSelected: jest.fn(), onSomeOtherThing: () => {} }
];
@@ -19,7 +19,7 @@ describe("withPlugins", () => {
const makeCommonAssertions = () => {
it("should execute the 'onCodeSelected' hooks of all plugins, in reverse order (since first plugin applies closest to the wrapped component), passing the props passed to withPlugins", () => {
let lastPlugin;
- plugins.forEach((plugin) => {
+ codeSelectionPlugins.forEach((plugin) => {
expect(plugin.onCodeSelected).toHaveBeenCalledTimes(1);
expect(plugin.onCodeSelected).toHaveBeenCalledWith(rest);
if (lastPlugin) {
@@ -48,13 +48,17 @@ describe("withPlugins", () => {
TestComponent.displayName = displayName;
TestComponent.name = name;
- Wrapped = withPlugins({ Component: TestComponent, plugins, ...rest });
+ Wrapped = withCodeSelectionPlugins({
+ Component: TestComponent,
+ codeSelectionPlugins,
+ ...rest
+ });
render();
});
- it("should have a display name that wraps the component in the plugins, in order", () => {
+ it("should have a display name that wraps the component in the code selection plugins, in order", () => {
expect(Wrapped.displayName).toBe(
- `With${plugins[1].name}(With${plugins[0].name}(${expectedDisplayName}))`
+ `With${codeSelectionPlugins[1].name}(With${codeSelectionPlugins[0].name}(${expectedDisplayName}))`
);
});
diff --git a/packages/react-pointcuts/src/withTogglePointFactory/getComponent/withErrorBoundary.js b/packages/react-pointcuts/src/withTogglePointFactory/getComponent/withErrorBoundary.js
index 35a60af..468696d 100644
--- a/packages/react-pointcuts/src/withTogglePointFactory/getComponent/withErrorBoundary.js
+++ b/packages/react-pointcuts/src/withTogglePointFactory/getComponent/withErrorBoundary.js
@@ -2,7 +2,7 @@ import { Component, forwardRef, createContext } from "react";
const ForwardedRefContext = createContext();
-const withErrorBoundary = ({ Variant, fallback, logError }) => {
+const withErrorBoundary = ({ Variant, onVariantError, fallback }) => {
class TogglePointErrorBoundary extends Component {
constructor(props) {
super(props);
@@ -15,7 +15,7 @@ const withErrorBoundary = ({ Variant, fallback, logError }) => {
componentDidCatch(error) {
error.message = `Variant errored, rendering fallback: ${error.message}`;
- logError(error);
+ onVariantError(error);
}
static contextType = ForwardedRefContext;
diff --git a/packages/react-pointcuts/src/withTogglePointFactory/getComponent/withErrorBoundary.test.js b/packages/react-pointcuts/src/withTogglePointFactory/getComponent/withErrorBoundary.test.js
index f1ffe6b..f61e204 100644
--- a/packages/react-pointcuts/src/withTogglePointFactory/getComponent/withErrorBoundary.test.js
+++ b/packages/react-pointcuts/src/withTogglePointFactory/getComponent/withErrorBoundary.test.js
@@ -3,7 +3,7 @@ import withErrorBoundary from "./withErrorBoundary";
import { render, screen } from "@testing-library/react";
import { createRef, forwardRef } from "react";
-const mockLogError = jest.fn();
+const mockOnVariantError = jest.fn();
describe("withErrorBoundary", () => {
const inboundProps = { "test-prop": Symbol("test-value") };
@@ -34,7 +34,7 @@ describe("withErrorBoundary", () => {
Boundaried = withErrorBoundary({
Variant: MockVariant,
fallback: MockFallback,
- logError: mockLogError
+ onVariantError: mockOnVariantError
});
render();
});
@@ -47,8 +47,8 @@ describe("withErrorBoundary", () => {
expect(screen.queryByTestId(mockFallback)).not.toBeInTheDocument();
});
- it("should not log anything", () => {
- expect(mockLogError).not.toHaveBeenCalled();
+ it("should not call the onVariantError callback", () => {
+ expect(mockOnVariantError).not.toHaveBeenCalled();
});
});
@@ -58,7 +58,7 @@ describe("withErrorBoundary", () => {
const Boundaried = withErrorBoundary({
Variant: MockErrorVariant,
fallback: MockFallback,
- logError: mockLogError
+ onVariantError: mockOnVariantError
});
render();
});
@@ -75,8 +75,8 @@ describe("withErrorBoundary", () => {
expect(screen.queryByTestId(mockVariant)).not.toBeInTheDocument();
});
- it("should log an error indicating that the fallback has been rendered", () => {
- expect(mockLogError).toHaveBeenCalledWith(mockError);
+ it("should call the onVariantError callback, indicating that the fallback has been rendered", () => {
+ expect(mockOnVariantError).toHaveBeenCalledWith(mockError);
});
it("should update the message on the error to include that the variant has errored", () => {
diff --git a/packages/react-pointcuts/src/withTogglePointFactory/index.js b/packages/react-pointcuts/src/withTogglePointFactory/index.js
index 4b0d0aa..a30e583 100644
--- a/packages/react-pointcuts/src/withTogglePointFactory/index.js
+++ b/packages/react-pointcuts/src/withTogglePointFactory/index.js
@@ -1,10 +1,11 @@
import { useMemo, forwardRef } from "react";
import getComponent from "./getComponent";
import useCodeMatches from "../useCodeMatches";
-import getCodeSelectionPlugins from "../getCodeSelectionPlugins";
+import getHooksFromPlugins from "../getHooksFromPlugins";
-// eslint-disable-next-line prettier/prettier, no-empty -- https://github.com/babel/babel/issues/15156
-{}
+// eslint-disable-next-line no-empty -- https://github.com/babel/babel/issues/15156
+{
+}
/**
* A factory function used to create a withTogglePoint React Higher-Order-Component.
* @memberof module:web-toggle-point-react-pointcuts
@@ -12,27 +13,33 @@ import getCodeSelectionPlugins from "../getCodeSelectionPlugins";
* @function
* @param {object} params parameters
* @param {function} params.getActiveFeatures a method to get active features. Called honouring the rules of hooks.
- * @param {external:HostApplication.logError} params.logError a method that logs errors
* @param {string} [params.variantKey='bucket'] A key use to identify a variant from the features data structure. Remaining members of the feature will be passed to the variant as props.
- * @param {Array} [params.plugins] plugins to be used when toggling
- * Will be used when a toggled component throws an error that can be caught by an {@link https://reactjs.org/docs/error-boundaries.html|ErrorBoundary}.
+ * @param {Array} [params.plugins] plugins to be used when toggling.
+ * Any plugins that include a 'onVariantError' hook will be called when a toggled component throws an error that can be caught by an {@link https://reactjs.org/docs/error-boundaries.html|ErrorBoundary}.
* When errors are caught, the control/base code will be used as the fallback component.
* @returns {module:web-toggle-point-react-pointcuts.withTogglePoint} withTogglePoint React Higher-Order-Component.
* @example
* const withTogglePoint = withTogglePointFactory({
* getActiveFeatures,
- * plugins: [plugin1, plugin2, plugin3],
- * logError: (error) => window.NREUM?.noticeError(error)
+ * plugins: [
+ * somePlugin,
+ * {
+ * onCodeSelected: ({ matchedFeatures }) => { console.log("matched: " + JSON.stringify(matchedFeatures)) }); },
+ * },
+ * {
+ * onVariantError: console.error
+ * }
+ * ]
* });
* export default withTogglePoint(MyReactComponent);
*/
const withTogglePointFactory = ({
getActiveFeatures,
- logError,
variantKey = "bucket",
plugins
}) => {
- const codeSelectionPlugins = getCodeSelectionPlugins(plugins);
+ const codeSelectionPlugins = getHooksFromPlugins(plugins, "onCodeSelected");
+ const variantErrorPlugins = getHooksFromPlugins(plugins, "onVariantError");
/**
* A React Higher-Order-Component that wraps a base / control component and swaps in a variant when deemed appropriate by a context
@@ -58,9 +65,9 @@ const withTogglePointFactory = ({
getComponent({
matchedFeatures,
matchedVariant,
- logError,
control,
- plugins: codeSelectionPlugins
+ codeSelectionPlugins,
+ variantErrorPlugins
}),
[matchedFeatures, matchedVariant]
);
diff --git a/packages/react-pointcuts/src/withTogglePointFactory/index.test.js b/packages/react-pointcuts/src/withTogglePointFactory/index.test.js
index 462939d..5d26cc3 100644
--- a/packages/react-pointcuts/src/withTogglePointFactory/index.test.js
+++ b/packages/react-pointcuts/src/withTogglePointFactory/index.test.js
@@ -2,14 +2,21 @@ import withTogglePointFactory from ".";
import { render, screen } from "@testing-library/react";
import useCodeMatches from "../useCodeMatches";
import getComponent from "./getComponent";
-import getCodeSelectionPlugins from "../getCodeSelectionPlugins";
+import getHooksFromPlugins from "../getHooksFromPlugins";
import { createRef, forwardRef } from "react";
const mockMatches = {};
jest.mock("../useCodeMatches", () => jest.fn(() => mockMatches));
-const mockCodeSelectionPlugins = Symbol("test-code-selection-plugins");
-jest.mock("../getCodeSelectionPlugins", () =>
- jest.fn(() => mockCodeSelectionPlugins)
+const mockCodeSelectionPlugins = Symbol("test-plugins");
+const mockVariantErrorPlugins = Symbol("test-plugins");
+jest.mock("../getHooksFromPlugins", () =>
+ jest.fn(
+ (_, type) =>
+ ({
+ onCodeSelected: mockCodeSelectionPlugins,
+ onVariantError: mockVariantErrorPlugins
+ })[type]
+ )
);
const mockVariedComponent = "test-component";
const MockVariedComponent = forwardRef(
@@ -22,7 +29,6 @@ describe("withTogglePointFactory", () => {
let rerender;
const featuresMap = Symbol("test-features-map");
const inboundProps = { "test-prop": Symbol("test-value") };
- const logError = Symbol("test-log-error");
const mockPlugins = [Symbol("test-plugin1"), Symbol("test-plugin2")];
const mockActiveFeatures = Symbol("test-active-features");
const getActiveFeatures = jest.fn(() => mockActiveFeatures);
@@ -43,7 +49,6 @@ describe("withTogglePointFactory", () => {
jest.clearAllMocks();
const withTogglePoint = withTogglePointFactory({
getActiveFeatures,
- logError,
variantKey: inputVariantKey,
plugins: mockPlugins
});
@@ -51,7 +56,17 @@ describe("withTogglePointFactory", () => {
});
it("should get code selection plugins", () => {
- expect(getCodeSelectionPlugins).toHaveBeenCalledWith(mockPlugins);
+ expect(getHooksFromPlugins).toHaveBeenCalledWith(
+ mockPlugins,
+ "onCodeSelected"
+ );
+ });
+
+ it("should get variant errored plugins", () => {
+ expect(getHooksFromPlugins).toHaveBeenCalledWith(
+ mockPlugins,
+ "onVariantError"
+ );
});
const makeRenderedAssertions = () => {
@@ -79,9 +94,9 @@ describe("withTogglePointFactory", () => {
expect(getComponent).toHaveBeenCalledWith({
matchedFeatures,
matchedVariant,
- logError,
control: mockComponent,
- plugins: mockCodeSelectionPlugins
+ codeSelectionPlugins: mockCodeSelectionPlugins,
+ variantErrorPlugins: mockVariantErrorPlugins
});
});
};
diff --git a/packages/react-pointcuts/src/withToggledHookFactory/index.js b/packages/react-pointcuts/src/withToggledHookFactory/index.js
index 9e70d11..69e417b 100644
--- a/packages/react-pointcuts/src/withToggledHookFactory/index.js
+++ b/packages/react-pointcuts/src/withToggledHookFactory/index.js
@@ -1,9 +1,10 @@
import useCodeMatches from "../useCodeMatches";
import pluginsHookFactory from "./pluginsHookFactory";
-import getCodeSelectionPlugins from "../getCodeSelectionPlugins";
+import getHooksFromPlugins from "../getHooksFromPlugins";
// eslint-disable-next-line prettier/prettier, no-empty -- https://github.com/babel/babel/issues/15156
-{}
+{
+}
/**
* A factory function used to create a withToggledHook React hook, wrapping an existing hook/function.
* @memberof module:web-toggle-point-react-pointcuts
@@ -27,8 +28,9 @@ const withToggledHookFactory = ({
variantKey = "bucket",
plugins
}) => {
- const codeSelectionPlugins = getCodeSelectionPlugins(plugins);
- const useCodeSelectionPlugins = pluginsHookFactory(codeSelectionPlugins);
+ const useCodeSelectionPlugins = pluginsHookFactory(
+ getHooksFromPlugins(plugins, "onCodeSelected")
+ );
/**
* A React hook that wraps a base / control function or hook and swaps in a variant based on the active features supplied
diff --git a/packages/react-pointcuts/src/withToggledHookFactory/index.test.js b/packages/react-pointcuts/src/withToggledHookFactory/index.test.js
index a5d5de7..8aa8451 100644
--- a/packages/react-pointcuts/src/withToggledHookFactory/index.test.js
+++ b/packages/react-pointcuts/src/withToggledHookFactory/index.test.js
@@ -1,5 +1,5 @@
import withToggledHookFactory from ".";
-import getCodeSelectionPlugins from "../getCodeSelectionPlugins";
+import getHooksFromPlugins from "../getHooksFromPlugins";
import pluginsHookFactory from "./pluginsHookFactory";
import { renderHook } from "@testing-library/react";
import useCodeMatches from "../useCodeMatches";
@@ -7,7 +7,7 @@ import useCodeMatches from "../useCodeMatches";
const mockMatches = { matchedFeatures: Symbol("test-matched-features") };
jest.mock("../useCodeMatches", () => jest.fn(() => mockMatches));
const mockCodeSelectionPlugins = Symbol("test-code-selection-plugins");
-jest.mock("../getCodeSelectionPlugins", () =>
+jest.mock("../getHooksFromPlugins", () =>
jest.fn(() => mockCodeSelectionPlugins)
);
jest.mock("./pluginsHookFactory", () => jest.fn());
@@ -29,7 +29,10 @@ describe("withToggledHookFactory", () => {
const makeCommonAssertions = () => {
it("should get code selection plugins", () => {
- expect(getCodeSelectionPlugins).toHaveBeenCalledWith(mockPlugins);
+ expect(getHooksFromPlugins).toHaveBeenCalledWith(
+ mockPlugins,
+ "onCodeSelected"
+ );
});
it("should create a code selection hook based on the appropriate plugins", () => {
diff --git a/packages/ssr/docs/CHANGELOG.md b/packages/ssr/docs/CHANGELOG.md
index 40aee00..a6dc120 100644
--- a/packages/ssr/docs/CHANGELOG.md
+++ b/packages/ssr/docs/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [0.2.6] - 2025-09-30
+
+### Fixed
+
+- Used the `prepare-publish.mjs` script provided by repo root version [0.12.0](../../../docs/CHANGELOG.md#0120---2025-09-30) to fix relative links in `README.md` on [npmjs.com](https://www.npmjs.com/) that were moved as part of [0.2.5](#025---2025-09-29)
+
## [0.2.5] - 2025-09-29
### Fixed
diff --git a/packages/ssr/package.json b/packages/ssr/package.json
index 4e11262..2d4ef2e 100644
--- a/packages/ssr/package.json
+++ b/packages/ssr/package.json
@@ -1,7 +1,7 @@
{
"name": "@asos/web-toggle-point-ssr",
"description": "toggle point server side rendering code",
- "version": "0.2.5",
+ "version": "0.2.6",
"license": "MIT",
"type": "module",
"main": "./lib/main.es5.cjs",
@@ -39,7 +39,7 @@
"build": "npm run clean && npm run build:browser && npm run build:server",
"build:browser": "cross-env BABEL_ENV=browser rollup -c build/rollup.mjs --config_isClient true",
"build:server": "rollup -c build/rollup.mjs --config_isClient false",
- "prepublishOnly": "shx cp docs/README.md ../../LICENSE . && npm run build",
+ "prepublishOnly": "node ../prepare-publish.mjs && npm run build",
"postpublish": "shx rm ./README.md LICENSE",
"clean": "rimraf ./lib",
"docs": "rimraf ./docs/**/*.html && jsdoc -c ../jsdoc.conf.js",
@@ -72,7 +72,8 @@
"react": "^18.3.1",
"react-dom": "^18.3.1",
"rollup-plugin-auto-external": "^2.0.0",
- "shx": "^0.4.0"
+ "shx": "^0.4.0",
+ "transform-markdown-links": "^2.1.0"
},
"peerDependencies": {
"prop-types": "^15.7.2",
diff --git a/packages/webpack/docs/CHANGELOG.md b/packages/webpack/docs/CHANGELOG.md
index 4df9b5b..7be0917 100644
--- a/packages/webpack/docs/CHANGELOG.md
+++ b/packages/webpack/docs/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [0.8.3] - 2025-09-30
+
+### Fixed
+
+- Used the `prepare-publish.mjs` script provided by repo root version [0.12.0](../../../docs/CHANGELOG.md#0120---2025-09-30) to fix relative links in `README.md` on [npmjs.com](https://www.npmjs.com/) that were moved as part of [0.8.1](#081---2025-07-14)
+
## [0.8.2] - 2025-09-29
### Fixed
diff --git a/packages/webpack/package.json b/packages/webpack/package.json
index 3ef4631..548ff8d 100644
--- a/packages/webpack/package.json
+++ b/packages/webpack/package.json
@@ -1,7 +1,7 @@
{
"name": "@asos/web-toggle-point-webpack",
"description": "toggle point webpack plugin",
- "version": "0.8.2",
+ "version": "0.8.3",
"license": "MIT",
"type": "module",
"main": "./lib/main.cjs",
@@ -33,7 +33,7 @@
},
"scripts": {
"build": "npm run clean && rollup -c build/rollup.mjs",
- "prepublishOnly": "shx cp docs/README.md ../../LICENSE . && npm run build",
+ "prepublishOnly": "node ../prepare-publish.mjs && npm run build",
"postpublish": "shx rm ./README.md LICENSE",
"clean": "rimraf ./lib",
"docs": "rimraf ./docs/**/*.html && jsdoc -c ../jsdoc.conf.js",
@@ -64,7 +64,8 @@
"webpack": "^5.88.2",
"webpack-cli": "^4.10.0",
"webpack-test-utils": "^2.1.0",
- "shx": "^0.4.0"
+ "shx": "^0.4.0",
+ "transform-markdown-links": "^2.1.0"
},
"peerDependencies": {
"webpack": ">=5.70",