Skip to content

Commit d530dee

Browse files
authored
fix: Alter entry points to support older TypeScript versions, maintain deprecated JSDocs in stabilized ['~unstable'] APIs (#2212)
1 parent 7b94e1d commit d530dee

80 files changed

Lines changed: 182 additions & 131 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/pkg-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
run: pnpm nightly-build
4242

4343
- name: Publish (pkg.pr.new)
44-
run: npx pkg-pr-new publish './packages/typegpu/dist' './packages/typegpu-noise/dist' './packages/unplugin-typegpu/dist' --json output.json --comment=off
44+
run: npx pkg-pr-new publish './packages/typegpu/dist' './packages/typegpu-noise/dist' './packages/unplugin-typegpu/dist' --json output.json --comment=off --pnpm
4545
- name: Post or update comment
4646
uses: actions/github-script@v6
4747
with:

packages/typegpu/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
"type": "module",
88
"exports": {
99
"./package.json": "./package.json",
10-
".": "./src/index.ts",
10+
".": {
11+
"types": "./src/index.d.ts",
12+
"default": "./src/index.js"
13+
},
1114
"./data": "./src/data/index.ts",
1215
"./std": "./src/std/index.ts",
1316
"./common": "./src/common/index.ts"

packages/typegpu/src/index.d.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @module typegpu
3+
*/
4+
5+
// NOTE: This is a barrel file, internal files should not import things from this file
6+
7+
export declare const tgpu: {
8+
const: typeof import('./core/constant/tgpuConstant.ts').constant;
9+
fn: typeof import('./core/function/tgpuFn.ts').fn;
10+
comptime: typeof import('./core/function/comptime.ts').comptime;
11+
resolve: typeof import('./core/resolve/tgpuResolve.ts').resolve;
12+
resolveWithContext:
13+
typeof import('./core/resolve/tgpuResolve.ts').resolveWithContext;
14+
init: typeof import('./core/root/init.ts').init;
15+
initFromDevice: typeof import('./core/root/init.ts').initFromDevice;
16+
slot: typeof import('./core/slot/slot.ts').slot;
17+
lazy: typeof import('./core/slot/lazy.ts').lazy;
18+
accessor: typeof import('./core/slot/accessor.ts').accessor;
19+
mutableAccessor: typeof import('./core/slot/accessor.ts').mutableAccessor;
20+
privateVar: typeof import('./core/variable/tgpuVariable.ts').privateVar;
21+
workgroupVar: typeof import('./core/variable/tgpuVariable.ts').workgroupVar;
22+
vertexLayout:
23+
typeof import('./core/vertexLayout/vertexLayout.ts').vertexLayout;
24+
bindGroupLayout: typeof import('./tgpuBindGroupLayout.ts').bindGroupLayout;
25+
computeFn: typeof import('./core/function/tgpuComputeFn.ts').computeFn;
26+
fragmentFn: typeof import('./core/function/tgpuFragmentFn.ts').fragmentFn;
27+
vertexFn: typeof import('./core/function/tgpuVertexFn.ts').vertexFn;
28+
unroll: typeof import('./core/unroll/tgpuUnroll.ts').unroll;
29+
30+
'~unstable': typeof import('./tgpuUnstable.ts');
31+
};
32+
33+
export default tgpu;
34+
35+
export * from './indexNamedExports.ts';

packages/typegpu/src/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @module typegpu
3+
*/
4+
5+
// NOTE: This is a barrel file, internal files should not import things from this file
6+
7+
import * as tgpu from './tgpu.ts';
8+
export * as tgpu from './tgpu.ts';
9+
export default tgpu;
10+
11+
export * from './indexNamedExports.ts';
Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
/**
2-
* @module typegpu
3-
*/
4-
51
// NOTE: This is a barrel file, internal files should not import things from this file
62

7-
import * as tgpu from './tgpu.ts';
8-
export * as tgpu from './tgpu.ts';
9-
export default tgpu;
10-
113
export * as d from './data/index.ts';
124
export * as std from './std/index.ts';
135
export * as common from './common/index.ts';
Lines changed: 56 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,63 @@
11
// NOTE: This is a barrel file, internal files should not import things from this file
22

3-
export {
4-
/** @deprecated This feature is now stable, use tgpu.const. */
5-
constant as const,
6-
} from './core/constant/tgpuConstant.ts';
73
export { declare } from './core/declare/tgpuDeclare.ts';
8-
export {
9-
/** @deprecated This feature is now stable, use tgpu.comptime. */
10-
comptime,
11-
} from './core/function/comptime.ts';
12-
export {
13-
/** @deprecated This feature is now stable, use tgpu.computeFn. */
14-
computeFn,
15-
} from './core/function/tgpuComputeFn.ts';
16-
export {
17-
/** @deprecated This feature is now stable, use tgpu.fn. */
18-
fn,
19-
} from './core/function/tgpuFn.ts';
20-
export {
21-
/** @deprecated This feature is now stable, use tgpu.fragmentFn. */
22-
fragmentFn,
23-
} from './core/function/tgpuFragmentFn.ts';
24-
export {
25-
/** @deprecated This feature is now stable, use tgpu.vertexFn. */
26-
vertexFn,
27-
} from './core/function/tgpuVertexFn.ts';
284
export { rawCodeSnippet } from './core/rawCodeSnippet/tgpuRawCodeSnippet.ts';
295
export { namespace } from './core/resolve/namespace.ts';
306
export { simulate } from './core/simulate/tgpuSimulate.ts';
7+
8+
// DEPRECATED
9+
10+
import { constant } from './core/constant/tgpuConstant.ts';
11+
import { comptime } from './core/function/comptime.ts';
12+
import { computeFn } from './core/function/tgpuComputeFn.ts';
13+
import { fn } from './core/function/tgpuFn.ts';
14+
import { fragmentFn } from './core/function/tgpuFragmentFn.ts';
15+
import { vertexFn } from './core/function/tgpuVertexFn.ts';
16+
import { accessor, mutableAccessor } from './core/slot/accessor.ts';
17+
import { lazy } from './core/slot/lazy.ts';
18+
import { slot } from './core/slot/slot.ts';
19+
import { privateVar, workgroupVar } from './core/variable/tgpuVariable.ts';
20+
import { vertexLayout } from './core/vertexLayout/vertexLayout.ts';
21+
22+
/** @deprecated This feature is now stable, use tgpu.const. */
23+
const _constant = constant;
24+
/** @deprecated This feature is now stable, use tgpu.comptime. */
25+
const _comptime = comptime;
26+
/** @deprecated This feature is now stable, use tgpu.computeFn. */
27+
const _computeFn = computeFn;
28+
/** @deprecated This feature is now stable, use tgpu.fn. */
29+
const _fn = fn;
30+
/** @deprecated This feature is now stable, use tgpu.fragmentFn. */
31+
const _fragmentFn = fragmentFn;
32+
/** @deprecated This feature is now stable, use tgpu.vertexFn. */
33+
const _vertexFn = vertexFn;
34+
/** @deprecated This feature is now stable, use tgpu.accessor. */
35+
const _accessor = accessor;
36+
/** @deprecated This feature is now stable, use tgpu.mutableAccessor. */
37+
const _mutableAccessor = mutableAccessor;
38+
/** @deprecated This feature is now stable, use tgpu.lazy. */
39+
const _lazy = lazy;
40+
/** @deprecated This feature is now stable, use tgpu.slot. */
41+
const _slot = slot;
42+
/** @deprecated This feature is now stable, use tgpu.privateVar. */
43+
const _privateVar = privateVar;
44+
/** @deprecated This feature is now stable, use tgpu.workgroupVar. */
45+
const _workgroupVar = workgroupVar;
46+
/** @deprecated This feature is now stable, use tgpu.vertexLayout. */
47+
const _vertexLayout = vertexLayout;
48+
3149
export {
32-
/** @deprecated This feature is now stable, use tgpu.accessor. */
33-
accessor,
34-
/** @deprecated This feature is now stable, use tgpu.mutableAccessor. */
35-
mutableAccessor,
36-
} from './core/slot/accessor.ts';
37-
export {
38-
/** @deprecated This feature is now stable, use tgpu.lazy. */
39-
lazy as derived,
40-
} from './core/slot/lazy.ts';
41-
export {
42-
/** @deprecated This feature is now stable, use tgpu.slot. */
43-
slot,
44-
} from './core/slot/slot.ts';
45-
export {
46-
/** @deprecated This feature is now stable, use tgpu.privateVar. */
47-
privateVar,
48-
/** @deprecated This feature is now stable, use tgpu.workgroupVar. */
49-
workgroupVar,
50-
} from './core/variable/tgpuVariable.ts';
51-
export {
52-
/** @deprecated This feature is now stable, use tgpu.vertexLayout. */
53-
vertexLayout,
54-
} from './core/vertexLayout/vertexLayout.ts';
50+
_accessor as accessor,
51+
_comptime as comptime,
52+
_computeFn as computeFn,
53+
_constant as const,
54+
_fn as fn,
55+
_fragmentFn as fragmentFn,
56+
_lazy as derived,
57+
_mutableAccessor as mutableAccessor,
58+
_privateVar as privateVar,
59+
_slot as slot,
60+
_vertexFn as vertexFn,
61+
_vertexLayout as vertexLayout,
62+
_workgroupVar as workgroupVar,
63+
};

packages/typegpu/tests/accessor.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, expectTypeOf } from 'vitest';
2-
import tgpu, { d, std, type TgpuAccessor } from '../src/index.ts';
2+
import tgpu, { d, std, type TgpuAccessor } from '../src/index.js';
33
import { it } from './utils/extendedIt.ts';
44

55
const RED = d.vec3f(1, 0, 0);

packages/typegpu/tests/align.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, expectTypeOf, it } from 'vitest';
2-
import { d, tgpu } from '../src/index.ts';
2+
import { d, tgpu } from '../src/index.js';
33

44
describe('d.align', () => {
55
it('adds @align attribute for custom aligned struct members', () => {

packages/typegpu/tests/array.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { attest } from '@ark/attest';
22
import { BufferReader, BufferWriter } from 'typed-binary';
33
import { describe, expect, expectTypeOf, it } from 'vitest';
44
import { readData, writeData } from '../src/data/dataIO.ts';
5-
import { d, tgpu } from '../src/index.ts';
5+
import { d, tgpu } from '../src/index.js';
66
import { namespace } from '../src/core/resolve/namespace.ts';
77
import { resolve } from '../src/resolutionCtx.ts';
88
import type { Infer } from '../src/shared/repr.ts';

packages/typegpu/tests/attributes.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, expect, expectTypeOf, it } from 'vitest';
2-
import { d, tgpu } from '../src/index.ts';
2+
import { d, tgpu } from '../src/index.js';
33

44
describe('attributes', () => {
55
it('adds attributes in the correct order', () => {

0 commit comments

Comments
 (0)