@teambit/preview 0.0.555 → 0.0.559
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/package.json +40 -25
- package/tsconfig.json +1 -1
- package/bundling-strategy.ts +0 -21
- package/events/click-inside-an-iframe.ts +0 -14
- package/events/index.ts +0 -1
- package/exceptions/bundling-strategy-not-found.ts +0 -5
- package/exceptions/index.ts +0 -3
- package/exceptions/preview-artifact-not-found.ts +0 -8
- package/exceptions/preview-not-found.ts +0 -5
- package/execution-ref.ts +0 -25
- package/generate-link.ts +0 -21
- package/index.ts +0 -8
- package/mk-temp-dir.ts +0 -7
- package/package-tar/teambit-preview-0.0.555.tgz +0 -0
- package/preview-artifact.ts +0 -12
- package/preview-context.ts +0 -5
- package/preview-definition.ts +0 -20
- package/preview-type.ts +0 -34
- package/preview.aspect.ts +0 -12
- package/preview.graphql.ts +0 -25
- package/preview.main.runtime.tsx +0 -346
- package/preview.preview.runtime.tsx +0 -148
- package/preview.route.ts +0 -56
- package/preview.start-plugin.tsx +0 -121
- package/preview.task.ts +0 -91
- package/rendering-context.ts +0 -12
- package/strategies/component-strategy.ts +0 -34
- package/strategies/env-strategy.ts +0 -118
- package/strategies/index.ts +0 -2
- package/types/asset.d.ts +0 -29
- package/types/preview-module.ts +0 -15
- package/types/style.d.ts +0 -42
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/preview",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.559",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/preview/preview",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.preview",
|
|
8
8
|
"name": "preview",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.559"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"fs-extra": "10.0.0",
|
|
@@ -17,26 +17,26 @@
|
|
|
17
17
|
"mime": "2.5.2",
|
|
18
18
|
"@babel/runtime": "7.12.18",
|
|
19
19
|
"core-js": "^3.0.0",
|
|
20
|
-
"@teambit/builder": "0.0.
|
|
21
|
-
"@teambit/bundler": "0.0.
|
|
22
|
-
"@teambit/component": "0.0.
|
|
23
|
-
"@teambit/envs": "0.0.
|
|
24
|
-
"@teambit/toolbox.path.to-windows-compatible-path": "0.0.
|
|
25
|
-
"@teambit/aspect-loader": "0.0.
|
|
26
|
-
"@teambit/cli": "0.0.
|
|
27
|
-
"@teambit/logger": "0.0.
|
|
28
|
-
"@teambit/pkg": "0.0.
|
|
29
|
-
"@teambit/pubsub": "0.0.
|
|
30
|
-
"@teambit/ui": "0.0.
|
|
31
|
-
"@teambit/workspace": "0.0.
|
|
32
|
-
"@teambit/component-id": "0.0.
|
|
33
|
-
"@teambit/express": "0.0.
|
|
34
|
-
"@teambit/ui-foundation.ui.pages.static-error": "0.0.
|
|
35
|
-
"@teambit/compiler": "0.0.
|
|
36
|
-
"@teambit/preview.cli.preview-server-status": "0.0.
|
|
37
|
-
"@teambit/preview.cli.webpack-events-listener": "0.0.
|
|
38
|
-
"@teambit/isolator": "0.0.
|
|
39
|
-
"@teambit/bit-error": "0.0.
|
|
20
|
+
"@teambit/builder": "0.0.559",
|
|
21
|
+
"@teambit/bundler": "0.0.559",
|
|
22
|
+
"@teambit/component": "0.0.559",
|
|
23
|
+
"@teambit/envs": "0.0.559",
|
|
24
|
+
"@teambit/toolbox.path.to-windows-compatible-path": "0.0.463",
|
|
25
|
+
"@teambit/aspect-loader": "0.0.559",
|
|
26
|
+
"@teambit/cli": "0.0.389",
|
|
27
|
+
"@teambit/logger": "0.0.474",
|
|
28
|
+
"@teambit/pkg": "0.0.559",
|
|
29
|
+
"@teambit/pubsub": "0.0.559",
|
|
30
|
+
"@teambit/ui": "0.0.559",
|
|
31
|
+
"@teambit/workspace": "0.0.559",
|
|
32
|
+
"@teambit/component-id": "0.0.379",
|
|
33
|
+
"@teambit/express": "0.0.478",
|
|
34
|
+
"@teambit/ui-foundation.ui.pages.static-error": "0.0.50",
|
|
35
|
+
"@teambit/compiler": "0.0.559",
|
|
36
|
+
"@teambit/preview.cli.preview-server-status": "0.0.469",
|
|
37
|
+
"@teambit/preview.cli.webpack-events-listener": "0.0.139",
|
|
38
|
+
"@teambit/isolator": "0.0.559",
|
|
39
|
+
"@teambit/bit-error": "0.0.375"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/fs-extra": "9.0.7",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"@types/jest": "^26.0.0",
|
|
50
50
|
"@types/react-dom": "^17.0.5",
|
|
51
51
|
"@types/node": "12.20.4",
|
|
52
|
-
"@teambit/preview.aspect-docs.preview": "0.0.
|
|
52
|
+
"@teambit/preview.aspect-docs.preview": "0.0.108"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@teambit/legacy": "1.0.
|
|
55
|
+
"@teambit/legacy": "1.0.175",
|
|
56
56
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
57
57
|
"react": "^16.8.0 || ^17.0.0"
|
|
58
58
|
},
|
|
@@ -80,12 +80,27 @@
|
|
|
80
80
|
"react": "-"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
|
-
"@teambit/legacy": "1.0.
|
|
83
|
+
"@teambit/legacy": "1.0.175",
|
|
84
84
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
85
85
|
"react": "^16.8.0 || ^17.0.0"
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
},
|
|
89
|
+
"files": [
|
|
90
|
+
"dist",
|
|
91
|
+
"!dist/tsconfig.tsbuildinfo",
|
|
92
|
+
"**/*.md",
|
|
93
|
+
"**/*.mdx",
|
|
94
|
+
"**/*.js",
|
|
95
|
+
"**/*.json",
|
|
96
|
+
"**/*.sass",
|
|
97
|
+
"**/*.scss",
|
|
98
|
+
"**/*.less",
|
|
99
|
+
"**/*.css",
|
|
100
|
+
"**/*.css",
|
|
101
|
+
"**/*.jpeg",
|
|
102
|
+
"**/*.gif"
|
|
103
|
+
],
|
|
89
104
|
"private": false,
|
|
90
105
|
"engines": {
|
|
91
106
|
"node": ">=12.22.0"
|
package/tsconfig.json
CHANGED
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
"skipLibCheck": true,
|
|
16
16
|
"moduleResolution": "node",
|
|
17
17
|
"esModuleInterop": true,
|
|
18
|
-
"outDir": "dist",
|
|
19
18
|
"composite": true,
|
|
20
19
|
"emitDeclarationOnly": true,
|
|
20
|
+
"outDir": "dist",
|
|
21
21
|
"experimentalDecorators": true,
|
|
22
22
|
"emitDecoratorMetadata": true,
|
|
23
23
|
"allowSyntheticDefaultImports": true,
|
package/bundling-strategy.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { BuildContext, BuiltTaskResult } from '@teambit/builder';
|
|
2
|
-
import { Target, BundlerResult, BundlerContext } from '@teambit/bundler';
|
|
3
|
-
import { PreviewDefinition } from './preview-definition';
|
|
4
|
-
import { PreviewTask } from './preview.task';
|
|
5
|
-
|
|
6
|
-
export interface BundlingStrategy {
|
|
7
|
-
/**
|
|
8
|
-
* name of the bundling strategy.
|
|
9
|
-
*/
|
|
10
|
-
name: string;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* compute bundling targets for the build context.
|
|
14
|
-
*/
|
|
15
|
-
computeTargets(context: BuildContext, previewDefs: PreviewDefinition[], previewTask: PreviewTask): Promise<Target[]>;
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* compute the results of the bundler.
|
|
19
|
-
*/
|
|
20
|
-
computeResults(context: BundlerContext, results: BundlerResult[], previewTask: PreviewTask): Promise<BuiltTaskResult>;
|
|
21
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-classes-per-file */
|
|
2
|
-
import { BitBaseEvent } from '@teambit/pubsub';
|
|
3
|
-
|
|
4
|
-
class ClickInsideAnIframeEventData {
|
|
5
|
-
constructor(private clickEvent: any) {}
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export class ClickInsideAnIframeEvent extends BitBaseEvent<ClickInsideAnIframeEventData> {
|
|
9
|
-
static readonly TYPE = 'click-inside-an-iframe';
|
|
10
|
-
|
|
11
|
-
constructor(readonly timestamp = Date.now(), readonly clickEvent) {
|
|
12
|
-
super(ClickInsideAnIframeEvent.TYPE, '0.0.1', timestamp, new ClickInsideAnIframeEventData(clickEvent));
|
|
13
|
-
}
|
|
14
|
-
}
|
package/events/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './click-inside-an-iframe';
|
package/exceptions/index.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BitError } from '@teambit/bit-error';
|
|
2
|
-
import { ComponentID } from '@teambit/component';
|
|
3
|
-
|
|
4
|
-
export class PreviewArtifactNotFound extends BitError {
|
|
5
|
-
constructor(componentId: ComponentID) {
|
|
6
|
-
super(`preview for component ${componentId.toString()} was not found`);
|
|
7
|
-
}
|
|
8
|
-
}
|
package/execution-ref.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Component, ComponentID } from '@teambit/component';
|
|
2
|
-
import type { ExecutionContext } from '@teambit/envs';
|
|
3
|
-
|
|
4
|
-
// TODO - use workspace.list() instead of this
|
|
5
|
-
export class ExecutionRef {
|
|
6
|
-
constructor(public executionCtx: ExecutionContext) {
|
|
7
|
-
this.currentComponents = executionCtx.components;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
currentComponents: Component[];
|
|
11
|
-
|
|
12
|
-
add(added: Component) {
|
|
13
|
-
this.currentComponents = this.currentComponents.concat(added);
|
|
14
|
-
}
|
|
15
|
-
remove(removed: ComponentID) {
|
|
16
|
-
this.currentComponents = this.currentComponents.filter((c) => c.id.toString() !== removed.toString());
|
|
17
|
-
}
|
|
18
|
-
update(next: Component) {
|
|
19
|
-
this.currentComponents = this.currentComponents.map((c) => (c.equals(next) ? next : c));
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
get(id: ComponentID) {
|
|
23
|
-
return this.currentComponents.find((x) => x.id.isEqual(id));
|
|
24
|
-
}
|
|
25
|
-
}
|
package/generate-link.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { toWindowsCompatiblePath } from '@teambit/toolbox.path.to-windows-compatible-path';
|
|
2
|
-
import type { ComponentMap } from '@teambit/component';
|
|
3
|
-
|
|
4
|
-
// :TODO refactor to building an AST and generate source code based on it.
|
|
5
|
-
export function generateLink(prefix: string, componentMap: ComponentMap<string[]>, defaultModule?: string): string {
|
|
6
|
-
return `
|
|
7
|
-
import { linkModules } from '${toWindowsCompatiblePath(require.resolve('./preview.preview.runtime'))}';
|
|
8
|
-
import harmony from '${toWindowsCompatiblePath(require.resolve('@teambit/harmony'))}';
|
|
9
|
-
${defaultModule ? `const defaultModule = require('${toWindowsCompatiblePath(defaultModule)}'` : ''});
|
|
10
|
-
linkModules('${prefix}', defaultModule, {
|
|
11
|
-
${componentMap
|
|
12
|
-
.toArray()
|
|
13
|
-
.map(([component, modulePaths]: any) => {
|
|
14
|
-
return `'${component.id.fullName}': [${modulePaths
|
|
15
|
-
.map((path) => `require('${toWindowsCompatiblePath(path)}')`)
|
|
16
|
-
.join(', ')}]`;
|
|
17
|
-
})
|
|
18
|
-
.join(',\n')}
|
|
19
|
-
});
|
|
20
|
-
`;
|
|
21
|
-
}
|
package/index.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { PreviewAspect as default, PreviewAspect, PreviewRuntime } from './preview.aspect';
|
|
2
|
-
|
|
3
|
-
export * from './events';
|
|
4
|
-
export type { PreviewMain } from './preview.main.runtime';
|
|
5
|
-
export type { PreviewPreview } from './preview.preview.runtime';
|
|
6
|
-
export { PreviewDefinition } from './preview-definition';
|
|
7
|
-
export type { PreviewModule, ModuleFile } from './types/preview-module';
|
|
8
|
-
export type { RenderingContext } from './rendering-context';
|
package/mk-temp-dir.ts
DELETED
|
Binary file
|
package/preview-artifact.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';
|
|
2
|
-
import { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';
|
|
3
|
-
|
|
4
|
-
export class PreviewArtifact {
|
|
5
|
-
constructor(private artifacts: AbstractVinyl[]) {}
|
|
6
|
-
|
|
7
|
-
getFile(path: string) {
|
|
8
|
-
return this.artifacts.find((file) => {
|
|
9
|
-
return pathNormalizeToLinux(file.relative) === path;
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
}
|
package/preview-context.ts
DELETED
package/preview-definition.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Component, ComponentMap } from '@teambit/component';
|
|
2
|
-
import { ExecutionContext } from '@teambit/envs';
|
|
3
|
-
import { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';
|
|
4
|
-
|
|
5
|
-
export interface PreviewDefinition {
|
|
6
|
-
/**
|
|
7
|
-
* extension preview prefix
|
|
8
|
-
*/
|
|
9
|
-
prefix: string;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* path of the default template to be executed.
|
|
13
|
-
*/
|
|
14
|
-
renderTemplatePath?: (context: ExecutionContext) => Promise<string>;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* get all files to require in the preview runtime.
|
|
18
|
-
*/
|
|
19
|
-
getModuleMap(components: Component[]): Promise<ComponentMap<AbstractVinyl[]>>;
|
|
20
|
-
}
|
package/preview-type.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { RenderingContext } from './rendering-context';
|
|
2
|
-
import { PreviewModule } from './types/preview-module';
|
|
3
|
-
|
|
4
|
-
export interface PreviewType {
|
|
5
|
-
/**
|
|
6
|
-
* preview name to register.
|
|
7
|
-
*/
|
|
8
|
-
name: string;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* preview render method.
|
|
12
|
-
*/
|
|
13
|
-
render(
|
|
14
|
-
componentId: string,
|
|
15
|
-
linkedModules: PreviewModule<any>,
|
|
16
|
-
includedPreviews: string[],
|
|
17
|
-
renderingContext: RenderingContext
|
|
18
|
-
): void;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* determine if this will be the default preview to render.
|
|
22
|
-
*/
|
|
23
|
-
default?: boolean;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* which other extension modules to include in the preview context.
|
|
27
|
-
*/
|
|
28
|
-
include?: string[];
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* select relevant information to show in preview context
|
|
32
|
-
*/
|
|
33
|
-
selectPreviewModel?: (componentId: string, module: PreviewModule) => any;
|
|
34
|
-
}
|
package/preview.aspect.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Aspect, RuntimeDefinition } from '@teambit/harmony';
|
|
2
|
-
|
|
3
|
-
export const PreviewRuntime = new RuntimeDefinition('preview');
|
|
4
|
-
|
|
5
|
-
export const PreviewAspect = Aspect.create({
|
|
6
|
-
id: 'teambit.preview/preview',
|
|
7
|
-
dependencies: [],
|
|
8
|
-
defaultConfig: {},
|
|
9
|
-
declareRuntime: PreviewRuntime,
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
export default PreviewAspect;
|
package/preview.graphql.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Component } from '@teambit/component';
|
|
2
|
-
import gql from 'graphql-tag';
|
|
3
|
-
|
|
4
|
-
import { PreviewMain } from './preview.main.runtime';
|
|
5
|
-
|
|
6
|
-
export function previewSchema(previewExtension: PreviewMain) {
|
|
7
|
-
return {
|
|
8
|
-
typeDefs: gql`
|
|
9
|
-
type Preview {
|
|
10
|
-
url: String!
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
extend type Component {
|
|
14
|
-
preview: Preview
|
|
15
|
-
}
|
|
16
|
-
`,
|
|
17
|
-
resolvers: {
|
|
18
|
-
Component: {
|
|
19
|
-
preview: (component: Component) => {
|
|
20
|
-
return previewExtension.getPreview(component);
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
}
|