@reicek/neataptic-ts 0.1.6 → 0.1.7

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.
@@ -29,17 +29,39 @@
29
29
  <script>
30
30
  // Try several candidate paths for the bundle so the example works under different server roots.
31
31
  (function tryLoadBundle() {
32
- const candidates = [
33
- '/docs/assets/ascii-maze.bundle.js',
34
- 'docs/assets/ascii-maze.bundle.js',
35
- './docs/assets/ascii-maze.bundle.js',
36
- '../../docs/assets/ascii-maze.bundle.js',
37
- '../../../docs/assets/ascii-maze.bundle.js'
38
- ];
32
+ // When published via GitHub Pages, the contents of the local `docs/` directory become the site root.
33
+ // Thus the bundle ends up at `<site-root>/assets/ascii-maze.bundle.js`.
34
+ // This page is served from `examples/asciiMaze/`, so relative path to assets is typically `../../assets/...`.
35
+ // Include a few fallbacks for local file browsing or alternate hosting setups.
36
+ // Build candidate paths programmatically to cover:
37
+ // - Running from docs/examples/asciiMaze/ (published) => ../../assets/
38
+ // - Running from test/examples/asciiMaze/ locally before copying => ../../../docs/assets/
39
+ // - Running from copied docs/examples/asciiMaze/ locally (after npm run docs) => ../../assets/
40
+ // - Opening the file directly from filesystem with inconsistent current working directory
41
+ const candidates = (() => {
42
+ const uniq = new Set();
43
+ function add(p){ if(!uniq.has(p)) uniq.add(p); }
44
+ // Upward relative search for assets/ path
45
+ for (let up=0; up<6; up++) {
46
+ const prefix = '../'.repeat(up);
47
+ add(prefix + 'assets/ascii-maze.bundle.js');
48
+ add(prefix + 'docs/assets/ascii-maze.bundle.js');
49
+ }
50
+ // Attempt repo-root prefixed path for GitHub Pages project sites
51
+ try {
52
+ const parts = window.location.pathname.split('/').filter(Boolean);
53
+ if (parts.length) {
54
+ const repo = parts[0];
55
+ add('/' + repo + '/assets/ascii-maze.bundle.js');
56
+ add('/' + repo + '/docs/assets/ascii-maze.bundle.js');
57
+ }
58
+ } catch {}
59
+ return Array.from(uniq);
60
+ })();
39
61
  let tried = 0;
40
62
  function tryNext() {
41
63
  if (tried >= candidates.length) {
42
- console.error('ascii-maze bundle not loaded. Make sure docs/assets/ascii-maze.bundle.js exists and run `npm run build:ascii-maze` from repo root. Tried paths:', candidates);
64
+ console.error('ascii-maze bundle not loaded. Ensure assets/ascii-maze.bundle.js exists (built by `npm run build:ascii-maze`). Tried paths:', candidates);
43
65
  return;
44
66
  }
45
67
  const src = candidates[tried++];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reicek/neataptic-ts",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Architecture-free neural network library with genetic algorithm implementations",
5
5
  "main": "./dist/neataptic.js",
6
6
  "module": "./dist/neataptic.js",
@@ -29,17 +29,39 @@
29
29
  <script>
30
30
  // Try several candidate paths for the bundle so the example works under different server roots.
31
31
  (function tryLoadBundle() {
32
- const candidates = [
33
- '/docs/assets/ascii-maze.bundle.js',
34
- 'docs/assets/ascii-maze.bundle.js',
35
- './docs/assets/ascii-maze.bundle.js',
36
- '../../docs/assets/ascii-maze.bundle.js',
37
- '../../../docs/assets/ascii-maze.bundle.js'
38
- ];
32
+ // When published via GitHub Pages, the contents of the local `docs/` directory become the site root.
33
+ // Thus the bundle ends up at `<site-root>/assets/ascii-maze.bundle.js`.
34
+ // This page is served from `examples/asciiMaze/`, so relative path to assets is typically `../../assets/...`.
35
+ // Include a few fallbacks for local file browsing or alternate hosting setups.
36
+ // Build candidate paths programmatically to cover:
37
+ // - Running from docs/examples/asciiMaze/ (published) => ../../assets/
38
+ // - Running from test/examples/asciiMaze/ locally before copying => ../../../docs/assets/
39
+ // - Running from copied docs/examples/asciiMaze/ locally (after npm run docs) => ../../assets/
40
+ // - Opening the file directly from filesystem with inconsistent current working directory
41
+ const candidates = (() => {
42
+ const uniq = new Set();
43
+ function add(p){ if(!uniq.has(p)) uniq.add(p); }
44
+ // Upward relative search for assets/ path
45
+ for (let up=0; up<6; up++) {
46
+ const prefix = '../'.repeat(up);
47
+ add(prefix + 'assets/ascii-maze.bundle.js');
48
+ add(prefix + 'docs/assets/ascii-maze.bundle.js');
49
+ }
50
+ // Attempt repo-root prefixed path for GitHub Pages project sites
51
+ try {
52
+ const parts = window.location.pathname.split('/').filter(Boolean);
53
+ if (parts.length) {
54
+ const repo = parts[0];
55
+ add('/' + repo + '/assets/ascii-maze.bundle.js');
56
+ add('/' + repo + '/docs/assets/ascii-maze.bundle.js');
57
+ }
58
+ } catch {}
59
+ return Array.from(uniq);
60
+ })();
39
61
  let tried = 0;
40
62
  function tryNext() {
41
63
  if (tried >= candidates.length) {
42
- console.error('ascii-maze bundle not loaded. Make sure docs/assets/ascii-maze.bundle.js exists and run `npm run build:ascii-maze` from repo root. Tried paths:', candidates);
64
+ console.error('ascii-maze bundle not loaded. Ensure assets/ascii-maze.bundle.js exists (built by `npm run build:ascii-maze`). Tried paths:', candidates);
43
65
  return;
44
66
  }
45
67
  const src = candidates[tried++];