Skip to content

Releases: 1natsu172/wait-element

v4.0.0

28 Aug 06:29
Compare
Choose a tag to compare

Major update 🚀

New Features

detector option for customized element detector

The option name is detector.optional

This is useful for use cases like wanting to fulfill after checking the state of an element. The return value type is explicitly defined, and when the condition is not fulfilled, it must return { isDetected: false }. Also, the resolved value of waitElement will be the returned result.

const waitPenguin = await waitElement("#animal", {
	detector: (element) => {
		return element?.textContent === "Penguin"
			? { isDetected: true, result: element }
			: { isDetected: false };
	},
});

AbortController is supported

The option name is signal.optional

You can now abort operations in the same way as the native fetch API.

const ac = new AbortController();

const checkElement = waitElement("#find", { signal: ac.signal });

await delay(300); // In fact, there will be some kind of process...

ac.abort("I feel like interrupting");

Performance optimization for concurrent processing

The option name is unifyProcess.optional

This option is enabled(true) by default.

// all waitElement internal process unified
await Promise.all([
	waitElement(".unify", {
		unifyProcess: true,
	}),
	waitElement(".unify", {
		unifyProcess: true,
	}),
	waitElement(".unify", {
		unifyProcess: true,
	}),
]);

About the all options

Note

See TS definition for detailed options information.

BREAKING CHANGE

Warning

There are some breaking changes!

waitDisappearElement has been removed

To replicate waitDisappearElement in v4, use the following approach.

BEFORE

import { waitDisappearElement } from "@1natsu/wait-element";

await waitDisappearElement('.will-disappear');

AFTER

import { isNotExist } from "@1natsu/wait-element/detectors";

await waitElement(".will-disappear", { detector: isNotExist });

Timeout API has changed

The timeout option has been removed. Please use AbortSignal.timeout() instead.

BEFORE

await waitElement('.late-comming', { timeout: 5000 });

AFTER

await waitElement('.late-comming', { signal: AbortSignal.timeout(5000) });

Cancel API has changed

The cancelable API has been removed. Please use AbortController instead.

BEFORE

let el;
try {
  el = waitElement('.cancelable');
  if (!isCondition) el.cancel();
} catch {
  // some handling...
}

AFTER

const ac = new AbortController();
let el;
try {
  el = waitElement(".aborted", {
    signal: ac.signal,
  });
  if (!isCondition) ac.abort("abort!");
} catch (error) {
  // some handling...
}

Concurrent processing is now enabled by default

If you want to use concurrent processing as in v3, set unifyProcess to false.

await waitElement(".please-no-unify", {
  unifyProcess: false,
});

Changed logs

Full Changelog: v3.0.0...v4.0.0

v4.0.0-beta.2

27 Aug 16:22
Compare
Choose a tag to compare
v4.0.0-beta.2 Pre-release
Pre-release
  • Merge pull request #12 from 1natsu172/v4-beta2 1a67dd3
  • feat: beta.2 generics and resolve Result types f8107c0
  • chore(fixme): Setup interrupted by blocker 264648a
  • docs: tweak 9788617
  • Merge pull request #3 from 1natsu172/renovate/configure 94d8cfd
  • chore: configure renovate json cf45a23
  • Add renovate.json 09cf661
  • Merge pull request #10 from 1natsu172/1natsu172-patch-1 3ba78f0
  • fix: generate lockfile a9768e7
  • add ci 9fe2afa
  • chore: bye travis 234c6df

v4.0.0-beta.1...v4.0.0-beta.2

v4.0.0-beta.1

25 Aug 18:40
Compare
Choose a tag to compare
v4.0.0-beta.1 Pre-release
Pre-release
  • Merge pull request #9 from 1natsu172/v4 1be0a7d
  • chore: release command c1433a4
  • chore: release command 3d1087b
  • fix: build settings f1814e0
  • docs: rewrite readme 8d77940
  • chore: tweak type and doc 118fa4c
  • chore: tweak commentout 5d80752
  • test: add already aborted signal 713f423
  • chore: sort package.json 886d454
  • fix: move defu to deps e7af54e
  • testl add coverage 170dedc
  • test: always execute shuffle tests 8ba7c96
  • test: fix timeout tests and dom conflict at each tests problem bf751de
  • chore: tweak commentout 2f69d92
  • test: fix detector testing 2a431a6
  • test: complete unifyProcess af5f25c
  • chore: setting testTimeout to 50sec ba9b6ed
  • chore: bump node c597708
  • feat: daitai implement e33ca63
  • test: add abortable tests bd01cb2
  • test: add unifyProcess option tests aca857b
  • chore: under test b740036
  • test: prepare detector tests 7591ef7
  • chore: coverage 19a715d
  • chore: prepare test description 60a7cd1
  • test: add mergeOptions test 4c529f0
  • chore: revert dom mock to jsdom for AbortController 319d518
  • chore: change browserslist 4d64b57
  • chore!: change to use vitest 6455e8d
  • chore: scaff 2ee734d
  • docs: add about observeConfigs 6173625

v3.0.0...v4.0.0-beta.1

Release v3 major updated

15 Feb 15:41
Compare
Choose a tag to compare

v2.2.0...v3.0.0


New API waitDisappearElement.

Following the suggestion of #6, implemented an API for waiting for an element to disappear.

It is provided by a separate API called waitDisappearElement. The arguments are the same as for waitElement.

Re-wrote all use TypeScript

Re-wrote all in TS. This means that it provides stable types that match the source code.

Changed to named-export

Users can now only use named-import.

Only ES Module is provided.

Starting from v3, only ES Module is provided. The previous CommonJS format is no longer provided.

Change default observe options.

It is now possible to waitElement for mutated attributes such as class.

Extend options for more flexibility

It is now possible to pass options for mutationObserver.

User can pass options to the options object from observeConfigs.

Fix d.ts and upgrade build tools for dev

16 Feb 12:43
Compare
Choose a tag to compare
  • chore: apply xo fix ecf6146
  • Merge pull request #5 from 1natsu172/fix/test-and-build-for-publish d0ee0b9
  • upgrade(build): upgrade rollup v1 latest and plugins a86e824
  • fix(test): upgrade to ava v3 and babel7's and xo 3217bc1
  • Merge pull request #4 from sectsect/fix-ts-error 8abb3b7
  • Fix TypeScript error 96fc354
  • 📝 chore: add some badges 3f45c4d

v2.1.0...v2.2.0

Support TypeScript definition

10 Nov 06:59
Compare
Choose a tag to compare

Add new index.d.ts

  • Support TypeScript completely