@storybook/react-native 8.5.5-alpha.4 → 8.6.0-alpha.0
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/dist/index.d.ts +1 -0
- package/dist/index.js +58 -4
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -51,6 +51,7 @@ declare class View {
|
|
|
51
51
|
_channel: Channel;
|
|
52
52
|
_idToPrepared: Record<string, PreparedStory<ReactRenderer>>;
|
|
53
53
|
constructor(preview: PreviewWithSelection<ReactRenderer>, channel: Channel);
|
|
54
|
+
_storyIdExists: (storyId: string) => boolean;
|
|
54
55
|
_getInitialStory: ({ initialSelection, shouldPersistSelection, }?: Partial<Params>) => Promise<{
|
|
55
56
|
storySpecifier: string;
|
|
56
57
|
viewMode: string;
|
package/dist/index.js
CHANGED
|
@@ -889,6 +889,9 @@ var View3 = class {
|
|
|
889
889
|
this._preview = preview;
|
|
890
890
|
this._channel = channel;
|
|
891
891
|
}
|
|
892
|
+
_storyIdExists = (storyId) => {
|
|
893
|
+
return Object.keys(this._storyIndex.entries).includes(storyId);
|
|
894
|
+
};
|
|
892
895
|
_getInitialStory = async ({
|
|
893
896
|
initialSelection,
|
|
894
897
|
shouldPersistSelection = true
|
|
@@ -910,7 +913,7 @@ var View3 = class {
|
|
|
910
913
|
value = await this._storage.getItem(STORAGE_KEY);
|
|
911
914
|
this._asyncStorageStoryId = value;
|
|
912
915
|
}
|
|
913
|
-
const exists = value &&
|
|
916
|
+
const exists = value && this._storyIdExists(value);
|
|
914
917
|
if (!exists)
|
|
915
918
|
console.log("Storybook: could not find persisted story");
|
|
916
919
|
return { storySpecifier: exists ? value : "*", viewMode: "story" };
|
|
@@ -990,13 +993,64 @@ var View3 = class {
|
|
|
990
993
|
() => (0, import_deepmerge.default)(colorScheme === "dark" ? import_react_native_theming2.darkTheme : import_react_native_theming2.theme, params.theme ?? {}),
|
|
991
994
|
[colorScheme]
|
|
992
995
|
);
|
|
996
|
+
(0, import_react4.useEffect)(() => {
|
|
997
|
+
const listener = import_react_native3.Linking.addEventListener("url", ({ url }) => {
|
|
998
|
+
if (typeof url === "string") {
|
|
999
|
+
const urlObj = new URL(url);
|
|
1000
|
+
const storyId = urlObj.searchParams.get("STORYBOOK_STORY_ID");
|
|
1001
|
+
const hasStoryId = storyId && typeof storyId === "string";
|
|
1002
|
+
const storyExists = hasStoryId && this._storyIdExists(storyId);
|
|
1003
|
+
if (storyExists && this._ready) {
|
|
1004
|
+
console.log(`STORYBOOK: Linking event received, navigating to story: ${storyId}`);
|
|
1005
|
+
this._channel.emit(import_core_events.default.SET_CURRENT_STORY, { storyId });
|
|
1006
|
+
} else if (hasStoryId) {
|
|
1007
|
+
console.log(
|
|
1008
|
+
`STORYBOOK: Linking event received, but story does not exist: ${storyId}`
|
|
1009
|
+
);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
});
|
|
1013
|
+
return () => {
|
|
1014
|
+
listener.remove();
|
|
1015
|
+
};
|
|
1016
|
+
}, []);
|
|
993
1017
|
(0, import_react4.useEffect)(() => {
|
|
994
1018
|
this.createPreparedStoryMapping().then(() => {
|
|
995
1019
|
this._ready = true;
|
|
996
1020
|
setReady(true);
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1021
|
+
return import_react_native3.Linking.getInitialURL().then((url) => {
|
|
1022
|
+
if (url && typeof url === "string") {
|
|
1023
|
+
const urlObj = new URL(url);
|
|
1024
|
+
const storyId = urlObj.searchParams.get("STORYBOOK_STORY_ID");
|
|
1025
|
+
const hasStoryId = storyId && typeof storyId === "string";
|
|
1026
|
+
const storyExists = hasStoryId && this._storyIdExists(storyId);
|
|
1027
|
+
if (hasStoryId && !storyExists) {
|
|
1028
|
+
console.log(
|
|
1029
|
+
`STORYBOOK: Initial Linking event received, but story does not exist: ${storyId}`
|
|
1030
|
+
);
|
|
1031
|
+
}
|
|
1032
|
+
if (storyExists) {
|
|
1033
|
+
return { initialStoryIdFromUrl: storyId, initialUrl: urlObj };
|
|
1034
|
+
} else {
|
|
1035
|
+
return null;
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
}).then(({ initialStoryIdFromUrl, initialUrl }) => {
|
|
1039
|
+
return initialStory.then((st) => {
|
|
1040
|
+
self._preview.selectionStore.selectionSpecifier = st;
|
|
1041
|
+
if (initialStoryIdFromUrl) {
|
|
1042
|
+
initialUrl.searchParams.delete("STORYBOOK_STORY_ID");
|
|
1043
|
+
import_react_native3.Linking.openURL(initialUrl.toString());
|
|
1044
|
+
console.log(
|
|
1045
|
+
`STORYBOOK: Setting initial story from Linking event, storyId: ${initialStoryIdFromUrl}`
|
|
1046
|
+
);
|
|
1047
|
+
self._preview.selectionStore.selectionSpecifier = {
|
|
1048
|
+
storySpecifier: initialStoryIdFromUrl,
|
|
1049
|
+
viewMode: "story"
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
self._preview.selectSpecifiedStory();
|
|
1053
|
+
});
|
|
1000
1054
|
});
|
|
1001
1055
|
}).catch((e) => console.error(e));
|
|
1002
1056
|
self._setStory = (newStory) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react-native",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.6.0-alpha.0",
|
|
4
4
|
"description": "A better way to develop React Native Components for your app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"@storybook/csf": "^0.1.13",
|
|
50
50
|
"@storybook/global": "^5.0.0",
|
|
51
51
|
"@storybook/react": "^8.5.1",
|
|
52
|
-
"@storybook/react-native-theming": "^8.
|
|
53
|
-
"@storybook/react-native-ui": "^8.
|
|
52
|
+
"@storybook/react-native-theming": "^8.6.0-alpha.0",
|
|
53
|
+
"@storybook/react-native-ui": "^8.6.0-alpha.0",
|
|
54
54
|
"commander": "^8.2.0",
|
|
55
55
|
"dedent": "^1.5.1",
|
|
56
56
|
"deepmerge": "^4.3.0",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "6a87785e97473df94a385971acf26c7893d0a7dd"
|
|
92
92
|
}
|