linked-data-browser 0.0.8-alpha.7 → 0.0.8-alpha.8

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/README.md CHANGED
@@ -16,13 +16,15 @@ Three steps are required for Expo/Metro. Vite and webpack 5 handle `import.meta.
16
16
 
17
17
  #### 1. Serve `RefreshWorker.js`
18
18
 
19
- `@ldo/solid-react` uses a `SharedWorker` for background token refresh (via `@uvdsl/solid-oidc-client-browser`). Metro cannot serve worker scripts automatically, so copy `RefreshWorker.js` into your project's `public/` folder:
19
+ `@ldo/solid-react` uses a `SharedWorker` for background token refresh (via `@uvdsl/solid-oidc-client-browser`). Metro cannot serve worker scripts automatically, so copy `RefreshWorker.js` into your project's `public/` folder by adding this to your `package.json`:
20
20
 
21
21
  ```json
22
- "postinstall": "mkdir -p public && cp node_modules/@uvdsl/solid-oidc-client-browser/dist/esm/web/RefreshWorker.js public/RefreshWorker.js"
22
+ "postinstall": "ldb-copy-refresh-worker"
23
23
  ```
24
24
 
25
- Add `public/RefreshWorker.js` to your `.gitignore` it's generated, not hand-authored.
25
+ The `ldb-copy-refresh-worker` binary is included in the package and placed in `node_modules/.bin/` on install. It finds `@uvdsl/solid-oidc-client-browser` in your install tree automatically regardless of how npm/pnpm/yarn hoists it.
26
+
27
+ Add `public/RefreshWorker.js` to your `.gitignore` — it is generated, not hand-authored.
26
28
 
27
29
  #### 2. Enable `import.meta` transform in `babel.config.js`
28
30
 
@@ -51,6 +53,22 @@ if (typeof location !== 'undefined') {
51
53
 
52
54
  This must run before any `@ldo` imports.
53
55
 
56
+ ## Development
57
+
58
+ After cloning and running `npm install`, copy the worker file before starting the dev server:
59
+
60
+ ```
61
+ npm run copy-refresh-worker
62
+ ```
63
+
64
+ Then start the dev server:
65
+
66
+ ```
67
+ npm run dev:web # Solid test server + Expo web
68
+ npm run dev:ios # iOS simulator
69
+ npm run dev:android # Android emulator
70
+ ```
71
+
54
72
  ## Publishing
55
73
 
56
74
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linked-data-browser",
3
- "version": "0.0.8-alpha.7",
3
+ "version": "0.0.8-alpha.8",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist-lib/index.d.ts",
@@ -21,7 +21,7 @@
21
21
  "build:ldo": "ldo build --input .shapes --output .ldo",
22
22
  "build:lib": "tsup lib/index.js --format cjs,esm --dts --out-dir dist-lib --clean",
23
23
  "build": "npm run build:standalone && npm run build:server && npm run build:lib",
24
- "postinstall": "mkdir -p public && cp node_modules/@uvdsl/solid-oidc-client-browser/dist/esm/web/RefreshWorker.js public/RefreshWorker.js",
24
+ "copy-refresh-worker": "node scripts/copy-refresh-worker.js",
25
25
  "prepublishOnly": "npm run build"
26
26
  },
27
27
  "dependencies": {
@@ -109,10 +109,14 @@
109
109
  "tsup": "^8.5.0",
110
110
  "typescript": "^5.8.3"
111
111
  },
112
+ "bin": {
113
+ "ldb-copy-refresh-worker": "scripts/copy-refresh-worker.js"
114
+ },
112
115
  "private": false,
113
116
  "files": [
114
117
  "dist-lib",
115
118
  "dist-server",
116
- "dist-standalone"
119
+ "dist-standalone",
120
+ "scripts/copy-refresh-worker.js"
117
121
  ]
118
122
  }
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+ // Copies RefreshWorker.js from @uvdsl/solid-oidc-client-browser into the project's
3
+ // public/ directory so Expo's dev server (and static builds) can serve it at /.
4
+ // Run this after install: npm run copy-refresh-worker
5
+ // Consumers of @o.team/linked-data-browser can add to their own postinstall:
6
+ // "postinstall": "node ./node_modules/@o.team/linked-data-browser/scripts/copy-refresh-worker.js"
7
+
8
+ const path = require('path');
9
+ const fs = require('fs');
10
+
11
+ const PKG = '@uvdsl/solid-oidc-client-browser';
12
+ const WORKER_REL = path.join('dist', 'esm', 'web', 'RefreshWorker.js');
13
+
14
+ function findPackageDir(pkgName, startDir) {
15
+ let dir = startDir;
16
+ while (true) {
17
+ const candidate = path.join(dir, 'node_modules', pkgName);
18
+ if (fs.existsSync(candidate)) return candidate;
19
+ const parent = path.dirname(dir);
20
+ if (parent === dir) return null;
21
+ dir = parent;
22
+ }
23
+ }
24
+
25
+ const pkgDir = findPackageDir(PKG, process.cwd());
26
+ if (!pkgDir) {
27
+ console.error(
28
+ `[copy-refresh-worker] Could not find ${PKG} in any node_modules directory. ` +
29
+ 'Make sure it is installed.'
30
+ );
31
+ process.exit(1);
32
+ }
33
+
34
+ const src = path.join(pkgDir, WORKER_REL);
35
+ const destDir = path.join(process.cwd(), 'public');
36
+ const dest = path.join(destDir, 'RefreshWorker.js');
37
+
38
+ fs.mkdirSync(destDir, { recursive: true });
39
+ fs.copyFileSync(src, dest);
40
+ console.log('[copy-refresh-worker] Copied RefreshWorker.js to', dest);