@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.
- 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 +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(`
|
|
119
|
+
throw new Error(`zkAssert(${reason})`);
|
|
120
120
|
}
|
|
121
|
-
function
|
|
121
|
+
function zkAssert(expr, reason) {
|
|
122
122
|
if (!expr) {
|
|
123
123
|
abort(reason ?? "#expr is false");
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
function
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
670
|
-
|
|
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/
|
|
714
|
-
function
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1661
|
+
zkAssert(this._status === 0 /* Unlocked */);
|
|
1662
1662
|
this._status = 1 /* Locked */;
|
|
1663
1663
|
}
|
|
1664
1664
|
release() {
|
|
1665
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1786
|
+
zkAssertNotNil(this._reader);
|
|
1787
1787
|
if (this._writer) {
|
|
1788
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1817
|
-
|
|
1816
|
+
zkAssertNotNil(this._writer);
|
|
1817
|
+
zkAssert(this._readerCount === 0);
|
|
1818
1818
|
this._writer.acquire();
|
|
1819
1819
|
listenOnce(this._writer.onUnlocked)(() => {
|
|
1820
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1937
|
+
zkAssertNotNil(instantiationService, "react components need service context.");
|
|
1938
1938
|
const service = useMemo(
|
|
1939
1939
|
() => instantiationService.invokeFunction(
|
|
1940
1940
|
(servicesAccessor) => servicesAccessor.get(identifier)
|