Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@stackflow/plugin-history-sync

Package Overview
Dependencies
Maintainers
3
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stackflow/plugin-history-sync - npm Package Compare versions

Comparing version 1.3.5 to 1.3.6-alpha.6

23

dist/index.js

@@ -62,3 +62,3 @@ "use strict";

// src/historyState.ts
var STATE_TAG = `${"@stackflow/plugin-history-sync"}@${"1.3.4"}`;
var STATE_TAG = `${"@stackflow/plugin-history-sync"}@${"1.3.5"}`;
function serializeStep(step) {

@@ -230,2 +230,3 @@ return __spreadProps(__spreadValues({}, step), {

let popFlag = 0;
let replacePopCount = 0;
const queue = makeQueue(history);

@@ -514,3 +515,6 @@ return {

},
onBeforeReplace({ actionParams, actions: { overrideActionParams } }) {
onBeforeReplace({
actionParams,
actions: { overrideActionParams, getStack }
}) {
const template = makeTemplate(

@@ -526,2 +530,9 @@ normalizeRoute(options.routes[actionParams.activityName])[0],

}));
const { activities } = getStack();
const enteredActivities = activities.filter(
(currentActivity) => currentActivity.transitionState === "enter-active" || currentActivity.transitionState === "enter-done"
);
const previousActivity = enteredActivities.length > 0 ? enteredActivities[enteredActivities.length - 1] : null;
const popCount = (previousActivity == null ? void 0 : previousActivity.steps.length) ? previousActivity.steps.length : 0;
replacePopCount += popCount;
},

@@ -555,5 +566,4 @@ onBeforeStepPop({ actions: { getStack } }) {

if ((currentActivity == null ? void 0 : currentActivity.enteredBy.name) === "Replaced" && previousActivity) {
const previousStepsLength = previousActivity.steps.length;
const replacedActivityDepth = 1;
popCount = currentStepsLength + previousStepsLength - replacedActivityDepth;
const shouldPopForCurrentStepPush = currentStepsLength > 1;
popCount = shouldPopForCurrentStepPush ? replacePopCount + currentStepsLength : replacePopCount;
}

@@ -565,2 +575,5 @@ popFlag += popCount;

}
if ((currentActivity == null ? void 0 : currentActivity.enteredBy.name) === "Replaced" && previousActivity && replacePopCount > 0) {
replacePopCount = 0;
}
} while (!safeParseState(getCurrentState({ history })));

@@ -567,0 +580,0 @@ }

{
"name": "@stackflow/plugin-history-sync",
"version": "1.3.5",
"version": "1.3.6-alpha.6+c5638916",
"license": "MIT",

@@ -84,3 +84,3 @@ "exports": {

},
"gitHead": "9f0cbe88880ec2ddc654fdb87c0f459e68b6ff3a"
"gitHead": "c563891650eb1042dc748dd400af25714fb254bd"
}

@@ -17,2 +17,5 @@ import type {

// 2프레임 + 1프레임
const ENOUGH_DELAY_TIME = 32 + 16;
let dt = 0;

@@ -671,2 +674,3 @@

});
await delay(ENOUGH_DELAY_TIME);

@@ -683,2 +687,58 @@ actions.pop();

test("historySyncPlugin - push 후 *push 를 한 번 더 수행한 뒤*, stepPush 를 반복한 뒤, replace 를 하고 pop 을 수행하면 *두번째 stack* 을 가리킵니다.", async () => {
actions.push({
activityId: "a2",
activityName: "Article",
activityParams: {
articleId: "1",
},
});
actions.push({
activityId: "a3",
activityName: "ThirdActivity",
activityParams: {
thirdId: "234",
},
});
actions.stepPush({
stepId: "s2",
stepParams: {
thirdId: "2",
},
});
actions.stepPush({
stepId: "s3",
stepParams: {
thirdId: "3",
},
});
actions.stepPush({
stepId: "s4",
stepParams: {
thirdId: "4",
},
});
actions.replace({
activityId: "a4",
activityName: "FourthActivity",
activityParams: {
fourthId: "567",
},
});
await delay(ENOUGH_DELAY_TIME);
actions.pop();
// 전환이 끝나기까지 충분한 시간
// 코어쪽 추가된 테스트 코드가 Resolve 되면 삭제 가능
await delay(32 + 16);
expect(path(history.location)).toEqual("/articles/1/");
expect(activeActivity(actions.getStack())?.name).toEqual("Article");
});
test("historySyncPlugin - push 후 stepPush 를 반복한 뒤, push 와 pop 을 1회 수행하고 replace를 수행하고 pop 을 진행하면 첫번째 stack 을 가리킵니다.", async () => {

@@ -731,2 +791,3 @@ actions.push({

});
await delay(ENOUGH_DELAY_TIME);

@@ -741,5 +802,5 @@ actions.pop();

expect(activeActivity(actions.getStack())?.name).toEqual("Home");
})
});
test("historySyncPlugin - push 후 stepPush 를 반복한 뒤, push 와 pop 을 1회 수행하고 replace 를 한 뒤 stepPush 를 반복하고 pop 을 진행해도 첫번째 stack 을 가리킵니다.", async () => {
test("historySyncPlugin - push 후 stepPush 를 반복한 뒤, replace 를 한 뒤 stepPush 를 반복하고 pop 을 진행해도 첫번째 stack 을 가리킵니다.", async () => {
actions.push({

@@ -774,3 +835,73 @@ activityId: "a2",

actions.replace({
activityId: "a4",
activityName: "FourthActivity",
activityParams: {
fourthId: "345",
},
});
await delay(ENOUGH_DELAY_TIME);
actions.stepPush({
stepId: "s5",
stepParams: {
fourthId: "5",
},
});
actions.stepPush({
stepId: "s6",
stepParams: {
fourthId: "6",
},
});
actions.stepPush({
stepId: "s7",
stepParams: {
fourthId: "7",
},
});
actions.pop();
// 전환이 끝나기까지 충분한 시간
// 코어쪽 추가된 테스트 코드가 Resolve 되면 삭제 가능
await delay(ENOUGH_DELAY_TIME);
expect(path(history.location)).toEqual("/home/");
expect(activeActivity(actions.getStack())?.name).toEqual("Home");
});
test("historySyncPlugin - push 후 stepPush 를 반복한 뒤, replace 를 수행하고 stepPush 를 반복하고 replace를 수행하고 pop을 진행해도 첫번째 stack을 가리킵니다.(for Hugh)", async () => {
actions.push({
activityId: "a2",
activityName: "Article",
activityParams: {
articleId: "1",
},
});
actions.stepPush({
stepId: "s2",
stepParams: {
articleId: "2",
},
});
actions.stepPush({
stepId: "s3",
stepParams: {
articleId: "3",
},
});
actions.stepPush({
stepId: "s4",
stepParams: {
articleId: "4",
},
});
actions.replace({
activityId: "a3",

@@ -782,5 +913,103 @@ activityName: "ThirdActivity",

});
await delay(ENOUGH_DELAY_TIME);
actions.stepPush({
stepId: "s2",
stepParams: {
thirdId: "2",
},
});
actions.stepPush({
stepId: "s3",
stepParams: {
thirdId: "3",
},
});
actions.stepPush({
stepId: "s4",
stepParams: {
thirdId: "4",
},
});
actions.replace({
activityId: "a4",
activityName: "FourthActivity",
activityParams: {
fourthId: "345",
},
});
await delay(ENOUGH_DELAY_TIME);
actions.pop();
// 전환이 끝나기까지 충분한 시간
// 코어쪽 추가된 테스트 코드가 Resolve 되면 삭제 가능
await delay(ENOUGH_DELAY_TIME);
expect(path(history.location)).toEqual("/home/");
expect(activeActivity(actions.getStack())?.name).toEqual("Home");
});
test("historySyncPlugin - push 후 stepPush 를 반복한 뒤, push 를 수행하고 stepPush 를 반복한 뒤 pop 을 수행, 그 후 replace 를 수행하고 pop을 진행해도 첫번째 stack을 가리킵니다.", async () => {
actions.push({
activityId: "a2",
activityName: "Article",
activityParams: {
articleId: "1",
},
});
actions.stepPush({
stepId: "s2",
stepParams: {
articleId: "2",
},
});
actions.stepPush({
stepId: "s3",
stepParams: {
articleId: "3",
},
});
actions.stepPush({
stepId: "s4",
stepParams: {
articleId: "4",
},
});
actions.push({
activityId: "a3",
activityName: "ThirdActivity",
activityParams: {
thirdId: "234",
},
});
actions.stepPush({
stepId: "s2",
stepParams: {
thirdId: "2",
},
});
actions.stepPush({
stepId: "s3",
stepParams: {
thirdId: "3",
},
});
actions.stepPush({
stepId: "s4",
stepParams: {
thirdId: "4",
},
});
actions.pop();
actions.replace({

@@ -793,7 +1022,24 @@ activityId: "a4",

});
await delay(ENOUGH_DELAY_TIME);
actions.pop();
await delay(ENOUGH_DELAY_TIME);
expect(path(history.location)).toEqual("/home/");
expect(activeActivity(actions.getStack())?.name).toEqual("Home");
});
test("historySyncPlugin - 2회 반복:push 후 stepPush 를 반복한 뒤, push 를 수행하고 stepPush 를 반복한 뒤 pop 을 수행, 그 후 replace 를 수행하고 pop을 진행해도 첫번째 stack을 가리킵니다.", async () => {
actions.push({
activityId: "a2",
activityName: "Article",
activityParams: {
articleId: "1",
},
});
actions.stepPush({
stepId: "s5",
stepId: "s2",
stepParams: {
fourthId: "5",
articleId: "2",
},

@@ -803,5 +1049,5 @@ });

actions.stepPush({
stepId: "s6",
stepId: "s3",
stepParams: {
fourthId: "6",
articleId: "3",
},

@@ -811,17 +1057,123 @@ });

actions.stepPush({
stepId: "s7",
stepId: "s4",
stepParams: {
fourthId: "7",
articleId: "4",
},
});
actions.push({
activityId: "a3",
activityName: "ThirdActivity",
activityParams: {
thirdId: "234",
},
});
actions.stepPush({
stepId: "s2",
stepParams: {
thirdId: "2",
},
});
actions.stepPush({
stepId: "s3",
stepParams: {
thirdId: "3",
},
});
actions.stepPush({
stepId: "s4",
stepParams: {
thirdId: "4",
},
});
actions.pop();
// 전환이 끝나기까지 충분한 시간
// 코어쪽 추가된 테스트 코드가 Resolve 되면 삭제 가능
await delay(16 * 7);
actions.replace({
activityId: "a4",
activityName: "FourthActivity",
activityParams: {
fourthId: "345",
},
});
await delay(ENOUGH_DELAY_TIME);
actions.pop();
await delay(ENOUGH_DELAY_TIME);
actions.push({
activityId: "a5",
activityName: "ThirdActivity",
activityParams: {
thirdId: "1",
},
});
actions.stepPush({
stepId: "s2",
stepParams: {
thirdId: "2",
},
});
actions.stepPush({
stepId: "s3",
stepParams: {
thirdId: "3",
},
});
actions.stepPush({
stepId: "s4",
stepParams: {
thirdId: "4",
},
});
actions.push({
activityId: "a6",
activityName: "FourthActivity",
activityParams: {
fourthId: "234",
},
});
actions.stepPush({
stepId: "s2",
stepParams: {
fourthId: "2",
},
});
actions.stepPush({
stepId: "s3",
stepParams: {
fourthId: "3",
},
});
actions.stepPush({
stepId: "s4",
stepParams: {
fourthId: "4",
},
});
actions.pop();
actions.replace({
activityId: "a7",
activityName: "Article",
activityParams: {
articleId: "345",
},
});
await delay(ENOUGH_DELAY_TIME);
actions.pop();
await delay(ENOUGH_DELAY_TIME);
expect(path(history.location)).toEqual("/home/");
expect(activeActivity(actions.getStack())?.name).toEqual("Home");
})
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc