Skip to content

Commit

Permalink
publish latest
Browse files Browse the repository at this point in the history
  • Loading branch information
dmail committed Nov 12, 2024
1 parent 8474702 commit e09f926
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 22 deletions.
14 changes: 8 additions & 6 deletions dist/jsenv_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -11530,7 +11530,9 @@ const assertAndNormalizeReturnValue = (hook, returnValue, info) => {
if (!returnValueAssertion.appliesTo.includes(hook.name)) {
continue;
}
const assertionResult = returnValueAssertion.assertion(returnValue, info);
const assertionResult = returnValueAssertion.assertion(returnValue, info, {
hook,
});
if (assertionResult !== undefined) {
// normalization
returnValue = assertionResult;
Expand All @@ -11544,15 +11546,15 @@ const returnValueAssertions = [
{
name: "url_assertion",
appliesTo: ["resolveReference", "redirectReference"],
assertion: (valueReturned) => {
assertion: (valueReturned, urlInfo, { hook }) => {
if (valueReturned instanceof URL) {
return valueReturned.href;
}
if (typeof valueReturned === "string") {
return undefined;
}
throw new Error(
`Unexpected value returned by plugin: it must be a string; got ${valueReturned}`,
`Unexpected value returned by "${hook.plugin.name}" plugin: it must be a string; got ${valueReturned}`,
);
},
},
Expand All @@ -11564,7 +11566,7 @@ const returnValueAssertions = [
"finalizeUrlContent",
"optimizeUrlContent",
],
assertion: (valueReturned, urlInfo) => {
assertion: (valueReturned, urlInfo, { hook }) => {
if (typeof valueReturned === "string" || Buffer.isBuffer(valueReturned)) {
return { content: valueReturned };
}
Expand All @@ -11575,13 +11577,13 @@ const returnValueAssertions = [
}
if (typeof content !== "string" && !Buffer.isBuffer(content) && !body) {
throw new Error(
`Unexpected "content" returned by plugin: it must be a string or a buffer; got ${content}`,
`Unexpected "content" returned by "${hook.plugin.name}" ${hook.name} hook: it must be a string or a buffer; got ${content}`,
);
}
return undefined;
}
throw new Error(
`Unexpected value returned by plugin: it must be a string, a buffer or an object; got ${valueReturned}`,
`Unexpected value returned by "${hook.plugin.name}" ${hook.name} hook: it must be a string, a buffer or an object; got ${valueReturned}`,
);
},
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jsenv/core",
"version": "39.5.22",
"version": "39.5.23",
"description": "Tool to develop, test and build js projects",
"license": "MIT",
"author": {
Expand Down
2 changes: 1 addition & 1 deletion packages/related/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jsenv/cli",
"version": "0.2.6",
"version": "0.2.7",
"description": "Command Line Interface for jsenv",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/related/cli/template-node-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"devDependencies": {
"@jsenv/assert": "4.4.2",
"@jsenv/core": "39.5.22",
"@jsenv/core": "39.5.23",
"@jsenv/eslint-config-relax": "1.2.12",
"@jsenv/test": "3.5.25",
"eslint": "9.14.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/related/cli/template-web-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@babel/plugin-syntax-import-attributes": "7.26.0",
"@jsenv/custom-elements-redefine": "0.0.1",
"@jsenv/assert": "4.4.2",
"@jsenv/core": "39.5.22",
"@jsenv/core": "39.5.23",
"@jsenv/plugin-bundling": "2.7.16",
"@jsenv/plugin-minification": "1.5.10",
"@jsenv/eslint-config-relax": "1.2.12",
Expand Down
4 changes: 2 additions & 2 deletions packages/related/cli/template-web-preact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"@babel/plugin-syntax-import-attributes": "7.26.0",
"@babel/plugin-transform-react-jsx": "7.25.9",
"@jsenv/assert": "4.4.2",
"@jsenv/core": "39.5.22",
"@jsenv/plugin-preact": "1.6.25",
"@jsenv/core": "39.5.23",
"@jsenv/plugin-preact": "1.6.26",
"@jsenv/plugin-bundling": "2.7.16",
"@jsenv/plugin-minification": "1.5.10",
"@jsenv/eslint-config-relax": "1.2.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/related/cli/template-web-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@babel/plugin-syntax-import-attributes": "7.26.0",
"@babel/plugin-transform-react-jsx": "7.25.9",
"@jsenv/assert": "4.4.2",
"@jsenv/core": "39.5.22",
"@jsenv/core": "39.5.23",
"@jsenv/plugin-react": "1.5.44",
"@jsenv/plugin-bundling": "2.7.16",
"@jsenv/plugin-minification": "1.5.10",
Expand Down
2 changes: 1 addition & 1 deletion packages/related/cli/template-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"devDependencies": {
"@babel/plugin-syntax-import-attributes": "7.26.0",
"@jsenv/assert": "4.4.2",
"@jsenv/core": "39.5.22",
"@jsenv/core": "39.5.23",
"@jsenv/eslint-config-relax": "1.2.12",
"@jsenv/plugin-bundling": "2.7.16",
"@jsenv/plugin-minification": "1.5.10",
Expand Down
2 changes: 1 addition & 1 deletion packages/related/plugin-preact/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jsenv/plugin-preact",
"version": "1.6.25",
"version": "1.6.26",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/related/plugin-preact/src/jsenv_plugin_preact.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export const jsenvPluginPreact = ({
const afterJsxReplace = magicSource.toContentAndSourcemap({
source: "jsenv_preact",
});
code = afterJsxReplace.code;
code = afterJsxReplace.content;
map = await composeTwoSourcemaps(map, afterJsxReplace.sourcemap);
}
if (refreshEnabled) {
Expand Down
14 changes: 8 additions & 6 deletions src/plugins/plugin_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,9 @@ const assertAndNormalizeReturnValue = (hook, returnValue, info) => {
if (!returnValueAssertion.appliesTo.includes(hook.name)) {
continue;
}
const assertionResult = returnValueAssertion.assertion(returnValue, info);
const assertionResult = returnValueAssertion.assertion(returnValue, info, {
hook,
});
if (assertionResult !== undefined) {
// normalization
returnValue = assertionResult;
Expand All @@ -338,15 +340,15 @@ const returnValueAssertions = [
{
name: "url_assertion",
appliesTo: ["resolveReference", "redirectReference"],
assertion: (valueReturned) => {
assertion: (valueReturned, urlInfo, { hook }) => {
if (valueReturned instanceof URL) {
return valueReturned.href;
}
if (typeof valueReturned === "string") {
return undefined;
}
throw new Error(
`Unexpected value returned by plugin: it must be a string; got ${valueReturned}`,
`Unexpected value returned by "${hook.plugin.name}" plugin: it must be a string; got ${valueReturned}`,
);
},
},
Expand All @@ -358,7 +360,7 @@ const returnValueAssertions = [
"finalizeUrlContent",
"optimizeUrlContent",
],
assertion: (valueReturned, urlInfo) => {
assertion: (valueReturned, urlInfo, { hook }) => {
if (typeof valueReturned === "string" || Buffer.isBuffer(valueReturned)) {
return { content: valueReturned };
}
Expand All @@ -369,13 +371,13 @@ const returnValueAssertions = [
}
if (typeof content !== "string" && !Buffer.isBuffer(content) && !body) {
throw new Error(
`Unexpected "content" returned by plugin: it must be a string or a buffer; got ${content}`,
`Unexpected "content" returned by "${hook.plugin.name}" ${hook.name} hook: it must be a string or a buffer; got ${content}`,
);
}
return undefined;
}
throw new Error(
`Unexpected value returned by plugin: it must be a string, a buffer or an object; got ${valueReturned}`,
`Unexpected value returned by "${hook.plugin.name}" ${hook.name} hook: it must be a string, a buffer or an object; got ${valueReturned}`,
);
},
},
Expand Down

0 comments on commit e09f926

Please sign in to comment.