solid-logic 3.1.1-86b6bac → 3.1.1-8dffdcb

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
@@ -10,64 +10,71 @@ Core business logic of SolidOS which can be used for any webapp as well.
10
10
 
11
11
  # Usage
12
12
 
13
- ## Install via npm
13
+ ## 📦 Install via npm
14
14
 
15
15
  ```sh
16
- npm install solid-logic
16
+ npm install solid-logic rdflib
17
17
  ```
18
18
 
19
+ > **Important**: `rdflib` is a peer dependency - you must install it separately.
20
+
19
21
  ### Import in your project (ESM/TypeScript)
20
22
 
21
23
  ```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());
23
28
  ```
24
29
 
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
27
35
 
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 |
33
42
 
43
+ ### UMD Bundle (Script Tags)
34
44
 
35
- ### UMD bundle (global variable)
45
+ **⚠️ Important**: Load rdflib **before** solid-logic or you'll get `$rdf is not defined` errors.
36
46
 
37
47
  ```html
38
- <!-- Load dependencies first -->
48
+ <!-- 1. Load rdflib first (creates window.$rdf) -->
39
49
  <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) -->
41
52
  <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
+
46
54
  <script>
47
55
  // Access via global variable
48
- const rdflib = window.$rdf;
49
- const logic = window.SolidLogic;
56
+ const { solidLogicSingleton, store, authn } = window.SolidLogic;
57
+
50
58
  // Example usage
51
- // logic.someFunction(...)
59
+ console.log('Store:', store);
60
+ console.log('Authentication:', authn.currentUser());
52
61
  </script>
53
62
  ```
54
63
 
55
-
56
- ### ESM bundle (import as module)
64
+ ### ESM Bundle (Native Modules)
57
65
 
58
66
  ```html
59
67
  <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';
62
70
 
63
71
  // Example usage
64
- // someFunction(...)
72
+ console.log('Store:', store);
73
+ console.log('Authentication:', authn.currentUser());
65
74
  </script>
66
75
  ```
67
76
 
68
- or
69
-
70
- ### ESM bundle with import map (bare specifiers)
77
+ ### ESM with Import Maps (Recommended)
71
78
 
72
79
  ```html
73
80
  <script type="importmap">
@@ -79,14 +86,33 @@ or
79
86
  }
80
87
  </script>
81
88
  <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';
84
91
 
85
- // Example usage
86
- // someFunction(...)
92
+ // Example usage - cleaner imports!
93
+ console.log('Store:', store);
94
+ console.log('Authentication:', authn.currentUser());
87
95
  </script>
88
96
  ```
89
97
 
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
+
90
116
  # How to develop
91
117
 
92
118
  Check the scripts in the `package.json` for build, watch, lint and test.
@@ -13,17 +13,17 @@ const _fetch = async (url, requestInit) => {
13
13
  };
14
14
  // Global singleton pattern to ensure unique store across library versions
15
15
  const SINGLETON_SYMBOL = Symbol.for('solid-logic-singleton');
16
- const globalThis = (typeof window !== 'undefined' ? window : global);
16
+ const globalTarget = (typeof window !== 'undefined' ? window : global);
17
17
  function getOrCreateSingleton() {
18
- if (!globalThis[SINGLETON_SYMBOL]) {
18
+ if (!globalTarget[SINGLETON_SYMBOL]) {
19
19
  debug.log('SolidLogic: Creating new global singleton instance.');
20
- globalThis[SINGLETON_SYMBOL] = createSolidLogic({ fetch: _fetch }, authSession);
20
+ globalTarget[SINGLETON_SYMBOL] = createSolidLogic({ fetch: _fetch }, authSession);
21
21
  debug.log('Unique quadstore initialized.');
22
22
  }
23
23
  else {
24
24
  debug.log('SolidLogic: Using existing global singleton instance.');
25
25
  }
26
- return globalThis[SINGLETON_SYMBOL];
26
+ return globalTarget[SINGLETON_SYMBOL];
27
27
  }
28
28
  //this const makes solidLogicSingleton global accessible in mashlib
29
29
  const solidLogicSingleton = getOrCreateSingleton();
@@ -1 +1 @@
1
- {"version":3,"file":"solidLogicSingleton.js","sourceRoot":"","sources":["../../src/logic/solidLogicSingleton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,C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AAC,uDAAuD,CAAC,CAAA;IACtE,CAAC;IACD,OAAO,YAAY,CAAC,gBAAgB,CAAE,CAAA;AAC1C,CAAC;AACD,mEAAmE;AACnE,MAAM,mBAAmB,GAAG,oBAAoB,EAAE,CAAA;AAElD,OAAO,EAAE,mBAAmB,EAAE,CAAA"}
@@ -7283,17 +7283,17 @@ const _fetch = async (url, requestInit) => {
7283
7283
  };
7284
7284
  // Global singleton pattern to ensure unique store across library versions
7285
7285
  const SINGLETON_SYMBOL = Symbol.for('solid-logic-singleton');
7286
- const globalThis = (typeof window !== 'undefined' ? window : __webpack_require__.g);
7286
+ const globalTarget = (typeof window !== 'undefined' ? window : __webpack_require__.g);
7287
7287
  function getOrCreateSingleton() {
7288
- if (!globalThis[SINGLETON_SYMBOL]) {
7288
+ if (!globalTarget[SINGLETON_SYMBOL]) {
7289
7289
  log('SolidLogic: Creating new global singleton instance.');
7290
- globalThis[SINGLETON_SYMBOL] = createSolidLogic({ fetch: _fetch }, authSession);
7290
+ globalTarget[SINGLETON_SYMBOL] = createSolidLogic({ fetch: _fetch }, authSession);
7291
7291
  log('Unique quadstore initialized.');
7292
7292
  }
7293
7293
  else {
7294
7294
  log('SolidLogic: Using existing global singleton instance.');
7295
7295
  }
7296
- return globalThis[SINGLETON_SYMBOL];
7296
+ return globalTarget[SINGLETON_SYMBOL];
7297
7297
  }
7298
7298
  //this const makes solidLogicSingleton global accessible in mashlib
7299
7299
  const solidLogicSingleton = getOrCreateSingleton();