@storybook/ember 9.0.0-beta.1 → 9.0.0-beta.11

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.
@@ -0,0 +1,3 @@
1
+ import './globals';
2
+ export { renderToCanvas } from './render';
3
+ export const parameters = { renderer: 'ember' };
@@ -0,0 +1,10 @@
1
+ import { enhanceArgTypes } from 'storybook/internal/docs-tools';
2
+ import { extractArgTypes, extractComponentDescription } from './jsondoc';
3
+ export const parameters = {
4
+ docs: {
5
+ story: { iframeHeight: '80px' },
6
+ extractArgTypes,
7
+ extractComponentDescription,
8
+ },
9
+ };
10
+ export const argTypesEnhancers = [enhanceArgTypes];
@@ -0,0 +1,42 @@
1
+ import { global } from '@storybook/global';
2
+ export const getJSONDoc = () => {
3
+ return global.__EMBER_GENERATED_DOC_JSON__;
4
+ };
5
+ export const extractArgTypes = (componentName) => {
6
+ const json = getJSONDoc();
7
+ if (!(json && json.included)) {
8
+ return null;
9
+ }
10
+ const componentDoc = json.included.find((doc) => doc.attributes.name === componentName);
11
+ if (!componentDoc) {
12
+ return null;
13
+ }
14
+ return componentDoc.attributes.arguments.reduce((acc, prop) => {
15
+ acc[prop.name] = {
16
+ name: prop.name,
17
+ defaultValue: prop.defaultValue,
18
+ description: prop.description,
19
+ table: {
20
+ defaultValue: { summary: prop.defaultValue },
21
+ type: {
22
+ summary: prop.type,
23
+ required: prop.tags.length
24
+ ? prop.tags.some((tag) => tag.name === 'required')
25
+ : false,
26
+ },
27
+ },
28
+ };
29
+ return acc;
30
+ }, {});
31
+ };
32
+ export const extractComponentDescription = (componentName) => {
33
+ const json = getJSONDoc();
34
+ if (!(json && json.included)) {
35
+ return null;
36
+ }
37
+ const componentDoc = json.included.find((doc) => doc.attributes.name === componentName);
38
+ if (!componentDoc) {
39
+ return null;
40
+ }
41
+ return componentDoc.attributes.description;
42
+ };
@@ -0,0 +1,3 @@
1
+ import { global } from '@storybook/global';
2
+ global.STORYBOOK_NAME = process.env.STORYBOOK_NAME;
3
+ global.STORYBOOK_ENV = 'ember';
@@ -0,0 +1,65 @@
1
+ import { global } from '@storybook/global';
2
+ import { dedent } from 'ts-dedent';
3
+ const { document } = global;
4
+ const rootEl = document.getElementById('storybook-root');
5
+ function loadEmberApp() {
6
+ const config = global.require(`${global.STORYBOOK_NAME}/config/environment`);
7
+ return global.require(`${global.STORYBOOK_NAME}/app`).default.create({
8
+ autoboot: false,
9
+ rootElement: rootEl,
10
+ ...config.APP,
11
+ });
12
+ }
13
+ const app = loadEmberApp();
14
+ let lastPromise = app.boot();
15
+ let hasRendered = false;
16
+ let isRendering = false;
17
+ function render(options, el) {
18
+ if (isRendering) {
19
+ return;
20
+ }
21
+ isRendering = true;
22
+ const { template, context = {}, element } = options;
23
+ if (hasRendered) {
24
+ lastPromise = lastPromise.then((instance) => instance.destroy());
25
+ }
26
+ lastPromise = lastPromise
27
+ .then(() => {
28
+ const appInstancePrivate = app.buildInstance();
29
+ return appInstancePrivate.boot().then(() => appInstancePrivate);
30
+ })
31
+ .then((instance) => {
32
+ instance.register('component:story-mode', Ember.Component.extend({
33
+ layout: template || options,
34
+ ...context,
35
+ }));
36
+ const component = instance.lookup('component:story-mode');
37
+ if (element) {
38
+ component.appendTo(element);
39
+ element.appendTo(el);
40
+ }
41
+ else {
42
+ component.appendTo(el);
43
+ }
44
+ hasRendered = true;
45
+ isRendering = false;
46
+ return instance;
47
+ });
48
+ }
49
+ export function renderToCanvas({ storyFn, kind, name, showMain, showError }, canvasElement) {
50
+ const element = storyFn();
51
+ if (!element) {
52
+ showError({
53
+ title: `Expecting a Ember element from the story: "${name}" of "${kind}".`,
54
+ description: dedent `
55
+ Did you forget to return the Ember element from the story?
56
+ Use "() => hbs('{{component}}')" or "() => { return {
57
+ template: hbs\`{{component}}\`
58
+ } }" when defining the story.
59
+ `,
60
+ });
61
+ return;
62
+ }
63
+ showMain();
64
+ render(element, canvasElement);
65
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export function defineMain(config) {
2
+ return config;
3
+ }
@@ -0,0 +1,44 @@
1
+ import { precompile } from 'ember-source/dist/ember-template-compiler.js';
2
+ import { findDistFile } from '../util';
3
+ let emberOptions;
4
+ function precompileWithPlugins(string, options) {
5
+ const precompileOptions = options;
6
+ if (emberOptions && emberOptions.polyfills) {
7
+ precompileOptions.plugins = { ast: emberOptions.polyfills };
8
+ }
9
+ return precompile(string, precompileOptions);
10
+ }
11
+ export const babel = (config, options) => {
12
+ if (options && options.presetsList) {
13
+ options.presetsList.forEach((e, index) => {
14
+ if (e.preset && e.preset.emberOptions) {
15
+ emberOptions = e.preset.emberOptions;
16
+ if (options.presetsList) {
17
+ delete options.presetsList[index].preset.emberOptions;
18
+ }
19
+ }
20
+ });
21
+ }
22
+ const babelConfigPlugins = config?.plugins || [];
23
+ const extraPlugins = [
24
+ [
25
+ require.resolve('babel-plugin-htmlbars-inline-precompile'),
26
+ {
27
+ precompile: precompileWithPlugins,
28
+ modules: {
29
+ 'ember-cli-htmlbars': 'hbs',
30
+ 'ember-cli-htmlbars-inline-precompile': 'default',
31
+ 'htmlbars-inline-precompile': 'default',
32
+ },
33
+ },
34
+ ],
35
+ [require.resolve('babel-plugin-ember-modules-api-polyfill')],
36
+ ];
37
+ return {
38
+ ...config,
39
+ plugins: [...babelConfigPlugins, ...extraPlugins],
40
+ };
41
+ };
42
+ export const previewAnnotations = (entry = []) => {
43
+ return [...entry, findDistFile(__dirname, 'client/preview/config')];
44
+ };
@@ -0,0 +1,8 @@
1
+ import { hasDocsOrControls } from 'storybook/internal/docs-tools';
2
+ import { findDistFile } from '../util';
3
+ export const previewAnnotations = (entry = [], options) => {
4
+ if (!hasDocsOrControls(options)) {
5
+ return entry;
6
+ }
7
+ return [...entry, findDistFile(__dirname, 'client/preview/docs/config')];
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/ember",
3
- "version": "9.0.0-beta.1",
3
+ "version": "9.0.0-beta.11",
4
4
  "description": "Storybook for Ember: Develop Ember Component in isolation with Hot Reloading.",
5
5
  "homepage": "https://github.com/storybookjs/storybook/tree/next/code/frameworks/ember",
6
6
  "bugs": {
@@ -49,16 +49,14 @@
49
49
  "prep": "jiti ../../../scripts/prepare/tsc.ts"
50
50
  },
51
51
  "dependencies": {
52
- "@storybook/builder-webpack5": "9.0.0-beta.1",
52
+ "@storybook/builder-webpack5": "9.0.0-beta.11",
53
53
  "@storybook/global": "^5.0.0",
54
54
  "babel-loader": "9.1.3",
55
- "find-up": "^5.0.0",
56
- "ts-dedent": "^2.0.0"
55
+ "find-up": "^5.0.0"
57
56
  },
58
57
  "devDependencies": {
59
- "@types/babel__preset-env": "^7.10.0",
60
58
  "ember-source": "~3.28.1",
61
- "typescript": "^5.7.3"
59
+ "typescript": "^5.8.3"
62
60
  },
63
61
  "peerDependencies": {
64
62
  "@babel/core": "*",
@@ -67,7 +65,7 @@
67
65
  "ember-source": "~3.28.1 || ^4.0.0",
68
66
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
69
67
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
70
- "storybook": "^9.0.0-beta.1"
68
+ "storybook": "^9.0.0-beta.11"
71
69
  },
72
70
  "engines": {
73
71
  "node": ">=20.0.0"