Skip to content

Commit 202ceff

Browse files
committed
build only once in PR branches, improved timestamp, readme update
1 parent a44ca66 commit 202ceff

3 files changed

Lines changed: 76 additions & 41 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ permissions:
88
on:
99
push:
1010
branches:
11-
- "**"
11+
- main
1212
pull_request:
1313
branches:
14-
- "**"
14+
- main
1515
workflow_dispatch:
1616

1717
jobs:

README.md

Lines changed: 58 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,64 +10,71 @@ Core business logic of SolidOS which can be used for any webapp as well.
1010

1111
# Usage
1212

13-
## Install via npm
13+
## 📦 Install via npm
1414

1515
```sh
16-
npm install solid-logic
16+
npm install solid-logic rdflib
1717
```
1818

19+
> **Important**: `rdflib` is a peer dependency - you must install it separately.
20+
1921
### Import in your project (ESM/TypeScript)
2022

2123
```js
22-
import { someFunction } from 'solid-logic';
24+
import { solidLogicSingleton, store, authn } from 'solid-logic';
25+
26+
// Example usage
27+
console.log('Current user:', authn.currentUser());
2328
```
2429

25-
## Use directly in a browser
26-
Both UMD and ESM bundles take rdflib as external, this means you need to install it yourself, separately.
30+
## 🌐 Use directly in a browser
31+
32+
Both UMD and ESM bundles externalize rdflib to keep bundle sizes small and avoid version conflicts.
33+
34+
## Available Files
2735

28-
## Files
29-
- For browser UMD, without rdflib: `dist/solid-logic.js` (global `window.SolidLogic`)
30-
- For browser ESM, without rdflib: `dist/solid-logic.esm.js` (import as module)
31-
- UMD has also chunked files.
32-
- both versions also contain minified versions.
36+
| Format | File | Usage | Global Variable |
37+
|--------|------|-------|----------------|
38+
| UMD | `dist/solid-logic.js` | Development | `window.SolidLogic` |
39+
| UMD | `dist/solid-logic.min.js` | Production | `window.SolidLogic` |
40+
| ESM | `dist/solid-logic.esm.js` | Development | Import only |
41+
| ESM | `dist/solid-logic.esm.min.js` | Production | Import only |
3342

43+
### UMD Bundle (Script Tags)
3444

35-
### UMD bundle (global variable)
45+
**⚠️ Important**: Load rdflib **before** solid-logic or you'll get `$rdf is not defined` errors.
3646

3747
```html
38-
<!-- Load dependencies first -->
48+
<!-- 1. Load rdflib first (creates window.$rdf) -->
3949
<script src="https://cdn.jsdelivr.net/npm/rdflib/dist/rdflib.min.js"></script>
40-
<!-- Load solid-logic UMD bundle -->
50+
51+
<!-- 2. Load solid-logic (expects $rdf to exist) -->
4152
<script src="https://unpkg.com/solid-logic/dist/solid-logic.min.js"></script>
42-
<!-- or -->
43-
<!-- script src="https://cdn.jsdelivr.net/npm/solid-logic/dist/solid-logic.min.js"></script -->
44-
<!-- or -->
45-
<!-- script src="dist/solid-logic.js"></script -->
53+
4654
<script>
4755
// Access via global variable
48-
const rdflib = window.$rdf;
49-
const logic = window.SolidLogic;
56+
const { solidLogicSingleton, store, authn } = window.SolidLogic;
57+
5058
// Example usage
51-
// logic.someFunction(...)
59+
console.log('Store:', store);
60+
console.log('Authentication:', authn.currentUser());
5261
</script>
5362
```
5463

55-
56-
### ESM bundle (import as module)
64+
### ESM Bundle (Native Modules)
5765

5866
```html
5967
<script type="module">
60-
import * as $rdf from 'https://esm.sh/rdflib'
61-
import { someFunction } from 'https://esm.sh/solid-logic'
68+
import * as $rdf from 'https://esm.sh/rdflib';
69+
import { solidLogicSingleton, store, authn } from 'https://esm.sh/solid-logic';
6270
6371
// Example usage
64-
// someFunction(...)
72+
console.log('Store:', store);
73+
console.log('Authentication:', authn.currentUser());
6574
</script>
6675
```
6776

68-
or
69-
70-
### ESM bundle with import map (bare specifiers)
77+
### ESM with Import Maps (Recommended)
7178

7279
```html
7380
<script type="importmap">
@@ -79,14 +86,33 @@ or
7986
}
8087
</script>
8188
<script type="module">
82-
import * as $rdf from 'rdflib'
83-
import { someFunction } from 'solid-logic'
89+
import * as $rdf from 'rdflib';
90+
import { solidLogicSingleton, store, authn } from 'solid-logic';
8491
85-
// Example usage
86-
// someFunction(...)
92+
// Example usage - cleaner imports!
93+
console.log('Store:', store);
94+
console.log('Authentication:', authn.currentUser());
8795
</script>
8896
```
8997

98+
## Common Exports
99+
100+
```js
101+
import {
102+
solidLogicSingleton, // Complete singleton instance
103+
store, // RDF store
104+
authn, // Authentication logic
105+
authSession, // Authentication session
106+
ACL_LINK, // ACL constants
107+
getSuggestedIssuers, // Identity provider suggestions
108+
createTypeIndexLogic, // Type index functionality
109+
// Error classes
110+
UnauthorizedError,
111+
NotFoundError,
112+
FetchError
113+
} from 'solid-logic';
114+
```
115+
90116
# How to develop
91117

92118
Check the scripts in the `package.json` for build, watch, lint and test.

timestamp.sh

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
#!/bin/bash
22

33
echo "export default {"
4-
date -u '+buildTime: "%Y-%m-%dT%H:%M:%SZ",'
5-
git log | grep commit | head -1 | sed -e 's/ /: "/' | sed -e 's/$/",/'
4+
date -u '+ buildTime: "%Y-%m-%dT%H:%M:%SZ",'
5+
if [ -d .git ]; then
6+
commit=$(git log --pretty=format:'%H' -n 1)
7+
else
8+
commit="unknown"
9+
fi
10+
echo " commit: \"$commit\","
611
echo " npmInfo: {"
7-
npm version | sed 's/\x1b\[[0-9;:]*[mG]//g' | grep -v '^{' | while read line; do
8-
key=$(echo "$line" | cut -d ':' -f 1 | tr -d ' ')
9-
value=$(echo "$line" | cut -d ':' -f 2- | tr -d ' ')
10-
echo " \"${key}\": \"${value}\","
11-
done
12+
npm version | grep -v '^{' | while IFS=: read key value; do
13+
key=$(echo "$key" | xargs)
14+
value=$(echo $value | xargs)
15+
# Remove any trailing comma from value
16+
value=$(echo "$value" | sed 's/,$//')
17+
if [ "$key" != "}" ]; then
18+
echo " '$key': '$value',"
19+
fi
20+
done
1221
echo " }"
1322
echo "}"

0 commit comments

Comments
 (0)