@solid-devtools/shared
Advanced tools
| // src/utils.ts | ||
| var getLogLabel = () => [ | ||
| `%csolid-devtools`, | ||
| "color: #fff; background: #2c4f7c; padding: 1px 4px;" | ||
| ]; | ||
| function info(data) { | ||
| console.info(...getLogLabel(), data); | ||
| return data; | ||
| } | ||
| function log(...args) { | ||
| console.log(...getLogLabel(), ...args); | ||
| } | ||
| function warn(...args) { | ||
| console.warn(...getLogLabel(), ...args); | ||
| } | ||
| function formatTime(d = new Date()) { | ||
| return ("0" + d.getHours()).slice(-2) + ":" + ("0" + d.getMinutes()).slice(-2) + ":" + ("0" + d.getSeconds()).slice(-2); | ||
| } | ||
| function callArrayProp(object, key, ...args) { | ||
| const arr = object[key]; | ||
| if (arr) | ||
| for (const cb of arr) | ||
| cb(...args); | ||
| } | ||
| function pushToArrayProp(object, key, value) { | ||
| let arr = object[key]; | ||
| if (arr) | ||
| arr.push(value); | ||
| else | ||
| arr = object[key] = [value]; | ||
| return arr; | ||
| } | ||
| function mutateFilter(array, predicate) { | ||
| const temp = array.filter(predicate); | ||
| array.length = 0; | ||
| array.push.apply(array, temp); | ||
| } | ||
| function mutateRemove(array, item) { | ||
| array.splice(array.indexOf(item), 1); | ||
| } | ||
| var dedupeArray = (array) => Array.from(new Set(array)); | ||
| var arrayRefEquals = (a, b) => a === b || a.length === b.length && a.every((e) => b.includes(e)); | ||
| function trimString(str, maxLength) { | ||
| if (str.length <= maxLength) | ||
| return str; | ||
| return str.slice(0, maxLength) + "\u2026"; | ||
| } | ||
| function findIndexById(array, id) { | ||
| for (let i = 0; i < array.length; i++) | ||
| if (array[i].id === id) | ||
| return i; | ||
| return -1; | ||
| } | ||
| function findItemById(array, id) { | ||
| for (let i = 0; i < array.length; i++) { | ||
| const item = array[i]; | ||
| if (item.id === id) | ||
| return item; | ||
| } | ||
| } | ||
| export { | ||
| info, | ||
| log, | ||
| warn, | ||
| formatTime, | ||
| callArrayProp, | ||
| pushToArrayProp, | ||
| mutateFilter, | ||
| mutateRemove, | ||
| dedupeArray, | ||
| arrayRefEquals, | ||
| trimString, | ||
| findIndexById, | ||
| findItemById | ||
| }; |
+13
-13
@@ -1,4 +0,4 @@ | ||
| @solid-devtools/shared:build: cache hit, replaying output 5cc1fdcb668a2d23 | ||
| @solid-devtools/shared:build: cache hit, replaying output 25e1f10923c9b0e5 | ||
| @solid-devtools/shared:build: | ||
| @solid-devtools/shared:build: > @solid-devtools/shared@0.7.4 build /home/runner/work/solid-devtools/solid-devtools/packages/shared | ||
| @solid-devtools/shared:build: > @solid-devtools/shared@0.8.0 build /home/runner/work/solid-devtools/solid-devtools/packages/shared | ||
| @solid-devtools/shared:build: > tsup | ||
@@ -17,24 +17,24 @@ @solid-devtools/shared:build: | ||
| @solid-devtools/shared:build: [32mESM[39m [1mdist/graph.js [22m[32m618.00 B[39m | ||
| @solid-devtools/shared:build: [32mESM[39m [1mdist/utils.js [22m[32m353.00 B[39m | ||
| @solid-devtools/shared:build: [32mESM[39m [1mdist/chunk-QTPCQOAB.js [22m[32m1.43 KB[39m | ||
| @solid-devtools/shared:build: [32mESM[39m [1mdist/utils.js [22m[32m419.00 B[39m | ||
| @solid-devtools/shared:build: [32mESM[39m [1mdist/chunk-HUGDDQ47.js [22m[32m1.74 KB[39m | ||
| @solid-devtools/shared:build: [32mESM[39m [1mdist/variables.js [22m[32m406.00 B[39m | ||
| @solid-devtools/shared:build: [32mESM[39m [1mdist/serialize.js [22m[32m2.94 KB[39m | ||
| @solid-devtools/shared:build: [32mESM[39m [1mdist/primitives.js [22m[32m1.34 KB[39m | ||
| @solid-devtools/shared:build: [32mESM[39m ⚡️ Build success in 76ms | ||
| @solid-devtools/shared:build: [32mESM[39m [1mdist/primitives.js [22m[32m1.14 KB[39m | ||
| @solid-devtools/shared:build: [32mESM[39m ⚡️ Build success in 55ms | ||
| @solid-devtools/shared:build: [32mCJS[39m [1mdist/bridge.cjs [22m[32m2.37 KB[39m | ||
| @solid-devtools/shared:build: [32mCJS[39m [1mdist/diff.cjs [22m[32m1.72 KB[39m | ||
| @solid-devtools/shared:build: [32mCJS[39m [1mdist/graph.cjs [22m[32m1.62 KB[39m | ||
| @solid-devtools/shared:build: [32mCJS[39m [1mdist/utils.cjs [22m[32m2.72 KB[39m | ||
| @solid-devtools/shared:build: [32mCJS[39m [1mdist/utils.cjs [22m[32m3.11 KB[39m | ||
| @solid-devtools/shared:build: [32mCJS[39m [1mdist/variables.cjs [22m[32m1.63 KB[39m | ||
| @solid-devtools/shared:build: [32mCJS[39m [1mdist/serialize.cjs [22m[32m4.09 KB[39m | ||
| @solid-devtools/shared:build: [32mCJS[39m [1mdist/primitives.cjs [22m[32m2.64 KB[39m | ||
| @solid-devtools/shared:build: [32mCJS[39m ⚡️ Build success in 91ms | ||
| @solid-devtools/shared:build: [32mCJS[39m [1mdist/primitives.cjs [22m[32m2.40 KB[39m | ||
| @solid-devtools/shared:build: [32mCJS[39m ⚡️ Build success in 73ms | ||
| @solid-devtools/shared:build: [34mDTS[39m Build start | ||
| @solid-devtools/shared:build: [32mDTS[39m ⚡️ Build success in 6578ms | ||
| @solid-devtools/shared:build: [32mDTS[39m ⚡️ Build success in 6142ms | ||
| @solid-devtools/shared:build: [32mDTS[39m [1mdist/bridge.d.ts [22m[32m2.81 KB[39m | ||
| @solid-devtools/shared:build: [32mDTS[39m [1mdist/graph.d.ts [22m[32m5.51 KB[39m | ||
| @solid-devtools/shared:build: [32mDTS[39m [1mdist/graph.d.ts [22m[32m4.27 KB[39m | ||
| @solid-devtools/shared:build: [32mDTS[39m [1mdist/variables.d.ts [22m[32m422.00 B[39m | ||
| @solid-devtools/shared:build: [32mDTS[39m [1mdist/serialize.d.ts [22m[32m1.79 KB[39m | ||
| @solid-devtools/shared:build: [32mDTS[39m [1mdist/diff.d.ts [22m[32m436.00 B[39m | ||
| @solid-devtools/shared:build: [32mDTS[39m [1mdist/utils.d.ts [22m[32m1.21 KB[39m | ||
| @solid-devtools/shared:build: [32mDTS[39m [1mdist/primitives.d.ts [22m[32m1.09 KB[39m | ||
| @solid-devtools/shared:build: [32mDTS[39m [1mdist/utils.d.ts [22m[32m1.43 KB[39m | ||
| @solid-devtools/shared:build: [32mDTS[39m [1mdist/primitives.d.ts [22m[32m893.00 B[39m |
+24
-23
@@ -1,9 +0,10 @@ | ||
| @solid-devtools/shared:test: cache hit, replaying output d942b0bca1217d23 | ||
| @solid-devtools/shared:test: cache hit, replaying output f2946bce2492e452 | ||
| @solid-devtools/shared:test: | ||
| @solid-devtools/shared:test: > @solid-devtools/shared@0.7.4 test /home/runner/work/solid-devtools/solid-devtools/packages/shared | ||
| @solid-devtools/shared:test: > @solid-devtools/shared@0.8.0 test /home/runner/work/solid-devtools/solid-devtools/packages/shared | ||
| @solid-devtools/shared:test: > jest --config jest.config.ts | ||
| @solid-devtools/shared:test: | ||
| @solid-devtools/shared:test: PASS test/serialise.test.ts (15.616 s) | ||
| @solid-devtools/shared:test: ts-jest[versions] (WARN) Version 29.0.3 of babel-jest installed has not been tested with ts-jest. If you're experiencing issues, consider using a supported version (>=28.0.0 <29.0.0-0). Please do not report issues in ts-jest if you are using unsupported versions. | ||
| @solid-devtools/shared:test: PASS test/serialise.test.ts (14.007 s) | ||
| @solid-devtools/shared:test: encodeValue Preview | ||
| @solid-devtools/shared:test: ✓ Infinity (28 ms) | ||
| @solid-devtools/shared:test: ✓ Infinity (19 ms) | ||
| @solid-devtools/shared:test: ✓ Negative Infinity (1 ms) | ||
@@ -13,26 +14,26 @@ @solid-devtools/shared:test: ✓ NaN (1 ms) | ||
| @solid-devtools/shared:test: ✓ Boolean true (1 ms) | ||
| @solid-devtools/shared:test: ✓ Boolean false (12 ms) | ||
| @solid-devtools/shared:test: ✓ String | ||
| @solid-devtools/shared:test: ✓ Boolean false (17 ms) | ||
| @solid-devtools/shared:test: ✓ String (1 ms) | ||
| @solid-devtools/shared:test: ✓ String (1 ms) | ||
| @solid-devtools/shared:test: ✓ Null (1 ms) | ||
| @solid-devtools/shared:test: ✓ Undefined (17 ms) | ||
| @solid-devtools/shared:test: ✓ Undefined (1 ms) | ||
| @solid-devtools/shared:test: ✓ Named Symbol (1 ms) | ||
| @solid-devtools/shared:test: ✓ Symbol (1 ms) | ||
| @solid-devtools/shared:test: ✓ Symbol | ||
| @solid-devtools/shared:test: ✓ Function | ||
| @solid-devtools/shared:test: ✓ Named Function | ||
| @solid-devtools/shared:test: ✓ Element div (13 ms) | ||
| @solid-devtools/shared:test: ✓ Named Function (1 ms) | ||
| @solid-devtools/shared:test: ✓ Element div (29 ms) | ||
| @solid-devtools/shared:test: ✓ Element a (1 ms) | ||
| @solid-devtools/shared:test: ✓ Array empty (1 ms) | ||
| @solid-devtools/shared:test: ✓ Array empty | ||
| @solid-devtools/shared:test: ✓ Array | ||
| @solid-devtools/shared:test: ✓ Object empty (1 ms) | ||
| @solid-devtools/shared:test: ✓ Object empty | ||
| @solid-devtools/shared:test: ✓ Object | ||
| @solid-devtools/shared:test: ✓ Date (12 ms) | ||
| @solid-devtools/shared:test: ✓ Error (1 ms) | ||
| @solid-devtools/shared:test: ✓ Map | ||
| @solid-devtools/shared:test: ✓ WeakMap (1 ms) | ||
| @solid-devtools/shared:test: ✓ Set | ||
| @solid-devtools/shared:test: ✓ Date | ||
| @solid-devtools/shared:test: ✓ Error | ||
| @solid-devtools/shared:test: ✓ Map (1 ms) | ||
| @solid-devtools/shared:test: ✓ WeakMap | ||
| @solid-devtools/shared:test: ✓ Set (1 ms) | ||
| @solid-devtools/shared:test: encodeValue Deep | ||
| @solid-devtools/shared:test: ✓ Array empty | ||
| @solid-devtools/shared:test: ✓ Array shallow (13 ms) | ||
| @solid-devtools/shared:test: ✓ Array nested (1 ms) | ||
| @solid-devtools/shared:test: ✓ Array shallow (1 ms) | ||
| @solid-devtools/shared:test: ✓ Array nested (13 ms) | ||
| @solid-devtools/shared:test: ✓ Object empty (1 ms) | ||
@@ -42,6 +43,6 @@ @solid-devtools/shared:test: ✓ Object shallow | ||
| @solid-devtools/shared:test: save elements to a map | ||
| @solid-devtools/shared:test: ✓ Element div (12 ms) | ||
| @solid-devtools/shared:test: ✓ Element a (1 ms) | ||
| @solid-devtools/shared:test: ✓ Element div (26 ms) | ||
| @solid-devtools/shared:test: ✓ Element a | ||
| @solid-devtools/shared:test: ✓ Element in object (1 ms) | ||
| @solid-devtools/shared:test: ✓ map containing correct values | ||
| @solid-devtools/shared:test: ✓ map containing correct values (1 ms) | ||
| @solid-devtools/shared:test: | ||
@@ -51,3 +52,3 @@ @solid-devtools/shared:test: Test Suites: 1 passed, 1 total | ||
| @solid-devtools/shared:test: Snapshots: 0 total | ||
| @solid-devtools/shared:test: Time: 16.938 s | ||
| @solid-devtools/shared:test: Time: 15.453 s | ||
| @solid-devtools/shared:test: Ran all test suites. |
@@ -1,5 +0,5 @@ | ||
| @solid-devtools/shared:typecheck: cache hit, replaying output 39863f6f26380ac2 | ||
| @solid-devtools/shared:typecheck: cache hit, replaying output 4a0972ebd9d0b08f | ||
| @solid-devtools/shared:typecheck: | ||
| @solid-devtools/shared:typecheck: > @solid-devtools/shared@0.7.4 typecheck /home/runner/work/solid-devtools/solid-devtools/packages/shared | ||
| @solid-devtools/shared:typecheck: > @solid-devtools/shared@0.8.0 typecheck /home/runner/work/solid-devtools/solid-devtools/packages/shared | ||
| @solid-devtools/shared:typecheck: > tsc --noEmit | ||
| @solid-devtools/shared:typecheck: |
+13
-0
| # solid-devtools-shared | ||
| ## 0.8.0 | ||
| ### Minor Changes | ||
| - 5e913ac: Add virtualization of the structure tree. | ||
| ### Patch Changes | ||
| - 089331d: Changes to the way roots and sub roots are handled. | ||
| Now every sub root will track their own graph independently, instead of being attached to parent tree. | ||
| Additionally the roots() and serializedRoots() signals were replaced with event emitter. (#108) | ||
| ## 0.7.4 | ||
@@ -4,0 +17,0 @@ |
+1
-1
| import { | ||
| log | ||
| } from "./chunk-QTPCQOAB.js"; | ||
| } from "./chunk-HUGDDQ47.js"; | ||
@@ -5,0 +5,0 @@ // src/bridge.ts |
+5
-51
| import * as solid_js_types_reactive_signal from 'solid-js/types/reactive/signal'; | ||
| import { Many } from '@solid-primitives/utils'; | ||
| import { INTERNAL, NOTFOUND } from './variables.js'; | ||
| import { INTERNAL } from './variables.js'; | ||
| import { EncodedValue } from './serialize.js'; | ||
@@ -33,3 +33,2 @@ | ||
| sdtType?: NodeType; | ||
| ownedRoots?: Set<Solid.Root>; | ||
| } | ||
@@ -39,3 +38,2 @@ interface Computation<Init, Next> { | ||
| sdtType?: NodeType; | ||
| ownedRoots?: Set<Solid.Root>; | ||
| onValueUpdate?: Record<symbol, ValueUpdateListener>; | ||
@@ -60,3 +58,3 @@ onComputationUpdate?: VoidFunction; | ||
| isDisposed?: boolean; | ||
| sdtAttached?: true; | ||
| sdtAttachedTo?: Owner | null; | ||
| sdtContext?: DebuggerContext; | ||
@@ -103,3 +101,3 @@ value?: undefined; | ||
| removed: NodeID[]; | ||
| updated: Mapped.SRoot[]; | ||
| updated: Record<NodeID, Mapped.Root>; | ||
| }; | ||
@@ -114,10 +112,5 @@ declare type SignalUpdate = { | ||
| id: NodeID; | ||
| attachedTo?: NodeID; | ||
| tree: Owner; | ||
| components: Component[]; | ||
| } | ||
| /** serialised (without components) */ | ||
| interface SRoot { | ||
| id: NodeID; | ||
| tree: Owner; | ||
| } | ||
| interface Owner { | ||
@@ -128,3 +121,2 @@ id: NodeID; | ||
| children: Owner[]; | ||
| sources: number; | ||
| } | ||
@@ -165,41 +157,3 @@ interface Signal { | ||
| } | ||
| declare namespace Graph { | ||
| interface Root { | ||
| readonly id: NodeID; | ||
| readonly tree: Owner; | ||
| } | ||
| interface Owner { | ||
| readonly id: NodeID; | ||
| readonly name: string; | ||
| readonly type: NodeType; | ||
| readonly sources: number; | ||
| readonly children: Owner[]; | ||
| } | ||
| type Signal = { | ||
| readonly type: NodeType.Signal | NodeType.Memo; | ||
| readonly name: string; | ||
| readonly id: NodeID; | ||
| readonly observers: NodeID[]; | ||
| readonly value: EncodedValue<boolean>; | ||
| readonly selected: boolean; | ||
| }; | ||
| type Path = (Owner | typeof NOTFOUND)[]; | ||
| type Props = { | ||
| proxy: boolean; | ||
| record: Record<string, { | ||
| selected: boolean; | ||
| value: EncodedValue<boolean>; | ||
| }>; | ||
| }; | ||
| interface OwnerDetails { | ||
| readonly id: NodeID; | ||
| readonly name: string; | ||
| readonly type: NodeType; | ||
| readonly path: Path; | ||
| readonly rawPath: NodeID[]; | ||
| readonly signals: Record<NodeID, Signal>; | ||
| readonly props?: Props; | ||
| } | ||
| } | ||
| export { ComputationUpdate, Core, DebuggerContext, Graph, Mapped, NodeID, NodeType, RootsUpdates, SignalUpdate, Solid, ValueUpdateListener, getOwner }; | ||
| export { ComputationUpdate, Core, DebuggerContext, Mapped, NodeID, NodeType, RootsUpdates, SignalUpdate, Solid, ValueUpdateListener, getOwner }; |
@@ -23,3 +23,2 @@ "use strict"; | ||
| __export(primitives_exports, { | ||
| createBoundSelector: () => createBoundSelector, | ||
| createConsumers: () => createConsumers, | ||
@@ -63,9 +62,4 @@ createDerivedSignal: () => createDerivedSignal, | ||
| } | ||
| function createBoundSelector(source, fn) { | ||
| const selector = (0, import_solid_js.createSelector)(source, fn); | ||
| return [(item) => selector.bind(void 0, item), selector]; | ||
| } | ||
| // Annotate the CommonJS export names for ESM import in node: | ||
| 0 && (module.exports = { | ||
| createBoundSelector, | ||
| createConsumers, | ||
@@ -72,0 +66,0 @@ createDerivedSignal, |
@@ -1,2 +0,2 @@ | ||
| import { MemoOptions, EqualityCheckerFunction } from 'solid-js/types/reactive/signal'; | ||
| import { MemoOptions } from 'solid-js/types/reactive/signal'; | ||
| import { Accessor } from 'solid-js'; | ||
@@ -24,4 +24,3 @@ import { AnyFunction } from '@solid-primitives/utils'; | ||
| declare function createDerivedSignal<T>(fallback: T, options?: MemoOptions<T>): DerivedSignal<T>; | ||
| declare function createBoundSelector<T, U>(source: Accessor<T>, fn?: EqualityCheckerFunction<T, U>): [useSelector: (item: U) => Accessor<boolean>, selector: (item: U) => boolean]; | ||
| export { DerivedSignal, createBoundSelector, createConsumers, createDerivedSignal, untrackedCallback }; | ||
| export { DerivedSignal, createConsumers, createDerivedSignal, untrackedCallback }; |
+1
-13
| // src/primitives.ts | ||
| import { | ||
| createMemo, | ||
| createSignal, | ||
| getOwner, | ||
| onCleanup, | ||
| createSelector, | ||
| untrack | ||
| } from "solid-js"; | ||
| import { createMemo, createSignal, getOwner, onCleanup, untrack } from "solid-js"; | ||
| import { remove } from "@solid-primitives/immutable"; | ||
@@ -42,8 +35,3 @@ import { onRootCleanup } from "@solid-primitives/utils"; | ||
| } | ||
| function createBoundSelector(source, fn) { | ||
| const selector = createSelector(source, fn); | ||
| return [(item) => selector.bind(void 0, item), selector]; | ||
| } | ||
| export { | ||
| createBoundSelector, | ||
| createConsumers, | ||
@@ -50,0 +38,0 @@ createDerivedSignal, |
+17
-0
@@ -26,2 +26,4 @@ "use strict"; | ||
| dedupeArray: () => dedupeArray, | ||
| findIndexById: () => findIndexById, | ||
| findItemById: () => findItemById, | ||
| formatTime: () => formatTime, | ||
@@ -83,2 +85,15 @@ info: () => info, | ||
| } | ||
| function findIndexById(array, id) { | ||
| for (let i = 0; i < array.length; i++) | ||
| if (array[i].id === id) | ||
| return i; | ||
| return -1; | ||
| } | ||
| function findItemById(array, id) { | ||
| for (let i = 0; i < array.length; i++) { | ||
| const item = array[i]; | ||
| if (item.id === id) | ||
| return item; | ||
| } | ||
| } | ||
| // Annotate the CommonJS export names for ESM import in node: | ||
@@ -89,2 +104,4 @@ 0 && (module.exports = { | ||
| dedupeArray, | ||
| findIndexById, | ||
| findItemById, | ||
| formatTime, | ||
@@ -91,0 +108,0 @@ info, |
+7
-1
@@ -19,3 +19,9 @@ declare function info<T>(data: T): T; | ||
| declare function trimString(str: string, maxLength: number): string; | ||
| declare function findIndexById<T extends { | ||
| id: string; | ||
| }>(array: T[], id: string): number; | ||
| declare function findItemById<T extends { | ||
| id: string; | ||
| }>(array: T[], id: string): T | undefined; | ||
| export { arrayRefEquals, callArrayProp, dedupeArray, formatTime, info, log, mutateFilter, mutateRemove, pushToArrayProp, trimString, warn }; | ||
| export { arrayRefEquals, callArrayProp, dedupeArray, findIndexById, findItemById, formatTime, info, log, mutateFilter, mutateRemove, pushToArrayProp, trimString, warn }; |
+5
-1
@@ -5,2 +5,4 @@ import { | ||
| dedupeArray, | ||
| findIndexById, | ||
| findItemById, | ||
| formatTime, | ||
@@ -14,3 +16,3 @@ info, | ||
| warn | ||
| } from "./chunk-QTPCQOAB.js"; | ||
| } from "./chunk-HUGDDQ47.js"; | ||
| export { | ||
@@ -20,2 +22,4 @@ arrayRefEquals, | ||
| dedupeArray, | ||
| findIndexById, | ||
| findItemById, | ||
| formatTime, | ||
@@ -22,0 +26,0 @@ info, |
+4
-4
| { | ||
| "name": "@solid-devtools/shared", | ||
| "version": "0.7.4", | ||
| "version": "0.8.0", | ||
| "license": "MIT", | ||
@@ -86,7 +86,7 @@ "author": "Damian Tarnawski <gthetarnav@gmail.com>", | ||
| "@testing-library/jest-dom": "^5.16.5", | ||
| "jest": "^28.1.3", | ||
| "jest-environment-jsdom": "^28.1.3", | ||
| "jest": "^29.0.3", | ||
| "jest-environment-jsdom": "^29.0.3", | ||
| "solid-js": "^1.5.4", | ||
| "tsup": "^6.2.3", | ||
| "typescript": "^4.8.2" | ||
| "typescript": "^4.8.3" | ||
| }, | ||
@@ -93,0 +93,0 @@ "peerDependencies": { |
+6
-63
| import { getOwner as _getOwner } from "solid-js" | ||
| import { Many } from "@solid-primitives/utils" | ||
| import { INTERNAL, NOTFOUND } from "./variables" | ||
| import { INTERNAL } from "./variables" | ||
| import { EncodedValue } from "./serialize" | ||
@@ -36,3 +36,2 @@ | ||
| sdtType?: NodeType | ||
| ownedRoots?: Set<Solid.Root> | ||
| } | ||
@@ -42,3 +41,2 @@ interface Computation<Init, Next> { | ||
| sdtType?: NodeType | ||
| ownedRoots?: Set<Solid.Root> | ||
| onValueUpdate?: Record<symbol, ValueUpdateListener> | ||
@@ -69,5 +67,5 @@ onComputationUpdate?: VoidFunction | ||
| sourceMap?: Record<string, Signal> | ||
| // Used by the debugger | ||
| isDisposed?: boolean | ||
| // Used by the debugger | ||
| sdtAttached?: true | ||
| sdtAttachedTo?: Owner | null | ||
| sdtContext?: DebuggerContext | ||
@@ -123,3 +121,3 @@ // Computation compatibility | ||
| removed: NodeID[] | ||
| updated: Mapped.SRoot[] | ||
| updated: Record<NodeID, Mapped.Root> | ||
| } | ||
@@ -142,14 +140,7 @@ | ||
| id: NodeID | ||
| // sub-roots will have an owner | ||
| attachedTo?: NodeID | ||
| tree: Owner | ||
| // components is an array instead of an object to preserve the order (nesting) of the components, | ||
| // this helps the locator find the most nested component first | ||
| components: Component[] | ||
| } | ||
| /** serialised (without components) */ | ||
| export interface SRoot { | ||
| id: NodeID | ||
| tree: Owner | ||
| } | ||
| export interface Owner { | ||
@@ -160,3 +151,2 @@ id: NodeID | ||
| children: Owner[] | ||
| sources: number | ||
| } | ||
@@ -201,48 +191,1 @@ | ||
| } | ||
| // | ||
| // "Graph___" — owner/signals/etc. objects handled by the devtools frontend (extension/overlay/ui packages) | ||
| // They are meant to be "reactive" — wrapped with a store | ||
| // | ||
| export namespace Graph { | ||
| export interface Root { | ||
| readonly id: NodeID | ||
| readonly tree: Owner | ||
| } | ||
| export interface Owner { | ||
| readonly id: NodeID | ||
| readonly name: string | ||
| readonly type: NodeType | ||
| readonly sources: number | ||
| readonly children: Owner[] | ||
| } | ||
| export type Signal = { | ||
| readonly type: NodeType.Signal | NodeType.Memo | ||
| readonly name: string | ||
| readonly id: NodeID | ||
| readonly observers: NodeID[] | ||
| readonly value: EncodedValue<boolean> | ||
| readonly selected: boolean | ||
| } | ||
| export type Path = (Owner | typeof NOTFOUND)[] | ||
| export type Props = { | ||
| proxy: boolean | ||
| record: Record<string, { selected: boolean; value: EncodedValue<boolean> }> | ||
| } | ||
| export interface OwnerDetails { | ||
| readonly id: NodeID | ||
| readonly name: string | ||
| readonly type: NodeType | ||
| readonly path: Path | ||
| readonly rawPath: NodeID[] | ||
| readonly signals: Record<NodeID, Signal> | ||
| readonly props?: Props | ||
| // TODO: more to come | ||
| } | ||
| } |
+2
-18
@@ -1,11 +0,3 @@ | ||
| import type { EqualityCheckerFunction, MemoOptions } from "solid-js/types/reactive/signal" | ||
| import { | ||
| Accessor, | ||
| createMemo, | ||
| createSignal, | ||
| getOwner, | ||
| onCleanup, | ||
| createSelector, | ||
| untrack, | ||
| } from "solid-js" | ||
| import type { MemoOptions } from "solid-js/types/reactive/signal" | ||
| import { Accessor, createMemo, createSignal, getOwner, onCleanup, untrack } from "solid-js" | ||
| import { remove } from "@solid-primitives/immutable" | ||
@@ -68,9 +60,1 @@ import { AnyFunction, onRootCleanup } from "@solid-primitives/utils" | ||
| } | ||
| export function createBoundSelector<T, U>( | ||
| source: Accessor<T>, | ||
| fn?: EqualityCheckerFunction<T, U>, | ||
| ): [useSelector: (item: U) => Accessor<boolean>, selector: (item: U) => boolean] { | ||
| const selector = createSelector(source, fn) | ||
| return [item => selector.bind(void 0, item), selector] | ||
| } |
+12
-0
@@ -80,1 +80,13 @@ const getLogLabel = () => [ | ||
| } | ||
| export function findIndexById<T extends { id: string }>(array: T[], id: string): number { | ||
| for (let i = 0; i < array.length; i++) if (array[i].id === id) return i | ||
| return -1 | ||
| } | ||
| export function findItemById<T extends { id: string }>(array: T[], id: string): T | undefined { | ||
| for (let i = 0; i < array.length; i++) { | ||
| const item = array[i] | ||
| if (item.id === id) return item | ||
| } | ||
| } |
| // src/utils.ts | ||
| var getLogLabel = () => [ | ||
| `%csolid-devtools`, | ||
| "color: #fff; background: #2c4f7c; padding: 1px 4px;" | ||
| ]; | ||
| function info(data) { | ||
| console.info(...getLogLabel(), data); | ||
| return data; | ||
| } | ||
| function log(...args) { | ||
| console.log(...getLogLabel(), ...args); | ||
| } | ||
| function warn(...args) { | ||
| console.warn(...getLogLabel(), ...args); | ||
| } | ||
| function formatTime(d = new Date()) { | ||
| return ("0" + d.getHours()).slice(-2) + ":" + ("0" + d.getMinutes()).slice(-2) + ":" + ("0" + d.getSeconds()).slice(-2); | ||
| } | ||
| function callArrayProp(object, key, ...args) { | ||
| const arr = object[key]; | ||
| if (arr) | ||
| for (const cb of arr) | ||
| cb(...args); | ||
| } | ||
| function pushToArrayProp(object, key, value) { | ||
| let arr = object[key]; | ||
| if (arr) | ||
| arr.push(value); | ||
| else | ||
| arr = object[key] = [value]; | ||
| return arr; | ||
| } | ||
| function mutateFilter(array, predicate) { | ||
| const temp = array.filter(predicate); | ||
| array.length = 0; | ||
| array.push.apply(array, temp); | ||
| } | ||
| function mutateRemove(array, item) { | ||
| array.splice(array.indexOf(item), 1); | ||
| } | ||
| var dedupeArray = (array) => Array.from(new Set(array)); | ||
| var arrayRefEquals = (a, b) => a === b || a.length === b.length && a.every((e) => b.includes(e)); | ||
| function trimString(str, maxLength) { | ||
| if (str.length <= maxLength) | ||
| return str; | ||
| return str.slice(0, maxLength) + "\u2026"; | ||
| } | ||
| export { | ||
| info, | ||
| log, | ||
| warn, | ||
| formatTime, | ||
| callArrayProp, | ||
| pushToArrayProp, | ||
| mutateFilter, | ||
| mutateRemove, | ||
| dedupeArray, | ||
| arrayRefEquals, | ||
| trimString | ||
| }; |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
75825
-2.19%1913
-3.87%