@teambit/isolator 0.0.0-13b05e0f967d2f43d6f3398f10eace82418bdb62

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.
Files changed (46) hide show
  1. package/capsule/capsule.ts +138 -0
  2. package/capsule/container-exec.ts +31 -0
  3. package/capsule/container.ts +128 -0
  4. package/capsule/index.ts +3 -0
  5. package/dist/capsule/capsule.d.ts +75 -0
  6. package/dist/capsule/capsule.js +194 -0
  7. package/dist/capsule/capsule.js.map +1 -0
  8. package/dist/capsule/container-exec.d.ts +13 -0
  9. package/dist/capsule/container-exec.js +51 -0
  10. package/dist/capsule/container-exec.js.map +1 -0
  11. package/dist/capsule/container.d.ts +34 -0
  12. package/dist/capsule/container.js +153 -0
  13. package/dist/capsule/container.js.map +1 -0
  14. package/dist/capsule/index.d.ts +3 -0
  15. package/dist/capsule/index.js +47 -0
  16. package/dist/capsule/index.js.map +1 -0
  17. package/dist/capsule-list.d.ts +22 -0
  18. package/dist/capsule-list.js +100 -0
  19. package/dist/capsule-list.js.map +1 -0
  20. package/dist/esm.mjs +13 -0
  21. package/dist/index.d.ts +6 -0
  22. package/dist/index.js +85 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/isolator.aspect.d.ts +2 -0
  25. package/dist/isolator.aspect.js +20 -0
  26. package/dist/isolator.aspect.js.map +1 -0
  27. package/dist/isolator.composition.d.ts +1 -0
  28. package/dist/isolator.composition.js +29 -0
  29. package/dist/isolator.composition.js.map +1 -0
  30. package/dist/isolator.docs.md +41 -0
  31. package/dist/isolator.main.runtime.d.ts +280 -0
  32. package/dist/isolator.main.runtime.js +1167 -0
  33. package/dist/isolator.main.runtime.js.map +1 -0
  34. package/dist/network.d.ts +122 -0
  35. package/dist/network.js +182 -0
  36. package/dist/network.js.map +1 -0
  37. package/dist/preview-1752574874379.js +7 -0
  38. package/dist/symlink-dependencies-to-capsules.d.ts +6 -0
  39. package/dist/symlink-dependencies-to-capsules.js +61 -0
  40. package/dist/symlink-dependencies-to-capsules.js.map +1 -0
  41. package/esm.mjs +13 -0
  42. package/isolator.composition.tsx +7 -0
  43. package/isolator.docs.md +41 -0
  44. package/package.json +93 -0
  45. package/types/asset.d.ts +41 -0
  46. package/types/style.d.ts +42 -0
@@ -0,0 +1,7 @@
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_isolator@13b05e0f967d2f43d6f3398f10eace82418bdb62/dist/isolator.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.component_isolator@13b05e0f967d2f43d6f3398f10eace82418bdb62/dist/isolator.docs.md';
3
+
4
+ export const compositions = [compositions_0];
5
+ export const overview = [overview_0];
6
+
7
+ export const compositions_metadata = {"compositions":[{"displayName":"Logo","identifier":"Logo"}]};
@@ -0,0 +1,6 @@
1
+ import { LinkDetail } from '@teambit/dependency-resolver';
2
+ import { Logger } from '@teambit/logger';
3
+ import { Capsule } from './capsule';
4
+ import CapsuleList from './capsule-list';
5
+ export declare function symlinkDependenciesToCapsules(capsules: Capsule[], capsuleList: CapsuleList, logger: Logger): Promise<Record<string, Record<string, string>>>;
6
+ export declare function symlinkOnCapsuleRoot(capsuleList: CapsuleList, logger: Logger, capsuleRoot: string): Promise<LinkDetail[]>;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.symlinkDependenciesToCapsules = symlinkDependenciesToCapsules;
7
+ exports.symlinkOnCapsuleRoot = symlinkOnCapsuleRoot;
8
+ function _pkgModules() {
9
+ const data = require("@teambit/pkg.modules.component-package-name");
10
+ _pkgModules = function () {
11
+ return data;
12
+ };
13
+ return data;
14
+ }
15
+ function _path() {
16
+ const data = _interopRequireDefault(require("path"));
17
+ _path = function () {
18
+ return data;
19
+ };
20
+ return data;
21
+ }
22
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
23
+ async function symlinkDependenciesToCapsules(capsules, capsuleList, logger) {
24
+ logger.debug(`symlinkDependenciesToCapsules, ${capsules.length} capsules`);
25
+ return Object.fromEntries(await Promise.all(capsules.map(capsule => {
26
+ return symlinkComponent(capsule.component.state._consumer, capsuleList, logger);
27
+ })));
28
+ }
29
+ async function symlinkOnCapsuleRoot(capsuleList, logger, capsuleRoot) {
30
+ const modulesPath = _path().default.join(capsuleRoot, 'node_modules');
31
+ return capsuleList.map(capsule => {
32
+ const packageName = (0, _pkgModules().componentIdToPackageName)(capsule.component.state._consumer);
33
+ const dest = _path().default.join(modulesPath, packageName);
34
+ return {
35
+ from: capsule.path,
36
+ to: dest,
37
+ packageName
38
+ };
39
+ });
40
+ }
41
+ async function symlinkComponent(component, capsuleList, logger) {
42
+ const componentCapsule = capsuleList.getCapsuleIgnoreVersion(component.id);
43
+ if (!componentCapsule) throw new Error(`unable to find the capsule for ${component.id.toString()}`);
44
+ const allDeps = component.getAllDependenciesIds();
45
+ const linkResults = allDeps.reduce((acc, depId) => {
46
+ // TODO: this is dangerous - we might have 2 capsules for the same component with different version, then we might link to the wrong place
47
+ const devCapsule = capsuleList.getCapsuleIgnoreVersion(depId);
48
+ if (!devCapsule) {
49
+ // happens when a dependency is not in the workspace. (it gets installed via the package manager)
50
+ logger.debug(`symlinkComponentToCapsule: unable to find the capsule for ${depId.toStringWithoutVersion()}. skipping`);
51
+ return acc;
52
+ }
53
+ const packageName = (0, _pkgModules().componentIdToPackageName)(devCapsule.component.state._consumer);
54
+ const devCapsulePath = devCapsule.path;
55
+ acc[packageName] = `link:${devCapsulePath}`;
56
+ return acc;
57
+ }, {});
58
+ return [componentCapsule.path, linkResults];
59
+ }
60
+
61
+ //# sourceMappingURL=symlink-dependencies-to-capsules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_pkgModules","data","require","_path","_interopRequireDefault","e","__esModule","default","symlinkDependenciesToCapsules","capsules","capsuleList","logger","debug","length","Object","fromEntries","Promise","all","map","capsule","symlinkComponent","component","state","_consumer","symlinkOnCapsuleRoot","capsuleRoot","modulesPath","path","join","packageName","componentIdToPackageName","dest","from","to","componentCapsule","getCapsuleIgnoreVersion","id","Error","toString","allDeps","getAllDependenciesIds","linkResults","reduce","acc","depId","devCapsule","toStringWithoutVersion","devCapsulePath"],"sources":["symlink-dependencies-to-capsules.ts"],"sourcesContent":["import { LinkDetail } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { ComponentID } from '@teambit/component-id';\nimport { ConsumerComponent } from '@teambit/legacy.consumer-component';\nimport { componentIdToPackageName } from '@teambit/pkg.modules.component-package-name';\nimport path from 'path';\n\nimport { Capsule } from './capsule';\nimport CapsuleList from './capsule-list';\n\nexport async function symlinkDependenciesToCapsules(\n capsules: Capsule[],\n capsuleList: CapsuleList,\n logger: Logger\n): Promise<Record<string, Record<string, string>>> {\n logger.debug(`symlinkDependenciesToCapsules, ${capsules.length} capsules`);\n return Object.fromEntries(\n await Promise.all(\n capsules.map((capsule) => {\n return symlinkComponent(capsule.component.state._consumer, capsuleList, logger);\n })\n )\n );\n}\n\nexport async function symlinkOnCapsuleRoot(\n capsuleList: CapsuleList,\n logger: Logger,\n capsuleRoot: string\n): Promise<LinkDetail[]> {\n const modulesPath = path.join(capsuleRoot, 'node_modules');\n return capsuleList.map((capsule) => {\n const packageName = componentIdToPackageName(capsule.component.state._consumer);\n const dest = path.join(modulesPath, packageName);\n return {\n from: capsule.path,\n to: dest,\n packageName,\n };\n });\n}\n\nasync function symlinkComponent(\n component: ConsumerComponent,\n capsuleList: CapsuleList,\n logger: Logger\n): Promise<[string, Record<string, string>]> {\n const componentCapsule = capsuleList.getCapsuleIgnoreVersion(component.id);\n if (!componentCapsule) throw new Error(`unable to find the capsule for ${component.id.toString()}`);\n const allDeps = component.getAllDependenciesIds();\n const linkResults = allDeps.reduce((acc, depId: ComponentID) => {\n // TODO: this is dangerous - we might have 2 capsules for the same component with different version, then we might link to the wrong place\n const devCapsule = capsuleList.getCapsuleIgnoreVersion(depId);\n if (!devCapsule) {\n // happens when a dependency is not in the workspace. (it gets installed via the package manager)\n logger.debug(\n `symlinkComponentToCapsule: unable to find the capsule for ${depId.toStringWithoutVersion()}. skipping`\n );\n return acc;\n }\n const packageName = componentIdToPackageName(devCapsule.component.state._consumer);\n const devCapsulePath = devCapsule.path;\n acc[packageName] = `link:${devCapsulePath}`;\n return acc;\n }, {});\n\n return [componentCapsule.path, linkResults];\n}\n"],"mappings":";;;;;;;AAIA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,MAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAwB,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAKjB,eAAeG,6BAA6BA,CACjDC,QAAmB,EACnBC,WAAwB,EACxBC,MAAc,EACmC;EACjDA,MAAM,CAACC,KAAK,CAAC,kCAAkCH,QAAQ,CAACI,MAAM,WAAW,CAAC;EAC1E,OAAOC,MAAM,CAACC,WAAW,CACvB,MAAMC,OAAO,CAACC,GAAG,CACfR,QAAQ,CAACS,GAAG,CAAEC,OAAO,IAAK;IACxB,OAAOC,gBAAgB,CAACD,OAAO,CAACE,SAAS,CAACC,KAAK,CAACC,SAAS,EAAEb,WAAW,EAAEC,MAAM,CAAC;EACjF,CAAC,CACH,CACF,CAAC;AACH;AAEO,eAAea,oBAAoBA,CACxCd,WAAwB,EACxBC,MAAc,EACdc,WAAmB,EACI;EACvB,MAAMC,WAAW,GAAGC,eAAI,CAACC,IAAI,CAACH,WAAW,EAAE,cAAc,CAAC;EAC1D,OAAOf,WAAW,CAACQ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AAO,CAACT,gBAAgB,CAACP,IAAI,EAAEc,WAAW,CAAC;AAC7C","ignoreList":[]}
package/esm.mjs ADDED
@@ -0,0 +1,13 @@
1
+ // eslint-disable-next-line import/no-unresolved
2
+ import cjsModule from './index.js';
3
+
4
+ export const CAPSULE_READY_FILE = cjsModule.CAPSULE_READY_FILE;
5
+ export const Network = cjsModule.Network;
6
+ export const FsContainer = cjsModule.FsContainer;
7
+ export const Capsule = cjsModule.Capsule;
8
+ export const ContainerExec = cjsModule.ContainerExec;
9
+ export const IsolatorAspect = cjsModule.IsolatorAspect;
10
+ export const CapsuleList = cjsModule.CapsuleList;
11
+
12
+ export default cjsModule;
13
+
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+
3
+ export const Logo = () => (
4
+ <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>
5
+ <img style={{ width: 70 }} src="https://static.bit.dev/extensions-icons/isolator.svg" />
6
+ </div>
7
+ );
@@ -0,0 +1,41 @@
1
+ ---
2
+ description: Isolate components for build, debugging, development and testing.
3
+ labels: ['isolation', 'component', 'core aspect']
4
+ ---
5
+
6
+ ## Isolate a component
7
+
8
+ ```bash
9
+ bit create-capsule ui/button
10
+ ```
11
+
12
+ ## Entities
13
+
14
+ ### Capsule
15
+
16
+ Bit implements a filesystem capsule, which is an isolated folder containing the component files.
17
+ Capsules include the component files and links to other capsules that include the component's dependencies.
18
+
19
+ ### Network
20
+
21
+ A network is a group of capsules, related to one another by their dependencies.
22
+ A network includes a graph of all seed components given to it, as well as a list of the capsules.
23
+
24
+ Example:
25
+
26
+ ```javascript
27
+ const Network = {
28
+ graph: Graph,
29
+ capsules: CapsuleList,
30
+ };
31
+ ```
32
+
33
+ ## API
34
+
35
+ The exact particularities of this API are beyond the scope of this readme. Instead, this document opts to
36
+ provide a general description of the methods of this API and their purpose.
37
+
38
+ ### Isolator.isolateComponents
39
+
40
+ This method receives a list of components, create capsule for the components and write the components data into the capsule.
41
+ It returns a list of capsules.
package/package.json ADDED
@@ -0,0 +1,93 @@
1
+ {
2
+ "name": "@teambit/isolator",
3
+ "version": "0.0.0-13b05e0f967d2f43d6f3398f10eace82418bdb62",
4
+ "homepage": "https://bit.cloud/teambit/component/isolator",
5
+ "main": "dist/index.js",
6
+ "componentId": {
7
+ "scope": "teambit.component",
8
+ "name": "isolator",
9
+ "version": "13b05e0f967d2f43d6f3398f10eace82418bdb62"
10
+ },
11
+ "dependencies": {
12
+ "chalk": "4.1.2",
13
+ "fs-extra": "10.0.0",
14
+ "lodash": "4.17.21",
15
+ "object-hash": "2.1.1",
16
+ "p-map": "4.0.0",
17
+ "rimraf": "3.0.2",
18
+ "semver": "7.7.1",
19
+ "uuid": "8.3.2",
20
+ "@teambit/any-fs": "0.0.5",
21
+ "@teambit/capsule": "0.0.12",
22
+ "filenamify": "4.2.0",
23
+ "glob": "7.1.6",
24
+ "debug": "4.3.4",
25
+ "execa": "2.1.0",
26
+ "@teambit/component-id": "1.2.4",
27
+ "@teambit/graph.cleargraph": "0.0.11",
28
+ "@teambit/harmony": "0.4.7",
29
+ "@teambit/component": "0.0.0-3d9d268ead0c62a707430649104c753747a9cf3d",
30
+ "@teambit/dependency-resolver": "0.0.0-14c6cb2c67f08764229d9406620622549d9c47f5",
31
+ "@teambit/aspect-loader": "0.0.0-5f72409f70e9646c70610ac8f4941fddece270d4",
32
+ "@teambit/cli": "0.0.0-6994b27e4c68e32213f598d96cd073368758bd3b",
33
+ "@teambit/component-package-version": "0.0.438",
34
+ "@teambit/component.sources": "0.0.107",
35
+ "@teambit/config-store": "0.0.0-f5fbcd535d1a1050fc2537a592c05df35b10ce4d",
36
+ "@teambit/dependencies.fs.linked-dependencies": "0.0.31",
37
+ "@teambit/global-config": "0.0.0-a52ccc2c970efc0cfd58af9b2b0bccf67afe6f85",
38
+ "@teambit/graph": "0.0.0-822e7ee20eb575cea24c94a878797ea073fccbea",
39
+ "@teambit/harmony.modules.concurrency": "0.0.13",
40
+ "@teambit/legacy.constants": "0.0.12",
41
+ "@teambit/legacy.consumer-component": "0.0.56",
42
+ "@teambit/legacy.scope": "0.0.55",
43
+ "@teambit/legacy.utils": "0.0.21",
44
+ "@teambit/logger": "0.0.0-f5e3748543c4b1cc2ee84be8ebb0af38bc77daec",
45
+ "@teambit/objects": "0.0.0-f03d52e4caff861760856aa8dde248d8ac3f0f2e",
46
+ "@teambit/pkg.modules.component-package-name": "0.0.62",
47
+ "@teambit/workspace.modules.node-modules-linker": "0.0.283"
48
+ },
49
+ "devDependencies": {
50
+ "@types/fs-extra": "9.0.7",
51
+ "@types/lodash": "4.14.165",
52
+ "@types/object-hash": "1.3.4",
53
+ "@types/semver": "7.5.8",
54
+ "@types/uuid": "8.3.4",
55
+ "@types/mocha": "9.1.0",
56
+ "@teambit/harmony.envs.core-aspect-env": "0.0.69"
57
+ },
58
+ "peerDependencies": {
59
+ "react": "^17.0.0 || ^18.0.0",
60
+ "@types/react": "^17.0.73"
61
+ },
62
+ "license": "Apache-2.0",
63
+ "optionalDependencies": {},
64
+ "peerDependenciesMeta": {},
65
+ "exports": {
66
+ ".": {
67
+ "node": {
68
+ "require": "./dist/index.js",
69
+ "import": "./dist/esm.mjs"
70
+ },
71
+ "default": "./dist/index.js"
72
+ },
73
+ "./dist/*": "./dist/*",
74
+ "./artifacts/*": "./artifacts/*",
75
+ "./*": "./*.ts"
76
+ },
77
+ "private": false,
78
+ "engines": {
79
+ "node": ">=16.0.0"
80
+ },
81
+ "repository": {
82
+ "type": "git",
83
+ "url": "https://github.com/teambit/bit"
84
+ },
85
+ "keywords": [
86
+ "bit",
87
+ "bit-aspect",
88
+ "bit-core-aspect",
89
+ "components",
90
+ "collaboration",
91
+ "web"
92
+ ]
93
+ }
@@ -0,0 +1,41 @@
1
+ declare module '*.png' {
2
+ const value: any;
3
+ export = value;
4
+ }
5
+ declare module '*.svg' {
6
+ import type { FunctionComponent, SVGProps } from 'react';
7
+
8
+ export const ReactComponent: FunctionComponent<
9
+ SVGProps<SVGSVGElement> & { title?: string }
10
+ >;
11
+ const src: string;
12
+ export default src;
13
+ }
14
+ declare module '*.jpg' {
15
+ const value: any;
16
+ export = value;
17
+ }
18
+ declare module '*.jpeg' {
19
+ const value: any;
20
+ export = value;
21
+ }
22
+ declare module '*.gif' {
23
+ const value: any;
24
+ export = value;
25
+ }
26
+ declare module '*.bmp' {
27
+ const value: any;
28
+ export = value;
29
+ }
30
+ declare module '*.otf' {
31
+ const value: any;
32
+ export = value;
33
+ }
34
+ declare module '*.woff' {
35
+ const value: any;
36
+ export = value;
37
+ }
38
+ declare module '*.woff2' {
39
+ const value: any;
40
+ export = value;
41
+ }
@@ -0,0 +1,42 @@
1
+ declare module '*.module.css' {
2
+ const classes: { readonly [key: string]: string };
3
+ export default classes;
4
+ }
5
+ declare module '*.module.scss' {
6
+ const classes: { readonly [key: string]: string };
7
+ export default classes;
8
+ }
9
+ declare module '*.module.sass' {
10
+ const classes: { readonly [key: string]: string };
11
+ export default classes;
12
+ }
13
+
14
+ declare module '*.module.less' {
15
+ const classes: { readonly [key: string]: string };
16
+ export default classes;
17
+ }
18
+
19
+ declare module '*.less' {
20
+ const classes: { readonly [key: string]: string };
21
+ export default classes;
22
+ }
23
+
24
+ declare module '*.css' {
25
+ const classes: { readonly [key: string]: string };
26
+ export default classes;
27
+ }
28
+
29
+ declare module '*.sass' {
30
+ const classes: { readonly [key: string]: string };
31
+ export default classes;
32
+ }
33
+
34
+ declare module '*.scss' {
35
+ const classes: { readonly [key: string]: string };
36
+ export default classes;
37
+ }
38
+
39
+ declare module '*.mdx' {
40
+ const component: any;
41
+ export default component;
42
+ }