@zk-tech/bedrock 0.1.5 → 0.2.1-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assert/index.cjs +9 -9
- package/dist/assert/index.cjs.map +1 -1
- package/dist/assert/index.d.cts +5 -5
- package/dist/assert/index.d.ts +5 -5
- package/dist/assert/index.js +6 -6
- package/dist/assert/index.js.map +1 -1
- package/dist/async/index.cjs +2 -2
- package/dist/async/index.cjs.map +1 -1
- package/dist/async/index.js +2 -2
- package/dist/async/index.js.map +1 -1
- package/dist/cache/index.cjs.map +1 -1
- package/dist/cache/index.js.map +1 -1
- package/dist/di/index.cjs +26 -26
- package/dist/di/index.cjs.map +1 -1
- package/dist/di/index.js +26 -26
- package/dist/di/index.js.map +1 -1
- package/dist/dispose/index.cjs +3 -3
- package/dist/dispose/index.cjs.map +1 -1
- package/dist/dispose/index.js +3 -3
- package/dist/dispose/index.js.map +1 -1
- package/dist/error/index.cjs +18 -18
- package/dist/error/index.cjs.map +1 -1
- package/dist/error/index.d.cts +2 -2
- package/dist/error/index.d.ts +2 -2
- package/dist/error/index.js +18 -18
- package/dist/error/index.js.map +1 -1
- package/dist/event/index.cjs +3 -3
- package/dist/event/index.cjs.map +1 -1
- package/dist/event/index.js +3 -3
- package/dist/event/index.js.map +1 -1
- package/dist/json/index.cjs +3 -3
- package/dist/json/index.cjs.map +1 -1
- package/dist/json/index.js +3 -3
- package/dist/json/index.js.map +1 -1
- package/dist/launch/index.cjs +5 -5
- package/dist/launch/index.cjs.map +1 -1
- package/dist/launch/index.js +5 -5
- package/dist/launch/index.js.map +1 -1
- package/dist/lock/index.cjs +14 -14
- package/dist/lock/index.cjs.map +1 -1
- package/dist/lock/index.js +14 -14
- package/dist/lock/index.js.map +1 -1
- package/dist/objects/index.cjs +3 -3
- package/dist/objects/index.cjs.map +1 -1
- package/dist/objects/index.js +3 -3
- package/dist/objects/index.js.map +1 -1
- package/dist/promise/index.cjs +8 -8
- package/dist/promise/index.cjs.map +1 -1
- package/dist/promise/index.js +8 -8
- package/dist/promise/index.js.map +1 -1
- package/dist/scheduler/index.cjs +15 -15
- package/dist/scheduler/index.cjs.map +1 -1
- package/dist/scheduler/index.d.cts +5 -5
- package/dist/scheduler/index.d.ts +5 -5
- package/dist/scheduler/index.js +13 -13
- package/dist/scheduler/index.js.map +1 -1
- package/dist/sprintf/index.cjs +4 -4
- package/dist/sprintf/index.cjs.map +1 -1
- package/dist/sprintf/index.js +4 -4
- package/dist/sprintf/index.js.map +1 -1
- package/dist/undo-redo-stack/index.cjs.map +1 -1
- package/dist/undo-redo-stack/index.js.map +1 -1
- package/dist/worker/index.cjs +7 -7
- package/dist/worker/index.cjs.map +1 -1
- package/dist/worker/index.d.cts +1 -1
- package/dist/worker/index.d.ts +1 -1
- package/dist/worker/index.js +7 -7
- package/dist/worker/index.js.map +1 -1
- package/package.json +3 -3
package/dist/di/index.cjs
CHANGED
|
@@ -118,14 +118,14 @@ var Logger = {
|
|
|
118
118
|
|
|
119
119
|
// src/assert/assert.ts
|
|
120
120
|
function abort(reason) {
|
|
121
|
-
throw new Error(`
|
|
121
|
+
throw new Error(`zkAssert(${reason})`);
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function zkAssert(expr, reason) {
|
|
124
124
|
if (!expr) {
|
|
125
125
|
abort(reason ?? "#expr is false");
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function zkAssertNotNil(val, reason) {
|
|
129
129
|
if (val === null || val === void 0) {
|
|
130
130
|
abort(reason ?? "#val is nil");
|
|
131
131
|
}
|
|
@@ -174,7 +174,7 @@ var Task = class {
|
|
|
174
174
|
return this._callback;
|
|
175
175
|
}
|
|
176
176
|
setCallback(callback) {
|
|
177
|
-
|
|
177
|
+
zkAssert(this._callback === void 0, "cant overlay callback.");
|
|
178
178
|
this._callback = callback;
|
|
179
179
|
}
|
|
180
180
|
clearCallback() {
|
|
@@ -412,14 +412,14 @@ var AbstractExecutor = class {
|
|
|
412
412
|
return this._deadline;
|
|
413
413
|
}
|
|
414
414
|
setFrameRate(fps) {
|
|
415
|
-
|
|
415
|
+
zkAssert(fps > 0 && fps <= 125);
|
|
416
416
|
this._yieldInterval = Math.floor(1e3 / fps);
|
|
417
417
|
}
|
|
418
418
|
resetFrameRate() {
|
|
419
419
|
this._yieldInterval = 16;
|
|
420
420
|
}
|
|
421
421
|
requestHostTimeout(fn, delayMs) {
|
|
422
|
-
|
|
422
|
+
zkAssert(this._timeoutId === -1, "has request host timeout.");
|
|
423
423
|
clearTimeout(this._timeoutId);
|
|
424
424
|
this._timeoutId = setTimeout(() => {
|
|
425
425
|
this._timeoutId = -1;
|
|
@@ -668,8 +668,8 @@ var Scheduler = class {
|
|
|
668
668
|
this._requestHostTimeout(currentTime);
|
|
669
669
|
}
|
|
670
670
|
_requestHostTimeout(currentTime) {
|
|
671
|
-
|
|
672
|
-
|
|
671
|
+
zkAssert(!this._isHostCallbackScheduled);
|
|
672
|
+
zkAssert(!this._isHostTimeoutScheduled);
|
|
673
673
|
const firstTimerTask = this._taskQueue.timerTasks.peek();
|
|
674
674
|
if (firstTimerTask !== null) {
|
|
675
675
|
this._isHostTimeoutScheduled = true;
|
|
@@ -712,8 +712,8 @@ var CallbackToken = class {
|
|
|
712
712
|
}
|
|
713
713
|
};
|
|
714
714
|
|
|
715
|
-
// src/scheduler/
|
|
716
|
-
function
|
|
715
|
+
// src/scheduler/zk-scheduler-callback.ts
|
|
716
|
+
function zkSchedulerCallback(callback, options = {}) {
|
|
717
717
|
const newTask = makeTask(callback, options);
|
|
718
718
|
getScheduler().addTask(newTask);
|
|
719
719
|
return new CallbackToken(newTask);
|
|
@@ -1025,7 +1025,7 @@ var IdleValue = class {
|
|
|
1025
1025
|
}
|
|
1026
1026
|
}
|
|
1027
1027
|
};
|
|
1028
|
-
this._handle =
|
|
1028
|
+
this._handle = zkSchedulerCallback(() => this._executor(), {
|
|
1029
1029
|
priorityLevel: 4 /* IdlePriority */
|
|
1030
1030
|
});
|
|
1031
1031
|
}
|
|
@@ -1619,7 +1619,7 @@ var ServiceRegistry = class {
|
|
|
1619
1619
|
);
|
|
1620
1620
|
}
|
|
1621
1621
|
if (this._checkDuplicate) {
|
|
1622
|
-
|
|
1622
|
+
zkAssert(!this._ids.has(id.toString()), `service: ${id.toString()} duplicate register.`);
|
|
1623
1623
|
this._ids.add(id.toString());
|
|
1624
1624
|
}
|
|
1625
1625
|
this._registry.push([id, ctorOrDescriptor]);
|
|
@@ -1632,7 +1632,7 @@ var ServiceRegistry = class {
|
|
|
1632
1632
|
*/
|
|
1633
1633
|
registerInstance(id, instance, options) {
|
|
1634
1634
|
if (this._checkDuplicate) {
|
|
1635
|
-
|
|
1635
|
+
zkAssert(!this._ids.has(id.toString()), `service: ${id.toString()} duplicate register.`);
|
|
1636
1636
|
this._ids.add(id.toString());
|
|
1637
1637
|
}
|
|
1638
1638
|
this._registry.push([id, instance]);
|
|
@@ -1660,11 +1660,11 @@ var Capability = class {
|
|
|
1660
1660
|
return this._status;
|
|
1661
1661
|
}
|
|
1662
1662
|
acquire() {
|
|
1663
|
-
|
|
1663
|
+
zkAssert(this._status === 0 /* Unlocked */);
|
|
1664
1664
|
this._status = 1 /* Locked */;
|
|
1665
1665
|
}
|
|
1666
1666
|
release() {
|
|
1667
|
-
|
|
1667
|
+
zkAssert(this._status === 1 /* Locked */);
|
|
1668
1668
|
this._status = 0 /* Unlocked */;
|
|
1669
1669
|
this._onUnlocked.fire();
|
|
1670
1670
|
}
|
|
@@ -1689,7 +1689,7 @@ var SharedCapability = class {
|
|
|
1689
1689
|
this._counter++;
|
|
1690
1690
|
}
|
|
1691
1691
|
release() {
|
|
1692
|
-
|
|
1692
|
+
zkAssert(this._counter > 0);
|
|
1693
1693
|
this._counter--;
|
|
1694
1694
|
if (this._counter === 0) {
|
|
1695
1695
|
this._status = 0 /* Unlocked */;
|
|
@@ -1751,7 +1751,7 @@ var SharedMutex = class {
|
|
|
1751
1751
|
* 解除写锁
|
|
1752
1752
|
*/
|
|
1753
1753
|
unLock() {
|
|
1754
|
-
|
|
1754
|
+
zkAssertNotNil(this._writer);
|
|
1755
1755
|
this._writer.release();
|
|
1756
1756
|
}
|
|
1757
1757
|
/**
|
|
@@ -1785,9 +1785,9 @@ var SharedMutex = class {
|
|
|
1785
1785
|
* 解除读锁
|
|
1786
1786
|
*/
|
|
1787
1787
|
unLockShared() {
|
|
1788
|
-
|
|
1788
|
+
zkAssertNotNil(this._reader);
|
|
1789
1789
|
if (this._writer) {
|
|
1790
|
-
|
|
1790
|
+
zkAssert(this._writer.status === 0 /* Unlocked */);
|
|
1791
1791
|
}
|
|
1792
1792
|
this._reader.release();
|
|
1793
1793
|
}
|
|
@@ -1801,7 +1801,7 @@ var SharedMutex = class {
|
|
|
1801
1801
|
* 写者进入第一道门
|
|
1802
1802
|
*/
|
|
1803
1803
|
_writerEnterGate1(resolve) {
|
|
1804
|
-
|
|
1804
|
+
zkAssert(!this._writer);
|
|
1805
1805
|
this._writer = new Capability();
|
|
1806
1806
|
if (this._readerCount > 0) {
|
|
1807
1807
|
listenOnce(this._reader.onUnlocked)(() => {
|
|
@@ -1815,11 +1815,11 @@ var SharedMutex = class {
|
|
|
1815
1815
|
* 写者进入第二道门
|
|
1816
1816
|
*/
|
|
1817
1817
|
_writerEnterGate2(resolve) {
|
|
1818
|
-
|
|
1819
|
-
|
|
1818
|
+
zkAssertNotNil(this._writer);
|
|
1819
|
+
zkAssert(this._readerCount === 0);
|
|
1820
1820
|
this._writer.acquire();
|
|
1821
1821
|
listenOnce(this._writer.onUnlocked)(() => {
|
|
1822
|
-
|
|
1822
|
+
zkAssertNotNil(this._writer);
|
|
1823
1823
|
this._writer = void 0;
|
|
1824
1824
|
this._moveForward();
|
|
1825
1825
|
});
|
|
@@ -1829,7 +1829,7 @@ var SharedMutex = class {
|
|
|
1829
1829
|
* 读者进入第一道门
|
|
1830
1830
|
*/
|
|
1831
1831
|
_readerEnterGate1(resolve) {
|
|
1832
|
-
|
|
1832
|
+
zkAssert(!this._writer);
|
|
1833
1833
|
this._waitingReader = void 0;
|
|
1834
1834
|
if (!this._reader) {
|
|
1835
1835
|
this._reader = new SharedCapability();
|
|
@@ -1908,7 +1908,7 @@ var IdleServiceLoader = class {
|
|
|
1908
1908
|
constructor(originService, staticArguments, _instantiationService) {
|
|
1909
1909
|
this._instantiationService = _instantiationService;
|
|
1910
1910
|
this._service = this._instantiationService.createInstance(originService, ...staticArguments);
|
|
1911
|
-
|
|
1911
|
+
zkSchedulerCallback(() => this._service.preload());
|
|
1912
1912
|
}
|
|
1913
1913
|
get loaded() {
|
|
1914
1914
|
return this._service.loaded;
|
|
@@ -1936,7 +1936,7 @@ var InstantiationContext = (props) => {
|
|
|
1936
1936
|
};
|
|
1937
1937
|
function useService(identifier) {
|
|
1938
1938
|
const instantiationService = react.useContext(Context);
|
|
1939
|
-
|
|
1939
|
+
zkAssertNotNil(instantiationService, "react components need service context.");
|
|
1940
1940
|
const service = react.useMemo(
|
|
1941
1941
|
() => instantiationService.invokeFunction(
|
|
1942
1942
|
(servicesAccessor) => servicesAccessor.get(identifier)
|