Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove once from function prototype #1520

Merged
merged 2 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Changelog

_Note: Gaps between patch versions are faulty, broken or test releases._

## v4.0.0-beta.172 (2024-12-25)

#### :boom: Breaking Change

* Updated `@v4fire/core` to version `4.0.0-alpha.54` with renaming `Function.prototype.once` to `memoize`

## v4.0.0-beta.171 (2024-12-23)

#### :house: Internal
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
"@types/semver": "7.3.10",
"@types/webpack": "5.28.0",
"@v4fire/cli": "1.6.0",
"@v4fire/core": "4.0.0-alpha.53",
"@v4fire/core": "v4fire/core#fix/remove-once-fn-proto",
"@v4fire/linters": "git+https://github.com/v4fire/linters#rework_rules",
"@v4fire/storybook": "0.8.0",
"@v4fire/storybook-framework-webpack5": "0.8.0",
Expand Down
4 changes: 2 additions & 2 deletions src/components/directives/bind-with/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* https://github.com/V4Fire/Client/blob/master/LICENSE
*/

import type { EventEmitterLike, PromiseLikeP } from 'core/async';
import type { EventEmitterLikeP, PromiseLikeP } from 'core/async';

import type { DirectiveBinding } from 'core/component/engines';
import type { WatchOptions } from 'core/component/interface';
Expand Down Expand Up @@ -62,7 +62,7 @@ export interface EventListener<A extends any[]> extends Handle<A> {
/**
* An event emitter to listen
*/
emitter?: EventEmitterLike | EventEmitterLike['on'];
emitter?: EventEmitterLikeP;

/**
* The event name to listen for, or a list of such events
Expand Down
1 change: 1 addition & 0 deletions src/components/directives/bind-with/test/unit/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ test.describe('components/directives/bind-with', () => {
const el = await renderDirective(page, {
emitter: (event: string, listener: AnyFunction) => {
document.body.addEventListener(event, listener);
return undefined;
},

on: 'testEvent'
Expand Down
2 changes: 1 addition & 1 deletion src/components/super/i-block/base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ export default abstract class iBlockBase extends iBlockFriends {
// eslint-disable-next-line prefer-const
unwatch: Nullable<Function>;

const emitter: Function = (_: any, wrappedHandler: RawWatchHandler<typeof that, T>) => {
const emitter = (_: any, wrappedHandler: RawWatchHandler<typeof that, T>) => {
wrappedHandler['originalLength'] = handler['originalLength'] ?? handler.length;
handler = wrappedHandler;

Expand Down
2 changes: 1 addition & 1 deletion src/core/component/engines/vue3/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function getComponent(meta: ComponentMeta): ComponentOptions<typeof Compo
unsafe.$vueWatch = this.$watch.bind(this);
init.beforeDataCreateState(ctx);

const emitter: Function = (_: unknown, handler: WatchHandler) => {
const emitter = (_: unknown, handler: WatchHandler) => {
// eslint-disable-next-line @v4fire/unbound-method
const {unwatch} = watch(unsafe.$fields, {deep: true, immediate: true}, handler);
return unwatch;
Expand Down
6 changes: 3 additions & 3 deletions src/core/component/init/states/before-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export function beforeCreateState(

let fn = () => ('getRoot' in ctx ? ctx.getRoot?.() : null) ?? ctx.$root;

fn = fn.once();
fn = fn.memoize();

Object.defineProperty(ctx, $getRoot, {
configurable: true,
Expand Down Expand Up @@ -163,7 +163,7 @@ export function beforeCreateState(
return targetCtx[$getParent];
}

let fn: CanUndef<Function>;
let fn: CanUndef<AnyFunction>;

if (restArgs != null) {
// VNODE
Expand All @@ -179,7 +179,7 @@ export function beforeCreateState(
fn = () => ctx;
}

fn = fn.once();
fn = fn.memoize();

Object.defineProperty(targetCtx, $getParent, {
configurable: true,
Expand Down
2 changes: 1 addition & 1 deletion src/core/init/dependencies/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function* createDependencyIterator(
wait: expandedWait
};

expandedDependency.fn = expandedDependency.fn.once();
expandedDependency.fn = expandedDependency.fn.memoize();
expandedDependencies.set(dependency, expandedDependency);

return expandedDependency;
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5740,7 +5740,7 @@ __metadata:
"@types/webpack-env": "npm:1.18.1"
"@v4fire/cli": "npm:1.6.0"
"@v4fire/config": "npm:1.0.0"
"@v4fire/core": "npm:4.0.0-alpha.53"
"@v4fire/core": "v4fire/core#fix/remove-once-fn-proto"
"@v4fire/design-system": "npm:1.23.0"
"@v4fire/linters": "git+https://github.com/v4fire/linters#rework_rules"
"@v4fire/storybook": "npm:0.8.0"
Expand Down Expand Up @@ -6022,9 +6022,9 @@ __metadata:
languageName: node
linkType: hard

"@v4fire/core@npm:4.0.0-alpha.53":
"@v4fire/core@v4fire/core#fix/remove-once-fn-proto":
version: 4.0.0-alpha.53
resolution: "@v4fire/core@npm:4.0.0-alpha.53"
resolution: "@v4fire/core@https://github.com/v4fire/core.git#commit=cf79bd0e90b2a0929a6aa30a3ce4e63b240aede2"
dependencies:
"@babel/core": "npm:7.17.5"
"@babel/helper-module-transforms": "npm:7.16.7"
Expand Down Expand Up @@ -6167,7 +6167,7 @@ __metadata:
optional: true
xhr2:
optional: true
checksum: e8d94bbb1c671f8b3b69b1671cd5cd9b5f4e42443ec0f68563cb387ef5b30a9b977696c2260ced8ccbb753f220e16b1f28a6462926b1b9a1129fd642122e753d
checksum: f2f7fe25beb1d37f703d31d528d8fa3b7de7ed1ba92668a1fd56c6fd67e9b246ba5b193406a4db6ff38233bbb28660f8ec96e2f6617ff3bbaa81b8b4633c6c85
languageName: node
linkType: hard

Expand Down
Loading