Skip to content

Commit

Permalink
update text-encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
bdemann committed Dec 12, 2024
1 parent dc239c3 commit d3753d4
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"dependencies": {
"@dfinity/agent": "^2.1.3",
"@dfinity/identity-secp256k1": "^2.1.3",
"@sinonjs/text-encoding": "^0.7.3",
"binaryen": "^116.0.0",
"buffer": "^6.0.3",
"chokidar": "^4.0.1",
Expand Down
5 changes: 4 additions & 1 deletion src/lib/experimental/globals.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import './experimental';
import '../stable/globals'; // We import this to remove type errors having to do with the stable and experimental globals

// @ts-expect-error
import { TextDecoder, TextEncoder } from '@sinonjs/text-encoding';
import { Buffer } from 'buffer';
import * as process from 'process';
import { TextDecoder, TextEncoder } from 'text-encoding';
import { URL } from 'url';
import { v4 } from 'uuid';

Expand Down Expand Up @@ -129,7 +130,9 @@ if (globalThis._azleInsideCanister === true) {
return match;
};

// eslint-disable-next-line @typescript-eslint/no-require-imports
global.Intl = require('intl');
// eslint-disable-next-line @typescript-eslint/no-require-imports
require('intl/locale-data/jsonp/en.js');
}

Expand Down
3 changes: 2 additions & 1 deletion src/lib/stable/globals.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { IDL } from '@dfinity/candid';
import { TextDecoder, TextEncoder } from 'text-encoding';
// @ts-expect-error
import { TextDecoder, TextEncoder } from '@sinonjs/text-encoding';

import { MethodMeta } from '../../build/stable/utils/types';
import { AzleIcExperimental } from '../experimental/ic/azle_ic_experimental';
Expand Down
3 changes: 2 additions & 1 deletion src/lib/stable/ic_apis/reject_code.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// TODO this should be removed once https://github.com/demergent-labs/azle/issues/2271 is resolved
import { TextDecoder, TextEncoder } from 'text-encoding';
// @ts-expect-error
import { TextDecoder, TextEncoder } from '@sinonjs/text-encoding';
globalThis.TextDecoder = TextDecoder;
globalThis.TextEncoder = TextEncoder;

Expand Down
3 changes: 2 additions & 1 deletion src/lib/stable/stable_structures/stable_json.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Principal } from '@dfinity/principal';
import { TextDecoder, TextEncoder } from 'text-encoding';
// @ts-expect-error
import { TextDecoder, TextEncoder } from '@sinonjs/text-encoding';

import { Serializable } from './stable_b_tree_map';

Expand Down

0 comments on commit d3753d4

Please sign in to comment.