@_unit/unit 1.0.9 → 1.0.10

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 (108) hide show
  1. package/build/web.js +8 -8
  2. package/lib/API.d.ts +2 -0
  3. package/lib/API.js +1 -0
  4. package/lib/API.js.map +1 -1
  5. package/lib/Class/Graph/index.d.ts +2 -3
  6. package/lib/Class/Graph/index.js +161 -95
  7. package/lib/Class/Graph/index.js.map +1 -1
  8. package/lib/Class/Graph/moveSubgraph.js +2 -4
  9. package/lib/Class/Graph/moveSubgraph.js.map +1 -1
  10. package/lib/boot/index.js +2 -2
  11. package/lib/boot/index.js.map +1 -1
  12. package/lib/buildIdSetFromBundle.js +4 -3
  13. package/lib/buildIdSetFromBundle.js.map +1 -1
  14. package/lib/bundle.js +19 -1
  15. package/lib/bundle.js.map +1 -1
  16. package/lib/client/cache.js.map +1 -1
  17. package/lib/client/component.js +9 -2
  18. package/lib/client/component.js.map +1 -1
  19. package/lib/client/event/wheel.js.map +1 -1
  20. package/lib/client/platform/node/boot.js +1 -1
  21. package/lib/client/platform/node/boot.js.map +1 -1
  22. package/lib/client/platform/web/api/document.js +3 -0
  23. package/lib/client/platform/web/api/document.js.map +1 -1
  24. package/lib/client/platform/web/api/file.js +92 -0
  25. package/lib/client/platform/web/api/file.js.map +1 -1
  26. package/lib/client/platform/web/boot.d.ts +2 -2
  27. package/lib/client/platform/web/boot.js +6 -6
  28. package/lib/client/platform/web/boot.js.map +1 -1
  29. package/lib/client/platform/web/render.d.ts +1 -0
  30. package/lib/client/platform/web/render.js +11 -1
  31. package/lib/client/platform/web/render.js.map +1 -1
  32. package/lib/client/render/renderBundle.d.ts +2 -1
  33. package/lib/client/render/renderBundle.js +3 -4
  34. package/lib/client/render/renderBundle.js.map +1 -1
  35. package/lib/host/none.d.ts +1 -1
  36. package/lib/host/none.js +4 -3
  37. package/lib/host/none.js.map +1 -1
  38. package/lib/spec/escape.js.map +1 -1
  39. package/lib/spec/type.js +4 -4
  40. package/lib/spec/type.js.map +1 -1
  41. package/lib/spec/util.d.ts +1 -1
  42. package/lib/spec/util.js +19 -5
  43. package/lib/spec/util.js.map +1 -1
  44. package/lib/spec/validate.js +1 -0
  45. package/lib/spec/validate.js.map +1 -1
  46. package/lib/start.d.ts +2 -2
  47. package/lib/start.js +2 -1
  48. package/lib/start.js.map +1 -1
  49. package/lib/system/_classes.d.ts +10 -2
  50. package/lib/system/_classes.js +10 -2
  51. package/lib/system/_classes.js.map +1 -1
  52. package/lib/system/_ids.d.ts +5 -0
  53. package/lib/system/_ids.js +15 -10
  54. package/lib/system/_ids.js.map +1 -1
  55. package/lib/system/_specs.js +1 -1
  56. package/lib/system/_specs.js.map +1 -1
  57. package/lib/system/f/unit/HasInput/index.d.ts +15 -0
  58. package/lib/system/f/unit/HasInput/index.js +24 -0
  59. package/lib/system/f/unit/HasInput/index.js.map +1 -0
  60. package/lib/system/globalComponent.d.ts +1 -0
  61. package/lib/system/globalComponent.js +16 -1
  62. package/lib/system/globalComponent.js.map +1 -1
  63. package/lib/system/platform/api/observer/IntersectionObserver/index.d.ts +19 -0
  64. package/lib/system/platform/api/observer/IntersectionObserver/index.js +60 -0
  65. package/lib/system/platform/api/observer/IntersectionObserver/index.js.map +1 -0
  66. package/lib/system/platform/api/observer/SizeObserver/index.js +1 -0
  67. package/lib/system/platform/api/observer/SizeObserver/index.js.map +1 -1
  68. package/lib/system/platform/component/app/Editor/Component.d.ts +3 -1
  69. package/lib/system/platform/component/app/Editor/Component.js +186 -93
  70. package/lib/system/platform/component/app/Editor/Component.js.map +1 -1
  71. package/lib/system/platform/component/app/GUI/Component.js +2 -2
  72. package/lib/system/platform/meta/{Child → component/Child}/index.d.ts +5 -5
  73. package/lib/system/platform/meta/{Child → component/Child}/index.js +2 -2
  74. package/lib/system/platform/meta/component/Child/index.js.map +1 -0
  75. package/lib/system/platform/meta/component/Children/index.d.ts +16 -0
  76. package/lib/system/platform/meta/component/Children/index.js +70 -0
  77. package/lib/system/platform/meta/component/Children/index.js.map +1 -0
  78. package/lib/system/platform/meta/{ParentChild → component/ParentChild}/index.d.ts +5 -5
  79. package/lib/system/platform/meta/{ParentChild → component/ParentChild}/index.js +2 -2
  80. package/lib/system/platform/meta/component/ParentChild/index.js.map +1 -0
  81. package/lib/system/platform/method/array/{Push → Length0}/index.d.ts +5 -4
  82. package/lib/system/platform/method/array/{Push → Length0}/index.js +16 -9
  83. package/lib/system/platform/method/array/Length0/index.js.map +1 -0
  84. package/lib/system/platform/method/process/NewGraph/index.js +1 -1
  85. package/lib/system/platform/method/process/NewGraph/index.js.map +1 -1
  86. package/lib/types/global/IIntersectionObserver.d.ts +7 -0
  87. package/lib/types/global/{IHTTPServer.js → IIntersectionObserver.js} +1 -1
  88. package/lib/types/global/IIntersectionObserver.js.map +1 -0
  89. package/lib/types/index.d.ts +4 -1
  90. package/package-lock.json +4 -4
  91. package/package.json +3 -2
  92. package/public/_worker.js +10 -86061
  93. package/public/build.json +1 -1
  94. package/public/index.js +1163 -88931
  95. package/lib/ObjectWaiter.d.ts +0 -7
  96. package/lib/ObjectWaiter.js +0 -43
  97. package/lib/ObjectWaiter.js.map +0 -1
  98. package/lib/system/platform/api/http/HTTPServer/index.d.ts +0 -31
  99. package/lib/system/platform/api/http/HTTPServer/index.js +0 -31
  100. package/lib/system/platform/api/http/HTTPServer/index.js.map +0 -1
  101. package/lib/system/platform/api/media/image/BlobToBitmap/index.d.ts +0 -18
  102. package/lib/system/platform/api/media/image/BlobToBitmap/index.js +0 -63
  103. package/lib/system/platform/api/media/image/BlobToBitmap/index.js.map +0 -1
  104. package/lib/system/platform/meta/Child/index.js.map +0 -1
  105. package/lib/system/platform/meta/ParentChild/index.js.map +0 -1
  106. package/lib/system/platform/method/array/Push/index.js.map +0 -1
  107. package/lib/types/global/IHTTPServer.d.ts +0 -9
  108. package/lib/types/global/IHTTPServer.js.map +0 -1
package/lib/API.d.ts CHANGED
@@ -10,6 +10,7 @@ import { IDisplayMediaOpt } from './types/global/IDisplayMedia';
10
10
  import { IDownloadDataOpt as IDownloadTextOpt } from './types/global/IDownloadData';
11
11
  import { IDownloadURLOpt } from './types/global/IDownloadURL';
12
12
  import { IGeoPosition } from './types/global/IGeoPosition';
13
+ import { IIntersectionObserverConstructor } from './types/global/IIntersectionObserver';
13
14
  import { IMutationObserverConstructor } from './types/global/IMutationObserver';
14
15
  import { IPositionObserverCostructor } from './types/global/IPositionObserver';
15
16
  import { IResizeObserverConstructor } from './types/global/IResizeObserver';
@@ -126,6 +127,7 @@ export type API = {
126
127
  MutationObserver: IMutationObserverConstructor;
127
128
  PositionObserver: IPositionObserverCostructor;
128
129
  ResizeObserver: IResizeObserverConstructor;
130
+ IntersectionObserver: IIntersectionObserverConstructor;
129
131
  };
130
132
  querystring: {
131
133
  stringify: (obj: Dict<any>) => string;
package/lib/API.js CHANGED
@@ -1,3 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ IntersectionObserver;
3
4
  //# sourceMappingURL=API.js.map
package/lib/API.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"API.js","sourceRoot":"src/","sources":["API.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"API.js","sourceRoot":"src/","sources":["API.ts"],"names":[],"mappings":";;AA6LA,oBAAoB,CAAA"}
@@ -86,7 +86,6 @@ export declare class Graph<I = any, O = any> extends Primitive<I, O, GraphEvents
86
86
  private _memPlugPinToUnitPin;
87
87
  private _memPlugPinToMerge;
88
88
  private _simPlugPinToUnitPin;
89
- private setExposedSubPin;
90
89
  private _setExposedSubPin;
91
90
  private _memSetExposedSubPin;
92
91
  private _simSetExposedSubPin;
@@ -145,7 +144,7 @@ export declare class Graph<I = any, O = any> extends Primitive<I, O, GraphEvents
145
144
  private _specSetPinSetFunctional;
146
145
  private _memSetPinSetFunctional;
147
146
  private _simSetPinSetFunctional;
148
- setPinSetId(type: IO, pinId: string, nextPinId: string): void;
147
+ setPinSetId(type: IO, pinId: string, nextPinId: string, emit?: boolean): void;
149
148
  _setPinSetId(type: IO, pinId: string, nextPinId: string): void;
150
149
  exposePin: (type: IO, pinId: string, subPinId: string, subPinSpec: GraphSubPinSpec, emit?: boolean, propagate?: boolean) => void;
151
150
  private _exposePin;
@@ -252,7 +251,7 @@ export declare class Graph<I = any, O = any> extends Primitive<I, O, GraphEvents
252
251
  getPlugSpecs(): IOOf<Dict<Dict<GraphSubPinSpec>>>;
253
252
  getPlug(type: IO, pinId: string, subPinId: string): Pin;
254
253
  getMerge(mergeId: string): Merge;
255
- refExposedMerges(): Dict<Merge>;
254
+ refExposedMerges(): IOOf<Dict<IOOf<Merge>>>;
256
255
  getUnitCount(): number;
257
256
  getMergeCount(): number;
258
257
  findMergeExposedSubPin(type: IO, mergeId: string): {
@@ -47,6 +47,7 @@ const Merge_1 = require("../Merge");
47
47
  const WaitAll_1 = require("../WaitAll");
48
48
  const moveSubgraph_1 = require("./moveSubgraph");
49
49
  const spec_3 = require("../../spec/reducers/spec");
50
+ const weakMerge_1 = require("../../types/weakMerge");
50
51
  class Graph extends Primitive_1.Primitive {
51
52
  constructor(spec, branch = {}, system, id) {
52
53
  var _a;
@@ -80,18 +81,19 @@ class Graph extends Primitive_1.Primitive {
80
81
  // console.log('Graph', '_onPinSetRenamed', type, name, newName, opt, newOpt)
81
82
  const oppositeType = (0, util_1.opposite)(type);
82
83
  const { functional } = opt;
83
- const exposedPinId = (0, util_1.getExposedPinId)(name, type);
84
- const newExposedPinId = (0, util_1.getExposedPinId)(newName, type);
85
- const exposedPin = this._exposedPin[exposedPinId];
86
- const exposedMerge = this._exposedMerge[exposedPinId];
84
+ const exposedPin = (0, f_1.default)(this._exposedPin, [type, name]);
85
+ const exposedMerge = (0, f_1.default)(this._exposedMerge, [type, name, type]);
86
+ const exposedMergeOpposite = (0, f_1.default)(this._exposedMerge, [type, name, oppositeType]);
87
87
  exposedMerge.renamePin(type, name, newName);
88
88
  if (functional) {
89
89
  this._unplugFromWaitAll(type, name);
90
90
  }
91
- delete this._exposedPin[exposedPinId];
92
- delete this._exposedMerge[exposedPinId];
93
- this._exposedPin[newExposedPinId] = exposedPin;
94
- this._exposedMerge[newExposedPinId] = exposedMerge;
91
+ (0, object_1.pathDestroy)(this._exposedPin, [type, name]);
92
+ (0, object_1.pathDestroy)(this._exposedMerge, [type, name, type]);
93
+ (0, object_1.pathDestroy)(this._exposedMerge, [type, name, oppositeType]);
94
+ (0, object_1.pathSet)(this._exposedPin, [type, newName], exposedPin);
95
+ (0, object_1.pathSet)(this._exposedMerge, [type, newName, type], exposedMerge);
96
+ (0, object_1.pathSet)(this._exposedMerge, [type, newName, oppositeType], exposedMergeOpposite);
95
97
  const emptySubPins = (0, f_1.default)(this._exposedEmptySubPin, [type, name]);
96
98
  for (const subPinId in Object.assign({}, emptySubPins)) {
97
99
  const emptySubPin = emptySubPins[subPinId];
@@ -183,35 +185,35 @@ class Graph extends Primitive_1.Primitive {
183
185
  const mergePinNodeId = (0, util_1.getMergePinNodeId)(mergeId, type);
184
186
  this._ensureMergePin(type, mergeId, propagate);
185
187
  const subPin = this._pin[mergePinNodeId];
186
- this._setExposedSubPin(type, pinId, subPinId, subPin, opt, propagate);
188
+ this._setExposedSubPin(type, pinId, type, subPinId, subPin, opt, propagate);
187
189
  };
188
190
  this._simPlugPinToMerge = (type, pinId, subPinId, mergeId, propagate = true) => {
189
191
  const mergePinNodeId = (0, util_1.getMergePinNodeId)(mergeId, type);
190
192
  this._ensureMergePin(type, mergeId, propagate);
191
193
  const subPin = this._pin[mergePinNodeId];
192
- this._simSetExposedSubPin(type, pinId, subPinId, subPin, propagate);
194
+ this._simSetExposedSubPin(type, pinId, type, subPinId, subPin, propagate);
193
195
  };
194
196
  this._simUnplugPinFromMerge = (type, name, subPinId, mergeId) => {
195
197
  this._simRemoveExposedSubPin(type, name, subPinId);
196
198
  };
197
- this._simUnplugPinFromUnitPin = (type, pinId, subPinId, _unitId, _pinId) => {
199
+ this._simUnplugPinFromUnitPin = (type, pinId, subPinId, _unitId, _pinId, _type) => {
198
200
  this._simRemoveExposedSubPin(type, pinId, subPinId);
199
201
  };
200
- this._plugPinToUnitPin = (type, name, subPinId, unitId, pinId, opt, propagate = false) => {
201
- this._memPlugPinToUnitPin(type, name, subPinId, unitId, pinId);
202
- this._simPlugPinToUnitPin(type, name, subPinId, unitId, pinId, propagate);
202
+ this._plugPinToUnitPin = (type, name, subPinId, unitId, kind, pinId, opt, propagate = false) => {
203
+ this._memPlugPinToUnitPin(type, name, subPinId, unitId, kind, pinId);
204
+ this._simPlugPinToUnitPin(type, name, subPinId, unitId, kind, pinId, propagate);
203
205
  };
204
- this._memPlugPinToUnitPin = (type, name, subPinId, unitId, pinId) => {
205
- const subPin = this.getUnitPin(unitId, type, pinId);
206
- (0, object_1.pathSet)(this._pinToPlug, [unitId, type, pinId], { pinId: name, subPinId });
207
- this._memSetExposedSubPin(type, name, subPinId, subPin);
206
+ this._memPlugPinToUnitPin = (type, pinId, subPinId, unitId, kind, pinId_) => {
207
+ const subPin = this.getUnitPin(unitId, kind, pinId_);
208
+ (0, object_1.pathSet)(this._pinToPlug, [unitId, type, pinId_], { pinId, subPinId, kind });
209
+ this._memSetExposedSubPin(type, pinId, subPinId, subPin);
208
210
  };
209
211
  this._memPlugPinToMerge = (type, name, subPinId, mergeId) => {
210
212
  //
211
213
  };
212
- this._simPlugPinToUnitPin = (type, name, subPinId, unitId, pinId, propagate = true) => {
213
- const subPin = this.getUnitPin(unitId, type, pinId);
214
- this._simSetExposedSubPin(type, name, subPinId, subPin, propagate);
214
+ this._simPlugPinToUnitPin = (type, name, subPinId, unitId, kind, pinId, propagate = true) => {
215
+ const subPin = this.getUnitPin(unitId, kind, pinId);
216
+ this._simSetExposedSubPin(type, name, kind, subPinId, subPin, propagate);
215
217
  };
216
218
  this._takeErr = () => {
217
219
  if (this._errUnitIds.length > 0) {
@@ -310,19 +312,21 @@ class Graph extends Primitive_1.Primitive {
310
312
  this._exposePinSet = (type, pinId, pinSpec, data, propagate = true) => {
311
313
  // console.log('Graph', '_exposePinSet', type, pinId, pinSpec, data, propagate)
312
314
  const exposedPin = new Pin_1.Pin({ data });
313
- const exposedMerge = new Merge_1.default(this.__system);
315
+ const exposeMerge = new Merge_1.default(this.__system);
316
+ const exposedMergeOpposite = new Merge_1.default(this.__system);
314
317
  this._fork();
315
318
  this._specExposePinSet(type, pinId, pinSpec);
316
- this._memExposePinSet(type, pinId, pinSpec, exposedPin, exposedMerge);
317
- this._simExposePinSet(type, pinId, pinSpec, exposedPin, exposedMerge, propagate);
319
+ this._memExposePinSet(type, pinId, pinSpec, exposedPin, exposeMerge, exposedMergeOpposite);
320
+ this._simExposePinSet(type, pinId, pinSpec, exposedPin, exposeMerge, exposedMergeOpposite, propagate);
318
321
  };
319
322
  this._initPinSet = (type, pinId, pinSpec, propagate = true) => {
320
323
  // console.log('Graph', '_initPinSet', type, pinId, pinSpec, exposedPin)
321
324
  const { ref } = pinSpec;
322
325
  const exposedPin = new Pin_1.Pin({ ref });
323
326
  const exposedMerge = new Merge_1.default(this.__system);
324
- this._memExposePinSet(type, pinId, pinSpec, exposedPin, exposedMerge);
325
- this._simExposePinSet(type, pinId, pinSpec, exposedPin, exposedMerge, propagate);
327
+ const exposedMergeOpposite = new Merge_1.default(this.__system);
328
+ this._memExposePinSet(type, pinId, pinSpec, exposedPin, exposedMerge, exposedMergeOpposite);
329
+ this._simExposePinSet(type, pinId, pinSpec, exposedPin, exposedMerge, exposedMergeOpposite, propagate);
326
330
  };
327
331
  this._specExposePinSet = (type, pinId, pinSpec) => {
328
332
  // console.log('Graph', '_specExposePinSet', type, pinId, pinSpec)
@@ -332,12 +336,13 @@ class Graph extends Primitive_1.Primitive {
332
336
  this._specExposePin(type, pinId, subPinId, subPinSpec);
333
337
  });
334
338
  };
335
- this._memExposePinSet = (type, pinId, pinSpec, exposedPin, exposedMerge) => {
339
+ this._memExposePinSet = (type, pinId, pinSpec, exposedPin, exposedMerge, exposedMergeOpposite) => {
336
340
  // console.log('Graph', '_memExposePinSet', type, pinId, pinSpec)
337
341
  const { plug } = pinSpec;
338
- const exposedNodeId = (0, util_1.getExposedPinId)(pinId, type);
339
- this._exposedPin[exposedNodeId] = exposedPin;
340
- this._exposedMerge[exposedNodeId] = exposedMerge;
342
+ const oppositeType = (0, util_1.opposite)(type);
343
+ (0, object_1.pathSet)(this._exposedPin, [type, pinId], exposedPin);
344
+ (0, object_1.pathSet)(this._exposedMerge, [type, pinId, type], exposedMerge);
345
+ (0, object_1.pathSet)(this._exposedMerge, [type, pinId, oppositeType], exposedMergeOpposite);
341
346
  (0, f_2.default)(plug, (subPinSpec, subPinId) => {
342
347
  this._memExposePin(type, pinId, subPinId, subPinSpec);
343
348
  });
@@ -409,12 +414,12 @@ class Graph extends Primitive_1.Primitive {
409
414
  // console.log('Graph', '_memCoverPinSet', type, pinId)
410
415
  const pinSpec = this.getExposedPinSpec(type, pinId);
411
416
  const { plug } = pinSpec;
412
- const exposedNodeId = (0, util_1.getExposedPinId)(pinId, type);
413
417
  (0, f_2.default)(plug, (subPinSpec, subPinId) => {
414
418
  this._memCoverPin(type, pinId, subPinId);
415
419
  });
416
- delete this._exposedPin[exposedNodeId];
417
- delete this._exposedMerge[exposedNodeId];
420
+ (0, object_1.pathDestroy)(this._exposedPin, [type, pinId]);
421
+ (0, object_1.pathDestroy)(this._exposedMerge, [type, pinId, 'input']);
422
+ (0, object_1.pathDestroy)(this._exposedMerge, [type, pinId, 'output']);
418
423
  };
419
424
  this._specCoverPinSet = (type, pinId) => {
420
425
  // console.log('Graph', '_specCoverPinSet', type, pinId)
@@ -437,13 +442,13 @@ class Graph extends Primitive_1.Primitive {
437
442
  (0, object_1.pathSet)(this._spec, [`${type}s`, pinId, 'ref'], ref);
438
443
  };
439
444
  this._memPlugPin = (type, pinId, subPinId, subPinSpec) => {
440
- const { mergeId, unitId: _unitId, pinId: _pinId } = subPinSpec;
445
+ const { mergeId, unitId: _unitId, pinId: _pinId, kind = type } = subPinSpec;
441
446
  let ref = undefined;
442
447
  if (_unitId && _pinId) {
443
- if (this.isUnitRefPin(_unitId, type, _pinId) || _pinId === SELF_1.SELF) {
448
+ if (this.isUnitRefPin(_unitId, kind, _pinId) || _pinId === SELF_1.SELF) {
444
449
  ref = true;
445
450
  }
446
- this._memPlugPinToUnitPin(type, pinId, subPinId, _unitId, _pinId);
451
+ this._memPlugPinToUnitPin(type, pinId, subPinId, _unitId, kind, _pinId);
447
452
  }
448
453
  else if (mergeId) {
449
454
  const merge = this.getMergeSpec(mergeId);
@@ -465,10 +470,10 @@ class Graph extends Primitive_1.Primitive {
465
470
  };
466
471
  this._specPlugPin = (type, pinId, subPinId, subPinSpec) => {
467
472
  // console.log('Graph', '_specPlugPin', type, pinId, subPinId, subPinSpec)
468
- const { mergeId: _mergeId, unitId: _unitId, pinId: _pinId } = subPinSpec;
473
+ const { mergeId: _mergeId, unitId: _unitId, pinId: _pinId, kind = type, } = subPinSpec;
469
474
  let ref = undefined;
470
475
  if (_unitId && _pinId) {
471
- if (this.isUnitRefPin(_unitId, type, _pinId) || _pinId === SELF_1.SELF) {
476
+ if (this.isUnitRefPin(_unitId, kind, _pinId) || _pinId === SELF_1.SELF) {
472
477
  ref = true;
473
478
  }
474
479
  }
@@ -490,7 +495,7 @@ class Graph extends Primitive_1.Primitive {
490
495
  (0, spec_2.plugPin)({ type, pinId, subPinId, subPinSpec }, this._spec);
491
496
  };
492
497
  this.plugPin = (type, pinId, subPinId, subPinSpec, emit = true, propagate = true) => {
493
- // console.log('Graph', 'plugPin', pinId, subPinId, subPinSpec)
498
+ // console.log('Graph', 'plugPin', type, pinId, subPinId, subPinSpec)
494
499
  this._plugPin(type, pinId, subPinId, subPinSpec, propagate);
495
500
  emit && this.emit('plug_pin', type, pinId, subPinId, subPinSpec, []);
496
501
  };
@@ -508,7 +513,7 @@ class Graph extends Primitive_1.Primitive {
508
513
  };
509
514
  this._plugPin = (type, pinId, subPinId, subPinSpec, propagate = true) => {
510
515
  // console.log('Graph', '_plugPin', type, pinId, subPinId, subPinSpec)
511
- const { mergeId, unitId, pinId: _pinId } = subPinSpec;
516
+ const { mergeId, unitId, pinId: _pinId, kind = type } = subPinSpec;
512
517
  if ((0, object_1.pathOrDefault)(this._exposedEmptySubPin, [type, pinId, subPinId], undefined)) {
513
518
  this._simUnplugPinFromEmpty(type, pinId, subPinId);
514
519
  this._memRemoveEmptyPin(type, pinId, subPinId);
@@ -520,7 +525,7 @@ class Graph extends Primitive_1.Primitive {
520
525
  this._plugPinToMerge(type, pinId, subPinId, mergeId, opt, propagate);
521
526
  }
522
527
  else if (unitId && _pinId) {
523
- this._plugPinToUnitPin(type, pinId, subPinId, unitId, _pinId, opt, propagate);
528
+ this._plugPinToUnitPin(type, pinId, subPinId, unitId, kind, _pinId, opt, propagate);
524
529
  }
525
530
  else {
526
531
  //
@@ -531,12 +536,12 @@ class Graph extends Primitive_1.Primitive {
531
536
  };
532
537
  this._simPlugPin = (type, pinId, subPinId, subPinSpec, propagate = true) => {
533
538
  // console.log('Graph', '_simPlugPin', pinId, subPinId, subPinSpec)
534
- const { mergeId, unitId, pinId: _pinId } = subPinSpec;
539
+ const { mergeId, unitId, pinId: _pinId, kind = type } = subPinSpec;
535
540
  if (mergeId) {
536
541
  this._simPlugPinToMerge(type, pinId, subPinId, mergeId, propagate);
537
542
  }
538
543
  else {
539
- this._simPlugPinToUnitPin(type, pinId, subPinId, unitId, _pinId, propagate);
544
+ this._simPlugPinToUnitPin(type, pinId, subPinId, unitId, kind, _pinId, propagate);
540
545
  }
541
546
  };
542
547
  this.plugInput = (subPinId, subPin, id) => {
@@ -651,7 +656,7 @@ class Graph extends Primitive_1.Primitive {
651
656
  };
652
657
  this.__simUnplugPin = (type, pinId, subPinId, propagate = true) => {
653
658
  const subPinSpec = this.getSubPinSpec(type, pinId, subPinId);
654
- const { mergeId: _mergeId, unitId: _unitId, pinId: _pinId } = subPinSpec;
659
+ const { mergeId: _mergeId, unitId: _unitId, pinId: _pinId, kind = type, } = subPinSpec;
655
660
  const isOutput = type === 'output';
656
661
  if (isOutput) {
657
662
  if (_mergeId) {
@@ -666,7 +671,7 @@ class Graph extends Primitive_1.Primitive {
666
671
  else if (_unitId && _pinId) {
667
672
  const unit = this.getUnit(_unitId);
668
673
  const isUnitPinRef = unit.isPinRef(type, _pinId);
669
- this._simUnplugPinFromUnitPin(type, pinId, subPinId, _unitId, _pinId);
674
+ this._simUnplugPinFromUnitPin(type, pinId, subPinId, _unitId, _pinId, kind);
670
675
  if (propagate) {
671
676
  if (isUnitPinRef) {
672
677
  if (isOutput) {
@@ -679,15 +684,21 @@ class Graph extends Primitive_1.Primitive {
679
684
  }
680
685
  }
681
686
  if (isRef) {
682
- const exposedPinId = (0, util_1.getExposedPinId)(pinId, type);
683
- const exposedMerge = this._exposedMerge[exposedPinId];
687
+ const oppositeType = (0, util_1.opposite)(type);
688
+ const exposedMerge = (0, f_1.default)(this._exposedMerge, [type, pinId, type]);
689
+ const exposedMergeOpposite = (0, f_1.default)(this._exposedMerge, [
690
+ type,
691
+ pinId,
692
+ oppositeType,
693
+ ]);
684
694
  exposedMerge.reset();
695
+ exposedMergeOpposite.reset();
685
696
  }
686
697
  };
687
698
  this._simPlugEmptyPin = (type, pinId, subPinId, propagate = true) => {
688
699
  // console.log('Graph', '_simPlugEmptyPin', type, pinId, subPinId)
689
700
  const emptySubPin = this._ensureEmptySubPin(type, pinId, subPinId);
690
- this._simSetExposedSubPin(type, pinId, subPinId, emptySubPin, propagate);
701
+ this._simSetExposedSubPin(type, pinId, type, subPinId, emptySubPin, propagate);
691
702
  };
692
703
  this._memUnplugInput = (pinId, subPinId) => {
693
704
  return this._memUnplugPin('input', pinId, subPinId);
@@ -702,12 +713,10 @@ class Graph extends Primitive_1.Primitive {
702
713
  return this._simUnplugPin('output', pinId, subPinId);
703
714
  };
704
715
  this.getExposedInputPin = (id) => {
705
- const exposedInputId = (0, util_1.getExposedPinId)(id, 'input');
706
- return this._exposedPin[exposedInputId];
716
+ return (0, f_1.default)(this._exposedPin, ['input', id]);
707
717
  };
708
718
  this.getExposedOutputPin = (id) => {
709
- const exposedOutputId = (0, util_1.getExposedPinId)(id, 'output');
710
- return this._exposedPin[exposedOutputId];
719
+ return (0, f_1.default)(this._exposedPin, ['output', id]);
711
720
  };
712
721
  this.getUnitOuterSpec = (unitId) => {
713
722
  const outerSpec = {
@@ -988,6 +997,7 @@ class Graph extends Primitive_1.Primitive {
988
997
  const exposedOutputId = this.getExposedOutput({
989
998
  unitId,
990
999
  pinId: SELF_1.SELF,
1000
+ kind: 'output',
991
1001
  });
992
1002
  this._simUnplugUnit(unitId, take);
993
1003
  if (take) {
@@ -1029,10 +1039,18 @@ class Graph extends Primitive_1.Primitive {
1029
1039
  const otherMergeUnitPinId = (0, object_1.getObjSingleKey)((_a = mergeSpec === null || mergeSpec === void 0 ? void 0 : mergeSpec[otherMergeUnitId]) === null || _a === void 0 ? void 0 : _a[otherMergeUnitType]);
1030
1040
  this._specRemoveMerge(mergeId);
1031
1041
  if (mergeInputPlug) {
1032
- this._specPlugPin('input', mergeInputPlug.pinId, mergeInputPlug.subPinId, { unitId: otherMergeUnitId, pinId: otherMergeUnitPinId });
1042
+ this._specPlugPin('input', mergeInputPlug.pinId, mergeInputPlug.subPinId, {
1043
+ unitId: otherMergeUnitId,
1044
+ pinId: otherMergeUnitPinId,
1045
+ kind: 'input',
1046
+ });
1033
1047
  }
1034
1048
  if (mergeOutputPlug) {
1035
- this._specPlugPin('output', mergeOutputPlug.pinId, mergeOutputPlug.subPinId, { unitId: otherMergeUnitId, pinId: otherMergeUnitPinId });
1049
+ this._specPlugPin('output', mergeOutputPlug.pinId, mergeOutputPlug.subPinId, {
1050
+ unitId: otherMergeUnitId,
1051
+ pinId: otherMergeUnitPinId,
1052
+ kind: 'output',
1053
+ });
1036
1054
  }
1037
1055
  }
1038
1056
  else {
@@ -1069,10 +1087,18 @@ class Graph extends Primitive_1.Primitive {
1069
1087
  const otherMergeUnitPinId = (0, object_1.getObjSingleKey)((_a = mergeSpec === null || mergeSpec === void 0 ? void 0 : mergeSpec[otherMergeUnitId]) === null || _a === void 0 ? void 0 : _a[otherMergeUnitType]);
1070
1088
  this._simRemoveMerge(mergeId, take);
1071
1089
  if (mergeInputPlug) {
1072
- this._simPlugPin('input', mergeInputPlug.pinId, mergeInputPlug.subPinId, { unitId: otherMergeUnitId, pinId: otherMergeUnitPinId }, false);
1090
+ this._simPlugPin('input', mergeInputPlug.pinId, mergeInputPlug.subPinId, {
1091
+ unitId: otherMergeUnitId,
1092
+ pinId: otherMergeUnitPinId,
1093
+ kind: 'input',
1094
+ }, false);
1073
1095
  }
1074
1096
  if (mergeOutputPlug) {
1075
- this._simPlugPin('output', mergeOutputPlug.pinId, mergeOutputPlug.subPinId, { unitId: otherMergeUnitId, pinId: otherMergeUnitPinId }, false);
1097
+ this._simPlugPin('output', mergeOutputPlug.pinId, mergeOutputPlug.subPinId, {
1098
+ unitId: otherMergeUnitId,
1099
+ pinId: otherMergeUnitPinId,
1100
+ kind: 'output',
1101
+ }, false);
1076
1102
  }
1077
1103
  }
1078
1104
  else {
@@ -1390,8 +1416,9 @@ class Graph extends Primitive_1.Primitive {
1390
1416
  if (!this._spec.id) {
1391
1417
  system.newSpec(this._spec);
1392
1418
  }
1393
- const specs = Object.assign(Object.assign({}, ((_a = spec.specs) !== null && _a !== void 0 ? _a : {})), { [id]: spec });
1394
- this._specs = this.__system.specs;
1419
+ // const specs = { ...(spec.specs ?? {}), [id]: spec }
1420
+ const specs = (0, weakMerge_1.weakMerge)(system.specs, (0, weakMerge_1.weakMerge)((_a = spec.specs) !== null && _a !== void 0 ? _a : {}, { [id]: spec }));
1421
+ this._specs = specs;
1395
1422
  const { inputs = {}, outputs = {}, units = {}, merges = {}, component = {}, render = false, } = this._spec;
1396
1423
  this._branch = branch;
1397
1424
  this._initAddUnits(units);
@@ -1508,40 +1535,54 @@ class Graph extends Primitive_1.Primitive {
1508
1535
  this._simRemoveBranch(mergeId, type, pinNodeId);
1509
1536
  this._memRemoveBranch(mergeId, type, pinNodeId);
1510
1537
  }
1511
- setExposedSubPin(type, name, subPinId, subPin, opt) {
1512
- this._setExposedSubPin(type, name, subPinId, subPin, opt);
1513
- this.emit('set_exposed_sub_pin', type, name, subPinId, subPin, opt, []);
1514
- }
1515
- _setExposedSubPin(type, name, subPinId, subPin, opt, propagate = true) {
1516
- const oppositeType = (0, util_1.opposite)(type);
1517
- const exposedPinId = (0, util_1.getExposedPinId)(name, type);
1518
- const exposedMerge = this._exposedMerge[exposedPinId];
1519
- exposedMerge.setPin(oppositeType, subPinId, subPin, opt, propagate);
1538
+ _setExposedSubPin(type, name, kind, subPinId, subPin, opt, propagate = true) {
1539
+ // console.log('Graph', '_setExposedSubPin', type, name, kind, subPinId, subPin, opt)
1540
+ this._simSetExposedSubPin(type, name, kind, subPinId, subPin, propagate);
1520
1541
  }
1521
1542
  _memSetExposedSubPin(type, name, subPinId, subPin) {
1522
1543
  //
1523
1544
  }
1524
- _simSetExposedSubPin(type, name, subPinId, subPin, propagate = true) {
1545
+ _simSetExposedSubPin(type, name, kind, subPinId, subPin, propagate = true) {
1525
1546
  // console.log(
1526
1547
  // 'Graph',
1527
1548
  // '_simSetExposedSubPin',
1528
1549
  // type,
1529
1550
  // name,
1551
+ // kind,
1530
1552
  // subPinId,
1531
1553
  // subPin,
1532
1554
  // propagate
1533
1555
  // )
1534
1556
  const oppositeType = (0, util_1.opposite)(type);
1535
- const exposedPinId = (0, util_1.getExposedPinId)(name, type);
1536
- const exposedMerge = this._exposedMerge[exposedPinId];
1537
- exposedMerge.setPin(oppositeType, subPinId, subPin, {}, propagate);
1557
+ const exposedMerge = (0, f_1.default)(this._exposedMerge, [type, name, type]);
1558
+ const exposedMergeOpposite = (0, f_1.default)(this._exposedMerge, [
1559
+ type,
1560
+ name,
1561
+ oppositeType,
1562
+ ]);
1563
+ if (type === kind || (0, object_1.pathOrDefault)(this._exposedEmptySubPin, [type, name, subPinId], undefined)) {
1564
+ exposedMerge.setPin(oppositeType, subPinId, subPin, {}, propagate);
1565
+ }
1566
+ else {
1567
+ exposedMergeOpposite.setPin(type, subPinId, subPin, {}, propagate);
1568
+ }
1538
1569
  }
1539
1570
  _simRemoveExposedSubPin(type, name, subPinId) {
1540
- // console.log('Graph', '_simRemoveExposedSubPin', type, name, subPinId)
1571
+ const subPinSpec = this.getSubPinSpec(type, name, subPinId);
1572
+ const { kind = type } = subPinSpec;
1541
1573
  const oppositeType = (0, util_1.opposite)(type);
1542
- const exposedPinId = (0, util_1.getExposedPinId)(name, type);
1543
- const exposedMerge = this._exposedMerge[exposedPinId];
1544
- exposedMerge.removePin(oppositeType, subPinId);
1574
+ const exposedMerge = (0, f_1.default)(this._exposedMerge, [type, name, type]);
1575
+ const exposedMergeOpposite = (0, f_1.default)(this._exposedMerge, [
1576
+ type,
1577
+ name,
1578
+ oppositeType,
1579
+ ]);
1580
+ if (type === kind || (0, object_1.pathOrDefault)(this._exposedEmptySubPin, [type, name, subPinId], undefined)) {
1581
+ exposedMerge.removePin(oppositeType, subPinId);
1582
+ }
1583
+ else {
1584
+ exposedMergeOpposite.removePin(type, subPinId);
1585
+ }
1545
1586
  }
1546
1587
  _play() {
1547
1588
  (0, f_2.default)(this._unit, (u) => u.play());
@@ -1634,16 +1675,24 @@ class Graph extends Primitive_1.Primitive {
1634
1675
  const merge_state = merge.snapshot();
1635
1676
  state.merge[mergeId] = merge_state;
1636
1677
  }
1637
- for (const pinId in this._exposedMerge) {
1638
- const merge = this._exposedMerge[pinId];
1639
- const merge_state = merge.snapshot();
1640
- state.exposedMerge[pinId] = merge_state;
1641
- }
1678
+ (0, IOOf_1.forIOObjKV)(this._exposedMerge, (type, pinId) => {
1679
+ const oppositeType = (0, util_1.opposite)(type);
1680
+ const merge = (0, f_1.default)(this._exposedMerge, [type, pinId, type]);
1681
+ const mergeOpposite = (0, f_1.default)(this._exposedMerge, [
1682
+ type,
1683
+ pinId,
1684
+ oppositeType,
1685
+ ]);
1686
+ const mergeState = merge.snapshot();
1687
+ const mergeOppositeState = mergeOpposite.snapshot();
1688
+ (0, object_1.pathSet)(state.exposedMerge, [type, pinId, type], mergeState);
1689
+ (0, object_1.pathSet)(state.exposedMerge, [type, pinId, oppositeType], mergeOppositeState);
1690
+ });
1642
1691
  state.waitAll = this._waitAll['input'].snapshot();
1643
1692
  return state;
1644
1693
  }
1645
1694
  restoreSelf(state) {
1646
- var _a, _b, _c;
1695
+ var _a, _b;
1647
1696
  super.restoreSelf(state);
1648
1697
  for (const unitId in this._unit) {
1649
1698
  const unit = this._unit[unitId];
@@ -1659,16 +1708,25 @@ class Graph extends Primitive_1.Primitive {
1659
1708
  merge.restore(merge_state);
1660
1709
  }
1661
1710
  }
1662
- for (const exposedPinId in this._exposedMerge) {
1663
- const [type, pinId] = exposedPinId.split('/');
1711
+ (0, IOOf_1.forIOObjKV)(this._exposedMerge, (type, pinId) => {
1712
+ const oppositeType = (0, util_1.opposite)(type);
1664
1713
  if (this.hasDataPinNamed(type, pinId)) {
1665
- const merge = this._exposedMerge[exposedPinId];
1666
- const merge_state = (_c = state.exposedMerge) === null || _c === void 0 ? void 0 : _c[exposedPinId];
1667
- if (merge_state) {
1668
- merge.restore(merge_state);
1714
+ const merge = (0, f_1.default)(this._exposedMerge, [type, pinId, type]);
1715
+ const mergeOpposite = (0, f_1.default)(this._exposedMerge, [
1716
+ type,
1717
+ pinId,
1718
+ oppositeType,
1719
+ ]);
1720
+ const mergeState = (0, object_1.pathOrDefault)(state, ['exposedMerge', type, pinId, type], undefined);
1721
+ const mergeOppositeState = (0, object_1.pathOrDefault)(state, ['exposedMerge', type, pinId, oppositeType], undefined);
1722
+ if (mergeState) {
1723
+ merge.restore(mergeState);
1724
+ }
1725
+ if (mergeOppositeState) {
1726
+ mergeOpposite.restore(mergeOppositeState);
1669
1727
  }
1670
1728
  }
1671
- }
1729
+ });
1672
1730
  const wait_all_state = state.waitAll;
1673
1731
  if (wait_all_state) {
1674
1732
  this._waitAll['input'].restore(wait_all_state);
@@ -1710,9 +1768,11 @@ class Graph extends Primitive_1.Primitive {
1710
1768
  this._setComponentSize(width, height);
1711
1769
  // emit && this.emit('set_component_size', unitId, width, height, [])
1712
1770
  }
1713
- _simExposePinSet(type, pinId, pinSpec, exposedPin, exposedMerge, propagate = true) {
1771
+ _simExposePinSet(type, pinId, pinSpec, exposedPin, exposedMerge, exposedMergeOpposite, propagate = true) {
1714
1772
  const { plug, ref } = pinSpec;
1773
+ const oppositeType = (0, util_1.opposite)(type);
1715
1774
  exposedMerge.setPin(type, pinId, exposedPin);
1775
+ exposedMergeOpposite.setPin(oppositeType, pinId, exposedPin);
1716
1776
  (0, f_2.default)(plug, (subPinSpec, subPinId) => {
1717
1777
  this._simExposePin(type, pinId, subPinId, subPinSpec, propagate);
1718
1778
  });
@@ -1749,10 +1809,10 @@ class Graph extends Primitive_1.Primitive {
1749
1809
  this._unplugFromWaitAll(type, pinId);
1750
1810
  }
1751
1811
  }
1752
- setPinSetId(type, pinId, nextPinId) {
1812
+ setPinSetId(type, pinId, nextPinId, emit = true) {
1753
1813
  this._setPinSetId(type, pinId, nextPinId);
1754
1814
  this.renamePin(type, pinId, nextPinId);
1755
- this.emit('set_pin_set_id', type, pinId, nextPinId, []);
1815
+ emit && this.emit('set_pin_set_id', type, pinId, nextPinId, []);
1756
1816
  }
1757
1817
  _setPinSetId(type, pinId, nextPinId) {
1758
1818
  // console.log('Graph', '_setPinSetId', type, pinId, nextPinId)
@@ -1762,7 +1822,7 @@ class Graph extends Primitive_1.Primitive {
1762
1822
  this._spec[`${type}s`][nextPinId] = pinSpec;
1763
1823
  }
1764
1824
  isExposedInput(pin) {
1765
- const inputs = this._spec.inputs || {};
1825
+ const { inputs = {} } = this._spec;
1766
1826
  const pinNodeId = this._getExposedSubPinNodeId('input', pin);
1767
1827
  return (0, object_1.someObj)(inputs, ({ plug }) => {
1768
1828
  return (0, object_1.someObj)(plug, (i) => {
@@ -1889,6 +1949,7 @@ class Graph extends Primitive_1.Primitive {
1889
1949
  this._plugPin(outerPin.type, outerPin.pinId, outerPin.subPinId, {
1890
1950
  unitId: nextUnitId,
1891
1951
  pinId: nextPinId,
1952
+ kind: outerPin.type,
1892
1953
  });
1893
1954
  });
1894
1955
  }
@@ -1926,6 +1987,7 @@ class Graph extends Primitive_1.Primitive {
1926
1987
  this._plugPin(outerPin.type, outerPin.pinId, outerPin.subPinId, {
1927
1988
  unitId: nextUnitId,
1928
1989
  pinId,
1990
+ kind: outerPin.type,
1929
1991
  });
1930
1992
  });
1931
1993
  if (snapshot) {
@@ -2048,8 +2110,7 @@ class Graph extends Primitive_1.Primitive {
2048
2110
  }
2049
2111
  getPlug(type, pinId, subPinId) {
2050
2112
  const oppositeType = (0, util_1.opposite)(type);
2051
- const exposedPinId = (0, util_1.getExposedPinId)(pinId, type);
2052
- const exposedMerge = this._exposedMerge[exposedPinId];
2113
+ const exposedMerge = (0, f_1.default)(this._exposedMerge, [type, pinId, type]);
2053
2114
  const plug = exposedMerge.getPin(oppositeType, subPinId);
2054
2115
  return plug;
2055
2116
  }
@@ -2180,12 +2241,16 @@ class Graph extends Primitive_1.Primitive {
2180
2241
  const pinNodeId = (0, util_1.getPinNodeId)(unitId, type, pinId);
2181
2242
  const pipedToMerge = this._pipedTo[pinNodeId];
2182
2243
  const pipedFromMerge = this._pipedFrom[pinNodeId];
2244
+ const pinPlug = (0, util_1.findUnitPinPlug)(this._spec, unitId, type, pinId);
2183
2245
  if (pipedToMerge) {
2184
2246
  this._removePinOrMerge(pipedToMerge, unitId, type, pinId);
2185
2247
  }
2186
2248
  if (pipedFromMerge) {
2187
2249
  this._removePinOrMerge(pipedFromMerge, unitId, type, pinId);
2188
2250
  }
2251
+ if (pinPlug) {
2252
+ this._unplugPin(type, pinPlug.pinId, pinPlug.subPinId);
2253
+ }
2189
2254
  delete this._pipedTo[pinNodeId];
2190
2255
  delete this._pipedFrom[pinNodeId];
2191
2256
  delete this._pin[pinNodeId];
@@ -2758,7 +2823,7 @@ class Graph extends Primitive_1.Primitive {
2758
2823
  }
2759
2824
  setUnitPinSetId(unitId, type, pinId, newPinId, emit = true) {
2760
2825
  const unit = this.getUnit(unitId);
2761
- unit.setPinSetId(type, pinId, newPinId);
2826
+ unit.setPinSetId(type, pinId, newPinId, false);
2762
2827
  emit && this.emit('set_unit_pin_set_id', unitId, type, pinId, newPinId, []);
2763
2828
  }
2764
2829
  setUnitPinConstant(unitId, type, pinId, constant, emit = true) {
@@ -2845,6 +2910,7 @@ class Graph extends Primitive_1.Primitive {
2845
2910
  this._plugPin(type, plugSpec.pinId, plugSpec.subPinId, {
2846
2911
  unitId,
2847
2912
  pinId,
2913
+ kind: type,
2848
2914
  }, propagate);
2849
2915
  });
2850
2916
  }