@iebh/tera-fy 1.0.11 → 1.0.12
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/api.md +323 -222
- package/dist/terafy.js +2 -2
- package/dist/terafy.js.map +4 -4
- package/lib/terafy.client.js +31 -8
- package/lib/terafy.server.js +28 -58
- package/package.json +1 -1
- package/.storybook/main.js +0 -22
- package/.storybook/preview.js +0 -17
- package/docs/assets/anchor.js +0 -350
- package/docs/assets/bass-addons.css +0 -12
- package/docs/assets/bass.css +0 -544
- package/docs/assets/fonts/EOT/SourceCodePro-Bold.eot +0 -0
- package/docs/assets/fonts/EOT/SourceCodePro-Regular.eot +0 -0
- package/docs/assets/fonts/LICENSE.txt +0 -93
- package/docs/assets/fonts/OTF/SourceCodePro-Bold.otf +0 -0
- package/docs/assets/fonts/OTF/SourceCodePro-Regular.otf +0 -0
- package/docs/assets/fonts/TTF/SourceCodePro-Bold.ttf +0 -0
- package/docs/assets/fonts/TTF/SourceCodePro-Regular.ttf +0 -0
- package/docs/assets/fonts/WOFF/OTF/SourceCodePro-Bold.otf.woff +0 -0
- package/docs/assets/fonts/WOFF/OTF/SourceCodePro-Regular.otf.woff +0 -0
- package/docs/assets/fonts/WOFF/TTF/SourceCodePro-Bold.ttf.woff +0 -0
- package/docs/assets/fonts/WOFF/TTF/SourceCodePro-Regular.ttf.woff +0 -0
- package/docs/assets/fonts/WOFF2/OTF/SourceCodePro-Bold.otf.woff2 +0 -0
- package/docs/assets/fonts/WOFF2/OTF/SourceCodePro-Regular.otf.woff2 +0 -0
- package/docs/assets/fonts/WOFF2/TTF/SourceCodePro-Bold.ttf.woff2 +0 -0
- package/docs/assets/fonts/WOFF2/TTF/SourceCodePro-Regular.ttf.woff2 +0 -0
- package/docs/assets/fonts/source-code-pro.css +0 -23
- package/docs/assets/github.css +0 -123
- package/docs/assets/site.js +0 -168
- package/docs/assets/split.css +0 -15
- package/docs/assets/split.js +0 -782
- package/docs/assets/style.css +0 -147
- package/docs/index.html +0 -3636
- package/docs/playground.html +0 -342
package/api.md
CHANGED
|
@@ -5,68 +5,78 @@
|
|
|
5
5
|
* [TeraFy][1]
|
|
6
6
|
* [settings][2]
|
|
7
7
|
* [Properties][3]
|
|
8
|
-
* [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* [
|
|
12
|
-
* [
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* [
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* [
|
|
29
|
-
* [
|
|
30
|
-
* [
|
|
31
|
-
* [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
* [
|
|
44
|
-
* [
|
|
45
|
-
* [
|
|
46
|
-
|
|
47
|
-
* [
|
|
48
|
-
* [
|
|
49
|
-
* [
|
|
50
|
-
* [
|
|
51
|
-
* [
|
|
52
|
-
|
|
53
|
-
* [
|
|
54
|
-
|
|
55
|
-
* [
|
|
56
|
-
|
|
57
|
-
* [
|
|
58
|
-
|
|
59
|
-
* [
|
|
60
|
-
|
|
61
|
-
* [
|
|
62
|
-
* [
|
|
63
|
-
* [
|
|
64
|
-
* [
|
|
8
|
+
* [events][4]
|
|
9
|
+
* [dom][5]
|
|
10
|
+
* [Properties][6]
|
|
11
|
+
* [methods][7]
|
|
12
|
+
* [plugins][8]
|
|
13
|
+
* [send][9]
|
|
14
|
+
* [Parameters][10]
|
|
15
|
+
* [sendRaw][11]
|
|
16
|
+
* [Parameters][12]
|
|
17
|
+
* [rpc][13]
|
|
18
|
+
* [Parameters][14]
|
|
19
|
+
* [acceptMessage][15]
|
|
20
|
+
* [Parameters][16]
|
|
21
|
+
* [acceptPostboxes][17]
|
|
22
|
+
* [createProjectStatePatch][18]
|
|
23
|
+
* [Parameters][19]
|
|
24
|
+
* [applyProjectStatePatchLocal][20]
|
|
25
|
+
* [Parameters][21]
|
|
26
|
+
* [init][22]
|
|
27
|
+
* [Parameters][23]
|
|
28
|
+
* [detectMode][24]
|
|
29
|
+
* [injectComms][25]
|
|
30
|
+
* [injectStylesheet][26]
|
|
31
|
+
* [injectMethods][27]
|
|
32
|
+
* [debug][28]
|
|
33
|
+
* [Parameters][29]
|
|
34
|
+
* [set][30]
|
|
35
|
+
* [Parameters][31]
|
|
36
|
+
* [setIfDev][32]
|
|
37
|
+
* [Parameters][33]
|
|
38
|
+
* [use][34]
|
|
39
|
+
* [Parameters][35]
|
|
40
|
+
* [mixin][36]
|
|
41
|
+
* [Parameters][37]
|
|
42
|
+
* [toggleDevMode][38]
|
|
43
|
+
* [Parameters][39]
|
|
44
|
+
* [toggleFocus][40]
|
|
45
|
+
* [Parameters][41]
|
|
46
|
+
* [handshake][42]
|
|
47
|
+
* [Properties][43]
|
|
48
|
+
* [User][44]
|
|
49
|
+
* [Properties][45]
|
|
50
|
+
* [getUser][46]
|
|
51
|
+
* [Project][47]
|
|
52
|
+
* [getProject][48]
|
|
53
|
+
* [getProjects][49]
|
|
54
|
+
* [setActiveProject][50]
|
|
55
|
+
* [Parameters][51]
|
|
56
|
+
* [requireProject][52]
|
|
57
|
+
* [Parameters][53]
|
|
58
|
+
* [selectProject][54]
|
|
59
|
+
* [Parameters][55]
|
|
60
|
+
* [getProjectState][56]
|
|
61
|
+
* [Parameters][57]
|
|
62
|
+
* [setProjectState][58]
|
|
63
|
+
* [Parameters][59]
|
|
64
|
+
* [setProjectStateDefaults][60]
|
|
65
65
|
* [Parameters][61]
|
|
66
|
-
* [
|
|
67
|
-
|
|
68
|
-
* [
|
|
69
|
-
|
|
66
|
+
* [saveProjectState][62]
|
|
67
|
+
* [replaceProjectState][63]
|
|
68
|
+
* [Parameters][64]
|
|
69
|
+
* [applyProjectStatePatch][65]
|
|
70
|
+
* [Parameters][66]
|
|
71
|
+
* [subscribeProjectState][67]
|
|
72
|
+
* [ProjectFile][68]
|
|
73
|
+
* [Properties][69]
|
|
74
|
+
* [getProjectFiles][70]
|
|
75
|
+
* [Parameters][71]
|
|
76
|
+
* [getProjectLibrary][72]
|
|
77
|
+
* [Parameters][73]
|
|
78
|
+
* [setProjectLibrary][74]
|
|
79
|
+
* [Parameters][75]
|
|
70
80
|
|
|
71
81
|
## TeraFy
|
|
72
82
|
|
|
@@ -76,21 +86,27 @@ Main Tera-Fy Client (class singleton) to be used in a frontend browser
|
|
|
76
86
|
|
|
77
87
|
Various settings to configure behaviour
|
|
78
88
|
|
|
79
|
-
Type: [Object][
|
|
89
|
+
Type: [Object][76]
|
|
80
90
|
|
|
81
91
|
#### Properties
|
|
82
92
|
|
|
83
|
-
* `devMode` **[Boolean][
|
|
93
|
+
* `devMode` **[Boolean][77]** Operate in devMode - i.e. force outer refresh when encountering an existing TeraFy instance
|
|
84
94
|
* `How` **(`"detect"` | `"parent"` | `"child"`)** 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 fallsback to 'child'
|
|
85
|
-
* `modeTimeout` **[Number][
|
|
86
|
-
* `siteUrl` **[String][
|
|
87
|
-
* `restrictOrigin` **[String][
|
|
95
|
+
* `modeTimeout` **[Number][78]** How long entities have in 'detect' mode to identify themselves
|
|
96
|
+
* `siteUrl` **[String][79]** The TERA URL to connect to
|
|
97
|
+
* `restrictOrigin` **[String][79]** URL to restrict communications to
|
|
98
|
+
|
|
99
|
+
### events
|
|
100
|
+
|
|
101
|
+
Event emitter subscription endpoint
|
|
102
|
+
|
|
103
|
+
Type: Mitt
|
|
88
104
|
|
|
89
105
|
### dom
|
|
90
106
|
|
|
91
107
|
DOMElements for this TeraFy instance
|
|
92
108
|
|
|
93
|
-
Type: [Object][
|
|
109
|
+
Type: [Object][76]
|
|
94
110
|
|
|
95
111
|
#### Properties
|
|
96
112
|
|
|
@@ -103,13 +119,13 @@ Type: [Object][66]
|
|
|
103
119
|
List of function stubs mapped here from the server
|
|
104
120
|
This array is forms the reference of `TeraFy.METHOD()` objects to provide locally which will be mapped via `TeraFy.rpc(METHOD, ...args)`
|
|
105
121
|
|
|
106
|
-
Type: [Array][
|
|
122
|
+
Type: [Array][80]<[String][79]>
|
|
107
123
|
|
|
108
124
|
### plugins
|
|
109
125
|
|
|
110
126
|
Loaded plugins via Use()
|
|
111
127
|
|
|
112
|
-
Type: [Array][
|
|
128
|
+
Type: [Array][80]\<TeraFyPlugin>
|
|
113
129
|
|
|
114
130
|
### send
|
|
115
131
|
|
|
@@ -117,9 +133,9 @@ Send a message + wait for a response object
|
|
|
117
133
|
|
|
118
134
|
#### Parameters
|
|
119
135
|
|
|
120
|
-
* `message` **[Object][
|
|
136
|
+
* `message` **[Object][76]** Message object to send
|
|
121
137
|
|
|
122
|
-
Returns **[Promise][
|
|
138
|
+
Returns **[Promise][81]\<any>** A promise which resolves when the operation has completed with the remote reply
|
|
123
139
|
|
|
124
140
|
### sendRaw
|
|
125
141
|
|
|
@@ -128,7 +144,7 @@ This function does not return or wait for a reply - use `send()` for that
|
|
|
128
144
|
|
|
129
145
|
#### Parameters
|
|
130
146
|
|
|
131
|
-
* `message` **[Object][
|
|
147
|
+
* `message` **[Object][76]** Message object to send
|
|
132
148
|
|
|
133
149
|
### rpc
|
|
134
150
|
|
|
@@ -136,10 +152,10 @@ Call an RPC function in the server instance
|
|
|
136
152
|
|
|
137
153
|
#### Parameters
|
|
138
154
|
|
|
139
|
-
* `method` **[String][
|
|
155
|
+
* `method` **[String][79]** The method name to call
|
|
140
156
|
* `args` **...any** 
|
|
141
157
|
|
|
142
|
-
Returns **[Promise][
|
|
158
|
+
Returns **[Promise][81]\<any>** The resolved output of the server function
|
|
143
159
|
|
|
144
160
|
### acceptMessage
|
|
145
161
|
|
|
@@ -148,7 +164,7 @@ Accept an incoming message
|
|
|
148
164
|
#### Parameters
|
|
149
165
|
|
|
150
166
|
* `rawMessage`  
|
|
151
|
-
* `Raw` **[MessageEvent][
|
|
167
|
+
* `Raw` **[MessageEvent][82]** message event to process
|
|
152
168
|
|
|
153
169
|
### acceptPostboxes
|
|
154
170
|
|
|
@@ -157,27 +173,27 @@ Listening postboxes, these correspond to outgoing message IDs that expect a resp
|
|
|
157
173
|
### createProjectStatePatch
|
|
158
174
|
|
|
159
175
|
Create + transmit a new project state patch base on the current and previous states
|
|
160
|
-
The transmitted patch follows the [JSPatch][
|
|
176
|
+
The transmitted patch follows the [JSPatch][83] standard
|
|
161
177
|
This function accepts an entire projectState instance, computes the delta and transmits that to the server for merging
|
|
162
178
|
|
|
163
179
|
#### Parameters
|
|
164
180
|
|
|
165
|
-
* `newState` **[Object][
|
|
166
|
-
* `oldState` **[Object][
|
|
181
|
+
* `newState` **[Object][76]** The local projectState to accept
|
|
182
|
+
* `oldState` **[Object][76]** The previous projectState to examine against
|
|
167
183
|
|
|
168
|
-
Returns **[Promise][
|
|
184
|
+
Returns **[Promise][81]** A promise which will resolve when the operation has completed
|
|
169
185
|
|
|
170
186
|
### applyProjectStatePatchLocal
|
|
171
187
|
|
|
172
188
|
Client function which accepts a patch from the server and applies it to local project state
|
|
173
|
-
The patch should follow the [JSPatch][
|
|
189
|
+
The patch should follow the [JSPatch][83] standard
|
|
174
190
|
This function is expected to be sub-classed by a plugin
|
|
175
191
|
|
|
176
192
|
#### Parameters
|
|
177
193
|
|
|
178
|
-
* `patch` **[Array][
|
|
194
|
+
* `patch` **[Array][80]** A JSPatch patch to apply
|
|
179
195
|
|
|
180
|
-
Returns **[Promise][
|
|
196
|
+
Returns **[Promise][81]** A promise which will resolve when the operation has completed
|
|
181
197
|
|
|
182
198
|
### init
|
|
183
199
|
|
|
@@ -186,22 +202,22 @@ This function can only be called once and will return the existing init() worker
|
|
|
186
202
|
|
|
187
203
|
#### Parameters
|
|
188
204
|
|
|
189
|
-
* `options` **[Object][
|
|
205
|
+
* `options` **[Object][76]?** Additional options to merge into `settings` via `set`
|
|
190
206
|
|
|
191
|
-
Returns **[Promise][
|
|
207
|
+
Returns **[Promise][81]<[TeraFy][1]>** An eventual promise which will resovle with this terafy instance
|
|
192
208
|
|
|
193
209
|
### detectMode
|
|
194
210
|
|
|
195
211
|
Populate `settings.mode`
|
|
196
212
|
Try to communicate with a parent frame, if none assume we need to fallback to child mode
|
|
197
213
|
|
|
198
|
-
Returns **[Promise][
|
|
214
|
+
Returns **[Promise][81]<[String][79]>** A promise which will resolve with the detected mode to use
|
|
199
215
|
|
|
200
216
|
### injectComms
|
|
201
217
|
|
|
202
218
|
Find an existing active TERA server OR initalize one
|
|
203
219
|
|
|
204
|
-
Returns **[Promise][
|
|
220
|
+
Returns **[Promise][81]** A promise which will resolve when the loading has completed and we have found a parent TERA instance or initiallized a child
|
|
205
221
|
|
|
206
222
|
### injectStylesheet
|
|
207
223
|
|
|
@@ -228,7 +244,20 @@ This function also routes 'special' keys like `devMode` to their internal handle
|
|
|
228
244
|
|
|
229
245
|
#### Parameters
|
|
230
246
|
|
|
231
|
-
* `key` **([String][
|
|
247
|
+
* `key` **([String][79] | [Object][76])** Either a single setting key to set or an object to merge
|
|
248
|
+
* `value` **any** The value to set if `key` is a string
|
|
249
|
+
|
|
250
|
+
Returns **[TeraFy][1]** This chainable terafy instance
|
|
251
|
+
|
|
252
|
+
### setIfDev
|
|
253
|
+
|
|
254
|
+
* **See**: set()
|
|
255
|
+
|
|
256
|
+
Set or merge settings - but only in dev mode
|
|
257
|
+
|
|
258
|
+
#### Parameters
|
|
259
|
+
|
|
260
|
+
* `key` **([String][79] | [Object][76])** Either a single setting key to set or an object to merge
|
|
232
261
|
* `value` **any** The value to set if `key` is a string
|
|
233
262
|
|
|
234
263
|
Returns **[TeraFy][1]** This chainable terafy instance
|
|
@@ -240,8 +269,8 @@ Include a TeraFy client plugin
|
|
|
240
269
|
#### Parameters
|
|
241
270
|
|
|
242
271
|
* `mod`  
|
|
243
|
-
* `options` **[Object][
|
|
244
|
-
* `The` **[Object][
|
|
272
|
+
* `options` **[Object][76]?** Additional options to mutate behaviour
|
|
273
|
+
* `The` **[Object][76]** module function to include. Invoked as `(teraClient:TeraFy, options:Object)`
|
|
245
274
|
|
|
246
275
|
Returns **[TeraFy][1]** This chainable terafy instance
|
|
247
276
|
|
|
@@ -251,8 +280,8 @@ Internal function used by use() to merge an external declared singleton against
|
|
|
251
280
|
|
|
252
281
|
#### Parameters
|
|
253
282
|
|
|
254
|
-
* `target` **[Object][
|
|
255
|
-
* `source` **[Object][
|
|
283
|
+
* `target` **[Object][76]** Initalied class instance to extend
|
|
284
|
+
* `source` **[Object][76]** Initalized source object to extend from
|
|
256
285
|
|
|
257
286
|
### toggleDevMode
|
|
258
287
|
|
|
@@ -260,7 +289,7 @@ Set or toggle devMode
|
|
|
260
289
|
|
|
261
290
|
#### Parameters
|
|
262
291
|
|
|
263
|
-
* `devModeEnabled` **([String][
|
|
292
|
+
* `devModeEnabled` **([String][79] | [Boolean][77])** Optional boolean to force dev mode (optional, default `'toggle'`)
|
|
264
293
|
|
|
265
294
|
Returns **[TeraFy][1]** This chainable terafy instance
|
|
266
295
|
|
|
@@ -271,7 +300,7 @@ This is usually because the server component wants to perform some user activity
|
|
|
271
300
|
|
|
272
301
|
#### Parameters
|
|
273
302
|
|
|
274
|
-
* `isFocused` **([String][
|
|
303
|
+
* `isFocused` **([String][79] | [Boolean][77])** Whether to fullscreen the embedded component (optional, default `'toggle'`)
|
|
275
304
|
|
|
276
305
|
## handshake
|
|
277
306
|
|
|
@@ -279,9 +308,9 @@ Return basic server information as a form of validation
|
|
|
279
308
|
|
|
280
309
|
### Properties
|
|
281
310
|
|
|
282
|
-
* `date` **[Date][
|
|
311
|
+
* `date` **[Date][84]** Server date
|
|
283
312
|
|
|
284
|
-
Returns **[Promise][
|
|
313
|
+
Returns **[Promise][81]<[Object][76]>** Basic promise result
|
|
285
314
|
|
|
286
315
|
## User
|
|
287
316
|
|
|
@@ -289,16 +318,16 @@ User / active session within TERA
|
|
|
289
318
|
|
|
290
319
|
### Properties
|
|
291
320
|
|
|
292
|
-
* `id` **[String][
|
|
293
|
-
* `email` **[String][
|
|
294
|
-
* `name` **[String][
|
|
295
|
-
* `isSubscribed` **[Boolean][
|
|
321
|
+
* `id` **[String][79]** Unique identifier of the user
|
|
322
|
+
* `email` **[String][79]** The email address of the current user
|
|
323
|
+
* `name` **[String][79]** The provided full name of the user
|
|
324
|
+
* `isSubscribed` **[Boolean][77]** Whether the active user has a TERA subscription
|
|
296
325
|
|
|
297
326
|
## getUser
|
|
298
327
|
|
|
299
328
|
Fetch the current session user
|
|
300
329
|
|
|
301
|
-
Returns **[Promise][
|
|
330
|
+
Returns **[Promise][81]<[User][44]>** The current logged in user or null if none
|
|
302
331
|
|
|
303
332
|
## Project
|
|
304
333
|
|
|
@@ -308,13 +337,13 @@ Project entry within TERA
|
|
|
308
337
|
|
|
309
338
|
Get the currently active project, if any
|
|
310
339
|
|
|
311
|
-
Returns **[Promise][
|
|
340
|
+
Returns **[Promise][81]<([Project][47] | null)>** The currently active project, if any
|
|
312
341
|
|
|
313
342
|
## getProjects
|
|
314
343
|
|
|
315
344
|
Get a list of projects the current session user has access to
|
|
316
345
|
|
|
317
|
-
Returns **[Promise][
|
|
346
|
+
Returns **[Promise][81]<[Array][80]<[Project][47]>>** Collection of projects the user has access to
|
|
318
347
|
|
|
319
348
|
## setActiveProject
|
|
320
349
|
|
|
@@ -322,7 +351,7 @@ Set the currently active project within TERA
|
|
|
322
351
|
|
|
323
352
|
### Parameters
|
|
324
353
|
|
|
325
|
-
* `project` **([Object][
|
|
354
|
+
* `project` **([Object][76] | [String][79])** The project to set as active - either the full Project object or its ID
|
|
326
355
|
|
|
327
356
|
## requireProject
|
|
328
357
|
|
|
@@ -331,14 +360,14 @@ Note that this function will percist in asking the uesr even if they try to canc
|
|
|
331
360
|
|
|
332
361
|
### Parameters
|
|
333
362
|
|
|
334
|
-
* `options` **[Object][
|
|
363
|
+
* `options` **[Object][76]?** Additional options to mutate behaviour
|
|
335
364
|
|
|
336
|
-
* `options.autoSetActiveProject` **[Boolean][
|
|
337
|
-
* `options.title` **[String][
|
|
338
|
-
* `options.noSelectTitle` **[String][
|
|
339
|
-
* `options.noSelectBody` **[String][
|
|
365
|
+
* `options.autoSetActiveProject` **[Boolean][77]** After selecting a project set that project as active in TERA (optional, default `true`)
|
|
366
|
+
* `options.title` **[String][79]** The title of the dialog to display (optional, default `"Select a project to work with"`)
|
|
367
|
+
* `options.noSelectTitle` **[String][79]** Dialog title when warning the user they need to select something (optional, default `'Select project'`)
|
|
368
|
+
* `options.noSelectBody` **[String][79]** Dialog body when warning the user they need to select something (optional, default `'A project needs to be selected to continue'`)
|
|
340
369
|
|
|
341
|
-
Returns **[Promise][
|
|
370
|
+
Returns **[Promise][81]<[Project][47]>** The active project
|
|
342
371
|
|
|
343
372
|
## selectProject
|
|
344
373
|
|
|
@@ -346,13 +375,13 @@ Prompt the user to select a project from those available
|
|
|
346
375
|
|
|
347
376
|
### Parameters
|
|
348
377
|
|
|
349
|
-
* `options` **[Object][
|
|
378
|
+
* `options` **[Object][76]?** Additional options to mutate behaviour
|
|
350
379
|
|
|
351
|
-
* `options.title` **[String][
|
|
352
|
-
* `options.allowCancel` **[Boolean][
|
|
353
|
-
* `options.setActive` **[Boolean][
|
|
380
|
+
* `options.title` **[String][79]** The title of the dialog to display (optional, default `"Select a project to work with"`)
|
|
381
|
+
* `options.allowCancel` **[Boolean][77]** Advertise cancelling the operation, the dialog can still be cancelled by closing it (optional, default `true`)
|
|
382
|
+
* `options.setActive` **[Boolean][77]** Also set the project as active when selected (optional, default `false`)
|
|
354
383
|
|
|
355
|
-
Returns **[Promise][
|
|
384
|
+
Returns **[Promise][81]<[Project][47]>** The active project
|
|
356
385
|
|
|
357
386
|
## getProjectState
|
|
358
387
|
|
|
@@ -360,12 +389,64 @@ Return the current, full snapshot state of the active project
|
|
|
360
389
|
|
|
361
390
|
### Parameters
|
|
362
391
|
|
|
363
|
-
* `options` **[Object][
|
|
392
|
+
* `options` **[Object][76]?** Additional options to mutate behaviour
|
|
364
393
|
|
|
365
|
-
* `options.autoRequire` **[Boolean][
|
|
366
|
-
* `Paths` **[Array][
|
|
394
|
+
* `options.autoRequire` **[Boolean][77]** Run `requireProject()` automatically before continuing (optional, default `true`)
|
|
395
|
+
* `Paths` **[Array][80]<[String][79]>** to subscribe to e.g. \['/users/'],
|
|
367
396
|
|
|
368
|
-
Returns **[Promise][
|
|
397
|
+
Returns **[Promise][81]<[Object][76]>** The current project state snapshot
|
|
398
|
+
|
|
399
|
+
## setProjectState
|
|
400
|
+
|
|
401
|
+
Set a nested value within the project state
|
|
402
|
+
Paths can be any valid Lodash.set() value such as:
|
|
403
|
+
|
|
404
|
+
- Dotted notation - e.g. `foo.bar.1.baz`
|
|
405
|
+
- Array path segments e.g. `['foo', 'bar', 1, 'baz']`
|
|
406
|
+
|
|
407
|
+
### Parameters
|
|
408
|
+
|
|
409
|
+
* `path` **([String][79] | [Array][80]<[String][79]>)** The sub-path within the project state to set
|
|
410
|
+
* `value` **any** The value to set
|
|
411
|
+
* `options` **[Object][76]?** Additional options to mutate behaviour
|
|
412
|
+
|
|
413
|
+
* `options.save` **[Boolean][77]** Save the changes to the server immediately, disable to queue up multiple writes (optional, default `true`)
|
|
414
|
+
* `options.sync` **[Boolean][77]** Wait for the server to acknowledge the write, you almost never need to do this (optional, default `false`)
|
|
415
|
+
|
|
416
|
+
Returns **[Promise][81]** A promise which resolves when the operation has synced with the server
|
|
417
|
+
|
|
418
|
+
## setProjectStateDefaults
|
|
419
|
+
|
|
420
|
+
* **See**: setProjectState()
|
|
421
|
+
|
|
422
|
+
Set a nested value within the project state - just like `setProjectState()` - but only if no value for that path exists
|
|
423
|
+
|
|
424
|
+
### Parameters
|
|
425
|
+
|
|
426
|
+
* `path` **([String][79] | [Array][80]<[String][79]>)** The sub-path within the project state to set
|
|
427
|
+
* `value` **any** The value to set
|
|
428
|
+
* `options` **[Object][76]?** Additional options to mutate behaviour, see setProjectState() for the full list of supported options
|
|
429
|
+
|
|
430
|
+
Returns **[Promise][81]<[Boolean][77]>** A promise which resolves to whether any changes were made - True if defaults were applied, false otherwise
|
|
431
|
+
|
|
432
|
+
## saveProjectState
|
|
433
|
+
|
|
434
|
+
Force-Save the currently active project state
|
|
435
|
+
|
|
436
|
+
Returns **[Promise][81]** A promise which resolves when the operation has completed
|
|
437
|
+
|
|
438
|
+
## replaceProjectState
|
|
439
|
+
|
|
440
|
+
* **See**: setProjectState()
|
|
441
|
+
|
|
442
|
+
Overwrite the entire project state with a new object
|
|
443
|
+
You almost never want to use this function directly, see `setProjectState(path, value)` for a nicer wrapper
|
|
444
|
+
|
|
445
|
+
### Parameters
|
|
446
|
+
|
|
447
|
+
* `newState` **[Object][76]** The new state to replace the current state with
|
|
448
|
+
|
|
449
|
+
Returns **[Promise][81]** A promise which resolves when the operation has completed
|
|
369
450
|
|
|
370
451
|
## applyProjectStatePatch
|
|
371
452
|
|
|
@@ -373,9 +454,9 @@ Apply a computed `just-diff` patch to the current project state
|
|
|
373
454
|
|
|
374
455
|
### Parameters
|
|
375
456
|
|
|
376
|
-
* `Patch` **[Object][
|
|
457
|
+
* `Patch` **[Object][76]** to apply
|
|
377
458
|
|
|
378
|
-
Returns **[Promise][
|
|
459
|
+
Returns **[Promise][81]** A promise which resolves when the operation has completed
|
|
379
460
|
|
|
380
461
|
## subscribeProjectState
|
|
381
462
|
|
|
@@ -383,7 +464,7 @@ Subscribe to project state changes
|
|
|
383
464
|
This will dispatch an RPC call to the source object `applyProjectStatePatchLocal()` function with the patch
|
|
384
465
|
If the above call fails the subscriber is assumed as dead and unsubscribed from the polling list
|
|
385
466
|
|
|
386
|
-
Returns **[Promise][
|
|
467
|
+
Returns **[Promise][81]<[Function][85]>** A promise which resolves when a subscription has been created, call the resulting function to unsubscribe
|
|
387
468
|
|
|
388
469
|
## ProjectFile
|
|
389
470
|
|
|
@@ -391,19 +472,19 @@ Data structure for a project file
|
|
|
391
472
|
|
|
392
473
|
### Properties
|
|
393
474
|
|
|
394
|
-
* `id` **[String][
|
|
395
|
-
* `name` **[String][
|
|
396
|
-
* `parsedName` **[Object][
|
|
475
|
+
* `id` **[String][79]** A UUID string representing the unique ID of the file
|
|
476
|
+
* `name` **[String][79]** Relative name path (can contain prefix directories) for the human readable file name
|
|
477
|
+
* `parsedName` **[Object][76]** An object representing meta file parts of a file name
|
|
397
478
|
|
|
398
|
-
* `parsedName.basename` **[String][
|
|
399
|
-
* `parsedName.filename` **[String][
|
|
400
|
-
* `parsedName.ext` **[String][
|
|
401
|
-
* `parsedName.dirName` **[String][
|
|
402
|
-
* `created` **[Date][
|
|
403
|
-
* `modified` **[Date][
|
|
404
|
-
* `accessed` **[Date][
|
|
405
|
-
* `size` **[Number][
|
|
406
|
-
* `mime` **[String][
|
|
479
|
+
* `parsedName.basename` **[String][79]** The filename + extention (i.e. everything without directory name)
|
|
480
|
+
* `parsedName.filename` **[String][79]** The file portion of the name (basename without the extension)
|
|
481
|
+
* `parsedName.ext` **[String][79]** The extension portion of the name (always lower case)
|
|
482
|
+
* `parsedName.dirName` **[String][79]** The directory path portion of the name
|
|
483
|
+
* `created` **[Date][84]** A date representing when the file was created
|
|
484
|
+
* `modified` **[Date][84]** A date representing when the file was created
|
|
485
|
+
* `accessed` **[Date][84]** A date representing when the file was last accessed
|
|
486
|
+
* `size` **[Number][78]** Size, in bytes, of the file
|
|
487
|
+
* `mime` **[String][79]** The associated mime type for the file
|
|
407
488
|
|
|
408
489
|
## getProjectFiles
|
|
409
490
|
|
|
@@ -411,12 +492,12 @@ Fetch the files associated with a given project
|
|
|
411
492
|
|
|
412
493
|
### Parameters
|
|
413
494
|
|
|
414
|
-
* `options` **[Object][
|
|
495
|
+
* `options` **[Object][76]** Options which mutate behaviour
|
|
415
496
|
|
|
416
|
-
* `options.autoRequire` **[Boolean][
|
|
417
|
-
* `options.meta` **[Boolean][
|
|
497
|
+
* `options.autoRequire` **[Boolean][77]** Run `requireProject()` automatically before continuing (optional, default `true`)
|
|
498
|
+
* `options.meta` **[Boolean][77]** Pull meta information for each file entity (optional, default `true`)
|
|
418
499
|
|
|
419
|
-
Returns **[Promise][
|
|
500
|
+
Returns **[Promise][81]<[ProjectFile][68]>** A collection of project files for the given project
|
|
420
501
|
|
|
421
502
|
## getProjectLibrary
|
|
422
503
|
|
|
@@ -424,16 +505,16 @@ Fetch the active projects citation library
|
|
|
424
505
|
|
|
425
506
|
### Parameters
|
|
426
507
|
|
|
427
|
-
* `path` **[String][
|
|
428
|
-
* `options` **[Object][
|
|
508
|
+
* `path` **[String][79]?** Optional file path to use, if omitted the contents of `options` are used to guess at a suitable file
|
|
509
|
+
* `options` **[Object][76]?** Additional options to mutate behaviour
|
|
429
510
|
|
|
430
|
-
* `options.autoRequire` **[Boolean][
|
|
431
|
-
* `options.multiple` **[Boolean][
|
|
432
|
-
* `options.filter` **[Function][
|
|
433
|
-
* `options.find` **[Function][
|
|
434
|
-
* `options.hint` **([String][
|
|
511
|
+
* `options.autoRequire` **[Boolean][77]** Run `requireProject()` automatically before continuing (optional, default `true`)
|
|
512
|
+
* `options.multiple` **[Boolean][77]** Allow selection of multiple libraries (optional, default `false`)
|
|
513
|
+
* `options.filter` **[Function][85]?** Optional async file filter, called each time as `(File:ProjectFile)`
|
|
514
|
+
* `options.find` **[Function][85]?** Optional async final stage file filter to reduce all candidates down to one subject file
|
|
515
|
+
* `options.hint` **([String][79] | [Array][80]<[String][79]>)?** Hints to identify the library to select in array order of preference. Generally corresponds to the previous stage - e.g. 'deduped', 'review1', 'review2', 'dedisputed'
|
|
435
516
|
|
|
436
|
-
Returns **[Promise][
|
|
517
|
+
Returns **[Promise][81]<[Array][80]<[ProjectFile][68]>>** Collection of references for the selected library matching the given hint + filter, this could be a zero length array
|
|
437
518
|
|
|
438
519
|
## setProjectLibrary
|
|
439
520
|
|
|
@@ -441,13 +522,13 @@ Save back a projects citation library
|
|
|
441
522
|
|
|
442
523
|
### Parameters
|
|
443
524
|
|
|
444
|
-
* `Collection` **[Array][
|
|
445
|
-
* `options` **[Object][
|
|
525
|
+
* `Collection` **[Array][80]\<RefLibRef>** of references for the selected library
|
|
526
|
+
* `options` **[Object][76]?** Additional options to mutate behaviour
|
|
446
527
|
|
|
447
|
-
* `options.autoRequire` **[Boolean][
|
|
448
|
-
* `options.hint` **[String][
|
|
528
|
+
* `options.autoRequire` **[Boolean][77]** Run `requireProject()` automatically before continuing (optional, default `true`)
|
|
529
|
+
* `options.hint` **[String][79]?** Hint to store against the library. Generally corresponds to the current operation being performed - e.g. 'deduped'
|
|
449
530
|
|
|
450
|
-
Returns **[Promise][
|
|
531
|
+
Returns **[Promise][81]** A promise which resolves when the save operation has completed
|
|
451
532
|
|
|
452
533
|
[1]: #terafy
|
|
453
534
|
|
|
@@ -455,146 +536,166 @@ Returns **[Promise][71]** A promise which resolves when the save operation has c
|
|
|
455
536
|
|
|
456
537
|
[3]: #properties
|
|
457
538
|
|
|
458
|
-
[4]: #
|
|
539
|
+
[4]: #events
|
|
540
|
+
|
|
541
|
+
[5]: #dom
|
|
542
|
+
|
|
543
|
+
[6]: #properties-1
|
|
544
|
+
|
|
545
|
+
[7]: #methods
|
|
546
|
+
|
|
547
|
+
[8]: #plugins
|
|
548
|
+
|
|
549
|
+
[9]: #send
|
|
550
|
+
|
|
551
|
+
[10]: #parameters
|
|
552
|
+
|
|
553
|
+
[11]: #sendraw
|
|
554
|
+
|
|
555
|
+
[12]: #parameters-1
|
|
556
|
+
|
|
557
|
+
[13]: #rpc
|
|
558
|
+
|
|
559
|
+
[14]: #parameters-2
|
|
459
560
|
|
|
460
|
-
[
|
|
561
|
+
[15]: #acceptmessage
|
|
461
562
|
|
|
462
|
-
[
|
|
563
|
+
[16]: #parameters-3
|
|
463
564
|
|
|
464
|
-
[
|
|
565
|
+
[17]: #acceptpostboxes
|
|
465
566
|
|
|
466
|
-
[
|
|
567
|
+
[18]: #createprojectstatepatch
|
|
467
568
|
|
|
468
|
-
[
|
|
569
|
+
[19]: #parameters-4
|
|
469
570
|
|
|
470
|
-
[
|
|
571
|
+
[20]: #applyprojectstatepatchlocal
|
|
471
572
|
|
|
472
|
-
[
|
|
573
|
+
[21]: #parameters-5
|
|
473
574
|
|
|
474
|
-
[
|
|
575
|
+
[22]: #init
|
|
475
576
|
|
|
476
|
-
[
|
|
577
|
+
[23]: #parameters-6
|
|
477
578
|
|
|
478
|
-
[
|
|
579
|
+
[24]: #detectmode
|
|
479
580
|
|
|
480
|
-
[
|
|
581
|
+
[25]: #injectcomms
|
|
481
582
|
|
|
482
|
-
[
|
|
583
|
+
[26]: #injectstylesheet
|
|
483
584
|
|
|
484
|
-
[
|
|
585
|
+
[27]: #injectmethods
|
|
485
586
|
|
|
486
|
-
[
|
|
587
|
+
[28]: #debug
|
|
487
588
|
|
|
488
|
-
[
|
|
589
|
+
[29]: #parameters-7
|
|
489
590
|
|
|
490
|
-
[
|
|
591
|
+
[30]: #set
|
|
491
592
|
|
|
492
|
-
[
|
|
593
|
+
[31]: #parameters-8
|
|
493
594
|
|
|
494
|
-
[
|
|
595
|
+
[32]: #setifdev
|
|
495
596
|
|
|
496
|
-
[
|
|
597
|
+
[33]: #parameters-9
|
|
497
598
|
|
|
498
|
-
[
|
|
599
|
+
[34]: #use
|
|
499
600
|
|
|
500
|
-
[
|
|
601
|
+
[35]: #parameters-10
|
|
501
602
|
|
|
502
|
-
[
|
|
603
|
+
[36]: #mixin
|
|
503
604
|
|
|
504
|
-
[
|
|
605
|
+
[37]: #parameters-11
|
|
505
606
|
|
|
506
|
-
[
|
|
607
|
+
[38]: #toggledevmode
|
|
507
608
|
|
|
508
|
-
[
|
|
609
|
+
[39]: #parameters-12
|
|
509
610
|
|
|
510
|
-
[
|
|
611
|
+
[40]: #togglefocus
|
|
511
612
|
|
|
512
|
-
[
|
|
613
|
+
[41]: #parameters-13
|
|
513
614
|
|
|
514
|
-
[
|
|
615
|
+
[42]: #handshake
|
|
515
616
|
|
|
516
|
-
[
|
|
617
|
+
[43]: #properties-2
|
|
517
618
|
|
|
518
|
-
[
|
|
619
|
+
[44]: #user
|
|
519
620
|
|
|
520
|
-
[
|
|
621
|
+
[45]: #properties-3
|
|
521
622
|
|
|
522
|
-
[
|
|
623
|
+
[46]: #getuser
|
|
523
624
|
|
|
524
|
-
[
|
|
625
|
+
[47]: #project
|
|
525
626
|
|
|
526
|
-
[
|
|
627
|
+
[48]: #getproject
|
|
527
628
|
|
|
528
|
-
[
|
|
629
|
+
[49]: #getprojects
|
|
529
630
|
|
|
530
|
-
[
|
|
631
|
+
[50]: #setactiveproject
|
|
531
632
|
|
|
532
|
-
[
|
|
633
|
+
[51]: #parameters-14
|
|
533
634
|
|
|
534
|
-
[
|
|
635
|
+
[52]: #requireproject
|
|
535
636
|
|
|
536
|
-
[
|
|
637
|
+
[53]: #parameters-15
|
|
537
638
|
|
|
538
|
-
[
|
|
639
|
+
[54]: #selectproject
|
|
539
640
|
|
|
540
|
-
[
|
|
641
|
+
[55]: #parameters-16
|
|
541
642
|
|
|
542
|
-
[
|
|
643
|
+
[56]: #getprojectstate
|
|
543
644
|
|
|
544
|
-
[
|
|
645
|
+
[57]: #parameters-17
|
|
545
646
|
|
|
546
|
-
[
|
|
647
|
+
[58]: #setprojectstate
|
|
547
648
|
|
|
548
|
-
[
|
|
649
|
+
[59]: #parameters-18
|
|
549
650
|
|
|
550
|
-
[
|
|
651
|
+
[60]: #setprojectstatedefaults
|
|
551
652
|
|
|
552
|
-
[
|
|
653
|
+
[61]: #parameters-19
|
|
553
654
|
|
|
554
|
-
[
|
|
655
|
+
[62]: #saveprojectstate
|
|
555
656
|
|
|
556
|
-
[
|
|
657
|
+
[63]: #replaceprojectstate
|
|
557
658
|
|
|
558
|
-
[
|
|
659
|
+
[64]: #parameters-20
|
|
559
660
|
|
|
560
|
-
[
|
|
661
|
+
[65]: #applyprojectstatepatch
|
|
561
662
|
|
|
562
|
-
[
|
|
663
|
+
[66]: #parameters-21
|
|
563
664
|
|
|
564
|
-
[
|
|
665
|
+
[67]: #subscribeprojectstate
|
|
565
666
|
|
|
566
|
-
[
|
|
667
|
+
[68]: #projectfile
|
|
567
668
|
|
|
568
|
-
[
|
|
669
|
+
[69]: #properties-4
|
|
569
670
|
|
|
570
|
-
[
|
|
671
|
+
[70]: #getprojectfiles
|
|
571
672
|
|
|
572
|
-
[
|
|
673
|
+
[71]: #parameters-22
|
|
573
674
|
|
|
574
|
-
[
|
|
675
|
+
[72]: #getprojectlibrary
|
|
575
676
|
|
|
576
|
-
[
|
|
677
|
+
[73]: #parameters-23
|
|
577
678
|
|
|
578
|
-
[
|
|
679
|
+
[74]: #setprojectlibrary
|
|
579
680
|
|
|
580
|
-
[
|
|
681
|
+
[75]: #parameters-24
|
|
581
682
|
|
|
582
|
-
[
|
|
683
|
+
[76]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
583
684
|
|
|
584
|
-
[
|
|
685
|
+
[77]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|
|
585
686
|
|
|
586
|
-
[
|
|
687
|
+
[78]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
587
688
|
|
|
588
|
-
[
|
|
689
|
+
[79]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
589
690
|
|
|
590
|
-
[
|
|
691
|
+
[80]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
591
692
|
|
|
592
|
-
[
|
|
693
|
+
[81]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
593
694
|
|
|
594
|
-
[
|
|
695
|
+
[82]: https://developer.mozilla.org/docs/Web/API/MessageEvent
|
|
595
696
|
|
|
596
|
-
[
|
|
697
|
+
[83]: http://jsonpatch.com
|
|
597
698
|
|
|
598
|
-
[
|
|
699
|
+
[84]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date
|
|
599
700
|
|
|
600
|
-
[
|
|
701
|
+
[85]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
|