@iebh/tera-fy 2.3.10 → 2.3.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.
Files changed (82) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/api.md +8 -11
  3. package/dist/plugin.vue2.es2019.js +28 -27
  4. package/dist/terafy.bootstrapper.es2019.js +2 -2
  5. package/dist/terafy.bootstrapper.js +2 -2
  6. package/dist/terafy.es2019.js +5 -5
  7. package/dist/terafy.js +5 -5
  8. package/eslint.config.js +4 -66
  9. package/lib/{projectFile.ts → projectFile.js} +52 -76
  10. package/lib/syncro/{entities.ts → entities.js} +14 -83
  11. package/lib/syncro/{keyed.ts → keyed.js} +46 -68
  12. package/lib/syncro/{syncro.ts → syncro.js} +104 -136
  13. package/lib/{terafy.bootstrapper.ts → terafy.bootstrapper.js} +20 -30
  14. package/lib/{terafy.client.ts → terafy.client.js} +85 -84
  15. package/lib/{terafy.proxy.ts → terafy.proxy.js} +12 -26
  16. package/lib/{terafy.server.ts → terafy.server.js} +204 -229
  17. package/package.json +20 -39
  18. package/plugins/{base.ts → base.js} +3 -5
  19. package/plugins/{firebase.ts → firebase.js} +22 -21
  20. package/plugins/{vite.ts → vite.js} +3 -3
  21. package/plugins/{vue2.ts → vue2.js} +8 -10
  22. package/plugins/{vue3.ts → vue3.js} +7 -10
  23. package/utils/mixin.js +15 -0
  24. package/utils/{pathTools.ts → pathTools.js} +8 -9
  25. package/widgets/tera-file-select.vue +1 -1
  26. package/dist/lib/projectFile.d.ts +0 -190
  27. package/dist/lib/projectFile.js +0 -305
  28. package/dist/lib/projectFile.js.map +0 -1
  29. package/dist/lib/syncro/entities.d.ts +0 -34
  30. package/dist/lib/syncro/entities.js +0 -212
  31. package/dist/lib/syncro/entities.js.map +0 -1
  32. package/dist/lib/syncro/keyed (Rhino's conflicted copy 2026-05-10).js +0 -287
  33. package/dist/lib/syncro/keyed.d.ts +0 -95
  34. package/dist/lib/syncro/keyed.js +0 -288
  35. package/dist/lib/syncro/keyed.js (Rhino's conflicted copy 2026-05-10).map +0 -1
  36. package/dist/lib/syncro/keyed.js.map +0 -1
  37. package/dist/lib/syncro/syncro (Rhino's conflicted copy 2026-05-10).js +0 -765
  38. package/dist/lib/syncro/syncro.d (Rhino's conflicted copy 2026-05-10).ts +0 -336
  39. package/dist/lib/syncro/syncro.d.ts +0 -343
  40. package/dist/lib/syncro/syncro.js +0 -771
  41. package/dist/lib/syncro/syncro.js (Rhino's conflicted copy 2026-05-10).map +0 -1
  42. package/dist/lib/syncro/syncro.js.map +0 -1
  43. package/dist/lib/terafy.bootstrapper.d.ts +0 -42
  44. package/dist/lib/terafy.bootstrapper.js +0 -129
  45. package/dist/lib/terafy.bootstrapper.js.map +0 -1
  46. package/dist/lib/terafy.client.d.ts +0 -555
  47. package/dist/lib/terafy.client.js +0 -1153
  48. package/dist/lib/terafy.client.js.map +0 -1
  49. package/dist/lib/terafy.proxy.d.ts +0 -66
  50. package/dist/lib/terafy.proxy.js +0 -130
  51. package/dist/lib/terafy.proxy.js.map +0 -1
  52. package/dist/lib/terafy.server.d.ts +0 -697
  53. package/dist/lib/terafy.server.js +0 -2062
  54. package/dist/lib/terafy.server.js.map +0 -1
  55. package/dist/plugin.vue2.es2019 (Rhino's conflicted copy 2026-05-10).js +0 -1271
  56. package/dist/plugins/base.d.ts +0 -20
  57. package/dist/plugins/base.js +0 -22
  58. package/dist/plugins/base.js.map +0 -1
  59. package/dist/plugins/firebase.d.ts +0 -62
  60. package/dist/plugins/firebase.js +0 -123
  61. package/dist/plugins/firebase.js.map +0 -1
  62. package/dist/plugins/vite.d.ts +0 -12
  63. package/dist/plugins/vite.js +0 -22
  64. package/dist/plugins/vite.js.map +0 -1
  65. package/dist/plugins/vue2.d.ts +0 -67
  66. package/dist/plugins/vue2.js +0 -104
  67. package/dist/plugins/vue2.js.map +0 -1
  68. package/dist/plugins/vue3.d.ts +0 -63
  69. package/dist/plugins/vue3.js +0 -93
  70. package/dist/plugins/vue3.js.map +0 -1
  71. package/dist/utils/mixin.d.ts +0 -11
  72. package/dist/utils/mixin.js +0 -15
  73. package/dist/utils/mixin.js.map +0 -1
  74. package/dist/utils/pDefer.d.ts +0 -16
  75. package/dist/utils/pDefer.js +0 -19
  76. package/dist/utils/pDefer.js.map +0 -1
  77. package/dist/utils/pathTools.d.ts +0 -70
  78. package/dist/utils/pathTools.js +0 -120
  79. package/dist/utils/pathTools.js.map +0 -1
  80. package/tsconfig.json +0 -30
  81. package/utils/mixin.ts +0 -18
  82. package/utils/pDefer.ts +0 -27
@@ -1,20 +0,0 @@
1
- import type TeraFy from "../lib/terafy.client.js";
2
- /**
3
- * Base TeraFy plugin interface
4
- * This is included as a documentation exanple only
5
- *
6
- * @class TeraFyPlugin
7
- */
8
- export default class TeraFyPlugin {
9
- /**
10
- * Optional function to be included when the main TeraFyClient is initalized
11
- */
12
- init(): any;
13
- /**
14
- * Instance constructor
15
- *
16
- * @param {TeraFy} terafy The TeraFy client this plugin is being initalized against
17
- * @param {Object} [options] Additional options to mutate behaviour
18
- */
19
- constructor(terafy: TeraFy, options: object);
20
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * Base TeraFy plugin interface
3
- * This is included as a documentation exanple only
4
- *
5
- * @class TeraFyPlugin
6
- */
7
- export default class TeraFyPlugin {
8
- /**
9
- * Optional function to be included when the main TeraFyClient is initalized
10
- */
11
- init() { }
12
- /**
13
- * Instance constructor
14
- *
15
- * @param {TeraFy} terafy The TeraFy client this plugin is being initalized against
16
- * @param {Object} [options] Additional options to mutate behaviour
17
- */
18
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
- constructor(terafy, options) {
20
- }
21
- }
22
- //# sourceMappingURL=base.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../../plugins/base.ts"],"names":[],"mappings":"AAEA;;;;;EAKE;AACF,MAAM,CAAC,OAAO,OAAO,YAAY;IAEhC;;MAEE;IACF,IAAI,KAAS,CAAC;IAGd;;;;;MAKE;IACF,6DAA6D;IAC7D,YAAY,MAAc,EAAE,OAAe;IAC3C,CAAC;CACD"}
@@ -1,62 +0,0 @@
1
- import Syncro from '../lib/syncro/syncro.js';
2
- import TeraFyPluginBase from './base.js';
3
- /**
4
- * Plugin which adds Firebase / Firestore support for namespace mounts
5
- *
6
- * @class TeraFyPluginFirebase
7
- */
8
- export default class TeraFyPluginFirebase extends TeraFyPluginBase {
9
- /**
10
- * Lookup object of mounted Syncro objects by path
11
- *
12
- * @type {Object<Syncro>}
13
- */
14
- syncros: Record<string, Syncro>;
15
- namespaces: Record<string, any>;
16
- getCredentials: () => Promise<Record<string, any>>;
17
- requireProject: () => Promise<{
18
- id: string;
19
- }>;
20
- debug: (...args: any[]) => void;
21
- /**
22
- * @interface
23
- * The Syncro#reactive option to use when creating new Syncro instances
24
- * This is expected to be overridden by other plugins
25
- * If falsy the Syncro module will fall back to its internal (POJO only) getReactive() function
26
- *
27
- * @name getReactive
28
- * @type {Function} A reactive function as defined in Syncro
29
- */
30
- getReactive?: () => any;
31
- /**
32
- * Setup Firebase + Firestore + Supabase
33
- * Default credentials (Firebase + Supabase) will be retrieved from `getCredentials()` unless overridden here
34
- *
35
- * @param {Object} options Additional options to mutate behaviour (defaults to the main teraFy settings)
36
- * @param {String} [options.firebaseApiKey] Firebase API key
37
- * @param {String} [options.firebaseAuthDomain] Firebase authorized domain
38
- * @param {String} [options.firebaseProjectId] Firebase project ID
39
- * @param {String} [options.firebaseAppId] Firebase App ID
40
- * @param {String} [options.supabaseUrl] Supabase URL
41
- * @param {String} [options.supabaseKey] Supabase client key
42
- *
43
- * @returns {Promise} A Promise which will resolve when the init process has completed
44
- */
45
- init(options?: any): Promise<void>;
46
- /**
47
- * Mount the given namespace against `namespaces[name]`
48
- *
49
- * @param {'_PROJECT'|String} name The name/Syncro path of the namespace to mount (or '_PROJECT' for the project mount-point)
50
- *
51
- * @returns {Promise} A promise which resolves when the operation has completed
52
- */
53
- _mountNamespace(name: string): Promise<void>;
54
- /**
55
- * Unmount the given namespace from `namespaces[name]`
56
- *
57
- * @param {String} name The name/Syncro path of the namespace to unmount
58
- *
59
- * @returns {Promise} A promise which resolves when the operation has completed
60
- */
61
- _unmountNamespace(name: string): Promise<void | any[]>;
62
- }
@@ -1,123 +0,0 @@
1
- import { initializeApp as Firebase } from 'firebase/app';
2
- import { getFirestore as Firestore } from 'firebase/firestore';
3
- import Supabasey from '@iebh/supabasey';
4
- import Syncro from '../lib/syncro/syncro.js';
5
- import TeraFyPluginBase from './base.js';
6
- /**
7
- * Plugin which adds Firebase / Firestore support for namespace mounts
8
- *
9
- * @class TeraFyPluginFirebase
10
- */
11
- export default class TeraFyPluginFirebase extends TeraFyPluginBase {
12
- /**
13
- * Lookup object of mounted Syncro objects by path
14
- *
15
- * @type {Object<Syncro>}
16
- */
17
- syncros = {};
18
- namespaces = {}; // Declare namespaces property
19
- // Declare properties expected by the class methods or potentially inherited
20
- getCredentials;
21
- requireProject;
22
- // eslint-disable-next-line no-unused-vars
23
- debug;
24
- /**
25
- * @interface
26
- * The Syncro#reactive option to use when creating new Syncro instances
27
- * This is expected to be overridden by other plugins
28
- * If falsy the Syncro module will fall back to its internal (POJO only) getReactive() function
29
- *
30
- * @name getReactive
31
- * @type {Function} A reactive function as defined in Syncro
32
- */
33
- getReactive;
34
- /**
35
- * Setup Firebase + Firestore + Supabase
36
- * Default credentials (Firebase + Supabase) will be retrieved from `getCredentials()` unless overridden here
37
- *
38
- * @param {Object} options Additional options to mutate behaviour (defaults to the main teraFy settings)
39
- * @param {String} [options.firebaseApiKey] Firebase API key
40
- * @param {String} [options.firebaseAuthDomain] Firebase authorized domain
41
- * @param {String} [options.firebaseProjectId] Firebase project ID
42
- * @param {String} [options.firebaseAppId] Firebase App ID
43
- * @param {String} [options.supabaseUrl] Supabase URL
44
- * @param {String} [options.supabaseKey] Supabase client key
45
- *
46
- * @returns {Promise} A Promise which will resolve when the init process has completed
47
- */
48
- async init(options) {
49
- const settings = {
50
- firebaseApiKey: null,
51
- firebaseAuthDomain: null,
52
- firebaseProjectId: null,
53
- firebaseAppId: null,
54
- supabaseUrl: null,
55
- supabaseKey: null,
56
- ...await this.getCredentials(),
57
- ...options,
58
- };
59
- const emptyValues = Object.keys(settings).filter(k => k === null);
60
- if (emptyValues.length > 0)
61
- throw new Error('Firebase plugin requires mandatory options: ' + emptyValues.join(', '));
62
- Syncro.firebase = Firebase({
63
- apiKey: settings.firebaseApiKey, // Add non-null assertion
64
- authDomain: settings.firebaseAuthDomain, // Add non-null assertion
65
- projectId: settings.firebaseProjectId, // Add non-null assertion
66
- appId: settings.firebaseAppId, // Add non-null assertion
67
- });
68
- Syncro.firestore = Firestore(Syncro.firebase); // Use Syncro.firebase
69
- Syncro.supabasey = await Supabasey.init({
70
- env: {
71
- SUPABASE_URL: settings.supabaseUrl,
72
- SUPABASE_KEY: settings.supabaseKey, // Add non-null assertions
73
- },
74
- });
75
- }
76
- /**
77
- * Mount the given namespace against `namespaces[name]`
78
- *
79
- * @param {'_PROJECT'|String} name The name/Syncro path of the namespace to mount (or '_PROJECT' for the project mount-point)
80
- *
81
- * @returns {Promise} A promise which resolves when the operation has completed
82
- */
83
- _mountNamespace(name) {
84
- let syncro; // Add type Syncro
85
- return Promise.resolve()
86
- .then(() => this.requireProject())
87
- .then(project => {
88
- const path = name == '_PROJECT'
89
- ? `projects::${project.id}`
90
- : `project_namespaces::${project.id}::${name}`;
91
- syncro = this.syncros[name] = new Syncro(path, {
92
- debug: (...msg) => this.debug(`SYNCRO://${path}`, ...msg), // Add type any[]
93
- getReactive: this.getReactive, // Try to inherit this instances getReactive prop, otherwise Syncro will fall back to its default
94
- });
95
- // Perform the mount action
96
- return syncro.mount();
97
- })
98
- .then(() => {
99
- this.namespaces[name] = syncro.value;
100
- });
101
- }
102
- /**
103
- * Unmount the given namespace from `namespaces[name]`
104
- *
105
- * @param {String} name The name/Syncro path of the namespace to unmount
106
- *
107
- * @returns {Promise} A promise which resolves when the operation has completed
108
- */
109
- _unmountNamespace(name) {
110
- const syncro = this.syncros[name]; // Create local alias for Syncro before we detach it
111
- // Detach local state
112
- delete this.namespaces[name];
113
- delete this.syncros[name];
114
- // Check if syncro exists before calling destroy
115
- if (syncro) {
116
- return syncro.destroy(); // Trigger Syncro destruction
117
- }
118
- else {
119
- return Promise.resolve(); // Or handle the case where syncro doesn't exist
120
- }
121
- }
122
- }
123
- //# sourceMappingURL=firebase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"firebase.js","sourceRoot":"","sources":["../../plugins/firebase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,IAAI,QAAQ,EAAC,MAAM,cAAc,CAAC;AACvD,OAAO,EAAC,YAAY,IAAI,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAC7D,OAAO,SAAS,MAAM,iBAAiB,CAAC;AACxC,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,OAAO,gBAAgB,MAAM,WAAW,CAAC;AAGzC;;;;EAIE;AACF,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,gBAAgB;IAEjE;;;;MAIE;IACF,OAAO,GAA2B,EAAE,CAAC;IACrC,UAAU,GAAwB,EAAE,CAAC,CAAC,8BAA8B;IAEpE,4EAA4E;IAC5E,cAAc,CAAsC;IACpD,cAAc,CAAiC;IAC/C,0CAA0C;IAC1C,KAAK,CAA4B;IAGjC;;;;;;;;MAQE;IACF,WAAW,CAAa;IAGxB;;;;;;;;;;;;;MAaE;IACF,KAAK,CAAC,IAAI,CAAC,OAAa;QACvB,MAAM,QAAQ,GAAG;YAChB,cAAc,EAAE,IAAI;YACpB,kBAAkB,EAAE,IAAI;YACxB,iBAAiB,EAAE,IAAI;YACvB,aAAa,EAAE,IAAI;YACnB,WAAW,EAAE,IAAI;YACjB,WAAW,EAAE,IAAI;YACjB,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE;YAC9B,GAAG,OAAO;SACV,CAAC;QAEF,MAAM,WAAW,GA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AAO,CAAC,IAAI,CAAC,GAAG,IAAI,MAAM,CAAC,IAAI,EAAE;gBAC9C,KAAK,EAAE,CAAC,GAAG,GAAU,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,EAAE,EAAE,GAAG,GAAG,CAAC,EAAE,iBAAiB;gBACnF,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,iGAAiG;aAChI,CAAC,CAAC;YAEH,2BAA2B;YAC3B,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;QACvB,CAAC,CAAC;aACD,IAAI,CAAC,GAAE,EAAE;YACT,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC;QACtC,CAAC,CAAC,CAAA;IACJ,CAAC;IAGD;;;;;;MAME;IACF,iBAAiB,CAAC,IAAY;QAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,oDAAoD;QAEvF,qBAAqB;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE1B,gDAAgD;QAChD,IAAI,MAAM,EAAE,CAAC;YACZ,OAAO,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,6BAA6B;QACvD,CAAC;aAAM,CAAC;YACP,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,gDAAgD;QAC3E,CAAC;IACF,CAAC;CACD"}
@@ -1,12 +0,0 @@
1
- /**
2
- * Setup a Vite local loopback
3
- *
4
- * @see lib/terafy.proxy.js
5
- *
6
- * @param {Object} [options] Options to pass to the Proxy module
7
- * @returns {VitePlugin}
8
- */
9
- export default function vitePluginTeraFy(options: any): {
10
- name: string;
11
- apply(config: any, { command }: any): false | undefined;
12
- };
@@ -1,22 +0,0 @@
1
- import TeraProxy from '../lib/terafy.proxy.js';
2
- /**
3
- * Setup a Vite local loopback
4
- *
5
- * @see lib/terafy.proxy.js
6
- *
7
- * @param {Object} [options] Options to pass to the Proxy module
8
- * @returns {VitePlugin}
9
- */
10
- export default function vitePluginTeraFy(options) {
11
- // Vite plugin config
12
- return {
13
- name: 'tera-fy',
14
- apply(config, { command }) {
15
- // Don't run when building
16
- if (command == 'build')
17
- return false;
18
- TeraProxy(options);
19
- },
20
- };
21
- }
22
- //# sourceMappingURL=vite.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vite.js","sourceRoot":"","sources":["../../plugins/vite.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAE/C;;;;;;;EAOE;AACF,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,OAAY;IAEpD,qBAAqB;IACrB,OAAO;QACN,IAAI,EAAE,SAAS;QACf,KAAK,CAAC,MAAW,EAAE,EAAE,OAAO,EAAO;YAElC,0BAA0B;YAC1B,IAAI,OAAO,IAAI,OAAO;gBAAE,OAAO,KAAK,CAAC;YAErC,SAAS,CAAC,OAAO,CAAC,CAAC;QACpB,CAAC;KACD,CAAA;AACF,CAAC"}
@@ -1,67 +0,0 @@
1
- import TeraFyPluginFirebase from './firebase.js';
2
- /**
3
- * Vue@2 observables plugin
4
- *
5
- * This function is expected to be included via the `terafy.use(MODULE, OPTIONS)` syntax rather than directly
6
- *
7
- * @class TeraFyPluginVue2
8
- *
9
- * @example Implementation within a Vue@2 project `src/main.js`:
10
- * // Include the main Tera-Fy core
11
- * import TeraFy from '@iebh/tera-fy';
12
- * import TerafyVue from '@iebh/tera-fy/plugins/vue2';
13
- * let terafy = new TeraFy()
14
- * .set('devMode', true) // Uncomment this line if you want TeraFy to be chatty
15
- * .set('siteUrl', 'http://localhost:7334/embed') // Uncomment this line if running TERA locally
16
- * .use(TerafyVue, { // Add the Vue plugin
17
- * vue: window.Vue, // Assumes Vue is available on the window object
18
- * })
19
- *
20
- * // Include after app boot
21
- * const app = new Vue({ ... })
22
- * app.$mount("#app");
23
- * await terafy.init({app});
24
- */
25
- export default class TeraFyPluginVue2 extends TeraFyPluginFirebase {
26
- /**
27
- * Local Vue@2 library to use, set during constructor
28
- *
29
- * @type {Vue}
30
- */
31
- Vue: any;
32
- /**
33
- * The root Vue app instance
34
- * @type {any}
35
- */
36
- app: any;
37
- /**
38
- * The bound, reactive state of the active TERA project
39
- *
40
- * @type {Object | null}
41
- */
42
- project: any;
43
- /**
44
- * Simple incrementor to ensure unique IDs for $watch expressions
45
- *
46
- * @type {Number}
47
- */
48
- reactiveId: number;
49
- /**
50
- * Install into Vue@2
51
- *
52
- * @param {Object} options Additional options to mutate behaviour, see TeraFyPluginFirebase for additional options
53
- * @param {Object} options.app Root level Vue app to bind against
54
- * @param {Vue} options.Vue Vue@2 instance to bind against
55
- * @param {String} [options.globalName='$tera'] Global property to allocate this service as within Vue2
56
- *
57
- * @returns {Promise} A Promise which will resolve when the init process has completed
58
- */
59
- init(options: any): Promise<void>;
60
- /** @override */
61
- getReactive(value: any): {
62
- doc: any;
63
- setState: (state: any) => void;
64
- getState: () => any;
65
- watch: (cb: Function) => void;
66
- };
67
- }
@@ -1,104 +0,0 @@
1
- import { cloneDeep, isEqual } from 'lodash-es';
2
- import TeraFyPluginFirebase from './firebase.js';
3
- /**
4
- * Vue@2 observables plugin
5
- *
6
- * This function is expected to be included via the `terafy.use(MODULE, OPTIONS)` syntax rather than directly
7
- *
8
- * @class TeraFyPluginVue2
9
- *
10
- * @example Implementation within a Vue@2 project `src/main.js`:
11
- * // Include the main Tera-Fy core
12
- * import TeraFy from '@iebh/tera-fy';
13
- * import TerafyVue from '@iebh/tera-fy/plugins/vue2';
14
- * let terafy = new TeraFy()
15
- * .set('devMode', true) // Uncomment this line if you want TeraFy to be chatty
16
- * .set('siteUrl', 'http://localhost:7334/embed') // Uncomment this line if running TERA locally
17
- * .use(TerafyVue, { // Add the Vue plugin
18
- * vue: window.Vue, // Assumes Vue is available on the window object
19
- * })
20
- *
21
- * // Include after app boot
22
- * const app = new Vue({ ... })
23
- * app.$mount("#app");
24
- * await terafy.init({app});
25
- */
26
- export default class TeraFyPluginVue2 extends TeraFyPluginFirebase {
27
- /**
28
- * Local Vue@2 library to use, set during constructor
29
- *
30
- * @type {Vue}
31
- */
32
- Vue;
33
- /**
34
- * The root Vue app instance
35
- * @type {any}
36
- */
37
- app;
38
- /**
39
- * The bound, reactive state of the active TERA project
40
- *
41
- * @type {Object | null}
42
- */
43
- project = null;
44
- /**
45
- * Simple incrementor to ensure unique IDs for $watch expressions
46
- *
47
- * @type {Number}
48
- */
49
- reactiveId = 1001;
50
- /**
51
- * Install into Vue@2
52
- *
53
- * @param {Object} options Additional options to mutate behaviour, see TeraFyPluginFirebase for additional options
54
- * @param {Object} options.app Root level Vue app to bind against
55
- * @param {Vue} options.Vue Vue@2 instance to bind against
56
- * @param {String} [options.globalName='$tera'] Global property to allocate this service as within Vue2
57
- *
58
- * @returns {Promise} A Promise which will resolve when the init process has completed
59
- */
60
- async init(options) {
61
- const settings = {
62
- app: null,
63
- Vue: null,
64
- globalName: '$tera',
65
- ...options,
66
- };
67
- if (!settings.Vue)
68
- throw new Error('Vue instance to use must be specified in init options as `Vue`');
69
- this.Vue = settings.Vue;
70
- if (!settings.app)
71
- throw new Error('Vue Root / App instance to use must be specified in init options as `app`');
72
- this.app = settings.app;
73
- // Make this module available globally
74
- if (settings.globalName)
75
- this.Vue.prototype[settings.globalName] = this;
76
- await super.init(settings); // Initalize parent class Firebase functionality
77
- // @ts-expect-error TODO: Track down why eslint throws error
78
- this.project = await this.mountNamespace('_PROJECT');
79
- }
80
- /** @override */
81
- // @ts-expect-error TODO: Work out why TS doesn't like overrides
82
- getReactive(value) {
83
- const doc = this.Vue.observable(value);
84
- const watcherPath = `_teraFy_${this.reactiveId++}`;
85
- this.app[watcherPath] = doc; // Attach onto app so we can use $watch later on
86
- return {
87
- doc,
88
- setState: (state) => {
89
- // Shallow copy all sub-keys into existing object (keeping the object pointer)
90
- Object.entries(state || {})
91
- .filter(([k]) => !isEqual(doc[k], state[k])) // Only accept changed keys
92
- .forEach(([k, v]) => doc[k] = v);
93
- },
94
- getState: () => {
95
- return cloneDeep(doc);
96
- },
97
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
98
- watch: (cb) => {
99
- this.app.$watch(watcherPath, cb, { deep: true });
100
- },
101
- };
102
- }
103
- }
104
- //# sourceMappingURL=vue2.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vue2.js","sourceRoot":"","sources":["../../plugins/vue2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,oBAAoB,MAAM,eAAe,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;EAsBE;AACF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,oBAAoB;IAEjE;;;;MAIE;IACF,GAAG,CAAM;IAET;;;MAGE;IACF,GAAG,CAAM;IAGT;;;;MAIE;IACF,OAAO,GAAQ,IAAI,CAAC;IAGpB;;;;MAIE;IACF,UAAU,GAAG,IAAI,CAAC;IAGlB;;;;;;;;;MASE;IACF,KAAK,CAAC,IAAI,CAAC,OAAY;QACtB,MAAM,QAAQ,GAAG;YAChB,GAAG,EAAE,IAAI;YACT,GAAG,EAAE,IAAI;YACT,UAAU,EAAE,OAAO;YACnB,GAAG,OAAO;SACV,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;QACrG,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;QAExB,IAAI,CAAC,QAAQ,CAAC,GAAG;YAAE,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;QAChH,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC;QAExB,sCAAsC;QACtC,IAAI,QAAQ,CAAC,UAAU;YACtB,IAAI,CAAC,GAAG,CAAC,SAAS,CAA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0 @@
1
- import TeraFyPluginFirebase from './firebase.js';
2
- import { App, WatchCallback } from 'vue';
3
- /**
4
- * Vue observables plugin
5
- *
6
- * This function is expected to be included via the `terafy.use(MODULE, OPTIONS)` syntax rather than directly
7
- *
8
- * @class TeraFyPluginVue3
9
- *
10
- * @example Implementation within a Vue3 / Vite project within `src/main.js`:
11
- * import TeraFy from '@iebh/tera-fy';
12
- * import TerafyVue from '@iebh/tera-fy/plugins/vue';
13
- * let terafy = new TeraFy()
14
- * .set('devMode', import.meta.env.DEV)
15
- * .set('siteUrl', 'http://localhost:7334/embed') // Uncomment this line if running TERA locally
16
- * .use(TerafyVue) // Add the Vue plugin
17
- *
18
- * terafy.init(); // Initialize everything
19
- *
20
- * app.use(terafy.vuePlugin({
21
- * globalName: '$tera', // Install as vm.$tera into every component
22
- * }));
23
- *
24
- * @example Accessing project state - within a Vue component
25
- * this.$tera.active
26
- */
27
- export default class TeraFyPluginVue3 extends TeraFyPluginFirebase {
28
- /**
29
- * The bound, reactive state of the active TERA project
30
- *
31
- * @type {Object}
32
- */
33
- project: any;
34
- /**
35
- * Init the project including create a reactive mount for the active project
36
- *
37
- * @param {Object} options Additional options to mutate behaviour, see TeraFyPluginFirebase
38
- */
39
- init(options: Record<string, any>): Promise<void>;
40
- /** @override */
41
- getReactive(value: any): {
42
- doc: any;
43
- setState(state: any): void;
44
- getState(): any;
45
- watch(cb: WatchCallback<any, any>): void;
46
- };
47
- /**
48
- * Provide a Vue@3 compatible plugin
49
- *
50
- * @returns {VuePlugin} A Vue@3 plugin spec
51
- */
52
- vuePlugin(): {
53
- /**
54
- * Install into Vue as a generic Vue@3 plugin
55
- *
56
- * @param {VueApp} app The Vue top-level app to install against
57
- *
58
- * @param {Object} [options] Additional options to mutate behaviour
59
- * @param {String} [options.globalName='$tera'] Global property to allocate this service as
60
- */
61
- install(app: App, options: Record<string, any>): void;
62
- };
63
- }
@@ -1,93 +0,0 @@
1
- import { cloneDeep } from 'lodash-es';
2
- import TeraFyPluginFirebase from './firebase.js';
3
- import { reactive as vueReactive, watch as vueWatch } from 'vue';
4
- /**
5
- * Vue observables plugin
6
- *
7
- * This function is expected to be included via the `terafy.use(MODULE, OPTIONS)` syntax rather than directly
8
- *
9
- * @class TeraFyPluginVue3
10
- *
11
- * @example Implementation within a Vue3 / Vite project within `src/main.js`:
12
- * import TeraFy from '@iebh/tera-fy';
13
- * import TerafyVue from '@iebh/tera-fy/plugins/vue';
14
- * let terafy = new TeraFy()
15
- * .set('devMode', import.meta.env.DEV)
16
- * .set('siteUrl', 'http://localhost:7334/embed') // Uncomment this line if running TERA locally
17
- * .use(TerafyVue) // Add the Vue plugin
18
- *
19
- * terafy.init(); // Initialize everything
20
- *
21
- * app.use(terafy.vuePlugin({
22
- * globalName: '$tera', // Install as vm.$tera into every component
23
- * }));
24
- *
25
- * @example Accessing project state - within a Vue component
26
- * this.$tera.active
27
- */
28
- export default class TeraFyPluginVue3 extends TeraFyPluginFirebase {
29
- /**
30
- * The bound, reactive state of the active TERA project
31
- *
32
- * @type {Object}
33
- */
34
- project = null;
35
- /**
36
- * Init the project including create a reactive mount for the active project
37
- *
38
- * @param {Object} options Additional options to mutate behaviour, see TeraFyPluginFirebase
39
- */
40
- async init(options) {
41
- await super.init(options); // Initalize parent class Firebase functionality
42
- // Mount the project namespace
43
- // @ts-expect-error TODO: Track down why eslint throws error
44
- this.project = await this.mountNamespace('_PROJECT');
45
- }
46
- /** @override */
47
- // @ts-expect-error TODO: Work out why TS doesn't like overrides
48
- getReactive(value) {
49
- const doc = vueReactive(value);
50
- return {
51
- doc,
52
- setState(state) {
53
- // Shallow copy all sub-keys into existing object (keeping the object pointer)
54
- Object.entries(state || {})
55
- .forEach(([k, v]) => doc[k] = v);
56
- },
57
- getState() {
58
- return cloneDeep(doc);
59
- },
60
- watch(cb) {
61
- vueWatch(doc, cb, { deep: true });
62
- },
63
- };
64
- }
65
- /**
66
- * Provide a Vue@3 compatible plugin
67
- *
68
- * @returns {VuePlugin} A Vue@3 plugin spec
69
- */
70
- vuePlugin() {
71
- // eslint-disable-next-line @typescript-eslint/no-this-alias
72
- const $tera = this;
73
- return {
74
- /**
75
- * Install into Vue as a generic Vue@3 plugin
76
- *
77
- * @param {VueApp} app The Vue top-level app to install against
78
- *
79
- * @param {Object} [options] Additional options to mutate behaviour
80
- * @param {String} [options.globalName='$tera'] Global property to allocate this service as
81
- */
82
- install(app, options) {
83
- const settings = {
84
- globalName: '$tera',
85
- ...options,
86
- };
87
- // Make this module available globally
88
- app.config.globalProperties[settings.globalName] = $tera;
89
- },
90
- };
91
- }
92
- }
93
- //# sourceMappingURL=vue3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"vue3.js","sourceRoot":"","sources":["../../plugins/vue3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AACpC,OAAO,oBAAoB,MAAM,eAAe,CAAC;AACjD,OAAO,EAAC,QAAQ,IAAI,WAAW,EAAE,KAAK,IAAI,QAAQ,EAAqB,MAAM,KAAK,CAAC;AAEnF;;;;;;;;;;;;;;;;;;;;;;;EAuBE;AACF,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,oBAAoB;IAEjE;;;;MAIE;IACF,OAAO,GAAQ,IAAI,CAAC;IAGpB;;;;MAIE;IACF,KAAK,CAAC,IAAI,CAAC,OAA4B;QACtC,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,gDAAgD;QAE3E,8BAA8B;QAC9B,4DAA4D;QAC5D,IAAI,CAAC,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IACtD,CAAC;IAGD,gBAAgB;IAChB,gEAAgE;IAChE,WAAW,CAAC,KAAU;QACrB,MAAM,GAAG,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;QAC/B,OAAO;YACN,GAAG;YACH,QAAQ,CAAC,KAAU;gBAClB,8EAA8E;gBAC9E,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;qBACzB,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;YAClC,CAAC;YACD,QAAQ;gBACP,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;YACvB,CAAC;YACD,KAAK,CAAC,EAA2B;gBAChC,QAAQ,CAAC,GAAG,EAAE,EAAE,EAAE,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC,CAAC;YACjC,CAAC;SACD,CAAC;IACH,CAAC;IAGD;;;;MAIE;IACF,SAAS;QACR,4DAA4D;QAC5D,MAAM,KAAK,GAAG,IAAI,CAAC;QAEnB,OAAO;YAEN;;;;;;;cAOE;YACF,OAAO,CAAC,GAAQ,EAAE,OAA4B;gBAC7C,MAAM,QAAQ,GAAG;oBAChB,UAAU,EAAE,OAAO;oBACnB,GAAG,OAAO;iBACV,CAAC;gBAEF,sCAAsC;gBACtC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,UAAU,CAAC,GAAG,KAAK,CAAC;YAC1D,CAAC;SAED,CAAC;IACH,CAAC;CACD"}
@@ -1,11 +0,0 @@
1
- /**
2
- * Shallow-copy a object instance and inject new properties into the result
3
- *
4
- * Rather ugly shallow-copy-of instance hack from https://stackoverflow.com/a/44782052/1295040
5
- * Keeps the original object instance and overrides the given object of assignments
6
- *
7
- * @param {Object} instance Original object class instance to mixin
8
- * @param {Object} assignments Additional object properties to mix
9
- * @returns {Object} A shallow copy of the input instance extended with the assignments
10
- */
11
- export default function mixin(instance: any, assignments: any): any;
@@ -1,15 +0,0 @@
1
- /**
2
- * Shallow-copy a object instance and inject new properties into the result
3
- *
4
- * Rather ugly shallow-copy-of instance hack from https://stackoverflow.com/a/44782052/1295040
5
- * Keeps the original object instance and overrides the given object of assignments
6
- *
7
- * @param {Object} instance Original object class instance to mixin
8
- * @param {Object} assignments Additional object properties to mix
9
- * @returns {Object} A shallow copy of the input instance extended with the assignments
10
- */
11
- export default function mixin(instance, assignments) {
12
- const output = Object.assign(Object.create(Object.getPrototypeOf(instance)), instance, assignments);
13
- return output;
14
- }
15
- //# sourceMappingURL=mixin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mixin.js","sourceRoot":"","sources":["../../utils/mixin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;EASE;AACF,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,QAAa,EAAE,WAAgB;IAC5D,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAC3B,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,EAC9C,QAAQ,EACR,WAAW,CACX,CAAC;IACF,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -1,16 +0,0 @@
1
- /**
2
- * Returns a defer object which represents a promise object which can resolve in the future - but without enclosing a function
3
- * The defer object has the keys {promise, resolve(), reject()}
4
- * @returns {Defer} A defered promise
5
- */
6
- interface Defer {
7
- promise: Promise<unknown>;
8
- resolve: (value?: unknown) => void;
9
- reject: (reason?: any) => void;
10
- }
11
- /**
12
- * Default export
13
- * @returns Deferred promise
14
- */
15
- export default function (): Defer;
16
- export {};