react-native-maplibre-gl-js 1.2.1 → 1.3.1
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/lib/module/react-native/components/Map/{Map.test.js → Map.test.unit.js} +1 -1
- package/lib/module/react-native/components/Map/Map.test.unit.js.map +1 -0
- package/lib/module/react-native/components/MapProvider/{MapProvider.test.js → MapProvider.test.unit.js} +3 -1
- package/lib/module/react-native/components/MapProvider/MapProvider.test.unit.js.map +1 -0
- package/lib/module/react-native/components/Marker/{Marker.test.js → Marker.test.unit.js} +2 -1
- package/lib/module/react-native/components/Marker/Marker.test.unit.js.map +1 -0
- package/lib/module/react-native/components/Popup/{Popup.test.js → Popup.test.unit.js} +1 -1
- package/lib/module/react-native/components/Popup/Popup.test.unit.js.map +1 -0
- package/lib/module/react-native/components-factory/createWebObjectAsComponent.js +5 -7
- package/lib/module/react-native/components-factory/createWebObjectAsComponent.js.map +1 -1
- package/lib/module/react-native/components-factory/createWebObjectAsComponent.test.integration.js +85 -0
- package/lib/module/react-native/components-factory/createWebObjectAsComponent.test.integration.js.map +1 -0
- package/lib/module/react-native/components-factory/createWebObjectAsComponent.test.unit.js +30 -0
- package/lib/module/react-native/components-factory/createWebObjectAsComponent.test.unit.js.map +1 -0
- package/lib/module/react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.js +79 -0
- package/lib/module/react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.js.map +1 -0
- package/lib/module/react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.mock.js +10 -0
- package/lib/module/react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.mock.js.map +1 -0
- package/lib/module/react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.types.js +2 -0
- package/lib/module/react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.types.js.map +1 -0
- package/lib/module/react-native/components-factory/hooks/useWebObjectMountUnmountWithProps.js +57 -0
- package/lib/module/react-native/components-factory/hooks/useWebObjectMountUnmountWithProps.js.map +1 -0
- package/lib/module/react-native/components-factory/hooks/useWebObjectMountUnmountWithProps.mock.js +5 -0
- package/lib/module/react-native/components-factory/hooks/useWebObjectMountUnmountWithProps.mock.js.map +1 -0
- package/lib/module/react-native/hooks/atoms/useMapAtoms.mock.js +5 -0
- package/lib/module/react-native/hooks/atoms/useMapAtoms.mock.js.map +1 -1
- package/lib/module/react-native/hooks/atoms/useMapAtoms.utils.js +17 -3
- package/lib/module/react-native/hooks/atoms/useMapAtoms.utils.js.map +1 -1
- package/lib/module/web/generated/webview_static_html.js +5 -2
- package/lib/module/web/generated/webview_static_html.js.map +1 -1
- package/lib/module/web/maplibre-gl-js/MapController.js +7 -0
- package/lib/module/web/maplibre-gl-js/MapController.js.map +1 -1
- package/lib/typescript/src/react-native/components/Map/Map.test.unit.d.ts +2 -0
- package/lib/typescript/src/react-native/components/Map/Map.test.unit.d.ts.map +1 -0
- package/lib/typescript/src/react-native/components/MapProvider/MapProvider.test.unit.d.ts +2 -0
- package/lib/typescript/src/react-native/components/MapProvider/MapProvider.test.unit.d.ts.map +1 -0
- package/lib/typescript/src/react-native/components/Marker/Marker.test.unit.d.ts +2 -0
- package/lib/typescript/src/react-native/components/Marker/Marker.test.unit.d.ts.map +1 -0
- package/lib/typescript/src/react-native/components/Popup/Popup.test.unit.d.ts +2 -0
- package/lib/typescript/src/react-native/components/Popup/Popup.test.unit.d.ts.map +1 -0
- package/lib/typescript/src/react-native/components-factory/createWebObjectAsComponent.d.ts.map +1 -1
- package/lib/typescript/src/react-native/components-factory/createWebObjectAsComponent.test.integration.d.ts +2 -0
- package/lib/typescript/src/react-native/components-factory/createWebObjectAsComponent.test.integration.d.ts.map +1 -0
- package/lib/typescript/src/react-native/components-factory/createWebObjectAsComponent.test.unit.d.ts +2 -0
- package/lib/typescript/src/react-native/components-factory/createWebObjectAsComponent.test.unit.d.ts.map +1 -0
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.d.ts +19 -0
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.d.ts.map +1 -0
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.mock.d.ts +9 -0
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.mock.d.ts.map +1 -0
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.types.d.ts +8 -0
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.types.d.ts.map +1 -0
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectMountUnmountWithProps.d.ts +14 -0
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectMountUnmountWithProps.d.ts.map +1 -0
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectMountUnmountWithProps.mock.d.ts +3 -0
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectMountUnmountWithProps.mock.d.ts.map +1 -0
- package/lib/typescript/src/react-native/hooks/atoms/useMapAtoms.mock.d.ts +2 -0
- package/lib/typescript/src/react-native/hooks/atoms/useMapAtoms.mock.d.ts.map +1 -1
- package/lib/typescript/src/react-native/hooks/atoms/useMapAtoms.utils.d.ts +2 -1
- package/lib/typescript/src/react-native/hooks/atoms/useMapAtoms.utils.d.ts.map +1 -1
- package/lib/typescript/src/web/generated/webview_static_html.d.ts +1 -1
- package/lib/typescript/src/web/generated/webview_static_html.d.ts.map +1 -1
- package/lib/typescript/src/web/maplibre-gl-js/MapController.d.ts.map +1 -1
- package/package.json +1 -1
- package/lib/module/react-native/components/Map/Map.test.js.map +0 -1
- package/lib/module/react-native/components/MapProvider/MapProvider.test.js.map +0 -1
- package/lib/module/react-native/components/Marker/Marker.test.js.map +0 -1
- package/lib/module/react-native/components/Popup/Popup.test.js.map +0 -1
- package/lib/module/react-native/components-factory/createWebObjectAsComponent.test.js +0 -28
- package/lib/module/react-native/components-factory/createWebObjectAsComponent.test.js.map +0 -1
- package/lib/module/react-native/components-factory/hooks/useWebObjectMountOnLaunch.js +0 -69
- package/lib/module/react-native/components-factory/hooks/useWebObjectMountOnLaunch.js.map +0 -1
- package/lib/module/react-native/components-factory/hooks/useWebObjectMountOnLaunch.mock.js +0 -5
- package/lib/module/react-native/components-factory/hooks/useWebObjectMountOnLaunch.mock.js.map +0 -1
- package/lib/module/react-native/components-factory/hooks/useWebObjectPropertiesUpdater.js +0 -14
- package/lib/module/react-native/components-factory/hooks/useWebObjectPropertiesUpdater.js.map +0 -1
- package/lib/module/react-native/components-factory/hooks/useWebObjectPropertiesUpdater.mock.js +0 -5
- package/lib/module/react-native/components-factory/hooks/useWebObjectPropertiesUpdater.mock.js.map +0 -1
- package/lib/typescript/src/react-native/components/Map/Map.test.d.ts +0 -2
- package/lib/typescript/src/react-native/components/Map/Map.test.d.ts.map +0 -1
- package/lib/typescript/src/react-native/components/MapProvider/MapProvider.test.d.ts +0 -2
- package/lib/typescript/src/react-native/components/MapProvider/MapProvider.test.d.ts.map +0 -1
- package/lib/typescript/src/react-native/components/Marker/Marker.test.d.ts +0 -2
- package/lib/typescript/src/react-native/components/Marker/Marker.test.d.ts.map +0 -1
- package/lib/typescript/src/react-native/components/Popup/Popup.test.d.ts +0 -2
- package/lib/typescript/src/react-native/components/Popup/Popup.test.d.ts.map +0 -1
- package/lib/typescript/src/react-native/components-factory/createWebObjectAsComponent.test.d.ts +0 -2
- package/lib/typescript/src/react-native/components-factory/createWebObjectAsComponent.test.d.ts.map +0 -1
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectMountOnLaunch.d.ts +0 -12
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectMountOnLaunch.d.ts.map +0 -1
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectMountOnLaunch.mock.d.ts +0 -3
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectMountOnLaunch.mock.d.ts.map +0 -1
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectPropertiesUpdater.d.ts +0 -4
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectPropertiesUpdater.d.ts.map +0 -1
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectPropertiesUpdater.mock.d.ts +0 -3
- package/lib/typescript/src/react-native/components-factory/hooks/useWebObjectPropertiesUpdater.mock.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["render","Map","jsx","_jsx","describe","beforeEach","jest","clearAllMocks","test"],"sourceRoot":"../../../../../src","sources":["react-native/components/Map/Map.test.unit.tsx"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,+BAA+B;AACtD,OAAOC,GAAG,MAAM,UAAO;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAEvBC,QAAQ,CAAC,KAAK,EAAE,MAAM;EACpBC,UAAU,CAAC,MAAM;IACfC,IAAI,CAACC,aAAa,CAAC,CAAC;EACtB,CAAC,CAAC;EAEFH,QAAQ,CAAC,iCAAiC,EAAE,MAAM;IAChDC,UAAU,CAAC,MAAM;MACfL,MAAM,cAACG,IAAA,CAACF,GAAG,IAAE,CAAC,CAAC;IACjB,CAAC,CAAC;IAEFG,QAAQ,CAAC,cAAc,EAAE,MAAM;MAC7BI,IAAI,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -6,12 +6,14 @@ import MapProvider from "./MapProvider.js";
|
|
|
6
6
|
import { useWebMessageHandler } from "./MapProvider.hooks.js";
|
|
7
7
|
import RNLogger from "../../logger/rn-logger.js";
|
|
8
8
|
import { getWebObjectListenersMock, resolveWebObjectPendingMethodResponseMock, setIsWebWorldReadyMock } from "../../hooks/atoms/useMapAtoms.mock.js";
|
|
9
|
+
import { jest } from '@jest/globals';
|
|
9
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
11
|
const createEvent = data => ({
|
|
11
12
|
nativeEvent: {
|
|
12
13
|
data: typeof data === 'string' ? data : JSON.stringify(data)
|
|
13
14
|
}
|
|
14
15
|
});
|
|
16
|
+
jest.mock('./../../hooks/atoms/useMapAtoms', () => require('./../../hooks/atoms/useMapAtoms.mock'));
|
|
15
17
|
describe('MapProvider', () => {
|
|
16
18
|
beforeEach(() => {
|
|
17
19
|
jest.clearAllMocks();
|
|
@@ -141,4 +143,4 @@ describe('useWebMessageHandler', () => {
|
|
|
141
143
|
});
|
|
142
144
|
});
|
|
143
145
|
});
|
|
144
|
-
//# sourceMappingURL=MapProvider.test.js.map
|
|
146
|
+
//# sourceMappingURL=MapProvider.test.unit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["View","Text","render","renderHook","screen","MapProvider","useWebMessageHandler","RNLogger","getWebObjectListenersMock","resolveWebObjectPendingMethodResponseMock","setIsWebWorldReadyMock","jest","jsx","_jsx","createEvent","data","nativeEvent","JSON","stringify","mock","require","describe","beforeEach","clearAllMocks","children","testID","test","child","getByTestId","expect","toBeTruthy","webView","handler","result","current","toBe","type","not","toThrow","payload","level","args","info","toHaveBeenCalledWith","rnListener","eventPayload","fn","x","Math","random","mockReturnValue","click","objectId","eventName","event","requestId","ok"],"sourceRoot":"../../../../../src","sources":["react-native/components/MapProvider/MapProvider.test.unit.tsx"],"mappings":";;AAAA,SAASA,IAAI,EAAEC,IAAI,QAAQ,cAAc;AACzC,SAASC,MAAM,EAAEC,UAAU,EAAEC,MAAM,QAAQ,+BAA+B;AAC1E,OAAOC,WAAW,MAAM,kBAAe;AACvC,SAASC,oBAAoB,QAAQ,wBAAqB;AAC1D,OAAOC,QAAQ,MAAM,2BAAwB;AAC7C,SACEC,yBAAyB,EACzBC,yCAAyC,EACzCC,sBAAsB,QACjB,uCAAoC;AAC3C,SAASC,IAAI,QAAQ,eAAe;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAEpC,MAAMC,WAAW,GAAIC,IAAa,KAC/B;EACCC,WAAW,EAAE;IAC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cAAEuB,EAAE,EAAE;YAAK;UACrB;QACF,CAAC,CACH,CAAC;MACH,CAAC,CAAC;MAEF9B,IAAI,CAAC,8CAA8C,EAAE,MAAM;QACzDG,MAAM,CAACpB,yCAAyC,CAAC,CAACkC,oBAAoB,CAAC;UACrEY,SAAS,EAAE,SAAS;UACpBtB,MAAM,EAAE;YAAEuB,EAAE,EAAE;UAAK;QACrB,CAAC,CAAC;MACJ,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { render } from '@testing-library/react-native';
|
|
4
4
|
import Marker from "./Marker.js";
|
|
5
|
+
import { jest } from '@jest/globals';
|
|
5
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
7
|
describe('Marker', () => {
|
|
7
8
|
beforeEach(() => {
|
|
@@ -16,4 +17,4 @@ describe('Marker', () => {
|
|
|
16
17
|
});
|
|
17
18
|
});
|
|
18
19
|
});
|
|
19
|
-
//# sourceMappingURL=Marker.test.js.map
|
|
20
|
+
//# sourceMappingURL=Marker.test.unit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["render","Marker","jest","jsx","_jsx","describe","beforeEach","clearAllMocks","test"],"sourceRoot":"../../../../../src","sources":["react-native/components/Marker/Marker.test.unit.tsx"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,+BAA+B;AACtD,OAAOC,MAAM,MAAM,aAAU;AAC7B,SAASC,IAAI,QAAQ,eAAe;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAEpCC,QAAQ,CAAC,QAAQ,EAAE,MAAM;EACvBC,UAAU,CAAC,MAAM;IACfJ,IAAI,CAACK,aAAa,CAAC,CAAC;EACtB,CAAC,CAAC;EAEFF,QAAQ,CAAC,iCAAiC,EAAE,MAAM;IAChDC,UAAU,CAAC,MAAM;MACfN,MAAM,cAACI,IAAA,CAACH,MAAM,IAAE,CAAC,CAAC;IACpB,CAAC,CAAC;IAEFI,QAAQ,CAAC,cAAc,EAAE,MAAM;MAC7BG,IAAI,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["render","Popup","jsx","_jsx","describe","beforeEach","jest","clearAllMocks","test"],"sourceRoot":"../../../../../src","sources":["react-native/components/Popup/Popup.test.unit.tsx"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,+BAA+B;AACtD,OAAOC,KAAK,MAAM,YAAS;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAE3BC,QAAQ,CAAC,OAAO,EAAE,MAAM;EACtBC,UAAU,CAAC,MAAM;IACfC,IAAI,CAACC,aAAa,CAAC,CAAC;EACtB,CAAC,CAAC;EAEFH,QAAQ,CAAC,iCAAiC,EAAE,MAAM;IAChDC,UAAU,CAAC,MAAM;MACfL,MAAM,cAACG,IAAA,CAACF,KAAK,IAAE,CAAC,CAAC;IACnB,CAAC,CAAC;IAEFG,QAAQ,CAAC,cAAc,EAAE,MAAM;MAC7BI,IAAI,CAAC,wBAAwB,EAAE,MAAM,CAAC,CAAC,CAAC;IAC1C,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { forwardRef, useId } from 'react';
|
|
4
|
-
import useWebObjectMountOnLaunch from "./hooks/useWebObjectMountOnLaunch.js";
|
|
5
4
|
import useWebObjectMethodsProxy from "./hooks/useWebObjectMethodsProxy.js";
|
|
6
|
-
import
|
|
5
|
+
import useWebObjectMountUnmountWithProps from "./hooks/useWebObjectMountUnmountWithProps.js";
|
|
7
6
|
const createWebObjectAsComponent = objectType => {
|
|
8
7
|
return /*#__PURE__*/forwardRef((props, ref) => {
|
|
9
8
|
// UID of the web object.
|
|
10
9
|
const id = useId();
|
|
11
|
-
//
|
|
12
|
-
useWebObjectMountOnLaunch(props, id, objectType);
|
|
13
|
-
// Forward a method call on the RN object to the web object.
|
|
10
|
+
// Forward a method call on the RN object ref to the web object.
|
|
14
11
|
useWebObjectMethodsProxy(ref, id);
|
|
15
|
-
//
|
|
16
|
-
|
|
12
|
+
// Mount the web object on launch and update the web object properties when
|
|
13
|
+
// they changed in the component body.
|
|
14
|
+
useWebObjectMountUnmountWithProps(props, id, objectType);
|
|
17
15
|
return null;
|
|
18
16
|
});
|
|
19
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["forwardRef","useId","
|
|
1
|
+
{"version":3,"names":["forwardRef","useId","useWebObjectMethodsProxy","useWebObjectMountUnmountWithProps","createWebObjectAsComponent","objectType","props","ref","id"],"sourceRoot":"../../../../src","sources":["react-native/components-factory/createWebObjectAsComponent.ts"],"mappings":";;AAAA,SAASA,UAAU,EAAEC,KAAK,QAAQ,OAAO;AAOzC,OAAOC,wBAAwB,MAAM,qCAAkC;AACvE,OAAOC,iCAAiC,MAAM,8CAA2C;AAEzF,MAAMC,0BAA0B,GAI9BC,UAAyB,IACU;EACnC,oBAAOL,UAAU,CAAa,CAACM,KAAK,EAAEC,GAAG,KAAK;IAC5C;IACA,MAAMC,EAAE,GAAGP,KAAK,CAAC,CAAC;IAClB;IACAC,wBAAwB,CAAMK,GAAG,EAAEC,EAAE,CAAC;IACtC;IACA;IACAL,iCAAiC,CAAQG,KAAK,EAAEE,EAAE,EAAEH,UAAU,CAAC;IAE/D,OAAO,IAAI;EACb,CAAC,CAAC;AACJ,CAAC;AAED,eAAeD,0BAA0B","ignoreList":[]}
|
package/lib/module/react-native/components-factory/createWebObjectAsComponent.test.integration.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { render, screen } from '@testing-library/react-native';
|
|
4
|
+
import createWebObjectAsComponent from "./createWebObjectAsComponent.js";
|
|
5
|
+
import { jest } from '@jest/globals';
|
|
6
|
+
import { mount, unmount } from "./hooks/useWebObjectMountUnmountCallbacks.mock.js";
|
|
7
|
+
import { setIsWebWorldReady } from "../hooks/atoms/useMapAtoms.mock.js";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
jest.mock('./../hooks/atoms/useMapAtoms', () => require('./../hooks/atoms/useMapAtoms.mock'));
|
|
10
|
+
jest.mock('./hooks/useWebObjectMountUnmountCallbacks', () => require('./hooks/useWebObjectMountUnmountCallbacks.mock'));
|
|
11
|
+
describe('createWebObjectAsComponent', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
jest.clearAllMocks();
|
|
14
|
+
});
|
|
15
|
+
describe('Given the web object is rendered and the web world is ready', () => {
|
|
16
|
+
let Component;
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
Component = createWebObjectAsComponent('map');
|
|
19
|
+
setIsWebWorldReady(true);
|
|
20
|
+
render(/*#__PURE__*/_jsx(Component, {}));
|
|
21
|
+
});
|
|
22
|
+
describe('When nothing', () => {
|
|
23
|
+
beforeEach(() => {});
|
|
24
|
+
test('Then everything have been mounted', () => {
|
|
25
|
+
expect(mount).toHaveBeenCalledTimes(1);
|
|
26
|
+
expect(mount).toHaveBeenCalledWith({
|
|
27
|
+
options: true,
|
|
28
|
+
listeners: true
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe('When rerendered with no change', () => {
|
|
33
|
+
beforeEach(() => {
|
|
34
|
+
screen.rerender(/*#__PURE__*/_jsx(Component, {}));
|
|
35
|
+
});
|
|
36
|
+
test('Then nothing is re-mounted', () => {
|
|
37
|
+
expect(unmount).toHaveBeenCalledTimes(1);
|
|
38
|
+
expect(mount).toHaveBeenCalledTimes(1);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe('When rerendered with new listeners', () => {
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
screen.rerender(/*#__PURE__*/_jsx(Component, {
|
|
44
|
+
listeners: {
|
|
45
|
+
new: () => {}
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
48
|
+
});
|
|
49
|
+
test('Then only the listeners have been re-mounted', () => {
|
|
50
|
+
expect(unmount).toHaveBeenCalledTimes(2);
|
|
51
|
+
expect(mount).toHaveBeenCalledTimes(2);
|
|
52
|
+
expect(unmount).toHaveBeenNthCalledWith(2, {
|
|
53
|
+
options: false,
|
|
54
|
+
listeners: true
|
|
55
|
+
});
|
|
56
|
+
expect(mount).toHaveBeenNthCalledWith(2, {
|
|
57
|
+
options: false,
|
|
58
|
+
listeners: true
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe('When rerendered with new options', () => {
|
|
63
|
+
beforeEach(() => {
|
|
64
|
+
screen.rerender(/*#__PURE__*/_jsx(Component, {
|
|
65
|
+
options: {
|
|
66
|
+
new: true
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
});
|
|
70
|
+
test('Then everything have been re-mounted', () => {
|
|
71
|
+
expect(unmount).toHaveBeenCalledTimes(2);
|
|
72
|
+
expect(mount).toHaveBeenCalledTimes(2);
|
|
73
|
+
expect(unmount).toHaveBeenNthCalledWith(2, {
|
|
74
|
+
options: true,
|
|
75
|
+
listeners: true
|
|
76
|
+
});
|
|
77
|
+
expect(mount).toHaveBeenNthCalledWith(2, {
|
|
78
|
+
options: true,
|
|
79
|
+
listeners: true
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
//# sourceMappingURL=createWebObjectAsComponent.test.integration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["render","screen","createWebObjectAsComponent","jest","mount","unmount","setIsWebWorldReady","jsx","_jsx","mock","require","describe","beforeEach","clearAllMocks","Component","test","expect","toHaveBeenCalledTimes","toHaveBeenCalledWith","options","listeners","rerender","new","toHaveBeenNthCalledWith"],"sourceRoot":"../../../../src","sources":["react-native/components-factory/createWebObjectAsComponent.test.integration.tsx"],"mappings":";;AAAA,SAASA,MAAM,EAAEC,MAAM,QAAQ,+BAA+B;AAC9D,OAAOC,0BAA0B,MAAM,iCAA8B;AACrE,SAASC,IAAI,QAAQ,eAAe;AAMpC,SAASC,KAAK,EAAEC,OAAO,QAAQ,mDAAgD;AAC/E,SAASC,kBAAkB,QAAQ,oCAAiC;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAEpEL,IAAI,CAACM,IAAI,CAAC,8BAA8B,EAAE,MACxCC,OAAO,CAAC,mCAAmC,CAC7C,CAAC;AAEDP,IAAI,CAACM,IAAI,CAAC,2CAA2C,EAAE,MACrDC,OAAO,CAAC,gDAAgD,CAC1D,CAAC;AAEDC,QAAQ,CAAC,4BAA4B,EAAE,MAAM;EAC3CC,UAAU,CAAC,MAAM;IACfT,IAAI,CAACU,aAAa,CAAC,CAAC;EACtB,CAAC,CAAC;EAEFF,QAAQ,CAAC,6DAA6D,EAAE,MAAM;IAC5E,IAAIG,SAGH;IAEDF,UAAU,CAAC,MAAM;MACfE,SAAS,GAAGZ,0BAA0B,CAAC,KAAK,CAAC;MAC7CI,kBAAkB,CAAC,IAAI,CAAC;MACxBN,MAAM,cAACQ,IAAA,CAACM,SAAS,IAAE,CAAC,CAAC;IACvB,CAAC,CAAC;IAEFH,QAAQ,CAAC,cAAc,EAAE,MAAM;MAC7BC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;MAEpBG,IAAI,CAAC,mCAAmC,EAAE,MAAM;QAC9CC,MAAM,CAACZ,KAAK,CAAC,CAACa,qBAAqB,CAAC,CAAC,CAAC;QACtCD,MAAM,CAACZ,KAAK,CAAC,CAACc,oBAAoB,CAAC;UAAEC,OAAO,EAAE,IAAI;UAAEC,SAAS,EAAE;QAAK,CAAC,CAAC;MACxE,CAAC,CAAC;IACJ,CAAC,CAAC;IAEFT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AC;MAEFP,IAAI,CAAC,sCAAsC,EAAE,MAAM;QACjDC,MAAM,CAACX,OAAO,CAAC,CAACY,qBAAqB,CAAC,CAAC,CAAC;QACxCD,MAAM,CAACZ,KAAK,CAAC,CAACa,qBAAqB,CAAC,CAAC,CAAC;QACtCD,MAAM,CAACX,OAAO,CAAC,CAACkB,uBAAuB,CAAC,CAAC,EAAE;UACzCJ,OAAO,EAAE,IAAI;UACbC,SAAS,EAAE;QACb,CAAC,CAAC;QACFJ,MAAM,CAACZ,KAAK,CAAC,CAACmB,uBAAuB,CAAC,CAAC,EAAE;UACvCJ,OAAO,EAAE,IAAI;UACbC,SAAS,EAAE;QACb,CAAC,CAAC;MACJ,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { render } from '@testing-library/react-native';
|
|
4
|
+
import createWebObjectAsComponent from "./createWebObjectAsComponent.js";
|
|
5
|
+
import useWebObjectMethodsProxy from "./hooks/useWebObjectMethodsProxy.js";
|
|
6
|
+
import useWebObjectMountUnmountWithProps from "./hooks/useWebObjectMountUnmountWithProps.js";
|
|
7
|
+
import { jest } from '@jest/globals';
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
jest.mock('./hooks/useWebObjectMethodsProxy', () => require('./hooks/useWebObjectMethodsProxy.mock'));
|
|
10
|
+
jest.mock('./hooks/useWebObjectMountUnmountWithProps', () => require('./hooks/useWebObjectMountUnmountWithProps.mock'));
|
|
11
|
+
describe('createWebObjectAsComponent', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
jest.clearAllMocks();
|
|
14
|
+
});
|
|
15
|
+
describe('Given the web object is rendered', () => {
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
const Component = createWebObjectAsComponent('map');
|
|
18
|
+
render(/*#__PURE__*/_jsx(Component, {}));
|
|
19
|
+
});
|
|
20
|
+
describe('When nothing', () => {
|
|
21
|
+
test('Then it has set the methods proxy', () => {
|
|
22
|
+
expect(useWebObjectMethodsProxy).toHaveBeenCalledTimes(1);
|
|
23
|
+
});
|
|
24
|
+
test('Then it has been mount on launch', () => {
|
|
25
|
+
expect(useWebObjectMountUnmountWithProps).toHaveBeenCalledTimes(1);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=createWebObjectAsComponent.test.unit.js.map
|
package/lib/module/react-native/components-factory/createWebObjectAsComponent.test.unit.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["render","createWebObjectAsComponent","useWebObjectMethodsProxy","useWebObjectMountUnmountWithProps","jest","jsx","_jsx","mock","require","describe","beforeEach","clearAllMocks","Component","test","expect","toHaveBeenCalledTimes"],"sourceRoot":"../../../../src","sources":["react-native/components-factory/createWebObjectAsComponent.test.unit.tsx"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,+BAA+B;AACtD,OAAOC,0BAA0B,MAAM,iCAA8B;AACrE,OAAOC,wBAAwB,MAAM,qCAAkC;AACvE,OAAOC,iCAAiC,MAAM,8CAA2C;AACzF,SAASC,IAAI,QAAQ,eAAe;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAEpCF,IAAI,CAACG,IAAI,CAAC,kCAAkC,EAAE,MAC5CC,OAAO,CAAC,uCAAuC,CACjD,CAAC;AAEDJ,IAAI,CAACG,IAAI,CAAC,2CAA2C,EAAE,MACrDC,OAAO,CAAC,gDAAgD,CAC1D,CAAC;AAEDC,QAAQ,CAAC,4BAA4B,EAAE,MAAM;EAC3CC,UAAU,CAAC,MAAM;IACfN,IAAI,CAACO,aAAa,CAAC,CAAC;EACtB,CAAC,CAAC;EAEFF,QAAQ,CAAC,kCAAkC,EAAE,MAAM;IACjDC,UAAU,CAAC,MAAM;MACf,MAAME,SAAS,GAAGX,0BAA0B,CAAC,KAAK,CAAC;MACnDD,MAAM,cAACM,IAAA,CAACM,SAAS,IAAE,CAAC,CAAC;IACvB,CAAC,CAAC;IAEFH,QAAQ,CAAC,cAAc,EAAE,MAAM;MAC7BI,IAAI,CAAC,mCAAmC,EAAE,MAAM;QAC9CC,MAAM,CAACZ,wBAAwB,CAAC,CAACa,qBAAqB,CAAC,CAAC,CAAC;MAC3D,CAAC,CAAC;MAEFF,IAAI,CAAC,kCAAkC,EAAE,MAAM;QAC7CC,MAAM,CAACX,iCAAiC,CAAC,CAACY,qBAAqB,CAAC,CAAC,CAAC;MACpE,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useCallback, useRef } from 'react';
|
|
4
|
+
import useMapAtoms from "../../hooks/atoms/useMapAtoms.js";
|
|
5
|
+
/**
|
|
6
|
+
* @param props - The RN object props.
|
|
7
|
+
* @param objectId - The ID of the web object that owns the method.
|
|
8
|
+
* @param objectType - The type of the associated web object.
|
|
9
|
+
* @returns – The callbacks used to mount and unmount the web object. They
|
|
10
|
+
* internally handle edge cases where execution must be prevented, with no
|
|
11
|
+
* external management required. They allow (un)mounting the web objects with
|
|
12
|
+
* their options, but also their listeners.
|
|
13
|
+
*/
|
|
14
|
+
const useWebObjectMountUnmountCallbacks = (props, objectId, objectType) => {
|
|
15
|
+
// Refs.
|
|
16
|
+
const areOptionsMounted = useRef(false);
|
|
17
|
+
const areListenersMounted = useRef(false);
|
|
18
|
+
// States.
|
|
19
|
+
// - Global.
|
|
20
|
+
const {
|
|
21
|
+
dispatchMessage,
|
|
22
|
+
setWebObjectListeners,
|
|
23
|
+
deleteWebObjectListeners
|
|
24
|
+
} = useMapAtoms();
|
|
25
|
+
const mount = useCallback(({
|
|
26
|
+
options = true,
|
|
27
|
+
listeners = true
|
|
28
|
+
} = {}) => {
|
|
29
|
+
// Mount the component as a web object within the web world.
|
|
30
|
+
if (options && !areOptionsMounted.current) {
|
|
31
|
+
dispatchMessage({
|
|
32
|
+
type: `webObjectMount`,
|
|
33
|
+
payload: {
|
|
34
|
+
objectId: objectId,
|
|
35
|
+
objectType,
|
|
36
|
+
options: props.options ?? {},
|
|
37
|
+
listeners: props.listeners ?? {}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
areOptionsMounted.current = true;
|
|
41
|
+
}
|
|
42
|
+
// Register listeners on event from the web world.
|
|
43
|
+
if (listeners && !areListenersMounted.current) {
|
|
44
|
+
setWebObjectListeners({
|
|
45
|
+
objectId: objectId,
|
|
46
|
+
listeners: props.listeners ?? {}
|
|
47
|
+
});
|
|
48
|
+
areListenersMounted.current = true;
|
|
49
|
+
}
|
|
50
|
+
}, [objectId, objectType, props.options, props.listeners, dispatchMessage, setWebObjectListeners]);
|
|
51
|
+
const unmount = useCallback(({
|
|
52
|
+
options = true,
|
|
53
|
+
listeners = true
|
|
54
|
+
} = {}) => {
|
|
55
|
+
// Mount the component as a web object within the web world.
|
|
56
|
+
if (options && areOptionsMounted.current) {
|
|
57
|
+
dispatchMessage({
|
|
58
|
+
type: `webObjectUnmount`,
|
|
59
|
+
payload: {
|
|
60
|
+
objectId
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
areOptionsMounted.current = false;
|
|
64
|
+
}
|
|
65
|
+
// Register listeners on event from the web world.
|
|
66
|
+
if (listeners && areListenersMounted.current) {
|
|
67
|
+
deleteWebObjectListeners({
|
|
68
|
+
objectId
|
|
69
|
+
});
|
|
70
|
+
areListenersMounted.current = false;
|
|
71
|
+
}
|
|
72
|
+
}, [objectId, dispatchMessage, deleteWebObjectListeners]);
|
|
73
|
+
return {
|
|
74
|
+
mount,
|
|
75
|
+
unmount
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export default useWebObjectMountUnmountCallbacks;
|
|
79
|
+
//# sourceMappingURL=useWebObjectMountUnmountCallbacks.js.map
|
package/lib/module/react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useRef","useMapAtoms","useWebObjectMountUnmountCallbacks","props","objectId","objectType","areOptionsMounted","areListenersMounted","dispatchMessage","setWebObjectListeners","deleteWebObjectListeners","mount","options","listeners","current","type","payload","unmount"],"sourceRoot":"../../../../../src","sources":["react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.ts"],"mappings":";;AACA,SAA+BA,WAAW,EAAEC,MAAM,QAAQ,OAAO;AAEjE,OAAOC,WAAW,MAAM,kCAA+B;AAGvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,iCAAiC,GAAGA,CAGxCC,KAA6B,EAC7BC,QAAgB,EAChBC,UAAyB,KACtB;EACH;EACA,MAAMC,iBAAiB,GAAGN,MAAM,CAAU,KAAK,CAAC;EAChD,MAAMO,mBAAmB,GAAGP,MAAM,CAAU,KAAK,CAAC;EAClD;EACA;EACA,MAAM;IAAEQ,eAAe;IAAEC,qBAAqB;IAAEC;EAAyB,CAAC,GACxET,WAAW,CAAC,CAAC;EAEf,MAAMU,KAAK,GAAGZ,WAAW,CACvB,CAAC;IACCa,OAAO,GAAG,IAAI;IACdC,SAAS,GAAG;EACgB,CAAC,GAAG,CAAC,CAAC,KAAK;IACvC;IACA,IAAID,OAAO,IAAI,CAACN,iBAAiB,CAACQ,OAAO,EAAE;MACzCN,eAAe,CAAC;QACdO,IAAI,EAAE,gBAAgB;QACtBC,OAAO,EAAE;UACPZ,QAAQ,EAAEA,QAAQ;UAClBC,UAAU;UACVO,OAAO,EAAET,KAAK,CAACS,OAAO,IAAI,CAAC,CAAC;UAC5BC,SAAS,EAAEV,KAAK,CAACU,SAAS,IAAI,CAAC;QACjC;MACF,CAAC,CAAC;MACFP,iBAAiB,CAACQ,OAAO,GAAG,IAAI;IAClC;IACA;IACA,IAAID,SAAS,IAAI,CAACN,mBAAmB,CAACO,OAAO,EAAE;MAC7CL,qBAAqB,CAAC;QACpBL,QAAQ,EAAEA,QAAQ;QAClBS,SAAS,EAAEV,KAAK,CAACU,SAAS,IAAI,CAAC;MACjC,CAAC,CAAC;MACFN,mBAAmB,CAACO,OAAO,GAAG,IAAI;IACpC;EACF,CAAC,EACD,CACEV,QAAQ,EACRC,UAAU,EACVF,KAAK,CAACS,OAAO,EACbT,KAAK,CAACU,SAAS,EACfL,eAAe,EACfC,qBAAqB,CAEzB,CAAC;EAED,MAAMQ,OAAO,GAAGlB,WAAW,CACzB,CAAC;IACCa,OAAO,GAAG,IAAI;IACdC,SAAS,GAAG;EACgB,CAAC,GAAG,CAAC,CAAC,KAAK;IACvC;IACA,IAAID,OAAO,IAAIN,iBAAiB,CAACQ,OAAO,EAAE;MACxCN,eAAe,CAAC;QACdO,IAAI,EAAE,kBAAkB;QACxBC,OAAO,EAAE;UAAEZ;QAAS;MACtB,CAAC,CAAC;MACFE,iBAAiB,CAACQ,OAAO,GAAG,KAAK;IACnC;IACA;IACA,IAAID,SAAS,IAAIN,mBAAmB,CAACO,OAAO,EAAE;MAC5CJ,wBAAwB,CAAC;QAAEN;MAAS,CAAC,CAAC;MACtCG,mBAAmB,CAACO,OAAO,GAAG,KAAK;IACrC;EACF,CAAC,EACD,CAACV,QAAQ,EAAEI,eAAe,EAAEE,wBAAwB,CACtD,CAAC;EAED,OAAO;IAAEC,KAAK;IAAEM;EAAQ,CAAC;AAC3B,CAAC;AAED,eAAef,iCAAiC","ignoreList":[]}
|
package/lib/module/react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.mock.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
export const mount = jest.fn();
|
|
4
|
+
export const unmount = jest.fn();
|
|
5
|
+
const useWebObjectMountUnmountCallbacksMock = () => ({
|
|
6
|
+
mount,
|
|
7
|
+
unmount
|
|
8
|
+
});
|
|
9
|
+
export default useWebObjectMountUnmountCallbacksMock;
|
|
10
|
+
//# sourceMappingURL=useWebObjectMountUnmountCallbacks.mock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["mount","jest","fn","unmount","useWebObjectMountUnmountCallbacksMock"],"sourceRoot":"../../../../../src","sources":["react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.mock.ts"],"mappings":";;AAEA,OAAO,MAAMA,KAAK,GAAGC,IAAI,CAACC,EAAE,CAAC,CAAC;AAC9B,OAAO,MAAMC,OAAO,GAAGF,IAAI,CAACC,EAAE,CAAC,CAAC;AAEhC,MAAME,qCAAqC,GAAGA,CAAA,MAGxC;EACJJ,KAAK;EACLG;AACF,CAAC,CAAC;AAEF,eAAeC,qCAAqC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../../../src","sources":["react-native/components-factory/hooks/useWebObjectMountUnmountCallbacks.types.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
4
|
+
import { stableStringify } from "../../hooks/atoms/useMapAtoms.utils.js";
|
|
5
|
+
import useMapAtoms from "../../hooks/atoms/useMapAtoms.js";
|
|
6
|
+
import useWebObjectMountUnmountCallbacks from "./useWebObjectMountUnmountCallbacks.js";
|
|
7
|
+
/**
|
|
8
|
+
* Mount the component as a web object within the web world on component mount.
|
|
9
|
+
* Propagate any change in the component props to the web world by unmounting
|
|
10
|
+
* and mounting the web object with the new options.
|
|
11
|
+
* @param props - The RN object props.
|
|
12
|
+
* @param objectId - The ID of the web object that owns the method.
|
|
13
|
+
* @param objectType - The type of the associated web object.
|
|
14
|
+
*/
|
|
15
|
+
export const useWebObjectMountUnmountWithProps = (props, objectId, objectType) => {
|
|
16
|
+
// Refs.
|
|
17
|
+
const optionsAsStringPrevious = useRef(undefined);
|
|
18
|
+
// States.
|
|
19
|
+
// - Local.
|
|
20
|
+
const hasBeenMountedAtLeastOnce = useRef(false);
|
|
21
|
+
// - Global.
|
|
22
|
+
const {
|
|
23
|
+
isWebWorldReady
|
|
24
|
+
} = useMapAtoms();
|
|
25
|
+
// Behaviors.
|
|
26
|
+
const {
|
|
27
|
+
mount,
|
|
28
|
+
unmount
|
|
29
|
+
} = useWebObjectMountUnmountCallbacks(props, objectId, objectType);
|
|
30
|
+
const optionsAsString = useMemo(() => stableStringify(props.options), [props]);
|
|
31
|
+
|
|
32
|
+
// Mount options only when they have changed (mounted in the web world), or
|
|
33
|
+
// that the web object has never been mounted.
|
|
34
|
+
// Listeners are always mounted: they are inexpensive (mounted in the RN
|
|
35
|
+
// world) and cannot be reliably compared when declared inline in the
|
|
36
|
+
// component, as they change on every render.
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!isWebWorldReady) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
console.log('optionsAsStringPrevious', optionsAsStringPrevious.current, optionsAsString, hasBeenMountedAtLeastOnce.current);
|
|
42
|
+
const areOptionsEqual = optionsAsStringPrevious.current === optionsAsString;
|
|
43
|
+
const shouldMountOptions = !areOptionsEqual || !hasBeenMountedAtLeastOnce.current;
|
|
44
|
+
hasBeenMountedAtLeastOnce.current = true;
|
|
45
|
+
optionsAsStringPrevious.current = optionsAsString;
|
|
46
|
+
unmount({
|
|
47
|
+
options: shouldMountOptions,
|
|
48
|
+
listeners: true
|
|
49
|
+
});
|
|
50
|
+
mount({
|
|
51
|
+
options: shouldMountOptions,
|
|
52
|
+
listeners: true
|
|
53
|
+
});
|
|
54
|
+
}, [mount, unmount, optionsAsStringPrevious, optionsAsString, props.listeners, hasBeenMountedAtLeastOnce, isWebWorldReady]);
|
|
55
|
+
};
|
|
56
|
+
export default useWebObjectMountUnmountWithProps;
|
|
57
|
+
//# sourceMappingURL=useWebObjectMountUnmountWithProps.js.map
|
package/lib/module/react-native/components-factory/hooks/useWebObjectMountUnmountWithProps.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useEffect","useMemo","useRef","stableStringify","useMapAtoms","useWebObjectMountUnmountCallbacks","useWebObjectMountUnmountWithProps","props","objectId","objectType","optionsAsStringPrevious","undefined","hasBeenMountedAtLeastOnce","isWebWorldReady","mount","unmount","optionsAsString","options","console","log","current","areOptionsEqual","shouldMountOptions","listeners"],"sourceRoot":"../../../../../src","sources":["react-native/components-factory/hooks/useWebObjectMountUnmountWithProps.ts"],"mappings":";;AACA,SAA+BA,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,OAAO;AACxE,SAASC,eAAe,QAAQ,wCAAqC;AACrE,OAAOC,WAAW,MAAM,kCAA+B;AACvD,OAAOC,iCAAiC,MAAM,wCAAqC;AAGnF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iCAAiC,GAAGA,CAG/CC,KAA6B,EAC7BC,QAAgB,EAChBC,UAAyB,KACtB;EACH;EACA,MAAMC,uBAAuB,GAAGR,MAAM,CAAqBS,SAAS,CAAC;EACrE;EACA;EACA,MAAMC,yBAAyB,GAAGV,MAAM,CAAU,KAAK,CAAC;EACxD;EACA,MAAM;IAAEW;EAAgB,CAAC,GAAGT,WAAW,CAAC,CAAC;EACzC;EACA,MAAM;IAAEU,KAAK;IAAEC;EAAQ,CAAC,GAAGV,iCAAiC,CAC1DE,KAAK,EACLC,QAAQ,EACRC,UACF,CAAC;EACD,MAAMO,eAAe,GAAGf,OAAO,CAAC,MAAME,eAAe,CAACI,KAAK,CAACU,OAAO,CAAC,EAAE,CAACV,KAAK,CAAC,CAAC;;EAE9E;EACA;EACA;EACA;EACA;EACAP,SAAS,CAAC,MAAM;IACd,IAAI,CAACa,eAAe,EAAE;MACpB;IACF;IACAK,OAAO,CAACC,GAAG,CACT,yBAAyB,EACzBT,uBAAuB,CAACU,OAAO,EAC/BJ,eAAe,EACfJ,yBAAyB,CAACQ,OAC5B,CAAC;IACD,MAAMC,eAAe,GAAGX,uBAAuB,CAACU,OAAO,KAAKJ,eAAe;IAC3E,MAAMM,kBAAkB,GACtB,CAACD,eAAe,IAAI,CAACT,yBAAyB,CAACQ,OAAO;IAExDR,yBAAyB,CAACQ,OAAO,GAAG,IAAI;IACxCV,uBAAuB,CAACU,OAAO,GAAGJ,eAAe;IAEjDD,OAAO,CAAC;MACNE,OAAO,EAAEK,kBAAkB;MAC3BC,SAAS,EAAE;IACb,CAAC,CAAC;IACFT,KAAK,CAAC;MACJG,OAAO,EAAEK,kBAAkB;MAC3BC,SAAS,EAAE;IACb,CAAC,CAAC;EACJ,CAAC,EAAE,CACDT,KAAK,EACLC,OAAO,EACPL,uBAAuB,EACvBM,eAAe,EACfT,KAAK,CAACgB,SAAS,EACfX,yBAAyB,EACzBC,eAAe,CAChB,CAAC;AACJ,CAAC;AAED,eAAeP,iCAAiC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useWebObjectMountUnmountWithPropsMock","jest","fn"],"sourceRoot":"../../../../../src","sources":["react-native/components-factory/hooks/useWebObjectMountUnmountWithProps.mock.ts"],"mappings":";;AAAA,MAAMA,qCAAqC,GAAGC,IAAI,CAACC,EAAE,CAAC,CAAC;AAEvD,eAAeF,qCAAqC","ignoreList":[]}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
let isWebWorldReady = false;
|
|
3
4
|
export const setIsWebWorldReadyMock = jest.fn();
|
|
4
5
|
export const getWebObjectListenersMock = jest.fn();
|
|
5
6
|
export const resolveWebObjectPendingMethodResponseMock = jest.fn();
|
|
7
|
+
export const setIsWebWorldReady = value => {
|
|
8
|
+
isWebWorldReady = value;
|
|
9
|
+
};
|
|
6
10
|
const useMapAtomsMock = () => ({
|
|
11
|
+
isWebWorldReady,
|
|
7
12
|
setIsWebWorldReady: setIsWebWorldReadyMock,
|
|
8
13
|
getWebObjectListeners: getWebObjectListenersMock,
|
|
9
14
|
resolveWebObjectPendingMethodResponse: resolveWebObjectPendingMethodResponseMock
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["setIsWebWorldReadyMock","jest","fn","getWebObjectListenersMock","resolveWebObjectPendingMethodResponseMock","
|
|
1
|
+
{"version":3,"names":["isWebWorldReady","setIsWebWorldReadyMock","jest","fn","getWebObjectListenersMock","resolveWebObjectPendingMethodResponseMock","setIsWebWorldReady","value","useMapAtomsMock","getWebObjectListeners","resolveWebObjectPendingMethodResponse"],"sourceRoot":"../../../../../src","sources":["react-native/hooks/atoms/useMapAtoms.mock.ts"],"mappings":";;AAAA,IAAIA,eAAe,GAAG,KAAK;AAE3B,OAAO,MAAMC,sBAAsB,GAAGC,IAAI,CAACC,EAAE,CAAC,CAAC;AAC/C,OAAO,MAAMC,yBAAyB,GAAGF,IAAI,CAACC,EAAE,CAAC,CAAC;AAClD,OAAO,MAAME,yCAAyC,GAAGH,IAAI,CAACC,EAAE,CAAC,CAAC;AAClE,OAAO,MAAMG,kBAAkB,GAAIC,KAAc,IAAK;EACpDP,eAAe,GAAGO,KAAK;AACzB,CAAC;AAED,MAAMC,eAAe,GAAGA,CAAA,MAAO;EAC7BR,eAAe;EACfM,kBAAkB,EAAEL,sBAAsB;EAC1CQ,qBAAqB,EAAEL,yBAAyB;EAChDM,qCAAqC,EACnCL;AACJ,CAAC,CAAC;AAEF,eAAeG,eAAe","ignoreList":[]}
|
|
@@ -2,17 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Stable stringify for messages that may contain functions. Keep the function
|
|
5
|
-
* members as '...' to allow identification of the object type (by default a
|
|
5
|
+
* members as '...' to allow identification of the object type (by default, a
|
|
6
6
|
* function cannot be stringified and is removed from the final string).
|
|
7
|
+
* Keys are sorted alphabetically to ensure consistent output.
|
|
7
8
|
* @param message - The message to be stringified.
|
|
8
9
|
* @returns - The stringified message.
|
|
9
10
|
*/
|
|
10
11
|
export const stableStringify = message => {
|
|
11
|
-
|
|
12
|
+
const replacer = (_, value) => {
|
|
12
13
|
if (typeof value === 'function') {
|
|
13
14
|
return '...';
|
|
14
15
|
}
|
|
15
16
|
return value;
|
|
16
|
-
}
|
|
17
|
+
};
|
|
18
|
+
const sortKeys = obj => {
|
|
19
|
+
if (Array.isArray(obj)) {
|
|
20
|
+
return obj.map(sortKeys);
|
|
21
|
+
} else if (obj !== null && typeof obj === 'object') {
|
|
22
|
+
const sortedObj = {};
|
|
23
|
+
Object.keys(obj).sort().forEach(key => {
|
|
24
|
+
sortedObj[key] = sortKeys(obj[key]);
|
|
25
|
+
});
|
|
26
|
+
return sortedObj;
|
|
27
|
+
}
|
|
28
|
+
return obj;
|
|
29
|
+
};
|
|
30
|
+
return JSON.stringify(sortKeys(message), replacer);
|
|
17
31
|
};
|
|
18
32
|
//# sourceMappingURL=useMapAtoms.utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["stableStringify","message","
|
|
1
|
+
{"version":3,"names":["stableStringify","message","replacer","_","value","sortKeys","obj","Array","isArray","map","sortedObj","Object","keys","sort","forEach","key","JSON","stringify"],"sourceRoot":"../../../../../src","sources":["react-native/hooks/atoms/useMapAtoms.utils.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,eAAe,GAAIC,OAAY,IAAa;EACvD,MAAMC,QAAQ,GAAGA,CAACC,CAAS,EAAEC,KAAU,KAAK;IAC1C,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;MAC/B,OAAO,KAAK;IACd;IACA,OAAOA,KAAK;EACd,CAAC;EAED,MAAMC,QAAQ,GAAIC,GAAQ,IAAU;IAClC,IAAIC,KAAK,CAACC,OAAO,CAACF,GAAG,CAAC,EAAE;MACtB,OAAOA,GAAG,CAACG,GAAG,CAACJ,QAAQ,CAAC;IAC1B,CAAC,MAAM,IAAIC,GAAG,KAAK,IAAI,IAAI,OAAOA,GAAG,KAAK,QAAQ,EAAE;MAClD,MAAMI,SAA8B,GAAG,CAAC,CAAC;MACzCC,MAAM,CAACC,IAAI,CAACN,GAAG,CAAC,CACbO,IAAI,CAAC,CAAC,CACNC,OAAO,CAAEC,GAAG,IAAK;QAChBL,SAAS,CAACK,GAAG,CAAC,GAAGV,QAAQ,CAACC,GAAG,CAACS,GAAG,CAAC,CAAC;MACrC,CAAC,CAAC;MACJ,OAAOL,SAAS;IAClB;IACA,OAAOJ,GAAG;EACZ,CAAC;EAED,OAAOU,IAAI,CAACC,SAAS,CAACZ,QAAQ,CAACJ,OAAO,CAAC,EAAEC,QAAQ,CAAC;AACpD,CAAC","ignoreList":[]}
|
|
@@ -23359,6 +23359,11 @@ uniform mat4 u_projection_matrix;
|
|
|
23359
23359
|
message.payload.objectId,
|
|
23360
23360
|
message.payload.listeners
|
|
23361
23361
|
);
|
|
23362
|
+
this.#objects.entries().forEach(([, object]) => {
|
|
23363
|
+
if (!(object instanceof import_maplibre_gl.default.Map)) {
|
|
23364
|
+
object.addTo(map);
|
|
23365
|
+
}
|
|
23366
|
+
});
|
|
23362
23367
|
break;
|
|
23363
23368
|
}
|
|
23364
23369
|
case "marker": {
|
|
@@ -23420,8 +23425,6 @@ uniform mat4 u_projection_matrix;
|
|
|
23420
23425
|
if (!this.#runIfSpecialMethod(message, object)) {
|
|
23421
23426
|
result = await this.#runNormalMethod(message, object);
|
|
23422
23427
|
}
|
|
23423
|
-
if (!(object instanceof import_maplibre_gl.default.Map)) {
|
|
23424
|
-
}
|
|
23425
23428
|
this.reactNativeBridge.postMessage({
|
|
23426
23429
|
type: "webObjectMethodResponse",
|
|
23427
23430
|
payload: { requestId: message.payload.requestId, result }
|