delete h2sa vs plugin src

Signed-off-by: gou-jingjing <goujingjing@kaihong.com>
This commit is contained in:
gou-jingjing 2024-10-21 19:59:44 +08:00
parent f624173f37
commit aadbc1c4b2
13 changed files with 0 additions and 1112 deletions

View File

@ -1,201 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,23 +0,0 @@
# Service生成工具使用说明
## 简介
Service代码生成工具它可以能够帮助使用者生成IPC通信框架代码提升开发效率。
## 约束
visual studio code 版本需1.62.0及以上。
## 操作简介
1.安装VS Code插件。
2.打开任意文件夹或文件鼠标单击右键选择“Generate Service Frame”插件。
3.在窗口中填写相应参数。
详细说明见[工具使用说明](https://gitee.com/openharmony/napi_generator/blob/master/hdc/service/service_vs_plugin/docs/INSTRUCTION_ZH.md)
## 合作共建
[联系方式](https://www.kaihong.com/)

View File

@ -1,263 +0,0 @@
/*
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
const vscode = require('vscode');
const fs = require('fs');
const re = require('./gen/tools/VsPluginRe');
const { VsPluginLog } = require('./gen/tools/VsPluginLog');
const { detectPlatform, readFile } = require('./gen/tools/VsPluginTool');
const path = require('path');
let exeFilePath = null;
let globalPanel = null;
let importToolChain = false;
let extensionIds = [];
let nextPluginId = null;
// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
/**
* @param {vscode.ExtensionContext} context
*/
function activate(context) {
// Use the console to output diagnostic information (console.log) and errors (console.error)
// This line of code will only be executed once when your extension is activated
console.log('Congratulations, your extension "service-gen" is now active!');
let disposable = register(context, 'generate_service');
let disposableMenu = register(context, 'generate_service_menu');
context.subscriptions.push(disposable);
context.subscriptions.push(disposableMenu);
let platform = detectPlatform();
if (platform === 'win') {
exeFilePath = __dirname + '/service-gen-win.exe';
} else if (platform === 'mac') {
exeFilePath = __dirname + '/service-gen-macos';
} else if (platform === 'Linux') {
exeFilePath = __dirname + '/service-gen-linux';
}
vscode.window.onDidChangeActiveColorTheme(colorTheme => {
let result = {
msg: 'colorThemeChanged'
};
globalPanel.webview.postMessage(result);
});
}
function executorService(name, genDir, serviceId) {
let command = exeFilePath + ' -f ' + name + ' -o ' + genDir + ' -s ' + serviceId;
let exec = require('child_process').exec;
exec(command, function (error, stdout, stderr) {
VsPluginLog.logInfo('VsPlugin: stdout =' + stdout + ', stderr =' + stderr);
if (error || stdout.indexOf('success') < 0) {
vscode.window.showErrorMessage('genError:' + ((error !== null && error !== undefined) ?
error : '') + stdout);
return VsPluginLog.logError('VsPlugin:' + error + stdout);
}
return vscode.window.showInformationMessage('Generated successfully');
});
}
function exeFileExit() {
if (fs.existsSync(exeFilePath)) {
return true;
}
return false;
}
function register(context, command) {
let disposable = vscode.commands.registerCommand(command, function (uri, boolValue, items) {
// The code you place here will be executed every time your command is executed
// Display a message box to the user
globalPanel = vscode.window.createWebviewPanel(
'generate', // Identifies the type of WebView
'Service Generate Frame', // Title of the panel displayed to the user
vscode.ViewColumn.Two, // Display the WebView panel in the form of new columns in the editor
{
enableScripts: true, // Enable or disable JS, default is Enable
retainContextWhenHidden: true, // Keep the WebView state when it is hidden to avoid being reset
}
);
checkBoolval(boolValue, items);
globalPanel.webview.html = getWebviewContent(context, importToolChain);
let msg;
globalPanel.webview.onDidReceiveMessage(message => {
msg = message.msg;
if (msg === 'cancel') {
globalPanel.dispose();
} else if (msg === 'param') {
checkReceiveMsg(message);
} else {
selectPath(globalPanel, message);
}
}, undefined, context.subscriptions);
// 路径有效性判断
if (uri.fsPath !== undefined) {
let fn = re.getFileInPath(uri.fsPath);
let tt = re.match('([a-zA-Z_0-9]+.h)', fn);
let result = {
msg: 'selectHFilePath',
path: tt ? uri.fsPath : ''
};
globalPanel.webview.postMessage(result);
}
});
return disposable;
}
function checkBoolval(boolValue, items) {
if (typeof (boolValue) === 'boolean' && Array.isArray(items)) {
if (boolValue === true) {
//遍历数组item,查看当前插件id是数组的第几个元素并拿出下一个元素并判断当前id是否是最后一个元素并做相应处理
getNextPlugin(items, boolValue);
}
}
}
function getNextPlugin(items, boolValue) {
let myExtensionId = 'kaihong.service-gen';
for (let i = 0; i < items.length; i++) {
if (myExtensionId === items[i] && (i === items.length - 1)) {
importToolChain = false;
} else if (myExtensionId === items[i] && (i !== items.length - 1)) {
importToolChain = boolValue;
nextPluginId = items[i + 1];
}
extensionIds.push(items[i]);
}
}
function checkReceiveMsg(message) {
let name = message.fileNames;
let genDir = message.genDir;
let serviceId = message.serviceId;
let buttonName = message.buttonName;
name = re.replaceAll(name, ' ', '');
if ('' === name) {
vscode.window.showErrorMessage('Please enter the path!');
return;
}
if (exeFileExit()) {
executorService(name, genDir, serviceId);
if (buttonName === 'Next') {
startNextPlugin();
}
} else {
vscode.window.showInformationMessage('Copy executable program to ' + __dirname);
}
}
/**
* 获取插件执行命令
*/
function nextPluginExeCommand(nextPluginId) {
if (nextPluginId === 'kaihong.ApiScan') {
return 'api_scan';
} else if (nextPluginId === 'kaihong.gn-gen') {
return 'generate_gn';
} else if (nextPluginId === 'kaihong.service-gen') {
return 'generate_service';
} else if (nextPluginId === 'kaihong.ts-gen') {
return 'generate_ts';
} else if (nextPluginId === 'kaihong.napi-gen') {
return 'generate_napi';
} else {
return null;
}
}
/**
* 执行完毕后开启工具链中下一个插件
*/
function startNextPlugin() {
const extension = vscode.extensions.getExtension(nextPluginId);
if (extension) {
let startNextPlugin = nextPluginExeCommand(nextPluginId);
try {
vscode.commands.executeCommand(startNextPlugin, '', importToolChain, extensionIds);
} catch (error) {
console.error(error);
}
}
}
/**
* 选择本地目录/文件夹
*/
function selectPath(panel, message) {
let mode = 1;
if (message.mode !== undefined && message.mode !== null) {
mode = message.mode;
}
const options = {
canSelectFiles: mode === 0 ? true : false, //是否选择文件
canSelectFolders: mode === 0 ? false : true, //是否选择文件夹
defaultUri: vscode.Uri.file(message.filePath), //默认打开本地路径
filters: mode === 0 ? {
'All files': ['h']
} : {}
};
return vscode.window.showOpenDialog(options).then(fileUri => {
if (fileUri && fileUri[0]) {
console.log('Selected file: ' + fileUri[0].fsPath);
let filePath = '';
for (let index = 0; index < fileUri.length; index++) {
filePath += fileUri[index].fsPath.concat(',');
}
let result = {
msg: message.msg,
path: filePath.length > 0 ? filePath.substring(0, filePath.length - 1) : filePath
};
panel.webview.postMessage(result);
return fileUri[0].fsPath;
}
return '';
});
}
// this method is called when your extension is deactivated
function deactivate() { }
function getWebviewContent(context, importToolChain) {
let data = readFile(__dirname + '/vs_plugin_view.html');
data = getWebViewContent(context, '/vs_plugin_view.html');
let content = data.toString();
if (importToolChain) {
content = content.replace('Ok', 'Next');
}
return content;
}
function getWebViewContent(context, templatePath) {
const resourcePath = path.join(context.extensionPath, templatePath);
const dirPath = path.dirname(resourcePath);
let html = fs.readFileSync(resourcePath, 'utf-8');
html = html.replace(/(<link.+?href="|<script.+?src="|<iframe.+?src="|<img.+?src=")(.+?)"/g, (m, $1, $2) => {
if ($2.indexOf('https://') < 0) {
return $1 + globalPanel.webview.asWebviewUri(vscode.Uri.file(path.resolve(dirPath, $2))) + '"';
} else {
return $1 + $2 + '"';
}
});
return html;
}
module.exports = {
activate,
deactivate
};

View File

@ -1,80 +0,0 @@
/*
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const fs = require('fs');
class VsPluginLog {
constructor() {
}
}
VsPluginLog.LEV_NONE = 0;
VsPluginLog.LEV_ERROR = 1;
VsPluginLog.LEV_DEBUG = 2;
VsPluginLog.LEV_INFO = 3;
const LEV_STR = ['[NON]', '[ERR]', '[DBG]', '[INF]'];
var logLevel = VsPluginLog.LEV_ERROR;
var logFileName = null;
var logResultMessage = [true, ''];
function getDateString() {
let nowDate = new Date();
return nowDate.toLocaleString();
}
function saveLog(dateStr, levStr, detail) {
if (logFileName) {
let logStr = dateStr + ' ' + levStr + ' ' + detail + '\n';
fs.appendFileSync(logFileName, logStr);
}
}
VsPluginLog.init = function (level, fileName) {
logLevel = level in [VsPluginLog.LEV_NONE, VsPluginLog.LEV_ERROR, VsPluginLog.LEV_DEBUG, VsPluginLog.LEV_INFO]
? level : VsPluginLog.LEV_ERROR;
logFileName = fileName ? fileName : 'napi_generator.log';
};
function recordLog(lev, ...args) {
let dataStr = getDateString();
let detail = args.join(' ');
saveLog(dataStr, LEV_STR[lev], detail);
if (lev === VsPluginLog.LEV_ERROR) {
logResultMessage = [false, detail];
}
if (logLevel < lev) {
return;
}
VsPluginLog.logInfo(dataStr + LEV_STR[lev] + detail);
}
VsPluginLog.logError = function (...args) {
recordLog(VsPluginLog.LEV_ERROR, args);
};
VsPluginLog.logDebug = function (...args) {
recordLog(VsPluginLog.LEV_DEBUG, args);
};
VsPluginLog.logInfo = function (...args) {
recordLog(VsPluginLog.LEV_INFO, args);
};
VsPluginLog.getResult = function () {
return logResultMessage;
};
module.exports = {
VsPluginLog
};

View File

@ -1,69 +0,0 @@
/*
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const path = require('path');
function search(ss, data) {
ss = replaceAll(ss, '\\.', '\\.');
let reg = new RegExp(ss);
let tt = reg.exec(data);
if (tt === null || tt === undefined) {
return null;
}
let ret = { 'regs': [] };
for (let i = 0; i < tt.length; i++) {
let p = data.indexOf(tt[i]);
if (tt[i] === null || tt[i] === undefined) {
ret.regs.push([-1, -1]);
}
else {
ret.regs.push([p, p + tt[i].length]);
}
}
return ret;
}
function match(ss, data) {
let tt = search(ss, data);
if (tt !== null && tt.regs[0][0] === 0) {
return tt;
}
return null;
}
function getFileInPath(tpath) {
return path.parse(tpath).base;
}
function getPathInPath(tpath) {
return path.parse(tpath).dir;
}
function all(sfrom) {
return new RegExp(sfrom, 'g');
}
function replaceAll(ss, sfrom, sto) {
return ss.replace(all(sfrom), sto);
}
module.exports = {
search,
match,
getFileInPath,
getPathInPath,
replaceAll,
all
};

View File

@ -1,118 +0,0 @@
/*
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const os = require('os');
const tsc = require('../../node_modules/typescript');
const fs = require('fs');
let vscode = null;
try {
vscode = require('vscode');
}
catch (err) {
vscode = null;
}
function replaceAll(s, sfrom, sto) {
while (s.indexOf(sfrom) >= 0) {
s = s.replace(sfrom, sto);
}
return s;
}
function detectPlatform() {
let result = '';
if (os.type() === 'Windows_NT') {
result = 'win';
} else if (os.type() === 'Darwin') {
result = 'mac';
} else if (os.type() === 'Linux') {
result = 'Linux';
}
return result;
}
function checkFileError(ifname) {
let program = tsc.createProgram([ifname], {});
let emitResult = program.emit();
let allDiagnostics = tsc.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
let errorMsg = '';
allDiagnostics.forEach(diagnostic => {
if (diagnostic.file) {
let { line, character } = tsc.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
let message = tsc.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
errorMsg += `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}\n`;
} else {
errorMsg += tsc.flattenDiagnosticMessageText(diagnostic.messageText, '\n') + '\n';
}
});
if (allDiagnostics.length > 0) {
return [false, errorMsg];
}
return [true, ''];
}
function utf8ArrayToStr(array) {
var res, i, length, ch;
var ch2, ch3;
res = '';
length = array.length;
i = 0;
while (i < length) {
ch = array[i++];
let c = ch >> 4;
switch (c) {
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
// 0xxxxxxx
res += String.fromCharCode(ch);
break;
case 12: case 13:
// 110x xxxx 10xx xxxx
ch2 = array[i++];
let tmp = (ch & 0x1F) << 6;
let tmp2 = ch2 & 0x3F;
res += String.fromCharCode(tmp | tmp2);
break;
case 14:
// 1110 xxxx 10xx xxxx 10xx xxxx
ch2 = array[i++];
ch3 = array[i++];
let tmp3 = (ch & 0x0F) << 12;
let tmp4 = (ch2 & 0x3F) << 6;
let tmp5 = (ch3 & 0x3F) << 0;
res += String.fromCharCode(tmp3 | tmp4 | tmp5);
break;
}
}
return res;
}
function readFile(fn) {
if (!fs.existsSync(fn)) {
return '';
}
let data = fs.readFileSync(fn);
data = utf8ArrayToStr(data);
return data;
}
module.exports = {
replaceAll,
detectPlatform,
checkFileError,
readFile
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 608 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

View File

@ -1,13 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "ES2020",
"checkJs": true, /* Typecheck .js files. */
"lib": [
"ES2020"
]
},
"exclude": [
"node_modules"
]
}

View File

@ -1,75 +0,0 @@
{
"name": "service-gen",
"displayName": "service-gen",
"description": "Generate IPC service framework code for OpenHarmony",
"version": "0.0.1",
"keywords": [
"service",
"service-gen"
],
"icon": "images/service.png",
"engines": {
"vscode": "^1.62.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onStartupFinished"
],
"main": "./extension.js",
"publisher": "kaihong",
"contributes": {
"commands": [
{
"command": "generate_service",
"title": "Service Generate Frame"
},
{
"command": "generate_service_menu",
"title": "Service Generate Frame"
}
],
"menus": {
"explorer/context": [
{
"when": "resourceExtname == .h",
"command": "generate_service"
}
],
"editor/context": [
{
"command": "generate_service_menu"
}
]
}
},
"scripts": {
"lint": "eslint .",
"pretest": "npm run lint",
"test": "node ./test/runTest.js"
},
"devDependencies": {
"@types/glob": "^7.1.4",
"@types/mocha": "^9.0.0",
"@types/node": "14.x",
"@types/vscode": "^1.62.0",
"@vscode/test-electron": "^1.6.2",
"eslint": "^8.1.0",
"glob": "^7.1.7",
"mocha": "^9.1.3",
"webpack": "^5.64.4",
"webpack-cli": "^4.9.1"
},
"dependencies": {
"compressing": "^1.5.1",
"node-gyp": "^9.0.0",
"stdio": "^2.1.1",
"typescript": "^4.8.4",
"vsce": "^2.11.0"
},
"repository": {
"type": "gitee",
"url": "https://gitee.com/openharmony/napi_generator/tree/master/hdc/service"
}
}

View File

@ -1,270 +0,0 @@
<!DOCTYPE html>
<html lang="en" style="width: 100%; height: 100%;">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Napi</title>
</head>
<style type="text/css">
body {
background-color: var(--vscode-editor-background, #000000);
margin:0 auto;
font-family: "Microsoft YaHei";
opacity: 0.9;
}
a {
text-decoration: none;
}
button.button {
background-color: #ffffff;
font-family: Consolas, sans-serif;
font-size: 16px;
border-radius: 3px;
border-color: #C4C4C4;
align-self: center;
border: 1px solid #C4C4C4;
outline: none;
width: 100px;
height:24px
}
input.text {
width: 250px;
vertical-align:middle;
background-color: var(--vscode-editor-background, #000000);
color: var(--vscode-editor-foreground, #ffffff);
border-radius: 6px;
border: 1px solid #555555;
opacity: 0.9;
height: 24px;
}
input.text:hover {
outline: none;
border-color: var(--vscode-focusBorder, #272727);
}
.tabs{
position: relative;
height: 800px;
min-height: 800px;
max-height: 800px;
clear: both;
margin: 25px 0;
overflow: hidden;
}
.tab{
float: left;
margin: 25px 0;
}
.tab label{
background: #eee;
padding: 10px 20px;
position: relative;
left: 1px;
border: 0px solid;
margin-left: -1px;
z-index: 2;
color: #333333;
background: white;
}
[type=radio]:checked ~ label{
color: white;
background: #3288e9;
border: 0px solid #ccc;
z-index: 3;
}
[type=radio]:checked ~ label ~ .content{
z-index: 1;
}
</style>
<script type="text/javascript">
var mode = 0;
let vscode = acquireVsCodeApi();
function sendParamMsg() {
var fileNames = document.getElementById('hFilePath').value;
var genDir = document.getElementById('genHResultDir').value;
var serviceId = document.getElementById('serviceID').value;
var buttonName = document.getElementById('okButton').textContent;
var result = {
msg: 'param',
fileNames: fileNames,
genDir: genDir,
serviceId: serviceId,
buttonName: buttonName,
};
vscode.postMessage(result);
}
function selectHFilePath() {
var fileNames = document.getElementById('hFilePath').value;
var result = {
msg: 'selectHFilePath',
mode: mode,
filePath: fileNames
};
vscode.postMessage(result);
}
function selectPath(message) {
var genDir = document.getElementById('genHResultDir').value;
var result = {
msg: message,
filePath: genDir
};
vscode.postMessage(result);
}
function cancel() {
var result = {
msg: 'cancel'
};
vscode.postMessage(result);
}
window.addEventListener('message', event => {
const message = event.data.msg;
const path = event.data.path;
if (message === 'selectHFilePath') {
document.getElementById('hFilePath').value = path;
fillInputDir(path);
} else if (message === 'selectHResultDir') {
document.getElementById('genHResultDir').value = path;
} else if (message === 'colorThemeChanged') {
reloadFileImgPic();
}
else {
console.log('param is error');
}
});
function inputChange() {
var fileNames = document.getElementById('hFilePath').value; //interfaceFile
fillInputDir(fileNames);
}
function fillInputDir(fileNames) {
var dir;
var fileName;
if (mode === 0) {
if (fileNames.indexOf(',') !== -1) {
fileName = fileNames.substring(0, fileNames.indexOf(','));
} else {
fileName = fileNames;
}
if (fileName.lastIndexOf('/') !== -1) {
dir = fileName.substring(0, fileName.lastIndexOf('/'));
} else {
dir = fileName.substring(0, fileName.lastIndexOf('\\'));
}
}
else {
dir = fileNames;
}
document.getElementById('genHResultDir').value = dir;
}
function onInput(event) {
var value = event.target.value;
checkServiceId(value);
}
function checkServiceId(value) {
if (value < 1 || value > 16777215) {
document.getElementById('error').style.display = '';
document.getElementById('error').innerHTML = 'serviceID范围错误, 请输入0-16777215之间的数字';
} else {
document.getElementById('error').style.display = 'none';
document.getElementById('error').innerHTML = '';
}
}
function isDarkColor(colorArr) {
let grayLevel = colorArr[0] * 0.299 + colorArr[1] * 0.587 + colorArr[2] * 0.114;
return grayLevel < 192;
}
function reloadFileImgPic() {
var bodyobj = document.getElementsByTagName('body')[0];
var bgStyle = document.defaultView.getComputedStyle(bodyobj, null);
var bgColor = bgStyle.getPropertyValue('background-color').match(/\d{1,3}/g);
var isDarkBackground = true;
if (bgColor) {
isDarkBackground = isDarkColor(bgColor);
}
var fileImgPng = isDarkBackground ? 'file.png' : 'file_black.png';
var currentFileImgPath = document.getElementById('hFilePathImg').src;
var fileImgPath = currentFileImgPath.substr(0, currentFileImgPath.lastIndexOf('/') + 1);
fileImgPath += fileImgPng;
document.getElementById('hFilePathImg').src = fileImgPath;
document.getElementById('genHResultDirImg').src = fileImgPath;
}
</script>
<body>
<div class="tabs">
<div class="tab">
<input type="radio" style="display: none;" id="tab2" name="group-1">
<label for="tab2">Gen-Service</label>
<div class="content">
<table style="border-spacing:0px 5px; margin-left: 20px; margin-top: 38px; width: 500px;">
<tr>
<td width="110px">.h文件选择*:</td>
<td width="340px">
<input class="text" type="text" id="hFilePath" onchange="inputChange()" onporpertychange="inputChange() ">
<img id="hFilePathImg" src="./images/file.png" width="20px" height="20px" style="vertical-align:middle;"
onclick="selectHFilePath()">
</td>
</tr>
<tr>
<td>输出路径选择:</td>
<td>
<input class="text" accept="text" id="genHResultDir">
<img id="genHResultDirImg" src="./images/path.png" width="20px" height="20px" style="vertical-align:middle;"
onclick="selectPath('selectHResultDir')">
</td>
</tr>
<tr>
<td>serviceID:</td>
<td>
<input class="text" type="number" id="serviceID" placeholder="1-16777215" oninput="onInput(event)" onpropertychange="onInput(event)"/>
<a href="" target="_blank" title="Please refer to system_ability_definition.h&#10;(OpenHarmony source code),&#10;and do not use the occupied serviceID.">
<button type="button" style="background-color: #333333; width: 20px; height: 20px; border-radius: 50%;border: none; color: #fff;">?</button>
</a>
</td>
</tr>
<tr>
<td></td>
<td>
<span id="error" style="color:red; display: none; background-color: transparent;"></span>
</td>
</tr>
<tr>
<td colspan="2">
<button type="button" class="button" onclick="cancel()"
style="background-color: #333333; border: 1px solid #333333; color: #fff;">Cancel</button>
<button id="okButton" type="button" class="button" onclick="sendParamMsg()"
style="background-color: #4B97D9; border: 1px solid #4B97D9; color: #fff;">Ok</button>
<a href="https://gitee.com/openharmony/napi_generator" target="_blank">
<button type="button"
style="background-color: #333333; width: 20px; height: 20px; border-radius: 50%;border: none; color: #fff;">?</button>
</a>
</td>
</tr>
</table>
</div>
</div>
</div>
</body>
</html>
<script>
reloadFileImgPic();
</script>