@backstage/plugin-signals-react 0.0.1-next.0 → 0.0.1-next.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @backstage/plugin-signals-react
2
2
 
3
+ ## 0.0.1-next.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 447d210: Fix disconnect loop on server start
8
+ - Updated dependencies
9
+ - @backstage/core-plugin-api@1.9.0-next.1
10
+ - @backstage/types@1.1.1
11
+
12
+ ## 0.0.1-next.1
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+ - @backstage/core-plugin-api@1.8.3-next.0
18
+ - @backstage/types@1.1.1
19
+
3
20
  ## 0.0.1-next.0
4
21
 
5
22
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -4,15 +4,18 @@ import { JsonObject } from '@backstage/types';
4
4
  /** @public */
5
5
  declare const signalApiRef: _backstage_core_plugin_api.ApiRef<SignalApi>;
6
6
  /** @public */
7
- type SignalApi = {
8
- subscribe(channel: string, onMessage: (message: JsonObject) => void): {
9
- unsubscribe: () => void;
10
- };
11
- };
7
+ interface SignalSubscriber {
8
+ unsubscribe(): void;
9
+ }
10
+ /** @public */
11
+ interface SignalApi {
12
+ subscribe(channel: string, onMessage: (message: JsonObject) => void): SignalSubscriber;
13
+ }
12
14
 
13
15
  /** @public */
14
16
  declare const useSignal: (channel: string) => {
15
17
  lastSignal: JsonObject | null;
18
+ isSignalsAvailable: boolean;
16
19
  };
17
20
 
18
- export { SignalApi, signalApiRef, useSignal };
21
+ export { SignalApi, SignalSubscriber, signalApiRef, useSignal };
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createApiRef, useApiHolder } from '@backstage/core-plugin-api';
2
- import { useState, useEffect } from 'react';
2
+ import { useState, useEffect, useMemo } from 'react';
3
3
 
4
4
  const signalApiRef = createApiRef({
5
5
  id: "plugin.signal.service"
@@ -23,7 +23,8 @@ const useSignal = (channel) => {
23
23
  }
24
24
  };
25
25
  }, [signals, channel]);
26
- return { lastSignal };
26
+ const isSignalsAvailable = useMemo(() => !signals, [signals]);
27
+ return { lastSignal, isSignalsAvailable };
27
28
  };
28
29
 
29
30
  export { signalApiRef, useSignal };
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/api/SignalApi.ts","../src/hooks/useSignal.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport { JsonObject } from '@backstage/types';\n\n/** @public */\nexport const signalApiRef = createApiRef<SignalApi>({\n id: 'plugin.signal.service',\n});\n\n/** @public */\nexport type SignalApi = {\n subscribe(\n channel: string,\n onMessage: (message: JsonObject) => void,\n ): { unsubscribe: () => void };\n};\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { signalApiRef } from '../api';\nimport { useApiHolder } from '@backstage/core-plugin-api';\nimport { JsonObject } from '@backstage/types';\nimport { useEffect, useState } from 'react';\n\n/** @public */\nexport const useSignal = (channel: string) => {\n const apiHolder = useApiHolder();\n // Use apiHolder instead useApi in case signalApi is not available in the\n // backstage instance this is used\n const signals = apiHolder.get(signalApiRef);\n const [lastSignal, setLastSignal] = useState<JsonObject | null>(null);\n useEffect(() => {\n let unsub: null | (() => void) = null;\n if (signals) {\n const { unsubscribe } = signals.subscribe(channel, (msg: JsonObject) => {\n setLastSignal(msg);\n });\n unsub = unsubscribe;\n }\n return () => {\n if (signals && unsub) {\n unsub();\n }\n };\n }, [signals, channel]);\n\n return { lastSignal };\n};\n"],"names":[],"mappings":";;;AAmBO,MAAM,eAAe,YAAwB,CAAA;AAAA,EAClD,EAAI,EAAA,uBAAA;AACN,CAAC;;ACAY,MAAA,SAAA,GAAY,CAAC,OAAoB,KAAA;AAC5C,EAAA,MAAM,YAAY,YAAa,EAAA,CAAA;AAG/B,EAAM,MAAA,OAAA,GAAU,SAAU,CAAA,GAAA,CAAI,YAAY,CAAA,CAAA;AAC1C,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAA4B,IAAI,CAAA,CAAA;AACpE,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,KAA6B,GAAA,IAAA,CAAA;AACjC,IAAA,IAAI,OAAS,EAAA;AACX,MAAA,MAAM,EAAE,WAAY,EAAA,GAAI,QAAQ,SAAU,CAAA,OAAA,EAAS,CAAC,GAAoB,KAAA;AACtE,QAAA,aAAA,CAAc,GAAG,CAAA,CAAA;AAAA,OAClB,CAAA,CAAA;AACD,MAAQ,KAAA,GAAA,WAAA,CAAA;AAAA,KACV;AACA,IAAA,OAAO,MAAM;AACX,MAAA,IAAI,WAAW,KAAO,EAAA;AACpB,QAAM,KAAA,EAAA,CAAA;AAAA,OACR;AAAA,KACF,CAAA;AAAA,GACC,EAAA,CAAC,OAAS,EAAA,OAAO,CAAC,CAAA,CAAA;AAErB,EAAA,OAAO,EAAE,UAAW,EAAA,CAAA;AACtB;;;;"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/api/SignalApi.ts","../src/hooks/useSignal.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { createApiRef } from '@backstage/core-plugin-api';\nimport { JsonObject } from '@backstage/types';\n\n/** @public */\nexport const signalApiRef = createApiRef<SignalApi>({\n id: 'plugin.signal.service',\n});\n\n/** @public */\nexport interface SignalSubscriber {\n unsubscribe(): void;\n}\n\n/** @public */\nexport interface SignalApi {\n subscribe(\n channel: string,\n onMessage: (message: JsonObject) => void,\n ): SignalSubscriber;\n}\n","/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { signalApiRef } from '../api';\nimport { useApiHolder } from '@backstage/core-plugin-api';\nimport { JsonObject } from '@backstage/types';\nimport { useEffect, useMemo, useState } from 'react';\n\n/** @public */\nexport const useSignal = (channel: string) => {\n const apiHolder = useApiHolder();\n // Use apiHolder instead useApi in case signalApi is not available in the\n // backstage instance this is used\n const signals = apiHolder.get(signalApiRef);\n const [lastSignal, setLastSignal] = useState<JsonObject | null>(null);\n useEffect(() => {\n let unsub: null | (() => void) = null;\n if (signals) {\n const { unsubscribe } = signals.subscribe(channel, (msg: JsonObject) => {\n setLastSignal(msg);\n });\n unsub = unsubscribe;\n }\n return () => {\n if (signals && unsub) {\n unsub();\n }\n };\n }, [signals, channel]);\n\n // Can be used to fallback (for example to long polling) if signals are not available in the system\n const isSignalsAvailable = useMemo(() => !signals, [signals]);\n\n return { lastSignal, isSignalsAvailable };\n};\n"],"names":[],"mappings":";;;AAmBO,MAAM,eAAe,YAAwB,CAAA;AAAA,EAClD,EAAI,EAAA,uBAAA;AACN,CAAC;;ACAY,MAAA,SAAA,GAAY,CAAC,OAAoB,KAAA;AAC5C,EAAA,MAAM,YAAY,YAAa,EAAA,CAAA;AAG/B,EAAM,MAAA,OAAA,GAAU,SAAU,CAAA,GAAA,CAAI,YAAY,CAAA,CAAA;AAC1C,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAA4B,IAAI,CAAA,CAAA;AACpE,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,KAA6B,GAAA,IAAA,CAAA;AACjC,IAAA,IAAI,OAAS,EAAA;AACX,MAAA,MAAM,EAAE,WAAY,EAAA,GAAI,QAAQ,SAAU,CAAA,OAAA,EAAS,CAAC,GAAoB,KAAA;AACtE,QAAA,aAAA,CAAc,GAAG,CAAA,CAAA;AAAA,OAClB,CAAA,CAAA;AACD,MAAQ,KAAA,GAAA,WAAA,CAAA;AAAA,KACV;AACA,IAAA,OAAO,MAAM;AACX,MAAA,IAAI,WAAW,KAAO,EAAA;AACpB,QAAM,KAAA,EAAA,CAAA;AAAA,OACR;AAAA,KACF,CAAA;AAAA,GACC,EAAA,CAAC,OAAS,EAAA,OAAO,CAAC,CAAA,CAAA;AAGrB,EAAA,MAAM,qBAAqB,OAAQ,CAAA,MAAM,CAAC,OAAS,EAAA,CAAC,OAAO,CAAC,CAAA,CAAA;AAE5D,EAAO,OAAA,EAAE,YAAY,kBAAmB,EAAA,CAAA;AAC1C;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@backstage/plugin-signals-react",
3
3
  "description": "Web library for the signals plugin",
4
- "version": "0.0.1-next.0",
4
+ "version": "0.0.1-next.2",
5
5
  "main": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -24,7 +24,7 @@
24
24
  "postpack": "backstage-cli package postpack"
25
25
  },
26
26
  "dependencies": {
27
- "@backstage/core-plugin-api": "^1.8.2",
27
+ "@backstage/core-plugin-api": "^1.9.0-next.1",
28
28
  "@backstage/types": "^1.1.1",
29
29
  "@material-ui/core": "^4.12.4"
30
30
  },
@@ -32,8 +32,8 @@
32
32
  "react": "^16.13.1 || ^17.0.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@backstage/cli": "^0.25.2-next.0",
36
- "@backstage/test-utils": "^1.5.0-next.0",
35
+ "@backstage/cli": "^0.25.2-next.2",
36
+ "@backstage/test-utils": "^1.5.0-next.2",
37
37
  "@testing-library/jest-dom": "^6.0.0",
38
38
  "@testing-library/react": "^14.0.0"
39
39
  },