solid-shim 0.1.0
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/LICENSE +21 -0
- package/README.md +147 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.html +44 -0
- package/dist/mashlib.js +3337 -0
- package/dist/styles.d.ts +29 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/vendors-node_modules_jsonld_lib_jsonld_js.mashlib.js +415 -0
- package/dist/versionInfo.d.ts +12 -0
- package/dist/versionInfo.d.ts.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 JavaScriptSolidServer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# solid-shim
|
|
2
|
+
|
|
3
|
+
Minimal Solid data browser - a lightweight alternative to [mashlib](https://github.com/SolidOS/mashlib) using the JSS authentication stack.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Same interface as mashlib** - Drop-in replacement for testing and migration
|
|
8
|
+
- **@view support** - Self-describing JSON-LD views ([W3C proposal](https://github.com/w3c/json-ld-syntax/issues/384))
|
|
9
|
+
- **Minimal authentication** - Uses [solid-oidc](https://github.com/JavaScriptSolidServer/solid-oidc) (~600 lines) instead of @inrupt/solid-client-authn-browser (~150KB)
|
|
10
|
+
- **Lightweight** - Smaller bundle size with fewer dependencies
|
|
11
|
+
|
|
12
|
+
## Quick Start
|
|
13
|
+
|
|
14
|
+
```html
|
|
15
|
+
<!DOCTYPE html>
|
|
16
|
+
<html>
|
|
17
|
+
<head>
|
|
18
|
+
<title>My Solid App</title>
|
|
19
|
+
</head>
|
|
20
|
+
<body id="PageBody">
|
|
21
|
+
<header id="PageHeader"></header>
|
|
22
|
+
<main id="DummyUUID"></main>
|
|
23
|
+
<footer id="PageFooter"></footer>
|
|
24
|
+
|
|
25
|
+
<script src="https://unpkg.com/solid-shim/dist/solid-shim.min.js"></script>
|
|
26
|
+
<script>
|
|
27
|
+
panes.runDataBrowser()
|
|
28
|
+
</script>
|
|
29
|
+
</body>
|
|
30
|
+
</html>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## @view - Self-Describing JSON-LD
|
|
34
|
+
|
|
35
|
+
solid-shim supports the `@view` proposal for JSON-LD, allowing data to specify its own renderer.
|
|
36
|
+
|
|
37
|
+
```html
|
|
38
|
+
<!DOCTYPE html>
|
|
39
|
+
<html>
|
|
40
|
+
<body>
|
|
41
|
+
<script type="application/ld+json">
|
|
42
|
+
{
|
|
43
|
+
"@context": { "schema": "http://schema.org/" },
|
|
44
|
+
"@type": "schema:Person",
|
|
45
|
+
"@view": "https://jsonos.com/examples/src/panes/person.js",
|
|
46
|
+
"schema:name": "Marie Curie",
|
|
47
|
+
"schema:jobTitle": "Physicist"
|
|
48
|
+
}
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<script src="https://jsonos.com/browser/dist/mashlib.min.js"></script>
|
|
52
|
+
<script>
|
|
53
|
+
solidShim.renderView()
|
|
54
|
+
</script>
|
|
55
|
+
</body>
|
|
56
|
+
</html>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
When `renderView()` is called, solid-shim:
|
|
60
|
+
1. Finds the JSON-LD on the page
|
|
61
|
+
2. Parses it into the RDF store
|
|
62
|
+
3. Loads the pane module from the `@view` URL
|
|
63
|
+
4. Calls the pane's `render(subject, context)` function
|
|
64
|
+
|
|
65
|
+
### renderView Options
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
solidShim.renderView({
|
|
69
|
+
target: '#myDiv', // Element or selector to render into
|
|
70
|
+
subject: '#me', // Subject ID to render (default: @id from JSON-LD)
|
|
71
|
+
fallbackPane: myPane // Pane to use if @view fails or is missing
|
|
72
|
+
})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Pane Module Format
|
|
76
|
+
|
|
77
|
+
Pane modules are ES modules with a `render` function:
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
export default {
|
|
81
|
+
name: 'person',
|
|
82
|
+
render(subject, context) {
|
|
83
|
+
const store = context.session.store
|
|
84
|
+
const div = document.createElement('div')
|
|
85
|
+
// ... render logic
|
|
86
|
+
return div
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
See the [W3C proposal](https://github.com/w3c/json-ld-syntax/issues/384) for more details.
|
|
92
|
+
|
|
93
|
+
## Global Objects
|
|
94
|
+
|
|
95
|
+
solid-shim exposes the same globals as mashlib:
|
|
96
|
+
|
|
97
|
+
- `$rdf` - RDF library (rdflib)
|
|
98
|
+
- `panes` - Solid panes with `runDataBrowser()` function
|
|
99
|
+
- `SolidLogic` - Authentication and store utilities
|
|
100
|
+
- `SolidLogic.authn` - Authentication logic
|
|
101
|
+
- `SolidLogic.authSession` - Session management
|
|
102
|
+
- `SolidLogic.store` - RDF store
|
|
103
|
+
- `SolidLogic.solidLogicSingleton` - Singleton instance
|
|
104
|
+
- `solidShim` - @view renderer
|
|
105
|
+
- `solidShim.renderView(options)` - Render JSON-LD using @view
|
|
106
|
+
- `solidShim.parseJsonLdToStore(jsonld, baseUri, store)` - Parse JSON-LD into RDF store
|
|
107
|
+
- `mashlib.versionInfo` - Version information
|
|
108
|
+
|
|
109
|
+
## Development
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
git clone https://github.com/JavaScriptSolidServer/solid-shim
|
|
113
|
+
cd solid-shim
|
|
114
|
+
npm install
|
|
115
|
+
npm start
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Build
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npm run build
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Architecture
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
solid-shim
|
|
128
|
+
├── solid-panes-jss (panes and UI components)
|
|
129
|
+
│ ├── solid-ui-jss (UI widgets)
|
|
130
|
+
│ │ └── solid-logic-jss (core logic)
|
|
131
|
+
│ │ └── solid-oidc (authentication)
|
|
132
|
+
│ └── various pane packages
|
|
133
|
+
└── rdflib (RDF processing)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Credits
|
|
137
|
+
|
|
138
|
+
This is a minimal alternative to [SolidOS/mashlib](https://github.com/SolidOS/mashlib) using the JSS authentication stack:
|
|
139
|
+
|
|
140
|
+
- [solid-oidc](https://github.com/JavaScriptSolidServer/solid-oidc) - Minimal Solid-OIDC client
|
|
141
|
+
- [solid-logic-jss](https://github.com/JavaScriptSolidServer/solid-logic-jss) - Core logic with solid-oidc
|
|
142
|
+
- [solid-ui-jss](https://github.com/JavaScriptSolidServer/solid-ui-jss) - UI widgets
|
|
143
|
+
- [solid-panes-jss](https://github.com/JavaScriptSolidServer/solid-panes-jss) - Pane components
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* solid-shim - Minimal Solid data browser
|
|
3
|
+
*
|
|
4
|
+
* Drop-in replacement for mashlib using solid-panes-jss with solid-oidc authentication.
|
|
5
|
+
* Provides the same interface as mashlib for easy testing and migration.
|
|
6
|
+
*
|
|
7
|
+
* Supports @view proposal for JSON-LD (self-describing view hint)
|
|
8
|
+
* See: https://github.com/w3c/json-ld-syntax/issues/384
|
|
9
|
+
*/
|
|
10
|
+
import * as $rdf from 'rdflib';
|
|
11
|
+
import * as panes from 'solid-panes-jss';
|
|
12
|
+
import * as UI from 'solid-ui-jss';
|
|
13
|
+
import { authn, solidLogicSingleton, authSession, store } from 'solid-logic-jss';
|
|
14
|
+
import { versionInfo } from './versionInfo';
|
|
15
|
+
/**
|
|
16
|
+
* Pane module interface for @view
|
|
17
|
+
*/
|
|
18
|
+
interface PaneModule {
|
|
19
|
+
name?: string;
|
|
20
|
+
render: (subject: $rdf.NamedNode, context: PaneContext) => HTMLElement;
|
|
21
|
+
}
|
|
22
|
+
interface PaneContext {
|
|
23
|
+
dom: Document;
|
|
24
|
+
session: {
|
|
25
|
+
store: $rdf.Store;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Parse JSON-LD data island from page into RDF store
|
|
30
|
+
*/
|
|
31
|
+
declare function parseJsonLdToStore(jsonld: any, baseUri: string, targetStore: $rdf.Store): $rdf.NamedNode;
|
|
32
|
+
/**
|
|
33
|
+
* Render JSON-LD using @view
|
|
34
|
+
*
|
|
35
|
+
* Implements the @view proposal: data specifies its own preferred renderer.
|
|
36
|
+
* See: https://github.com/w3c/json-ld-syntax/issues/384
|
|
37
|
+
*
|
|
38
|
+
* @param options.target - Element to render into (default: creates one after JSON-LD script)
|
|
39
|
+
* @param options.subject - Subject ID to render (default: @id from JSON-LD or '#thing')
|
|
40
|
+
* @param options.fallbackPane - Pane to use if @view fails or is missing
|
|
41
|
+
*/
|
|
42
|
+
declare function renderView(options?: {
|
|
43
|
+
target?: HTMLElement | string;
|
|
44
|
+
subject?: string;
|
|
45
|
+
fallbackPane?: PaneModule;
|
|
46
|
+
}): Promise<{
|
|
47
|
+
subject: $rdf.NamedNode;
|
|
48
|
+
store: $rdf.Store;
|
|
49
|
+
} | null>;
|
|
50
|
+
export { versionInfo };
|
|
51
|
+
export { $rdf, panes, UI, authn, authSession, store, solidLogicSingleton };
|
|
52
|
+
export { renderView, parseJsonLdToStore };
|
|
53
|
+
export type { PaneModule, PaneContext };
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAA;AAC9B,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAA;AACxC,OAAO,KAAK,EAAE,MAAM,cAAc,CAAA;AAClC,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAM3C;;GAEG;AACH,UAAU,UAAU;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW,KAAK,WAAW,CAAA;CACvE;AAED,UAAU,WAAW;IACnB,GAAG,EAAE,QAAQ,CAAA;IACb,OAAO,EAAE;QAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAA;KAAE,CAAA;CAC/B;AAED;;GAEG;AACH,iBAAS,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,CA6CjG;AAED;;;;;;;;;GASG;AACH,iBAAe,UAAU,CAAC,OAAO,GAAE;IACjC,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAAA;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,UAAU,CAAA;CACrB,GAAG,OAAO,CAAC;IAAE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;IAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAA;CAAE,GAAG,IAAI,CAAC,CA4EtE;AA4ED,OAAO,EAAE,WAAW,EAAE,CAAA;AACtB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAA;AAC1E,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAA;AACzC,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,CAAA"}
|
package/dist/index.html
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Solid Shim - Data Browser</title>
|
|
7
|
+
<style>
|
|
8
|
+
* {
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
}
|
|
11
|
+
html, body {
|
|
12
|
+
margin: 0;
|
|
13
|
+
padding: 0;
|
|
14
|
+
height: 100%;
|
|
15
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
16
|
+
}
|
|
17
|
+
</style>
|
|
18
|
+
<script defer src="mashlib.js"></script></head>
|
|
19
|
+
<body id="PageBody">
|
|
20
|
+
<header id="PageHeader">
|
|
21
|
+
<!-- Header content will be populated by solid-ui -->
|
|
22
|
+
</header>
|
|
23
|
+
|
|
24
|
+
<main id="DummyUUID">
|
|
25
|
+
<!-- Main content area for panes -->
|
|
26
|
+
</main>
|
|
27
|
+
|
|
28
|
+
<footer id="PageFooter">
|
|
29
|
+
<!-- Footer content will be populated by solid-ui -->
|
|
30
|
+
</footer>
|
|
31
|
+
|
|
32
|
+
<script>
|
|
33
|
+
// Initialize the data browser when the page loads
|
|
34
|
+
window.addEventListener('DOMContentLoaded', function() {
|
|
35
|
+
if (window.panes && window.panes.runDataBrowser) {
|
|
36
|
+
// Get URI from URL hash or query parameter
|
|
37
|
+
const urlParams = new URLSearchParams(window.location.search)
|
|
38
|
+
const uri = urlParams.get('uri') || window.location.hash.slice(1) || null
|
|
39
|
+
window.panes.runDataBrowser(uri)
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
</script>
|
|
43
|
+
</body>
|
|
44
|
+
</html>
|