@syrin/iris 0.4.0
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/LICENSE +21 -0
- package/README.md +110 -0
- package/dist/babel.d.ts +14 -0
- package/dist/babel.js +32 -0
- package/dist/cli.d.ts +17 -0
- package/dist/cli.js +5160 -0
- package/dist/eslint.d.ts +22 -0
- package/dist/eslint.js +134 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +3984 -0
- package/dist/next.d.ts +4 -0
- package/dist/next.js +64 -0
- package/dist/server.d.ts +59 -0
- package/dist/server.js +5174 -0
- package/dist/test.d.ts +16 -0
- package/dist/test.js +5798 -0
- package/package.json +93 -0
package/dist/eslint.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
|
|
2
|
+
import * as __options_js from './options.js';
|
|
3
|
+
export { requireSignalOnMutation } from './require-signal-on-mutation.js';
|
|
4
|
+
|
|
5
|
+
declare const rules: {
|
|
6
|
+
readonly "require-signal-on-mutation": _typescript_eslint_utils_ts_eslint.RuleModule<"mutationWithoutSignal", [__options_js.RawRuleOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
declare const plugin: {
|
|
11
|
+
meta: {
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
rules: {
|
|
15
|
+
readonly "require-signal-on-mutation": _typescript_eslint_utils_ts_eslint.RuleModule<"mutationWithoutSignal", [__options_js.RawRuleOptions], unknown, _typescript_eslint_utils_ts_eslint.RuleListener> & {
|
|
16
|
+
name: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
configs: Record<string, unknown>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { plugin as default, rules };
|
package/dist/eslint.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// ../eslint-plugin/dist/require-signal-on-mutation.js
|
|
2
|
+
import { AST_NODE_TYPES, ESLintUtils } from "@typescript-eslint/utils";
|
|
3
|
+
|
|
4
|
+
// ../eslint-plugin/dist/constants.js
|
|
5
|
+
var RULE_NAME = "require-signal-on-mutation";
|
|
6
|
+
var MessageId = {
|
|
7
|
+
MUTATION_WITHOUT_SIGNAL: "mutationWithoutSignal"
|
|
8
|
+
};
|
|
9
|
+
var MUTATION_WITHOUT_SIGNAL_MESSAGE = "store mutation without a mapped Iris signal";
|
|
10
|
+
var DEFAULT_SIGNAL_CALLEES = ["irisSignal", "signal"];
|
|
11
|
+
var DEFAULT_MUTATORS = [];
|
|
12
|
+
var PLUGIN_NAME = "iris";
|
|
13
|
+
var DOCS_URL_ROOT = "https://github.com/syrin-labs/iris/blob/main/packages/eslint-plugin/README.md";
|
|
14
|
+
|
|
15
|
+
// ../eslint-plugin/dist/options.js
|
|
16
|
+
var OPTIONS_SCHEMA = [
|
|
17
|
+
{
|
|
18
|
+
type: "object",
|
|
19
|
+
properties: {
|
|
20
|
+
mutators: {
|
|
21
|
+
type: "array",
|
|
22
|
+
items: { type: "string" }
|
|
23
|
+
},
|
|
24
|
+
signalCallee: {
|
|
25
|
+
oneOf: [{ type: "string" }, { type: "array", items: { type: "string" } }]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
additionalProperties: false
|
|
29
|
+
}
|
|
30
|
+
];
|
|
31
|
+
function toNonEmptySet(values) {
|
|
32
|
+
return new Set(values.filter((v) => v.length > 0));
|
|
33
|
+
}
|
|
34
|
+
function normalizeOptions(raw) {
|
|
35
|
+
const mutatorList = raw?.mutators ?? DEFAULT_MUTATORS;
|
|
36
|
+
const rawSignal = raw?.signalCallee;
|
|
37
|
+
let signalList;
|
|
38
|
+
if (rawSignal === void 0) {
|
|
39
|
+
signalList = DEFAULT_SIGNAL_CALLEES;
|
|
40
|
+
} else if (typeof rawSignal === "string") {
|
|
41
|
+
signalList = [rawSignal];
|
|
42
|
+
} else {
|
|
43
|
+
signalList = rawSignal;
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
mutators: toNonEmptySet(mutatorList),
|
|
47
|
+
signalCallees: toNonEmptySet(signalList)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ../eslint-plugin/dist/require-signal-on-mutation.js
|
|
52
|
+
var createRule = ESLintUtils.RuleCreator((name) => `${DOCS_URL_ROOT}#${name}`);
|
|
53
|
+
function calleeName(node) {
|
|
54
|
+
const callee = node.callee;
|
|
55
|
+
if (callee.type === AST_NODE_TYPES.Identifier) {
|
|
56
|
+
return callee.name;
|
|
57
|
+
}
|
|
58
|
+
if (callee.type === AST_NODE_TYPES.MemberExpression && callee.computed === false && callee.property.type === AST_NODE_TYPES.Identifier) {
|
|
59
|
+
return callee.property.name;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
var requireSignalOnMutation = createRule({
|
|
64
|
+
name: "require-signal-on-mutation",
|
|
65
|
+
meta: {
|
|
66
|
+
type: "problem",
|
|
67
|
+
docs: {
|
|
68
|
+
description: "Require an Iris signal alongside any user-visible store mutation so the signal layer cannot drift."
|
|
69
|
+
},
|
|
70
|
+
schema: OPTIONS_SCHEMA,
|
|
71
|
+
messages: {
|
|
72
|
+
[MessageId.MUTATION_WITHOUT_SIGNAL]: MUTATION_WITHOUT_SIGNAL_MESSAGE
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
defaultOptions: [{}],
|
|
76
|
+
create(context) {
|
|
77
|
+
const { mutators, signalCallees } = normalizeOptions(context.options[0]);
|
|
78
|
+
const stack = [];
|
|
79
|
+
function enterFn() {
|
|
80
|
+
stack.push({ calledSignal: false, mutatorNode: null });
|
|
81
|
+
}
|
|
82
|
+
function exitFn() {
|
|
83
|
+
const frame = stack.pop();
|
|
84
|
+
if (frame === void 0)
|
|
85
|
+
return;
|
|
86
|
+
if (frame.mutatorNode !== null && frame.calledSignal === false) {
|
|
87
|
+
context.report({
|
|
88
|
+
node: frame.mutatorNode,
|
|
89
|
+
messageId: MessageId.MUTATION_WITHOUT_SIGNAL
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
FunctionDeclaration: enterFn,
|
|
95
|
+
"FunctionDeclaration:exit": exitFn,
|
|
96
|
+
FunctionExpression: enterFn,
|
|
97
|
+
"FunctionExpression:exit": exitFn,
|
|
98
|
+
ArrowFunctionExpression: enterFn,
|
|
99
|
+
"ArrowFunctionExpression:exit": exitFn,
|
|
100
|
+
CallExpression(node) {
|
|
101
|
+
const frame = stack.at(-1);
|
|
102
|
+
if (frame === void 0)
|
|
103
|
+
return;
|
|
104
|
+
const name = calleeName(node);
|
|
105
|
+
if (name === null)
|
|
106
|
+
return;
|
|
107
|
+
if (mutators.has(name) && frame.mutatorNode === null) {
|
|
108
|
+
frame.mutatorNode = node;
|
|
109
|
+
}
|
|
110
|
+
if (signalCallees.has(name)) {
|
|
111
|
+
frame.calledSignal = true;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
// ../eslint-plugin/dist/index.js
|
|
119
|
+
var rules = { [RULE_NAME]: requireSignalOnMutation };
|
|
120
|
+
var plugin = {
|
|
121
|
+
meta: { name: PLUGIN_NAME },
|
|
122
|
+
rules,
|
|
123
|
+
configs: {}
|
|
124
|
+
};
|
|
125
|
+
plugin.configs.recommended = {
|
|
126
|
+
plugins: { [PLUGIN_NAME]: plugin },
|
|
127
|
+
rules: { [`${PLUGIN_NAME}/${RULE_NAME}`]: "warn" }
|
|
128
|
+
};
|
|
129
|
+
var dist_default = plugin;
|
|
130
|
+
export {
|
|
131
|
+
dist_default as default,
|
|
132
|
+
requireSignalOnMutation,
|
|
133
|
+
rules
|
|
134
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Iris } from './iris.js';
|
|
2
|
+
export { Iris, IrisConnectOptions } from './iris.js';
|
|
3
|
+
import { ComponentStateResult } from './constants.js';
|
|
4
|
+
export { SESSION_AUTO } from './constants.js';
|
|
5
|
+
import { ComponentInfo } from './registry/adapters.js';
|
|
6
|
+
export { ComponentInfo, ComponentSource, IrisAdapter, adapterNames, elementHasHoverHandlers, identifyComponent, readComponentState, registerAdapter } from './registry/adapters.js';
|
|
7
|
+
export { Capabilities, CapabilitiesInput, CapabilityFlow, getCapabilities, hasCapabilities, registerCapabilities } from './registry/capabilities.js';
|
|
8
|
+
export { CreateIrisEmitterOptions, EmitterTarget, IrisEmitter, createIrisEmitter } from './registry/emitter.js';
|
|
9
|
+
export { IrisDomain, registerIrisDomain } from './registry/domains.js';
|
|
10
|
+
export { RefRegistry, refs } from './dom/refs.js';
|
|
11
|
+
export { StoreGetter, readStores, registerStore, storeNames, unregisterStore } from './registry/stores.js';
|
|
12
|
+
export { buildSnapshot } from './dom/snapshot.js';
|
|
13
|
+
export { commitAndSignal } from './registry/commit-and-signal.js';
|
|
14
|
+
export { describe, getAccessibleName, getRole, getStates, isVisible } from './dom/a11y.js';
|
|
15
|
+
export { executeAction, executeSequence } from './actions/actions.js';
|
|
16
|
+
export { matchQuery, runQuery } from './dom/query.js';
|
|
17
|
+
export { setIgnoreSelectors } from './dom/dom-ignore.js';
|
|
18
|
+
|
|
19
|
+
declare const iris: Iris;
|
|
20
|
+
|
|
21
|
+
/** Walk the fiber tree from a DOM node up to the root, collecting components + source. */
|
|
22
|
+
declare function identify(el: Element): ComponentInfo | null;
|
|
23
|
+
declare function readState(el: Element): ComponentStateResult;
|
|
24
|
+
/**
|
|
25
|
+
* True if the element's host fiber declares React enter/leave handlers. Synthetic dispatchEvent
|
|
26
|
+
* does not reliably trigger React's native enter/leave synthesis (no hit-testing), so callers warn.
|
|
27
|
+
* Fail soft: any unexpected fiber shape returns false.
|
|
28
|
+
*/
|
|
29
|
+
declare function hasHoverHandlers(el: Element): boolean;
|
|
30
|
+
/** Register the React adapter so `iris.inspect` returns component stack + source file. */
|
|
31
|
+
declare function install(): void;
|
|
32
|
+
|
|
33
|
+
export { hasHoverHandlers, identify, install, iris, readState };
|