@master/css-binding 0.0.0-site.1793659883.g69c9aebcf628

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 (66) hide show
  1. package/artifacts/mastercss.node +0 -0
  2. package/artifacts/mcss +0 -0
  3. package/dist/binding-options.d.ts +14 -0
  4. package/dist/binding-options.js +15 -0
  5. package/dist/binding.d.ts +12 -0
  6. package/dist/binding.js +23 -0
  7. package/dist/browser.d.ts +3 -0
  8. package/dist/browser.js +3 -0
  9. package/dist/compiler-binding-adapter.js +55 -0
  10. package/dist/compiler-binding-browser.d.ts +6 -0
  11. package/dist/compiler-binding-browser.js +24 -0
  12. package/dist/compiler-binding-contract.d.ts +45 -0
  13. package/dist/compiler-binding-node.d.ts +5 -0
  14. package/dist/compiler-binding-node.js +20 -0
  15. package/dist/compiler-binding-wasm.js +58 -0
  16. package/dist/compiler-binding.d.ts +6 -0
  17. package/dist/compiler-binding.js +42 -0
  18. package/dist/compiler.js +52 -0
  19. package/dist/engine-binding-adapter.js +61 -0
  20. package/dist/engine-binding-browser.d.ts +8 -0
  21. package/dist/engine-binding-browser.js +35 -0
  22. package/dist/engine-binding-js.js +81 -0
  23. package/dist/engine-binding-node.d.ts +9 -0
  24. package/dist/engine-binding-node.js +38 -0
  25. package/dist/engine-binding-wasm.js +64 -0
  26. package/dist/engine-binding.d.ts +40 -0
  27. package/dist/engine-binding.js +57 -0
  28. package/dist/engine-contract.d.ts +14 -0
  29. package/dist/engine-js/src/animation.js +154 -0
  30. package/dist/engine-js/src/apply.js +207 -0
  31. package/dist/engine-js/src/class-syntax.js +333 -0
  32. package/dist/engine-js/src/condition.js +440 -0
  33. package/dist/engine-js/src/css-syntax.js +247 -0
  34. package/dist/engine-js/src/generate.js +288 -0
  35. package/dist/engine-js/src/mixin.js +328 -0
  36. package/dist/engine-js/src/native-properties.js +5 -0
  37. package/dist/engine-js/src/order.js +97 -0
  38. package/dist/engine-js/src/program-model.js +19 -0
  39. package/dist/engine-js/src/program.js +434 -0
  40. package/dist/engine-js/src/selector.js +195 -0
  41. package/dist/engine-js/src/session.js +540 -0
  42. package/dist/engine-js/src/state.js +62 -0
  43. package/dist/engine-js/src/text.js +51 -0
  44. package/dist/engine-js/src/utility.js +236 -0
  45. package/dist/engine-js/src/value.js +254 -0
  46. package/dist/engine.js +86 -0
  47. package/dist/errors.js +10 -0
  48. package/dist/index.d.ts +4 -0
  49. package/dist/index.js +3 -0
  50. package/dist/native-loader.js +134 -0
  51. package/dist/normalize-error.js +63 -0
  52. package/dist/protocol.d.ts +1119 -0
  53. package/dist/protocol.js +14 -0
  54. package/dist/tooling-binding-adapter.js +23 -0
  55. package/dist/tooling-binding-browser.d.ts +5 -0
  56. package/dist/tooling-binding-browser.js +15 -0
  57. package/dist/tooling-binding-contract.d.ts +92 -0
  58. package/dist/tooling-binding-native.js +46 -0
  59. package/dist/tooling-binding-node.d.ts +4 -0
  60. package/dist/tooling-binding-node.js +11 -0
  61. package/dist/tooling-binding-wasm.js +127 -0
  62. package/dist/tooling-binding.d.ts +5 -0
  63. package/dist/tooling-binding.js +21 -0
  64. package/dist/tooling.js +144 -0
  65. package/dist/version.js +3 -0
  66. package/package.json +78 -0
@@ -0,0 +1,134 @@
1
+ import "./protocol.js";
2
+ import { assertMasterCSSBindingInfo } from "./binding.js";
3
+ import { NativeBindingError } from "./errors.js";
4
+ import { MASTER_CSS_PACKAGE_VERSION } from "./version.js";
5
+ import { createRequire } from "node:module";
6
+ import { existsSync } from "node:fs";
7
+ import { dirname, parse, resolve } from "node:path";
8
+ import { fileURLToPath, pathToFileURL } from "node:url";
9
+ // src/native-loader.ts
10
+ function detectLinuxLibc() {
11
+ return (process.report?.getReport())?.header?.glibcVersionRuntime ? "glibc" : "musl";
12
+ }
13
+ function resolveNativeTarget(platform = process.platform, arch = process.arch, libc = platform === "linux" ? detectLinuxLibc() : void 0) {
14
+ if (platform === "darwin" && (arch === "arm64" || arch === "x64")) return {
15
+ platform,
16
+ arch,
17
+ packageName: `@master/css-binding-darwin-${arch}`
18
+ };
19
+ if (platform === "win32" && (arch === "arm64" || arch === "x64")) return {
20
+ platform,
21
+ arch,
22
+ packageName: `@master/css-binding-win32-${arch}-msvc`
23
+ };
24
+ if (platform === "linux" && (arch === "arm64" || arch === "x64") && libc) return {
25
+ platform,
26
+ arch,
27
+ libc,
28
+ packageName: `@master/css-binding-linux-${arch}-${libc === "glibc" ? "gnu" : "musl"}`
29
+ };
30
+ }
31
+ function nativeAddonsDisabled(execArgv = process.execArgv) {
32
+ return execArgv.includes("--no-addons");
33
+ }
34
+ function runtimeResolutionBases() {
35
+ const bases = [import.meta.url];
36
+ if (process.argv[1]) bases.push(pathToFileURL(resolve(process.argv[1])).href);
37
+ bases.push(pathToFileURL(resolve(process.cwd(), "package.json")).href);
38
+ return [...new Set(bases)];
39
+ }
40
+ function resolveDevelopmentArtifact(name) {
41
+ try {
42
+ const packageArtifact = resolve(dirname(fileURLToPath(import.meta.url)), "../artifacts", name);
43
+ if (existsSync(packageArtifact)) return packageArtifact;
44
+ } catch {}
45
+ const startDirectories = [process.cwd()];
46
+ if (process.argv[1]) startDirectories.push(dirname(resolve(process.argv[1])));
47
+ for (const startDirectory of new Set(startDirectories)) {
48
+ let directory = startDirectory;
49
+ const root = parse(directory).root;
50
+ while (true) {
51
+ for (const artifact of [resolve(directory, "node_modules/@master/css-binding/artifacts", name), resolve(directory, "packages/binding/artifacts", name)]) if (existsSync(
52
+ /*turbopackIgnore: true*/
53
+ artifact
54
+ )) return artifact;
55
+ if (directory === root) break;
56
+ directory = dirname(directory);
57
+ }
58
+ }
59
+ }
60
+ function resolveTargetArtifact(packageName, name) {
61
+ for (const base of runtimeResolutionBases()) try {
62
+ for (const directory of createRequire(base).resolve.paths(packageName) || []) {
63
+ const packageRoot = resolve(directory, packageName);
64
+ const artifact = resolve(packageRoot, name);
65
+ if (existsSync(resolve(packageRoot, "package.json")) && existsSync(artifact)) return artifact;
66
+ }
67
+ } catch {}
68
+ }
69
+ function loadNativeAddon(source) {
70
+ const nativeModule = { exports: {} };
71
+ process.dlopen(nativeModule, source);
72
+ return nativeModule.exports;
73
+ }
74
+ function assertBindingInfo(binding, source) {
75
+ let info;
76
+ try {
77
+ info = JSON.parse(binding.bindingInfoJson());
78
+ } catch (cause) {
79
+ throw new NativeBindingError("NATIVE_LOAD_FAILED", `Master CSS native binding returned invalid metadata: ${source}`, { cause });
80
+ }
81
+ try {
82
+ return assertMasterCSSBindingInfo(info, {
83
+ surface: "native",
84
+ features: [
85
+ "compiler",
86
+ "diagnostics",
87
+ "engine",
88
+ "language",
89
+ "lint",
90
+ "project",
91
+ "render",
92
+ "scanner",
93
+ "source",
94
+ "validator"
95
+ ],
96
+ packageVersion: MASTER_CSS_PACKAGE_VERSION
97
+ });
98
+ } catch (cause) {
99
+ throw new NativeBindingError("NATIVE_LOAD_FAILED", `Master CSS native binding ABI mismatch: ${source}`, { cause });
100
+ }
101
+ }
102
+ const loadedNativeBindings = /* @__PURE__ */ new Map();
103
+ function loadNativeBinding(options = {}) {
104
+ if (nativeAddonsDisabled()) {
105
+ if (!options.required) return;
106
+ throw new NativeBindingError("NATIVE_UNAVAILABLE", "Native addons are disabled by --no-addons.");
107
+ }
108
+ const configuredPath = options.bindingPath || process.env.MASTER_CSS_NATIVE_BINDING_PATH;
109
+ const developmentPath = resolveDevelopmentArtifact("mastercss.node");
110
+ const target = resolveNativeTarget();
111
+ const targetPath = target && resolveTargetArtifact(target.packageName, "mastercss.node");
112
+ const source = configuredPath || developmentPath || targetPath;
113
+ if (!source) {
114
+ if (target) throw new NativeBindingError("NATIVE_LOAD_FAILED", `Cannot resolve the expected Master CSS native binding: ${target.packageName}`);
115
+ if (!options.required) return;
116
+ throw new NativeBindingError("NATIVE_UNAVAILABLE", `Master CSS has no native binding for ${process.platform}-${process.arch}.`);
117
+ }
118
+ const cached = loadedNativeBindings.get(source);
119
+ if (cached) return cached;
120
+ try {
121
+ const binding = loadNativeAddon(source);
122
+ const loaded = Object.freeze({
123
+ binding,
124
+ info: assertBindingInfo(binding, source),
125
+ source
126
+ });
127
+ loadedNativeBindings.set(source, loaded);
128
+ return loaded;
129
+ } catch (cause) {
130
+ if (cause instanceof NativeBindingError) throw cause;
131
+ throw new NativeBindingError("NATIVE_LOAD_FAILED", `Cannot load the expected Master CSS native binding: ${source}`, { cause });
132
+ }
133
+ }
134
+ export { loadNativeBinding, nativeAddonsDisabled, resolveNativeTarget };
@@ -0,0 +1,63 @@
1
+ import { NativeBindingError } from "./errors.js";
2
+ import { MASTER_CSS_DIAGNOSTIC_VERSION, MasterCSSError } from "@master/css-schema";
3
+ // src/normalize-error.ts
4
+ function parseBindingDiagnostic(cause) {
5
+ const message = typeof cause === "string" ? cause : cause && typeof cause === "object" && "message" in cause ? cause.message : void 0;
6
+ if (typeof message !== "string") return;
7
+ const start = message.indexOf("{");
8
+ if (start === -1) return;
9
+ try {
10
+ const parsed = JSON.parse(message.slice(start));
11
+ return typeof parsed.message === "string" ? parsed : void 0;
12
+ } catch {
13
+ return;
14
+ }
15
+ }
16
+ function positionAt(source, offset) {
17
+ const lines = source.slice(0, Math.max(0, offset)).split(/\r\n?|\n/);
18
+ return Object.freeze({
19
+ line: lines.length - 1,
20
+ character: lines.at(-1)?.length ?? 0
21
+ });
22
+ }
23
+ function normalizeBindingError(cause, domain = "binding", fallbackCode = "INTERNAL", fallbackMessage = "Master CSS binding operation failed.", sourceText) {
24
+ if (cause instanceof MasterCSSError) return cause;
25
+ const parsed = parseBindingDiagnostic(cause);
26
+ const code = typeof parsed?.code === "string" ? parsed.code : cause instanceof NativeBindingError ? cause.code : cause && typeof cause === "object" && "code" in cause && typeof cause.code === "string" ? cause.code : fallbackCode;
27
+ const message = typeof parsed?.message === "string" ? parsed.message : cause instanceof Error && cause.message ? cause.message : fallbackMessage;
28
+ const text = typeof sourceText === "function" ? typeof parsed?.source === "string" ? sourceText(parsed.source) : void 0 : sourceText;
29
+ const diagnostic = parsed ? Object.freeze({
30
+ version: MASTER_CSS_DIAGNOSTIC_VERSION,
31
+ code,
32
+ domain,
33
+ severity: "error",
34
+ message,
35
+ ...typeof parsed.source === "string" ? { source: parsed.source } : {},
36
+ ...text !== void 0 && typeof parsed.range?.start === "number" && typeof parsed.range.end === "number" ? { range: Object.freeze({
37
+ start: positionAt(text, parsed.range.start),
38
+ end: positionAt(text, parsed.range.end)
39
+ }) } : {},
40
+ ...Array.isArray(parsed.notes) ? { notes: Object.freeze(parsed.notes.filter((note) => typeof note === "string")) } : {}
41
+ }) : void 0;
42
+ return new MasterCSSError({
43
+ code,
44
+ domain,
45
+ message,
46
+ ...diagnostic ? { diagnostics: [diagnostic] } : {}
47
+ }, { cause });
48
+ }
49
+ function callBinding(domain, operation, sourceText) {
50
+ try {
51
+ return operation();
52
+ } catch (cause) {
53
+ throw normalizeBindingError(cause, domain, "INTERNAL", "Master CSS binding operation failed.", sourceText);
54
+ }
55
+ }
56
+ async function callBindingAsync(domain, operation, sourceText) {
57
+ try {
58
+ return await operation();
59
+ } catch (cause) {
60
+ throw normalizeBindingError(cause, domain, "INTERNAL", "Master CSS binding operation failed.", sourceText);
61
+ }
62
+ }
63
+ export { callBinding, callBindingAsync, normalizeBindingError };