@luckylillia-dev/luckylillia 9.0.3 → 9.0.5

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/llbot-core.js CHANGED
@@ -1,9 +1,9 @@
1
- import { $ as Hono, A as Registries, At as require_dist, B as installHostLifecycle, Bt as getPluginDirs, C as scanPluginRoots, Ct as normalizeScope, D as removeScannedPackage, Dt as deepMerge, E as cleanupRemovedPackages, Et as platform_exports, F as parseSpec, G as GATEWAY_SECRET_HEADER, Gt as LOG_DIR, Ht as isDockerEnvironment, I as pickVersion, J as isManaged, Jt as globalVars_exports, L as lockInstance, M as isExactVersion, Mt as configPaths_exports, N as isPackageName, Nt as currentInstance, O as scannedPackagePath, Ot as mergeNewProperties, P as matches, Pt as instance_exports, Q as version_exports, Qt as __toESM, S as resolveMain, St as acceptsScope, T as sdkRangeOf, Tt as normalizePlatformId, Ut as isPluginHmr, Vt as isDevMode, W as GATEWAY_SECRET_ENV, Wt as DATA_DIR, X as protocol_exports, Xt as __exportAll, Y as isManagerMessage, Yt as __commonJSMin, Z as version$10, Zt as __require, _ as manifest_exports, _t as templateSection, at as migrateRenamedPackages, b as parsePluginDependencies, bt as newEntryId, c as marketSettings, ct as renameNativeQQSettings, d as extractPackage, dt as renamed_exports, et as HtmlEscapedCallbackPhase, f as readTarStream, ft as withCurrentNames, g as isInside, gt as templateConfig, h as isImagePath, ht as DEPRECATED_KEYS, it as migrateNTQQMessaging, j as RegistryError, jt as configPaths, k as require_semver, kt as JsonFile, l as registriesOf, lt as RENAMED_PACKAGES, m as SDK_PACKAGE, mt as ADAPTER_KEYS, nt as liftBuiltinSettings, ot as migrateToInstances, p as PLUGIN_CATEGORIES, pt as ADAPTER_ENTRIES, qt as TEMP_DIR, r as coreUpdate_exports, rt as migrateExtractedPlugins, s as MarketSchema, st as migrateWebuiToken, tt as resolveCallback, u as Catalog, ut as currentPackageName, v as matchesPluginVersion, vt as upgradeConfig, w as sdkIncompatibility, wt as normalizePlatform, x as readPluginPackage, xt as normalizeUi, y as normalizeService, yt as PluginStore, zt as environment_exports } from "./chunks/coreUpdate-FeEAjxU_.js";
1
+ import { $ as Hono, A as Registries, At as require_dist, B as installHostLifecycle, Bt as getPluginDirs, C as scanPluginRoots, Ct as normalizeScope, D as removeScannedPackage, Dt as deepMerge, E as cleanupRemovedPackages, Et as platform_exports, F as parseSpec, G as GATEWAY_SECRET_HEADER, Gt as LOG_DIR, Ht as isDockerEnvironment, I as pickVersion, J as isManaged, Jt as globalVars_exports, L as lockInstance, M as isExactVersion, Mt as configPaths_exports, N as isPackageName, Nt as currentInstance, O as scannedPackagePath, Ot as mergeNewProperties, P as matches, Pt as instance_exports, Q as version_exports, Qt as __toESM, S as resolveMain, St as acceptsScope, T as sdkRangeOf, Tt as normalizePlatformId, Ut as isPluginHmr, Vt as isDevMode, W as GATEWAY_SECRET_ENV, Wt as DATA_DIR, X as protocol_exports, Xt as __exportAll, Y as isManagerMessage, Yt as __commonJSMin, Z as version$10, Zt as __require, _ as manifest_exports, _t as templateSection, at as migrateRenamedPackages, b as parsePluginDependencies, bt as newEntryId, c as marketSettings, ct as renameNativeQQSettings, d as extractPackage, dt as renamed_exports, et as HtmlEscapedCallbackPhase, f as readTarStream, ft as withCurrentNames, g as isInside, gt as templateConfig, h as isImagePath, ht as DEPRECATED_KEYS, it as migrateNTQQMessaging, j as RegistryError, jt as configPaths, k as require_semver, kt as JsonFile, l as registriesOf, lt as RENAMED_PACKAGES, m as SDK_PACKAGE, mt as ADAPTER_KEYS, nt as liftBuiltinSettings, ot as migrateToInstances, p as PLUGIN_CATEGORIES, pt as ADAPTER_ENTRIES, qt as TEMP_DIR, r as coreUpdate_exports, rt as migrateExtractedPlugins, s as MarketSchema, st as migrateWebuiToken, tt as resolveCallback, u as Catalog, ut as currentPackageName, v as matchesPluginVersion, vt as upgradeConfig, w as sdkIncompatibility, wt as normalizePlatform, x as readPluginPackage, xt as normalizeUi, y as normalizeService, yt as PluginStore, zt as environment_exports } from "./chunks/coreUpdate-DyKGU2VM.js";
2
2
  import { p as compareVersions } from "./chunks/restart-TVy8kurW.js";
3
3
  import { t as __vitePreload } from "./chunks/preload-helper-DxWiKyOd.js";
4
4
  import * as nodeModule from "node:module";
5
5
  import { createRequire } from "node:module";
6
- import fs, { appendFile, appendFileSync, createReadStream, createWriteStream, existsSync, mkdirSync, realpathSync, stat, statSync, watch } from "node:fs";
6
+ import fs, { appendFile, appendFileSync, createReadStream, createWriteStream, existsSync, mkdirSync, readFileSync, realpathSync, stat, statSync, watch } from "node:fs";
7
7
  import path, { dirname, join } from "node:path";
8
8
  import { fileURLToPath, pathToFileURL } from "node:url";
9
9
  import { execFile } from "node:child_process";
@@ -707,6 +707,8 @@ var resolve_hook_exports = /* @__PURE__ */ __exportAll({
707
707
  LEGACY_SPECIFIERS: () => LEGACY_SPECIFIERS,
708
708
  SHARED_SPECIFIERS: () => SHARED_SPECIFIERS,
709
709
  installPluginResolver: () => installPluginResolver,
710
+ isCommonJS: () => isCommonJS,
711
+ isModulePackage: () => isModulePackage,
710
712
  resolvePluginSpecifier: () => resolvePluginSpecifier,
711
713
  sharedSpecifierMap: () => sharedSpecifierMap
712
714
  });
@@ -735,10 +737,13 @@ function sharedSpecifierMap() {
735
737
  }
736
738
  /**
737
739
  * Two jobs: pin shared packages to the host copy, and copy the `?v=` reload epoch from a plugin module
738
- * to the modules it imports inside the same package. Without the latter only the entry would be
739
- * re-evaluated on reload and every relative import would come back from the ESM cache.
740
+ * to the ES modules it imports inside the same package. Without the latter only the entry would be
741
+ * re-evaluated on reload and every relative import would come back from the ESM cache. CommonJS files keep
742
+ * their plain URL: imported with a query, Node evaluates them apart from require() and their exports come out
743
+ * wrong (a reload of the NTQQ plugin failed on `debug`, imported by an ES module in its node_modules). The host
744
+ * clears them from require.cache for a reload instead.
740
745
  */
741
- function resolvePluginSpecifier(state, specifier, context, nextResolve) {
746
+ function resolvePluginSpecifier(state, specifier, context, nextResolve, moduleType = isModulePackage) {
742
747
  const internal = builtinRuntimeModule(specifier);
743
748
  if (internal) return {
744
749
  url: internal,
@@ -755,7 +760,7 @@ function resolvePluginSpecifier(state, specifier, context, nextResolve) {
755
760
  const epoch = new URL(parent).searchParams.get("v");
756
761
  if (!epoch) return result;
757
762
  const root = packageRootOf(state.roots, parent);
758
- if (!root || !stripQuery(result.url).startsWith(root)) return result;
763
+ if (!root || !stripQuery(result.url).startsWith(root) || isCommonJS(result.url, moduleType)) return result;
759
764
  const url = new URL(result.url);
760
765
  url.searchParams.set("v", epoch);
761
766
  return {
@@ -776,6 +781,40 @@ function packageRootOf(roots, url) {
776
781
  for (const root of roots) if (bare.startsWith(root) && (!best || root.length > best.length)) best = root;
777
782
  return best;
778
783
  }
784
+ var packageTypes = /* @__PURE__ */ new Map();
785
+ /**
786
+ * Whether the nearest package.json of a directory (a file URL) says "type": "module". Read once per directory:
787
+ * a reload does not change it.
788
+ */
789
+ function isModulePackage(dirUrl) {
790
+ let dir;
791
+ try {
792
+ dir = fileURLToPath(dirUrl);
793
+ } catch {
794
+ return false;
795
+ }
796
+ return moduleIn(path.resolve(dir));
797
+ }
798
+ function moduleIn(dir) {
799
+ const known = packageTypes.get(dir);
800
+ if (known !== void 0) return known;
801
+ let module;
802
+ try {
803
+ module = JSON.parse(readFileSync(path.join(dir, "package.json"), "utf8")).type === "module";
804
+ } catch {
805
+ const parent = path.dirname(dir);
806
+ module = parent !== dir && moduleIn(parent);
807
+ }
808
+ packageTypes.set(dir, module);
809
+ return module;
810
+ }
811
+ /** How Node decides it: .cjs, or .js without "type": "module" in the nearest package.json. */
812
+ function isCommonJS(url, moduleType) {
813
+ const bare = stripQuery(url);
814
+ if (bare.endsWith(".cjs")) return true;
815
+ if (!bare.endsWith(".js")) return false;
816
+ return !moduleType(new URL(".", bare).href);
817
+ }
779
818
  function stripQuery(url) {
780
819
  const index = url.search(/[?#]/);
781
820
  return index < 0 ? url : url.slice(0, index);