@iebh/tera-fy 1.0.16 → 1.0.18
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.
- package/README.md +3 -2
- package/api.md +333 -188
- package/dist/plugin.vue2.es2019.js +1 -1
- package/dist/plugin.vue2.es2019.js.map +3 -3
- package/dist/terafy.es2019.js +2 -2
- package/dist/terafy.es2019.js.map +3 -3
- package/dist/terafy.js +2 -2
- package/dist/terafy.js.map +3 -3
- package/hints.md +26 -0
- package/lib/terafy.client.js +149 -18
- package/lib/terafy.server.js +415 -54
- package/package.json +10 -11
- package/plugins/vue2.js +68 -0
- package/utils/pDefer.js +15 -0
package/api.md
CHANGED
|
@@ -49,38 +49,51 @@
|
|
|
49
49
|
* [Properties][45]
|
|
50
50
|
* [getUser][46]
|
|
51
51
|
* [requireUser][47]
|
|
52
|
-
* [][48]
|
|
53
|
-
* [
|
|
54
|
-
* [
|
|
55
|
-
* [
|
|
56
|
-
* [
|
|
57
|
-
|
|
58
|
-
* [
|
|
59
|
-
|
|
60
|
-
* [
|
|
61
|
-
|
|
62
|
-
* [
|
|
63
|
-
|
|
64
|
-
* [
|
|
65
|
-
|
|
66
|
-
* [
|
|
67
|
-
|
|
68
|
-
* [
|
|
69
|
-
* [
|
|
70
|
-
|
|
71
|
-
* [
|
|
72
|
-
|
|
73
|
-
* [
|
|
74
|
-
* [
|
|
75
|
-
|
|
76
|
-
* [
|
|
77
|
-
|
|
78
|
-
* [
|
|
79
|
-
|
|
80
|
-
* [
|
|
81
|
-
|
|
82
|
-
* [
|
|
83
|
-
|
|
52
|
+
* [Parameters][48]
|
|
53
|
+
* [][49]
|
|
54
|
+
* [Project][50]
|
|
55
|
+
* [getProject][51]
|
|
56
|
+
* [getProjects][52]
|
|
57
|
+
* [setActiveProject][53]
|
|
58
|
+
* [Parameters][54]
|
|
59
|
+
* [requireProject][55]
|
|
60
|
+
* [Parameters][56]
|
|
61
|
+
* [selectProject][57]
|
|
62
|
+
* [Parameters][58]
|
|
63
|
+
* [getProjectState][59]
|
|
64
|
+
* [Parameters][60]
|
|
65
|
+
* [setProjectState][61]
|
|
66
|
+
* [Parameters][62]
|
|
67
|
+
* [setProjectStateDefaults][63]
|
|
68
|
+
* [Parameters][64]
|
|
69
|
+
* [saveProjectState][65]
|
|
70
|
+
* [replaceProjectState][66]
|
|
71
|
+
* [Parameters][67]
|
|
72
|
+
* [applyProjectStatePatch][68]
|
|
73
|
+
* [Parameters][69]
|
|
74
|
+
* [subscribeProjectState][70]
|
|
75
|
+
* [ProjectFile][71]
|
|
76
|
+
* [Properties][72]
|
|
77
|
+
* [FileFilters][73]
|
|
78
|
+
* [Properties][74]
|
|
79
|
+
* [selectProjectFile][75]
|
|
80
|
+
* [Parameters][76]
|
|
81
|
+
* [getProjectFiles][77]
|
|
82
|
+
* [Parameters][78]
|
|
83
|
+
* [selectProjectLibrary][79]
|
|
84
|
+
* [Parameters][80]
|
|
85
|
+
* [parseProjectLibrary][81]
|
|
86
|
+
* [Parameters][82]
|
|
87
|
+
* [setProjectLibrary][83]
|
|
88
|
+
* [Parameters][84]
|
|
89
|
+
* [setProjectLibrary][85]
|
|
90
|
+
* [Parameters][86]
|
|
91
|
+
* [uiAlert][87]
|
|
92
|
+
* [Parameters][88]
|
|
93
|
+
* [uiSplat][89]
|
|
94
|
+
* [Parameters][90]
|
|
95
|
+
* [uiWindow][91]
|
|
96
|
+
* [Parameters][92]
|
|
84
97
|
|
|
85
98
|
## TeraFy
|
|
86
99
|
|
|
@@ -90,16 +103,18 @@ Main Tera-Fy Client (class singleton) to be used in a frontend browser
|
|
|
90
103
|
|
|
91
104
|
Various settings to configure behaviour
|
|
92
105
|
|
|
93
|
-
Type: [Object][
|
|
106
|
+
Type: [Object][93]
|
|
94
107
|
|
|
95
108
|
#### Properties
|
|
96
109
|
|
|
97
|
-
* `devMode` **[Boolean][
|
|
98
|
-
* `
|
|
99
|
-
* `
|
|
100
|
-
* `
|
|
101
|
-
* `
|
|
102
|
-
* `
|
|
110
|
+
* `devMode` **[Boolean][94]** Operate in devMode - i.e. force outer refresh when encountering an existing TeraFy instance
|
|
111
|
+
* `mode` **(`"detect"` | `"parent"` | `"child"` | `"popup"`)** How to communicate with TERA. 'parent' assumes that the parent of the current document is TERA, 'child' spawns an iFrame and uses TERA there, 'detect' tries parent and switches to `modeFallback` if communication fails
|
|
112
|
+
* `modeFallback` **[String][95]** Method to use when all method detection fails
|
|
113
|
+
* `modeTimeout` **[Number][96]** How long entities have in 'detect' mode to identify themselves
|
|
114
|
+
* `siteUrl` **[String][95]** The TERA URL to connect to
|
|
115
|
+
* `restrictOrigin` **[String][95]** URL to restrict communications to
|
|
116
|
+
* `List` **[Array][97]<[String][95]>** of sandbox allowables for the embedded if in embed mode
|
|
117
|
+
* `handshakeInterval` **[Number][96]** Interval in milliseconds when sanning for a handshake
|
|
103
118
|
|
|
104
119
|
### events
|
|
105
120
|
|
|
@@ -111,12 +126,13 @@ Type: Mitt
|
|
|
111
126
|
|
|
112
127
|
DOMElements for this TeraFy instance
|
|
113
128
|
|
|
114
|
-
Type: [Object][
|
|
129
|
+
Type: [Object][93]
|
|
115
130
|
|
|
116
131
|
#### Properties
|
|
117
132
|
|
|
118
133
|
* `el` **DOMElement** The main tera-fy div wrapper
|
|
119
|
-
* `iframe` **DOMElement** The internal iFrame element
|
|
134
|
+
* `iframe` **DOMElement** The internal iFrame element (if `settings.mode == 'child'`)
|
|
135
|
+
* `popup` **[Window][98]** The popup window context (if `settings.mode == 'popup'`)
|
|
120
136
|
* `stylesheet` **DOMElement** The corresponding stylesheet
|
|
121
137
|
|
|
122
138
|
### methods
|
|
@@ -124,13 +140,13 @@ Type: [Object][80]
|
|
|
124
140
|
List of function stubs mapped here from the server
|
|
125
141
|
This array is forms the reference of `TeraFy.METHOD()` objects to provide locally which will be mapped via `TeraFy.rpc(METHOD, ...args)`
|
|
126
142
|
|
|
127
|
-
Type: [Array][
|
|
143
|
+
Type: [Array][97]<[String][95]>
|
|
128
144
|
|
|
129
145
|
### plugins
|
|
130
146
|
|
|
131
147
|
Loaded plugins via Use()
|
|
132
148
|
|
|
133
|
-
Type: [Array][
|
|
149
|
+
Type: [Array][97]\<TeraFyPlugin>
|
|
134
150
|
|
|
135
151
|
### send
|
|
136
152
|
|
|
@@ -138,9 +154,9 @@ Send a message + wait for a response object
|
|
|
138
154
|
|
|
139
155
|
#### Parameters
|
|
140
156
|
|
|
141
|
-
* `message` **[Object][
|
|
157
|
+
* `message` **[Object][93]** Message object to send
|
|
142
158
|
|
|
143
|
-
Returns **[Promise][
|
|
159
|
+
Returns **[Promise][99]\<any>** A promise which resolves when the operation has completed with the remote reply
|
|
144
160
|
|
|
145
161
|
### sendRaw
|
|
146
162
|
|
|
@@ -149,7 +165,7 @@ This function does not return or wait for a reply - use `send()` for that
|
|
|
149
165
|
|
|
150
166
|
#### Parameters
|
|
151
167
|
|
|
152
|
-
* `message` **[Object][
|
|
168
|
+
* `message` **[Object][93]** Message object to send
|
|
153
169
|
|
|
154
170
|
### rpc
|
|
155
171
|
|
|
@@ -157,10 +173,10 @@ Call an RPC function in the server instance
|
|
|
157
173
|
|
|
158
174
|
#### Parameters
|
|
159
175
|
|
|
160
|
-
* `method` **[String][
|
|
176
|
+
* `method` **[String][95]** The method name to call
|
|
161
177
|
* `args` **...any** 
|
|
162
178
|
|
|
163
|
-
Returns **[Promise][
|
|
179
|
+
Returns **[Promise][99]\<any>** The resolved output of the server function
|
|
164
180
|
|
|
165
181
|
### acceptMessage
|
|
166
182
|
|
|
@@ -169,7 +185,7 @@ Accept an incoming message
|
|
|
169
185
|
#### Parameters
|
|
170
186
|
|
|
171
187
|
* `rawMessage`  
|
|
172
|
-
* `Raw` **[MessageEvent][
|
|
188
|
+
* `Raw` **[MessageEvent][100]** message event to process
|
|
173
189
|
|
|
174
190
|
### acceptPostboxes
|
|
175
191
|
|
|
@@ -178,27 +194,27 @@ Listening postboxes, these correspond to outgoing message IDs that expect a resp
|
|
|
178
194
|
### createProjectStatePatch
|
|
179
195
|
|
|
180
196
|
Create + transmit a new project state patch base on the current and previous states
|
|
181
|
-
The transmitted patch follows the [JSPatch][
|
|
197
|
+
The transmitted patch follows the [JSPatch][101] standard
|
|
182
198
|
This function accepts an entire projectState instance, computes the delta and transmits that to the server for merging
|
|
183
199
|
|
|
184
200
|
#### Parameters
|
|
185
201
|
|
|
186
|
-
* `newState` **[Object][
|
|
187
|
-
* `oldState` **[Object][
|
|
202
|
+
* `newState` **[Object][93]** The local projectState to accept
|
|
203
|
+
* `oldState` **[Object][93]** The previous projectState to examine against
|
|
188
204
|
|
|
189
|
-
Returns **[Promise][
|
|
205
|
+
Returns **[Promise][99]** A promise which will resolve when the operation has completed
|
|
190
206
|
|
|
191
207
|
### applyProjectStatePatchLocal
|
|
192
208
|
|
|
193
209
|
Client function which accepts a patch from the server and applies it to local project state
|
|
194
|
-
The patch should follow the [JSPatch][
|
|
210
|
+
The patch should follow the [JSPatch][101] standard
|
|
195
211
|
This function is expected to be sub-classed by a plugin
|
|
196
212
|
|
|
197
213
|
#### Parameters
|
|
198
214
|
|
|
199
|
-
* `patch` **[Array][
|
|
215
|
+
* `patch` **[Array][97]** A JSPatch patch to apply
|
|
200
216
|
|
|
201
|
-
Returns **[Promise][
|
|
217
|
+
Returns **[Promise][99]** A promise which will resolve when the operation has completed
|
|
202
218
|
|
|
203
219
|
### init
|
|
204
220
|
|
|
@@ -207,22 +223,22 @@ This function can only be called once and will return the existing init() worker
|
|
|
207
223
|
|
|
208
224
|
#### Parameters
|
|
209
225
|
|
|
210
|
-
* `options` **[Object][
|
|
226
|
+
* `options` **[Object][93]?** Additional options to merge into `settings` via `set`
|
|
211
227
|
|
|
212
|
-
Returns **[Promise][
|
|
228
|
+
Returns **[Promise][99]<[TeraFy][1]>** An eventual promise which will resovle with this terafy instance
|
|
213
229
|
|
|
214
230
|
### detectMode
|
|
215
231
|
|
|
216
232
|
Populate `settings.mode`
|
|
217
233
|
Try to communicate with a parent frame, if none assume we need to fallback to child mode
|
|
218
234
|
|
|
219
|
-
Returns **[Promise][
|
|
235
|
+
Returns **[Promise][99]<[String][95]>** A promise which will resolve with the detected mode to use
|
|
220
236
|
|
|
221
237
|
### injectComms
|
|
222
238
|
|
|
223
239
|
Find an existing active TERA server OR initalize one
|
|
224
240
|
|
|
225
|
-
Returns **[Promise][
|
|
241
|
+
Returns **[Promise][99]** A promise which will resolve when the loading has completed and we have found a parent TERA instance or initiallized a child
|
|
226
242
|
|
|
227
243
|
### injectStylesheet
|
|
228
244
|
|
|
@@ -249,7 +265,7 @@ This function also routes 'special' keys like `devMode` to their internal handle
|
|
|
249
265
|
|
|
250
266
|
#### Parameters
|
|
251
267
|
|
|
252
|
-
* `key` **([String][
|
|
268
|
+
* `key` **([String][95] | [Object][93])** Either a single setting key to set or an object to merge
|
|
253
269
|
* `value` **any** The value to set if `key` is a string
|
|
254
270
|
|
|
255
271
|
Returns **[TeraFy][1]** This chainable terafy instance
|
|
@@ -258,11 +274,11 @@ Returns **[TeraFy][1]** This chainable terafy instance
|
|
|
258
274
|
|
|
259
275
|
* **See**: set()
|
|
260
276
|
|
|
261
|
-
Set or merge settings - but only in dev mode
|
|
277
|
+
Set or merge settings - but only in dev mode and only if the value is not undefined
|
|
262
278
|
|
|
263
279
|
#### Parameters
|
|
264
280
|
|
|
265
|
-
* `key` **([String][
|
|
281
|
+
* `key` **([String][95] | [Object][93])** Either a single setting key to set or an object to merge
|
|
266
282
|
* `value` **any** The value to set if `key` is a string
|
|
267
283
|
|
|
268
284
|
Returns **[TeraFy][1]** This chainable terafy instance
|
|
@@ -274,8 +290,8 @@ Include a TeraFy client plugin
|
|
|
274
290
|
#### Parameters
|
|
275
291
|
|
|
276
292
|
* `mod`  
|
|
277
|
-
* `options` **[Object][
|
|
278
|
-
* `The` **[Object][
|
|
293
|
+
* `options` **[Object][93]?** Additional options to mutate behaviour during construction (pass options to init() to intialize later options)
|
|
294
|
+
* `The` **[Object][93]** module function to include. Invoked as `(teraClient:TeraFy, options:Object)`
|
|
279
295
|
|
|
280
296
|
Returns **[TeraFy][1]** This chainable terafy instance
|
|
281
297
|
|
|
@@ -285,8 +301,8 @@ Internal function used by use() to merge an external declared singleton against
|
|
|
285
301
|
|
|
286
302
|
#### Parameters
|
|
287
303
|
|
|
288
|
-
* `target` **[Object][
|
|
289
|
-
* `source` **[Object][
|
|
304
|
+
* `target` **[Object][93]** Initalied class instance to extend
|
|
305
|
+
* `source` **[Object][93]** Initalized source object to extend from
|
|
290
306
|
|
|
291
307
|
### toggleDevMode
|
|
292
308
|
|
|
@@ -294,7 +310,7 @@ Set or toggle devMode
|
|
|
294
310
|
|
|
295
311
|
#### Parameters
|
|
296
312
|
|
|
297
|
-
* `devModeEnabled` **([String][
|
|
313
|
+
* `devModeEnabled` **([String][95] | [Boolean][94])** Optional boolean to force dev mode (optional, default `'toggle'`)
|
|
298
314
|
|
|
299
315
|
Returns **[TeraFy][1]** This chainable terafy instance
|
|
300
316
|
|
|
@@ -305,7 +321,7 @@ This is usually because the server component wants to perform some user activity
|
|
|
305
321
|
|
|
306
322
|
#### Parameters
|
|
307
323
|
|
|
308
|
-
* `isFocused` **([String][
|
|
324
|
+
* `isFocused` **([String][95] | [Boolean][94])** Whether to fullscreen the embedded component (optional, default `'toggle'`)
|
|
309
325
|
|
|
310
326
|
## handshake
|
|
311
327
|
|
|
@@ -313,9 +329,9 @@ Return basic server information as a form of validation
|
|
|
313
329
|
|
|
314
330
|
### Properties
|
|
315
331
|
|
|
316
|
-
* `date` **[Date][
|
|
332
|
+
* `date` **[Date][102]** Server date
|
|
317
333
|
|
|
318
|
-
Returns **[Promise][
|
|
334
|
+
Returns **[Promise][99]<[Object][93]>** Basic promise result
|
|
319
335
|
|
|
320
336
|
## User
|
|
321
337
|
|
|
@@ -323,16 +339,16 @@ User / active session within TERA
|
|
|
323
339
|
|
|
324
340
|
### Properties
|
|
325
341
|
|
|
326
|
-
* `id` **[String][
|
|
327
|
-
* `email` **[String][
|
|
328
|
-
* `name` **[String][
|
|
329
|
-
* `isSubscribed` **[Boolean][
|
|
342
|
+
* `id` **[String][95]** Unique identifier of the user
|
|
343
|
+
* `email` **[String][95]** The email address of the current user
|
|
344
|
+
* `name` **[String][95]** The provided full name of the user
|
|
345
|
+
* `isSubscribed` **[Boolean][94]** Whether the active user has a TERA subscription
|
|
330
346
|
|
|
331
347
|
## getUser
|
|
332
348
|
|
|
333
349
|
Fetch the current session user
|
|
334
350
|
|
|
335
|
-
Returns **[Promise][
|
|
351
|
+
Returns **[Promise][99]<[User][44]>** The current logged in user or null if none
|
|
336
352
|
|
|
337
353
|
## requireUser
|
|
338
354
|
|
|
@@ -340,7 +356,13 @@ Require a user login to TERA
|
|
|
340
356
|
If there is no user OR they are not logged in a prompt is shown to go and do so
|
|
341
357
|
This is an pre-requisite step for requireProject()
|
|
342
358
|
|
|
343
|
-
|
|
359
|
+
### Parameters
|
|
360
|
+
|
|
361
|
+
* `options` **[Object][93]?** Additional options to mutate behaviour
|
|
362
|
+
|
|
363
|
+
* `options.forceRetry` **[Boolean][94]** Forcabily try to refresh the user state (optional, default `false`)
|
|
364
|
+
|
|
365
|
+
Returns **[Promise][99]<[User][44]>** The current logged in user or null if none
|
|
344
366
|
|
|
345
367
|
##
|
|
346
368
|
|
|
@@ -348,7 +370,7 @@ Require a user login to TERA
|
|
|
348
370
|
If there is no user OR they are not logged in a prompt is shown to go and do so
|
|
349
371
|
This is an pre-requisite step for requireProject()
|
|
350
372
|
|
|
351
|
-
Returns **[Promise][
|
|
373
|
+
Returns **[Promise][99]** A promise which will resolve if the there is a user and they are logged in
|
|
352
374
|
|
|
353
375
|
## Project
|
|
354
376
|
|
|
@@ -358,13 +380,13 @@ Project entry within TERA
|
|
|
358
380
|
|
|
359
381
|
Get the currently active project, if any
|
|
360
382
|
|
|
361
|
-
Returns **[Promise][
|
|
383
|
+
Returns **[Promise][99]<([Project][50] | null)>** The currently active project, if any
|
|
362
384
|
|
|
363
385
|
## getProjects
|
|
364
386
|
|
|
365
387
|
Get a list of projects the current session user has access to
|
|
366
388
|
|
|
367
|
-
Returns **[Promise][
|
|
389
|
+
Returns **[Promise][99]<[Array][97]<[Project][50]>>** Collection of projects the user has access to
|
|
368
390
|
|
|
369
391
|
## setActiveProject
|
|
370
392
|
|
|
@@ -372,7 +394,7 @@ Set the currently active project within TERA
|
|
|
372
394
|
|
|
373
395
|
### Parameters
|
|
374
396
|
|
|
375
|
-
* `project` **([Object][
|
|
397
|
+
* `project` **([Object][93] | [String][95])** The project to set as active - either the full Project object or its ID
|
|
376
398
|
|
|
377
399
|
## requireProject
|
|
378
400
|
|
|
@@ -381,14 +403,14 @@ Note that this function will percist in asking the uesr even if they try to canc
|
|
|
381
403
|
|
|
382
404
|
### Parameters
|
|
383
405
|
|
|
384
|
-
* `options` **[Object][
|
|
406
|
+
* `options` **[Object][93]?** Additional options to mutate behaviour
|
|
385
407
|
|
|
386
|
-
* `options.autoSetActiveProject` **[Boolean][
|
|
387
|
-
* `options.title` **[String][
|
|
388
|
-
* `options.noSelectTitle` **[String][
|
|
389
|
-
* `options.noSelectBody` **[String][
|
|
408
|
+
* `options.autoSetActiveProject` **[Boolean][94]** After selecting a project set that project as active in TERA (optional, default `true`)
|
|
409
|
+
* `options.title` **[String][95]** The title of the dialog to display (optional, default `"Select a project to work with"`)
|
|
410
|
+
* `options.noSelectTitle` **[String][95]** Dialog title when warning the user they need to select something (optional, default `'Select project'`)
|
|
411
|
+
* `options.noSelectBody` **[String][95]** Dialog body when warning the user they need to select something (optional, default `'A project needs to be selected to continue'`)
|
|
390
412
|
|
|
391
|
-
Returns **[Promise][
|
|
413
|
+
Returns **[Promise][99]<[Project][50]>** The active project
|
|
392
414
|
|
|
393
415
|
## selectProject
|
|
394
416
|
|
|
@@ -396,13 +418,13 @@ Prompt the user to select a project from those available
|
|
|
396
418
|
|
|
397
419
|
### Parameters
|
|
398
420
|
|
|
399
|
-
* `options` **[Object][
|
|
421
|
+
* `options` **[Object][93]?** Additional options to mutate behaviour
|
|
400
422
|
|
|
401
|
-
* `options.title` **[String][
|
|
402
|
-
* `options.allowCancel` **[Boolean][
|
|
403
|
-
* `options.setActive` **[Boolean][
|
|
423
|
+
* `options.title` **[String][95]** The title of the dialog to display (optional, default `"Select a project to work with"`)
|
|
424
|
+
* `options.allowCancel` **[Boolean][94]** Advertise cancelling the operation, the dialog can still be cancelled by closing it (optional, default `true`)
|
|
425
|
+
* `options.setActive` **[Boolean][94]** Also set the project as active when selected (optional, default `false`)
|
|
404
426
|
|
|
405
|
-
Returns **[Promise][
|
|
427
|
+
Returns **[Promise][99]<[Project][50]>** The active project
|
|
406
428
|
|
|
407
429
|
## getProjectState
|
|
408
430
|
|
|
@@ -410,12 +432,12 @@ Return the current, full snapshot state of the active project
|
|
|
410
432
|
|
|
411
433
|
### Parameters
|
|
412
434
|
|
|
413
|
-
* `options` **[Object][
|
|
435
|
+
* `options` **[Object][93]?** Additional options to mutate behaviour
|
|
414
436
|
|
|
415
|
-
* `options.autoRequire` **[Boolean][
|
|
416
|
-
* `Paths` **[Array][
|
|
437
|
+
* `options.autoRequire` **[Boolean][94]** Run `requireProject()` automatically before continuing (optional, default `true`)
|
|
438
|
+
* `Paths` **[Array][97]<[String][95]>** to subscribe to e.g. \['/users/'],
|
|
417
439
|
|
|
418
|
-
Returns **[Promise][
|
|
440
|
+
Returns **[Promise][99]<[Object][93]>** The current project state snapshot
|
|
419
441
|
|
|
420
442
|
## setProjectState
|
|
421
443
|
|
|
@@ -427,14 +449,14 @@ Paths can be any valid Lodash.set() value such as:
|
|
|
427
449
|
|
|
428
450
|
### Parameters
|
|
429
451
|
|
|
430
|
-
* `path` **([String][
|
|
452
|
+
* `path` **([String][95] | [Array][97]<[String][95]>)** The sub-path within the project state to set
|
|
431
453
|
* `value` **any** The value to set
|
|
432
|
-
* `options` **[Object][
|
|
454
|
+
* `options` **[Object][93]?** Additional options to mutate behaviour
|
|
433
455
|
|
|
434
|
-
* `options.save` **[Boolean][
|
|
435
|
-
* `options.sync` **[Boolean][
|
|
456
|
+
* `options.save` **[Boolean][94]** Save the changes to the server immediately, disable to queue up multiple writes (optional, default `true`)
|
|
457
|
+
* `options.sync` **[Boolean][94]** Wait for the server to acknowledge the write, you almost never need to do this (optional, default `false`)
|
|
436
458
|
|
|
437
|
-
Returns **[Promise][
|
|
459
|
+
Returns **[Promise][99]** A promise which resolves when the operation has synced with the server
|
|
438
460
|
|
|
439
461
|
## setProjectStateDefaults
|
|
440
462
|
|
|
@@ -444,17 +466,17 @@ Set a nested value within the project state - just like `setProjectState()` - bu
|
|
|
444
466
|
|
|
445
467
|
### Parameters
|
|
446
468
|
|
|
447
|
-
* `path` **([String][
|
|
469
|
+
* `path` **([String][95] | [Array][97]<[String][95]>)** The sub-path within the project state to set
|
|
448
470
|
* `value` **any** The value to set
|
|
449
|
-
* `options` **[Object][
|
|
471
|
+
* `options` **[Object][93]?** Additional options to mutate behaviour, see setProjectState() for the full list of supported options
|
|
450
472
|
|
|
451
|
-
Returns **[Promise][
|
|
473
|
+
Returns **[Promise][99]<[Boolean][94]>** A promise which resolves to whether any changes were made - True if defaults were applied, false otherwise
|
|
452
474
|
|
|
453
475
|
## saveProjectState
|
|
454
476
|
|
|
455
477
|
Force-Save the currently active project state
|
|
456
478
|
|
|
457
|
-
Returns **[Promise][
|
|
479
|
+
Returns **[Promise][99]** A promise which resolves when the operation has completed
|
|
458
480
|
|
|
459
481
|
## replaceProjectState
|
|
460
482
|
|
|
@@ -465,9 +487,9 @@ You almost never want to use this function directly, see `setProjectState(path,
|
|
|
465
487
|
|
|
466
488
|
### Parameters
|
|
467
489
|
|
|
468
|
-
* `newState` **[Object][
|
|
490
|
+
* `newState` **[Object][93]** The new state to replace the current state with
|
|
469
491
|
|
|
470
|
-
Returns **[Promise][
|
|
492
|
+
Returns **[Promise][99]** A promise which resolves when the operation has completed
|
|
471
493
|
|
|
472
494
|
## applyProjectStatePatch
|
|
473
495
|
|
|
@@ -475,9 +497,9 @@ Apply a computed `just-diff` patch to the current project state
|
|
|
475
497
|
|
|
476
498
|
### Parameters
|
|
477
499
|
|
|
478
|
-
* `Patch` **[Object][
|
|
500
|
+
* `Patch` **[Object][93]** to apply
|
|
479
501
|
|
|
480
|
-
Returns **[Promise][
|
|
502
|
+
Returns **[Promise][99]** A promise which resolves when the operation has completed
|
|
481
503
|
|
|
482
504
|
## subscribeProjectState
|
|
483
505
|
|
|
@@ -485,7 +507,7 @@ Subscribe to project state changes
|
|
|
485
507
|
This will dispatch an RPC call to the source object `applyProjectStatePatchLocal()` function with the patch
|
|
486
508
|
If the above call fails the subscriber is assumed as dead and unsubscribed from the polling list
|
|
487
509
|
|
|
488
|
-
Returns **[Promise][
|
|
510
|
+
Returns **[Promise][99]<[Function][103]>** A promise which resolves when a subscription has been created, call the resulting function to unsubscribe
|
|
489
511
|
|
|
490
512
|
## ProjectFile
|
|
491
513
|
|
|
@@ -493,19 +515,50 @@ Data structure for a project file
|
|
|
493
515
|
|
|
494
516
|
### Properties
|
|
495
517
|
|
|
496
|
-
* `id` **[String][
|
|
497
|
-
* `name` **[String][
|
|
498
|
-
* `parsedName` **[Object][
|
|
518
|
+
* `id` **[String][95]** A UUID string representing the unique ID of the file
|
|
519
|
+
* `name` **[String][95]** Relative name path (can contain prefix directories) for the human readable file name
|
|
520
|
+
* `parsedName` **[Object][93]** An object representing meta file parts of a file name
|
|
521
|
+
|
|
522
|
+
* `parsedName.basename` **[String][95]** The filename + extention (i.e. everything without directory name)
|
|
523
|
+
* `parsedName.filename` **[String][95]** The file portion of the name (basename without the extension)
|
|
524
|
+
* `parsedName.ext` **[String][95]** The extension portion of the name (always lower case)
|
|
525
|
+
* `parsedName.dirName` **[String][95]** The directory path portion of the name
|
|
526
|
+
* `created` **[Date][102]** A date representing when the file was created
|
|
527
|
+
* `modified` **[Date][102]** A date representing when the file was created
|
|
528
|
+
* `accessed` **[Date][102]** A date representing when the file was last accessed
|
|
529
|
+
* `size` **[Number][96]** Size, in bytes, of the file
|
|
530
|
+
* `mime` **[String][95]** The associated mime type for the file
|
|
531
|
+
|
|
532
|
+
## FileFilters
|
|
533
|
+
|
|
534
|
+
Data structure for a file filter
|
|
535
|
+
|
|
536
|
+
### Properties
|
|
537
|
+
|
|
538
|
+
* `library` **[Boolean][94]?** Restrict to library files only
|
|
539
|
+
* `filename` **[String][95]?** CSV of @momsfriendlydevco/match expressions to filter the filename by (filenames are the basename sans extension)
|
|
540
|
+
* `basename` **[String][95]?** CSV of @momsfriendlydevco/match expressions to filter the basename by
|
|
541
|
+
* `ext` **[String][95]?** CSV of @momsfriendlydevco/match expressions to filter the file extension by
|
|
542
|
+
|
|
543
|
+
## selectProjectFile
|
|
544
|
+
|
|
545
|
+
Prompt the user to select a library to operate on
|
|
546
|
+
|
|
547
|
+
### Parameters
|
|
548
|
+
|
|
549
|
+
* `options` **[Object][93]?** Additional options to mutate behaviour
|
|
499
550
|
|
|
500
|
-
* `
|
|
501
|
-
* `
|
|
502
|
-
* `
|
|
503
|
-
* `
|
|
504
|
-
* `
|
|
505
|
-
* `
|
|
506
|
-
* `
|
|
507
|
-
* `
|
|
508
|
-
* `
|
|
551
|
+
* `options.title` **[String][95]** The title of the dialog to display (optional, default `"Select a file"`)
|
|
552
|
+
* `options.hint` **([String][95] | [Array][97]<[String][95]>)?** Hints to identify the file to select in array order of preference
|
|
553
|
+
* `options.filters` **[FileFilters][73]?** Optional file filters
|
|
554
|
+
* `options.allowUpload` **[Boolean][94]** Allow uploading new files (optional, default `true`)
|
|
555
|
+
* `options.allowRefresh` **[Boolean][94]** Allow the user to manually refresh the file list (optional, default `true`)
|
|
556
|
+
* `options.allowDownloadZip` **[Boolean][94]** Allow the user to download a Zip of all files (optional, default `true`)
|
|
557
|
+
* `options.allowCancel` **[Boolean][94]** Allow cancelling the operation. Will throw `'CANCEL'` as the promise rejection if acationed (optional, default `true`)
|
|
558
|
+
* `options.autoRequire` **[Boolean][94]** Run `requireProject()` automatically before continuing (optional, default `true`)
|
|
559
|
+
* `options.filter` **[FileFilters][73]?** Optional file filters
|
|
560
|
+
|
|
561
|
+
Returns **[Promise][99]<[ProjectFile][71]>** The eventually selected file
|
|
509
562
|
|
|
510
563
|
## getProjectFiles
|
|
511
564
|
|
|
@@ -513,29 +566,65 @@ Fetch the files associated with a given project
|
|
|
513
566
|
|
|
514
567
|
### Parameters
|
|
515
568
|
|
|
516
|
-
* `options` **[Object][
|
|
569
|
+
* `options` **[Object][93]** Options which mutate behaviour
|
|
570
|
+
|
|
571
|
+
* `options.autoRequire` **[Boolean][94]** Run `requireProject()` automatically before continuing (optional, default `true`)
|
|
572
|
+
* `options.meta` **[Boolean][94]** Pull meta information for each file entity (optional, default `true`)
|
|
573
|
+
|
|
574
|
+
Returns **[Promise][99]<[Array][97]<[ProjectFile][71]>>** A collection of project files for the given project
|
|
575
|
+
|
|
576
|
+
## selectProjectLibrary
|
|
577
|
+
|
|
578
|
+
Prompt the user to select a library to operate on and return a array of references in a given format
|
|
579
|
+
|
|
580
|
+
### Parameters
|
|
581
|
+
|
|
582
|
+
* `options` **[Object][93]?** Additional options to mutate behaviour
|
|
583
|
+
|
|
584
|
+
* `options.title` **[String][95]** The title of the dialog to display (optional, default `"Select a citation library"`)
|
|
585
|
+
* `options.hint` **([String][95] | [Array][97]<[String][95]>)?** Hints to identify the library to select in array order of preference. Generally corresponds to the previous stage - e.g. 'deduped', 'review1', 'review2', 'dedisputed'
|
|
586
|
+
* `options.allowUpload` **[Boolean][94]** Allow uploading new files (optional, default `true`)
|
|
587
|
+
* `options.allowRefresh` **[Boolean][94]** Allow the user to manually refresh the file list (optional, default `true`)
|
|
588
|
+
* `options.allowDownloadZip` **[Boolean][94]** Allow the user to download a Zip of all files (optional, default `true`)
|
|
589
|
+
* `options.allowCancel` **[Boolean][94]** Allow cancelling the operation. Will throw `'CANCEL'` as the promise rejection if acationed (optional, default `true`)
|
|
590
|
+
* `options.autoRequire` **[Boolean][94]** Run `requireProject()` automatically before continuing (optional, default `true`)
|
|
591
|
+
* `options.filters` **[FileFilters][73]?** Optional file filters, defaults to citation library selection only
|
|
592
|
+
|
|
593
|
+
Returns **[Promise][99]<[Array][97]\<Ref>>** A collection of references from the selected file
|
|
594
|
+
|
|
595
|
+
## parseProjectLibrary
|
|
596
|
+
|
|
597
|
+
Convert a project file into a library of citations
|
|
598
|
+
|
|
599
|
+
### Parameters
|
|
600
|
+
|
|
601
|
+
* `path` **[String][95]** File path to read, if omitted the contents of `options` are used to guess at a suitable file
|
|
602
|
+
* `options` **[Object][93]?** Additional options to mutate behaviour
|
|
517
603
|
|
|
518
|
-
* `options.
|
|
519
|
-
* `options.
|
|
604
|
+
* `options.format` **[String][95]** Format for the file. ENUM: 'pojo' (return a parsed JS collection), 'blob' (raw JS Blob object), 'file' (named JS File object) (optional, default `'json'`)
|
|
605
|
+
* `options.autoRequire` **[Boolean][94]** Run `requireProject()` automatically before continuing (optional, default `true`)
|
|
606
|
+
* `options.filter` **[Function][103]?** Optional async file filter, called each time as `(File:ProjectFile)`
|
|
607
|
+
* `options.find` **[Function][103]?** Optional async final stage file filter to reduce all candidates down to one subject file
|
|
520
608
|
|
|
521
|
-
Returns **[Promise][
|
|
609
|
+
Returns **([Promise][99]<[Array][97]\<Ref>> | [Promise][99]\<any>)** A collection of references (default bevahiour) or a whatever format was requested
|
|
522
610
|
|
|
523
|
-
##
|
|
611
|
+
## setProjectLibrary
|
|
524
612
|
|
|
525
|
-
|
|
613
|
+
Save back a citation library from some input
|
|
526
614
|
|
|
527
615
|
### Parameters
|
|
528
616
|
|
|
529
|
-
* `path` **[String][
|
|
530
|
-
* `
|
|
617
|
+
* `path` **[String][95]?** File path to save back to
|
|
618
|
+
* `Collection` **[Array][97]\<RefLibRef>** of references for the selected library
|
|
619
|
+
* `options` **[Object][93]?** Additional options to mutate behaviour
|
|
531
620
|
|
|
532
|
-
* `options.
|
|
533
|
-
* `options.
|
|
534
|
-
* `options.
|
|
535
|
-
* `options.
|
|
536
|
-
* `options.
|
|
621
|
+
* `options.format` **[String][95]** Input format used. ENUM: 'pojo' (return a parsed JS collection), 'blob' (raw JS Blob object), 'file' (named JS File object) (optional, default `'json'`)
|
|
622
|
+
* `options.autoRequire` **[Boolean][94]** Run `requireProject()` automatically before continuing (optional, default `true`)
|
|
623
|
+
* `options.hint` **[String][95]?** Hint to store against the library. Generally corresponds to the current operation being performed - e.g. 'deduped'
|
|
624
|
+
* `options.overwrite` **[Boolean][94]** Allow existing file upsert (optional, default `true`)
|
|
625
|
+
* `options.meta` **[Object][93]?** Optional meta data to merge into the file data
|
|
537
626
|
|
|
538
|
-
Returns **[Promise][
|
|
627
|
+
Returns **[Promise][99]** A promise which resolves when the save operation has completed
|
|
539
628
|
|
|
540
629
|
## setProjectLibrary
|
|
541
630
|
|
|
@@ -543,13 +632,13 @@ Save back a projects citation library
|
|
|
543
632
|
|
|
544
633
|
### Parameters
|
|
545
634
|
|
|
546
|
-
* `Collection` **[Array][
|
|
547
|
-
* `options` **[Object][
|
|
635
|
+
* `Collection` **[Array][97]\<RefLibRef>** of references for the selected library
|
|
636
|
+
* `options` **[Object][93]?** Additional options to mutate behaviour
|
|
548
637
|
|
|
549
|
-
* `options.autoRequire` **[Boolean][
|
|
550
|
-
* `options.hint` **[String][
|
|
638
|
+
* `options.autoRequire` **[Boolean][94]** Run `requireProject()` automatically before continuing (optional, default `true`)
|
|
639
|
+
* `options.hint` **[String][95]?** Hint to store against the library. Generally corresponds to the current operation being performed - e.g. 'deduped'
|
|
551
640
|
|
|
552
|
-
Returns **[Promise][
|
|
641
|
+
Returns **[Promise][99]** A promise which resolves when the save operation has completed
|
|
553
642
|
|
|
554
643
|
## uiAlert
|
|
555
644
|
|
|
@@ -557,13 +646,41 @@ Display simple text within TERA
|
|
|
557
646
|
|
|
558
647
|
### Parameters
|
|
559
648
|
|
|
560
|
-
* `text` **[String][
|
|
561
|
-
* `options` **[Object][
|
|
649
|
+
* `text` **[String][95]** The text to display
|
|
650
|
+
* `options` **[Object][93]?** Additional options to mutate behaviour
|
|
651
|
+
|
|
652
|
+
* `options.title` **[String][95]** The title of the alert box (optional, default `'TERA'`)
|
|
653
|
+
* `options.isHtml` **[Boolean][94]** If falsy the text is rendered as plain-text otherwise it will be assumed as HTML content (optional, default `false`)
|
|
654
|
+
|
|
655
|
+
Returns **[Promise][99]** A promise which resolves when the alert has been dismissed
|
|
656
|
+
|
|
657
|
+
## uiSplat
|
|
658
|
+
|
|
659
|
+
Display HTML content full-screen within TERA
|
|
660
|
+
This function is ideally called within a requestFocus() wrapper
|
|
661
|
+
|
|
662
|
+
### Parameters
|
|
663
|
+
|
|
664
|
+
* `content` **(DOMElement | [String][95] | `false`)** Either a prepared DOM element or string to compile, set to falsy to remove existing content
|
|
665
|
+
* `options` **[Object][93]?** Additional options to mutate behaviour
|
|
666
|
+
|
|
667
|
+
* `options.logo` **([Boolean][94] | [String][95])** Add a logo to the output, if boolean true the Tera-tools logo is used otherwise specify a path or URL (optional, default `false`)
|
|
668
|
+
|
|
669
|
+
## uiWindow
|
|
670
|
+
|
|
671
|
+
Open a popup window containing a new site
|
|
672
|
+
|
|
673
|
+
### Parameters
|
|
674
|
+
|
|
675
|
+
* `url` **[String][95]** The URL to open
|
|
676
|
+
* `options` **[Object][93]?** Additional options to mutate behaviour
|
|
562
677
|
|
|
563
|
-
* `options.
|
|
564
|
-
* `options.
|
|
678
|
+
* `options.width` **[Number][96]** The desired width of the window (optional, default `500`)
|
|
679
|
+
* `options.height` **[Number][96]** The desired height of the window (optional, default `600`)
|
|
680
|
+
* `options.center` **[Boolean][94]** Attempt to center the window on the screen (optional, default `true`)
|
|
681
|
+
* `options.permissions` **[Object][93]?** Additional permissions to set on opening, defaults to a suitable set of permission for popups (see code)
|
|
565
682
|
|
|
566
|
-
Returns **
|
|
683
|
+
Returns **WindowProxy** The opened window object (if `noopener` is not set in permissions)
|
|
567
684
|
|
|
568
685
|
[1]: #terafy
|
|
569
686
|
|
|
@@ -659,86 +776,114 @@ Returns **[Promise][85]** A promise which resolves when the alert has been dismi
|
|
|
659
776
|
|
|
660
777
|
[47]: #requireuser
|
|
661
778
|
|
|
662
|
-
[48]: #
|
|
779
|
+
[48]: #parameters-14
|
|
780
|
+
|
|
781
|
+
[49]: #
|
|
782
|
+
|
|
783
|
+
[50]: #project
|
|
784
|
+
|
|
785
|
+
[51]: #getproject
|
|
786
|
+
|
|
787
|
+
[52]: #getprojects
|
|
788
|
+
|
|
789
|
+
[53]: #setactiveproject
|
|
790
|
+
|
|
791
|
+
[54]: #parameters-15
|
|
792
|
+
|
|
793
|
+
[55]: #requireproject
|
|
794
|
+
|
|
795
|
+
[56]: #parameters-16
|
|
796
|
+
|
|
797
|
+
[57]: #selectproject
|
|
798
|
+
|
|
799
|
+
[58]: #parameters-17
|
|
800
|
+
|
|
801
|
+
[59]: #getprojectstate
|
|
802
|
+
|
|
803
|
+
[60]: #parameters-18
|
|
804
|
+
|
|
805
|
+
[61]: #setprojectstate
|
|
806
|
+
|
|
807
|
+
[62]: #parameters-19
|
|
663
808
|
|
|
664
|
-
[
|
|
809
|
+
[63]: #setprojectstatedefaults
|
|
665
810
|
|
|
666
|
-
[
|
|
811
|
+
[64]: #parameters-20
|
|
667
812
|
|
|
668
|
-
[
|
|
813
|
+
[65]: #saveprojectstate
|
|
669
814
|
|
|
670
|
-
[
|
|
815
|
+
[66]: #replaceprojectstate
|
|
671
816
|
|
|
672
|
-
[
|
|
817
|
+
[67]: #parameters-21
|
|
673
818
|
|
|
674
|
-
[
|
|
819
|
+
[68]: #applyprojectstatepatch
|
|
675
820
|
|
|
676
|
-
[
|
|
821
|
+
[69]: #parameters-22
|
|
677
822
|
|
|
678
|
-
[
|
|
823
|
+
[70]: #subscribeprojectstate
|
|
679
824
|
|
|
680
|
-
[
|
|
825
|
+
[71]: #projectfile
|
|
681
826
|
|
|
682
|
-
[
|
|
827
|
+
[72]: #properties-4
|
|
683
828
|
|
|
684
|
-
[
|
|
829
|
+
[73]: #filefilters
|
|
685
830
|
|
|
686
|
-
[
|
|
831
|
+
[74]: #properties-5
|
|
687
832
|
|
|
688
|
-
[
|
|
833
|
+
[75]: #selectprojectfile
|
|
689
834
|
|
|
690
|
-
[
|
|
835
|
+
[76]: #parameters-23
|
|
691
836
|
|
|
692
|
-
[
|
|
837
|
+
[77]: #getprojectfiles
|
|
693
838
|
|
|
694
|
-
[
|
|
839
|
+
[78]: #parameters-24
|
|
695
840
|
|
|
696
|
-
[
|
|
841
|
+
[79]: #selectprojectlibrary
|
|
697
842
|
|
|
698
|
-
[
|
|
843
|
+
[80]: #parameters-25
|
|
699
844
|
|
|
700
|
-
[
|
|
845
|
+
[81]: #parseprojectlibrary
|
|
701
846
|
|
|
702
|
-
[
|
|
847
|
+
[82]: #parameters-26
|
|
703
848
|
|
|
704
|
-
[
|
|
849
|
+
[83]: #setprojectlibrary
|
|
705
850
|
|
|
706
|
-
[
|
|
851
|
+
[84]: #parameters-27
|
|
707
852
|
|
|
708
|
-
[
|
|
853
|
+
[85]: #setprojectlibrary-1
|
|
709
854
|
|
|
710
|
-
[
|
|
855
|
+
[86]: #parameters-28
|
|
711
856
|
|
|
712
|
-
[
|
|
857
|
+
[87]: #uialert
|
|
713
858
|
|
|
714
|
-
[
|
|
859
|
+
[88]: #parameters-29
|
|
715
860
|
|
|
716
|
-
[
|
|
861
|
+
[89]: #uisplat
|
|
717
862
|
|
|
718
|
-
[
|
|
863
|
+
[90]: #parameters-30
|
|
719
864
|
|
|
720
|
-
[
|
|
865
|
+
[91]: #uiwindow
|
|
721
866
|
|
|
722
|
-
[
|
|
867
|
+
[92]: #parameters-31
|
|
723
868
|
|
|
724
|
-
[
|
|
869
|
+
[93]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
725
870
|
|
|
726
|
-
[
|
|
871
|
+
[94]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
727
872
|
|
|
728
|
-
[
|
|
873
|
+
[95]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
729
874
|
|
|
730
|
-
[
|
|
875
|
+
[96]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
731
876
|
|
|
732
|
-
[
|
|
877
|
+
[97]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
733
878
|
|
|
734
|
-
[
|
|
879
|
+
[98]: https://developer.mozilla.org/docs/Web/API/Window
|
|
735
880
|
|
|
736
|
-
[
|
|
881
|
+
[99]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
737
882
|
|
|
738
|
-
[
|
|
883
|
+
[100]: https://developer.mozilla.org/docs/Web/API/MessageEvent
|
|
739
884
|
|
|
740
|
-
[
|
|
885
|
+
[101]: http://jsonpatch.com
|
|
741
886
|
|
|
742
|
-
[
|
|
887
|
+
[102]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date
|
|
743
888
|
|
|
744
|
-
[
|
|
889
|
+
[103]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|