Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ Use these scripts for local workspace builds:

`npm run build`, `npm run watch`, and `npm run start` stay on default package resolution.

### Authentication worker asset (solid-logic)

mashlib relies on solid-logic authentication and should serve the refresh worker as a same-origin static asset.

- Worker file to serve: `RefreshWorker.js`
- Runtime override (optional): `window.__SOLID_LOGIC_WORKER_URL__`

See solid-logic runtime contract details in:
https://github.com/solidos/solid-logic#worker-asset-and-runtime-configuration

## Goals

The goals of mashlib overlap with the [SolidOS Goals](https://solidos.solidcommunity.net/Team/docs/SolidOSNorthStar.html).
Expand Down
5 changes: 5 additions & 0 deletions src/databrowser.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"/>
<title>SolidOS</title>
<script>
if (!window.__SOLID_LOGIC_WORKER_URL__) {
window.__SOLID_LOGIC_WORKER_URL__ = new URL('/RefreshWorker.js', window.location.origin).toString()
}
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
panes.runDataBrowser()
Expand Down
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// (they declare `solid-logic` and `rdflib` as UMD externals with
// root: "SolidLogic" / "$rdf").
import './globals'
import './worker-config'

import * as $rdf from 'rdflib'
import * as SolidLogic from 'solid-logic'
Expand Down Expand Up @@ -67,7 +68,11 @@ global.panes.runDataBrowser = function (uri?:string|$rdf.NamedNode|null) {

// Authenticate the user
SolidLogic.authn.checkUser()
.then(() => panes.initMainPage(SolidLogic.solidLogicSingleton.store, uri))
.then(() => {
// Avoid rdflib type identity clashes when workspace packages resolve different node_modules paths.
const storeForPanes = SolidLogic.solidLogicSingleton.store as unknown as Parameters<typeof panes.initMainPage>[0]
return panes.initMainPage(storeForPanes, uri)
})
.then(() => {
// Inject render environment into pane context after outliner exists
syncEnvironmentToContext('initMainPage')
Expand Down
13 changes: 13 additions & 0 deletions src/worker-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Configure solid-logic worker URL before solid-logic module initialization.
// Consumers can still override this by defining __SOLID_LOGIC_WORKER_URL__ earlier.
declare global {
interface Window {
__SOLID_LOGIC_WORKER_URL__?: string | URL
}
}

if (typeof window !== 'undefined' && !window.__SOLID_LOGIC_WORKER_URL__) {
window.__SOLID_LOGIC_WORKER_URL__ = new URL('/RefreshWorker.js', window.location.origin).toString()
}

export {}
5 changes: 5 additions & 0 deletions static/browse.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
}
}, true);
</script>
<script>
if (!window.__SOLID_LOGIC_WORKER_URL__) {
window.__SOLID_LOGIC_WORKER_URL__ = new URL('/RefreshWorker.js', window.location.origin).toString()
}
</script>
<link type="text/css" rel="stylesheet" href="mash.css" />
<script type="text/javascript" src="mashlib.js"></script>
<script>
Expand Down
8 changes: 6 additions & 2 deletions webpack.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,17 @@ const packageAliases = {
}

const workspaceAliases = {
'solid-logic': path.resolve('../solid-logic/src/index.ts'),
'SolidLogic': path.resolve('../solid-logic/src/index.ts'),
'solid-panes$': path.resolve('../solid-panes/src/index.ts'),
'solid-ui$': path.resolve('../solid-ui/src/index.ts'),
'UI$': path.resolve('../solid-ui/src/index.ts'),
'solid-ui/components/header$': path.resolve('../solid-ui/src/v2/components/header/index.ts'),
}

function getResolutionMode (env = {}) {
const resolutionMode = env.resolutionMode || process.env.MASHLIB_RESOLUTION_MODE || PACKAGE_RESOLUTION_MODE
const isDevServeOrWatch = Boolean(process.env.WEBPACK_SERVE || process.argv.includes('--watch'))
const resolutionMode = env.resolutionMode || process.env.MASHLIB_RESOLUTION_MODE || (isDevServeOrWatch ? WORKSPACE_RESOLUTION_MODE : PACKAGE_RESOLUTION_MODE)
Comment on lines +34 to +35
if (resolutionMode !== PACKAGE_RESOLUTION_MODE && resolutionMode !== WORKSPACE_RESOLUTION_MODE) {
throw new Error(`Invalid mashlib webpack resolution mode: ${resolutionMode}. Use "${PACKAGE_RESOLUTION_MODE}" or "${WORKSPACE_RESOLUTION_MODE}".`)
}
Expand Down Expand Up @@ -130,7 +133,8 @@ function createCommonConfig (resolutionMode) {
new NodePolyfillPlugin(),
new CopyPlugin({
patterns: [
{ from: 'static', to: '.' }
{ from: 'static', to: '.' },
{ from: 'node_modules/solid-logic/dist/RefreshWorker.js', to: 'RefreshWorker.js' }
]
})
],
Expand Down
Loading