@sigx/terminal 0.1.6 → 0.1.8
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/index.js +141 -16
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
1
2
|
const ComputedSymbol = Symbol("computed");
|
|
2
3
|
let activeEffect = null;
|
|
3
4
|
var batchDepth = 0;
|
|
@@ -266,11 +267,14 @@ var accessObserver = null;
|
|
|
266
267
|
function getAccessObserver() {
|
|
267
268
|
return accessObserver;
|
|
268
269
|
}
|
|
270
|
+
function setAccessObserver(observer) {
|
|
271
|
+
accessObserver = observer;
|
|
272
|
+
}
|
|
269
273
|
function detectAccess(selector) {
|
|
270
274
|
let result = null;
|
|
271
275
|
const prev = accessObserver;
|
|
272
276
|
accessObserver = (target, key) => {
|
|
273
|
-
|
|
277
|
+
result = [target, key];
|
|
274
278
|
};
|
|
275
279
|
try {
|
|
276
280
|
selector();
|
|
@@ -504,18 +508,28 @@ function computed(getterOrOptions) {
|
|
|
504
508
|
[ComputedSymbol]: true,
|
|
505
509
|
get value() {
|
|
506
510
|
const observer = getAccessObserver();
|
|
507
|
-
if (observer)
|
|
511
|
+
if (observer) {
|
|
512
|
+
observer(computedObj, "value");
|
|
513
|
+
setAccessObserver(null);
|
|
514
|
+
}
|
|
508
515
|
track(subscribers);
|
|
509
|
-
|
|
516
|
+
const result = dirty ? computeValue() : cachedValue;
|
|
517
|
+
if (observer) setAccessObserver(observer);
|
|
518
|
+
return result;
|
|
510
519
|
}
|
|
511
520
|
};
|
|
512
521
|
if (setter) {
|
|
513
522
|
Object.defineProperty(computedObj, "value", {
|
|
514
523
|
get() {
|
|
515
524
|
const observer = getAccessObserver();
|
|
516
|
-
if (observer)
|
|
525
|
+
if (observer) {
|
|
526
|
+
observer(computedObj, "value");
|
|
527
|
+
setAccessObserver(null);
|
|
528
|
+
}
|
|
517
529
|
track(subscribers);
|
|
518
|
-
|
|
530
|
+
const result = dirty ? computeValue() : cachedValue;
|
|
531
|
+
if (observer) setAccessObserver(observer);
|
|
532
|
+
return result;
|
|
519
533
|
},
|
|
520
534
|
set(newValue) {
|
|
521
535
|
setter(newValue);
|
|
@@ -551,14 +565,64 @@ function registerContextExtension(extension) {
|
|
|
551
565
|
function applyContextExtensions(ctx) {
|
|
552
566
|
for (const extension of contextExtensions) extension(ctx);
|
|
553
567
|
}
|
|
568
|
+
var require___vite_browser_external = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
569
|
+
module.exports = {};
|
|
570
|
+
}));
|
|
571
|
+
var asyncLocalStorage = null;
|
|
572
|
+
try {
|
|
573
|
+
if (typeof globalThis !== "undefined" && typeof globalThis.process !== "undefined") {
|
|
574
|
+
const nodeAsync = globalThis.process?.versions?.node ? require___vite_browser_external() : null;
|
|
575
|
+
if (nodeAsync?.AsyncLocalStorage) asyncLocalStorage = new nodeAsync.AsyncLocalStorage();
|
|
576
|
+
}
|
|
577
|
+
} catch {}
|
|
578
|
+
var _fallbackContext = {
|
|
579
|
+
currentComponentContext: null,
|
|
580
|
+
currentSuspenseBoundary: null
|
|
581
|
+
};
|
|
582
|
+
function getRequestContext() {
|
|
583
|
+
if (asyncLocalStorage) {
|
|
584
|
+
const store = asyncLocalStorage.getStore();
|
|
585
|
+
if (store) return store;
|
|
586
|
+
}
|
|
587
|
+
return _fallbackContext;
|
|
588
|
+
}
|
|
589
|
+
function getCurrentInstanceSafe() {
|
|
590
|
+
return getRequestContext().currentComponentContext;
|
|
591
|
+
}
|
|
592
|
+
function setCurrentInstanceSafe(ctx) {
|
|
593
|
+
const reqCtx = getRequestContext();
|
|
594
|
+
const prev = reqCtx.currentComponentContext;
|
|
595
|
+
reqCtx.currentComponentContext = ctx;
|
|
596
|
+
return prev;
|
|
597
|
+
}
|
|
598
|
+
function getCurrentSuspenseBoundarySafe() {
|
|
599
|
+
return getRequestContext().currentSuspenseBoundary;
|
|
600
|
+
}
|
|
601
|
+
function setCurrentSuspenseBoundarySafe(boundary) {
|
|
602
|
+
const reqCtx = getRequestContext();
|
|
603
|
+
const prev = reqCtx.currentSuspenseBoundary;
|
|
604
|
+
reqCtx.currentSuspenseBoundary = boundary;
|
|
605
|
+
return prev;
|
|
606
|
+
}
|
|
607
|
+
function runInRequestScope(fn) {
|
|
608
|
+
if (asyncLocalStorage) return asyncLocalStorage.run({
|
|
609
|
+
currentComponentContext: null,
|
|
610
|
+
currentSuspenseBoundary: null
|
|
611
|
+
}, fn);
|
|
612
|
+
return fn();
|
|
613
|
+
}
|
|
614
|
+
function hasRequestIsolation() {
|
|
615
|
+
return asyncLocalStorage !== null;
|
|
616
|
+
}
|
|
554
617
|
var currentComponentContext = null;
|
|
555
618
|
function getCurrentInstance() {
|
|
556
|
-
return currentComponentContext;
|
|
619
|
+
return getCurrentInstanceSafe() ?? currentComponentContext;
|
|
557
620
|
}
|
|
558
621
|
function setCurrentInstance(ctx) {
|
|
559
|
-
const
|
|
622
|
+
const prevSafe = setCurrentInstanceSafe(ctx);
|
|
623
|
+
const prevModule = currentComponentContext;
|
|
560
624
|
currentComponentContext = ctx;
|
|
561
|
-
return
|
|
625
|
+
return prevSafe ?? prevModule;
|
|
562
626
|
}
|
|
563
627
|
function onMounted(fn) {
|
|
564
628
|
if (currentComponentContext) currentComponentContext.onMounted(fn);
|
|
@@ -657,6 +721,14 @@ function provideAppContext(ctx, appContext) {
|
|
|
657
721
|
ctx.provides.set(appContextToken, appContext);
|
|
658
722
|
if (appContext.provides) for (const [token, value] of appContext.provides) ctx.provides.set(token, value);
|
|
659
723
|
}
|
|
724
|
+
const __DIRECTIVE__ = Symbol.for("sigx.directive");
|
|
725
|
+
function defineDirective(definition) {
|
|
726
|
+
definition[__DIRECTIVE__] = true;
|
|
727
|
+
return definition;
|
|
728
|
+
}
|
|
729
|
+
function isDirective(value) {
|
|
730
|
+
return value != null && typeof value === "object" && value[__DIRECTIVE__] === true;
|
|
731
|
+
}
|
|
660
732
|
var isDev = typeof process !== "undefined" && process.env.NODE_ENV !== "production" || true;
|
|
661
733
|
var defaultMountFn = null;
|
|
662
734
|
function setDefaultMount(mountFn) {
|
|
@@ -671,7 +743,8 @@ function defineApp(rootComponent) {
|
|
|
671
743
|
app: null,
|
|
672
744
|
provides: /* @__PURE__ */ new Map(),
|
|
673
745
|
config: {},
|
|
674
|
-
hooks: []
|
|
746
|
+
hooks: [],
|
|
747
|
+
directives: /* @__PURE__ */ new Map()
|
|
675
748
|
};
|
|
676
749
|
let isMounted = false;
|
|
677
750
|
let container = null;
|
|
@@ -701,6 +774,14 @@ function defineApp(rootComponent) {
|
|
|
701
774
|
context.hooks.push(hooks);
|
|
702
775
|
return app;
|
|
703
776
|
},
|
|
777
|
+
directive(name, definition) {
|
|
778
|
+
if (definition !== void 0) {
|
|
779
|
+
if (isDev && !isDirective(definition)) console.warn(`[sigx] app.directive('${name}', ...) received a value that is not a valid directive definition. Use defineDirective() to create directive definitions.`);
|
|
780
|
+
context.directives.set(name, definition);
|
|
781
|
+
return app;
|
|
782
|
+
}
|
|
783
|
+
return context.directives.get(name);
|
|
784
|
+
},
|
|
704
785
|
mount(target, renderFn) {
|
|
705
786
|
if (isMounted) {
|
|
706
787
|
if (isDev) console.warn("App is already mounted. Call app.unmount() first.");
|
|
@@ -953,7 +1034,7 @@ function jsxs(type, props, key) {
|
|
|
953
1034
|
const jsxDEV = jsx;
|
|
954
1035
|
var currentSuspenseBoundary = null;
|
|
955
1036
|
function registerPendingPromise(promise) {
|
|
956
|
-
const boundary = currentSuspenseBoundary;
|
|
1037
|
+
const boundary = getCurrentSuspenseBoundarySafe() ?? currentSuspenseBoundary;
|
|
957
1038
|
if (boundary) {
|
|
958
1039
|
boundary.pending.add(promise);
|
|
959
1040
|
promise.finally(() => {
|
|
@@ -1037,8 +1118,9 @@ const Suspense = component((ctx) => {
|
|
|
1037
1118
|
return () => {
|
|
1038
1119
|
state.isReady;
|
|
1039
1120
|
state.pendingCount;
|
|
1040
|
-
const prevBoundary = currentSuspenseBoundary;
|
|
1121
|
+
const prevBoundary = getCurrentSuspenseBoundarySafe() ?? currentSuspenseBoundary;
|
|
1041
1122
|
currentSuspenseBoundary = boundary;
|
|
1123
|
+
setCurrentSuspenseBoundarySafe(boundary);
|
|
1042
1124
|
try {
|
|
1043
1125
|
const children = slots.default();
|
|
1044
1126
|
if (boundary.pending.size > 0) {
|
|
@@ -1063,12 +1145,41 @@ const Suspense = component((ctx) => {
|
|
|
1063
1145
|
throw err;
|
|
1064
1146
|
} finally {
|
|
1065
1147
|
currentSuspenseBoundary = prevBoundary;
|
|
1148
|
+
setCurrentSuspenseBoundarySafe(prevBoundary);
|
|
1066
1149
|
}
|
|
1067
1150
|
};
|
|
1068
1151
|
}, { name: "Suspense" });
|
|
1069
1152
|
function isLazyComponent(component) {
|
|
1070
1153
|
return component && component.__lazy === true;
|
|
1071
1154
|
}
|
|
1155
|
+
const ErrorBoundary = component((ctx) => {
|
|
1156
|
+
const { fallback } = ctx.props;
|
|
1157
|
+
const { slots } = ctx;
|
|
1158
|
+
const state = ctx.signal({
|
|
1159
|
+
hasError: false,
|
|
1160
|
+
error: null
|
|
1161
|
+
});
|
|
1162
|
+
const retry = () => {
|
|
1163
|
+
state.hasError = false;
|
|
1164
|
+
state.error = null;
|
|
1165
|
+
};
|
|
1166
|
+
return () => {
|
|
1167
|
+
if (state.hasError && state.error) {
|
|
1168
|
+
if (typeof fallback === "function") return fallback(state.error, retry);
|
|
1169
|
+
return fallback ?? null;
|
|
1170
|
+
}
|
|
1171
|
+
try {
|
|
1172
|
+
return slots.default();
|
|
1173
|
+
} catch (e) {
|
|
1174
|
+
const error = e instanceof Error ? e : new Error(String(e));
|
|
1175
|
+
state.hasError = true;
|
|
1176
|
+
state.error = error;
|
|
1177
|
+
if (process.env.NODE_ENV !== "production") console.error("[ErrorBoundary] Caught error during render:", error);
|
|
1178
|
+
if (typeof fallback === "function") return fallback(error, retry);
|
|
1179
|
+
return fallback ?? null;
|
|
1180
|
+
}
|
|
1181
|
+
};
|
|
1182
|
+
}, { name: "ErrorBoundary" });
|
|
1072
1183
|
var Utils = class {
|
|
1073
1184
|
static isPromise(value) {
|
|
1074
1185
|
return !!value && (typeof value === "object" || typeof value === "function") && typeof value.then === "function";
|
|
@@ -1308,7 +1419,7 @@ function createEmit(reactiveProps) {
|
|
|
1308
1419
|
};
|
|
1309
1420
|
}
|
|
1310
1421
|
function createRenderer(options) {
|
|
1311
|
-
const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent } = options;
|
|
1422
|
+
const { insert: hostInsert, remove: hostRemove, patchProp: hostPatchProp, createElement: hostCreateElement, createText: hostCreateText, createComment: hostCreateComment, setText: hostSetText, setElementText: hostSetElementText, parentNode: hostParentNode, nextSibling: hostNextSibling, cloneNode: hostCloneNode, insertStaticContent: hostInsertStaticContent, patchDirective: hostPatchDirective, onElementMounted: hostOnElementMounted, onElementUnmounted: hostOnElementUnmounted } = options;
|
|
1312
1423
|
let currentAppContext = null;
|
|
1313
1424
|
function render(element, container, appContext) {
|
|
1314
1425
|
if (appContext) currentAppContext = appContext;
|
|
@@ -1430,7 +1541,9 @@ function createRenderer(options) {
|
|
|
1430
1541
|
vnode.dom = element;
|
|
1431
1542
|
element.__vnode = vnode;
|
|
1432
1543
|
if (vnode.props) {
|
|
1433
|
-
for (const key in vnode.props) if (key !== "children" && key !== "key" && key !== "ref")
|
|
1544
|
+
for (const key in vnode.props) if (key !== "children" && key !== "key" && key !== "ref") if (key.charCodeAt(0) === 117 && key.startsWith("use:")) {
|
|
1545
|
+
if (hostPatchDirective) hostPatchDirective(element, key.slice(4), null, vnode.props[key], currentAppContext);
|
|
1546
|
+
} else hostPatchProp(element, key, null, vnode.props[key], isSVG);
|
|
1434
1547
|
if (vnode.props.ref) untrack(() => {
|
|
1435
1548
|
if (typeof vnode.props.ref === "function") vnode.props.ref(element);
|
|
1436
1549
|
else if (typeof vnode.props.ref === "object") vnode.props.ref.current = element;
|
|
@@ -1442,6 +1555,7 @@ function createRenderer(options) {
|
|
|
1442
1555
|
mount(child, element, null, childIsSVG);
|
|
1443
1556
|
});
|
|
1444
1557
|
hostInsert(element, container, before);
|
|
1558
|
+
if (hostOnElementMounted) hostOnElementMounted(element);
|
|
1445
1559
|
}
|
|
1446
1560
|
function unmount(vnode, container) {
|
|
1447
1561
|
const internalVNode = vnode;
|
|
@@ -1466,6 +1580,7 @@ function createRenderer(options) {
|
|
|
1466
1580
|
if (typeof vnode.props.ref === "function") vnode.props.ref(null);
|
|
1467
1581
|
else if (vnode.props.ref && typeof vnode.props.ref === "object") vnode.props.ref.current = null;
|
|
1468
1582
|
});
|
|
1583
|
+
if (hostOnElementUnmounted && vnode.dom) hostOnElementUnmounted(vnode.dom);
|
|
1469
1584
|
if (vnode.children && vnode.children.length > 0) vnode.children.forEach((child) => unmount(child, vnode.dom));
|
|
1470
1585
|
if (vnode.dom) hostRemove(vnode.dom);
|
|
1471
1586
|
}
|
|
@@ -1530,6 +1645,12 @@ function createRenderer(options) {
|
|
|
1530
1645
|
}
|
|
1531
1646
|
if (newVNode.type === Text) {
|
|
1532
1647
|
newVNode.dom = oldVNode.dom;
|
|
1648
|
+
if (!newVNode.dom) {
|
|
1649
|
+
const textNode = hostCreateText(String(newVNode.text));
|
|
1650
|
+
newVNode.dom = textNode;
|
|
1651
|
+
if (container) hostInsert(textNode, container, oldVNode.dom || null);
|
|
1652
|
+
return;
|
|
1653
|
+
}
|
|
1533
1654
|
if (oldVNode.text !== newVNode.text) hostSetText(newVNode.dom, String(newVNode.text));
|
|
1534
1655
|
return;
|
|
1535
1656
|
}
|
|
@@ -1546,11 +1667,15 @@ function createRenderer(options) {
|
|
|
1546
1667
|
const isSVG = tag === "svg" || isSvgTag(tag);
|
|
1547
1668
|
const oldProps = oldVNode.props || {};
|
|
1548
1669
|
const newProps = newVNode.props || {};
|
|
1549
|
-
for (const key in oldProps) if (!(key in newProps) && key !== "children" && key !== "key" && key !== "ref")
|
|
1670
|
+
for (const key in oldProps) if (!(key in newProps) && key !== "children" && key !== "key" && key !== "ref") if (key.charCodeAt(0) === 117 && key.startsWith("use:")) {
|
|
1671
|
+
if (hostPatchDirective) hostPatchDirective(element, key.slice(4), oldProps[key], null, currentAppContext);
|
|
1672
|
+
} else hostPatchProp(element, key, oldProps[key], null, isSVG);
|
|
1550
1673
|
for (const key in newProps) {
|
|
1551
1674
|
const oldValue = oldProps[key];
|
|
1552
1675
|
const newValue = newProps[key];
|
|
1553
|
-
if (key !== "children" && key !== "key" && key !== "ref" && oldValue !== newValue)
|
|
1676
|
+
if (key !== "children" && key !== "key" && key !== "ref" && oldValue !== newValue) if (key.charCodeAt(0) === 117 && key.startsWith("use:")) {
|
|
1677
|
+
if (hostPatchDirective) hostPatchDirective(element, key.slice(4), oldValue, newValue, currentAppContext);
|
|
1678
|
+
} else hostPatchProp(element, key, oldValue, newValue, isSVG);
|
|
1554
1679
|
}
|
|
1555
1680
|
patchChildren(oldVNode, newVNode, element, isSVG && tag !== "foreignObject");
|
|
1556
1681
|
}
|
|
@@ -2324,6 +2449,6 @@ const terminalMount = (component, options, appContext) => {
|
|
|
2324
2449
|
};
|
|
2325
2450
|
};
|
|
2326
2451
|
setDefaultMount(terminalMount);
|
|
2327
|
-
export { Button, CLIENT_DIRECTIVES, CLIENT_DIRECTIVE_PREFIX, Checkbox, ComputedSymbol, Fragment, Input, InstanceLifetimes, ProgressBar, Select, SubscriptionHandler, Suspense, Text, Utils, applyContextExtensions, batch, cleanup, component, compound, computed, createEmit, createModel, createModelFromBinding, createPropsAccessor, createPropsProxy, createRenderer, createSlots, createTopic, defineApp, defineFactory, defineInjectable, defineProvide, detectAccess, effect, effectScope, exitTerminal, filterClientDirectives, focus, focusNext, focusPrev, focusState, getAppContextToken, getComponentMeta, getComponentPlugins, getCurrentInstance, getDefaultMount, getHydrationDirective, getModelSymbol, getPlatformModelProcessor, guid, handleComponentError, hasClientDirective, isComponent, isComputed, isLazyComponent, isModel, isReactive, jsx, jsxDEV, jsxs, lazy, mountTerminal, normalizeSubTree, notifyComponentCreated, notifyComponentMounted, notifyComponentUnmounted, notifyComponentUpdated, onCreated, onKey, onMounted, onUnmounted, onUpdated, provideAppContext, registerComponentPlugin, registerContextExtension, registerFocusable, registerPendingPromise, render, renderNodeToLines, renderTerminal, serializeProps, setCurrentInstance, setDefaultMount, setPlatformModelProcessor, signal, terminalMount, toRaw, toSubscriber, track, trigger, unregisterFocusable, untrack, useAppContext, valueOf, watch };
|
|
2452
|
+
export { Button, CLIENT_DIRECTIVES, CLIENT_DIRECTIVE_PREFIX, Checkbox, ComputedSymbol, ErrorBoundary, Fragment, Input, InstanceLifetimes, ProgressBar, Select, SubscriptionHandler, Suspense, Text, Utils, __DIRECTIVE__, applyContextExtensions, batch, cleanup, component, compound, computed, createEmit, createModel, createModelFromBinding, createPropsAccessor, createPropsProxy, createRenderer, createSlots, createTopic, defineApp, defineDirective, defineFactory, defineInjectable, defineProvide, detectAccess, effect, effectScope, exitTerminal, filterClientDirectives, focus, focusNext, focusPrev, focusState, getAppContextToken, getComponentMeta, getComponentPlugins, getCurrentInstance, getDefaultMount, getHydrationDirective, getModelSymbol, getPlatformModelProcessor, guid, handleComponentError, hasClientDirective, hasRequestIsolation, isComponent, isComputed, isDirective, isLazyComponent, isModel, isReactive, jsx, jsxDEV, jsxs, lazy, mountTerminal, normalizeSubTree, notifyComponentCreated, notifyComponentMounted, notifyComponentUnmounted, notifyComponentUpdated, onCreated, onKey, onMounted, onUnmounted, onUpdated, provideAppContext, registerComponentPlugin, registerContextExtension, registerFocusable, registerPendingPromise, render, renderNodeToLines, renderTerminal, runInRequestScope, serializeProps, setCurrentInstance, setDefaultMount, setPlatformModelProcessor, signal, terminalMount, toRaw, toSubscriber, track, trigger, unregisterFocusable, untrack, useAppContext, valueOf, watch };
|
|
2328
2453
|
|
|
2329
2454
|
//# sourceMappingURL=index.js.map
|