typenative 0.4.1 → 0.6.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/.github/workflows/ci.yml +2 -2
- package/.github/workflows/npm-publish-github-packages.yml +2 -2
- package/CHANGELOG.md +442 -1
- package/CONTRIBUTION.md +2 -1
- package/README.md +73 -25
- package/bin/cli.js +2 -0
- package/bin/index.js +75 -5
- package/bin/main.js +2 -0
- package/bin/node/assert.js +2 -2
- package/bin/node/async_hooks.js +1 -1
- package/bin/node/buffer.js +16 -5
- package/bin/node/child_process.js +7 -7
- package/bin/node/cluster.js +3 -3
- package/bin/node/core.js +41 -0
- package/bin/node/crypto_keys.js +21 -21
- package/bin/node/dgram.js +1 -1
- package/bin/node/diagnostics_channel.js +3 -3
- package/bin/node/dns.js +2 -2
- package/bin/node/events.js +18 -13
- package/bin/node/fetch.js +2 -2
- package/bin/node/fs.js +3 -3
- package/bin/node/fs_watch.js +5 -5
- package/bin/node/http.js +3 -3
- package/bin/node/http2.js +3 -3
- package/bin/node/net.js +8 -8
- package/bin/node/path.js +17 -3
- package/bin/node/process.js +47 -11
- package/bin/node/punycode.js +2 -2
- package/bin/node/readline.js +1 -1
- package/bin/node/registry.js +4 -1
- package/bin/node/sqlite.js +6 -6
- package/bin/node/stream.js +81 -15
- package/bin/node/stream_web.js +10 -10
- package/bin/node/system_extra.js +3 -3
- package/bin/node/test.js +674 -366
- package/bin/node/test_coverage.js +187 -0
- package/bin/node/test_report.js +1392 -0
- package/bin/node/test_run.js +575 -0
- package/bin/node/timers.js +8 -6
- package/bin/node/tls.js +5 -5
- package/bin/node/url.js +1 -1
- package/bin/node/util.js +31 -7
- package/bin/node/util_extra.js +7 -7
- package/bin/node/webview.js +654 -0
- package/bin/node/worker_threads.js +1 -1
- package/bin/node/zlib.js +3 -3
- package/bin/parse-node.js +6 -2
- package/bin/regex_vm.js +2057 -0
- package/bin/transpiler.js +32872 -11265
- package/bin/typecheck-node.js +2 -1
- package/bin/version.js +1 -1
- package/conformance.md +515 -345
- package/examples/README.md +71 -11
- package/examples/angular-templates/README.md +139 -0
- package/examples/angular-templates/bench.mjs +173 -0
- package/examples/angular-templates/dom-type-globals.d.ts +21 -0
- package/examples/angular-templates/dom-type-stubs.ts +21 -0
- package/examples/angular-templates/main.ts +135 -0
- package/examples/angular-templates/parity.mjs +157 -0
- package/examples/angular-templates/run-node.mjs +69 -0
- package/examples/angular-templates/vendor/angular/compiler/LICENSE +21 -0
- package/examples/desktop-notes/README.md +106 -0
- package/examples/desktop-notes/bench.mjs +125 -0
- package/examples/desktop-notes/main.ts +131 -0
- package/examples/desktop-notes/package-lock.json +726 -0
- package/examples/desktop-notes/package.json +9 -0
- package/examples/desktop-notes/ui.ts +176 -0
- package/examples/dupe-finder/README.md +78 -0
- package/examples/dupe-finder/bench.mjs +120 -0
- package/examples/dupe-finder/main.ts +87 -0
- package/examples/fibonacci/README.md +7 -7
- package/examples/hello-world/README.md +6 -6
- package/examples/json-server/README.md +19 -18
- package/examples/mandelbrot-png/README.md +63 -0
- package/examples/mandelbrot-png/bench.mjs +95 -0
- package/examples/mandelbrot-png/main.ts +98 -0
- package/examples/mandelbrot-png/preview.png +0 -0
- package/examples/marked-cli/README.md +160 -0
- package/examples/marked-cli/bench.mjs +178 -0
- package/examples/marked-cli/main.ts +292 -0
- package/examples/marked-cli/parity.mjs +185 -0
- package/examples/marked-cli/vendor/marked/LICENSE +44 -0
- package/examples/marked-cli/vendor/marked/VENDOR.md +26 -0
- package/examples/openai-chat/README.md +148 -0
- package/examples/openai-chat/bench.mjs +175 -0
- package/examples/openai-chat/main.ts +488 -0
- package/examples/react-compiler/README.md +170 -0
- package/examples/react-compiler/bench.mjs +181 -0
- package/examples/react-compiler/main.ts +158 -0
- package/examples/react-compiler/parity.mjs +362 -0
- package/examples/react-compiler/run-node.mjs +88 -0
- package/examples/react-compiler/vendor/babel/LICENSE +22 -0
- package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-lower.json +15 -0
- package/examples/react-compiler/vendor/babel/helper-globals/data/builtin-upper.json +51 -0
- package/examples/react-compiler/vendor/charcodes/package.json +25 -0
- package/examples/react-compiler/vendor/invariant/LICENSE +21 -0
- package/examples/react-compiler/vendor/invariant/invariant.cjs +51 -0
- package/examples/react-compiler/vendor/invariant/invariant.d.cts +11 -0
- package/examples/react-compiler/vendor/invariant/types/LICENSE +21 -0
- package/examples/react-compiler/vendor/jridgewell/gen-mapping/LICENSE +19 -0
- package/examples/react-compiler/vendor/jridgewell/resolve-uri/LICENSE +19 -0
- package/examples/react-compiler/vendor/jridgewell/sourcemap-codec/LICENSE +19 -0
- package/examples/react-compiler/vendor/jridgewell/trace-mapping/LICENSE +19 -0
- package/examples/react-compiler/vendor/js-tokens/LICENSE +21 -0
- package/examples/react-compiler/vendor/js-tokens/index.cjs +23 -0
- package/examples/react-compiler/vendor/js-tokens/index.d.cts +13 -0
- package/examples/react-compiler/vendor/jsesc/LICENSE-MIT.txt +20 -0
- package/examples/react-compiler/vendor/jsesc/jsesc.cjs +337 -0
- package/examples/react-compiler/vendor/jsesc/jsesc.d.cts +384 -0
- package/examples/react-compiler/vendor/jsesc/types/LICENSE +21 -0
- package/examples/react-compiler/vendor/picocolors/LICENSE +15 -0
- package/examples/react-compiler/vendor/picocolors/picocolors.cjs +75 -0
- package/examples/react-compiler/vendor/picocolors/picocolors.d.cts +5 -0
- package/examples/react-compiler/vendor/picocolors/types.d.ts +51 -0
- package/examples/react-compiler/vendor/react-compiler/LICENSE +21 -0
- package/examples/react-compiler/vendor/stubs/babel-core.ts +31 -0
- package/examples/react-compiler/vendor/stubs/debug.ts +18 -0
- package/examples/react-compiler/vendor/stubs/js-tokens.d.ts +13 -0
- package/examples/react-compiler/vendor/stubs/pretty-format.ts +18 -0
- package/examples/react-compiler/vendor/zod/LICENSE +21 -0
- package/examples/react-compiler/vendor/zod-validation-error/LICENSE +9 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/NonEmptyArray.ts +5 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinPath.ts +49 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/joinValues.ts +48 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/stringify.ts +50 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/utils/titleCase.ts +6 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/MessageBuilder.ts +126 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/ValidationError.ts +39 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/custom.ts +12 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/errorMap.ts +78 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/index.ts +2 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidElement.ts +12 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidKey.ts +12 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidStringFormat.ts +131 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidType.ts +54 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidUnion.ts +12 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/invalidValue.ts +40 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/notMultipleOf.ts +12 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooBig.ts +76 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/tooSmall.ts +76 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/types.ts +27 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/errorMap/unrecognizedKeys.ts +27 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromError.ts +13 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodError.ts +61 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/fromZodIssue.ts +38 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/index.ts +20 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationError.ts +5 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isValidationErrorLike.ts +8 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/isZodErrorLike.ts +11 -0
- package/examples/react-compiler/vendor/zod-validation-error/lib/v4/toValidationError.ts +20 -0
- package/examples/react-compiler/vendor.mjs +688 -0
- package/examples/todo-cli/README.md +69 -0
- package/examples/todo-cli/bench.mjs +89 -0
- package/examples/todo-cli/main.ts +92 -0
- package/examples/yaml-cli/README.md +146 -0
- package/examples/yaml-cli/bench.mjs +265 -0
- package/examples/yaml-cli/main.ts +29 -0
- package/examples/yaml-cli/parity.mjs +156 -0
- package/examples/yaml-cli/vendor/yaml/LICENSE +13 -0
- package/examples/yaml-cli/vendor/yaml/VENDOR.md +25 -0
- package/govendor/github.com/jchv/go-webview2/LICENSE +22 -0
- package/govendor/github.com/jchv/go-webview2/README.md +21 -0
- package/govendor/github.com/jchv/go-webview2/common.go +84 -0
- package/govendor/github.com/jchv/go-webview2/go.mod +3 -0
- package/govendor/github.com/jchv/go-webview2/internal/w32/w32.go +194 -0
- package/govendor/github.com/jchv/go-webview2/internal/w32/w32_386.go +14 -0
- package/govendor/github.com/jchv/go-webview2/internal/w32/w32_64bit.go +15 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_COLOR.go +8 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_HOST_RESOURCE_ACCESS_KIND.go +9 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_KEY_EVENT_KIND.go +10 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_MOVE_FOCUS_REASON.go +9 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_PHYSICAL_KEY_STATUS.go +10 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/COREWEBVIEW2_WEB_RESOURCE_CONTEXT.go +23 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2AcceleratorKeyPressedEventArgs.go +78 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2AcceleratorKeyPressedEventHandler.go +52 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2Controller.go +132 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2Controller2.go +74 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2CreateCoreWebView2ControllerCompletedHandler.go +48 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2NavigationCompletedEventArgs.go +17 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2NavigationCompletedEventHandler.go +48 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2Settings.go +270 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2WebResourceRequest.go +43 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2WebResourceRequestedEventArgs.go +51 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2WebResourceRequestedEventHandler.go +48 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2WebResourceResponse.go +21 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2_2.go +21 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebView2_3.go +60 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/ICoreWebViewSettings.go +396 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/chromium.go +361 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/chromium_386.go +24 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/chromium_amd64.go +22 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/chromium_arm64.go +26 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/comproc.go +13 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/comproc_go17.go +51 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/comproc_go18.go +16 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/corewebview2.go +411 -0
- package/govendor/github.com/jchv/go-webview2/pkg/edge/guid.go +223 -0
- package/govendor/github.com/jchv/go-webview2/webview.go +482 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/README.md +3 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/module.go +153 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/module_386.go +6 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/module_amd64.go +6 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/module_arm64.go +6 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/sdk/arm64/WebView2Loader.dll +0 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/sdk/x64/WebView2Loader.dll +0 -0
- package/govendor/github.com/jchv/go-webview2/webviewloader/sdk/x86/WebView2Loader.dll +0 -0
- package/govendor/github.com/jchv/go-winloader/LICENSE.md +7 -0
- package/govendor/github.com/jchv/go-winloader/README.md +124 -0
- package/govendor/github.com/jchv/go-winloader/common.go +11 -0
- package/govendor/github.com/jchv/go-winloader/go.mod +3 -0
- package/govendor/github.com/jchv/go-winloader/internal/loader/loader.go +25 -0
- package/govendor/github.com/jchv/go-winloader/internal/loader/machine.go +53 -0
- package/govendor/github.com/jchv/go-winloader/internal/memloader/cache.go +42 -0
- package/govendor/github.com/jchv/go-winloader/internal/memloader/loader.go +253 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/export.go +76 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/format.go +522 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/import.go +106 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/module.go +91 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/reloc.go +177 -0
- package/govendor/github.com/jchv/go-winloader/internal/pe/util.go +40 -0
- package/govendor/github.com/jchv/go-winloader/internal/vmem/common.go +55 -0
- package/govendor/github.com/jchv/go-winloader/internal/vmem/memory_other.go +71 -0
- package/govendor/github.com/jchv/go-winloader/internal/vmem/memory_windows.go +179 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/hacks_other.go +17 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/hacks_windows.go +73 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/loader_windows.go +64 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/machine_windows.go +32 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/nativearch_386.go +9 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/nativearch_amd64.go +9 -0
- package/govendor/github.com/jchv/go-winloader/internal/winloader/nativearch_arm64.go +9 -0
- package/govendor/github.com/jchv/go-winloader/loader_other.go +24 -0
- package/govendor/github.com/jchv/go-winloader/loader_windows.go +33 -0
- package/govendor/manifest.txt +3 -1
- package/package.json +8 -5
- package/performance/README.md +195 -0
- package/performance/any-dynamic.ts +21 -0
- package/performance/any-record-view.ts +20 -0
- package/performance/arr-hof.ts +21 -0
- package/performance/arr-push-index.ts +15 -0
- package/performance/arr-sort.ts +21 -0
- package/performance/async-await.ts +24 -0
- package/performance/class-dispatch.ts +52 -0
- package/performance/events-emit.ts +27 -0
- package/performance/exc-throw-rare.ts +25 -0
- package/performance/exc-try-catch.ts +26 -0
- package/performance/fn-closures.ts +29 -0
- package/performance/fn-recursion-tree.ts +31 -0
- package/performance/gen-for-of.ts +46 -0
- package/performance/json-roundtrip.ts +27 -0
- package/performance/map-delete.ts +24 -0
- package/performance/map-string-keys.ts +22 -0
- package/performance/num-arith-loop.ts +14 -0
- package/performance/num-bitwise.ts +21 -0
- package/performance/num-mod-int.ts +16 -0
- package/performance/num-to-string.ts +16 -0
- package/performance/obj-alloc.ts +32 -0
- package/performance/regex-exec.ts +29 -0
- package/performance/regex-site.ts +28 -0
- package/performance/set-ops.ts +20 -0
- package/performance/str-char-scan.ts +35 -0
- package/performance/str-concat-plus.ts +18 -0
- package/performance/str-concat.ts +24 -0
- package/performance/str-short-scan.ts +26 -0
- package/performance/str-split-join.ts +23 -0
- package/performance/str-template.ts +16 -0
- package/performance/union-switch.ts +57 -0
- package/tsparser/check.go +2 -1
- package/tsparser/main.go +5 -0
- package/types/typenative-npm.d.ts +193 -4
- package/types/typenative.d.ts +138 -41
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// Parity check: Node.js vs the TypeNative build of the yaml CLI.
|
|
2
|
+
//
|
|
3
|
+
// Fetches the yaml-test-suite (tag data-2022-01-17) into .cache/, compiles
|
|
4
|
+
// main.ts to a native binary with the TypeNative CLI from this repo checkout,
|
|
5
|
+
// then feeds every test's in.yaml to both, in each mode: default (re-emit the
|
|
6
|
+
// YAML), --json, valid and lex. stdout, stderr and the exit code must match
|
|
7
|
+
// byte for byte (stack frames aside: see withoutStackFrames). Failures are
|
|
8
|
+
// written to .cache/failures/.
|
|
9
|
+
//
|
|
10
|
+
// Usage: node parity.mjs [filter] (filter: a test id substring or a mode)
|
|
11
|
+
|
|
12
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
13
|
+
import fs from 'node:fs';
|
|
14
|
+
import os from 'node:os';
|
|
15
|
+
import path from 'node:path';
|
|
16
|
+
import { fileURLToPath } from 'node:url';
|
|
17
|
+
|
|
18
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
19
|
+
const repoRoot = path.resolve(here, '..', '..');
|
|
20
|
+
const cli = path.join(repoRoot, 'bin', 'cli.js');
|
|
21
|
+
const cache = path.join(here, '.cache');
|
|
22
|
+
const suite = path.join(cache, 'yaml-test-suite');
|
|
23
|
+
const failuresDir = path.join(cache, 'failures');
|
|
24
|
+
const exePath = path.join(cache, process.platform === 'win32' ? 'yaml.exe' : 'yaml');
|
|
25
|
+
const filter = process.argv[2] ?? '';
|
|
26
|
+
const MODES = [
|
|
27
|
+
{ name: 'default', args: [] },
|
|
28
|
+
{ name: 'json', args: ['--json'] },
|
|
29
|
+
{ name: 'valid', args: ['valid'] },
|
|
30
|
+
{ name: 'lex', args: ['lex'] }
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
function run(command, args, options = {}) {
|
|
34
|
+
const result = spawnSync(command, args, { stdio: 'inherit', ...options });
|
|
35
|
+
if (result.status !== 0) {
|
|
36
|
+
console.error(`${command} ${args.join(' ')} failed`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// The corpus: yaml-test-suite's data branch, one directory per test (some
|
|
42
|
+
// with numbered sub-tests), each with an in.yaml
|
|
43
|
+
function fetchSuite() {
|
|
44
|
+
if (fs.existsSync(path.join(suite, '.git')) || fs.existsSync(path.join(suite, '229Q'))) return;
|
|
45
|
+
fs.mkdirSync(cache, { recursive: true });
|
|
46
|
+
console.log('Fetching yaml-test-suite data-2022-01-17 ...');
|
|
47
|
+
run('git', ['clone', '--quiet', '--depth', '1', '--branch', 'data-2022-01-17', 'https://github.com/yaml/yaml-test-suite.git', suite]);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function listInputs() {
|
|
51
|
+
const inputs = [];
|
|
52
|
+
const walk = (dir, id) => {
|
|
53
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
54
|
+
if (entry.isDirectory() && entry.name !== '.git') walk(path.join(dir, entry.name), id ? `${id}-${entry.name}` : entry.name);
|
|
55
|
+
else if (entry.name === 'in.yaml') inputs.push({ id, file: path.join(dir, entry.name) });
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
walk(suite, '');
|
|
59
|
+
return inputs;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function exec(command, args, input) {
|
|
63
|
+
return new Promise((resolve) => {
|
|
64
|
+
const p = spawn(command, args, { cwd: here, stdio: ['pipe', 'pipe', 'pipe'] });
|
|
65
|
+
const stdout = [];
|
|
66
|
+
const stderr = [];
|
|
67
|
+
p.stdout.on('data', (d) => stdout.push(d));
|
|
68
|
+
p.stderr.on('data', (d) => stderr.push(d));
|
|
69
|
+
const timer = setTimeout(() => p.kill('SIGKILL'), 10000);
|
|
70
|
+
p.on('close', (code, signal) => {
|
|
71
|
+
clearTimeout(timer);
|
|
72
|
+
resolve({ code: signal ? signal : code, stdout: Buffer.concat(stdout), stderr: Buffer.concat(stderr) });
|
|
73
|
+
});
|
|
74
|
+
p.stdin.on('error', () => {});
|
|
75
|
+
p.stdin.end(input);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Node prints an error's stack (" at …" lines, the frames of the JS call
|
|
80
|
+
// stack); a native binary has no JS frames to show. The frames are dropped
|
|
81
|
+
// (an inspected error's own properties, which follow the last frame as " {",
|
|
82
|
+
// stay where they are); warnings' process ids differ too
|
|
83
|
+
function withoutStackFrames(buffer) {
|
|
84
|
+
const out = [];
|
|
85
|
+
for (const line of buffer.toString().split('\n')) {
|
|
86
|
+
if (/^ {4}at /.test(line)) {
|
|
87
|
+
if (line.endsWith(' {')) out[out.length - 1] += ' {';
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
// (and process warnings name the process id)
|
|
91
|
+
out.push(line.replace(/^\(node:\d+\) /, '(node) '));
|
|
92
|
+
}
|
|
93
|
+
return Buffer.from(out.join('\n'));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function sameOutput(a, b) {
|
|
97
|
+
return a.code === b.code && a.stdout.equals(b.stdout) && withoutStackFrames(a.stderr).equals(withoutStackFrames(b.stderr));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function report(failure) {
|
|
101
|
+
const { id, mode, input, node, native } = failure;
|
|
102
|
+
const text = [
|
|
103
|
+
`# ${id} (${mode})`,
|
|
104
|
+
'## input',
|
|
105
|
+
input.toString(),
|
|
106
|
+
`## node (exit ${node.code})`,
|
|
107
|
+
'### stdout', node.stdout.toString(), '### stderr', node.stderr.toString(),
|
|
108
|
+
`## native (exit ${native.code})`,
|
|
109
|
+
'### stdout', native.stdout.toString(), '### stderr', native.stderr.toString()
|
|
110
|
+
].join('\n');
|
|
111
|
+
fs.writeFileSync(path.join(failuresDir, `${id}-${mode}.txt`), text);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
fetchSuite();
|
|
115
|
+
console.log('Compiling main.ts ...');
|
|
116
|
+
run(process.execPath, [cli, '--source', path.join(here, 'main.ts'), '--output', exePath], { cwd: here });
|
|
117
|
+
|
|
118
|
+
const cases = [];
|
|
119
|
+
for (const input of listInputs()) {
|
|
120
|
+
for (const mode of MODES) {
|
|
121
|
+
if (filter && !input.id.includes(filter) && mode.name !== filter) continue;
|
|
122
|
+
cases.push({ ...input, mode });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
fs.rmSync(failuresDir, { recursive: true, force: true });
|
|
126
|
+
fs.mkdirSync(failuresDir, { recursive: true });
|
|
127
|
+
|
|
128
|
+
let next = 0;
|
|
129
|
+
let passed = 0;
|
|
130
|
+
const failed = [];
|
|
131
|
+
async function worker() {
|
|
132
|
+
while (next < cases.length) {
|
|
133
|
+
const c = cases[next++];
|
|
134
|
+
const input = fs.readFileSync(c.file);
|
|
135
|
+
const [node, native] = await Promise.all([
|
|
136
|
+
exec(process.execPath, [path.join(here, 'main.ts'), ...c.mode.args], input),
|
|
137
|
+
exec(exePath, c.mode.args, input)
|
|
138
|
+
]);
|
|
139
|
+
if (sameOutput(node, native)) passed++;
|
|
140
|
+
else {
|
|
141
|
+
failed.push(`${c.id} (${c.mode.name})`);
|
|
142
|
+
report({ id: c.id, mode: c.mode.name, input, node, native });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const workers = Math.max(2, Math.min(16, os.availableParallelism()));
|
|
147
|
+
await Promise.all(Array.from({ length: workers }, () => worker()));
|
|
148
|
+
|
|
149
|
+
const rate = cases.length ? ((100 * passed) / cases.length).toFixed(2) : '100.00';
|
|
150
|
+
console.log(`\n${passed}/${cases.length} cases match (${rate}%)`);
|
|
151
|
+
if (failed.length > 0) {
|
|
152
|
+
console.log(`${failed.length} failures (details in .cache/failures/):`);
|
|
153
|
+
for (const f of failed.slice(0, 40)) console.log(` ${f}`);
|
|
154
|
+
if (failed.length > 40) console.log(` … and ${failed.length - 40} more`);
|
|
155
|
+
process.exitCode = 1;
|
|
156
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright Eemeli Aro <eemeli@gmail.com>
|
|
2
|
+
|
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
4
|
+
with or without fee is hereby granted, provided that the above copyright notice
|
|
5
|
+
and this permission notice appear in all copies.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
9
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
11
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
12
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
13
|
+
THIS SOFTWARE.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Vendored: `yaml`
|
|
2
|
+
|
|
3
|
+
| | |
|
|
4
|
+
| ---------- | ----------------------------------------------------------------------------------- |
|
|
5
|
+
| Upstream | [eemeli/yaml](https://github.com/eemeli/yaml) |
|
|
6
|
+
| Tag | `v3.0.0-2` |
|
|
7
|
+
| Commit | `15aa653fa2b94c4c9041a04964e83b9d794cf345` |
|
|
8
|
+
| License | ISC ([LICENSE](LICENSE)) |
|
|
9
|
+
| Copied | `src/` and `LICENSE`, byte for byte. Upstream's tests, docs and `bin.js` aren't vendored |
|
|
10
|
+
|
|
11
|
+
`bin.js` is ported to [../../main.ts](../../main.ts) instead of vendored. It's a
|
|
12
|
+
JavaScript file that imports the built package, and main.ts makes the same
|
|
13
|
+
`cli()` call from TypeScript.
|
|
14
|
+
|
|
15
|
+
## Patches
|
|
16
|
+
|
|
17
|
+
None. `src/` is upstream's tree unmodified. To check:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
git clone --depth 1 --branch v3.0.0-2 https://github.com/eemeli/yaml.git /tmp/yaml
|
|
21
|
+
diff -r /tmp/yaml/src src && diff /tmp/yaml/LICENSE LICENSE
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Anything in this tree that TypeNative couldn't compile was fixed in the
|
|
25
|
+
transpiler, never here. Each fix has a probe in [conformance/](../../../../conformance/).
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 John Chadwick
|
|
4
|
+
Some portions Copyright (c) 2017 Serge Zaitsev
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[](https://github.com/jchv/go-webview2/actions/workflows/go.yml) [](https://goreportcard.com/report/github.com/jchv/go-webview2) [](https://pkg.go.dev/github.com/jchv/go-webview2)
|
|
2
|
+
|
|
3
|
+
# go-webview2
|
|
4
|
+
This package provides an interface for using the Microsoft Edge WebView2 component with Go. It is based on [webview/webview](https://github.com/webview/webview) and provides a compatible API.
|
|
5
|
+
|
|
6
|
+
Please note that this package only supports Windows, since it provides functionality specific to WebView2. If you wish to use this library for Windows, but use webview/webview for all other operating systems, you could use the [go-webview-selector](https://github.com/jchv/go-webview-selector) package instead. However, you will not be able to use WebView2-specific functionality.
|
|
7
|
+
|
|
8
|
+
If you wish to build desktop applications in Go using web technologies, please consider [Wails](https://wails.io/). It uses go-webview2 internally on Windows.
|
|
9
|
+
|
|
10
|
+
## Demo
|
|
11
|
+
If you are using Windows 10+, the WebView2 runtime should already be installed. If you don't have it installed, you can download and install a copy from Microsoft's website:
|
|
12
|
+
|
|
13
|
+
[WebView2 runtime](https://developer.microsoft.com/en-us/microsoft-edge/webview2/)
|
|
14
|
+
|
|
15
|
+
After that, you should be able to run go-webview2 directly:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
go run ./cmd/demo
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This will use go-winloader to load an embedded copy of WebView2Loader.dll. If you want, you can also provide a newer version of WebView2Loader.dll in the DLL search path and it should be picked up instead. It can be acquired from the WebView2 SDK (which is permissively licensed.)
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
package webview2
|
|
2
|
+
|
|
3
|
+
import "unsafe"
|
|
4
|
+
|
|
5
|
+
// This is copied from webview/webview.
|
|
6
|
+
// The documentation is included for convenience.
|
|
7
|
+
|
|
8
|
+
// Hint is used to configure window sizing and resizing behavior.
|
|
9
|
+
type Hint int
|
|
10
|
+
|
|
11
|
+
const (
|
|
12
|
+
// HintNone specifies that width and height are default size
|
|
13
|
+
HintNone Hint = iota
|
|
14
|
+
|
|
15
|
+
// HintFixed specifies that window size can not be changed by a user
|
|
16
|
+
HintFixed
|
|
17
|
+
|
|
18
|
+
// HintMin specifies that width and height are minimum bounds
|
|
19
|
+
HintMin
|
|
20
|
+
|
|
21
|
+
// HintMax specifies that width and height are maximum bounds
|
|
22
|
+
HintMax
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
// WebView is the interface for the webview.
|
|
26
|
+
type WebView interface {
|
|
27
|
+
|
|
28
|
+
// Run runs the main loop until it's terminated. After this function exits -
|
|
29
|
+
// you must destroy the webview.
|
|
30
|
+
Run()
|
|
31
|
+
|
|
32
|
+
// Terminate stops the main loop. It is safe to call this function from
|
|
33
|
+
// a background thread.
|
|
34
|
+
Terminate()
|
|
35
|
+
|
|
36
|
+
// Dispatch posts a function to be executed on the main thread. You normally
|
|
37
|
+
// do not need to call this function, unless you want to tweak the native
|
|
38
|
+
// window.
|
|
39
|
+
Dispatch(f func())
|
|
40
|
+
|
|
41
|
+
// Destroy destroys a webview and closes the native window.
|
|
42
|
+
Destroy()
|
|
43
|
+
|
|
44
|
+
// Window returns a native window handle pointer. When using GTK backend the
|
|
45
|
+
// pointer is GtkWindow pointer, when using Cocoa backend the pointer is
|
|
46
|
+
// NSWindow pointer, when using Win32 backend the pointer is HWND pointer.
|
|
47
|
+
Window() unsafe.Pointer
|
|
48
|
+
|
|
49
|
+
// SetTitle updates the title of the native window. Must be called from the UI
|
|
50
|
+
// thread.
|
|
51
|
+
SetTitle(title string)
|
|
52
|
+
|
|
53
|
+
// SetSize updates native window size. See Hint constants.
|
|
54
|
+
SetSize(w int, h int, hint Hint)
|
|
55
|
+
|
|
56
|
+
// Navigate navigates webview to the given URL. URL may be a data URI, i.e.
|
|
57
|
+
// "data:text/text,<html>...</html>". It is often ok not to url-encode it
|
|
58
|
+
// properly, webview will re-encode it for you.
|
|
59
|
+
Navigate(url string)
|
|
60
|
+
|
|
61
|
+
// SetHtml sets the webview HTML directly.
|
|
62
|
+
// The origin of the page is `about:blank`.
|
|
63
|
+
SetHtml(html string)
|
|
64
|
+
|
|
65
|
+
// Init injects JavaScript code at the initialization of the new page. Every
|
|
66
|
+
// time the webview will open a the new page - this initialization code will
|
|
67
|
+
// be executed. It is guaranteed that code is executed before window.onload.
|
|
68
|
+
Init(js string)
|
|
69
|
+
|
|
70
|
+
// Eval evaluates arbitrary JavaScript code. Evaluation happens asynchronously,
|
|
71
|
+
// also the result of the expression is ignored. Use RPC bindings if you want
|
|
72
|
+
// to receive notifications about the results of the evaluation.
|
|
73
|
+
Eval(js string)
|
|
74
|
+
|
|
75
|
+
// Bind binds a callback function so that it will appear under the given name
|
|
76
|
+
// as a global JavaScript function. Internally it uses webview_init().
|
|
77
|
+
// Callback receives a request string and a user-provided argument pointer.
|
|
78
|
+
// Request string is a JSON array of all the arguments passed to the
|
|
79
|
+
// JavaScript function.
|
|
80
|
+
//
|
|
81
|
+
// f must be a function
|
|
82
|
+
// f must return either value and error or just error
|
|
83
|
+
Bind(name string, f interface{}) error
|
|
84
|
+
}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
package w32
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"syscall"
|
|
5
|
+
"unicode/utf16"
|
|
6
|
+
"unsafe"
|
|
7
|
+
|
|
8
|
+
"golang.org/x/sys/windows"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
var (
|
|
12
|
+
ole32 = windows.NewLazySystemDLL("ole32")
|
|
13
|
+
Ole32CoInitializeEx = ole32.NewProc("CoInitializeEx")
|
|
14
|
+
|
|
15
|
+
kernel32 = windows.NewLazySystemDLL("kernel32")
|
|
16
|
+
Kernel32GetCurrentThreadID = kernel32.NewProc("GetCurrentThreadId")
|
|
17
|
+
|
|
18
|
+
shlwapi = windows.NewLazySystemDLL("shlwapi")
|
|
19
|
+
shlwapiSHCreateMemStream = shlwapi.NewProc("SHCreateMemStream")
|
|
20
|
+
|
|
21
|
+
user32 = windows.NewLazySystemDLL("user32")
|
|
22
|
+
User32LoadImageW = user32.NewProc("LoadImageW")
|
|
23
|
+
User32GetSystemMetrics = user32.NewProc("GetSystemMetrics")
|
|
24
|
+
User32RegisterClassExW = user32.NewProc("RegisterClassExW")
|
|
25
|
+
User32CreateWindowExW = user32.NewProc("CreateWindowExW")
|
|
26
|
+
User32DestroyWindow = user32.NewProc("DestroyWindow")
|
|
27
|
+
User32ShowWindow = user32.NewProc("ShowWindow")
|
|
28
|
+
User32UpdateWindow = user32.NewProc("UpdateWindow")
|
|
29
|
+
User32SetFocus = user32.NewProc("SetFocus")
|
|
30
|
+
User32GetMessageW = user32.NewProc("GetMessageW")
|
|
31
|
+
User32TranslateMessage = user32.NewProc("TranslateMessage")
|
|
32
|
+
User32DispatchMessageW = user32.NewProc("DispatchMessageW")
|
|
33
|
+
User32DefWindowProcW = user32.NewProc("DefWindowProcW")
|
|
34
|
+
User32GetClientRect = user32.NewProc("GetClientRect")
|
|
35
|
+
User32PostQuitMessage = user32.NewProc("PostQuitMessage")
|
|
36
|
+
User32PostMessageW = user32.NewProc("PostMessageW")
|
|
37
|
+
User32SetWindowTextW = user32.NewProc("SetWindowTextW")
|
|
38
|
+
User32PostThreadMessageW = user32.NewProc("PostThreadMessageW")
|
|
39
|
+
User32GetWindowLongW = user32.NewProc("GetWindowLongW")
|
|
40
|
+
User32GetWindowLongPtrW = user32.NewProc("GetWindowLongPtrW")
|
|
41
|
+
User32SetWindowLongW = user32.NewProc("SetWindowLongW")
|
|
42
|
+
User32SetWindowLongPtrW = user32.NewProc("SetWindowLongPtrW")
|
|
43
|
+
User32AdjustWindowRect = user32.NewProc("AdjustWindowRect")
|
|
44
|
+
User32SetWindowPos = user32.NewProc("SetWindowPos")
|
|
45
|
+
User32IsDialogMessage = user32.NewProc("IsDialogMessage")
|
|
46
|
+
User32GetAncestor = user32.NewProc("GetAncestor")
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
const (
|
|
50
|
+
SM_CXSCREEN = 0
|
|
51
|
+
SM_CYSCREEN = 1
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
const (
|
|
55
|
+
CW_USEDEFAULT = 0x80000000
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
const (
|
|
59
|
+
LR_DEFAULTCOLOR = 0x0000
|
|
60
|
+
LR_MONOCHROME = 0x0001
|
|
61
|
+
LR_LOADFROMFILE = 0x0010
|
|
62
|
+
LR_LOADTRANSPARENT = 0x0020
|
|
63
|
+
LR_DEFAULTSIZE = 0x0040
|
|
64
|
+
LR_VGACOLOR = 0x0080
|
|
65
|
+
LR_LOADMAP3DCOLORS = 0x1000
|
|
66
|
+
LR_CREATEDIBSECTION = 0x2000
|
|
67
|
+
LR_SHARED = 0x8000
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
const (
|
|
71
|
+
SystemMetricsCxIcon = 11
|
|
72
|
+
SystemMetricsCyIcon = 12
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
const (
|
|
76
|
+
SWShow = 5
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
const (
|
|
80
|
+
SWPNoZOrder = 0x0004
|
|
81
|
+
SWPNoActivate = 0x0010
|
|
82
|
+
SWPNoMove = 0x0002
|
|
83
|
+
SWPFrameChanged = 0x0020
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
const (
|
|
87
|
+
WMDestroy = 0x0002
|
|
88
|
+
WMMove = 0x0003
|
|
89
|
+
WMSize = 0x0005
|
|
90
|
+
WMActivate = 0x0006
|
|
91
|
+
WMClose = 0x0010
|
|
92
|
+
WMQuit = 0x0012
|
|
93
|
+
WMGetMinMaxInfo = 0x0024
|
|
94
|
+
WMNCLButtonDown = 0x00A1
|
|
95
|
+
WMMoving = 0x0216
|
|
96
|
+
WMApp = 0x8000
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
const (
|
|
100
|
+
GAParent = 1
|
|
101
|
+
GARoot = 2
|
|
102
|
+
GARootOwner = 3
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
const (
|
|
106
|
+
GWLStyle = -16
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
const (
|
|
110
|
+
WSOverlapped = 0x00000000
|
|
111
|
+
WSMaximizeBox = 0x00010000
|
|
112
|
+
WSThickFrame = 0x00040000
|
|
113
|
+
WSCaption = 0x00C00000
|
|
114
|
+
WSSysMenu = 0x00080000
|
|
115
|
+
WSMinimizeBox = 0x00020000
|
|
116
|
+
WSOverlappedWindow = (WSOverlapped | WSCaption | WSSysMenu | WSThickFrame | WSMinimizeBox | WSMaximizeBox)
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
const (
|
|
120
|
+
WAInactive = 0
|
|
121
|
+
WAActive = 1
|
|
122
|
+
WAActiveClick = 2
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
type WndClassExW struct {
|
|
126
|
+
CbSize uint32
|
|
127
|
+
Style uint32
|
|
128
|
+
LpfnWndProc uintptr
|
|
129
|
+
CnClsExtra int32
|
|
130
|
+
CbWndExtra int32
|
|
131
|
+
HInstance windows.Handle
|
|
132
|
+
HIcon windows.Handle
|
|
133
|
+
HCursor windows.Handle
|
|
134
|
+
HbrBackground windows.Handle
|
|
135
|
+
LpszMenuName *uint16
|
|
136
|
+
LpszClassName *uint16
|
|
137
|
+
HIconSm windows.Handle
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
type Rect struct {
|
|
141
|
+
Left int32
|
|
142
|
+
Top int32
|
|
143
|
+
Right int32
|
|
144
|
+
Bottom int32
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
type MinMaxInfo struct {
|
|
148
|
+
PtReserved Point
|
|
149
|
+
PtMaxSize Point
|
|
150
|
+
PtMaxPosition Point
|
|
151
|
+
PtMinTrackSize Point
|
|
152
|
+
PtMaxTrackSize Point
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
type Point struct {
|
|
156
|
+
X, Y int32
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
type Msg struct {
|
|
160
|
+
Hwnd syscall.Handle
|
|
161
|
+
Message uint32
|
|
162
|
+
WParam uintptr
|
|
163
|
+
LParam uintptr
|
|
164
|
+
Time uint32
|
|
165
|
+
Pt Point
|
|
166
|
+
LPrivate uint32
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
func Utf16PtrToString(p *uint16) string {
|
|
170
|
+
if p == nil {
|
|
171
|
+
return ""
|
|
172
|
+
}
|
|
173
|
+
// Find NUL terminator.
|
|
174
|
+
end := unsafe.Pointer(p)
|
|
175
|
+
n := 0
|
|
176
|
+
for *(*uint16)(end) != 0 {
|
|
177
|
+
end = unsafe.Pointer(uintptr(end) + unsafe.Sizeof(*p))
|
|
178
|
+
n++
|
|
179
|
+
}
|
|
180
|
+
s := (*[(1 << 30) - 1]uint16)(unsafe.Pointer(p))[:n:n]
|
|
181
|
+
return string(utf16.Decode(s))
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
func SHCreateMemStream(data []byte) (uintptr, error) {
|
|
185
|
+
ret, _, err := shlwapiSHCreateMemStream.Call(
|
|
186
|
+
uintptr(unsafe.Pointer(&data[0])),
|
|
187
|
+
uintptr(len(data)),
|
|
188
|
+
)
|
|
189
|
+
if ret == 0 {
|
|
190
|
+
return 0, err
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return ret, nil
|
|
194
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//go:build windows && 386
|
|
2
|
+
// +build windows,386
|
|
3
|
+
|
|
4
|
+
package w32
|
|
5
|
+
|
|
6
|
+
func GetWindowLong(hwnd uintptr, index int) uintptr {
|
|
7
|
+
ret, _, _ := User32GetWindowLongW.Call(hwnd, uintptr(index))
|
|
8
|
+
return ret
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
func SetWindowLong(hwnd uintptr, index int, newLong uintptr) uintptr {
|
|
12
|
+
ret, _, _ := User32SetWindowLongW.Call(hwnd, uintptr(index), newLong)
|
|
13
|
+
return ret
|
|
14
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//go:build windows && (amd64 || arm64)
|
|
2
|
+
// +build windows
|
|
3
|
+
// +build amd64 arm64
|
|
4
|
+
|
|
5
|
+
package w32
|
|
6
|
+
|
|
7
|
+
func GetWindowLong(hwnd uintptr, index int) uintptr {
|
|
8
|
+
ret, _, _ := User32GetWindowLongPtrW.Call(hwnd, uintptr(index))
|
|
9
|
+
return ret
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
func SetWindowLong(hwnd uintptr, index int, newLong uintptr) uintptr {
|
|
13
|
+
ret, _, _ := User32SetWindowLongPtrW.Call(hwnd, uintptr(index), newLong)
|
|
14
|
+
return ret
|
|
15
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
package edge
|
|
2
|
+
|
|
3
|
+
type COREWEBVIEW2_WEB_RESOURCE_CONTEXT uint32
|
|
4
|
+
|
|
5
|
+
const (
|
|
6
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_ALL = 0
|
|
7
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_DOCUMENT = 1
|
|
8
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_STYLESHEET = 2
|
|
9
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_IMAGE = 3
|
|
10
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_MEDIA = 4
|
|
11
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_FONT = 5
|
|
12
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_SCRIPT = 6
|
|
13
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_XML_HTTP_REQUEST = 7
|
|
14
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_FETCH = 8
|
|
15
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_TEXT_TRACK = 9
|
|
16
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_EVENT_SOURCE = 10
|
|
17
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_WEBSOCKET = 11
|
|
18
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_MANIFEST = 12
|
|
19
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_SIGNED_EXCHANGE = 13
|
|
20
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_PING = 14
|
|
21
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_CSP_VIOLATION_REPORT = 15
|
|
22
|
+
COREWEBVIEW2_WEB_RESOURCE_CONTEXT_OTHER = 16
|
|
23
|
+
)
|