Skip to content

Commit 0326168

Browse files
committed
Removed circular dependency
1 parent cc6acf7 commit 0326168

File tree

5 files changed

+28
-25
lines changed

5 files changed

+28
-25
lines changed

src/effects/texture.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { CanvasPolyfill } from '../utils/canvas-polyfill.js';
77
import { Vector } from '../vector.js';
88
import { Registry } from '../registry.js';
99

10-
import { Renderer as CanvasRenderer } from '../renderers/canvas.js';
11-
1210
let anchor;
1311
const regex = {
1412
video: /\.(mp4|webm|ogg)$/i,
@@ -283,7 +281,7 @@ export class Texture extends Element {
283281
if (CanvasPolyfill.Image) {
284282
// TODO: Fix for headless environments
285283
image = new CanvasPolyfill.Image();
286-
CanvasRenderer.Utils.shim(image, 'img');
284+
CanvasPolyfill.shim(image, 'img');
287285
} else if (root.document) {
288286
if (regex.video.test(absoluteSrc)) {
289287
image = document.createElement('video');

src/renderers/canvas.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Curve } from '../utils/curves.js';
44
import { Events } from '../events.js';
55
import { getRatio } from '../utils/device-pixel-ratio.js';
66
import { _ } from '../utils/underscore.js';
7-
import { CanvasPolyfill } from '../utils/canvas-polyfill.js';
87

98
import { Group } from '../group.js';
109
import { Vector } from '../vector.js';
@@ -36,8 +35,6 @@ const canvas = {
3635
baseline: 'alphabetic',
3736
},
3837

39-
shim: CanvasPolyfill.shim,
40-
4138
getRendererType: function (type) {
4239
return type in canvas ? type : 'path';
4340
},

types.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,6 @@ declare module 'two.js/src/renderers/canvas' {
16171617
middle: string;
16181618
right: string;
16191619
};
1620-
shim: (elem: any, name: any) => any;
16211620
group: {
16221621
renderChild: (child: any) => void;
16231622
render: (ctx: any) => any;

utils/build.js

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,32 @@ const path = require('path');
44
const _ = require('underscore');
55
const gzip = require('gzip-size');
66

7-
const publishDateString = (new Date()).toISOString();
7+
const publishDateString = new Date().toISOString();
88
const config = getJSON(path.resolve(__dirname, '../package.json'));
99
const paths = {
1010
entry: path.resolve(__dirname, '../src/two.js'),
1111
umd: path.resolve(__dirname, '../build/two.js'),
1212
esm: path.resolve(__dirname, '../build/two.module.js'),
1313
min: path.resolve(__dirname, '../build/two.min.js'),
14-
license: path.resolve(__dirname, '../LICENSE')
14+
license: path.resolve(__dirname, '../LICENSE'),
1515
};
1616

1717
async function buildModules() {
18-
1918
esbuild.buildSync({
2019
entryPoints: [paths.entry],
2120
outfile: paths.umd,
2221
bundle: true,
2322
minify: false,
2423
format: 'iife',
25-
globalName: 'Two'
24+
globalName: 'Two',
2625
});
2726

2827
esbuild.buildSync({
2928
entryPoints: [paths.entry],
3029
outfile: paths.esm,
3130
bundle: true,
3231
target: 'es6',
33-
format: 'esm'
32+
format: 'esm',
3433
});
3534

3635
esbuild.buildSync({
@@ -39,10 +38,12 @@ async function buildModules() {
3938
bundle: true,
4039
minify: true,
4140
format: 'iife',
42-
globalName: 'Two'
41+
globalName: 'Two',
4342
});
4443

45-
const license = await fs.promises.readFile(paths.license, { encoding: 'utf-8' });
44+
const license = await fs.promises.readFile(paths.license, {
45+
encoding: 'utf-8',
46+
});
4647
const licenseComment = ['/*', license.trim(), '*/'].join('\n');
4748

4849
const umdOutput = await fs.promises.readFile(paths.umd);
@@ -52,19 +53,27 @@ async function buildModules() {
5253
const moduleExports = `(function(){if(typeof exports==='object'&&typeof module!=='undefined'){module.exports=Two}})()`;
5354

5455
return Promise.all([
55-
fs.promises.writeFile(paths.umd, [licenseComment, template(umdOutput, true), moduleExports].join('\n')),
56-
fs.promises.writeFile(paths.esm, [licenseComment, template(esmOutput, false)].join('\n')),
57-
fs.promises.writeFile(paths.min, [licenseComment, template(minOutput, true), moduleExports].join('\n'))
56+
fs.promises.writeFile(
57+
paths.umd,
58+
[licenseComment, template(umdOutput, true), moduleExports].join('\n')
59+
),
60+
fs.promises.writeFile(
61+
paths.esm,
62+
[licenseComment, template(esmOutput, false)].join('\n')
63+
),
64+
fs.promises.writeFile(
65+
paths.min,
66+
[licenseComment, template(minOutput, true), moduleExports].join('\n')
67+
),
5868
]);
59-
6069
}
6170

6271
function template(buffer, isExposed) {
6372
const code = buffer.toString();
6473
const generate = _.template(code);
6574
let result = generate({
6675
version: config.version,
67-
publishDate: publishDateString
76+
publishDate: publishDateString,
6877
});
6978
if (isExposed) {
7079
result = result.replace(/\}\)\(\);/, '})().default;');
@@ -73,7 +82,6 @@ function template(buffer, isExposed) {
7382
}
7483

7584
function publishModule() {
76-
7785
let size;
7886
const result = {};
7987

@@ -87,7 +95,6 @@ function publishModule() {
8795
const outputPath = path.resolve(__dirname, './file-sizes.json');
8896

8997
return fs.promises.writeFile(outputPath, contents);
90-
9198
}
9299

93100
function getFileSize(filepath) {
@@ -106,7 +113,6 @@ function formatFileSize(v) {
106113
}
107114

108115
async function build() {
109-
110116
let startTime, elapsed;
111117

112118
startTime = Date.now();
@@ -124,8 +130,11 @@ async function build() {
124130
} catch (error) {
125131
console.log(error);
126132
}
127-
console.log('Published additional statistics to wiki:', elapsed / 1000, 'seconds');
128-
133+
console.log(
134+
'Published additional statistics to wiki:',
135+
elapsed / 1000,
136+
'seconds'
137+
);
129138
}
130139

131140
function getJSON(filepath) {

utils/file-sizes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"development":"60KB","production":"45KB"}
1+
{"development":"59KB","production":"45KB"}

0 commit comments

Comments
 (0)