@teambit/ipc-events 1.0.579 → 1.0.581

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.
@@ -0,0 +1,39 @@
1
+ <pre>
2
+ +---------------------+
3
+ | User runs |
4
+ | bit install CLI |
5
+ +---------+-----------+
6
+ |
7
+ v
8
+ +---------------------+
9
+ | Install Aspect |
10
+ | (publishIpcEvent) |
11
+ +---------+-----------+
12
+ |
13
+ Writes ".bit/events/onPostInstall"
14
+ |
15
+ v
16
+ +---------------------+
17
+ | File System (FS) |
18
+ | .bit/events/... |
19
+ +---------+-----------+
20
+ | (FS notifies watchers)
21
+ |------------------------------+
22
+ | |
23
+ | |
24
+ v v
25
+ +---------------------+ +---------------------+
26
+ | bit start | | bit watch |
27
+ | (watcher) | | (watcher) |
28
+ | Calls: | | Calls: |
29
+ | ipcEvents | | ipcEvents |
30
+ | .triggerGotEvent | | .triggerGotEvent |
31
+ +---------+-----------+ +---------+-----------+
32
+ | |
33
+ | |
34
+ | +------------------+
35
+ v v
36
+ Registered aspects get notified, for instance:
37
+ - Clearing component issues
38
+ - Performing post-install tasks
39
+ </pre>
@@ -5,19 +5,19 @@ type EventName = 'onPostInstall' | 'onPostObjectsPersist' | 'onNotifySSE';
5
5
  type GotEvent = (eventName: EventName) => Promise<void>;
6
6
  type GotEventSlot = SlotRegistry<GotEvent>;
7
7
  /**
8
- * imagine you have multiple processes running in the background, such as `bit watch`, `bit start`, `bit server`.
9
- * the user is running `bit install` from the cli, how do you let these processes know that the installation is complete?
10
- * `bit start` for instance could use ths info to clear the "component issues" of the components that were missing packages.
8
+ * You might have several processes running in the background (for example, bit watch, bit start, or bit server).
9
+ * When the user runs `bit install`, these processes need to be notified that the installation has completed. One reason
10
+ * is that "bit start" in the workspace could remove component-issues related to missing dependencies.
11
11
  *
12
- * this class provides a mechanism to achieve this by writing the event into the filesystem (`.bit/events/event-name`),
13
- * while each one of the processes has a watcher in the background watch this file. once they got the data from the watcher,
14
- * they can act upon it.
12
+ * To achieve this, an event file is written to the filesystem (e.g., .bit/events/<event-name>), and each background
13
+ * process has a file watcher monitoring these event files. When an event file is created or updated, they can act upon it.
15
14
  *
16
- * in the previous example, when the user is running `bit install`, the install aspect runs `this.publishIpcEvent` to
17
- * write `.bit/events/onPostInstall` to the filesystem. then, the watcher of `bit start` process got a notification
18
- * that this file has changed/added and it runs `triggerGotEvent` to run all aspects registered to its gotEventSlot.
19
- * the installer in turn is registered to this slot and once its function is triggered, it check whether the eventName
20
- * is onPostInstall and then triggers its own OnPostInstall slot.
15
+ * For instance, when the user runs bit install, the install aspect calls publishIpcEvent, which writes
16
+ * `.bit/events/onPostInstall`. The "bit start" process (along with others) detects the file change and invokes
17
+ * `ipcEvents.triggerGotEvent()`. Any aspect subscribed to the gotEventSlot then runs its logic. In this example, the
18
+ * installer aspect is subscribed, so when it recognizes the onPostInstall event, it triggers its own OnPostInstall slot.
19
+ *
20
+ * @see ./example-diagram.md for a visual representation of the above.
21
21
  */
22
22
  export declare class IpcEventsMain {
23
23
  private scope;
@@ -67,19 +67,19 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
67
67
  const EVENTS_DIR = 'events';
68
68
 
69
69
  /**
70
- * imagine you have multiple processes running in the background, such as `bit watch`, `bit start`, `bit server`.
71
- * the user is running `bit install` from the cli, how do you let these processes know that the installation is complete?
72
- * `bit start` for instance could use ths info to clear the "component issues" of the components that were missing packages.
70
+ * You might have several processes running in the background (for example, bit watch, bit start, or bit server).
71
+ * When the user runs `bit install`, these processes need to be notified that the installation has completed. One reason
72
+ * is that "bit start" in the workspace could remove component-issues related to missing dependencies.
73
73
  *
74
- * this class provides a mechanism to achieve this by writing the event into the filesystem (`.bit/events/event-name`),
75
- * while each one of the processes has a watcher in the background watch this file. once they got the data from the watcher,
76
- * they can act upon it.
74
+ * To achieve this, an event file is written to the filesystem (e.g., .bit/events/<event-name>), and each background
75
+ * process has a file watcher monitoring these event files. When an event file is created or updated, they can act upon it.
77
76
  *
78
- * in the previous example, when the user is running `bit install`, the install aspect runs `this.publishIpcEvent` to
79
- * write `.bit/events/onPostInstall` to the filesystem. then, the watcher of `bit start` process got a notification
80
- * that this file has changed/added and it runs `triggerGotEvent` to run all aspects registered to its gotEventSlot.
81
- * the installer in turn is registered to this slot and once its function is triggered, it check whether the eventName
82
- * is onPostInstall and then triggers its own OnPostInstall slot.
77
+ * For instance, when the user runs bit install, the install aspect calls publishIpcEvent, which writes
78
+ * `.bit/events/onPostInstall`. The "bit start" process (along with others) detects the file change and invokes
79
+ * `ipcEvents.triggerGotEvent()`. Any aspect subscribed to the gotEventSlot then runs its logic. In this example, the
80
+ * installer aspect is subscribed, so when it recognizes the onPostInstall event, it triggers its own OnPostInstall slot.
81
+ *
82
+ * @see ./example-diagram.md for a visual representation of the above.
83
83
  */
84
84
  class IpcEventsMain {
85
85
  constructor(scope, gotEventSlot, logger) {
@@ -1 +1 @@
1
- {"version":3,"names":["_scope","data","require","_harmony","_logger","_pMapSeries","_interopRequireDefault","_cli","_path","_fsExtra","_ipcEvents","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","EVENTS_DIR","IpcEventsMain","constructor","scope","gotEventSlot","logger","registerGotEventSlot","fn","register","triggerGotEvent","eventName","info","pMapSeries","values","publishIpcEvent","filename","path","join","eventsDir","content","JSON","stringify","undefined","fs","outputFile","publishIpcOnNotifySseEvent","event","provider","loggerMain","_","createLogger","IpcEventsAspect","id","ipcEventsMain","registerOnPostObjectsPersist","debug","legacyScope","objects","clearObjectsFromCache","setStagedSnaps","exports","Slot","withType","ScopeAspect","LoggerAspect","MainRuntime","addRuntime","_default"],"sources":["ipc-events.main.runtime.ts"],"sourcesContent":["import { ScopeAspect, ScopeMain } from '@teambit/scope';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport pMapSeries from 'p-map-series';\nimport { MainRuntime } from '@teambit/cli';\nimport path from 'path';\nimport fs from 'fs-extra';\nimport { IpcEventsAspect } from './ipc-events.aspect';\n\ntype EventName = 'onPostInstall' | 'onPostObjectsPersist' | 'onNotifySSE';\n\ntype GotEvent = (eventName: EventName) => Promise<void>;\ntype GotEventSlot = SlotRegistry<GotEvent>;\n\nconst EVENTS_DIR = 'events';\n\n/**\n * imagine you have multiple processes running in the background, such as `bit watch`, `bit start`, `bit server`.\n * the user is running `bit install` from the cli, how do you let these processes know that the installation is complete?\n * `bit start` for instance could use ths info to clear the \"component issues\" of the components that were missing packages.\n *\n * this class provides a mechanism to achieve this by writing the event into the filesystem (`.bit/events/event-name`),\n * while each one of the processes has a watcher in the background watch this file. once they got the data from the watcher,\n * they can act upon it.\n *\n * in the previous example, when the user is running `bit install`, the install aspect runs `this.publishIpcEvent` to\n * write `.bit/events/onPostInstall` to the filesystem. then, the watcher of `bit start` process got a notification\n * that this file has changed/added and it runs `triggerGotEvent` to run all aspects registered to its gotEventSlot.\n * the installer in turn is registered to this slot and once its function is triggered, it check whether the eventName\n * is onPostInstall and then triggers its own OnPostInstall slot.\n */\nexport class IpcEventsMain {\n constructor(\n private scope: ScopeMain,\n private gotEventSlot: GotEventSlot,\n private logger: Logger\n ) {}\n\n registerGotEventSlot(fn: GotEvent) {\n this.gotEventSlot.register(fn);\n }\n\n /**\n * this gets called from the watcher only.\n * as soon as the watcher finds out that a new event has been written to the filesystem, it triggers this function\n */\n async triggerGotEvent(eventName: EventName) {\n this.logger.info(`triggering got event ${eventName}`);\n await pMapSeries(this.gotEventSlot.values(), (fn) => fn(eventName));\n }\n\n /**\n * write event data into the filesystem, so then other processes, such as \"bit start\", \"bit watch\", could use the\n * watcher to get the event data.\n */\n async publishIpcEvent(eventName: EventName, data?: Record<string, any>) {\n const filename = path.join(this.eventsDir, eventName);\n const content = data ? JSON.stringify(data, undefined, 2) : '';\n await fs.outputFile(filename, content);\n }\n\n /**\n * This is helpful when all we want is to notify the watchers that a new event has been written to the filesystem.\n * It doesn't require the watchers to register to GotEventSlot. The watchers always listen to this onNotifySSE event,\n * and once they get it, they simply send a server-send-event to the clients.\n */\n async publishIpcOnNotifySseEvent(event: string, data?: Record<string, any>) {\n await this.publishIpcEvent('onNotifySSE', { event, data });\n }\n\n get eventsDir() {\n return path.join(this.scope.path, EVENTS_DIR);\n }\n\n static slots = [Slot.withType<GotEventSlot>()];\n static dependencies = [ScopeAspect, LoggerAspect];\n static runtime = MainRuntime;\n\n static async provider([scope, loggerMain]: [ScopeMain, LoggerMain], _, [gotEventSlot]: [GotEventSlot]) {\n const logger = loggerMain.createLogger(IpcEventsAspect.id);\n const ipcEventsMain = new IpcEventsMain(scope, gotEventSlot, logger);\n\n if (scope) {\n // in case commands like \"bit export\" are running from the cli, long-running processes should clear their cache.\n // otherwise, objects like \"ModelComponent\" are out-of-date and could have the wrong head and the \"state\"/\"local\" data.\n scope.registerOnPostObjectsPersist(async () => {\n await ipcEventsMain.publishIpcEvent('onPostObjectsPersist');\n });\n ipcEventsMain.registerGotEventSlot(async (eventName) => {\n if (eventName === 'onPostObjectsPersist') {\n logger.debug('got an event onPostObjectsPersist, clearing the cache and reloading staged-snaps');\n scope.legacyScope.objects.clearObjectsFromCache();\n scope.legacyScope.setStagedSnaps(); // \"bit export\" deletes the staged-snaps file, so it should be reloaded\n }\n });\n }\n\n return ipcEventsMain;\n }\n}\n\nIpcEventsAspect.addRuntime(IpcEventsMain);\n\nexport default IpcEventsMain;\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG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AACF;AAACO,OAAA,CAAAvC,aAAA,GAAAA,aAAA;AAAAnB,eAAA,CApEYmB,aAAa,WA2CT,CAACwC,eAAI,CAACC,QAAQ,CAAe,CAAC,CAAC;AAAA5D,eAAA,CA3CnCmB,aAAa,kBA4CF,CAAC0C,oBAAW,EAAEC,sBAAY,CAAC;AAAA9D,eAAA,CA5CtCmB,aAAa,aA6CP4C,kBAAW;AAyB9Bd,4BAAe,CAACe,UAAU,CAAC7C,aAAa,CAAC;AAAC,IAAA8C,QAAA,GAAAP,OAAA,CAAA3D,OAAA,GAE3BoB,aAAa","ignoreList":[]}
1
+ {"version":3,"names":["_scope","data","require","_harmony","_logger","_pMapSeries","_interopRequireDefault","_cli","_path","_fsExtra","_ipcEvents","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","EVENTS_DIR","IpcEventsMain","constructor","scope","gotEventSlot","logger","registerGotEventSlot","fn","register","triggerGotEvent","eventName","info","pMapSeries","values","publishIpcEvent","filename","path","join","eventsDir","content","JSON","stringify","undefined","fs","outputFile","publishIpcOnNotifySseEvent","event","provider","loggerMain","_","createLogger","IpcEventsAspect","id","ipcEventsMain","registerOnPostObjectsPersist","debug","legacyScope","objects","clearObjectsFromCache","setStagedSnaps","exports","Slot","withType","ScopeAspect","LoggerAspect","MainRuntime","addRuntime","_default"],"sources":["ipc-events.main.runtime.ts"],"sourcesContent":["import { ScopeAspect, ScopeMain } from '@teambit/scope';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport pMapSeries from 'p-map-series';\nimport { MainRuntime } from '@teambit/cli';\nimport path from 'path';\nimport fs from 'fs-extra';\nimport { IpcEventsAspect } from './ipc-events.aspect';\n\ntype EventName = 'onPostInstall' | 'onPostObjectsPersist' | 'onNotifySSE';\n\ntype GotEvent = (eventName: EventName) => Promise<void>;\ntype GotEventSlot = SlotRegistry<GotEvent>;\n\nconst EVENTS_DIR = 'events';\n\n/**\n * You might have several processes running in the background (for example, bit watch, bit start, or bit server).\n * When the user runs `bit install`, these processes need to be notified that the installation has completed. One reason\n * is that \"bit start\" in the workspace could remove component-issues related to missing dependencies.\n *\n * To achieve this, an event file is written to the filesystem (e.g., .bit/events/<event-name>), and each background\n * process has a file watcher monitoring these event files. When an event file is created or updated, they can act upon it.\n *\n * For instance, when the user runs bit install, the install aspect calls publishIpcEvent, which writes\n * `.bit/events/onPostInstall`. The \"bit start\" process (along with others) detects the file change and invokes\n * `ipcEvents.triggerGotEvent()`. Any aspect subscribed to the gotEventSlot then runs its logic. In this example, the\n * installer aspect is subscribed, so when it recognizes the onPostInstall event, it triggers its own OnPostInstall slot.\n *\n * @see ./example-diagram.md for a visual representation of the above.\n */\nexport class IpcEventsMain {\n constructor(\n private scope: ScopeMain,\n private gotEventSlot: GotEventSlot,\n private logger: Logger\n ) {}\n\n registerGotEventSlot(fn: GotEvent) {\n this.gotEventSlot.register(fn);\n }\n\n /**\n * this gets called from the watcher only.\n * as soon as the watcher finds out that a new event has been written to the filesystem, it triggers this function\n */\n async triggerGotEvent(eventName: EventName) {\n this.logger.info(`triggering got event ${eventName}`);\n await pMapSeries(this.gotEventSlot.values(), (fn) => fn(eventName));\n }\n\n /**\n * write event data into the filesystem, so then other processes, such as \"bit start\", \"bit watch\", could use the\n * watcher to get the event data.\n */\n async publishIpcEvent(eventName: EventName, data?: Record<string, any>) {\n const filename = path.join(this.eventsDir, eventName);\n const content = data ? JSON.stringify(data, undefined, 2) : '';\n await fs.outputFile(filename, content);\n }\n\n /**\n * This is helpful when all we want is to notify the watchers that a new event has been written to the filesystem.\n * It doesn't require the watchers to register to GotEventSlot. The watchers always listen to this onNotifySSE event,\n * and once they get it, they simply send a server-send-event to the clients.\n */\n async publishIpcOnNotifySseEvent(event: string, data?: Record<string, any>) {\n await this.publishIpcEvent('onNotifySSE', { event, data });\n }\n\n get eventsDir() {\n return path.join(this.scope.path, EVENTS_DIR);\n }\n\n static slots = [Slot.withType<GotEventSlot>()];\n static dependencies = [ScopeAspect, LoggerAspect];\n static runtime = MainRuntime;\n\n static async provider([scope, loggerMain]: [ScopeMain, LoggerMain], _, [gotEventSlot]: [GotEventSlot]) {\n const logger = loggerMain.createLogger(IpcEventsAspect.id);\n const ipcEventsMain = new IpcEventsMain(scope, gotEventSlot, logger);\n\n if (scope) {\n // in case commands like \"bit export\" are running from the cli, long-running processes should clear their cache.\n // otherwise, objects like \"ModelComponent\" are out-of-date and could have the wrong head and the \"state\"/\"local\" data.\n scope.registerOnPostObjectsPersist(async () => {\n await ipcEventsMain.publishIpcEvent('onPostObjectsPersist');\n });\n ipcEventsMain.registerGotEventSlot(async (eventName) => {\n if (eventName === 'onPostObjectsPersist') {\n logger.debug('got an event onPostObjectsPersist, clearing the cache and reloading staged-snaps');\n scope.legacyScope.objects.clearObjectsFromCache();\n scope.legacyScope.setStagedSnaps(); // \"bit export\" deletes the staged-snaps file, so it should be reloaded\n }\n });\n }\n\n return ipcEventsMain;\n }\n}\n\nIpcEventsAspect.addRuntime(IpcEventsMain);\n\nexport default IpcEventsMain;\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAK,sBAAA,CAAAJ,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,O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5CtCmB,aAAa,aA6CP4C,kBAAW;AAyB9Bd,4BAAe,CAACe,UAAU,CAAC7C,aAAa,CAAC;AAAC,IAAA8C,QAAA,GAAAP,OAAA,CAAA3D,OAAA,GAE3BoB,aAAa","ignoreList":[]}
@@ -0,0 +1,39 @@
1
+ <pre>
2
+ +---------------------+
3
+ | User runs |
4
+ | bit install CLI |
5
+ +---------+-----------+
6
+ |
7
+ v
8
+ +---------------------+
9
+ | Install Aspect |
10
+ | (publishIpcEvent) |
11
+ +---------+-----------+
12
+ |
13
+ Writes ".bit/events/onPostInstall"
14
+ |
15
+ v
16
+ +---------------------+
17
+ | File System (FS) |
18
+ | .bit/events/... |
19
+ +---------+-----------+
20
+ | (FS notifies watchers)
21
+ |------------------------------+
22
+ | |
23
+ | |
24
+ v v
25
+ +---------------------+ +---------------------+
26
+ | bit start | | bit watch |
27
+ | (watcher) | | (watcher) |
28
+ | Calls: | | Calls: |
29
+ | ipcEvents | | ipcEvents |
30
+ | .triggerGotEvent | | .triggerGotEvent |
31
+ +---------+-----------+ +---------+-----------+
32
+ | |
33
+ | |
34
+ | +------------------+
35
+ v v
36
+ Registered aspects get notified, for instance:
37
+ - Clearing component issues
38
+ - Performing post-install tasks
39
+ </pre>
package/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@teambit/ipc-events",
3
- "version": "1.0.579",
3
+ "version": "1.0.581",
4
4
  "homepage": "https://bit.cloud/teambit/harmony/ipc-events",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.harmony",
8
8
  "name": "ipc-events",
9
- "version": "1.0.579"
9
+ "version": "1.0.581"
10
10
  },
11
11
  "dependencies": {
12
12
  "fs-extra": "10.0.0",
13
13
  "p-map-series": "2.1.0",
14
14
  "@teambit/harmony": "0.4.7",
15
- "@teambit/cli": "0.0.1156",
16
- "@teambit/logger": "0.0.1249",
17
- "@teambit/scope": "1.0.579"
15
+ "@teambit/cli": "0.0.1158",
16
+ "@teambit/logger": "0.0.1251",
17
+ "@teambit/scope": "1.0.581"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/fs-extra": "9.0.7",