Skip to content

Commit

Permalink
AG-34942 Use AGTree parser in the Scriptlets library
Browse files Browse the repository at this point in the history
Merge in ADGUARD-FILTERS/scriptlets from fix/AG-34942 to master

Squashed commit of the following:

commit d398f4c
Author: scripthunter7 <d.tota@adguard.com>
Date:   Thu Sep 19 18:26:06 2024 +0200

    update agtree to v2.1.2

commit 4d40d40
Author: scripthunter7 <d.tota@adguard.com>
Date:   Thu Sep 19 12:17:08 2024 +0200

    use method directly

commit 98f5bb4
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 18 21:02:07 2024 +0200

    resolve fixmes

commit 88dc173
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 18 18:05:53 2024 +0200

    restore quote tests

commit 806d04c
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 18 18:05:34 2024 +0200

    update AGTree to v2.1.0

commit c64a778
Merge: a17a984 1633b06
Author: scripthunter7 <d.tota@adguard.com>
Date:   Mon Sep 16 18:36:48 2024 +0200

    Merge branch 'master' into fix/AG-34942

commit a17a984
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 15:39:19 2024 +0200

    remove .yarnrc

commit 73c468e
Merge: 1bf1041 51a1496
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 15:37:02 2024 +0200

    Merge branch 'master' into fix/AG-34942

commit 1bf1041
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 09:57:02 2024 +0200

    remove unnecessary file

commit 1540c82
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 09:54:12 2024 +0200

    bump minor version

commit d94311d
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 09:53:29 2024 +0200

    update changelog

commit ef9b38e
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 09:44:58 2024 +0200

    remove resolved fixmes

commit 24c0f3a
Merge: 638b526 f37ce70
Author: scripthunter7 <d.tota@adguard.com>
Date:   Wed Sep 11 09:35:33 2024 +0200

    Merge branch 'master' into fix/AG-34942

commit 638b526
Author: scripthunter7 <d.tota@adguard.com>
Date:   Tue Sep 10 18:23:13 2024 +0200

    fix nit

commit ce28e06
Author: scripthunter7 <d.tota@adguard.com>
Date:   Tue Sep 10 18:16:16 2024 +0200

    add yarnrc

commit 459d129
Author: scripthunter7 <d.tota@adguard.com>
Date:   Tue Sep 10 18:16:06 2024 +0200

    update agtree

commit 0b7c743
Author: Maxim Topciu <mtopciu@adguard.com>
Date:   Mon Sep 9 17:34:46 2024 +0300

    fix tests

commit 3548c8c
Author: scripthunter7 <d.tota@adguard.com>
Date:   Mon Sep 9 15:36:28 2024 +0200

    test - do not close server

commit 47dbff2
Author: scripthunter7 <d.tota@adguard.com>
Date:   Mon Sep 9 15:36:18 2024 +0200

    update rollup config

commit f9e01c5
Author: Slava Leleka <v.leleka@adguard.com>
Date:   Fri Sep 6 20:15:17 2024 +0300

    src/helpers/rule-helpers.ts edited online with Bitbucket

... and 13 more commits
  • Loading branch information
scripthunter7 committed Sep 19, 2024
1 parent 1633b06 commit 3988786
Show file tree
Hide file tree
Showing 13 changed files with 453 additions and 1,565 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic

## [Unreleased]

### Added

- Integrated [`@adguard/agtree`][agtree-npm] library for working with rules, compatibility tables,
validator and converter.

### Fixed

- issue with re-adding element on every DOM change in `trusted-create-element` scriptlet [#450]
- setting cookie which name has special prefix `__Host-` or `__Secure-` by
`trusted-set-cookie` and `trusted-set-cookie-reload` scriptlets [#448]

[Unreleased]: https://github.com/AdguardTeam/Scriptlets/compare/v1.11.27...HEAD
[agtree-npm]: https://www.npmjs.com/package/@adguard/agtree
[#450]: https://github.com/AdguardTeam/Scriptlets/issues/450
[#448]: https://github.com/AdguardTeam/Scriptlets/issues/448

Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ AdGuard's Scriptlets and Redirect resources library which provides extended capa
- [Development](#development)
- [How to build](#how-to-build)
- [How to test](#how-to-test)
- [How to link packages](#how-to-link-packages)
- [How to update wiki](#how-to-update-wiki)
- [Usage](#usage)
- [CoreLibs](#corelibs)
Expand Down Expand Up @@ -328,6 +329,20 @@ yarn test
and open needed HTML file from `tests/dist` in your browser with devtools


### <a name="how-to-link-packages"></a> How to link packages

Scriptlets library relies on external packages, such as `@adguard/agtree`.
During development, you might need to link these packages using `yarn link`.
**When you do this, make sure to install dependencies in the `tsurlfilter` monorepo with `pnpm i --shamefully-hoist`**,
otherwise you will encounter issues during tests and builds, because we use Babel runtime and in the nested structure,
the program will try to resolve it from the `node_modules` folder of the linked package, not from the `node_modules`
in the Scriptlets library.

The reason behind this is that `pnpm` creates a nested `node_modules` structure,
while `yarn` and `npm` create a flat structure. By adding `--shamefully-hoist`,
you force `pnpm` to create a flat structure, which is required for the Babel runtime to work correctly.


### <a name="how-to-update-wiki"></a> How to update wiki

There are two scripts to update wiki:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adguard/scriptlets",
"version": "1.11.31",
"version": "1.2.0",
"description": "AdGuard's JavaScript library of Scriptlets and Redirect resources",
"scripts": {
"build": "babel-node -x .js,.ts scripts/build.js",
Expand Down Expand Up @@ -48,6 +48,7 @@
}
},
"dependencies": {
"@adguard/agtree": "^2.1.2",
"@babel/runtime": "^7.20.13",
"js-yaml": "^3.13.1"
},
Expand Down
5 changes: 1 addition & 4 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import commonjs from '@rollup/plugin-commonjs';
import copy from 'rollup-plugin-copy';
import cleanup from 'rollup-plugin-cleanup';
import generateHtml from 'rollup-plugin-generate-html';
import path from 'path';
import project from './package.json';

const BUILD_DIST = 'dist';
Expand All @@ -30,9 +29,7 @@ const FOOTER = `
const commonPlugins = [
json(),
resolve({ extensions: ['.js', '.ts'] }),
commonjs({
include: path.resolve(__dirname, './node_modules/**'),
}),
commonjs(),
babel({
extensions: ['.js', '.ts'],
babelHelpers: 'runtime',
Expand Down
201 changes: 0 additions & 201 deletions src/helpers/compatibility-redirects.ts

This file was deleted.

Loading

0 comments on commit 3988786

Please sign in to comment.