@teambit/objects 0.0.19

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 (123) hide show
  1. package/artifacts/__bit_junit.xml +68 -0
  2. package/artifacts/preview/teambit_scope_objects-preview.js +1 -0
  3. package/dist/fixtures/version-model-extended.json +48 -0
  4. package/dist/fixtures/version-model-object.json +87 -0
  5. package/dist/index.d.ts +19 -0
  6. package/dist/index.js +371 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/models/dependencies-graph.d.ts +45 -0
  9. package/dist/models/dependencies-graph.js +106 -0
  10. package/dist/models/dependencies-graph.js.map +1 -0
  11. package/dist/models/detach-heads.d.ts +25 -0
  12. package/dist/models/detach-heads.js +84 -0
  13. package/dist/models/detach-heads.js.map +1 -0
  14. package/dist/models/export-metadata.d.ts +24 -0
  15. package/dist/models/export-metadata.js +76 -0
  16. package/dist/models/export-metadata.js.map +1 -0
  17. package/dist/models/index.d.ts +10 -0
  18. package/dist/models/index.js +125 -0
  19. package/dist/models/index.js.map +1 -0
  20. package/dist/models/lane-history.d.ts +40 -0
  21. package/dist/models/lane-history.js +117 -0
  22. package/dist/models/lane-history.js.map +1 -0
  23. package/dist/models/lane.d.ts +124 -0
  24. package/dist/models/lane.js +463 -0
  25. package/dist/models/lane.js.map +1 -0
  26. package/dist/models/model-component.d.ts +317 -0
  27. package/dist/models/model-component.js +1365 -0
  28. package/dist/models/model-component.js.map +1 -0
  29. package/dist/models/model-component.spec.d.ts +1 -0
  30. package/dist/models/model-component.spec.js +71 -0
  31. package/dist/models/model-component.spec.js.map +1 -0
  32. package/dist/models/scopeMeta.d.ts +20 -0
  33. package/dist/models/scopeMeta.js +71 -0
  34. package/dist/models/scopeMeta.js.map +1 -0
  35. package/dist/models/source.d.ts +10 -0
  36. package/dist/models/source.js +43 -0
  37. package/dist/models/source.js.map +1 -0
  38. package/dist/models/symlink.d.ts +30 -0
  39. package/dist/models/symlink.js +91 -0
  40. package/dist/models/symlink.js.map +1 -0
  41. package/dist/models/version-history.d.ts +59 -0
  42. package/dist/models/version-history.js +285 -0
  43. package/dist/models/version-history.js.map +1 -0
  44. package/dist/models/version.d.ts +279 -0
  45. package/dist/models/version.js +777 -0
  46. package/dist/models/version.js.map +1 -0
  47. package/dist/models/version.spec.d.ts +1 -0
  48. package/dist/models/version.spec.js +340 -0
  49. package/dist/models/version.spec.js.map +1 -0
  50. package/dist/objects/bit-object-list.d.ts +24 -0
  51. package/dist/objects/bit-object-list.js +65 -0
  52. package/dist/objects/bit-object-list.js.map +1 -0
  53. package/dist/objects/index.d.ts +5 -0
  54. package/dist/objects/index.js +60 -0
  55. package/dist/objects/index.js.map +1 -0
  56. package/dist/objects/object-list-to-graph.d.ts +13 -0
  57. package/dist/objects/object-list-to-graph.js +93 -0
  58. package/dist/objects/object-list-to-graph.js.map +1 -0
  59. package/dist/objects/object-list.d.ts +52 -0
  60. package/dist/objects/object-list.js +369 -0
  61. package/dist/objects/object-list.js.map +1 -0
  62. package/dist/objects/object.d.ts +35 -0
  63. package/dist/objects/object.js +190 -0
  64. package/dist/objects/object.js.map +1 -0
  65. package/dist/objects/objects-readable-generator.d.ts +31 -0
  66. package/dist/objects/objects-readable-generator.js +192 -0
  67. package/dist/objects/objects-readable-generator.js.map +1 -0
  68. package/dist/objects/raw-object.d.ts +23 -0
  69. package/dist/objects/raw-object.js +155 -0
  70. package/dist/objects/raw-object.js.map +1 -0
  71. package/dist/objects/ref.d.ts +14 -0
  72. package/dist/objects/ref.js +45 -0
  73. package/dist/objects/ref.js.map +1 -0
  74. package/dist/objects/repository-hooks.d.ts +4 -0
  75. package/dist/objects/repository-hooks.js +56 -0
  76. package/dist/objects/repository-hooks.js.map +1 -0
  77. package/dist/objects/repository.d.ts +148 -0
  78. package/dist/objects/repository.js +842 -0
  79. package/dist/objects/repository.js.map +1 -0
  80. package/dist/objects/scope-index.d.ts +73 -0
  81. package/dist/objects/scope-index.js +251 -0
  82. package/dist/objects/scope-index.js.map +1 -0
  83. package/dist/objects/scope-index.spec.d.ts +1 -0
  84. package/dist/objects/scope-index.spec.js +152 -0
  85. package/dist/objects/scope-index.spec.js.map +1 -0
  86. package/dist/objects.aspect.d.ts +2 -0
  87. package/dist/objects.aspect.js +18 -0
  88. package/dist/objects.aspect.js.map +1 -0
  89. package/dist/objects.main.runtime.d.ts +7 -0
  90. package/dist/objects.main.runtime.js +36 -0
  91. package/dist/objects.main.runtime.js.map +1 -0
  92. package/dist/preview-1736824735631.js +7 -0
  93. package/fixtures/version-model-extended.json +48 -0
  94. package/fixtures/version-model-object.json +87 -0
  95. package/models/dependencies-graph.ts +119 -0
  96. package/models/detach-heads.ts +79 -0
  97. package/models/export-metadata.ts +57 -0
  98. package/models/index.ts +11 -0
  99. package/models/lane-history.ts +106 -0
  100. package/models/lane.ts +367 -0
  101. package/models/model-component.spec.ts +55 -0
  102. package/models/model-component.ts +1367 -0
  103. package/models/scopeMeta.ts +60 -0
  104. package/models/source.ts +32 -0
  105. package/models/symlink.ts +66 -0
  106. package/models/version-history.ts +266 -0
  107. package/models/version.spec.ts +288 -0
  108. package/models/version.ts +818 -0
  109. package/objects/bit-object-list.ts +59 -0
  110. package/objects/index.ts +6 -0
  111. package/objects/object-list-to-graph.ts +69 -0
  112. package/objects/object-list.ts +313 -0
  113. package/objects/object.ts +153 -0
  114. package/objects/objects-readable-generator.ts +167 -0
  115. package/objects/raw-object.ts +142 -0
  116. package/objects/ref.ts +45 -0
  117. package/objects/repository-hooks.ts +42 -0
  118. package/objects/repository.ts +753 -0
  119. package/objects/scope-index.spec.ts +95 -0
  120. package/objects/scope-index.ts +192 -0
  121. package/package.json +98 -0
  122. package/types/asset.d.ts +41 -0
  123. package/types/style.d.ts +42 -0
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+
3
+ function _chai() {
4
+ const data = require("chai");
5
+ _chai = function () {
6
+ return data;
7
+ };
8
+ return data;
9
+ }
10
+ function _models() {
11
+ const data = require("../models");
12
+ _models = function () {
13
+ return data;
14
+ };
15
+ return data;
16
+ }
17
+ function _scopeIndex() {
18
+ const data = require("./scope-index");
19
+ _scopeIndex = function () {
20
+ return data;
21
+ };
22
+ return data;
23
+ }
24
+ function _object() {
25
+ const data = _interopRequireDefault(require("./object"));
26
+ _object = function () {
27
+ return data;
28
+ };
29
+ return data;
30
+ }
31
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
32
+ describe('ComponentsIndex', () => {
33
+ describe('addOne', () => {
34
+ let scopeIndex;
35
+ beforeEach(() => {
36
+ scopeIndex = new (_scopeIndex().ScopeIndex)('scope-path');
37
+ });
38
+ it('should add to the index array', () => {
39
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
40
+ const modelComponent = new (_models().ModelComponent)({
41
+ scope: 'my-scope',
42
+ name: 'is-string'
43
+ });
44
+ scopeIndex.addOne(modelComponent);
45
+ const allItems = scopeIndex.getAll();
46
+ // @ts-ignore
47
+ (0, _chai().expect)(allItems[0].id).to.deep.equal({
48
+ scope: 'my-scope',
49
+ name: 'is-string'
50
+ });
51
+ });
52
+ it('should not add the same component multiple times', () => {
53
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
54
+ const modelComponent = new (_models().ModelComponent)({
55
+ scope: 'my-scope',
56
+ name: 'is-string'
57
+ });
58
+ scopeIndex.addOne(modelComponent);
59
+ scopeIndex.addOne(modelComponent);
60
+ scopeIndex.addOne(modelComponent);
61
+ (0, _chai().expect)(scopeIndex.getAll()).to.have.lengthOf(1);
62
+ });
63
+ it('should not add BitObjects that are not Symlink nor ModelComponent', () => {
64
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
65
+ const bitObject = new (_object().default)({
66
+ scope: 'my-scope',
67
+ name: 'is-string'
68
+ });
69
+ const result = scopeIndex.addOne(bitObject);
70
+ (0, _chai().expect)(scopeIndex.getAll()).to.have.lengthOf(0);
71
+ (0, _chai().expect)(result).to.be.false;
72
+ });
73
+ });
74
+ describe('remove', () => {
75
+ let scopeIndex;
76
+ beforeEach(() => {
77
+ scopeIndex = new (_scopeIndex().ScopeIndex)('scope-path');
78
+ });
79
+ it('should remove from the index array', () => {
80
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
81
+ const modelComponent = new (_models().ModelComponent)({
82
+ scope: 'my-scope',
83
+ name: 'is-string'
84
+ });
85
+ scopeIndex.addOne(modelComponent);
86
+ (0, _chai().expect)(scopeIndex.getAll()).to.have.lengthOf(1);
87
+ scopeIndex.removeOne(modelComponent.hash().toString());
88
+ (0, _chai().expect)(scopeIndex.getAll()).to.have.lengthOf(0);
89
+ });
90
+ it('should remove the correct one when there are multiple', () => {
91
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
92
+ const isStringComponent = new (_models().ModelComponent)({
93
+ scope: 'my-scope',
94
+ name: 'is-string'
95
+ });
96
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
97
+ const isTypeComponent = new (_models().ModelComponent)({
98
+ scope: 'my-scope',
99
+ name: 'is-type'
100
+ });
101
+ scopeIndex.addOne(isStringComponent);
102
+ scopeIndex.addOne(isTypeComponent);
103
+ (0, _chai().expect)(scopeIndex.getAll()).to.have.lengthOf(2);
104
+ scopeIndex.removeOne(isStringComponent.hash().toString());
105
+ const allIds = scopeIndex.getAll();
106
+ (0, _chai().expect)(allIds).to.have.lengthOf(1);
107
+ // @ts-ignore
108
+ (0, _chai().expect)(allIds[0].id).to.deep.equal({
109
+ scope: 'my-scope',
110
+ name: 'is-type'
111
+ });
112
+ });
113
+ });
114
+ describe('removeMany', () => {
115
+ let scopeIndex;
116
+ let isStringComponent;
117
+ let isTypeComponent;
118
+ beforeEach(() => {
119
+ scopeIndex = new (_scopeIndex().ScopeIndex)('scope-path');
120
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
121
+ isStringComponent = new (_models().ModelComponent)({
122
+ scope: 'my-scope',
123
+ name: 'is-string'
124
+ });
125
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
126
+ isTypeComponent = new (_models().ModelComponent)({
127
+ scope: 'my-scope',
128
+ name: 'is-type'
129
+ });
130
+ scopeIndex.addMany([isStringComponent, isTypeComponent]);
131
+ (0, _chai().expect)(scopeIndex.getAll()).to.have.lengthOf(2);
132
+ });
133
+ it('should remove multiple when removing them at the same removeMany call', () => {
134
+ (0, _chai().expect)(scopeIndex.getAll()).to.have.lengthOf(2);
135
+ scopeIndex.removeMany([isStringComponent.hash().toString(), isTypeComponent.hash().toString()]);
136
+ (0, _chai().expect)(scopeIndex.getAll()).to.have.lengthOf(0);
137
+ });
138
+ it('should remove multiple when removing them with separate removeMany calls', () => {
139
+ (0, _chai().expect)(scopeIndex.getAll()).to.have.lengthOf(2);
140
+ scopeIndex.removeMany([isStringComponent.hash().toString()]);
141
+ scopeIndex.removeMany([isTypeComponent.hash().toString()]);
142
+ (0, _chai().expect)(scopeIndex.getAll()).to.have.lengthOf(0);
143
+ });
144
+ it('should remove multiple when calling them with separate removeMany calls using array.map', () => {
145
+ (0, _chai().expect)(scopeIndex.getAll()).to.have.lengthOf(2);
146
+ [isStringComponent.hash().toString(), isTypeComponent.hash().toString()].map(h => scopeIndex.removeMany([h]));
147
+ (0, _chai().expect)(scopeIndex.getAll()).to.have.lengthOf(0);
148
+ });
149
+ });
150
+ });
151
+
152
+ //# sourceMappingURL=scope-index.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_chai","data","require","_models","_scopeIndex","_object","_interopRequireDefault","e","__esModule","default","describe","scopeIndex","beforeEach","ScopeIndex","it","modelComponent","ModelComponent","scope","name","addOne","allItems","getAll","expect","id","to","deep","equal","have","lengthOf","bitObject","BitObject","result","be","false","removeOne","hash","toString","isStringComponent","isTypeComponent","allIds","addMany","removeMany","map","h"],"sources":["scope-index.spec.ts"],"sourcesContent":["import { expect } from 'chai';\n\nimport { ModelComponent } from '../models';\nimport { ScopeIndex } from './scope-index';\nimport BitObject from './object';\n\ndescribe('ComponentsIndex', () => {\n describe('addOne', () => {\n let scopeIndex: ScopeIndex;\n beforeEach(() => {\n scopeIndex = new ScopeIndex('scope-path');\n });\n it('should add to the index array', () => {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const modelComponent = new ModelComponent({ scope: 'my-scope', name: 'is-string' });\n scopeIndex.addOne(modelComponent);\n const allItems = scopeIndex.getAll();\n // @ts-ignore\n expect(allItems[0].id).to.deep.equal({ scope: 'my-scope', name: 'is-string' });\n });\n it('should not add the same component multiple times', () => {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const modelComponent = new ModelComponent({ scope: 'my-scope', name: 'is-string' });\n scopeIndex.addOne(modelComponent);\n scopeIndex.addOne(modelComponent);\n scopeIndex.addOne(modelComponent);\n expect(scopeIndex.getAll()).to.have.lengthOf(1);\n });\n it('should not add BitObjects that are not Symlink nor ModelComponent', () => {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const bitObject = new BitObject({ scope: 'my-scope', name: 'is-string' });\n const result = scopeIndex.addOne(bitObject);\n expect(scopeIndex.getAll()).to.have.lengthOf(0);\n expect(result).to.be.false;\n });\n });\n describe('remove', () => {\n let scopeIndex: ScopeIndex;\n beforeEach(() => {\n scopeIndex = new ScopeIndex('scope-path');\n });\n it('should remove from the index array', () => {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const modelComponent = new ModelComponent({ scope: 'my-scope', name: 'is-string' });\n scopeIndex.addOne(modelComponent);\n expect(scopeIndex.getAll()).to.have.lengthOf(1);\n scopeIndex.removeOne(modelComponent.hash().toString());\n expect(scopeIndex.getAll()).to.have.lengthOf(0);\n });\n it('should remove the correct one when there are multiple', () => {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const isStringComponent = new ModelComponent({ scope: 'my-scope', name: 'is-string' });\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const isTypeComponent = new ModelComponent({ scope: 'my-scope', name: 'is-type' });\n scopeIndex.addOne(isStringComponent);\n scopeIndex.addOne(isTypeComponent);\n expect(scopeIndex.getAll()).to.have.lengthOf(2);\n scopeIndex.removeOne(isStringComponent.hash().toString());\n const allIds = scopeIndex.getAll();\n expect(allIds).to.have.lengthOf(1);\n // @ts-ignore\n expect(allIds[0].id).to.deep.equal({ scope: 'my-scope', name: 'is-type' });\n });\n });\n describe('removeMany', () => {\n let scopeIndex: ScopeIndex;\n let isStringComponent;\n let isTypeComponent;\n beforeEach(() => {\n scopeIndex = new ScopeIndex('scope-path');\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n isStringComponent = new ModelComponent({ scope: 'my-scope', name: 'is-string' });\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n isTypeComponent = new ModelComponent({ scope: 'my-scope', name: 'is-type' });\n scopeIndex.addMany([isStringComponent, isTypeComponent]);\n expect(scopeIndex.getAll()).to.have.lengthOf(2);\n });\n it('should remove multiple when removing them at the same removeMany call', () => {\n expect(scopeIndex.getAll()).to.have.lengthOf(2);\n scopeIndex.removeMany([isStringComponent.hash().toString(), isTypeComponent.hash().toString()]);\n expect(scopeIndex.getAll()).to.have.lengthOf(0);\n });\n it('should remove multiple when removing them with separate removeMany calls', () => {\n expect(scopeIndex.getAll()).to.have.lengthOf(2);\n scopeIndex.removeMany([isStringComponent.hash().toString()]);\n scopeIndex.removeMany([isTypeComponent.hash().toString()]);\n expect(scopeIndex.getAll()).to.have.lengthOf(0);\n });\n it('should remove multiple when calling them with separate removeMany calls using array.map', () => {\n expect(scopeIndex.getAll()).to.have.lengthOf(2);\n [isStringComponent.hash().toString(), isTypeComponent.hash().toString()].map((h) => scopeIndex.removeMany([h]));\n expect(scopeIndex.getAll()).to.have.lengthOf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d,EAAE,CAAC,0EAA0E,EAAE,MAAM;MACnF,IAAAQ,cAAM,EAACX,UAAU,CAACU,MAAM,CAAC,CAAC,CAAC,CAACG,EAAE,CAACG,IAAI,CAACC,QAAQ,CAAC,CAAC,CAAC;MAC/CjB,UAAU,CAAC8B,UAAU,CAAC,CAACJ,iBAAiB,CAACF,IAAI,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAAC,CAAC;MAC5DzB,UAAU,CAAC8B,UAAU,CAAC,CAACH,eAAe,CAACH,IAAI,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAAC,CAAC;MAC1D,IAAAd,cAAM,EAACX,UAAU,CAACU,MAAM,CAAC,CAAC,CAAC,CAACG,EAAE,CAACG,IAAI,CAACC,QAAQ,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC;IACFd,EAAE,CAAC,yFAAyF,EAAE,MAAM;MAClG,IAAAQ,cAAM,EAACX,UAAU,CAACU,MAAM,CAAC,CAAC,CAAC,CAACG,EAAE,CAACG,IAAI,CAACC,QAAQ,CAAC,CAAC,CAAC;MAC/C,CAACS,iBAAiB,CAACF,IAAI,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAEE,eAAe,CAACH,IAAI,CAAC,CAAC,CAACC,QAAQ,CAAC,CAAC,CAAC,CAACM,GAAG,CAAEC,CAAC,IAAKhC,UAAU,CAAC8B,UAAU,CAAC,CAACE,CAAC,CAAC,CAAC,CAAC;MAC/G,IAAArB,cAAM,EAACX,UAAU,CAACU,MAAM,CAAC,CAAC,CAAC,CAACG,EAAE,CAACG,IAAI,CAACC,QAAQ,CAAC,CAAC,CAAC;IACjD,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import { Aspect } from '@teambit/harmony';
2
+ export declare const ObjectsAspect: Aspect;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ObjectsAspect = void 0;
7
+ function _harmony() {
8
+ const data = require("@teambit/harmony");
9
+ _harmony = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ const ObjectsAspect = exports.ObjectsAspect = _harmony().Aspect.create({
15
+ id: 'teambit.scope/objects'
16
+ });
17
+
18
+ //# sourceMappingURL=objects.aspect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_harmony","data","require","ObjectsAspect","exports","Aspect","create","id"],"sources":["objects.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const ObjectsAspect = Aspect.create({\n id: 'teambit.scope/objects',\n});\n"],"mappings":";;;;;;AAAA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAME,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAGE,iBAAM,CAACC,MAAM,CAAC;EACzCC,EAAE,EAAE;AACN,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,7 @@
1
+ export declare class ObjectsMain {
2
+ static slots: never[];
3
+ static dependencies: never[];
4
+ static runtime: import("@teambit/harmony").RuntimeDefinition;
5
+ static provider(): Promise<ObjectsMain>;
6
+ }
7
+ export default ObjectsMain;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.ObjectsMain = void 0;
7
+ function _cli() {
8
+ const data = require("@teambit/cli");
9
+ _cli = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ function _objects() {
15
+ const data = require("./objects.aspect");
16
+ _objects = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
22
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
23
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
24
+ class ObjectsMain {
25
+ static async provider() {
26
+ return new ObjectsMain();
27
+ }
28
+ }
29
+ exports.ObjectsMain = ObjectsMain;
30
+ _defineProperty(ObjectsMain, "slots", []);
31
+ _defineProperty(ObjectsMain, "dependencies", []);
32
+ _defineProperty(ObjectsMain, "runtime", _cli().MainRuntime);
33
+ _objects().ObjectsAspect.addRuntime(ObjectsMain);
34
+ var _default = exports.default = ObjectsMain;
35
+
36
+ //# sourceMappingURL=objects.main.runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_cli","data","require","_objects","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ObjectsMain","provider","exports","MainRuntime","ObjectsAspect","addRuntime","_default","default"],"sources":["objects.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\nimport { ObjectsAspect } from './objects.aspect';\n\nexport class ObjectsMain {\n static slots = [];\n static dependencies = [];\n static runtime = MainRuntime;\n static async provider() {\n return new ObjectsMain();\n }\n}\n\nObjectsAspect.addRuntime(ObjectsMain);\n\nexport default ObjectsMain;\n"],"mappings":";;;;;;AAAA,SAAAA,KAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,IAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAiD,SAAAG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 "file": "041875a4daae4a64415374062f7a4bd2eac3f751",
5
+ "relativePath": "bar/foo.ts",
6
+ "name": "foo.ts",
7
+ "test": false
8
+ }
9
+ ],
10
+ "mainFile": "bar/foo.ts",
11
+ "bindingPrefix": "@bit",
12
+ "log": {
13
+ "message": "tag-message",
14
+ "date": "1527523854385",
15
+ "username": "David First",
16
+ "email": "david@bit.dev"
17
+ },
18
+ "ci": {},
19
+ "docs": [],
20
+ "dependencies": [
21
+ {
22
+ "id": { "scope": "23th85mi-remote", "name": "/utils/is-string", "version": "0.0.1" },
23
+ "relativePaths": [
24
+ {
25
+ "sourceRelativePath": "utils/is-string.ts",
26
+ "destinationRelativePath": "utils/is-string.ts",
27
+ "importSpecifiers": [
28
+ {
29
+ "mainFile": {
30
+ "isDefault": true,
31
+ "name": "isString"
32
+ }
33
+ }
34
+ ]
35
+ }
36
+ ]
37
+ }
38
+ ],
39
+ "devDependencies": [],
40
+ "flattenedDependencies": [
41
+ { "scope": "23th85mi-remote", "name": "utils/is-type", "version": "0.0.1" },
42
+ { "scope": "23th85mi-remote", "name": "utils/is-string", "version": "0.0.1" }
43
+ ],
44
+ "flattenedDevDependencies": [],
45
+ "packageDependencies": {},
46
+ "devPackageDependencies": {},
47
+ "peerPackageDependencies": {}
48
+ }
@@ -0,0 +1,87 @@
1
+ {
2
+ "files": [{
3
+ "file": "3ef84ee58242de1b3feadfab4d12a7018de69e93",
4
+ "relativePath": "impl.js",
5
+ "name": "impl.js",
6
+ "test": false
7
+ }, {
8
+ "file": "b0f492d50dff231d3d50872f1fe42901a26be66e",
9
+ "relativePath": "spec.js",
10
+ "name": "spec.js",
11
+ "test": true
12
+ }],
13
+ "mainFile": "impl.js",
14
+ "dists": [{
15
+ "file": "aa633b24c97bb53dcd52b0ef5ac7f6aa7b7c85fa",
16
+ "relativePath": "dist.js",
17
+ "name": "dist.js",
18
+ "test": false
19
+ }],
20
+ "compiler": "bit.envs/compilers/babel",
21
+ "bindingPrefix": "@bit",
22
+ "tester": "bit.envs/mocha/react",
23
+ "log": {
24
+ "message": "init",
25
+ "date": "1497953762445",
26
+ "username": "David First",
27
+ "email": "david@bitsrc.io"
28
+ },
29
+ "ci": {
30
+ "startTime": "1497953909560",
31
+ "endTime": "1497953937808"
32
+ },
33
+ "specsResults": [{
34
+ "tests": [{
35
+ "title": "QuerySelectorAll should use GetElementByTagName",
36
+ "pass": true,
37
+ "err": null,
38
+ "duration": 5
39
+ }, {
40
+ "title": "QuerySelectorAll should use GetElementById",
41
+ "pass": true,
42
+ "err": null,
43
+ "duration": 2
44
+ }, {
45
+ "title": "QuerySelectorAll should use GetElementsByClassName",
46
+ "pass": true,
47
+ "err": null,
48
+ "duration": 2
49
+ }, {
50
+ "title": "QuerySelectorAll should use qsa for complex selectors",
51
+ "pass": true,
52
+ "err": null,
53
+ "duration": 9
54
+ }],
55
+ "stats": {
56
+ "start": "2017-06-20T10:18:57.361Z",
57
+ "end": "2017-06-20T10:18:57.792Z",
58
+ "duration": 431
59
+ },
60
+ "pass": true,
61
+ "specFile": "spec.js"
62
+ }],
63
+ "docs": [{
64
+ "name": "querySelectorAll",
65
+ "description": "# Returns all elements in the document that matches a specified CSS selector.",
66
+ "args": [{
67
+ "description": null,
68
+ "type": "object",
69
+ "name": "element"
70
+ }, {
71
+ "description": null,
72
+ "type": "string",
73
+ "name": "selector"
74
+ }],
75
+ "returns": {},
76
+ "access": "public",
77
+ "examples": [],
78
+ "static": false
79
+ }],
80
+ "dependencies": [],
81
+ "devDependencies": [],
82
+ "flattenedDependencies": [],
83
+ "flattenedDevDependencies": [],
84
+ "packageDependencies": {},
85
+ "devPackageDependencies": {},
86
+ "peerPackageDependencies": {}
87
+ }
@@ -0,0 +1,119 @@
1
+ import semver from 'semver';
2
+ import { PackageInfo } from '@pnpm/lockfile.types';
3
+ import * as dp from '@pnpm/dependency-path';
4
+
5
+ export type PackagesMap = Map<string, PackageAttributes>;
6
+
7
+ export type PackageAttributes = PackageInfo & {
8
+ component?: {
9
+ scope: string;
10
+ name: string;
11
+ };
12
+ };
13
+
14
+ export type DependencyEdge = {
15
+ id: string;
16
+ neighbours: DependencyNeighbour[];
17
+ attr?: {
18
+ pkgId?: string;
19
+ transitivePeerDependencies?: string[];
20
+ };
21
+ };
22
+
23
+ export type DependencyNeighbour = {
24
+ id: string;
25
+ /**
26
+ * This is true when the dependency is from optionalDependencies.
27
+ */
28
+ optional?: boolean;
29
+ name?: string;
30
+ specifier?: string;
31
+ lifecycle?: 'runtime' | 'dev';
32
+ };
33
+
34
+ const DEPENDENCIES_GRAPH_SCHEMA_VERSION = '1.0';
35
+
36
+ export class DependenciesGraph {
37
+ static ROOT_EDGE_ID = '.';
38
+
39
+ schemaVersion: string;
40
+ packages: PackagesMap;
41
+ edges: DependencyEdge[];
42
+
43
+ constructor({
44
+ packages,
45
+ edges,
46
+ schemaVersion,
47
+ }: {
48
+ packages: PackagesMap;
49
+ edges: DependencyEdge[];
50
+ schemaVersion?: string;
51
+ }) {
52
+ this.packages = packages;
53
+ this.edges = edges;
54
+ this.schemaVersion = schemaVersion ?? DEPENDENCIES_GRAPH_SCHEMA_VERSION;
55
+ }
56
+
57
+ serialize(): string {
58
+ return JSON.stringify({
59
+ schemaVersion: this.schemaVersion,
60
+ packages: Object.fromEntries(this.packages.entries()),
61
+ edges: this.edges,
62
+ });
63
+ }
64
+
65
+ static deserialize(data: string): DependenciesGraph | undefined {
66
+ const parsed = JSON.parse(data);
67
+ // If the schema version is not supported, then we just ignore the data
68
+ if (parsed.schemaVersion !== DEPENDENCIES_GRAPH_SCHEMA_VERSION) {
69
+ return undefined;
70
+ }
71
+ return new DependenciesGraph({
72
+ schemaVersion: parsed.schemaVersion,
73
+ edges: parsed.edges,
74
+ packages: new Map(Object.entries(parsed.packages)),
75
+ });
76
+ }
77
+
78
+ merge(graph: DependenciesGraph): void {
79
+ const directDependencies = graph.findRootEdge()?.neighbours;
80
+ if (directDependencies) {
81
+ for (const directDep of directDependencies) {
82
+ const existingDirectDeps = this.findRootEdge()?.neighbours;
83
+ if (existingDirectDeps) {
84
+ const existingDirectDep = existingDirectDeps.find(
85
+ ({ name, specifier }) => name === directDep.name && specifier === directDep.specifier
86
+ );
87
+ if (existingDirectDep == null) {
88
+ existingDirectDeps.push(directDep);
89
+ } else if (existingDirectDep.id !== directDep.id && nodeIdLessThan(existingDirectDep.id, directDep.id)) {
90
+ existingDirectDep.id = directDep.id;
91
+ }
92
+ }
93
+ }
94
+ }
95
+ for (const [newPkgId, newPkgAttr] of graph.packages.entries()) {
96
+ this.packages.set(newPkgId, newPkgAttr);
97
+ }
98
+ this.edges.push(...graph.edges);
99
+ }
100
+
101
+ isEmpty(): boolean {
102
+ return this.packages.size === 0 && this.edges.length === 0;
103
+ }
104
+
105
+ /**
106
+ * Returns the edge related to the root component
107
+ */
108
+ findRootEdge(): DependencyEdge | undefined {
109
+ return this.edges.find(({ id }) => id === DependenciesGraph.ROOT_EDGE_ID);
110
+ }
111
+ }
112
+
113
+ function nodeIdLessThan(nodeId1: string, nodeId2: string): boolean {
114
+ const parsed1 = dp.parse(nodeId1);
115
+ if (!parsed1?.version) return false;
116
+ const parsed2 = dp.parse(nodeId2);
117
+ if (!parsed2?.version) return false;
118
+ return semver.lt(parsed1.version, parsed2.version);
119
+ }
@@ -0,0 +1,79 @@
1
+ import Ref from '../objects/ref';
2
+ import { uniqBy } from 'lodash';
3
+
4
+ type DetachedHeadsObject = {
5
+ heads?: string[];
6
+ deleted?: string[];
7
+ current?: string;
8
+ };
9
+
10
+ export class DetachedHeads {
11
+ constructor(
12
+ protected heads: Ref[] = [],
13
+ protected current?: Ref,
14
+ protected deleted: Ref[] = []
15
+ ) {}
16
+
17
+ setHead(head: Ref) {
18
+ this.current = head;
19
+ this.heads.push(head);
20
+ }
21
+
22
+ getCurrent(): Ref | undefined {
23
+ return this.current;
24
+ }
25
+
26
+ getAllHeads(): Ref[] {
27
+ return this.heads;
28
+ }
29
+
30
+ /**
31
+ * happens during reset. these heads are local, so no need to enter them into "deleted" array.
32
+ */
33
+ removeLocalHeads(refs: Ref[]) {
34
+ this.heads = this.heads.filter((head) => !refs.find((ref) => ref.isEqual(head)));
35
+ if (this.current && refs.find((ref) => ref.isEqual(this.current!))) {
36
+ this.current = undefined;
37
+ }
38
+ }
39
+
40
+ clearCurrent() {
41
+ this.current = undefined;
42
+ }
43
+
44
+ merge(incoming: DetachedHeads, isImport: boolean) {
45
+ if (!isImport) {
46
+ this.current = undefined;
47
+ }
48
+ this.heads = uniqBy([...this.heads, ...incoming.heads], 'hash');
49
+ this.deleted = uniqBy([...this.deleted, ...incoming.deleted], 'hash');
50
+ }
51
+
52
+ deleteFromHeadsIfNeeded() {
53
+ this.heads = this.heads.filter((head) => !this.deleted.find((deleted) => deleted.isEqual(head)));
54
+ }
55
+
56
+ toObject(): DetachedHeadsObject | undefined {
57
+ const heads = this.heads.length ? this.heads.map((head) => head.toString()) : undefined;
58
+ const deleted = this.deleted.length ? this.deleted.map((head) => head.toString()) : undefined;
59
+ const current = this.current?.toString();
60
+
61
+ if (!heads && !deleted && !current) return undefined;
62
+
63
+ return {
64
+ heads,
65
+ deleted,
66
+ current,
67
+ };
68
+ }
69
+
70
+ static fromObject(object?: DetachedHeadsObject): DetachedHeads {
71
+ if (!object) {
72
+ return new DetachedHeads();
73
+ }
74
+ const heads = object.heads ? object.heads.map((head) => new Ref(head)) : [];
75
+ const deleted = object.deleted ? object.deleted.map((head) => new Ref(head)) : [];
76
+ const current = object.current ? new Ref(object.current) : undefined;
77
+ return new DetachedHeads(heads, current, deleted);
78
+ }
79
+ }
@@ -0,0 +1,57 @@
1
+ import { ComponentID } from '@teambit/component-id';
2
+ import { getStringifyArgs } from '@teambit/legacy.utils';
3
+ import { BitObject, Ref } from '../objects';
4
+
5
+ type ExportMetadataProps = {
6
+ exportVersions: ExportVersions[];
7
+ };
8
+
9
+ export type ExportVersions = { id: ComponentID; versions: string[]; head: Ref };
10
+
11
+ /**
12
+ * @deprecated since 0.0.928 (see #6758). this object is not sent to the remote anymore.
13
+ * introduced in 0.0.782 (see #5935)
14
+ */
15
+ export default class ExportMetadata extends BitObject {
16
+ exportVersions: ExportVersions[];
17
+ constructor(props: ExportMetadataProps) {
18
+ super();
19
+ this.exportVersions = props.exportVersions;
20
+ }
21
+
22
+ toObject(): Record<string, any> {
23
+ return {
24
+ exportVersions: this.exportVersions.map((exportComp) => ({
25
+ id: exportComp.id.toStringWithoutVersion(),
26
+ versions: exportComp.versions,
27
+ head: exportComp.head.toString(),
28
+ })),
29
+ };
30
+ }
31
+
32
+ // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!
33
+ toString(pretty: boolean): string {
34
+ const args = getStringifyArgs(pretty);
35
+ return JSON.stringify(this.toObject(), ...args);
36
+ }
37
+
38
+ id(): string {
39
+ return ExportMetadata.name;
40
+ }
41
+
42
+ toBuffer(pretty): Buffer {
43
+ return Buffer.from(this.toString(pretty));
44
+ }
45
+
46
+ static parse(contents: string): ExportMetadata {
47
+ const parsed = JSON.parse(contents);
48
+ const props: ExportMetadataProps = {
49
+ exportVersions: parsed.exportVersions.map((comp) => ({
50
+ id: ComponentID.fromString(comp.id),
51
+ versions: comp.versions,
52
+ head: Ref.from(comp.head),
53
+ })),
54
+ };
55
+ return new ExportMetadata(props);
56
+ }
57
+ }
@@ -0,0 +1,11 @@
1
+ import Lane from './lane';
2
+ import ModelComponent from './model-component';
3
+ import ScopeMeta from './scopeMeta';
4
+ import Source from './source';
5
+ import Symlink from './symlink';
6
+ import Version from './version';
7
+ import ExportMetadata from './export-metadata';
8
+ import VersionHistory from './version-history';
9
+ import { LaneHistory } from './lane-history';
10
+
11
+ export { ModelComponent, ScopeMeta, Source, Version, Symlink, Lane, ExportMetadata, VersionHistory, LaneHistory };