folder-pane 2.4.9-beta.0 → 2.4.11

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.
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ /* Folder pane
3
+ **
4
+ ** This outline pane lists the members of a folder
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ var UI = require("solid-ui");
8
+ module.exports = {
9
+ icon: UI.icons.iconBase + 'noun_973694_expanded.svg',
10
+ name: 'folder',
11
+ // Create a new folder in a Solid system,
12
+ mintNew: function (context, newPaneOptions) {
13
+ var kb = context.session.store;
14
+ var newInstance = newPaneOptions.newInstance || kb.sym(newPaneOptions.newBase);
15
+ var u = newInstance.uri;
16
+ if (u.endsWith('/')) {
17
+ u = u.slice(0, -1); // chop off trailer
18
+ } // { throw new Error('URI of new folder must end in "/" :' + u) }
19
+ newPaneOptions.newInstance = kb.sym(u + '/');
20
+ // @@@@ kludge until we can get the solid-client version working
21
+ // Force the folder by saving a dummy file inside it
22
+ return kb.fetcher
23
+ .webOperation('PUT', newInstance.uri + '.dummy', { contentType: 'application/octet-stream' })
24
+ .then(function () {
25
+ console.log('New folder created: ' + newInstance.uri);
26
+ return kb.fetcher.delete(newInstance.uri + '.dummy');
27
+ })
28
+ .then(function () {
29
+ console.log('Dummy file deleted : ' + newInstance.uri + '.dummy');
30
+ /*
31
+ return kb.fetcher.createContainer(parentURI, folderName) // Not BOTH ways
32
+ })
33
+ .then(function () {
34
+ */
35
+ console.log('New container created: ' + newInstance.uri);
36
+ return newPaneOptions;
37
+ });
38
+ },
39
+ label: function (subject, context) {
40
+ var kb = context.session.store;
41
+ var n = kb.each(subject, UI.ns.ldp('contains')).length;
42
+ if (n > 0) {
43
+ return 'Contents (' + n + ')'; // Show how many in hover text
44
+ }
45
+ if (kb.holds(subject, UI.ns.rdf('type'), UI.ns.ldp('Container'))) {
46
+ // It is declared as being a container
47
+ return 'Container (0)';
48
+ }
49
+ return null; // Suppress pane otherwise
50
+ },
51
+ // Render a file folder in a LDP/solid system
52
+ render: function (subject, context) {
53
+ function noHiddenFiles(obj) {
54
+ // @@ This hiddenness should actually be server defined
55
+ var pathEnd = obj.uri.slice(obj.dir().uri.length);
56
+ return !(pathEnd.startsWith('.') ||
57
+ pathEnd.endsWith('.acl') ||
58
+ pathEnd.endsWith('~'));
59
+ }
60
+ function refresh() {
61
+ var objs = kb.each(subject, UI.ns.ldp('contains')).filter(noHiddenFiles);
62
+ objs = objs.map(function (obj) { return [UI.utils.label(obj).toLowerCase(), obj]; });
63
+ objs.sort(); // Sort by label case-insensitive
64
+ objs = objs.map(function (pair) { return pair[1]; });
65
+ UI.utils.syncTableToArray(mainTable, objs, function (obj) {
66
+ var st = kb.statementsMatching(subject, UI.ns.ldp('contains'), obj)[0];
67
+ var defaultpropview = outliner.VIEWAS_boring_default;
68
+ var tr = outliner.propertyTR(dom, st, false);
69
+ tr.firstChild.textContent = ''; // Was initialized to 'Contains'
70
+ tr.firstChild.style.cssText += 'min-width: 3em;';
71
+ tr.appendChild(outliner.outlineObjectTD(obj, defaultpropview, undefined, st));
72
+ // UI.widgets.makeDraggable(tr, obj)
73
+ return tr;
74
+ });
75
+ }
76
+ var dom = context.dom;
77
+ var outliner = context.getOutliner(dom);
78
+ var kb = context.session.store;
79
+ var mainTable; // This is a live synced table
80
+ var div = dom.createElement('div');
81
+ div.setAttribute('class', 'instancePane');
82
+ var paneStyle = UI.style.folderPaneStyle || 'border-top: solid 1px #777; border-bottom: solid 1px #777; margin-top: 0.5em; margin-bottom: 0.5em;';
83
+ div.setAttribute('style', paneStyle);
84
+ var thisDir = subject.uri.endsWith('/') ? subject.uri : subject.uri + '/';
85
+ var indexThing = kb.sym(thisDir + 'index.ttl#this');
86
+ if (kb.holds(subject, UI.ns.ldp('contains'), indexThing.doc())) {
87
+ console.log('View of folder will be view of indexThing. Loading ' + indexThing);
88
+ var packageDiv_1 = div.appendChild(dom.createElement('div'));
89
+ packageDiv_1.style.cssText = 'border-top: 0.2em solid #ccc;'; // Separate folder views above from package views below
90
+ kb.fetcher.load(indexThing.doc()).then(function () {
91
+ mainTable = packageDiv_1.appendChild(dom.createElement('table'));
92
+ context
93
+ .getOutliner(dom)
94
+ .GotoSubject(indexThing, true, undefined, false, undefined, mainTable);
95
+ });
96
+ return div;
97
+ }
98
+ else {
99
+ mainTable = div.appendChild(dom.createElement('table'));
100
+ mainTable.refresh = refresh;
101
+ refresh();
102
+ // addDownstreamChangeListener is a high level function which when someone else changes the resource,
103
+ // reloads it into the kb, then must call addDownstreamChangeListener to be able to update the folder pane.
104
+ kb.updater.addDownstreamChangeListener(subject, refresh); // Update store and call me if folder changes
105
+ }
106
+ // Allow user to create new things within the folder
107
+ var creationDiv = div.appendChild(dom.createElement('div'));
108
+ var me = UI.authn.currentUser(); // @@ respond to login events
109
+ var creationContext = {
110
+ folder: subject,
111
+ div: creationDiv,
112
+ dom: dom,
113
+ statusArea: creationDiv,
114
+ me: me
115
+ };
116
+ creationContext.refreshTarget = mainTable;
117
+ UI.authn
118
+ .filterAvailablePanes(context.session.paneRegistry.list)
119
+ .then(function (relevantPanes) {
120
+ UI.create.newThingUI(creationContext, context, relevantPanes); // Have to pass panes down newUI
121
+ UI.aclControl.preventBrowserDropEvents(dom);
122
+ var explictDropIcon = false;
123
+ var target;
124
+ if (explictDropIcon) {
125
+ var iconStyleFound = creationDiv.firstChild.style.cssText;
126
+ target = creationDiv.insertBefore(dom.createElement('img'), creationDiv.firstChild);
127
+ target.style.cssText = iconStyleFound;
128
+ target.setAttribute('src', UI.icons.iconBase + 'noun_748003.svg');
129
+ target.setAttribute('style', 'width: 2em; height: 2em'); // Safari says target.style is read-only
130
+ }
131
+ else {
132
+ target = creationDiv.firstChild; // Overload drop target semantics onto the plus sign
133
+ }
134
+ // /////////// Allow new file to be Uploaded
135
+ UI.widgets.makeDropTarget(target, null, droppedFileHandler);
136
+ });
137
+ return div;
138
+ function droppedFileHandler(files) {
139
+ UI.widgets.uploadFiles(kb.fetcher, files, subject.uri, subject.uri, function (file, uri) {
140
+ // A file has been uploaded
141
+ var destination = kb.sym(uri);
142
+ console.log(' Upload: put OK: ' + destination);
143
+ kb.add(subject, UI.ns.ldp('contains'), destination, subject.doc());
144
+ mainTable.refresh();
145
+ });
146
+ }
147
+ }
148
+ };
149
+ // ends
150
+ //# sourceMappingURL=folderPane.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"folderPane.js","sourceRoot":"","sources":["../src/folderPane.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAGH,6BAA8B;AAE9B,MAAM,CAAC,OAAO,GAAG;IACf,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,0BAA0B;IACpD,IAAI,EAAE,QAAQ;IAEd,yCAAyC;IACzC,OAAO,EAAE,UAAU,OAAO,EAAE,cAAc;QACxC,IAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAA;QAChC,IAAM,WAAW,GACf,cAAc,CAAC,WAAW,IAAI,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;QAC9D,IAAI,CAAC,GAAG,WAAW,CAAC,GAAG,CAAA;QACvB,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACnB,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA,CAAC,mBAAmB;SACvC,CAAC,iEAAiE;QACnE,cAAc,CAAC,WAAW,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;QAE5C,gEAAgE;QAChE,oDAAoD;QACpD,OAAO,EAAE,CAAC,OAAO;aACd,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG,GAAG,QAAQ,EAAE,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAC;aAC5F,IAAI,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,WAAW,CAA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GAAG,CAAC,UAAU,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;gBAClE,SAAS,CAAC,OAAO,EAAE,CAAA;YACrB,CAAC,CACF,CAAA;QACH,CAAC;IACH,CAAC;CACF,CAAA;AACD,OAAO"}
package/package.json CHANGED
@@ -1,16 +1,20 @@
1
1
  {
2
2
  "name": "folder-pane",
3
- "version": "2.4.9-beta.0",
3
+ "version": "2.4.11",
4
4
  "description": "Solid-compatible Panes: File browser",
5
- "main": "./folderPane.js",
5
+ "main": "./lib/folderPane.js",
6
6
  "scripts": {
7
- "build": "echo nothing to build",
8
- "lint": "eslint '*.js'",
9
- "lint-fix": "eslint '*.js' --fix",
7
+ "build": "tsc",
8
+ "lint": "eslint './src'",
9
+ "lint-fix": "eslint './src' --fix",
10
10
  "test": "npm run lint",
11
+ "check": "npm run lint && npm run build && npm run test",
11
12
  "prepublishOnly": "npm test",
12
13
  "postpublish": "git push origin main --follow-tags"
13
14
  },
15
+ "files": [
16
+ "/lib"
17
+ ],
14
18
  "repository": {
15
19
  "type": "git",
16
20
  "url": "https://github.com/solid/folder-pane"
@@ -34,13 +38,20 @@
34
38
  },
35
39
  "homepage": "https://github.com/solid/folder-pane",
36
40
  "dependencies": {
37
- "solid-ui": "^2.4.9-beta"
41
+ "solid-ui": "^2.4.11"
38
42
  },
39
43
  "devDependencies": {
40
- "eslint": "^7.28.0",
41
- "husky": "^6.0.0",
42
- "lint-staged": "^11.0.0",
43
- "standard": "^16.0.3"
44
+ "@babel/core": "^7.16.0",
45
+ "@babel/preset-env": "^7.16.0",
46
+ "@babel/preset-typescript": "^7.16.0",
47
+ "@typescript-eslint/eslint-plugin": "^5.3.0",
48
+ "@typescript-eslint/parser": "^5.3.0",
49
+ "eslint": "^7.32.0",
50
+ "husky": "^7.0.4",
51
+ "lint-staged": "^11.2.6",
52
+ "prettier": "^2.4.1",
53
+ "standard": "^16.0.4",
54
+ "typescript": "^4.4.4"
44
55
  },
45
56
  "husky": {
46
57
  "hooks": {
package/.eslintrc DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "env": {
3
- "browser": true,
4
- "es6": true,
5
- "node": true
6
- },
7
- "extends": "standard",
8
- "globals": {
9
- "Atomics": "readonly",
10
- "SharedArrayBuffer": "readonly"
11
- },
12
- "rules": {
13
- "no-unused-vars": ["warn", {
14
- "argsIgnorePattern": "^_",
15
- "varsIgnorePattern": "^_"
16
- }]
17
- }
18
- }
package/.nvmrc DELETED
@@ -1 +0,0 @@
1
- v12.7.0
package/folderPane.js DELETED
@@ -1,183 +0,0 @@
1
- /* Folder pane
2
- **
3
- ** This outline pane lists the members of a folder
4
- */
5
-
6
- const UI = require('solid-ui')
7
- const style = UI.style
8
- const ns = UI.ns
9
-
10
- module.exports = {
11
- icon: UI.icons.iconBase + 'noun_973694_expanded.svg',
12
-
13
- name: 'folder',
14
-
15
- // Create a new folder in a Solid system,
16
- mintNew: function (context, newPaneOptions) {
17
- const kb = context.session.store
18
- const newInstance =
19
- newPaneOptions.newInstance || kb.sym(newPaneOptions.newBase)
20
- let u = newInstance.uri
21
- if (u.endsWith('/')) {
22
- u = u.slice(0, -1) // chop off trailer
23
- } // { throw new Error('URI of new folder must end in "/" :' + u) }
24
- newPaneOptions.newInstance = kb.sym(u + '/')
25
-
26
- // @@@@ kludge until we can get the solid-client version working
27
- // Force the folder by saving a dummy file inside it
28
- return kb.fetcher
29
- .webOperation('PUT', newInstance.uri + '.dummy', { contentType: 'application/octet-stream' })
30
- .then(function () {
31
- console.log('New folder created: ' + newInstance.uri)
32
-
33
- return kb.fetcher.delete(newInstance.uri + '.dummy')
34
- })
35
- .then(function () {
36
- console.log('Dummy file deleted : ' + newInstance.uri + '.dummy')
37
- /*
38
- return kb.fetcher.createContainer(parentURI, folderName) // Not BOTH ways
39
- })
40
- .then(function () {
41
- */
42
- console.log('New container created: ' + newInstance.uri)
43
- return newPaneOptions
44
- })
45
- },
46
-
47
- label: function (subject, context) {
48
- const kb = context.session.store
49
- const n = kb.each(subject, ns.ldp('contains')).length
50
- if (n > 0) {
51
- return 'Contents (' + n + ')' // Show how many in hover text
52
- }
53
- if (kb.holds(subject, ns.rdf('type'), ns.ldp('Container'))) {
54
- // It is declared as being a container
55
- return 'Container (0)'
56
- }
57
- return null // Suppress pane otherwise
58
- },
59
-
60
- // Render a file folder in a LDP/solid system
61
-
62
- render: function (subject, context) {
63
- function noHiddenFiles (obj) {
64
- // @@ This hiddenness should actually be server defined
65
- const pathEnd = obj.uri.slice(obj.dir().uri.length)
66
- return !(
67
- pathEnd.startsWith('.') ||
68
- pathEnd.endsWith('.acl') ||
69
- pathEnd.endsWith('~')
70
- )
71
- }
72
-
73
- function refresh () {
74
- var objs = kb.each(subject, ns.ldp('contains')).filter(noHiddenFiles)
75
- objs = objs.map(obj => [UI.utils.label(obj).toLowerCase(), obj])
76
- objs.sort() // Sort by label case-insensitive
77
- objs = objs.map(pair => pair[1])
78
- UI.utils.syncTableToArray(mainTable, objs, function (obj) {
79
- const st = kb.statementsMatching(subject, ns.ldp('contains'), obj)[0]
80
- const defaultpropview = outliner.VIEWAS_boring_default
81
- const tr = outliner.propertyTR(dom, st, false)
82
- tr.firstChild.textContent = '' // Was initialized to 'Contains'
83
- tr.firstChild.style.cssText += 'min-width: 3em;'
84
- tr.appendChild(
85
- outliner.outlineObjectTD(obj, defaultpropview, undefined, st)
86
- )
87
- // UI.widgets.makeDraggable(tr, obj)
88
- return tr
89
- })
90
- }
91
-
92
- const dom = context.dom
93
- const outliner = context.getOutliner(dom)
94
- const kb = context.session.store
95
- var mainTable // This is a live synced table
96
- const div = dom.createElement('div')
97
- div.setAttribute('class', 'instancePane')
98
- const paneStyle = style.folderPaneStyle || 'border-top: solid 1px #777; border-bottom: solid 1px #777; margin-top: 0.5em; margin-bottom: 0.5em;'
99
- div.setAttribute('style', paneStyle)
100
-
101
- // If this is an LDP container just list the directory
102
-
103
- const thisDir = subject.uri.endsWith('/') ? subject.uri : subject.uri + '/'
104
- const indexThing = kb.sym(thisDir + 'index.ttl#this')
105
- if (kb.holds(subject, ns.ldp('contains'), indexThing.doc())) {
106
- console.log(
107
- 'View of folder will be view of indexThing. Loading ' + indexThing
108
- )
109
- const packageDiv = div.appendChild(dom.createElement('div'))
110
- packageDiv.style.cssText = 'border-top: 0.2em solid #ccc;' // Separate folder views above from package views below
111
- kb.fetcher.load(indexThing.doc()).then(function () {
112
- mainTable = packageDiv.appendChild(dom.createElement('table'))
113
- context
114
- .getOutliner(dom)
115
- .GotoSubject(indexThing, true, undefined, false, undefined, mainTable)
116
- })
117
- return div
118
- } else {
119
- mainTable = div.appendChild(dom.createElement('table'))
120
- mainTable.refresh = refresh
121
- refresh()
122
- // addDownstreamChangeListener is a high level function which when oneone else changes the resource
123
- // reloads it into the kb, and then calls us to be able to update the folder pane.
124
- kb.updater.addDownstreamChangeListener(subject, refresh) // Update store and call me if folder changes
125
- }
126
-
127
- // Allow user to create new things within the folder
128
- const creationDiv = div.appendChild(dom.createElement('div'))
129
- const me = UI.authn.currentUser() // @@ respond to login events
130
- const creationContext = {
131
- folder: subject,
132
- div: creationDiv,
133
- dom: dom,
134
- statusArea: creationDiv,
135
- me: me
136
- }
137
- creationContext.refreshTarget = mainTable
138
- UI.authn
139
- .filterAvailablePanes(context.session.paneRegistry.list)
140
- .then(function (relevantPanes) {
141
- UI.create.newThingUI(creationContext, context, relevantPanes) // Have to pass panes down newUI
142
-
143
- UI.aclControl.preventBrowserDropEvents(dom)
144
-
145
- const explictDropIcon = false
146
- let target
147
- if (explictDropIcon) {
148
- const iconStyleFound = creationDiv.firstChild.style.cssText
149
- target = creationDiv.insertBefore(
150
- dom.createElement('img'),
151
- creationDiv.firstChild
152
- )
153
- target.style.cssText = iconStyleFound
154
- target.setAttribute('src', UI.icons.iconBase + 'noun_748003.svg')
155
- target.setAttribute('style', 'width: 2em; height: 2em') // Safari says target.style is read-only
156
- } else {
157
- target = creationDiv.firstChild // Overload drop target semantics onto the plus sign
158
- }
159
-
160
- // /////////// Allow new file to be Uploaded
161
- UI.widgets.makeDropTarget(target, null, droppedFileHandler)
162
- })
163
-
164
- return div
165
-
166
- function droppedFileHandler (files) {
167
- UI.widgets.uploadFiles(
168
- kb.fetcher,
169
- files,
170
- subject.uri,
171
- subject.uri,
172
- function (file, uri) {
173
- // A file has been uploaded
174
- const destination = kb.sym(uri)
175
- console.log(' Upload: put OK: ' + destination)
176
- kb.add(subject, ns.ldp('contains'), destination, subject.doc())
177
- mainTable.refresh()
178
- }
179
- )
180
- }
181
- }
182
- }
183
- // ends