Skip to content

Commit

Permalink
Update unsafe
Browse files Browse the repository at this point in the history
  • Loading branch information
kirill-782 committed Jan 9, 2024
1 parent 36b3ad8 commit a174cbf
Show file tree
Hide file tree
Showing 15 changed files with 13 additions and 591 deletions.
561 changes: 0 additions & 561 deletions lib/index.d.ts

This file was deleted.

1 change: 1 addition & 0 deletions src/handles/Ability.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HandleHolder } from "@war3js/unsafe";
import { CreateAbilityNe } from "../utils/common.js";
import { Handle, HandleEventMap } from "./Handle.js";

Expand Down
1 change: 1 addition & 0 deletions src/handles/Destructable.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HandleHolder } from "@war3js/unsafe";
import { CreateDestructableNe } from "../utils/common.js";
import { Widget, WidgetEventMap } from "./Widget.js";

Expand Down
1 change: 1 addition & 0 deletions src/handles/Handle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { EventMap, EventEmitter } from "@war3js/events";
import { HandleHolder } from "@war3js/unsafe";

export type HandleConstructor<T extends string = string, H extends Handle = Handle> = new (
handle: HandleHolder<T>,
Expand Down
1 change: 1 addition & 0 deletions src/handles/Item.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Widget, WidgetEventMap } from "./Widget.js";
import { CreateItemNe } from "../utils/common.js";
import { HandleHolder } from "@war3js/unsafe";

export interface ItemEventMap extends WidgetEventMap {}

Expand Down
1 change: 1 addition & 0 deletions src/handles/Player.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HandleHolder } from "@war3js/unsafe";
import { PlayerNative, GetLocalPlayer } from "../utils/common.js";
import { Handle, HandleEventMap } from "./Handle.js";

Expand Down
1 change: 1 addition & 0 deletions src/handles/Unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { UnitEventSpellCast } from "../triggerEvents/unit/UnitEventSpellCast.js"
import { UnitEventSpellEffect } from "../triggerEvents/unit/UnitEventSpellEffect.js";
import { UnitEventSpellFinish } from "../triggerEvents/unit/UnitEventSpellFinish.js";
import { UnitEventSpellEndcast } from "../triggerEvents/unit/UnitEventSpellEndcast.js";
import { HandleHolder } from "@war3js/unsafe";

const eventUnitEmiter = unitEmiter;

Expand Down
1 change: 1 addition & 0 deletions src/handles/Widget.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HandleHolder } from "@war3js/unsafe";
import { Handle, HandleEventMap } from "./Handle.js";

export interface WidgetEventMap extends HandleEventMap {
Expand Down
1 change: 1 addition & 0 deletions src/handles/instanceApi/AbilityData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable matching-export-value-to-file-name */
import { HandleHolder } from "@war3js/unsafe";
import { ABILITY_IF_LEVELS, GetAbilityBaseIntegerFieldById, GetAbilityIntegerField } from "../../utils/common.js";
import { Ability } from "../Ability.js";

Expand Down
26 changes: 0 additions & 26 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,29 +85,3 @@ export {
export { UnitState, LimitOp } from "./services/emitters/UnitStateEmiter.js";

export { Websocket } from "./services/websocket/Websocket.js";

// -- ONLY FOR dts-bundle

declare global {
/**
* A low-level object that replaces the handle type in war3js.
* It is not recommended to use it as an object, as some fields may start to be used by the war3js backend.
*/
interface HandleHolder<T extends string = string, P = unknown> {
/**
* Returns jass handle type. For fake handles this is _enum.
*/
get type(): T;
/**
* The library object this handle is bound to
*/
payload: P;

/**
* Compares handle's internal pointers as numbers. ``null`` is interpreted as 0
* @param handle another handle for compare
* @returns true if jass
*/
equals: (handle: HandleHolder<string> | null) => boolean;
}
}
2 changes: 1 addition & 1 deletion src/services/ClassBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getNativeByName, getListNatives, getGlobalsKeys, getGlobal } from "@war3js/unsafe";
import { getNativeByName, getListNatives, getGlobalsKeys, getGlobal, HandleHolder } from "@war3js/unsafe";
import { Handle } from "../handles/Handle.js";
import { toHandleHolderSoft } from "../utils/ToHandleHolder.js";
import { fromHandleHolderSoft } from "../utils/FromHandleHolder.js";
Expand Down
2 changes: 1 addition & 1 deletion src/services/NativeEvents.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EventEmitter, EventMap } from "@war3js/events";

import { setOnNewHandle, setOnHandleDestroy } from "@war3js/unsafe";
import { setOnNewHandle, setOnHandleDestroy, HandleHolder } from "@war3js/unsafe";

export interface NativeEventsEventMap extends EventMap {
newHandle: (handle: HandleHolder<string>, constructorNative: string) => void;
Expand Down
1 change: 1 addition & 0 deletions src/utils/ToHandleHolder.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { HandleHolder } from "@war3js/unsafe";
import { Handle } from "../handles/Handle.js";

export function toHandleHolderSoft(value: any): HandleHolder<string> | null | undefined {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getNativeByName, getGlobal } from "@war3js/unsafe";
import { getNativeByName, getGlobal, HandleHolder } from "@war3js/unsafe";
import { Unit } from "../handles/Unit.js";
import { Player } from "../handles/Player.js";
import { Widget } from "../handles/Widget.js";
Expand Down
2 changes: 1 addition & 1 deletion tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ export default defineConfig([
dts: true,
target: "es5",
tsconfig: "./tsconfig.build.json",
noExternal: ["@war3js/events", "text-decoding", "@war3js/headers-polyfill"],
noExternal: ["@war3js/events", "@war3js/unsafe", "text-decoding", "@war3js/headers-polyfill"],
},
]);

0 comments on commit a174cbf

Please sign in to comment.