Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaced require and module.exports with import and export #364

Merged
merged 4 commits into from
Feb 2, 2023
Merged
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
20,794 changes: 18,858 additions & 1,936 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"clean": "rm -rf dist lib",
"lint": "eslint 'src/**/*.js' 'src/**/*.ts'",
"lint-fix": "eslint 'src/**/*.js' 'src/**/*.ts' --fix",
"test": "npm run lint && jest",
"test": "npm run lint && jest src/**/*test*",
"test-watch": "npm run lint && jest --onlyChanged --watch",
"prepublishOnly": "npm test && npm run build",
"postversion": "git push origin main --follow-tags",
Expand Down
4 changes: 2 additions & 2 deletions src/RDFXMLPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
** in generated N3 syntax.
*/

const UI = require('solid-ui')
import * as UI from 'solid-ui'
const ns = UI.ns

module.exports = {
export const RDFXMLPane = {
icon: UI.icons.originalIconBase + '22-text-xml4.png',

name: 'RDFXML',
Expand Down
2 changes: 1 addition & 1 deletion src/argument/argumentPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as UI from 'solid-ui'
import * as panes from 'pane-registry'

// console.log('@@@ argument pane icon at ' + (module.__dirname || __dirname) + '/icon_argument.png')
module.exports = {
export default {
icon: (module.__dirname || __dirname) + '/icon_argument.png', // @@ fix fro mashlib version

name: 'argument',
Expand Down
6 changes: 3 additions & 3 deletions src/attach/attachPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
**
*/

const UI = require('solid-ui')
const $rdf = require('rdflib')
import * as UI from 'solid-ui'
import * as $rdf from 'rdflib'

module.exports = {
export default {
icon: UI.icons.iconBase + 'noun_25830.svg', // noun_25830

name: 'attachments',
Expand Down
6 changes: 3 additions & 3 deletions src/audio/audioPane.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* Single audio play Pane
**
*/
const UI = require('solid-ui')
const $rdf = require('rdflib')
import * as UI from 'solid-ui'
import * as $rdf from 'rdflib'
const ns = UI.ns

module.exports = {
export default {
icon: UI.icons.iconBase + 'noun_534313.svg',

name: 'audio',
Expand Down
6 changes: 3 additions & 3 deletions src/classInstancePane.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
** This outline pane lists the members of a class
*/

const UI = require('solid-ui')
const $rdf = require('rdflib')
import * as UI from 'solid-ui'
import * as $rdf from 'rdflib'

const ns = UI.ns

module.exports = {
export const classInstancePane = {
icon: UI.icons.originalIconBase + 'tango/22-folder-open.png',

name: 'classInstance',
Expand Down
7 changes: 3 additions & 4 deletions src/dataContentPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
// - Expand automatically all the way down
// - original source view? Use ffox view source

const UI = require('solid-ui')
const $rdf = require('rdflib')
import * as UI from 'solid-ui'
const ns = UI.ns

module.exports = {
export const dataContentPane = {
icon: UI.icons.originalIconBase + 'rdf_flyer.24.gif',

name: 'dataContents',
Expand Down Expand Up @@ -280,7 +279,7 @@ module.exports = {
// or we could keep all the pre-smushed triples.
const sts = kb.statementsMatching(undefined, undefined, undefined, subject) // @@ slow with current store!

if ($rdf.keepThisCodeForLaterButDisableFerossConstantConditionPolice) {
if (false) { // keep code
alternativeRendering()
} else {
mainRendering()
Expand Down
6 changes: 3 additions & 3 deletions src/defaultPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
** This pane hides the ones considered too low-level for the normal user.
*/

const UI = require('solid-ui')
const $rdf = require('rdflib')
import * as UI from 'solid-ui'
import * as $rdf from 'rdflib'
const ns = UI.ns

module.exports = {
export const defaultPane = {
icon: UI.icons.originalIconBase + 'about.png',

name: 'default',
Expand Down
10 changes: 5 additions & 5 deletions src/dokieli/dokieliPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
** review. It does not use turtle, but RDF/a
*/

const UI = require('solid-ui')
const $rdf = require('rdflib')
const mime = require('mime-types')
import * as UI from 'solid-ui'
import * as $rdf from 'rdflib'
import * as mime from 'mime-types'

// const DOKIELI_TEMPLATE_URI = 'https://dokie.li/new' // Copy to make new dok

const DOKIELI_TEMPLATE = require('./new.js') // Distributed with this library
import * as DOKIELI_TEMPLATE from './new.js' // Distributed with this library

module.exports = {
export default {
icon: UI.icons.iconBase + 'dokieli-logo.png', // @@ improve? more like doccument?

name: 'Dokieli',
Expand Down
2 changes: 1 addition & 1 deletion src/dokieli/new.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = `
export default `
<!DOCTYPE html>
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
Expand Down
4 changes: 2 additions & 2 deletions src/form/pane.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
** Pane for running existing forms for any object
** Pane for running existing forms for any object
**
*/

Expand All @@ -8,7 +8,7 @@ import { authn } from 'solid-logic'
import * as $rdf from 'rdflib'
const ns = UI.ns

module.exports = {
export const formPane = {
icon: UI.icons.iconBase + 'noun_122196.svg',

name: 'form',
Expand Down
15 changes: 1 addition & 14 deletions src/home/homePane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,7 @@ const HomePaneSource: PaneDefinition = {
)
create.newThingUI(creationContext, context, relevantPanes) // newUI Have to pass panes down

div.appendChild(dom.createElement('h4')).textContent = 'Private things'
// TODO: Replace by a common, representative interface
login
.registrationList(homePaneContext, { private: true })
.then(function (authContext) {
div.appendChild(dom.createElement('h4')).textContent = 'Public things'
div.appendChild(dom.createElement('p')).textContent =
'Things in this list are visible to others.'
login
.registrationList(authContext, { public: true })
.then(function () {
// done
})
})
login.registrationList(homePaneContext, {}).then(function () {})
}

const div = dom.createElement('div')
Expand Down
4 changes: 2 additions & 2 deletions src/imagePane.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
**
** This outline pane contains the document contents for an Image document
*/
const UI = require('solid-ui')
import * as UI from 'solid-ui'

module.exports = {
export const imagePane = {
icon: UI.icons.originalIconBase + 'tango/22-image-x-generic.png',

name: 'image',
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as UI from 'solid-ui'
import { LiveStore } from 'rdflib'
import { solidLogicSingleton, store } from 'solid-logic'
import OutlineManager from './outline/manager.js'
import registerPanes from './registerPanes.js'
import { registerPanes } from './registerPanes.js'
import {
list,
paneForIcon,
Expand Down
2 changes: 1 addition & 1 deletion src/microblogPane/microblogPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { authn, store } from 'solid-logic'
import * as UI from 'solid-ui'

module.exports = {
export default {
icon: UI.icons.originalIconBase + 'microblog/microblog.png',
name: 'microblogPane',
label: function (subject) {
Expand Down
4 changes: 2 additions & 2 deletions src/n3Pane.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
** or at least the RDF semantics we attribute to that resource,
** in generated N3 syntax.
*/
const UI = require('solid-ui')
import * as UI from 'solid-ui'
const ns = UI.ns

module.exports = {
export const n3Pane = {
icon: UI.icons.originalIconBase + 'w3c/n3_smaller.png',

name: 'n3',
Expand Down
17 changes: 9 additions & 8 deletions src/outline/licenseOptions.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// This was a student project to
// allow the user to chose favoite CC licence terms and have them highlighted
// allow the user to chose favoite CC license terms and have them highlighted

// tabulator.options becaome UI.licenseOptions
// Possible future alternative directoons: Store licence preferences in a solid preferences file
import * as UI from 'solid-ui'
// Possible future alternative directoons: Store license preferences in a solid preferences file
import { store } from 'solid-logic'

const licenseURI = [
export const licenseURI = [
'http://creativecommons.org/licenses/by-nc-nd/3.0/',
'http://creativecommons.org/licenses/by-nc-sa/3.0/',
'http://creativecommons.org/licenses/by-nc/3.0/',
Expand All @@ -17,7 +16,7 @@ const licenseURI = [

const names = ['BY-NC-ND', 'BY-NC-SA', 'BY-NC', 'BY-ND', 'BY-SA', 'BY']

module.exports = function licenseOptions () {
export function licenseOptions () {
this.options = {}
this.references = []
this.checkedLicenses = []
Expand Down Expand Up @@ -81,12 +80,14 @@ module.exports = function licenseOptions () {
}
}

this.checkLicence = function checkLicense (statement) {
this.checkLicense = function checkLicense (statement) {
const licenses = store.each(
statement.why,
store.sym('http://creativecommons.org/ns#license')
store.sym('http://creativecommons.org/ns#license'),
null,
statement.why
)
UI.log.info('licenses:' + statement.why + ': ' + licenses)
// UI.log.info('licenses:' + statement.why + ': ' + licenses)
for (let i = 0; i < licenses.length; i++) {
for (let j = 0; j < this.checkedLicenses.length; j++) {
if (this.checkedLicenses[j] && licenses[i].uri === licenseURI[j]) {
Expand Down
39 changes: 18 additions & 21 deletions src/outline/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import * as paneRegistry from 'pane-registry'
import * as $rdf from 'rdflib'
import * as UI from 'solid-ui'
import { authn, authSession, store } from 'solid-logic'
import propertyViews from './propertyViews'
import * as licenseOptions from './licenseOptions'
import { propertyViews } from './propertyViews'
import { licenseOptions } from './licenseOptions'

const outlineIcons = require('./outlineIcons.js')
const UserInput = require('./userInput.js')
const queryByExample = require('./queryByExample.js')
import { outlineIcons } from './outlineIcons.js' // @@ chec
import { UserInput } from './userInput.js'
import * as queryByExample from './queryByExample.js'

/* global alert XPathResult sourceWidget */
// XPathResult?
Expand Down Expand Up @@ -181,7 +181,7 @@ export default function (context) {

// check the IPR on the data. Ok if there is any checked license which is one the document has.
if (statement && statement.why) {
if (licenseOptions && licenseOptions.checkLicence()) {
if (licenseOptions && licenseOptions.checklicense()) {
theClass += ' licOkay' // flag as light green etc .licOkay {background-color: #dfd}
}
}
Expand Down Expand Up @@ -647,23 +647,20 @@ export default function (context) {
const renderPane = function (pane) {
let paneDiv
UI.log.info('outline: Rendering pane (2): ' + pane.name)
if (UI.no_catch_pane_errors) {
// for debugging

try {
paneDiv = pane.render(subject, context, options)
} else {
try {
paneDiv = pane.render(subject, context, options)
} catch (e) {
// Easier debugging for pane developers
paneDiv = dom.createElement('div')
paneDiv.setAttribute('class', 'exceptionPane')
const pre = dom.createElement('pre')
paneDiv.appendChild(pre)
pre.appendChild(
dom.createTextNode(UI.utils.stackString(e))
)
}
} catch (e) {
// Easier debugging for pane developers
paneDiv = dom.createElement('div')
paneDiv.setAttribute('class', 'exceptionPane')
const pre = dom.createElement('pre')
paneDiv.appendChild(pre)
pre.appendChild(
dom.createTextNode(UI.utils.stackString(e))
)
}

if (
pane.requireQueryButton &&
dom.getElementById('queryButton')
Expand Down
6 changes: 6 additions & 0 deletions src/outline/manager.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
/* eslint-env jest */

import { TextEncoder, TextDecoder } from 'util'
global.TextEncoder = TextEncoder as any
global.TextDecoder = TextDecoder as any


import OutlineManager from './manager'

import { lit, NamedNode, sym, blankNode } from 'rdflib'
Expand Down
6 changes: 4 additions & 2 deletions src/outline/outlineIcons.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// This is a system of tracking tooltip phrases used by the tabulator outliner

const outlineIcons = (module.exports = {}) // was tabulator.Icon
const UI = require('solid-ui')
import * as UI from 'solid-ui'


export const outlineIcons = {}

outlineIcons.src = [] // collect the URIs of the icon filterColumns
outlineIcons.tooltips = [] // look up tool tips from URL
Expand Down
8 changes: 7 additions & 1 deletion src/outline/propertyViews.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
/* eslint-env jest */

import { TextEncoder, TextDecoder } from 'util'
global.TextEncoder = TextEncoder as any
global.TextDecoder = TextDecoder as any


import { sym } from 'rdflib'
import propertyViews from './propertyViews'
import { propertyViews } from './propertyViews'

describe('property views', () => {
it.each([
Expand Down
6 changes: 3 additions & 3 deletions src/outline/propertyViews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import viewAsMbox from './viewAsMbox'

/** some builtin simple views **/

export default (dom) => {
export function propertyViews (dom) {
// view that applies to items that are objects of certain properties.
const views = {
properties: [],
Expand All @@ -25,7 +25,7 @@ export default (dom) => {
}

/** add a property view function **/
function viewsAddPropertyView (views, property, pviewfunc, isDefault) {
export function viewsAddPropertyView (views, property, pviewfunc, isDefault) {
if (!views.properties[property]) {
views.properties[property] = []
}
Expand All @@ -34,4 +34,4 @@ function viewsAddPropertyView (views, property, pviewfunc, isDefault) {
// will override an existing default!
views.defaults[property] = pviewfunc
}
} // addPropertyView
} // viewsAddPropertyView
Loading