Skip to content

Commit

Permalink
- Downgrading node-fetch to CJS compatible version;
Browse files Browse the repository at this point in the history
- Awaitable methods for XSLT processing, since using `fetch()` requires certain parts to be awaited;
- Stubbing unit test.
  • Loading branch information
leonelsanchesdasilva committed Apr 7, 2024
1 parent 288b584 commit d065a3d
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 64 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ module.exports = {
'no-alert': 'error',
'no-array-constructor': 'error',
'no-async-promise-executor': 'error',
'no-await-in-loop': 'error',
'no-buffer-constructor': 'error',
'no-caller': 'error',
'no-case-declarations': 'off',
Expand Down
4 changes: 3 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export default async (): Promise<Config.InitialOptions> => ({
color: 'greenBright'
},
detectOpenHandles: true,
preset: 'ts-jest',
transform: {
'\\.[jt]sx?$': 'babel-jest'
'^.+\\.(ts|tsx)?$': 'ts-jest',
'^.+\\.(js|jsx)$': 'babel-jest'
}
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"@rollup/plugin-typescript": "^11.1.1",
"@types/he": "^1.2.0",
"@types/jest": "^29.5.2",
"@types/react": "^18.2.74",
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.60.0",
"babel-jest": "^29.5.0",
Expand All @@ -72,7 +73,7 @@
},
"dependencies": {
"he": "^1.2.0",
"node-fetch": "^3.3.2"
"node-fetch": "cjs"
},
"copyFiles": [
{
Expand Down
110 changes: 56 additions & 54 deletions src/xslt/xslt.ts

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions tests/xslt/include.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import assert from 'assert';

import { XmlParser } from "../../src/dom";
import { Xslt } from "../../src/xslt";

describe('xsl:include', () => {
it('Trivial', async () => {
const xmlSource = `<html></html>`;

const xsltSource = `<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="html" indent="yes"/>
<xsl:include href="https://raw.githubusercontent.com/DesignLiquido/xslt-processor/xsl-include/examples/head.xsl"/>
</xsl:stylesheet>`;

const xsltClass = new Xslt();
const xmlParser = new XmlParser();
const xml = xmlParser.xmlParse(xmlSource);
const xslt = xmlParser.xmlParse(xsltSource);
const resultingXml = await xsltClass.xsltProcess(xml, xslt);
// assert.equal(html, '<h1><D>Hello</D>-<D>World</D></h1>');
assert.ok(resultingXml)
});
});
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"demo/**/*",
"dist/**/*",
"interactive-tests/js/**/*",
"node_modules/**/*",
"tests/**/*"
]
}
30 changes: 23 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1879,6 +1879,19 @@
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.3.tgz#3e51a17e291d01d17d3fc61422015a933af7a08f"
integrity sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA==

"@types/prop-types@*":
version "15.7.12"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.12.tgz#12bb1e2be27293c1406acb6af1c3f3a1481d98c6"
integrity sha512-5zvhXYtRNRluoE/jAp4GVsSduVUzNWKkOZrCDBWYtE7biZywwdC2AcEzg+cSMLFRfVgeAFqpfNabiPjxFddV1Q==

"@types/react@^18.2.74":
version "18.2.74"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.74.tgz#2d52eb80e4e7c4ea8812c89181d6d590b53f958c"
integrity sha512-9AEqNZZyBx8OdZpxzQlaFEVCSFUM2YXJH46yPOiOpm078k6ZLOCcuAzGum/zK8YBwY+dbahVNbHrbgrAwIRlqw==
dependencies:
"@types/prop-types" "*"
csstype "^3.0.2"

"@types/[email protected]":
version "0.0.8"
resolved "https://registry.yarnpkg.com/@types/resolve/-/resolve-0.0.8.tgz#f26074d238e02659e323ce1a13d041eee280e194"
Expand Down Expand Up @@ -2876,6 +2889,11 @@ crypto-random-string@^4.0.0:
dependencies:
type-fest "^1.0.1"

csstype@^3.0.2:
version "3.1.3"
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.3.tgz#d80ff294d114fb0e6ac500fbf85b60137d7eff81"
integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==

data-uri-to-buffer@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz#d8feb2b2881e6a4f58c2e08acfd0e2834e26222e"
Expand Down Expand Up @@ -5436,14 +5454,12 @@ node-fetch@^2.6.7:
dependencies:
whatwg-url "^5.0.0"

node-fetch@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-3.3.2.tgz#d1e889bacdf733b4ff3b2b243eb7a12866a0b78b"
integrity sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==
node-fetch@cjs:
version "2.6.7"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.7.tgz#24de9fba827e3b4ae44dc8b20256a379160052ad"
integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==
dependencies:
data-uri-to-buffer "^4.0.0"
fetch-blob "^3.1.4"
formdata-polyfill "^4.0.10"
whatwg-url "^5.0.0"

node-gyp@^9.0.0:
version "9.4.0"
Expand Down

0 comments on commit d065a3d

Please sign in to comment.