@neuxnet/neux-cli 0.2.3

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.
Files changed (73) hide show
  1. package/README.md +438 -0
  2. package/README.zh-CN.md +554 -0
  3. package/assets/container/assets/index.css +1 -0
  4. package/assets/container/assets/index.js +137 -0
  5. package/assets/container/assets/pageFrame.css +1 -0
  6. package/assets/container/assets/pageFrame.js +56 -0
  7. package/assets/container/assets/service.js +6 -0
  8. package/assets/container/assets/vconsole.js +931 -0
  9. package/assets/container/favicon.ico +0 -0
  10. package/assets/container/images/icon-arrow.png +0 -0
  11. package/assets/container/images/mini-action-white.png +0 -0
  12. package/assets/container/images/mini-action.png +0 -0
  13. package/assets/container/images/mini-arrow-left-white.png +0 -0
  14. package/assets/container/images/mini-arrow-left.jpg +0 -0
  15. package/assets/container/images/mini-arrow-left.png +0 -0
  16. package/assets/container/images/mini-close-white.png +0 -0
  17. package/assets/container/images/mini-close.png +0 -0
  18. package/assets/container/images/more.png +0 -0
  19. package/assets/container/images/search.jpg +0 -0
  20. package/assets/container/index.html +1 -0
  21. package/assets/container/pageFrame.html +1 -0
  22. package/assets/init/tabbar/home-active.png +0 -0
  23. package/assets/init/tabbar/home.png +0 -0
  24. package/assets/init/tabbar/list-active.png +0 -0
  25. package/assets/init/tabbar/list.png +0 -0
  26. package/assets/init/types/neux-api.d.ts +1402 -0
  27. package/package.json +68 -0
  28. package/scripts/generate-init-types.js +210 -0
  29. package/scripts/sync-compiler.js +22 -0
  30. package/scripts/sync-web-container.js +34 -0
  31. package/src/bin/cli.js +646 -0
  32. package/src/core/brand.js +11 -0
  33. package/src/core/compiler.js +305 -0
  34. package/src/core/defaults.js +12 -0
  35. package/src/core/dev.js +15 -0
  36. package/src/core/errors.js +17 -0
  37. package/src/core/fs.js +66 -0
  38. package/src/core/i18n.js +37 -0
  39. package/src/core/init.js +866 -0
  40. package/src/core/lifecycle.js +32 -0
  41. package/src/core/manifest.js +72 -0
  42. package/src/core/pack.js +156 -0
  43. package/src/core/package-info.js +27 -0
  44. package/src/core/preview-server.js +123 -0
  45. package/src/core/project.js +101 -0
  46. package/src/core/prompts.js +71 -0
  47. package/src/core/proxy-security.js +141 -0
  48. package/src/core/proxy.js +156 -0
  49. package/src/core/qr.js +41 -0
  50. package/src/core/terminal-qr.js +72 -0
  51. package/src/core/update.js +278 -0
  52. package/src/core/watch.js +113 -0
  53. package/src/core/web.js +649 -0
  54. package/src/core/zip.js +120 -0
  55. package/src/index.js +20 -0
  56. package/src/providers/service-client.js +149 -0
  57. package/src/providers/service-config.js +264 -0
  58. package/src/providers/service.js +146 -0
  59. package/src/providers/upload.js +112 -0
  60. package/vendor/dimina-compiler/bin/index.cjs +265 -0
  61. package/vendor/dimina-compiler/bin/index.js +263 -0
  62. package/vendor/dimina-compiler/compatibility-B-DoZtUX.cjs +395 -0
  63. package/vendor/dimina-compiler/compatibility-Cl3-DO6V.js +366 -0
  64. package/vendor/dimina-compiler/core/logic-compiler.cjs +378 -0
  65. package/vendor/dimina-compiler/core/logic-compiler.js +374 -0
  66. package/vendor/dimina-compiler/core/style-compiler.cjs +392 -0
  67. package/vendor/dimina-compiler/core/style-compiler.js +377 -0
  68. package/vendor/dimina-compiler/core/view-compiler.cjs +1601 -0
  69. package/vendor/dimina-compiler/core/view-compiler.js +1582 -0
  70. package/vendor/dimina-compiler/index.cjs +762 -0
  71. package/vendor/dimina-compiler/index.js +751 -0
  72. package/vendor/dimina-compiler/sourcemap-BgtIgqkC.cjs +1377 -0
  73. package/vendor/dimina-compiler/sourcemap-CKjhV9h7.js +1135 -0
@@ -0,0 +1,366 @@
1
+ import { M as tagWhiteList, k as miniProgramBuiltinTags, v as getTemplateDirectivePrefixes, x as getViewScriptTags } from "./sourcemap-CKjhV9h7.js";
2
+ import { isMainThread } from "node:worker_threads";
3
+ import { Parser } from "htmlparser2";
4
+ import { isHTMLTag } from "@vue/shared";
5
+ //#region src/common/compatibility-reference.js
6
+ var supportedBuiltinComponents = [
7
+ "audio",
8
+ "block",
9
+ "button",
10
+ "canvas",
11
+ "checkbox",
12
+ "checkbox-group",
13
+ "cover-image",
14
+ "cover-view",
15
+ "form",
16
+ "icon",
17
+ "image",
18
+ "input",
19
+ "label",
20
+ "map",
21
+ "movable-area",
22
+ "movable-view",
23
+ "navigation-bar",
24
+ "navigator",
25
+ "page-container",
26
+ "picker",
27
+ "picker-view",
28
+ "picker-view-column",
29
+ "progress",
30
+ "radio",
31
+ "radio-group",
32
+ "rich-text",
33
+ "scroll-view",
34
+ "slider",
35
+ "slot",
36
+ "swiper",
37
+ "swiper-item",
38
+ "switch",
39
+ "template",
40
+ "text",
41
+ "textarea",
42
+ "video",
43
+ "view",
44
+ "web-view",
45
+ "wxs",
46
+ "include",
47
+ "import"
48
+ ];
49
+ var supportedWxApis = [
50
+ "env",
51
+ "canIUse",
52
+ "getUserProfile",
53
+ "getAuthCode",
54
+ "getHostFontSize",
55
+ "getAuthList",
56
+ "getPhoneNumber",
57
+ "generateQRCode",
58
+ "captureScreen",
59
+ "shareToApp",
60
+ "shareMiniAppMessage",
61
+ "showShareMenu",
62
+ "hideShareMenu",
63
+ "showShareImageMenu",
64
+ "getPrivacySetting",
65
+ "requirePrivacyAuthorize",
66
+ "setEnableDebug",
67
+ "onError",
68
+ "offError",
69
+ "onAppShow",
70
+ "onAppHide",
71
+ "offAppShow",
72
+ "offAppHide",
73
+ "getUpdateManager",
74
+ "openSystemBluetoothSetting",
75
+ "openAppAuthorizeSetting",
76
+ "getWindowInfo",
77
+ "getSystemSetting",
78
+ "getSystemInfoSync",
79
+ "getSystemInfoAsync",
80
+ "getSystemInfo",
81
+ "getAppBaseInfo",
82
+ "setKeepScreenOn",
83
+ "getScreenBrightness",
84
+ "setScreenBrightness",
85
+ "setVisualEffectOnCapture",
86
+ "onUserCaptureScreen",
87
+ "offUserCaptureScreen",
88
+ "getDeviceInfo",
89
+ "onThemeChange",
90
+ "offThemeChange",
91
+ "reLaunch",
92
+ "redirectTo",
93
+ "navigateTo",
94
+ "navigateBack",
95
+ "exitMiniProgram",
96
+ "showToast",
97
+ "showModal",
98
+ "showLoading",
99
+ "showActionSheet",
100
+ "hideToast",
101
+ "hideLoading",
102
+ "setNavigationBarTitle",
103
+ "setNavigationBarColor",
104
+ "showNavigationBarLoading",
105
+ "hideNavigationBarLoading",
106
+ "pageScrollTo",
107
+ "getMenuButtonBoundingClientRect",
108
+ "onMenuButtonBoundingClientRectWeightChange",
109
+ "offMenuButtonBoundingClientRectWeightChange",
110
+ "nextTick",
111
+ "createAnimation",
112
+ "createCanvasContext",
113
+ "createOffscreenCanvas",
114
+ "canvasToTempFilePath",
115
+ "createSelectorQuery",
116
+ "createIntersectionObserver",
117
+ "request",
118
+ "downloadFile",
119
+ "uploadFile",
120
+ "getFileSystemManager",
121
+ "startLocalServiceDiscovery",
122
+ "stopLocalServiceDiscovery",
123
+ "onLocalServiceDiscoveryStop",
124
+ "offLocalServiceDiscoveryStop",
125
+ "onLocalServiceFound",
126
+ "offLocalServiceFound",
127
+ "onLocalServiceLost",
128
+ "offLocalServiceLost",
129
+ "onLocalServiceResolveFail",
130
+ "offLocalServiceResolveFail",
131
+ "createUDPSocket",
132
+ "UDPSocket.bind",
133
+ "UDPSocket.close",
134
+ "UDPSocket.connect",
135
+ "UDPSocket.send",
136
+ "UDPSocket.write",
137
+ "UDPSocket.setTTL",
138
+ "UDPSocket.onClose",
139
+ "UDPSocket.offClose",
140
+ "UDPSocket.onError",
141
+ "UDPSocket.offError",
142
+ "UDPSocket.onListening",
143
+ "UDPSocket.offListening",
144
+ "UDPSocket.onMessage",
145
+ "UDPSocket.offMessage",
146
+ "createTCPSocket",
147
+ "TCPSocket.bindWifi",
148
+ "TCPSocket.close",
149
+ "TCPSocket.connect",
150
+ "TCPSocket.write",
151
+ "TCPSocket.onBindWifi",
152
+ "TCPSocket.offBindWifi",
153
+ "TCPSocket.onClose",
154
+ "TCPSocket.offClose",
155
+ "TCPSocket.onConnect",
156
+ "TCPSocket.offConnect",
157
+ "TCPSocket.onError",
158
+ "TCPSocket.offError",
159
+ "TCPSocket.onMessage",
160
+ "TCPSocket.offMessage",
161
+ "setStorageSync",
162
+ "getStorageSync",
163
+ "removeStorageSync",
164
+ "clearStorageSync",
165
+ "setStorage",
166
+ "getStorage",
167
+ "removeStorage",
168
+ "clearStorage",
169
+ "getStorageInfoSync",
170
+ "getStorageInfo",
171
+ "saveImageToPhotosAlbum",
172
+ "previewImage",
173
+ "compressImage",
174
+ "chooseImage",
175
+ "createAudioContext",
176
+ "playBackgroundAudio",
177
+ "pauseBackgroundAudio",
178
+ "stopBackgroundAudio",
179
+ "seekBackgroundAudio",
180
+ "getBackgroundAudioPlayerState",
181
+ "startRecord",
182
+ "stopRecord",
183
+ "chooseMedia",
184
+ "saveVideoToPhotosAlbum",
185
+ "createMapContext",
186
+ "scanCode",
187
+ "getLocation",
188
+ "startLocationUpdate",
189
+ "stopLocationUpdate",
190
+ "onLocationChange",
191
+ "offLocationChange",
192
+ "openLocation",
193
+ "chooseLocation",
194
+ "chooseContact",
195
+ "addPhoneContact",
196
+ "addPhoneCalendar",
197
+ "setClipboardData",
198
+ "getClipboardData",
199
+ "openBluetoothAdapter",
200
+ "closeBluetoothAdapter",
201
+ "getBluetoothAdapterState",
202
+ "startBluetoothDevicesDiscovery",
203
+ "stopBluetoothDevicesDiscovery",
204
+ "onBluetoothDeviceFound",
205
+ "offBluetoothDeviceFound",
206
+ "onBluetoothAdapterStateChange",
207
+ "offBluetoothAdapterStateChange",
208
+ "getBluetoothDevices",
209
+ "getConnectedBluetoothDevices",
210
+ "createBLEConnection",
211
+ "closeBLEConnection",
212
+ "onBLEConnectionStateChange",
213
+ "offBLEConnectionStateChange",
214
+ "getBLEDeviceServices",
215
+ "getBLEDeviceCharacteristics",
216
+ "readBLECharacteristicValue",
217
+ "writeBLECharacteristicValue",
218
+ "notifyBLECharacteristicValueChange",
219
+ "onBLECharacteristicValueChange",
220
+ "offBLECharacteristicValueChange",
221
+ "getBLEDeviceRSSI",
222
+ "setBLEMTU",
223
+ "vibrateShort",
224
+ "vibrateLong",
225
+ "hideKeyboard",
226
+ "getNetworkType",
227
+ "makePhoneCall",
228
+ "onUserCaptureScreen",
229
+ "offUserCaptureScreen",
230
+ "extBridge",
231
+ "extOnBridge",
232
+ "extOffBridge",
233
+ "onHostEvent",
234
+ "offHostEvent"
235
+ ];
236
+ //#endregion
237
+ //#region src/common/compatibility.js
238
+ var cachedReference = null;
239
+ var warnedItems = /* @__PURE__ */ new Set();
240
+ var pendingWarnings = [];
241
+ var TEMPLATE_DIRECTIVE_NAMES = /* @__PURE__ */ new Set([
242
+ "if",
243
+ "elif",
244
+ "else",
245
+ "for",
246
+ "for-items",
247
+ "for-item",
248
+ "for-index",
249
+ "key"
250
+ ]);
251
+ var KNOWN_NON_TEMPLATE_PREFIXES = /* @__PURE__ */ new Set([
252
+ "model",
253
+ "change",
254
+ "worklet",
255
+ "data",
256
+ "class",
257
+ "style",
258
+ "bind",
259
+ "mut-bind",
260
+ "catch",
261
+ "capture-bind",
262
+ "capture-mut-bind",
263
+ "capture-catch",
264
+ "mark",
265
+ "generic",
266
+ "extra-attr",
267
+ "slot",
268
+ "let"
269
+ ]);
270
+ function splitAttributePrefix(attributeName) {
271
+ const segments = attributeName.split(":");
272
+ if (segments.length !== 2 || !segments[0] || !segments[1]) return null;
273
+ return {
274
+ prefix: segments[0],
275
+ name: segments[1]
276
+ };
277
+ }
278
+ function getTemplateDirectiveName(attributeName) {
279
+ const attribute = splitAttributePrefix(attributeName);
280
+ if (!attribute || !getTemplateDirectivePrefixes().includes(attribute.prefix)) return null;
281
+ return TEMPLATE_DIRECTIVE_NAMES.has(attribute.name) ? attribute.name : null;
282
+ }
283
+ function getInvalidAttributePrefix(attributeName) {
284
+ const attribute = splitAttributePrefix(attributeName);
285
+ if (!attribute) return null;
286
+ if (getTemplateDirectivePrefixes().includes(attribute.prefix)) return TEMPLATE_DIRECTIVE_NAMES.has(attribute.name) ? null : attribute.prefix;
287
+ if (KNOWN_NON_TEMPLATE_PREFIXES.has(attribute.prefix)) return null;
288
+ return attribute.prefix;
289
+ }
290
+ function loadReference() {
291
+ if (cachedReference) return cachedReference;
292
+ cachedReference = {
293
+ supportedBuiltinComponents: new Set(supportedBuiltinComponents),
294
+ supportedWxApis: new Set(supportedWxApis)
295
+ };
296
+ return cachedReference;
297
+ }
298
+ function getWxMemberName(node) {
299
+ if (node?.type !== "MemberExpression") return null;
300
+ if (node.object?.type !== "Identifier" || node.object.name !== "wx") return null;
301
+ if (!node.computed && node.property?.type === "Identifier") return node.property.name;
302
+ if (node.computed && (node.property?.type === "StringLiteral" || node.property?.type === "Literal") && typeof node.property.value === "string") return node.property.value;
303
+ return null;
304
+ }
305
+ function warnUnsupportedWxApi(apiName, filePath, line) {
306
+ const { supportedWxApis } = loadReference();
307
+ if (!apiName || supportedWxApis.has(apiName)) return;
308
+ const location = formatLocation(filePath, line);
309
+ warnOnce("api", apiName, location, `[compat] Unsupported wx API: wx.${apiName}${location}`);
310
+ }
311
+ function warnUnsupportedComponent(tagName, filePath, line) {
312
+ const { supportedBuiltinComponents } = loadReference();
313
+ if (!tagName || supportedBuiltinComponents.has(tagName) || tagWhiteList.includes(tagName) || getViewScriptTags().includes(tagName)) return;
314
+ if (!miniProgramBuiltinTags.has(tagName) && isHTMLTag(tagName)) return;
315
+ const location = formatLocation(filePath, line);
316
+ warnOnce("component", tagName, location, `[compat] Unsupported or undeclared component: <${tagName}>${location}`);
317
+ }
318
+ function checkTemplateCompatibility(content, filePath, components = {}) {
319
+ let parser;
320
+ parser = new Parser({
321
+ onopentag(tagName, attrs) {
322
+ const line = getLineByIndex(content, parser.startIndex);
323
+ for (const attributeName of Object.keys(attrs)) {
324
+ const invalidPrefix = getInvalidAttributePrefix(attributeName);
325
+ if (invalidPrefix) {
326
+ const location = formatLocation(filePath, line);
327
+ warnOnce("template-prefix", attributeName, location, `[compat] Invalid template attribute prefix: ${invalidPrefix}: (${attributeName})${location}`);
328
+ }
329
+ }
330
+ if (components?.[tagName]) return;
331
+ warnUnsupportedComponent(tagName, filePath, line);
332
+ },
333
+ onerror(error) {
334
+ warnOnce("parse", filePath, error.message, `[compat] Failed to parse template for compatibility diagnostics: ${filePath} ${error.message}`);
335
+ }
336
+ }, {
337
+ xmlMode: true,
338
+ lowerCaseTags: false,
339
+ lowerCaseAttributeNames: false,
340
+ withStartIndices: true
341
+ });
342
+ parser.write(content);
343
+ parser.end();
344
+ }
345
+ function getLineByIndex(content, index) {
346
+ if (typeof index !== "number" || index < 0) return null;
347
+ let line = 1;
348
+ for (let i = 0; i < index; i++) if (content.charCodeAt(i) === 10) line++;
349
+ return line;
350
+ }
351
+ function formatLocation(filePath, line) {
352
+ if (!filePath) return "";
353
+ return line ? ` (${filePath}:${line})` : ` (${filePath})`;
354
+ }
355
+ function warnOnce(type, name, location, message) {
356
+ const key = `${type}:${name}:${location}`;
357
+ if (warnedItems.has(key)) return;
358
+ warnedItems.add(key);
359
+ if (isMainThread) console.warn(message);
360
+ else pendingWarnings.push(message);
361
+ }
362
+ function takeCompatibilityWarnings() {
363
+ return pendingWarnings.splice(0);
364
+ }
365
+ //#endregion
366
+ export { warnUnsupportedWxApi as a, takeCompatibilityWarnings as i, getTemplateDirectiveName as n, getWxMemberName as r, checkTemplateCompatibility as t };