@iebh/tera-fy 1.13.2 → 1.13.4

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.
@@ -25,7 +25,7 @@ export class TeraProxy {
25
25
  host: '0.0.0.0',
26
26
  port: 7334,
27
27
  targetProtocol: 'https',
28
- targetHost: 'tera-tools.com',
28
+ targetHost: 'dev.tera-tools.com',
29
29
  targetPort: 443,
30
30
  portConflict: 'ignore',
31
31
  onLog: (level, ...msg) => console.log(...msg),
@@ -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) {
@@ -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
  *
@@ -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
  */
@@ -1380,36 +1380,17 @@ export default class TeraFyServer {
1380
1380
  }
1381
1381
  // }}}
1382
1382
 
1383
- // Webpages - setPageUrl(), setPageTitle {{{
1384
-
1383
+ // Webpages - setPage() {{{
1385
1384
  /**
1386
- * Set an active tools URL (or path) so that it survives a refresh
1385
+ * Set an active tools URL or other context information so that it survives a refresh
1387
1386
  * This only really makes a difference to tools within the tera-tools.com site where the tool is working as an embed
1388
1387
  *
1389
- * @param {String} url The URL to restore on next refresh
1390
- */
1391
- setPageUrl(url) {
1392
- if (!url.startsWith('/')) throw new Error('All pageURLs must be a relative path starting with a slash');
1393
-
1394
- let $routeMatched = app.service('$route').matched[0];
1395
- if (!$routeMatched?.name) throw new Error('No active route');
1396
- if ($routeMatched?.path == '/embed') return this.debug('INFO', 2, 'Ignoring setPageUrl(', url, ') on when in embed mode');
1397
- if (!$routeMatched?.path.endsWith('/:toolPath(.*)?')) return this.debug('INFO', 2, 'Ignoring setPageUrl(', url, ') - no active tool anyway');
1398
-
1399
- app.router.push({
1400
- path: $routeMatched.path.replace(/\/:toolPath\(\.\*\)\?$/, url),
1401
- });
1402
- }
1403
-
1404
-
1405
- /**
1406
- * Set the active page title
1407
- * This is usually called by a tool nested within the tera-tools.com embed
1408
- *
1409
- * @param {String} [title] The current page title. Set to a falsy value to revert back to the default page title
1388
+ * @param {Object|String} options Context information about the page, if this is a string, its assumed to popupate `url`
1389
+ * @param {String} [options.path] The URL path segment to restore on next refresh
1390
+ * @param {String} [options.title] The page title associated with the path
1410
1391
  */
1411
- setPageTitle(title) {
1412
- app.root.setPageTitle(title);
1392
+ setPage(options) {
1393
+ app.service('$projects').setPage(options);
1413
1394
  }
1414
1395
  // }}}
1415
1396
 
@@ -1737,13 +1718,14 @@ export default class TeraFyServer {
1737
1718
 
1738
1719
  // Utility - debug() {{{
1739
1720
 
1721
+ /* eslint-disable jsdoc/check-param-names */
1740
1722
  /**
1741
1723
  * Debugging output function
1742
1724
  * This function will only act if `settings.devMode` is truthy
1743
1725
  *
1744
1726
  * @param {'INFO'|'LOG'|'WARN'|'ERROR'} [method='LOG'] Logging method to use
1745
1727
  * @param {Number} [verboseLevel=1] The verbosity level to trigger at. If `settings.verbosity` is lower than this, the message is ignored
1746
- * @param {String} [msg...] Output to show
1728
+ * @param {...*} [msg] Output to show
1747
1729
  */
1748
1730
  debug(...msg) {
1749
1731
  if (!this.settings.devMode || this.settings.verbosity < 1) return; // Debugging is disabled
@@ -1768,5 +1750,6 @@ export default class TeraFyServer {
1768
1750
  ...msg,
1769
1751
  );
1770
1752
  }
1753
+ /* eslint-enable */
1771
1754
  // }}}
1772
1755
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iebh/tera-fy",
3
- "version": "1.13.2",
3
+ "version": "1.13.4",
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"
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() {