tailwind-styled-v4 5.0.9 → 5.0.10
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/CHANGELOG.md +15 -1
- package/dist/{analyzeWorkspace-DuJKh7Ty.d.mts → analyzeWorkspace-BS5O4rhC.d.mts} +47 -2
- package/dist/{analyzeWorkspace-Ct_NTAWt.d.ts → analyzeWorkspace-DDOQdzzI.d.ts} +47 -2
- package/dist/analyzer.d.mts +5 -3
- package/dist/analyzer.d.ts +5 -3
- package/dist/analyzer.js +563 -468
- package/dist/analyzer.js.map +1 -1
- package/dist/analyzer.mjs +562 -467
- package/dist/analyzer.mjs.map +1 -1
- package/dist/animate.d.mts +4 -7
- package/dist/animate.d.ts +4 -7
- package/dist/animate.js +171 -265
- package/dist/animate.js.map +1 -1
- package/dist/animate.mjs +165 -264
- package/dist/animate.mjs.map +1 -1
- package/dist/atomic.d.mts +22 -1
- package/dist/atomic.d.ts +22 -1
- package/dist/atomic.js +221 -165
- package/dist/atomic.js.map +1 -1
- package/dist/atomic.mjs +200 -165
- package/dist/atomic.mjs.map +1 -1
- package/dist/cli.d.mts +60 -1
- package/dist/cli.d.ts +60 -1
- package/dist/cli.js +1261 -1517
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1238 -1513
- package/dist/cli.mjs.map +1 -1
- package/dist/compiler.d.mts +38 -7
- package/dist/compiler.d.ts +38 -7
- package/dist/compiler.js +174 -197
- package/dist/compiler.js.map +1 -1
- package/dist/compiler.mjs +151 -194
- package/dist/compiler.mjs.map +1 -1
- package/dist/devtools.js +7 -31
- package/dist/devtools.js.map +1 -1
- package/dist/devtools.mjs +7 -31
- package/dist/devtools.mjs.map +1 -1
- package/dist/engine.d.mts +134 -63
- package/dist/engine.d.ts +134 -63
- package/dist/engine.js +2863 -2482
- package/dist/engine.js.map +1 -1
- package/dist/engine.mjs +2852 -2485
- package/dist/engine.mjs.map +1 -1
- package/dist/{index-eWAocnD2.d.mts → index-NDINUhLN.d.mts} +3 -1
- package/dist/{index-eWAocnD2.d.ts → index-NDINUhLN.d.ts} +3 -1
- package/dist/index.d.mts +45 -32
- package/dist/index.d.ts +45 -32
- package/dist/index.js +271 -158
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +251 -158
- package/dist/index.mjs.map +1 -1
- package/dist/{liveTokenEngine-DSUk88P6.d.ts → liveTokenEngine-CN9ian1R.d.ts} +1 -1
- package/dist/{liveTokenEngine-CX5_0c4q.d.mts → liveTokenEngine-DKoWRtqH.d.mts} +1 -1
- package/dist/next.js +20 -39
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +18 -37
- package/dist/next.mjs.map +1 -1
- package/dist/plugin-api.d.mts +8 -2
- package/dist/plugin-api.d.ts +8 -2
- package/dist/plugin-api.js +14 -2
- package/dist/plugin-api.js.map +1 -1
- package/dist/plugin-api.mjs +14 -3
- package/dist/plugin-api.mjs.map +1 -1
- package/dist/plugin-registry.js +51 -11
- package/dist/plugin-registry.js.map +1 -1
- package/dist/plugin-registry.mjs +51 -11
- package/dist/plugin-registry.mjs.map +1 -1
- package/dist/plugin.d.mts +5 -7
- package/dist/plugin.d.ts +5 -7
- package/dist/plugin.js +16 -15
- package/dist/plugin.js.map +1 -1
- package/dist/plugin.mjs +16 -16
- package/dist/plugin.mjs.map +1 -1
- package/dist/rspack.js +17 -38
- package/dist/rspack.js.map +1 -1
- package/dist/rspack.mjs +15 -36
- package/dist/rspack.mjs.map +1 -1
- package/dist/runtime.d.mts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/scanner.d.mts +10 -1
- package/dist/scanner.d.ts +10 -1
- package/dist/scanner.js +298 -124
- package/dist/scanner.js.map +1 -1
- package/dist/scanner.mjs +296 -124
- package/dist/scanner.mjs.map +1 -1
- package/dist/shared.d.mts +1 -1
- package/dist/shared.d.ts +1 -1
- package/dist/shared.js +104 -176
- package/dist/shared.js.map +1 -1
- package/dist/shared.mjs +85 -176
- package/dist/shared.mjs.map +1 -1
- package/dist/storybook-addon.d.mts +1 -1
- package/dist/storybook-addon.d.ts +1 -1
- package/dist/svelte.d.mts +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/svelte.js +166 -3
- package/dist/svelte.js.map +1 -1
- package/dist/svelte.mjs +143 -1
- package/dist/svelte.mjs.map +1 -1
- package/dist/syntax.js +21 -21
- package/dist/syntax.js.map +1 -1
- package/dist/syntax.mjs +21 -21
- package/dist/syntax.mjs.map +1 -1
- package/dist/testing.js +9 -1
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +9 -1
- package/dist/testing.mjs.map +1 -1
- package/dist/theme.d.mts +2 -2
- package/dist/theme.d.ts +2 -2
- package/dist/theme.js +40 -112
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +37 -110
- package/dist/theme.mjs.map +1 -1
- package/dist/turbopackLoader.js +79 -124
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/turbopackLoader.mjs +63 -122
- package/dist/turbopackLoader.mjs.map +1 -1
- package/dist/tw.js +1256 -1517
- package/dist/tw.js.map +1 -1
- package/dist/tw.mjs +1236 -1513
- package/dist/tw.mjs.map +1 -1
- package/dist/vite.js +1783 -823
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +1767 -821
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.d.mts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +165 -4
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +141 -1
- package/dist/vue.mjs.map +1 -1
- package/dist/webpackLoader.js +65 -108
- package/dist/webpackLoader.js.map +1 -1
- package/dist/webpackLoader.mjs +45 -104
- package/dist/webpackLoader.mjs.map +1 -1
- package/native/tailwind-styled-native.node +0 -0
- package/package.json +22 -24
package/dist/shared.mjs
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { createHash } from 'crypto';
|
|
2
|
+
import * as fs2 from 'fs';
|
|
3
|
+
import fs2__default from 'fs';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import path__default from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import { createRequire } from 'module';
|
|
1
8
|
import { z } from 'zod';
|
|
2
9
|
|
|
3
10
|
/* tailwind-styled-v4 v5.0.4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
@@ -236,9 +243,9 @@ function parseNative(schema, data, context) {
|
|
|
236
243
|
const result = schema.safeParse(data);
|
|
237
244
|
if (!result.success) {
|
|
238
245
|
const first = result.error.issues[0];
|
|
239
|
-
const
|
|
246
|
+
const path3 = first?.path?.join(".") ?? "(root)";
|
|
240
247
|
throw new Error(
|
|
241
|
-
`[${context}] Native binding returned unexpected data: ${
|
|
248
|
+
`[${context}] Native binding returned unexpected data: ${path3}: ${first?.message ?? "validation failed"}`
|
|
242
249
|
);
|
|
243
250
|
}
|
|
244
251
|
return result.data;
|
|
@@ -536,10 +543,13 @@ function getDirnameFromUrl(importMetaUrl) {
|
|
|
536
543
|
if (isBrowser2) return "";
|
|
537
544
|
try {
|
|
538
545
|
const nodeUrl = __require(NODE_URL);
|
|
539
|
-
|
|
546
|
+
const nodePath = __require(NODE_PATH);
|
|
547
|
+
return nodePath.dirname(nodeUrl.fileURLToPath(importMetaUrl));
|
|
540
548
|
} catch {
|
|
541
549
|
if (importMetaUrl.startsWith("file://")) {
|
|
542
|
-
|
|
550
|
+
const filePath = importMetaUrl.slice(7);
|
|
551
|
+
const lastSlash = filePath.lastIndexOf("/");
|
|
552
|
+
return lastSlash >= 0 ? filePath.slice(0, lastSlash) : filePath;
|
|
543
553
|
}
|
|
544
554
|
return "";
|
|
545
555
|
}
|
|
@@ -553,11 +563,11 @@ function resolvePath(...segments) {
|
|
|
553
563
|
return segments.join("/").replace(/\/+/g, "/");
|
|
554
564
|
}
|
|
555
565
|
}
|
|
556
|
-
function existsSync(
|
|
566
|
+
function existsSync(path3) {
|
|
557
567
|
if (isBrowser2) return false;
|
|
558
568
|
try {
|
|
559
569
|
const nodeFs = __require(NODE_FS);
|
|
560
|
-
return nodeFs.existsSync(
|
|
570
|
+
return nodeFs.existsSync(path3);
|
|
561
571
|
} catch {
|
|
562
572
|
return false;
|
|
563
573
|
}
|
|
@@ -764,50 +774,8 @@ function generateBarrelFile(exports$1, dir, opts = {}) {
|
|
|
764
774
|
}
|
|
765
775
|
return lines.join("\n");
|
|
766
776
|
}
|
|
767
|
-
|
|
768
|
-
// packages/domain/shared/src/native-resolution.ts
|
|
769
777
|
var isBrowser3 = typeof window !== "undefined" || typeof document !== "undefined";
|
|
770
|
-
var
|
|
771
|
-
function getNodeModuleRef2() {
|
|
772
|
-
if (isBrowser3) return null;
|
|
773
|
-
if (nodeModuleRef2 !== null) return nodeModuleRef2;
|
|
774
|
-
try {
|
|
775
|
-
const test = typeof __require === "function" ? __require("module") : null;
|
|
776
|
-
nodeModuleRef2 = test;
|
|
777
|
-
return test;
|
|
778
|
-
} catch {
|
|
779
|
-
nodeModuleRef2 = null;
|
|
780
|
-
return null;
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
var _nodeFs2 = null;
|
|
784
|
-
var _nodePath2 = null;
|
|
785
|
-
var _require = null;
|
|
786
|
-
function getNodeFs2() {
|
|
787
|
-
if (isBrowser3) return { existsSync: () => false };
|
|
788
|
-
const nodeRequire = getNodeModuleRef2();
|
|
789
|
-
if (!nodeRequire) return { existsSync: () => false };
|
|
790
|
-
if (!_nodeFs2) _nodeFs2 = nodeRequire.createRequire(import.meta.url)("node:fs");
|
|
791
|
-
return _nodeFs2;
|
|
792
|
-
}
|
|
793
|
-
function getNodePath2() {
|
|
794
|
-
if (isBrowser3) return { resolve: () => "", dirname: "" };
|
|
795
|
-
const nodeRequire = getNodeModuleRef2();
|
|
796
|
-
if (!nodeRequire) return { resolve: () => "", dirname: "" };
|
|
797
|
-
if (!_nodePath2) _nodePath2 = nodeRequire.createRequire(import.meta.url)("node:path");
|
|
798
|
-
return _nodePath2;
|
|
799
|
-
}
|
|
800
|
-
function getRequire(_importMetaUrl) {
|
|
801
|
-
if (isBrowser3) return () => {
|
|
802
|
-
throw new Error("node:module not available");
|
|
803
|
-
};
|
|
804
|
-
const nodeRequire = getNodeModuleRef2();
|
|
805
|
-
if (!nodeRequire) return () => {
|
|
806
|
-
throw new Error("require not available");
|
|
807
|
-
};
|
|
808
|
-
if (!_require) _require = nodeRequire.createRequire(_importMetaUrl);
|
|
809
|
-
return _require;
|
|
810
|
-
}
|
|
778
|
+
var _require = typeof __require !== "undefined" ? __require : createRequire(import.meta.url);
|
|
811
779
|
var PLATFORM_MAP = {
|
|
812
780
|
"linux-x64": ["@tailwind-styled/native-linux-x64"],
|
|
813
781
|
"linux-arm64": ["@tailwind-styled/native-linux-arm64"],
|
|
@@ -826,24 +794,21 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
826
794
|
if (isBrowser3) {
|
|
827
795
|
return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
|
|
828
796
|
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
797
|
+
if (process.env.TWS_DISABLE_NATIVE === "1") {
|
|
798
|
+
return { path: null, source: "not-found", platform, tried: [] };
|
|
799
|
+
}
|
|
832
800
|
const envPath = process.env.TW_NATIVE_PATH?.trim();
|
|
833
801
|
if (envPath) {
|
|
834
|
-
if (
|
|
802
|
+
if (fs2.existsSync(envPath)) {
|
|
835
803
|
return { path: envPath, source: "env", platform, tried };
|
|
836
804
|
}
|
|
837
805
|
tried.push(`env:${envPath} (not found)`);
|
|
838
806
|
}
|
|
839
|
-
if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1" || process.env.TWS_DISABLE_NATIVE === "1") {
|
|
840
|
-
return { path: null, source: "not-found", platform, tried: ["disabled by env"] };
|
|
841
|
-
}
|
|
842
807
|
const prebuiltPkgs = PLATFORM_MAP[platform] ?? [];
|
|
843
808
|
for (const pkg of prebuiltPkgs) {
|
|
844
809
|
try {
|
|
845
|
-
const candidate =
|
|
846
|
-
if (
|
|
810
|
+
const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
|
|
811
|
+
if (fs2.existsSync(candidate)) {
|
|
847
812
|
return { path: candidate, source: "prebuilt", platform, tried };
|
|
848
813
|
}
|
|
849
814
|
tried.push(`prebuilt:${pkg} (resolved but missing)`);
|
|
@@ -853,17 +818,33 @@ function resolveNativeBinary(runtimeDir) {
|
|
|
853
818
|
}
|
|
854
819
|
const cwd = process.cwd();
|
|
855
820
|
const base = runtimeDir ?? cwd;
|
|
856
|
-
const
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
path.resolve(
|
|
861
|
-
|
|
862
|
-
path.resolve(base,
|
|
863
|
-
|
|
821
|
+
const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
|
|
822
|
+
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
823
|
+
const localCandidates = [];
|
|
824
|
+
for (const bin of BINARY_NAMES) {
|
|
825
|
+
localCandidates.push(path.resolve(base, `${bin}.node`));
|
|
826
|
+
localCandidates.push(path.resolve(base, "..", `${bin}.node`));
|
|
827
|
+
localCandidates.push(path.resolve(base, `${bin}.${platform}.node`));
|
|
828
|
+
localCandidates.push(path.resolve(base, `${bin}.${napiPlatform}.node`));
|
|
829
|
+
}
|
|
830
|
+
for (const startDir of [cwd, base]) {
|
|
831
|
+
let dir = startDir;
|
|
832
|
+
for (let i = 0; i < 6; i++) {
|
|
833
|
+
const nativeDir = path.resolve(dir, "native");
|
|
834
|
+
for (const bin of BINARY_NAMES) {
|
|
835
|
+
localCandidates.push(path.resolve(nativeDir, `${bin}.node`));
|
|
836
|
+
localCandidates.push(path.resolve(nativeDir, `${bin}.${platform}.node`));
|
|
837
|
+
localCandidates.push(path.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
|
|
838
|
+
localCandidates.push(path.resolve(nativeDir, "target", "release", `${bin}.node`));
|
|
839
|
+
}
|
|
840
|
+
const parent = path.resolve(dir, "..");
|
|
841
|
+
if (parent === dir) break;
|
|
842
|
+
dir = parent;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
864
845
|
for (const candidate of localCandidates) {
|
|
865
846
|
tried.push(`local:${candidate}`);
|
|
866
|
-
if (
|
|
847
|
+
if (fs2.existsSync(candidate)) {
|
|
867
848
|
return { path: candidate, source: "local", platform, tried };
|
|
868
849
|
}
|
|
869
850
|
}
|
|
@@ -879,8 +860,7 @@ function formatNativeNotFoundError(result) {
|
|
|
879
860
|
`Solutions:`,
|
|
880
861
|
` 1. Build locally: npm run build:rust`,
|
|
881
862
|
` 2. Install prebuilt: npm install @tailwind-styled/native-${result.platform}`,
|
|
882
|
-
` 3. Override path: TW_NATIVE_PATH=/path/to/parser.node
|
|
883
|
-
` 4. Disable native: TWS_DISABLE_NATIVE=1 (slower, JS fallback)`
|
|
863
|
+
` 3. Override path: TW_NATIVE_PATH=/path/to/parser.node`
|
|
884
864
|
];
|
|
885
865
|
return lines.join("\n");
|
|
886
866
|
}
|
|
@@ -888,9 +868,9 @@ function formatNativeNotFoundError(result) {
|
|
|
888
868
|
// packages/domain/shared/src/observability.ts
|
|
889
869
|
function createObservabilityClient(opts = {}) {
|
|
890
870
|
const { baseUrl = "http://localhost:7421", timeoutMs = 3e3 } = opts;
|
|
891
|
-
async function fetchJson(
|
|
871
|
+
async function fetchJson(path3) {
|
|
892
872
|
try {
|
|
893
|
-
const res = await fetch(`${baseUrl}${
|
|
873
|
+
const res = await fetch(`${baseUrl}${path3}`, {
|
|
894
874
|
signal: AbortSignal.timeout(timeoutMs)
|
|
895
875
|
});
|
|
896
876
|
if (!res.ok) return null;
|
|
@@ -919,52 +899,6 @@ function createObservabilityClient(opts = {}) {
|
|
|
919
899
|
}
|
|
920
900
|
|
|
921
901
|
// packages/domain/shared/src/index.ts
|
|
922
|
-
var isBrowser4 = typeof window !== "undefined" || typeof document !== "undefined";
|
|
923
|
-
var nodeModuleRef3 = null;
|
|
924
|
-
function getNodeModuleRef3() {
|
|
925
|
-
if (isBrowser4) return null;
|
|
926
|
-
if (nodeModuleRef3 !== null) return nodeModuleRef3;
|
|
927
|
-
try {
|
|
928
|
-
const test = typeof __require === "function" ? __require("module") : null;
|
|
929
|
-
nodeModuleRef3 = test;
|
|
930
|
-
return test;
|
|
931
|
-
} catch {
|
|
932
|
-
nodeModuleRef3 = null;
|
|
933
|
-
return null;
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
var _nodeCrypto = null;
|
|
937
|
-
var _nodeFs3 = null;
|
|
938
|
-
var _nodePath3 = null;
|
|
939
|
-
var _nodeUrl2 = null;
|
|
940
|
-
function getNodeCrypto() {
|
|
941
|
-
if (isBrowser4) throw new Error("node:crypto not available in browser");
|
|
942
|
-
const nodeRequire = getNodeModuleRef3();
|
|
943
|
-
if (!nodeRequire) throw new Error("require not available");
|
|
944
|
-
if (!_nodeCrypto) _nodeCrypto = nodeRequire.createRequire(import.meta.url)("node:crypto");
|
|
945
|
-
return _nodeCrypto;
|
|
946
|
-
}
|
|
947
|
-
function getNodeFs3() {
|
|
948
|
-
if (isBrowser4) throw new Error("node:fs not available in browser");
|
|
949
|
-
const nodeRequire = getNodeModuleRef3();
|
|
950
|
-
if (!nodeRequire) throw new Error("require not available");
|
|
951
|
-
if (!_nodeFs3) _nodeFs3 = nodeRequire.createRequire(import.meta.url)("node:fs");
|
|
952
|
-
return _nodeFs3;
|
|
953
|
-
}
|
|
954
|
-
function getNodePath3() {
|
|
955
|
-
if (isBrowser4) throw new Error("node:path not available in browser");
|
|
956
|
-
const nodeRequire = getNodeModuleRef3();
|
|
957
|
-
if (!nodeRequire) throw new Error("require not available");
|
|
958
|
-
if (!_nodePath3) _nodePath3 = nodeRequire.createRequire(import.meta.url)("node:path");
|
|
959
|
-
return _nodePath3;
|
|
960
|
-
}
|
|
961
|
-
function getNodeUrl2() {
|
|
962
|
-
if (isBrowser4) throw new Error("node:url not available in browser");
|
|
963
|
-
const nodeRequire = getNodeModuleRef3();
|
|
964
|
-
if (!nodeRequire) throw new Error("require not available");
|
|
965
|
-
if (!_nodeUrl2) _nodeUrl2 = nodeRequire.createRequire(import.meta.url)("node:url");
|
|
966
|
-
return _nodeUrl2;
|
|
967
|
-
}
|
|
968
902
|
function createLogger(namespace) {
|
|
969
903
|
const prefix = `[${namespace}]`;
|
|
970
904
|
return {
|
|
@@ -994,9 +928,9 @@ function createDebugLogger(namespace, label) {
|
|
|
994
928
|
}
|
|
995
929
|
};
|
|
996
930
|
}
|
|
997
|
-
function formatIssuePath(
|
|
998
|
-
if (!
|
|
999
|
-
return
|
|
931
|
+
function formatIssuePath(path3) {
|
|
932
|
+
if (!path3 || path3.length === 0) return "(root)";
|
|
933
|
+
return path3.map(
|
|
1000
934
|
(segment) => typeof segment === "symbol" ? segment.description ?? segment.toString() : String(segment)
|
|
1001
935
|
).join(".");
|
|
1002
936
|
}
|
|
@@ -1033,8 +967,8 @@ var TwError = class _TwError extends Error {
|
|
|
1033
967
|
/** Buat TwError dari ZodError — dukung shape Zod v3 (`errors`) dan v4 (`issues`). */
|
|
1034
968
|
static fromZod(err) {
|
|
1035
969
|
const first = err.issues?.[0] ?? err.errors?.[0];
|
|
1036
|
-
const
|
|
1037
|
-
const message = first ? `${
|
|
970
|
+
const path3 = formatIssuePath(first?.path);
|
|
971
|
+
const message = first ? `${path3}: ${first.message}` : "Schema validation failed";
|
|
1038
972
|
return new _TwError("validation", "SCHEMA_VALIDATION_FAILED", message, err);
|
|
1039
973
|
}
|
|
1040
974
|
static wrap(source, code, err) {
|
|
@@ -1059,17 +993,12 @@ function isTwError(err) {
|
|
|
1059
993
|
return err instanceof TwError;
|
|
1060
994
|
}
|
|
1061
995
|
function loadNativeBinding(options) {
|
|
1062
|
-
if (isBrowser4) {
|
|
1063
|
-
return { binding: null, loadErrors: [{ path: "", message: "Native bindings not available in browser" }] };
|
|
1064
|
-
}
|
|
1065
996
|
const { runtimeDir, candidates, isValid } = options;
|
|
1066
997
|
const loadErrors = [];
|
|
1067
|
-
const path = getNodePath3();
|
|
1068
|
-
const fs = getNodeFs3();
|
|
1069
998
|
for (const candidate of candidates) {
|
|
1070
|
-
const candidatePath =
|
|
999
|
+
const candidatePath = path__default.resolve(runtimeDir, candidate);
|
|
1071
1000
|
try {
|
|
1072
|
-
if (!
|
|
1001
|
+
if (!fs2__default.existsSync(candidatePath) && !fs2__default.existsSync(candidatePath + ".node")) {
|
|
1073
1002
|
continue;
|
|
1074
1003
|
}
|
|
1075
1004
|
const mod = requireNativeModule(candidatePath);
|
|
@@ -1083,76 +1012,56 @@ function loadNativeBinding(options) {
|
|
|
1083
1012
|
}
|
|
1084
1013
|
return { binding: null, loadErrors };
|
|
1085
1014
|
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
});
|
|
1090
|
-
const nodeRequire = getNodeModuleRef3();
|
|
1091
|
-
if (!nodeRequire) return (() => {
|
|
1092
|
-
throw new Error("require not available");
|
|
1093
|
-
});
|
|
1094
|
-
return nodeRequire.createRequire(import.meta.url);
|
|
1095
|
-
}
|
|
1096
|
-
var _require2 = getRequire2();
|
|
1097
|
-
function requireNativeModule(path) {
|
|
1098
|
-
return _require2(path);
|
|
1015
|
+
var _require2 = createRequire(import.meta.url);
|
|
1016
|
+
function requireNativeModule(p) {
|
|
1017
|
+
return _require2(p);
|
|
1099
1018
|
}
|
|
1100
1019
|
function resolveNativeBindingCandidates(options) {
|
|
1101
|
-
|
|
1102
|
-
|
|
1020
|
+
const {
|
|
1021
|
+
envVarNames = ["TW_NATIVE_PATH", "TWS_NATIVE_PATH"],
|
|
1022
|
+
includeDefaultCandidates = true,
|
|
1023
|
+
enforceNodeExtensionForEnvPath = false
|
|
1024
|
+
} = options;
|
|
1025
|
+
const runtimeDir = options.runtimeDir || process.cwd();
|
|
1103
1026
|
const candidates = [];
|
|
1104
|
-
const path = getNodePath3();
|
|
1105
|
-
const fs = getNodeFs3();
|
|
1106
1027
|
for (const envVar of envVarNames) {
|
|
1107
1028
|
const envPath = process.env[envVar];
|
|
1108
1029
|
if (envPath) {
|
|
1109
|
-
|
|
1110
|
-
candidates.push(envPath + ".node");
|
|
1111
|
-
} else {
|
|
1112
|
-
candidates.push(envPath);
|
|
1113
|
-
}
|
|
1030
|
+
candidates.push(enforceNodeExtensionForEnvPath && !envPath.endsWith(".node") ? envPath + ".node" : envPath);
|
|
1114
1031
|
}
|
|
1115
1032
|
}
|
|
1116
1033
|
if (!includeDefaultCandidates) return candidates;
|
|
1117
|
-
if (
|
|
1034
|
+
if (fs2__default.existsSync(runtimeDir)) {
|
|
1118
1035
|
try {
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1121
|
-
if (entry.endsWith(".node")) {
|
|
1122
|
-
candidates.push(entry);
|
|
1123
|
-
}
|
|
1036
|
+
for (const entry of fs2__default.readdirSync(runtimeDir)) {
|
|
1037
|
+
if (entry.endsWith(".node")) candidates.push(entry);
|
|
1124
1038
|
}
|
|
1125
1039
|
} catch {
|
|
1126
1040
|
}
|
|
1127
1041
|
}
|
|
1128
|
-
const
|
|
1129
|
-
const
|
|
1130
|
-
const
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1042
|
+
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
1043
|
+
const napiPlatform = process.platform === "linux" && process.arch === "x64" ? "linux-x64-gnu" : process.platform === "linux" && process.arch === "arm64" ? "linux-arm64-gnu" : `${process.platform}-${process.arch}`;
|
|
1044
|
+
for (const bin of BINARY_NAMES) {
|
|
1045
|
+
candidates.push(path__default.resolve(runtimeDir, `${bin}.node`));
|
|
1046
|
+
candidates.push(path__default.resolve(runtimeDir, `${bin}.${napiPlatform}.node`));
|
|
1047
|
+
candidates.push(path__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.node`));
|
|
1048
|
+
candidates.push(path__default.resolve(runtimeDir, "..", "..", "..", "..", "native", `${bin}.${napiPlatform}.node`));
|
|
1049
|
+
candidates.push(path__default.resolve(runtimeDir, "..", "..", "..", "native", `${bin}.node`));
|
|
1050
|
+
candidates.push(path__default.resolve(process.cwd(), "native", `${bin}.node`));
|
|
1051
|
+
candidates.push(path__default.resolve(process.cwd(), "native", `${bin}.${napiPlatform}.node`));
|
|
1052
|
+
}
|
|
1134
1053
|
return Array.from(new Set(candidates));
|
|
1135
1054
|
}
|
|
1136
1055
|
function resolveRuntimeDir(dir, importMetaUrl) {
|
|
1137
|
-
if (
|
|
1138
|
-
if (dir) return getNodePath3().resolve(dir);
|
|
1056
|
+
if (dir) return path__default.resolve(dir);
|
|
1139
1057
|
try {
|
|
1140
|
-
return
|
|
1058
|
+
return path__default.dirname(fileURLToPath(importMetaUrl));
|
|
1141
1059
|
} catch {
|
|
1142
1060
|
return process.cwd();
|
|
1143
1061
|
}
|
|
1144
1062
|
}
|
|
1145
1063
|
function hashContent(content, algorithm = "md5", length) {
|
|
1146
|
-
|
|
1147
|
-
let hash2 = 0;
|
|
1148
|
-
for (let i = 0; i < content.length; i++) {
|
|
1149
|
-
const char = content.charCodeAt(i);
|
|
1150
|
-
hash2 = (hash2 << 5) - hash2 + char;
|
|
1151
|
-
hash2 = hash2 & hash2;
|
|
1152
|
-
}
|
|
1153
|
-
return Math.abs(hash2).toString(16).slice(0, length ?? 8);
|
|
1154
|
-
}
|
|
1155
|
-
const hash = getNodeCrypto().createHash(algorithm).update(content).digest("hex");
|
|
1064
|
+
const hash = createHash(algorithm).update(content).digest("hex");
|
|
1156
1065
|
return length ? hash.slice(0, length) : hash;
|
|
1157
1066
|
}
|
|
1158
1067
|
function formatErrorMessage(error) {
|