@storybook/angular 6.5.0-alpha.28 → 6.5.0-alpha.31
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/ts3.9/builders/build-storybook/index.js +33 -84
- package/dist/ts3.9/builders/start-storybook/index.js +40 -91
- package/dist/ts3.9/builders/utils/build-standalone-errors-handler.js +13 -11
- package/dist/ts3.9/builders/utils/run-compodoc.js +19 -25
- package/dist/ts3.9/client/preview/angular/app.token.js +1 -1
- package/dist/ts3.9/client/preview/angular/components/app.component.js +55 -59
- package/dist/ts3.9/client/preview/angular/helpers.js +66 -80
- package/dist/ts3.9/client/preview/angular-beta/AbstractRenderer.js +77 -125
- package/dist/ts3.9/client/preview/angular-beta/CanvasRenderer.js +18 -81
- package/dist/ts3.9/client/preview/angular-beta/ComputesTemplateFromComponent.js +53 -73
- package/dist/ts3.9/client/preview/angular-beta/DocsRenderer.js +41 -127
- package/dist/ts3.9/client/preview/angular-beta/RendererFactory.js +30 -66
- package/dist/ts3.9/client/preview/angular-beta/StorybookModule.js +42 -46
- package/dist/ts3.9/client/preview/angular-beta/StorybookProvider.js +15 -17
- package/dist/ts3.9/client/preview/angular-beta/StorybookWrapperComponent.js +63 -92
- package/dist/ts3.9/client/preview/angular-beta/utils/NgComponentAnalyzer.js +29 -49
- package/dist/ts3.9/client/preview/angular-beta/utils/NgModulesAnalyzer.js +10 -10
- package/dist/ts3.9/client/preview/decorateStory.js +18 -40
- package/dist/ts3.9/client/preview/decorators.js +27 -46
- package/dist/ts3.9/client/preview/globals.js +2 -2
- package/dist/ts3.9/client/preview/index.js +8 -21
- package/dist/ts3.9/client/preview/render.js +17 -56
- package/dist/ts3.9/demo/button.component.js +31 -22
- package/dist/ts3.9/demo/welcome.component.js +85 -18
- package/dist/ts3.9/server/angular-cli-webpack-12.2.x.js +38 -81
- package/dist/ts3.9/server/angular-cli-webpack-13.x.x.js +42 -85
- package/dist/ts3.9/server/angular-cli-webpack-older.js +77 -123
- package/dist/ts3.9/server/angular-devkit-build-webpack.js +72 -133
- package/dist/ts3.9/server/angular-read-workspace.js +44 -78
- package/dist/ts3.9/server/build.js +10 -47
- package/dist/ts3.9/server/create-fork-ts-checker-plugin.js +2 -2
- package/dist/ts3.9/server/framework-preset-angular-cli.js +111 -188
- package/dist/ts3.9/server/framework-preset-angular-ivy.js +35 -92
- package/dist/ts3.9/server/framework-preset-angular.js +62 -115
- package/dist/ts3.9/server/index.js +2 -2
- package/dist/ts3.9/server/ngx-template-loader/index.js +15 -15
- package/dist/ts3.9/server/options.js +1 -1
- package/dist/ts3.9/server/preset.js +4 -13
- package/dist/ts3.9/server/ts_config.js +5 -5
- package/dist/ts3.9/server/utils/filter-out-styling-rules.js +4 -4
- package/dist/ts3.9/server/utils/module-is-available.js +1 -1
- package/dist/ts3.9/server/utils/normalize-asset-patterns.js +16 -31
- package/dist/ts3.9/server/utils/normalize-optimization.js +3 -3
- package/package.json +9 -9
- package/standalone.d.ts +3 -5
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,97 +8,57 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
9
|
});
|
|
21
10
|
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
13
|
};
|
|
52
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
15
|
+
const architect_1 = require("@angular-devkit/architect");
|
|
16
|
+
const rxjs_1 = require("rxjs");
|
|
17
|
+
const operators_1 = require("rxjs/operators");
|
|
18
|
+
const find_up_1 = require("find-up");
|
|
57
19
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
20
|
+
const standalone_1 = __importDefault(require("@storybook/angular/standalone"));
|
|
21
|
+
const run_compodoc_1 = require("../utils/run-compodoc");
|
|
22
|
+
const build_standalone_errors_handler_1 = require("../utils/build-standalone-errors-handler");
|
|
61
23
|
exports.default = architect_1.createBuilder(commandBuilder);
|
|
62
24
|
function commandBuilder(options, context) {
|
|
63
|
-
return rxjs_1.from(setup(options, context)).pipe(operators_1.switchMap(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
? run_compodoc_1.runCompodoc({ compodocArgs: options.compodocArgs, tsconfig: tsConfig }, context).pipe(operators_1.mapTo({ tsConfig: tsConfig }))
|
|
25
|
+
return rxjs_1.from(setup(options, context)).pipe(operators_1.switchMap(({ tsConfig }) => {
|
|
26
|
+
const runCompodoc$ = options.compodoc
|
|
27
|
+
? run_compodoc_1.runCompodoc({ compodocArgs: options.compodocArgs, tsconfig: tsConfig }, context).pipe(operators_1.mapTo({ tsConfig }))
|
|
67
28
|
: rxjs_1.of({});
|
|
68
|
-
return runCompodoc$.pipe(operators_1.mapTo({ tsConfig
|
|
69
|
-
}), operators_1.map(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
quiet: quiet,
|
|
29
|
+
return runCompodoc$.pipe(operators_1.mapTo({ tsConfig }));
|
|
30
|
+
}), operators_1.map(({ tsConfig }) => {
|
|
31
|
+
const { browserTarget, stylePreprocessorOptions, styles, configDir, docs, loglevel, outputDir, quiet, } = options;
|
|
32
|
+
const standaloneOptions = {
|
|
33
|
+
configDir,
|
|
34
|
+
docs,
|
|
35
|
+
loglevel,
|
|
36
|
+
outputDir,
|
|
37
|
+
quiet,
|
|
78
38
|
angularBrowserTarget: browserTarget,
|
|
79
39
|
angularBuilderContext: context,
|
|
80
|
-
angularBuilderOptions:
|
|
81
|
-
tsConfig
|
|
40
|
+
angularBuilderOptions: Object.assign(Object.assign({}, (stylePreprocessorOptions ? { stylePreprocessorOptions } : {})), (styles ? { styles } : {})),
|
|
41
|
+
tsConfig,
|
|
82
42
|
};
|
|
83
43
|
return standaloneOptions;
|
|
84
|
-
}), operators_1.switchMap(
|
|
44
|
+
}), operators_1.switchMap((standaloneOptions) => runInstance(Object.assign(Object.assign({}, standaloneOptions), { mode: 'static' }))), operators_1.map(() => {
|
|
85
45
|
return { success: true };
|
|
86
46
|
}));
|
|
87
47
|
}
|
|
88
48
|
function setup(options, context) {
|
|
89
49
|
var _a, _b;
|
|
90
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
_e = [_f.sent()];
|
|
101
|
-
return [4 /*yield*/, context.getBuilderNameForTarget(browserTarget)];
|
|
102
|
-
case 2: return [4 /*yield*/, _d.apply(_c, _e.concat([_f.sent()]))];
|
|
103
|
-
case 3:
|
|
104
|
-
browserOptions = _f.sent();
|
|
105
|
-
_f.label = 4;
|
|
106
|
-
case 4: return [2 /*return*/, {
|
|
107
|
-
tsConfig: (_b = (_a = options.tsConfig) !== null && _a !== void 0 ? _a : find_up_1.sync('tsconfig.json', { cwd: options.configDir })) !== null && _b !== void 0 ? _b : browserOptions.tsConfig,
|
|
108
|
-
}];
|
|
109
|
-
}
|
|
110
|
-
});
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
let browserOptions;
|
|
52
|
+
let browserTarget;
|
|
53
|
+
if (options.browserTarget) {
|
|
54
|
+
browserTarget = architect_1.targetFromTargetString(options.browserTarget);
|
|
55
|
+
browserOptions = yield context.validateOptions(yield context.getTargetOptions(browserTarget), yield context.getBuilderNameForTarget(browserTarget));
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
tsConfig: (_b = (_a = options.tsConfig) !== null && _a !== void 0 ? _a : find_up_1.sync('tsconfig.json', { cwd: options.configDir })) !== null && _b !== void 0 ? _b : browserOptions.tsConfig,
|
|
59
|
+
};
|
|
111
60
|
});
|
|
112
61
|
}
|
|
113
62
|
function runInstance(options) {
|
|
114
|
-
return rxjs_1.from(standalone_1.default(options)).pipe(operators_1.catchError(
|
|
63
|
+
return rxjs_1.from(standalone_1.default(options)).pipe(operators_1.catchError((error) => rxjs_1.throwError(build_standalone_errors_handler_1.buildStandaloneErrorHandler(error))));
|
|
115
64
|
}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,106 +8,66 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
9
|
});
|
|
21
10
|
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
13
|
};
|
|
52
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
15
|
+
const architect_1 = require("@angular-devkit/architect");
|
|
16
|
+
const rxjs_1 = require("rxjs");
|
|
17
|
+
const operators_1 = require("rxjs/operators");
|
|
18
|
+
const find_up_1 = require("find-up");
|
|
57
19
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
20
|
+
const standalone_1 = __importDefault(require("@storybook/angular/standalone"));
|
|
21
|
+
const run_compodoc_1 = require("../utils/run-compodoc");
|
|
22
|
+
const build_standalone_errors_handler_1 = require("../utils/build-standalone-errors-handler");
|
|
61
23
|
exports.default = architect_1.createBuilder(commandBuilder);
|
|
62
24
|
function commandBuilder(options, context) {
|
|
63
|
-
return rxjs_1.from(setup(options, context)).pipe(operators_1.switchMap(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
? run_compodoc_1.runCompodoc({ compodocArgs: options.compodocArgs, tsconfig: tsConfig }, context).pipe(operators_1.mapTo({ tsConfig: tsConfig }))
|
|
25
|
+
return rxjs_1.from(setup(options, context)).pipe(operators_1.switchMap(({ tsConfig }) => {
|
|
26
|
+
const runCompodoc$ = options.compodoc
|
|
27
|
+
? run_compodoc_1.runCompodoc({ compodocArgs: options.compodocArgs, tsconfig: tsConfig }, context).pipe(operators_1.mapTo({ tsConfig }))
|
|
67
28
|
: rxjs_1.of({});
|
|
68
|
-
return runCompodoc$.pipe(operators_1.mapTo({ tsConfig
|
|
69
|
-
}), operators_1.map(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
sslKey: sslKey,
|
|
29
|
+
return runCompodoc$.pipe(operators_1.mapTo({ tsConfig }));
|
|
30
|
+
}), operators_1.map(({ tsConfig }) => {
|
|
31
|
+
const { browserTarget, stylePreprocessorOptions, styles, ci, configDir, docs, host, https, port, quiet, smokeTest, sslCa, sslCert, sslKey, } = options;
|
|
32
|
+
const standaloneOptions = {
|
|
33
|
+
ci,
|
|
34
|
+
configDir,
|
|
35
|
+
docs,
|
|
36
|
+
host,
|
|
37
|
+
https,
|
|
38
|
+
port,
|
|
39
|
+
quiet,
|
|
40
|
+
smokeTest,
|
|
41
|
+
sslCa,
|
|
42
|
+
sslCert,
|
|
43
|
+
sslKey,
|
|
84
44
|
angularBrowserTarget: browserTarget,
|
|
85
45
|
angularBuilderContext: context,
|
|
86
|
-
angularBuilderOptions:
|
|
87
|
-
tsConfig
|
|
46
|
+
angularBuilderOptions: Object.assign(Object.assign({}, (stylePreprocessorOptions ? { stylePreprocessorOptions } : {})), (styles ? { styles } : {})),
|
|
47
|
+
tsConfig,
|
|
88
48
|
};
|
|
89
49
|
return standaloneOptions;
|
|
90
|
-
}), operators_1.switchMap(
|
|
50
|
+
}), operators_1.switchMap((standaloneOptions) => runInstance(standaloneOptions)), operators_1.map(() => {
|
|
91
51
|
return { success: true };
|
|
92
52
|
}));
|
|
93
53
|
}
|
|
94
54
|
function setup(options, context) {
|
|
95
55
|
var _a, _b;
|
|
96
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
_e = [_f.sent()];
|
|
107
|
-
return [4 /*yield*/, context.getBuilderNameForTarget(browserTarget)];
|
|
108
|
-
case 2: return [4 /*yield*/, _d.apply(_c, _e.concat([_f.sent()]))];
|
|
109
|
-
case 3:
|
|
110
|
-
browserOptions = _f.sent();
|
|
111
|
-
_f.label = 4;
|
|
112
|
-
case 4: return [2 /*return*/, {
|
|
113
|
-
tsConfig: (_b = (_a = options.tsConfig) !== null && _a !== void 0 ? _a : find_up_1.sync('tsconfig.json', { cwd: options.configDir })) !== null && _b !== void 0 ? _b : browserOptions.tsConfig,
|
|
114
|
-
}];
|
|
115
|
-
}
|
|
116
|
-
});
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
let browserOptions;
|
|
58
|
+
let browserTarget;
|
|
59
|
+
if (options.browserTarget) {
|
|
60
|
+
browserTarget = architect_1.targetFromTargetString(options.browserTarget);
|
|
61
|
+
browserOptions = yield context.validateOptions(yield context.getTargetOptions(browserTarget), yield context.getBuilderNameForTarget(browserTarget));
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
tsConfig: (_b = (_a = options.tsConfig) !== null && _a !== void 0 ? _a : find_up_1.sync('tsconfig.json', { cwd: options.configDir })) !== null && _b !== void 0 ? _b : browserOptions.tsConfig,
|
|
65
|
+
};
|
|
117
66
|
});
|
|
118
67
|
}
|
|
119
68
|
function runInstance(options) {
|
|
120
|
-
return new rxjs_1.Observable(
|
|
69
|
+
return new rxjs_1.Observable((observer) => {
|
|
121
70
|
// This Observable intentionally never complete, leaving the process running ;)
|
|
122
|
-
standalone_1.default(options).then(
|
|
71
|
+
standalone_1.default(options).then(() => observer.next(), (error) => observer.error(build_standalone_errors_handler_1.buildStandaloneErrorHandler(error)));
|
|
123
72
|
});
|
|
124
73
|
}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
-
return cooked;
|
|
5
|
-
};
|
|
6
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
4
|
};
|
|
9
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
6
|
exports.buildStandaloneErrorHandler = void 0;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
exports.buildStandaloneErrorHandler =
|
|
7
|
+
const node_logger_1 = require("@storybook/node-logger");
|
|
8
|
+
const ts_dedent_1 = __importDefault(require("ts-dedent"));
|
|
9
|
+
exports.buildStandaloneErrorHandler = (error) => {
|
|
14
10
|
var _a;
|
|
15
11
|
// Duplicate code for Standalone error handling
|
|
16
12
|
// Source: https://github.com/storybookjs/storybook/blob/39c7ba09ad84fbd466f9c25d5b92791a5450b9f6/lib/core-server/src/build-dev.ts#L136
|
|
@@ -20,17 +16,23 @@ exports.buildStandaloneErrorHandler = function (error) {
|
|
|
20
16
|
node_logger_1.logger.error(error.error);
|
|
21
17
|
}
|
|
22
18
|
else if (error.stats && error.stats.compilation.errors) {
|
|
23
|
-
error.stats.compilation.errors.forEach(
|
|
19
|
+
error.stats.compilation.errors.forEach((e) => node_logger_1.logger.plain(e));
|
|
24
20
|
}
|
|
25
21
|
else {
|
|
26
22
|
node_logger_1.logger.error(error);
|
|
27
23
|
}
|
|
28
24
|
}
|
|
29
25
|
else if ((_a = error.compilation) === null || _a === void 0 ? void 0 : _a.errors) {
|
|
30
|
-
error.compilation.errors.forEach(
|
|
26
|
+
error.compilation.errors.forEach((e) => node_logger_1.logger.plain(e));
|
|
31
27
|
}
|
|
32
28
|
node_logger_1.logger.line();
|
|
33
29
|
return error.close
|
|
34
|
-
? ts_dedent_1.default
|
|
30
|
+
? ts_dedent_1.default `
|
|
31
|
+
FATAL broken build!, will close the process,
|
|
32
|
+
Fix the error below and restart storybook.
|
|
33
|
+
`
|
|
34
|
+
: ts_dedent_1.default `
|
|
35
|
+
Broken build, fix the error above.
|
|
36
|
+
You may need to refresh the browser.
|
|
37
|
+
`;
|
|
35
38
|
};
|
|
36
|
-
var templateObject_1, templateObject_2;
|
|
@@ -18,48 +18,42 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
22
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
23
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
24
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
25
|
-
r[k] = a[j];
|
|
26
|
-
return r;
|
|
27
|
-
};
|
|
28
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
22
|
exports.runCompodoc = void 0;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
const child_process_1 = require("child_process");
|
|
24
|
+
const rxjs_1 = require("rxjs");
|
|
25
|
+
const path = __importStar(require("path"));
|
|
26
|
+
const hasTsConfigArg = (args) => args.indexOf('-p') !== -1;
|
|
34
27
|
// path.relative is necessary to workaround a compodoc issue with
|
|
35
28
|
// absolute paths on windows machines
|
|
36
|
-
|
|
29
|
+
const toRelativePath = (pathToTsConfig) => {
|
|
37
30
|
return path.isAbsolute(pathToTsConfig) ? path.relative('.', pathToTsConfig) : pathToTsConfig;
|
|
38
31
|
};
|
|
39
|
-
exports.runCompodoc =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
32
|
+
exports.runCompodoc = ({ compodocArgs, tsconfig }, context) => {
|
|
33
|
+
return new rxjs_1.Observable((observer) => {
|
|
34
|
+
const tsConfigPath = toRelativePath(tsconfig);
|
|
35
|
+
const finalCompodocArgs = [
|
|
36
|
+
'compodoc',
|
|
37
|
+
// Default options
|
|
38
|
+
...(hasTsConfigArg(compodocArgs) ? [] : ['-p', tsConfigPath]),
|
|
46
39
|
'-d',
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
`${context.workspaceRoot}`,
|
|
41
|
+
...compodocArgs,
|
|
42
|
+
];
|
|
49
43
|
try {
|
|
50
44
|
context.logger.info(finalCompodocArgs.join(' '));
|
|
51
|
-
|
|
45
|
+
const child = child_process_1.spawn('npx', finalCompodocArgs, {
|
|
52
46
|
cwd: context.workspaceRoot,
|
|
53
47
|
env: process.env,
|
|
54
48
|
shell: true,
|
|
55
49
|
});
|
|
56
|
-
child.stdout.on('data',
|
|
50
|
+
child.stdout.on('data', (data) => {
|
|
57
51
|
context.logger.info(data.toString());
|
|
58
52
|
});
|
|
59
|
-
child.stderr.on('data',
|
|
53
|
+
child.stderr.on('data', (data) => {
|
|
60
54
|
context.logger.error(data.toString());
|
|
61
55
|
});
|
|
62
|
-
child.on('close',
|
|
56
|
+
child.on('close', (code) => {
|
|
63
57
|
if (code === 0) {
|
|
64
58
|
observer.next();
|
|
65
59
|
observer.complete();
|
|
@@ -18,103 +18,100 @@ exports.AppComponent = void 0;
|
|
|
18
18
|
// to provide @Inputs and subscribe to @Outputs, see
|
|
19
19
|
// https://github.com/angular/angular/issues/15360
|
|
20
20
|
// For the time being, the ViewContainerRef approach works pretty well.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
const core_1 = require("@angular/core");
|
|
22
|
+
const rxjs_1 = require("rxjs");
|
|
23
|
+
const operators_1 = require("rxjs/operators");
|
|
24
|
+
const app_token_1 = require("../app.token");
|
|
25
|
+
let AppComponent = class AppComponent {
|
|
26
|
+
constructor(cfr, changeDetectorRef, data) {
|
|
27
27
|
this.cfr = cfr;
|
|
28
28
|
this.changeDetectorRef = changeDetectorRef;
|
|
29
29
|
this.data = data;
|
|
30
30
|
this.previousValues = {};
|
|
31
31
|
this.propSubscriptions = new Map();
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
var instance = componentRef.instance;
|
|
33
|
+
ngOnInit() {
|
|
34
|
+
this.data.pipe(operators_1.first()).subscribe((data) => {
|
|
35
|
+
this.target.clear();
|
|
36
|
+
const compFactory = this.cfr.resolveComponentFactory(data.component);
|
|
37
|
+
const componentRef = this.target.createComponent(compFactory);
|
|
38
|
+
const { instance } = componentRef;
|
|
40
39
|
// For some reason, manual change detection ref is only working when getting the ref from the injector (rather than componentRef.changeDetectorRef)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
const childChangeDetectorRef = componentRef.injector.get(core_1.ChangeDetectorRef);
|
|
41
|
+
this.subscription = this.data.subscribe((newData) => {
|
|
42
|
+
this.setProps(instance, newData);
|
|
44
43
|
childChangeDetectorRef.markForCheck();
|
|
45
44
|
// Must detect changes on the current component in order to update any changes in child component's @HostBinding properties (angular/angular#22560)
|
|
46
|
-
|
|
45
|
+
this.changeDetectorRef.detectChanges();
|
|
47
46
|
});
|
|
48
47
|
});
|
|
49
|
-
}
|
|
50
|
-
|
|
48
|
+
}
|
|
49
|
+
ngOnDestroy() {
|
|
51
50
|
this.target.clear();
|
|
52
51
|
if (this.subscription) {
|
|
53
52
|
this.subscription.unsubscribe();
|
|
54
53
|
}
|
|
55
|
-
this.propSubscriptions.forEach(
|
|
54
|
+
this.propSubscriptions.forEach((v) => {
|
|
56
55
|
if (!v.sub.closed) {
|
|
57
56
|
v.sub.unsubscribe();
|
|
58
57
|
}
|
|
59
58
|
});
|
|
60
59
|
this.propSubscriptions.clear();
|
|
61
|
-
}
|
|
60
|
+
}
|
|
62
61
|
/**
|
|
63
62
|
* Set inputs and outputs
|
|
64
63
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var value = props[key];
|
|
72
|
-
var instanceProperty = instance[key];
|
|
64
|
+
setProps(instance, { props = {} }) {
|
|
65
|
+
const changes = {};
|
|
66
|
+
const hasNgOnChangesHook = !!instance.ngOnChanges;
|
|
67
|
+
Object.keys(props).forEach((key) => {
|
|
68
|
+
const value = props[key];
|
|
69
|
+
const instanceProperty = instance[key];
|
|
73
70
|
if (!(instanceProperty instanceof core_1.EventEmitter) && value !== undefined && value !== null) {
|
|
74
71
|
// eslint-disable-next-line no-param-reassign
|
|
75
72
|
instance[key] = value;
|
|
76
73
|
if (hasNgOnChangesHook) {
|
|
77
|
-
|
|
74
|
+
const previousValue = this.previousValues[key];
|
|
78
75
|
if (previousValue !== value) {
|
|
79
|
-
changes[key] = new core_1.SimpleChange(previousValue, value, !Object.prototype.hasOwnProperty.call(
|
|
80
|
-
|
|
76
|
+
changes[key] = new core_1.SimpleChange(previousValue, value, !Object.prototype.hasOwnProperty.call(this.previousValues, key));
|
|
77
|
+
this.previousValues[key] = value;
|
|
81
78
|
}
|
|
82
79
|
}
|
|
83
80
|
}
|
|
84
81
|
else if (typeof value === 'function' && key !== 'ngModelChange') {
|
|
85
|
-
|
|
82
|
+
this.setPropSubscription(key, instanceProperty, value);
|
|
86
83
|
}
|
|
87
84
|
});
|
|
88
85
|
this.callNgOnChangesHook(instance, changes);
|
|
89
86
|
this.setNgModel(instance, props);
|
|
90
|
-
}
|
|
87
|
+
}
|
|
91
88
|
/**
|
|
92
89
|
* Manually call 'ngOnChanges' hook because angular doesn't do that for dynamic components
|
|
93
90
|
* Issue: [https://github.com/angular/angular/issues/8903]
|
|
94
91
|
*/
|
|
95
|
-
|
|
92
|
+
callNgOnChangesHook(instance, changes) {
|
|
96
93
|
if (Object.keys(changes).length) {
|
|
97
94
|
instance.ngOnChanges(changes);
|
|
98
95
|
}
|
|
99
|
-
}
|
|
96
|
+
}
|
|
100
97
|
/**
|
|
101
98
|
* If component implements ControlValueAccessor interface try to set ngModel
|
|
102
99
|
*/
|
|
103
|
-
|
|
100
|
+
setNgModel(instance, props) {
|
|
104
101
|
if (props.ngModel) {
|
|
105
102
|
instance.writeValue(props.ngModel);
|
|
106
103
|
}
|
|
107
104
|
if (typeof props.ngModelChange === 'function') {
|
|
108
105
|
instance.registerOnChange(props.ngModelChange);
|
|
109
106
|
}
|
|
110
|
-
}
|
|
107
|
+
}
|
|
111
108
|
/**
|
|
112
109
|
* Store ref to subscription for cleanup in 'ngOnDestroy' and check if
|
|
113
110
|
* observable needs to be resubscribed to, before creating a new subscription.
|
|
114
111
|
*/
|
|
115
|
-
|
|
112
|
+
setPropSubscription(key, instanceProperty, value) {
|
|
116
113
|
if (this.propSubscriptions.has(key)) {
|
|
117
|
-
|
|
114
|
+
const v = this.propSubscriptions.get(key);
|
|
118
115
|
if (v.prop === value) {
|
|
119
116
|
// Prop hasn't changed, so the existing subscription can stay.
|
|
120
117
|
return;
|
|
@@ -124,23 +121,22 @@ var AppComponent = /** @class */ (function () {
|
|
|
124
121
|
v.sub.unsubscribe();
|
|
125
122
|
}
|
|
126
123
|
}
|
|
127
|
-
|
|
128
|
-
this.propSubscriptions.set(key, { prop: value, sub
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}());
|
|
124
|
+
const sub = instanceProperty.subscribe(value);
|
|
125
|
+
this.propSubscriptions.set(key, { prop: value, sub });
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
__decorate([
|
|
129
|
+
core_1.ViewChild('target', { read: core_1.ViewContainerRef, static: true }),
|
|
130
|
+
__metadata("design:type", core_1.ViewContainerRef)
|
|
131
|
+
], AppComponent.prototype, "target", void 0);
|
|
132
|
+
AppComponent = __decorate([
|
|
133
|
+
core_1.Component({
|
|
134
|
+
selector: 'storybook-dynamic-app-root',
|
|
135
|
+
template: '<ng-template #target></ng-template>',
|
|
136
|
+
}),
|
|
137
|
+
__param(2, core_1.Inject(app_token_1.STORY)),
|
|
138
|
+
__metadata("design:paramtypes", [core_1.ComponentFactoryResolver,
|
|
139
|
+
core_1.ChangeDetectorRef,
|
|
140
|
+
rxjs_1.Observable])
|
|
141
|
+
], AppComponent);
|
|
146
142
|
exports.AppComponent = AppComponent;
|