@iebh/tera-fy 1.13.3 → 1.14.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.
@@ -127,7 +127,7 @@ export default class TeraFy {
127
127
  'getProjectFileContents',
128
128
  // 'createProjectFile', - Handled below (requires return mapped to ProjectFile)
129
129
  'deleteProjectFile',
130
- 'setProjectFile',
130
+ 'setProjectFileContents',
131
131
 
132
132
  // Project Libraries
133
133
  'selectProjectLibrary',
@@ -145,7 +145,7 @@ export default class TeraFy {
145
145
  'uiConfirm',
146
146
  'uiProgress',
147
147
  'uiPrompt',
148
- 'uiTrhow',
148
+ 'uiThrow',
149
149
  'uiSplat',
150
150
  'uiWindow',
151
151
  ];
@@ -222,7 +222,7 @@ export default class TeraFy {
222
222
  * Call an RPC function in the server instance
223
223
  *
224
224
  * @param {String} method The method name to call
225
- * @param {*} [...] Optional arguments to pass to the function
225
+ * @param {...*} [args] Optional arguments to pass to the function
226
226
  *
227
227
  * @returns {Promise<*>} The resolved output of the server function
228
228
  */
@@ -238,7 +238,9 @@ export default class TeraFy {
238
238
  /**
239
239
  * Accept an incoming message
240
240
  *
241
- * @param {MessageEvent} Raw message event to process
241
+ * @param {MessageEvent} rawMessage Raw message event to process
242
+ *
243
+ * @returns {Promise} A promise which will resolve when the message has been processed
242
244
  */
243
245
  acceptMessage(rawMessage) {
244
246
  if (rawMessage.origin == window.location.origin) return; // Message came from us
@@ -322,7 +324,7 @@ export default class TeraFy {
322
324
 
323
325
  if (watchedPaths.length > 0) {
324
326
  console.info('Detected writes to', watchedPaths, '- entering debugging mode');
325
- debugger;
327
+ debugger; // eslint-disable-line no-debugger
326
328
  }
327
329
  }
328
330
 
@@ -698,13 +700,14 @@ export default class TeraFy {
698
700
 
699
701
  // Utility - debug(), use(), mixin(), toggleDevMode(), toggleFocus() {{{
700
702
 
703
+ /* eslint-disable jsdoc/check-param-names */
701
704
  /**
702
705
  * Debugging output function
703
706
  * This function will only act if `settings.devMode` is truthy
704
707
  *
705
708
  * @param {'INFO'|'LOG'|'WARN'|'ERROR'} [method='LOG'] Logging method to use
706
709
  * @param {Number} [verboseLevel=1] The verbosity level to trigger at. If `settings.verbosity` is lower than this, the message is ignored
707
- * @param {String} [msg...] Output to show
710
+ * @param {...*} [msg] Output to show
708
711
  */
709
712
  debug(...msg) {
710
713
  if (!this.settings.devMode || this.settings.verbosity < 1) return; // Debugging is disabled
@@ -729,6 +732,7 @@ export default class TeraFy {
729
732
  ...msg,
730
733
  );
731
734
  }
735
+ /* eslint-enable */
732
736
 
733
737
 
734
738
  /**
@@ -779,7 +783,7 @@ export default class TeraFy {
779
783
  /**
780
784
  * Include a TeraFy client plugin
781
785
  *
782
- * @param {Object} The module function to include. Invoked as `(teraClient:TeraFy, options:Object)`
786
+ * @param {Object} mod The module function to include. Invoked as `(teraClient:TeraFy, options:Object)`
783
787
  * @param {Object} [options] Additional options to mutate behaviour during construction (pass options to init() to intialize later options)
784
788
  *
785
789
  * @returns {TeraFy} This chainable terafy instance
@@ -1124,6 +1128,7 @@ export default class TeraFy {
1124
1128
  /**
1125
1129
  * Fetch the files associated with a given project
1126
1130
  *
1131
+ * @function getProjectFiles
1127
1132
  * @param {Object} options Options which mutate behaviour
1128
1133
  * @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
1129
1134
  * @param {Boolean} [options.lazy=true] If true, use the fastest method to retrieve the file list such as the cache. If false, force a refresh each time
@@ -1157,7 +1162,8 @@ export default class TeraFy {
1157
1162
  /**
1158
1163
  * Fetch a project file by its name
1159
1164
  *
1160
- * @param {String} name The name + relative directory path component
1165
+ * @function getProjectFile
1166
+ * @param {String} id The name + relative directory path component
1161
1167
  *
1162
1168
  * @param {Object|String} [options] Additional options to mutate behaviour, if a string is given `options.subkey` is assumed
1163
1169
  * @param {String} [options.subkey] If specified only the extracted subkey is returned rather than the full object
@@ -1181,6 +1187,7 @@ export default class TeraFy {
1181
1187
  * Create a new file
1182
1188
  * This creates an empty file which can then be written to
1183
1189
  *
1190
+ * @function createProjectFile
1184
1191
  * @param {String} name The name + relative directory path component
1185
1192
  * @returns {Promise<ProjectFile>} The eventual ProjectFile created
1186
1193
  */
@@ -1209,7 +1216,7 @@ export default class TeraFy {
1209
1216
  /**
1210
1217
  * Replace a project files contents
1211
1218
  *
1212
- * @function setProjectFile
1219
+ * @function setProjectFileContents
1213
1220
  * @param {String} id File to overwrite
1214
1221
  * @param {File|Blob|FormData|Object|Array} contents The new file contents
1215
1222
  * @returns {Promise} A promise which will resolve when the write operation has completed
@@ -1229,7 +1236,7 @@ export default class TeraFy {
1229
1236
  * @param {Boolean} [options.allowCancel=true] Allow cancelling the operation. Will throw `'CANCEL'` as the promise rejection if acationed
1230
1237
  * @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
1231
1238
  * @param {FileFilters} [options.filters] Optional file filters, defaults to citation library selection only
1232
- * @param {*} [options.*] Additional options - see `getProjectLibrary()`
1239
+ * @param {...*} [options] Additional options - see `getProjectLibrary()`
1233
1240
  *
1234
1241
  * @returns {Promise<Array<Ref>>} A collection of references from the selected file
1235
1242
  */
@@ -1290,7 +1297,7 @@ export default class TeraFy {
1290
1297
  *
1291
1298
  * @function setPage
1292
1299
  * @param {Object|String} options Context information about the page, if this is a string, its assumed to popupate `url`
1293
- * @param {String} [options.url] The URL to restore on next refresh
1300
+ * @param {String} [options.path] The URL path segment to restore on next refresh
1294
1301
  * @param {String} [options.title] The page title associated with the path
1295
1302
  */
1296
1303
 
@@ -109,6 +109,9 @@ export class TeraProxy {
109
109
 
110
110
  /**
111
111
  * Utility function to return a new TeraProxy instance
112
+ *
113
+ * @param {Object} [options] Options to pass to the Proxy module
114
+ * @returns {TeraProxy} A TeraProxy instance
112
115
  */
113
116
  export default function(options) {
114
117
  return new TeraProxy(options);
@@ -152,7 +152,7 @@ export default class TeraFyServer {
152
152
  * This function only works if the context was sub-classed via `createContext()`
153
153
  *
154
154
  * @param {String} method The method name to call
155
- * @param {*} [...] Optional arguments to pass to the function
155
+ * @param {...*} [args] Optional arguments to pass to the function
156
156
  *
157
157
  * @returns {Promise<*>} The resolved output of the server function
158
158
  */
@@ -213,7 +213,7 @@ export default class TeraFyServer {
213
213
  * Unlike send() this method does not expect any response
214
214
  *
215
215
  * @param {Object} message Message object to send
216
- * @param {Window} Window context to dispatch the message via if its not the same as the regular window
216
+ * @param {Window} sendVia Window context to dispatch the message via if its not the same as the regular window
217
217
  */
218
218
  sendRaw(message, sendVia) {
219
219
  let payload;
@@ -256,7 +256,7 @@ export default class TeraFyServer {
256
256
  /**
257
257
  * Accept a message from the parent event listener
258
258
  *
259
- * @param {MessageEvent} Raw message event to process
259
+ * @param {MessageEvent} rawMessage Raw message event to process
260
260
  */
261
261
  acceptMessage(rawMessage) {
262
262
  if (rawMessage.origin == window.location.origin) return; // Message came from us
@@ -326,7 +326,7 @@ export default class TeraFyServer {
326
326
  * Note that emitted messages have no response - they are sent to clients only with no return value
327
327
  *
328
328
  * @param {String} event The event name to emit
329
- * @param {*} [args...] Optional event payload to send
329
+ * @param {...*} [args] Optional event payload to send
330
330
  * @returns {Promise} A promise which resolves when the transmission has completed
331
331
  */
332
332
  emitClients(event, ...args) {
@@ -709,7 +709,7 @@ export default class TeraFyServer {
709
709
  *
710
710
  * @param {Object} [options] Additional options to mutate behaviour
711
711
  * @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
712
- * @param {Array<String>} Paths to subscribe to e.g. ['/users/'],
712
+ * @param {Array<String>} [options.paths] Paths to subscribe to e.g. ['/users/'],
713
713
  *
714
714
  * @returns {Promise<Object>} The current project state snapshot
715
715
  */
@@ -877,7 +877,7 @@ export default class TeraFyServer {
877
877
  /**
878
878
  * Apply a computed `just-diff` patch to the current project state
879
879
  *
880
- * @param {Object} Patch to apply
880
+ * @param {Object} patch Patch to apply
881
881
  * @returns {Promise} A promise which resolves when the operation has completed
882
882
  */
883
883
  applyProjectStatePatch(patch) {
@@ -889,7 +889,7 @@ export default class TeraFyServer {
889
889
  }
890
890
  // }}}
891
891
 
892
- // Project files - selectProjectFile(), getProjectFiles(), getProjectFile(), createProjectFile(), deleteProjectFile(), setProjectFile() {{{
892
+ // Project files - selectProjectFile(), getProjectFiles(), getProjectFile(), createProjectFile(), deleteProjectFile(), setProjectFileContents() {{{
893
893
 
894
894
  /**
895
895
  * Data structure for a project file
@@ -1056,6 +1056,7 @@ export default class TeraFyServer {
1056
1056
  * Fetch the raw contents of a file by its ID
1057
1057
  *
1058
1058
  * @param {String} [id] File ID to retrieve the contents of
1059
+ *
1059
1060
  * @param {Object} [options] Additioanl options to mutate behaviour
1060
1061
  * @param {'blob'|'json'} [options.format='blob'] The format to retrieve the file in. If `json` the raw output is run via JSON.parse() first
1061
1062
  *
@@ -1130,7 +1131,7 @@ export default class TeraFyServer {
1130
1131
  *
1131
1132
  * @returns {Promise} A promise which will resolve when the write operation has completed
1132
1133
  */
1133
- setProjectFile(id, contents, options) {
1134
+ setProjectFileContents(id, contents, options) {
1134
1135
  // Argument mangling {{{
1135
1136
  // TODO: Horrible kludge to detect ID is "not a JSON blob"
1136
1137
  if (typeof id == 'string' && !id.startsWith('{') && contents && options) { // Called as `(id, contents, options)`
@@ -1180,7 +1181,7 @@ export default class TeraFyServer {
1180
1181
  /**
1181
1182
  * Prompt the user to select a library to operate on and return a array of references in a given format
1182
1183
  *
1183
- * @param {Object} [options] Additional options to mutate behaviour
1184
+ * @param {Object} [options] Additional options to mutate behaviour - see `getProjectLibrary()` for parent list of options
1184
1185
  * @param {String} [options.title="Select a citation library"] The title of the dialog to display
1185
1186
  * @param {String|Array<String>} [options.hint] Hints to identify the library to select in array order of preference. Generally corresponds to the previous stage - e.g. 'deduped', 'review1', 'review2', 'dedisputed'
1186
1187
  * @param {Boolean} [options.allowUpload=true] Allow uploading new files
@@ -1189,7 +1190,6 @@ export default class TeraFyServer {
1189
1190
  * @param {Boolean} [options.allowCancel=true] Allow cancelling the operation. Will throw `'CANCEL'` as the promise rejection if acationed
1190
1191
  * @param {Boolean} [options.autoRequire=true] Run `requireProject()` automatically before continuing
1191
1192
  * @param {FileFilters} [options.filters] Optional file filters, defaults to citation library selection only
1192
- * @param {*} [options.*] Additional options - see `getProjectLibrary()`
1193
1193
  *
1194
1194
  * @returns {Promise<Array<Ref>>} A collection of references from the selected file
1195
1195
  */
@@ -1386,7 +1386,7 @@ export default class TeraFyServer {
1386
1386
  * This only really makes a difference to tools within the tera-tools.com site where the tool is working as an embed
1387
1387
  *
1388
1388
  * @param {Object|String} options Context information about the page, if this is a string, its assumed to popupate `url`
1389
- * @param {String} [options.url] The URL to restore on next refresh
1389
+ * @param {String} [options.path] The URL path segment to restore on next refresh
1390
1390
  * @param {String} [options.title] The page title associated with the path
1391
1391
  */
1392
1392
  setPage(options) {
@@ -1718,13 +1718,14 @@ export default class TeraFyServer {
1718
1718
 
1719
1719
  // Utility - debug() {{{
1720
1720
 
1721
+ /* eslint-disable jsdoc/check-param-names */
1721
1722
  /**
1722
1723
  * Debugging output function
1723
1724
  * This function will only act if `settings.devMode` is truthy
1724
1725
  *
1725
1726
  * @param {'INFO'|'LOG'|'WARN'|'ERROR'} [method='LOG'] Logging method to use
1726
1727
  * @param {Number} [verboseLevel=1] The verbosity level to trigger at. If `settings.verbosity` is lower than this, the message is ignored
1727
- * @param {String} [msg...] Output to show
1728
+ * @param {...*} [msg] Output to show
1728
1729
  */
1729
1730
  debug(...msg) {
1730
1731
  if (!this.settings.devMode || this.settings.verbosity < 1) return; // Debugging is disabled
@@ -1749,5 +1750,6 @@ export default class TeraFyServer {
1749
1750
  ...msg,
1750
1751
  );
1751
1752
  }
1753
+ /* eslint-enable */
1752
1754
  // }}}
1753
1755
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iebh/tera-fy",
3
- "version": "1.13.3",
3
+ "version": "1.14.0",
4
4
  "description": "TERA website worker",
5
5
  "scripts": {
6
6
  "dev": "esbuild --platform=browser --format=esm --bundle lib/terafy.client.js --outfile=dist/terafy.js --minify --serve --servedir=.",
@@ -76,15 +76,15 @@
76
76
  "lodash-es": "^4.17.21",
77
77
  "mitt": "^3.0.1",
78
78
  "nanoid": "^5.0.7",
79
- "release-it": "^17.5.0"
79
+ "release-it": "^17.6.0"
80
80
  },
81
81
  "devDependencies": {
82
- "@momsfriendlydevco/eslint-config": "^2.0.1",
82
+ "@momsfriendlydevco/eslint-config": "^2.0.3",
83
83
  "@release-it/conventional-changelog": "^8.0.1",
84
84
  "concurrently": "^8.2.2",
85
85
  "documentation": "^14.0.3",
86
86
  "esbuild": "^0.23.0",
87
- "eslint": "^9.6.0"
87
+ "eslint": "^9.7.0"
88
88
  },
89
89
  "peerDependencies": {
90
90
  "vue": "^3.0.0"
@@ -112,7 +112,7 @@
112
112
  },
113
113
  "plugins": {
114
114
  "@release-it/conventional-changelog": {
115
- "preset": "angular",
115
+ "preset": "eslint",
116
116
  "infile": "CHANGELOG.md",
117
117
  "header": "# Changelog"
118
118
  }
package/plugins/vite.js CHANGED
@@ -5,6 +5,7 @@ import TeraProxy from '../lib/terafy.proxy.js';
5
5
  *
6
6
  * @see lib/terafy.proxy.js
7
7
  *
8
+ * @param {Object} [options] Options to pass to the Proxy module
8
9
  * @returns {VitePlugin}
9
10
  */
10
11
  export default function vitePluginTeraFy(options) {
package/plugins/vue3.js CHANGED
@@ -118,6 +118,8 @@ export default class TeraFyPluginVue extends TeraFyPluginBase {
118
118
  * Utility function which returns an awaitable promise when the state is loading or being refreshed
119
119
  * This is used in place of `statePromisable` as it has a slightly more logical syntax as a function
120
120
  *
121
+ * @returns {Promise} A promise representing the loading of the project state
122
+ *
121
123
  * @example Await the state loading
122
124
  * await $tera.statePromise();
123
125
  */
@@ -128,6 +130,8 @@ export default class TeraFyPluginVue extends TeraFyPluginBase {
128
130
 
129
131
  /**
130
132
  * Provide a Vue@3 compatible plugin
133
+ *
134
+ * @returns {VuePlugin} A Vue@3 plugin spec
131
135
  */
132
136
  vuePlugin() {
133
137
  let $tera = this;
@@ -137,12 +141,12 @@ export default class TeraFyPluginVue extends TeraFyPluginBase {
137
141
  /**
138
142
  * Install into Vue as a generic Vue@3 plugin
139
143
  *
144
+ * @param {VueApp} app The Vue top-level app to install against
145
+ *
140
146
  * @param {Object} [options] Additional options to mutate behaviour
141
147
  * @param {Boolean} [options.autoInit=true] Call Init() during the `statePromiseable` cycle if its not already been called
142
148
  * @param {String} [options.globalName='$tera'] Globa property to allocate this service as
143
149
  * @param {Objecct} [options.bindOptions] Options passed to `bindProjectState()`
144
- *
145
- * @returns {VuePlugin} A plugin matching the Vue@3 spec
146
150
  */
147
151
  install(app, options) {
148
152
  let settings = {
@@ -11,7 +11,6 @@ import {
11
11
  * General path setters / getters for project state
12
12
  * These are _MAINLY_ wrappers for Lodash functionality such as Lodash.set() / Lodash.get(), any deviations are documented inline
13
13
  *
14
- * @typedef {PathTools}
15
14
  * In each case these functions work with either dotted or array notation against a target master-object
16
15
  * - Dotted notation - e.g. `foo.bar.1.baz`
17
16
  * - Array path segments e.g. `['foo', 'bar', 1, 'baz']`
@@ -77,8 +76,8 @@ export function set(target, path, value, options) {
77
76
  * @param {*} [fallback] Optional fallback to return if the end point does not exist
78
77
  * @returns {*} The fetched value
79
78
  */
80
- export function get(subject, path, fallback) {
81
- return _get(subject, path, fallback);
79
+ export function get(target, path, fallback) {
80
+ return _get(target, path, fallback);
82
81
  }
83
82
 
84
83
 
@@ -132,6 +131,7 @@ export function defaults(target, path, value) {
132
131
  }
133
132
  }
134
133
 
134
+
135
135
  // Export all functions as a lookup object
136
136
  export default {
137
137
  set,
@@ -55,7 +55,7 @@ export default {
55
55
  * Trigger the file selection functionality within TERA-fy
56
56
  * This sets the `selected` data property to the newly selected file + fires @change
57
57
  *
58
- * @fires change Fired as `(file:ProjectFile)` when the contents changes
58
+ * @emits change Fired as `(file:ProjectFile)` when the contents changes
59
59
  * @returns {ProjectFile} file The selected file
60
60
  */
61
61
  async choose() {