Skip to content

Commit

Permalink
upgrade lib pixi
Browse files Browse the repository at this point in the history
  • Loading branch information
brookhong committed Feb 1, 2024
1 parent 8f0a2cf commit 56284d6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@
},
"dependencies": {
"@msgpack/msgpack": "^2.7.0",
"@pixi/app": "^6.2.1",
"@pixi/constants": "^6.2.1",
"@pixi/core": "^6.2.1",
"@pixi/display": "^6.2.1",
"@pixi/graphics": "^6.2.1",
"@pixi/math": "^6.2.1",
"@pixi/runner": "^6.2.1",
"@pixi/settings": "^6.2.1",
"@pixi/sprite": "^6.2.1",
"@pixi/ticker": "^6.2.1",
"@pixi/unsafe-eval": "^6.2.1",
"@pixi/utils": "^6.2.1",
"@pixi/extensions": "^6.2.1",
"@pixi/app": "^7.4.0",
"@pixi/constants": "^7.4.0",
"@pixi/core": "^7.4.0",
"@pixi/display": "^7.4.0",
"@pixi/graphics": "^7.4.0",
"@pixi/math": "^7.4.0",
"@pixi/runner": "^7.4.0",
"@pixi/settings": "^7.4.0",
"@pixi/sprite": "^7.4.0",
"@pixi/ticker": "^7.4.0",
"@pixi/unsafe-eval": "^7.4.0",
"@pixi/utils": "^7.4.0",
"@pixi/extensions": "^7.4.0",
"ace-builds": "^1.4.12",
"dompurify": "^2.3.1",
"js-base64": "^3.7.2",
Expand Down
17 changes: 9 additions & 8 deletions src/nvim/lib/pixi.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
// Customized minimal build for pixi.js
// https://github.com/pixijs/pixi.js/blob/dev/bundles/pixi.js/src/index.ts

import { TickerPlugin } from '@pixi/ticker';
import * as utils from '@pixi/utils';
import { install } from '@pixi/unsafe-eval';
import { ShaderSystem, Renderer, Texture, BatchRenderer } from '@pixi/core';
import '@pixi/unsafe-eval'
import { Application } from '@pixi/app';
import { BatchRenderer, Renderer, Texture } from '@pixi/core';
import { TickerPlugin } from '@pixi/ticker';
export { Application, BatchRenderer, Renderer, Texture, TickerPlugin };

export * from '@pixi/sprite';
export * from '@pixi/display';
export * from '@pixi/graphics';
export { install, ShaderSystem, Application, TickerPlugin, utils, Renderer, Texture, BatchRenderer };
export { Container } from '@pixi/display';
export { Graphics } from '@pixi/graphics';
export { Sprite } from '@pixi/sprite';
export { extensions } from '@pixi/extensions';
export { clearTextureCache, TextureCache } from '@pixi/utils';
16 changes: 7 additions & 9 deletions src/nvim/screen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ type Char = {

const DEFAULT_FONT_FAMILY = 'monospace';

PIXI.Renderer.registerPlugin('batch', PIXI.BatchRenderer);
PIXI.Application.registerPlugin(PIXI.TickerPlugin);
PIXI.install({ ShaderSystem: PIXI.ShaderSystem });
PIXI.extensions.add(PIXI.BatchRenderer, PIXI.TickerPlugin);

const screen = ({
settings,
Expand Down Expand Up @@ -188,7 +186,7 @@ const screen = ({
...windowPixelSize(),
});

screenEl.appendChild(pixi.view);
screenEl.appendChild((pixi.view as unknown) as Node);

screenContainer.appendChild(screenEl);

Expand Down Expand Up @@ -249,7 +247,7 @@ const screen = ({
charCanvas.height = charHeight;
}

PIXI.utils.clearTextureCache();
PIXI.clearTextureCache();
}
screenEl.removeChild(char);
};
Expand Down Expand Up @@ -308,7 +306,7 @@ const screen = ({

const getCharTexture = (char: string, hlId: number) => {
const key = `${char}:${hlId}`;
if (!PIXI.utils.TextureCache[key]) {
if (!PIXI.TextureCache[key]) {
const props = highlightTable[hlId].calculated;
// @ts-expect-error getCharBitmap returns ImageBitmap that can be used as texture
PIXI.Texture.addToCache(PIXI.Texture.from(getCharBitmap(char, props)), key);
Expand All @@ -319,7 +317,7 @@ const screen = ({
const getBgTexture = (bgColor: string, j: number) => {
const isLastCol = j === cols - 1;
const key = `bg:${bgColor}:${isLastCol}`;
if (!PIXI.utils.TextureCache[key]) {
if (!PIXI.TextureCache[key]) {
charCtx.fillStyle = bgColor;
if (isLastCol) {
charCtx.fillRect(0, 0, charWidth * 2, charHeight);
Expand Down Expand Up @@ -466,7 +464,7 @@ const screen = ({
screenEl.style.background = highlightTable[0].calculated.bgColor;
}

PIXI.utils.clearTextureCache();
PIXI.clearTextureCache();
for (let i = 0; i <= rows; i += 1) {
for (let j = 0; j <= cols; j += 1) {
initChar(i, j);
Expand Down Expand Up @@ -895,7 +893,7 @@ const screen = ({

if (requireRedraw) {
measureCharSize();
PIXI.utils.clearTextureCache();
PIXI.clearTextureCache();
if (!isInitial) {
resize(true);
}
Expand Down

0 comments on commit 56284d6

Please sign in to comment.