@storybook/core-server 6.5.0-alpha.48 → 6.5.0-alpha.50

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.
@@ -71,7 +71,11 @@ async function storybookDevServer(options) {
71
71
 
72
72
  app.use(function (req, res, next) {
73
73
  res.header('Access-Control-Allow-Origin', '*');
74
- res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
74
+ res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); // These headers are required to enable SharedArrayBuffer
75
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer
76
+
77
+ res.header('Cross-Origin-Opener-Policy', 'same-origin');
78
+ res.header('Cross-Origin-Embedder-Policy', 'require-corp');
75
79
  next();
76
80
  }); // User's own static files
77
81
 
@@ -47,23 +47,27 @@ async function useStoriesJson(router, serverChannel, options, workingDir = proce
47
47
  }); // Wait until someone actually requests `stories.json` before we start generating/watching.
48
48
  // This is mainly for testing purposes.
49
49
 
50
- var started = false;
51
50
  var maybeInvalidate = (0, _debounce.default)(function () {
52
51
  return serverChannel.emit(_coreEvents.default.STORY_INDEX_INVALIDATED);
53
52
  }, DEBOUNCE, {
54
53
  leading: true
55
54
  });
55
+ var startedPromise;
56
56
 
57
57
  async function ensureStarted() {
58
- if (started) return;
59
- started = true;
60
- (0, _watchStorySpecifiers.watchStorySpecifiers)(normalizedStories, {
61
- workingDir: workingDir
62
- }, function (specifier, path, removed) {
63
- generator.invalidate(specifier, path, removed);
64
- maybeInvalidate();
65
- });
66
- await generator.initialize();
58
+ if (!startedPromise) {
59
+ startedPromise = async function () {
60
+ (0, _watchStorySpecifiers.watchStorySpecifiers)(normalizedStories, {
61
+ workingDir: workingDir
62
+ }, function (specifier, path, removed) {
63
+ generator.invalidate(specifier, path, removed);
64
+ maybeInvalidate();
65
+ });
66
+ await generator.initialize();
67
+ }();
68
+ }
69
+
70
+ return startedPromise;
67
71
  }
68
72
 
69
73
  router.use('/stories.json', async function (req, res) {
@@ -41,7 +41,11 @@ export async function storybookDevServer(options) {
41
41
 
42
42
  app.use(function (req, res, next) {
43
43
  res.header('Access-Control-Allow-Origin', '*');
44
- res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
44
+ res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); // These headers are required to enable SharedArrayBuffer
45
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer
46
+
47
+ res.header('Cross-Origin-Opener-Policy', 'same-origin');
48
+ res.header('Cross-Origin-Embedder-Policy', 'require-corp');
45
49
  next();
46
50
  }); // User's own static files
47
51
 
@@ -26,23 +26,27 @@ export async function useStoriesJson(router, serverChannel, options, workingDir
26
26
  }); // Wait until someone actually requests `stories.json` before we start generating/watching.
27
27
  // This is mainly for testing purposes.
28
28
 
29
- var started = false;
30
29
  var maybeInvalidate = debounce(function () {
31
30
  return serverChannel.emit(Events.STORY_INDEX_INVALIDATED);
32
31
  }, DEBOUNCE, {
33
32
  leading: true
34
33
  });
34
+ var startedPromise;
35
35
 
36
36
  async function ensureStarted() {
37
- if (started) return;
38
- started = true;
39
- watchStorySpecifiers(normalizedStories, {
40
- workingDir: workingDir
41
- }, function (specifier, path, removed) {
42
- generator.invalidate(specifier, path, removed);
43
- maybeInvalidate();
44
- });
45
- await generator.initialize();
37
+ if (!startedPromise) {
38
+ startedPromise = async function () {
39
+ watchStorySpecifiers(normalizedStories, {
40
+ workingDir: workingDir
41
+ }, function (specifier, path, removed) {
42
+ generator.invalidate(specifier, path, removed);
43
+ maybeInvalidate();
44
+ });
45
+ await generator.initialize();
46
+ }();
47
+ }
48
+
49
+ return startedPromise;
46
50
  }
47
51
 
48
52
  router.use('/stories.json', async function (req, res) {
@@ -41,7 +41,11 @@ export async function storybookDevServer(options) {
41
41
 
42
42
  app.use(function (req, res, next) {
43
43
  res.header('Access-Control-Allow-Origin', '*');
44
- res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
44
+ res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); // These headers are required to enable SharedArrayBuffer
45
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer
46
+
47
+ res.header('Cross-Origin-Opener-Policy', 'same-origin');
48
+ res.header('Cross-Origin-Embedder-Policy', 'require-corp');
45
49
  next();
46
50
  }); // User's own static files
47
51
 
@@ -26,23 +26,27 @@ export async function useStoriesJson(router, serverChannel, options, workingDir
26
26
  }); // Wait until someone actually requests `stories.json` before we start generating/watching.
27
27
  // This is mainly for testing purposes.
28
28
 
29
- var started = false;
30
29
  var maybeInvalidate = debounce(function () {
31
30
  return serverChannel.emit(Events.STORY_INDEX_INVALIDATED);
32
31
  }, DEBOUNCE, {
33
32
  leading: true
34
33
  });
34
+ var startedPromise;
35
35
 
36
36
  async function ensureStarted() {
37
- if (started) return;
38
- started = true;
39
- watchStorySpecifiers(normalizedStories, {
40
- workingDir: workingDir
41
- }, function (specifier, path, removed) {
42
- generator.invalidate(specifier, path, removed);
43
- maybeInvalidate();
44
- });
45
- await generator.initialize();
37
+ if (!startedPromise) {
38
+ startedPromise = async function () {
39
+ watchStorySpecifiers(normalizedStories, {
40
+ workingDir: workingDir
41
+ }, function (specifier, path, removed) {
42
+ generator.invalidate(specifier, path, removed);
43
+ maybeInvalidate();
44
+ });
45
+ await generator.initialize();
46
+ }();
47
+ }
48
+
49
+ return startedPromise;
46
50
  }
47
51
 
48
52
  router.use('/stories.json', async function (req, res) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/core-server",
3
- "version": "6.5.0-alpha.48",
3
+ "version": "6.5.0-alpha.50",
4
4
  "description": "Storybook framework-agnostic API",
5
5
  "keywords": [
6
6
  "storybook"
@@ -40,16 +40,16 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "@discoveryjs/json-ext": "^0.5.3",
43
- "@storybook/builder-webpack4": "6.5.0-alpha.48",
44
- "@storybook/core-client": "6.5.0-alpha.48",
45
- "@storybook/core-common": "6.5.0-alpha.48",
46
- "@storybook/core-events": "6.5.0-alpha.48",
47
- "@storybook/csf": "0.0.2--canary.87bc651.0",
48
- "@storybook/csf-tools": "6.5.0-alpha.48",
49
- "@storybook/manager-webpack4": "6.5.0-alpha.48",
50
- "@storybook/node-logger": "6.5.0-alpha.48",
43
+ "@storybook/builder-webpack4": "6.5.0-alpha.50",
44
+ "@storybook/core-client": "6.5.0-alpha.50",
45
+ "@storybook/core-common": "6.5.0-alpha.50",
46
+ "@storybook/core-events": "6.5.0-alpha.50",
47
+ "@storybook/csf": "0.0.2--canary.507502b.0",
48
+ "@storybook/csf-tools": "6.5.0-alpha.50",
49
+ "@storybook/manager-webpack4": "6.5.0-alpha.50",
50
+ "@storybook/node-logger": "6.5.0-alpha.50",
51
51
  "@storybook/semver": "^7.3.2",
52
- "@storybook/store": "6.5.0-alpha.48",
52
+ "@storybook/store": "6.5.0-alpha.50",
53
53
  "@types/node": "^14.0.10 || ^16.0.0",
54
54
  "@types/node-fetch": "^2.5.7",
55
55
  "@types/pretty-hrtime": "^1.0.0",
@@ -85,7 +85,7 @@
85
85
  "x-default-browser": "^0.4.0"
86
86
  },
87
87
  "devDependencies": {
88
- "@storybook/builder-webpack5": "6.5.0-alpha.48",
88
+ "@storybook/builder-webpack5": "6.5.0-alpha.50",
89
89
  "@types/compression": "^1.7.0",
90
90
  "@types/ip": "^1.1.0",
91
91
  "@types/serve-favicon": "^2.5.2",
@@ -110,6 +110,6 @@
110
110
  "publishConfig": {
111
111
  "access": "public"
112
112
  },
113
- "gitHead": "5f3afb8cf4389c16be11a6e5099e902d16a82762",
113
+ "gitHead": "6cf4571e5a1200613de94aa066fe93f75aec6ad1",
114
114
  "sbmodern": "dist/modern/index.js"
115
115
  }