@zk-tech/bedrock 0.2.1-alpha.1 → 0.3.1

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 (69) hide show
  1. package/dist/assert/index.cjs +9 -9
  2. package/dist/assert/index.cjs.map +1 -1
  3. package/dist/assert/index.d.cts +5 -5
  4. package/dist/assert/index.d.ts +5 -5
  5. package/dist/assert/index.js +6 -6
  6. package/dist/assert/index.js.map +1 -1
  7. package/dist/async/index.cjs +2 -2
  8. package/dist/async/index.cjs.map +1 -1
  9. package/dist/async/index.js +2 -2
  10. package/dist/async/index.js.map +1 -1
  11. package/dist/cache/index.cjs.map +1 -1
  12. package/dist/cache/index.js.map +1 -1
  13. package/dist/di/index.cjs +26 -26
  14. package/dist/di/index.cjs.map +1 -1
  15. package/dist/di/index.js +26 -26
  16. package/dist/di/index.js.map +1 -1
  17. package/dist/dispose/index.cjs +3 -3
  18. package/dist/dispose/index.cjs.map +1 -1
  19. package/dist/dispose/index.js +3 -3
  20. package/dist/dispose/index.js.map +1 -1
  21. package/dist/error/index.cjs +18 -18
  22. package/dist/error/index.cjs.map +1 -1
  23. package/dist/error/index.d.cts +2 -2
  24. package/dist/error/index.d.ts +2 -2
  25. package/dist/error/index.js +18 -18
  26. package/dist/error/index.js.map +1 -1
  27. package/dist/event/index.cjs +3 -3
  28. package/dist/event/index.cjs.map +1 -1
  29. package/dist/event/index.js +3 -3
  30. package/dist/event/index.js.map +1 -1
  31. package/dist/json/index.cjs +3 -3
  32. package/dist/json/index.cjs.map +1 -1
  33. package/dist/json/index.js +3 -3
  34. package/dist/json/index.js.map +1 -1
  35. package/dist/launch/index.cjs +5 -5
  36. package/dist/launch/index.cjs.map +1 -1
  37. package/dist/launch/index.js +5 -5
  38. package/dist/launch/index.js.map +1 -1
  39. package/dist/lock/index.cjs +14 -14
  40. package/dist/lock/index.cjs.map +1 -1
  41. package/dist/lock/index.js +14 -14
  42. package/dist/lock/index.js.map +1 -1
  43. package/dist/objects/index.cjs +3 -3
  44. package/dist/objects/index.cjs.map +1 -1
  45. package/dist/objects/index.js +3 -3
  46. package/dist/objects/index.js.map +1 -1
  47. package/dist/promise/index.cjs +8 -8
  48. package/dist/promise/index.cjs.map +1 -1
  49. package/dist/promise/index.js +8 -8
  50. package/dist/promise/index.js.map +1 -1
  51. package/dist/scheduler/index.cjs +15 -15
  52. package/dist/scheduler/index.cjs.map +1 -1
  53. package/dist/scheduler/index.d.cts +5 -5
  54. package/dist/scheduler/index.d.ts +5 -5
  55. package/dist/scheduler/index.js +13 -13
  56. package/dist/scheduler/index.js.map +1 -1
  57. package/dist/sprintf/index.cjs +4 -4
  58. package/dist/sprintf/index.cjs.map +1 -1
  59. package/dist/sprintf/index.js +4 -4
  60. package/dist/sprintf/index.js.map +1 -1
  61. package/dist/undo-redo-stack/index.cjs.map +1 -1
  62. package/dist/undo-redo-stack/index.js.map +1 -1
  63. package/dist/worker/index.cjs +7 -7
  64. package/dist/worker/index.cjs.map +1 -1
  65. package/dist/worker/index.d.cts +1 -1
  66. package/dist/worker/index.d.ts +1 -1
  67. package/dist/worker/index.js +7 -7
  68. package/dist/worker/index.js.map +1 -1
  69. package/package.json +1 -1
package/dist/di/index.js CHANGED
@@ -116,14 +116,14 @@ var Logger = {
116
116
 
117
117
  // src/assert/assert.ts
118
118
  function abort(reason) {
119
- throw new Error(`lvAssert(${reason})`);
119
+ throw new Error(`zkAssert(${reason})`);
120
120
  }
121
- function lvAssert(expr, reason) {
121
+ function zkAssert(expr, reason) {
122
122
  if (!expr) {
123
123
  abort(reason ?? "#expr is false");
124
124
  }
125
125
  }
126
- function lvAssertNotNil(val, reason) {
126
+ function zkAssertNotNil(val, reason) {
127
127
  if (val === null || val === void 0) {
128
128
  abort(reason ?? "#val is nil");
129
129
  }
@@ -172,7 +172,7 @@ var Task = class {
172
172
  return this._callback;
173
173
  }
174
174
  setCallback(callback) {
175
- lvAssert(this._callback === void 0, "cant overlay callback.");
175
+ zkAssert(this._callback === void 0, "cant overlay callback.");
176
176
  this._callback = callback;
177
177
  }
178
178
  clearCallback() {
@@ -410,14 +410,14 @@ var AbstractExecutor = class {
410
410
  return this._deadline;
411
411
  }
412
412
  setFrameRate(fps) {
413
- lvAssert(fps > 0 && fps <= 125);
413
+ zkAssert(fps > 0 && fps <= 125);
414
414
  this._yieldInterval = Math.floor(1e3 / fps);
415
415
  }
416
416
  resetFrameRate() {
417
417
  this._yieldInterval = 16;
418
418
  }
419
419
  requestHostTimeout(fn, delayMs) {
420
- lvAssert(this._timeoutId === -1, "has request host timeout.");
420
+ zkAssert(this._timeoutId === -1, "has request host timeout.");
421
421
  clearTimeout(this._timeoutId);
422
422
  this._timeoutId = setTimeout(() => {
423
423
  this._timeoutId = -1;
@@ -666,8 +666,8 @@ var Scheduler = class {
666
666
  this._requestHostTimeout(currentTime);
667
667
  }
668
668
  _requestHostTimeout(currentTime) {
669
- lvAssert(!this._isHostCallbackScheduled);
670
- lvAssert(!this._isHostTimeoutScheduled);
669
+ zkAssert(!this._isHostCallbackScheduled);
670
+ zkAssert(!this._isHostTimeoutScheduled);
671
671
  const firstTimerTask = this._taskQueue.timerTasks.peek();
672
672
  if (firstTimerTask !== null) {
673
673
  this._isHostTimeoutScheduled = true;
@@ -710,8 +710,8 @@ var CallbackToken = class {
710
710
  }
711
711
  };
712
712
 
713
- // src/scheduler/lv-scheduler-callback.ts
714
- function lvSchedulerCallback(callback, options = {}) {
713
+ // src/scheduler/zk-scheduler-callback.ts
714
+ function zkSchedulerCallback(callback, options = {}) {
715
715
  const newTask = makeTask(callback, options);
716
716
  getScheduler().addTask(newTask);
717
717
  return new CallbackToken(newTask);
@@ -1023,7 +1023,7 @@ var IdleValue = class {
1023
1023
  }
1024
1024
  }
1025
1025
  };
1026
- this._handle = lvSchedulerCallback(() => this._executor(), {
1026
+ this._handle = zkSchedulerCallback(() => this._executor(), {
1027
1027
  priorityLevel: 4 /* IdlePriority */
1028
1028
  });
1029
1029
  }
@@ -1617,7 +1617,7 @@ var ServiceRegistry = class {
1617
1617
  );
1618
1618
  }
1619
1619
  if (this._checkDuplicate) {
1620
- lvAssert(!this._ids.has(id.toString()), `service: ${id.toString()} duplicate register.`);
1620
+ zkAssert(!this._ids.has(id.toString()), `service: ${id.toString()} duplicate register.`);
1621
1621
  this._ids.add(id.toString());
1622
1622
  }
1623
1623
  this._registry.push([id, ctorOrDescriptor]);
@@ -1630,7 +1630,7 @@ var ServiceRegistry = class {
1630
1630
  */
1631
1631
  registerInstance(id, instance, options) {
1632
1632
  if (this._checkDuplicate) {
1633
- lvAssert(!this._ids.has(id.toString()), `service: ${id.toString()} duplicate register.`);
1633
+ zkAssert(!this._ids.has(id.toString()), `service: ${id.toString()} duplicate register.`);
1634
1634
  this._ids.add(id.toString());
1635
1635
  }
1636
1636
  this._registry.push([id, instance]);
@@ -1658,11 +1658,11 @@ var Capability = class {
1658
1658
  return this._status;
1659
1659
  }
1660
1660
  acquire() {
1661
- lvAssert(this._status === 0 /* Unlocked */);
1661
+ zkAssert(this._status === 0 /* Unlocked */);
1662
1662
  this._status = 1 /* Locked */;
1663
1663
  }
1664
1664
  release() {
1665
- lvAssert(this._status === 1 /* Locked */);
1665
+ zkAssert(this._status === 1 /* Locked */);
1666
1666
  this._status = 0 /* Unlocked */;
1667
1667
  this._onUnlocked.fire();
1668
1668
  }
@@ -1687,7 +1687,7 @@ var SharedCapability = class {
1687
1687
  this._counter++;
1688
1688
  }
1689
1689
  release() {
1690
- lvAssert(this._counter > 0);
1690
+ zkAssert(this._counter > 0);
1691
1691
  this._counter--;
1692
1692
  if (this._counter === 0) {
1693
1693
  this._status = 0 /* Unlocked */;
@@ -1749,7 +1749,7 @@ var SharedMutex = class {
1749
1749
  * 解除写锁
1750
1750
  */
1751
1751
  unLock() {
1752
- lvAssertNotNil(this._writer);
1752
+ zkAssertNotNil(this._writer);
1753
1753
  this._writer.release();
1754
1754
  }
1755
1755
  /**
@@ -1783,9 +1783,9 @@ var SharedMutex = class {
1783
1783
  * 解除读锁
1784
1784
  */
1785
1785
  unLockShared() {
1786
- lvAssertNotNil(this._reader);
1786
+ zkAssertNotNil(this._reader);
1787
1787
  if (this._writer) {
1788
- lvAssert(this._writer.status === 0 /* Unlocked */);
1788
+ zkAssert(this._writer.status === 0 /* Unlocked */);
1789
1789
  }
1790
1790
  this._reader.release();
1791
1791
  }
@@ -1799,7 +1799,7 @@ var SharedMutex = class {
1799
1799
  * 写者进入第一道门
1800
1800
  */
1801
1801
  _writerEnterGate1(resolve) {
1802
- lvAssert(!this._writer);
1802
+ zkAssert(!this._writer);
1803
1803
  this._writer = new Capability();
1804
1804
  if (this._readerCount > 0) {
1805
1805
  listenOnce(this._reader.onUnlocked)(() => {
@@ -1813,11 +1813,11 @@ var SharedMutex = class {
1813
1813
  * 写者进入第二道门
1814
1814
  */
1815
1815
  _writerEnterGate2(resolve) {
1816
- lvAssertNotNil(this._writer);
1817
- lvAssert(this._readerCount === 0);
1816
+ zkAssertNotNil(this._writer);
1817
+ zkAssert(this._readerCount === 0);
1818
1818
  this._writer.acquire();
1819
1819
  listenOnce(this._writer.onUnlocked)(() => {
1820
- lvAssertNotNil(this._writer);
1820
+ zkAssertNotNil(this._writer);
1821
1821
  this._writer = void 0;
1822
1822
  this._moveForward();
1823
1823
  });
@@ -1827,7 +1827,7 @@ var SharedMutex = class {
1827
1827
  * 读者进入第一道门
1828
1828
  */
1829
1829
  _readerEnterGate1(resolve) {
1830
- lvAssert(!this._writer);
1830
+ zkAssert(!this._writer);
1831
1831
  this._waitingReader = void 0;
1832
1832
  if (!this._reader) {
1833
1833
  this._reader = new SharedCapability();
@@ -1906,7 +1906,7 @@ var IdleServiceLoader = class {
1906
1906
  constructor(originService, staticArguments, _instantiationService) {
1907
1907
  this._instantiationService = _instantiationService;
1908
1908
  this._service = this._instantiationService.createInstance(originService, ...staticArguments);
1909
- lvSchedulerCallback(() => this._service.preload());
1909
+ zkSchedulerCallback(() => this._service.preload());
1910
1910
  }
1911
1911
  get loaded() {
1912
1912
  return this._service.loaded;
@@ -1934,7 +1934,7 @@ var InstantiationContext = (props) => {
1934
1934
  };
1935
1935
  function useService(identifier) {
1936
1936
  const instantiationService = useContext(Context);
1937
- lvAssertNotNil(instantiationService, "react components need service context.");
1937
+ zkAssertNotNil(instantiationService, "react components need service context.");
1938
1938
  const service = useMemo(
1939
1939
  () => instantiationService.invokeFunction(
1940
1940
  (servicesAccessor) => servicesAccessor.get(identifier)