Skip to content

Commit

Permalink
Merge pull request #550 from SolidOS/chat-thread-proof
Browse files Browse the repository at this point in the history
Chat thread with proof
  • Loading branch information
bourgeoa committed Apr 3, 2024
2 parents 9d930db + 17f11db commit 42e66c3
Show file tree
Hide file tree
Showing 23 changed files with 1,841 additions and 27,382 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16.14.0
v18.19.0
18 changes: 18 additions & 0 deletions jest-environment-jsdom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { TextEncoder, TextDecoder } = require('util')
const JSDOMEnvironmentBase = require('jest-environment-jsdom')

Object.defineProperty(exports, '__esModule', {
value: true,
})

class JSDOMEnvironment extends JSDOMEnvironmentBase {
constructor(...args) {
const { global } = super(...args)
global.TextEncoder = TextEncoder
global.TextDecoder = TextDecoder
global.Uint8Array = Uint8Array
}
}

exports.default = JSDOMEnvironment
exports.TestEnvironment = JSDOMEnvironment;
10 changes: 8 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
module.exports = {
verbose: true,
testEnvironment: 'jsdom',
// https://github.com/paralleldrive/cuid2/issues/44#issuecomment-1531731695
testEnvironment: './jest-environment-jsdom.js', // had to extend; see https://github.com/jsdom/jsdom/issues/2524
testMatch: [
'**/?(*.)+(spec|test).[tj]s?(x)' ],
setupFilesAfterEnv: [
'./test/helpers/setup.ts'
]
],
transformIgnorePatterns: ["/node_modules/(?!lit-html).+\\.js"],
testEnvironmentOptions: {
customExportConditions: ['node']
}

}
28,189 changes: 1,274 additions & 26,915 deletions package-lock.json

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "solid-ui",
"version": "2.4.32",
"version": "2.4.33-beta4",
"description": "UI library for writing Solid read-write-web applications",
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
Expand Down Expand Up @@ -55,29 +55,28 @@
},
"homepage": "https://github.com/solidos/solid-ui",
"dependencies": {
"@noble/curves": "^1.2.0",
"@noble/curves": "^1.4.0",
"acorn": "^7.4.1",
"escape-html": "^1.0.3",
"eslint-plugin-n": "^15.7.0",
"i": "^0.3.7",
"mime-types": "^2.1.35",
"npm": "^8.19.4",
"pane-registry": "^2.4.25",
"rdflib": "^2.2.33",
"solid-logic": "^3.0.6",
"pane-registry": "^2.4.26",
"solid-logic": "^3.0.7",
"solid-namespace": "^0.5.3",
"uuid": "^8.3.2"
},
"devDependencies": {
"@babel/cli": "^7.23.4",
"@babel/core": "^7.23.5",
"@babel/cli": "^7.24.1",
"@babel/core": "^7.24.3",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
"@babel/plugin-transform-async-to-generator": "^7.23.3",
"@babel/plugin-transform-runtime": "^7.23.4",
"@babel/preset-env": "^7.23.5",
"@babel/preset-typescript": "^7.23.3",
"@babel/runtime": "^7.23.5",
"@babel/plugin-transform-async-to-generator": "^7.24.1",
"@babel/plugin-transform-runtime": "^7.24.3",
"@babel/preset-env": "^7.24.3",
"@babel/preset-typescript": "^7.24.1",
"@babel/runtime": "^7.24.1",
"@mdx-js/react": "^2.3.0",
"@storybook/addon-actions": "6.5.16",
"@storybook/addon-docs": "6.5.16",
Expand All @@ -90,34 +89,35 @@
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.5.2",
"@types/jsdom": "^16.2.15",
"@types/node": "^18.19.1",
"@types/react": "^17.0.71",
"@types/node": "^18.19.26",
"@types/react": "^17.0.79",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"babel-loader": "^8.3.0",
"crypto": "^1.0.1",
"eslint": "^8.54.0",
"eslint": "^8.57.0",
"eslint-config-standard": "^17.1.0",
"eslint-import-resolver-typescript": "^2.7.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^26.9.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.1.1",
"get-random-values": "^2.1.0",
"html-webpack-plugin": "^5.5.3",
"html-webpack-plugin": "^5.6.0",
"husky": "^7.0.4",
"isomorphic-fetch": "^3.0.0",
"jest": "^27.5.1",
"jsdom": "^19.0.0",
"jest-environment-jsdom": "^27.5.1",
"jsdom": "^16.7.0",
"lint-staged": "^12.5.0",
"nock": "^13.4.0",
"nock": "^13.5.4",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-is": "^17.0.2",
"ts-jest": "^27.1.5",
"typedoc": "^0.25.4",
"typedoc": "^0.25.12",
"typescript": "^4.9.5",
"webpack": "^5.89.0",
"webpack": "^5.91.0",
"webpack-cli": "^4.10.0"
},
"optionalDependencies": {
Expand Down
61 changes: 7 additions & 54 deletions src/chat/bookmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* @packageDocumentation
*/

/* global alert confirm */
import * as debug from '../debug'
import { icons } from '../iconBase'
import { media } from '../media/index'
Expand All @@ -25,53 +24,6 @@ const BOOKMARK_ICON = 'noun_45961.svg'
const label = utils.label
const dom = window.document || null

/** Create a resource if it really does not exist
* Be absolutely sure something does not exist before creating a new empty file
* as otherwise existing could be deleted.
* @param doc {NamedNode} - The resource
*/
function createIfNotExists (doc) {
return new Promise(function (resolve, reject) {
store.fetcher.load(doc).then(
response => {
debug.log('createIfNotExists doc exists, all good ' + doc)
// store.fetcher.webOperation('HEAD', doc.uri).then(response => {
resolve(response)
},
err => {
if (err.response.status === 404) {
debug.log(
'createIfNotExists doc does NOT exist, will create... ' + doc
)

store.fetcher
.webOperation('PUT', doc.uri, {
data: '',
contentType: 'text/turtle'
})
.then(
response => {
// fetcher.requested[doc.uri] = 'done' // do not need to read ?? but no headers
delete store.fetcher.requested[doc.uri] // delete cached 404 error
debug.log('createIfNotExists doc created ok ' + doc)
resolve(response)
},
err => {
debug.log('createIfNotExists doc FAILED: ' + doc + ': ' + err)
reject(err)
}
)
} else {
debug.log(
'createIfNotExists doc load error NOT 404: ' + doc + ': ' + err
)
reject(err)
}
}
)
})
}

// @@@@ use the one in rdflib.js when it is avaiable and delete this
function updatePromise (del, ins) {
return new Promise(function (resolve, reject) {
Expand Down Expand Up @@ -99,7 +51,8 @@ export async function findBookmarkDocument (userContext) {
if (userContext.instances && userContext.instances.length > 0) {
userContext.bookmarkDocument = userContext.instances[0]
if (userContext.instances.length > 1) {
alert('More than one bookmark file! ' + userContext.instances)
debug.warn('More than one bookmark file! ' + userContext.instances) // @@ todo - deal with > 1
// Note: should pick up community bookmarks as well
}
} else {
if (userContext.publicProfile) {
Expand All @@ -109,9 +62,9 @@ export async function findBookmarkDocument (userContext) {
)
try {
debug.log('Creating new bookmark file ' + newBookmarkFile)
await createIfNotExists(newBookmarkFile)
await store.fetcher.createIfNotExists(newBookmarkFile)
} catch (e) {
alert.error("Can't make fresh bookmark file:" + e)
debug.warn("Can't make fresh bookmark file:" + e)
return userContext
}
await registerInTypeIndex(
Expand All @@ -121,7 +74,7 @@ export async function findBookmarkDocument (userContext) {
)
userContext.bookmarkDocument = newBookmarkFile
} else {
alert('You seem to have no bookmark file and not even a profile file.')
debug.warn('You seem to have no bookmark file, nor even a profile file!')
}
}
return userContext
Expand Down Expand Up @@ -164,7 +117,7 @@ async function addBookmark (context, target) {
await updatePromise([], ins) // 20190118A
} catch (e) {
const msg = 'Making bookmark: ' + e
alert.error(msg)
debug.warn(msg)
return null
}
return bookmark
Expand All @@ -188,7 +141,7 @@ export async function toggleBookmark (userContext, target, bookmarkButton) {
debug.log('Bookmark deleted: ' + bookmarks[i])
} catch (e) {
debug.error('Cant delete bookmark:' + e)
alert('Cant delete bookmark:' + e)
debug.warn('Cannot delete bookmark:' + e)
}
}
} else {
Expand Down
Loading

0 comments on commit 42e66c3

Please sign in to comment.