wesl-fetch 0.0.12 → 0.0.13

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/dist/index.js CHANGED
@@ -400,7 +400,8 @@ async function fetchDependencies(rootModuleSource, options) {
400
400
  const shaderRoot = options?.shaderRoot ?? "/shaders";
401
401
  const currentPath = options?.currentPath;
402
402
  const existingSources = options?.existingSources;
403
- const skipExternal = options?.skipExternal ?? false;
403
+ const fetchLibs = options?.fetchLibs ?? true;
404
+ const fetchSources = options?.fetchSources ?? true;
404
405
  const rootModuleName = currentPath ? urlToModulePath(currentPath, shaderRoot) : "package::main";
405
406
  const resolver = new FetchingResolver({
406
407
  ...existingSources,
@@ -416,12 +417,12 @@ async function fetchDependencies(rootModuleSource, options) {
416
417
  const unresolved = getNonVirtualUnresolved(resolver, fetched);
417
418
  if (unresolved.length === 0) break;
418
419
  const [internal, external] = partition(unresolved, isInternal);
419
- await Promise.all(internal.map((p) => resolver.resolveModuleAsync(p)));
420
- if (skipExternal) for (const p of external) fetched.add(p.split("::")[0]);
421
- else {
420
+ if (fetchSources) await Promise.all(internal.map((p) => resolver.resolveModuleAsync(p)));
421
+ else for (const p of internal) fetched.add(p);
422
+ if (fetchLibs) {
422
423
  const newLibs = await fetchExternalBundles(external, fetched);
423
424
  libs.push(...newLibs);
424
- }
425
+ } else for (const p of external) fetched.add(p.split("::")[0]);
425
426
  }
426
427
  return {
427
428
  libs,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wesl-fetch",
3
3
  "description": "Browser-based HTTP fetching for WESL packages from npm",
4
- "version": "0.0.12",
4
+ "version": "0.0.13",
5
5
  "type": "module",
6
6
  "repository": "github:wgsl-tooling-wg/wesl-js",
7
7
  "exports": {
@@ -11,7 +11,7 @@
11
11
  "fflate": "^0.8.2",
12
12
  "nanotar": "^0.2.0",
13
13
  "resolve.exports": "^2.0.3",
14
- "wesl": "0.7.24"
14
+ "wesl": "0.7.25"
15
15
  },
16
16
  "scripts": {
17
17
  "build": "tsdown",
@@ -47,8 +47,10 @@ export interface FetchOptions {
47
47
  currentPath?: string;
48
48
  /** Pre-existing sources to include. */
49
49
  existingSources?: Record<string, string>;
50
- /** Skip fetching external packages from npm (default: false). */
51
- skipExternal?: boolean;
50
+ /** Fetch library packages from npm (default: true). */
51
+ fetchLibs?: boolean;
52
+ /** Fetch local .wesl source files via HTTP (default: true). */
53
+ fetchSources?: boolean;
52
54
  }
53
55
 
54
56
  const virtualModules = ["constants", "env"];
@@ -61,7 +63,8 @@ export async function fetchDependencies(
61
63
  const shaderRoot = options?.shaderRoot ?? "/shaders";
62
64
  const currentPath = options?.currentPath;
63
65
  const existingSources = options?.existingSources;
64
- const skipExternal = options?.skipExternal ?? false;
66
+ const fetchLibs = options?.fetchLibs ?? true;
67
+ const fetchSources = options?.fetchSources ?? true;
65
68
 
66
69
  const rootModuleName = currentPath
67
70
  ? urlToModulePath(currentPath, shaderRoot)
@@ -84,13 +87,17 @@ export async function fetchDependencies(
84
87
  if (unresolved.length === 0) break;
85
88
 
86
89
  const [internal, external] = partition(unresolved, isInternal);
87
- await Promise.all(internal.map(p => resolver.resolveModuleAsync(p)));
88
-
89
- if (skipExternal) {
90
- for (const p of external) fetched.add(p.split("::")[0]);
90
+ if (fetchSources) {
91
+ await Promise.all(internal.map(p => resolver.resolveModuleAsync(p)));
91
92
  } else {
93
+ for (const p of internal) fetched.add(p);
94
+ }
95
+
96
+ if (fetchLibs) {
92
97
  const newLibs = await fetchExternalBundles(external, fetched);
93
98
  libs.push(...newLibs);
99
+ } else {
100
+ for (const p of external) fetched.add(p.split("::")[0]);
94
101
  }
95
102
  }
96
103