plusui-native-connect 0.1.55 → 0.1.58
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/package.json +1 -1
- package/src/index.js +41 -6
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -9,8 +9,27 @@ const TS_EXTENSIONS = new Set(['.ts', '.tsx', '.js', '.jsx', '.mts', '.cts']);
|
|
|
9
9
|
const CPP_EXTENSIONS = new Set(['.cpp', '.cc', '.cxx', '.hpp', '.h', '.hh', '.hxx']);
|
|
10
10
|
const IGNORE_SEGMENTS = new Set(['node_modules', '.git', 'dist', 'build', '.plusui', 'generated']);
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const CONNECT_EMIT_PATTERN = /\bconnect\s*\.\s*emit\s*\(\s*['\"]([^'\"]+)['\"]/g;
|
|
13
|
+
const CONNECT_ON_PATTERN = /\bconnect\s*\.\s*on\s*\(\s*['\"]([^'\"]+)['\"]/g;
|
|
14
|
+
const FEATURE_CONNECT_EMIT_PATTERN =
|
|
15
|
+
/\b([A-Za-z_$][\w$]*)\s*\.\s*connect\s*\.\s*emit\s*\(\s*['\"]([^'\"]+)['\"]/g;
|
|
16
|
+
const FEATURE_CONNECT_ON_PATTERN =
|
|
17
|
+
/\b([A-Za-z_$][\w$]*)\s*\.\s*connect\s*\.\s*on\s*\(\s*['\"]([^'\"]+)['\"]/g;
|
|
18
|
+
const FEATURE_EMIT_PATTERN = /\b([A-Za-z_$][\w$]*)\s*\.\s*emit\s*\(\s*['\"]([^'\"]+)['\"]/g;
|
|
19
|
+
const FEATURE_ON_PATTERN = /\b([A-Za-z_$][\w$]*)\s*\.\s*on\s*\(\s*['\"]([^'\"]+)['\"]/g;
|
|
20
|
+
|
|
21
|
+
function resolveChannel(scope, name) {
|
|
22
|
+
if (!scope || scope === 'connect') {
|
|
23
|
+
return name;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const prefix = `${scope}.`;
|
|
27
|
+
if (name.startsWith(prefix)) {
|
|
28
|
+
return name;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return `${scope}.${name}`;
|
|
32
|
+
}
|
|
14
33
|
|
|
15
34
|
function isIgnored(path) {
|
|
16
35
|
const normalized = path.replace(/\\/g, '/');
|
|
@@ -51,14 +70,30 @@ function parseConnectUsage(content) {
|
|
|
51
70
|
const listens = [];
|
|
52
71
|
|
|
53
72
|
let match = null;
|
|
54
|
-
while ((match =
|
|
73
|
+
while ((match = CONNECT_EMIT_PATTERN.exec(content)) !== null) {
|
|
55
74
|
emits.push(match[1]);
|
|
56
75
|
}
|
|
57
76
|
|
|
58
|
-
while ((match =
|
|
77
|
+
while ((match = CONNECT_ON_PATTERN.exec(content)) !== null) {
|
|
59
78
|
listens.push(match[1]);
|
|
60
79
|
}
|
|
61
80
|
|
|
81
|
+
while ((match = FEATURE_CONNECT_EMIT_PATTERN.exec(content)) !== null) {
|
|
82
|
+
emits.push(resolveChannel(match[1], match[2]));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
while ((match = FEATURE_CONNECT_ON_PATTERN.exec(content)) !== null) {
|
|
86
|
+
listens.push(resolveChannel(match[1], match[2]));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
while ((match = FEATURE_EMIT_PATTERN.exec(content)) !== null) {
|
|
90
|
+
emits.push(resolveChannel(match[1], match[2]));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
while ((match = FEATURE_ON_PATTERN.exec(content)) !== null) {
|
|
94
|
+
listens.push(resolveChannel(match[1], match[2]));
|
|
95
|
+
}
|
|
96
|
+
|
|
62
97
|
return { emits, listens };
|
|
63
98
|
}
|
|
64
99
|
|
|
@@ -80,7 +115,7 @@ function generateTsBindings(channels, projectRoot) {
|
|
|
80
115
|
lines.push('/**');
|
|
81
116
|
lines.push(' * Auto-generated by plusui-connect');
|
|
82
117
|
lines.push(' * DO NOT EDIT - Changes will be overwritten');
|
|
83
|
-
lines.push(' * Source: connect
|
|
118
|
+
lines.push(' * Source: connect/feature emit()/on() usage scan');
|
|
84
119
|
lines.push(' */');
|
|
85
120
|
lines.push('import { connect as runtimeConnect } from "plusui-native-core/connect";');
|
|
86
121
|
lines.push('');
|
|
@@ -120,7 +155,7 @@ function generateCppBindings(channels, projectRoot) {
|
|
|
120
155
|
lines.push('/**');
|
|
121
156
|
lines.push(' * Auto-generated by plusui-connect');
|
|
122
157
|
lines.push(' * DO NOT EDIT - Changes will be overwritten');
|
|
123
|
-
lines.push(' * Source: connect
|
|
158
|
+
lines.push(' * Source: connect/feature emit()/on() usage scan');
|
|
124
159
|
lines.push(' */');
|
|
125
160
|
lines.push('#pragma once');
|
|
126
161
|
lines.push('#include <array>');
|