Preheat oven and line sheet:
Preheat oven to 400°F (205°C). Line a baking sheet with parchment paper.Cut puff pastry into squares:
Unfold the thawed puff pastry and cut into 12 equal squares. Place squares on the prepared baking sheet.Mix cream cheese filling:
In a bowl, beat together cream cheese, sugar, egg yolk, vanilla, and flour (if using) until smooth.Fill pastry squares:
Spoon about 1 tsp of the cheese mixture into the center of each puff pastry square. If using fruit preserves, add a small dollop on top of the cream cheese.Fold and brush with egg:
Fold corners slightly inward or leave open. Beat the whole egg and brush around the edges of each square for a golden finish.Bake until golden:
Bake for 15–18 minutes or until puffed and lightly golden. Remove and let cool slightly.Glaze with powdered sugar:
Optional glaze: Mix powdered sugar with milk and drizzle over warm danishes before serving.