wgsl-play 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wgsl-play",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "repository": "github:wgsl-tooling-wg/wesl-js",
6
6
  "exports": {
@@ -12,8 +12,8 @@
12
12
  "fflate": "^0.8.2",
13
13
  "nanotar": "^0.2.0",
14
14
  "resolve.exports": "^2.0.3",
15
- "wesl": "0.6.49",
16
- "wesl-gpu": "0.1.3"
15
+ "wesl": "0.7.2",
16
+ "wesl-gpu": "0.1.5"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@playwright/test": "^1.53.2",
@@ -3,6 +3,14 @@ import { type ParsedTarFileItem, parseTar } from "nanotar";
3
3
  import type { WeslBundle } from "wesl";
4
4
  import { loadBundlesFromFiles, type WeslBundleFile } from "./BundleHydrator.ts";
5
5
 
6
+ /** Fetch bundle files from an npm package (without evaluating). */
7
+ export async function fetchBundleFilesFromNpm(
8
+ packageName: string,
9
+ ): Promise<WeslBundleFile[]> {
10
+ const tgzUrl = await npmPackageToUrl(packageName);
11
+ return fetchBundleFilesFromUrl(tgzUrl);
12
+ }
13
+
6
14
  /** Load bundles from URL or npm package name, return bundles, package name, and resolved tgz URL. */
7
15
  export async function loadBundlesWithPackageName(
8
16
  input: string,
@@ -28,7 +36,8 @@ export async function loadBundlesWithPackageName(
28
36
  return { bundles, packageName, tgzUrl };
29
37
  }
30
38
 
31
- /** Load WESL bundles from a tgz URL. */
39
+ /** Load WESL bundles from a tgz URL.
40
+ * (handy for privately published packages) */
32
41
  export async function loadBundlesFromTgz(
33
42
  tgzUrl: string,
34
43
  packageName: string,
@@ -41,16 +50,11 @@ export async function loadBundlesFromTgz(
41
50
  return loadBundlesFromFiles(bundleFiles);
42
51
  }
43
52
 
44
- /** Custom tgz URL for lygia (npm package is outdated). */
45
- export const lygiaTgzUrl =
46
- "https://raw.githubusercontent.com/mighdoll/big-files/refs/heads/main/lygia-1.3.5-rc.2.tgz";
47
-
48
53
  /** Resolve input to a tgz URL (converts npm package names to registry URLs). */
49
54
  async function resolvePackageInput(input: string): Promise<string> {
50
55
  if (input.startsWith("http://") || input.startsWith("https://")) {
51
56
  return input;
52
57
  }
53
- if (input === "lygia") return lygiaTgzUrl;
54
58
  return npmPackageToUrl(input);
55
59
  }
56
60
 
@@ -77,7 +81,7 @@ async function fetchAndExtractTgz(
77
81
  }
78
82
 
79
83
  /** Fetch bundle files from a tgz URL (without evaluating). */
80
- export async function fetchBundleFilesFromUrl(
84
+ async function fetchBundleFilesFromUrl(
81
85
  tgzUrl: string,
82
86
  ): Promise<WeslBundleFile[]> {
83
87
  const entries = await fetchAndExtractTgz(tgzUrl);
@@ -91,16 +95,8 @@ export async function fetchBundleFilesFromUrl(
91
95
  return bundleFilesWithoutPkg.map(f => ({ ...f, packageName: pkgName }));
92
96
  }
93
97
 
94
- /** Fetch bundle files from an npm package (without evaluating). */
95
- export async function fetchBundleFilesFromNpm(
96
- packageName: string,
97
- ): Promise<WeslBundleFile[]> {
98
- const tgzUrl = await npmPackageToUrl(packageName);
99
- return fetchBundleFilesFromUrl(tgzUrl);
100
- }
101
-
102
98
  /** Fetch npm package tarball URL from registry metadata. */
103
- export async function npmPackageToUrl(packageName: string): Promise<string> {
99
+ async function npmPackageToUrl(packageName: string): Promise<string> {
104
100
  const metadataUrl = `https://registry.npmjs.org/${packageName}`;
105
101
  const response = await fetch(metadataUrl);
106
102
  if (!response.ok) {
@@ -27,11 +27,7 @@ import {
27
27
  } from "wesl";
28
28
  import type { WeslBundleFile } from "./BundleHydrator.ts";
29
29
  import { bundleRegistry, hydrateBundleRegistry } from "./BundleHydrator.ts";
30
- import {
31
- fetchBundleFilesFromNpm,
32
- fetchBundleFilesFromUrl,
33
- lygiaTgzUrl,
34
- } from "./BundleLoader.ts";
30
+ import { fetchBundleFilesFromNpm } from "./BundleLoader.ts";
35
31
  import { getConfig, type WgslPlayConfig } from "./Config.ts";
36
32
  import { FetchingResolver } from "./FetchingResolver.ts";
37
33
 
@@ -162,11 +158,6 @@ async function fetchOnePackage(
162
158
  if (loaded.has(pkgId)) return [];
163
159
  loaded.add(pkgId);
164
160
 
165
- // Special case for lygia - use custom tgz URL (npm package is outdated)
166
- if (pkgId === "lygia") {
167
- return fetchBundleFilesFromUrl(lygiaTgzUrl);
168
- }
169
-
170
161
  for (const npmName of npmNameVariations(pkgId)) {
171
162
  try {
172
163
  return await fetchBundleFilesFromNpm(npmName);
package/src/WgslPlay.ts CHANGED
@@ -35,20 +35,7 @@ export interface CompileErrorDetail {
35
35
  let styles: CSSStyleSheet | null = null;
36
36
  let template: HTMLTemplateElement | null = null;
37
37
 
38
- /**
39
- * <wgsl-play> - Web component for rendering WESL/WGSL fragment shaders.
40
- *
41
- * @example
42
- * <!-- From URL -->
43
- * <wgsl-play src="./shader.wesl"></wgsl-play>
44
- *
45
- * <!-- Inline source -->
46
- * <wgsl-play>
47
- * @fragment fn fs_main() -> @location(0) vec4f {
48
- * return vec4f(1.0, 0.0, 0.0, 1.0);
49
- * }
50
- * </wgsl-play>
51
- */
38
+ /** <wgsl-play> web component for rendering WESL/WGSL fragment shaders. */
52
39
  export class WgslPlay extends HTMLElement {
53
40
  static observedAttributes = ["src", "shader-root"];
54
41
 
package/tsconfig.json CHANGED
@@ -1,4 +1,7 @@
1
1
  {
2
2
  "extends": "../../tsconfig.browser.json",
3
+ "compilerOptions": {
4
+ "types": ["@webgpu/types", "node"]
5
+ },
3
6
  "include": ["src"]
4
7
  }