@@ -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" >
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
92118Check the scripts in the ` package.json ` for build, watch, lint and test.
0 commit comments