@naylence/runtime 0.3.5-test.913 → 0.3.5-test.915

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.
@@ -5364,12 +5364,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
5364
5364
  }
5365
5365
 
5366
5366
  // This file is auto-generated during build - do not edit manually
5367
- // Generated from package.json version: 0.3.5-test.913
5367
+ // Generated from package.json version: 0.3.5-test.915
5368
5368
  /**
5369
5369
  * The package version, injected at build time.
5370
5370
  * @internal
5371
5371
  */
5372
- const VERSION = '0.3.5-test.913';
5372
+ const VERSION = '0.3.5-test.915';
5373
5373
 
5374
5374
  /**
5375
5375
  * Fame errors module - Fame protocol specific error classes
@@ -14707,47 +14707,125 @@ const currentModuleUrl = (() => {
14707
14707
  return undefined;
14708
14708
  }
14709
14709
  })();
14710
- // Shared flag that allows synchronous waiting for the Node-specific require shim
14711
- const requireReadyFlag = isNode && typeof SharedArrayBuffer !== 'undefined'
14712
- ? new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))
14713
- : null;
14714
- if (requireReadyFlag) {
14715
- // 0 means initializing, 1 means ready (success or failure)
14716
- Atomics.store(requireReadyFlag, 0, 0);
14717
- // Prepare a CommonJS-style require when running in pure ESM contexts
14718
- void (async () => {
14719
- try {
14720
- if (typeof require !== 'function') {
14721
- const moduleNamespace = (await import('node:module'));
14722
- const createRequire = moduleNamespace.createRequire;
14723
- if (typeof createRequire === 'function') {
14724
- const fallbackPath = `${process.cwd()}/.__naylence_require_shim__.mjs`;
14725
- const nodeRequire = createRequire(currentModuleUrl ?? fallbackPath);
14726
- globalThis.require = nodeRequire;
14710
+ let cachedNodeRequire = typeof require === 'function' ? require : null;
14711
+ function createFsShim() {
14712
+ if (!isNode) {
14713
+ return null;
14714
+ }
14715
+ const processBinding = process.binding;
14716
+ if (typeof processBinding !== 'function') {
14717
+ return null;
14718
+ }
14719
+ try {
14720
+ const fsBinding = processBinding('fs');
14721
+ if (!fsBinding || typeof fsBinding.readFileUtf8 !== 'function') {
14722
+ return null;
14723
+ }
14724
+ const shim = {
14725
+ readFileSync: (...args) => {
14726
+ const [pathOrDescriptor, options] = args;
14727
+ if (typeof pathOrDescriptor !== 'string') {
14728
+ throw new Error('FS shim only supports string file paths');
14727
14729
  }
14728
- }
14730
+ let encoding;
14731
+ if (typeof options === 'string') {
14732
+ encoding = options;
14733
+ }
14734
+ else if (options &&
14735
+ typeof options === 'object' &&
14736
+ 'encoding' in options &&
14737
+ typeof options.encoding === 'string') {
14738
+ encoding = options.encoding;
14739
+ }
14740
+ const data = fsBinding.readFileUtf8(pathOrDescriptor, 0);
14741
+ if (!encoding) {
14742
+ return typeof Buffer !== 'undefined'
14743
+ ? Buffer.from(data, 'utf-8')
14744
+ : data;
14745
+ }
14746
+ const lowered = encoding.toLowerCase();
14747
+ if (lowered === 'utf-8' || lowered === 'utf8') {
14748
+ return data;
14749
+ }
14750
+ if (typeof Buffer === 'undefined') {
14751
+ throw new Error(`Buffer API is not available to convert encoding ${String(encoding)}`);
14752
+ }
14753
+ return Buffer.from(data, 'utf-8').toString(encoding);
14754
+ },
14755
+ existsSync: (...args) => {
14756
+ const [pathLike] = args;
14757
+ if (typeof pathLike !== 'string') {
14758
+ return false;
14759
+ }
14760
+ if (typeof fsBinding.existsSync === 'function') {
14761
+ try {
14762
+ return Boolean(fsBinding.existsSync(pathLike));
14763
+ }
14764
+ catch {
14765
+ // fall through to the internal stat fallback
14766
+ }
14767
+ }
14768
+ if (typeof fsBinding.internalModuleStat === 'function') {
14769
+ try {
14770
+ return (fsBinding.internalModuleStat(pathLike) >= 0);
14771
+ }
14772
+ catch {
14773
+ return false;
14774
+ }
14775
+ }
14776
+ return false;
14777
+ },
14778
+ };
14779
+ return shim;
14780
+ }
14781
+ catch {
14782
+ return null;
14783
+ }
14784
+ }
14785
+ function fileUrlToPath(url) {
14786
+ try {
14787
+ const parsed = new URL(url);
14788
+ if (parsed.protocol !== 'file:') {
14789
+ return null;
14729
14790
  }
14730
- catch {
14731
- // Ignore failures getFsModule will surface a helpful error when needed
14732
- }
14733
- })()
14734
- .catch(() => {
14735
- // Ignore async errors – the ready flag will still unblock consumers
14736
- })
14737
- .finally(() => {
14738
- Atomics.store(requireReadyFlag, 0, 1);
14739
- Atomics.notify(requireReadyFlag, 0);
14740
- });
14791
+ let pathname = parsed.pathname;
14792
+ if (typeof process !== 'undefined' &&
14793
+ process.platform === 'win32' &&
14794
+ pathname.startsWith('/')) {
14795
+ pathname = pathname.slice(1);
14796
+ }
14797
+ return decodeURIComponent(pathname);
14798
+ }
14799
+ catch {
14800
+ return null;
14801
+ }
14741
14802
  }
14742
- function ensureRequireReady() {
14743
- if (!requireReadyFlag) {
14744
- return;
14803
+ function getNodeRequire() {
14804
+ if (cachedNodeRequire) {
14805
+ return cachedNodeRequire;
14745
14806
  }
14746
- if (Atomics.load(requireReadyFlag, 0) === 1) {
14747
- return;
14807
+ if (!isNode) {
14808
+ return null;
14809
+ }
14810
+ const processBinding = process.binding;
14811
+ if (typeof processBinding !== 'function') {
14812
+ return null;
14813
+ }
14814
+ try {
14815
+ const moduleWrap = processBinding('module_wrap');
14816
+ if (typeof moduleWrap?.createRequire !== 'function') {
14817
+ return null;
14818
+ }
14819
+ const modulePathFromUrl = currentModuleUrl
14820
+ ? fileUrlToPath(currentModuleUrl)
14821
+ : null;
14822
+ const requireSource = modulePathFromUrl ?? `${process.cwd()}/.naylence-require-shim.js`;
14823
+ cachedNodeRequire = moduleWrap.createRequire(requireSource);
14824
+ return cachedNodeRequire;
14825
+ }
14826
+ catch {
14827
+ return null;
14748
14828
  }
14749
- // Block until the asynchronous loader finishes initialising
14750
- Atomics.wait(requireReadyFlag, 0, 0);
14751
14829
  }
14752
14830
  function getFsModule() {
14753
14831
  if (cachedFsModule) {
@@ -14756,16 +14834,21 @@ function getFsModule() {
14756
14834
  if (!isNode) {
14757
14835
  throw new Error('File system access is not available in this environment');
14758
14836
  }
14759
- ensureRequireReady();
14760
- if (typeof require === 'function') {
14837
+ const nodeRequire = typeof require === 'function' ? require : getNodeRequire();
14838
+ if (nodeRequire) {
14761
14839
  try {
14762
- cachedFsModule = require(fsModuleSpecifier);
14840
+ cachedFsModule = nodeRequire(fsModuleSpecifier);
14763
14841
  return cachedFsModule;
14764
14842
  }
14765
14843
  catch (error) {
14766
14844
  throw new Error(`Unable to load file system module: ${error instanceof Error ? error.message : String(error)}`);
14767
14845
  }
14768
14846
  }
14847
+ const shim = createFsShim();
14848
+ if (shim) {
14849
+ cachedFsModule = shim;
14850
+ return cachedFsModule;
14851
+ }
14769
14852
  throw new Error('File system module is not accessible in this environment');
14770
14853
  }
14771
14854
  function readConfigFile(filePath) {
@@ -5363,12 +5363,12 @@ for (const [name, config] of Object.entries(SQLITE_PROFILES)) {
5363
5363
  }
5364
5364
 
5365
5365
  // This file is auto-generated during build - do not edit manually
5366
- // Generated from package.json version: 0.3.5-test.913
5366
+ // Generated from package.json version: 0.3.5-test.915
5367
5367
  /**
5368
5368
  * The package version, injected at build time.
5369
5369
  * @internal
5370
5370
  */
5371
- const VERSION = '0.3.5-test.913';
5371
+ const VERSION = '0.3.5-test.915';
5372
5372
 
5373
5373
  /**
5374
5374
  * Fame errors module - Fame protocol specific error classes
@@ -14706,47 +14706,125 @@ const currentModuleUrl = (() => {
14706
14706
  return undefined;
14707
14707
  }
14708
14708
  })();
14709
- // Shared flag that allows synchronous waiting for the Node-specific require shim
14710
- const requireReadyFlag = isNode && typeof SharedArrayBuffer !== 'undefined'
14711
- ? new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))
14712
- : null;
14713
- if (requireReadyFlag) {
14714
- // 0 means initializing, 1 means ready (success or failure)
14715
- Atomics.store(requireReadyFlag, 0, 0);
14716
- // Prepare a CommonJS-style require when running in pure ESM contexts
14717
- void (async () => {
14718
- try {
14719
- if (typeof require !== 'function') {
14720
- const moduleNamespace = (await import('node:module'));
14721
- const createRequire = moduleNamespace.createRequire;
14722
- if (typeof createRequire === 'function') {
14723
- const fallbackPath = `${process.cwd()}/.__naylence_require_shim__.mjs`;
14724
- const nodeRequire = createRequire(currentModuleUrl ?? fallbackPath);
14725
- globalThis.require = nodeRequire;
14709
+ let cachedNodeRequire = typeof require === 'function' ? require : null;
14710
+ function createFsShim() {
14711
+ if (!isNode) {
14712
+ return null;
14713
+ }
14714
+ const processBinding = process.binding;
14715
+ if (typeof processBinding !== 'function') {
14716
+ return null;
14717
+ }
14718
+ try {
14719
+ const fsBinding = processBinding('fs');
14720
+ if (!fsBinding || typeof fsBinding.readFileUtf8 !== 'function') {
14721
+ return null;
14722
+ }
14723
+ const shim = {
14724
+ readFileSync: (...args) => {
14725
+ const [pathOrDescriptor, options] = args;
14726
+ if (typeof pathOrDescriptor !== 'string') {
14727
+ throw new Error('FS shim only supports string file paths');
14726
14728
  }
14727
- }
14729
+ let encoding;
14730
+ if (typeof options === 'string') {
14731
+ encoding = options;
14732
+ }
14733
+ else if (options &&
14734
+ typeof options === 'object' &&
14735
+ 'encoding' in options &&
14736
+ typeof options.encoding === 'string') {
14737
+ encoding = options.encoding;
14738
+ }
14739
+ const data = fsBinding.readFileUtf8(pathOrDescriptor, 0);
14740
+ if (!encoding) {
14741
+ return typeof Buffer !== 'undefined'
14742
+ ? Buffer.from(data, 'utf-8')
14743
+ : data;
14744
+ }
14745
+ const lowered = encoding.toLowerCase();
14746
+ if (lowered === 'utf-8' || lowered === 'utf8') {
14747
+ return data;
14748
+ }
14749
+ if (typeof Buffer === 'undefined') {
14750
+ throw new Error(`Buffer API is not available to convert encoding ${String(encoding)}`);
14751
+ }
14752
+ return Buffer.from(data, 'utf-8').toString(encoding);
14753
+ },
14754
+ existsSync: (...args) => {
14755
+ const [pathLike] = args;
14756
+ if (typeof pathLike !== 'string') {
14757
+ return false;
14758
+ }
14759
+ if (typeof fsBinding.existsSync === 'function') {
14760
+ try {
14761
+ return Boolean(fsBinding.existsSync(pathLike));
14762
+ }
14763
+ catch {
14764
+ // fall through to the internal stat fallback
14765
+ }
14766
+ }
14767
+ if (typeof fsBinding.internalModuleStat === 'function') {
14768
+ try {
14769
+ return (fsBinding.internalModuleStat(pathLike) >= 0);
14770
+ }
14771
+ catch {
14772
+ return false;
14773
+ }
14774
+ }
14775
+ return false;
14776
+ },
14777
+ };
14778
+ return shim;
14779
+ }
14780
+ catch {
14781
+ return null;
14782
+ }
14783
+ }
14784
+ function fileUrlToPath(url) {
14785
+ try {
14786
+ const parsed = new URL(url);
14787
+ if (parsed.protocol !== 'file:') {
14788
+ return null;
14728
14789
  }
14729
- catch {
14730
- // Ignore failures getFsModule will surface a helpful error when needed
14731
- }
14732
- })()
14733
- .catch(() => {
14734
- // Ignore async errors – the ready flag will still unblock consumers
14735
- })
14736
- .finally(() => {
14737
- Atomics.store(requireReadyFlag, 0, 1);
14738
- Atomics.notify(requireReadyFlag, 0);
14739
- });
14790
+ let pathname = parsed.pathname;
14791
+ if (typeof process !== 'undefined' &&
14792
+ process.platform === 'win32' &&
14793
+ pathname.startsWith('/')) {
14794
+ pathname = pathname.slice(1);
14795
+ }
14796
+ return decodeURIComponent(pathname);
14797
+ }
14798
+ catch {
14799
+ return null;
14800
+ }
14740
14801
  }
14741
- function ensureRequireReady() {
14742
- if (!requireReadyFlag) {
14743
- return;
14802
+ function getNodeRequire() {
14803
+ if (cachedNodeRequire) {
14804
+ return cachedNodeRequire;
14744
14805
  }
14745
- if (Atomics.load(requireReadyFlag, 0) === 1) {
14746
- return;
14806
+ if (!isNode) {
14807
+ return null;
14808
+ }
14809
+ const processBinding = process.binding;
14810
+ if (typeof processBinding !== 'function') {
14811
+ return null;
14812
+ }
14813
+ try {
14814
+ const moduleWrap = processBinding('module_wrap');
14815
+ if (typeof moduleWrap?.createRequire !== 'function') {
14816
+ return null;
14817
+ }
14818
+ const modulePathFromUrl = currentModuleUrl
14819
+ ? fileUrlToPath(currentModuleUrl)
14820
+ : null;
14821
+ const requireSource = modulePathFromUrl ?? `${process.cwd()}/.naylence-require-shim.js`;
14822
+ cachedNodeRequire = moduleWrap.createRequire(requireSource);
14823
+ return cachedNodeRequire;
14824
+ }
14825
+ catch {
14826
+ return null;
14747
14827
  }
14748
- // Block until the asynchronous loader finishes initialising
14749
- Atomics.wait(requireReadyFlag, 0, 0);
14750
14828
  }
14751
14829
  function getFsModule() {
14752
14830
  if (cachedFsModule) {
@@ -14755,16 +14833,21 @@ function getFsModule() {
14755
14833
  if (!isNode) {
14756
14834
  throw new Error('File system access is not available in this environment');
14757
14835
  }
14758
- ensureRequireReady();
14759
- if (typeof require === 'function') {
14836
+ const nodeRequire = typeof require === 'function' ? require : getNodeRequire();
14837
+ if (nodeRequire) {
14760
14838
  try {
14761
- cachedFsModule = require(fsModuleSpecifier);
14839
+ cachedFsModule = nodeRequire(fsModuleSpecifier);
14762
14840
  return cachedFsModule;
14763
14841
  }
14764
14842
  catch (error) {
14765
14843
  throw new Error(`Unable to load file system module: ${error instanceof Error ? error.message : String(error)}`);
14766
14844
  }
14767
14845
  }
14846
+ const shim = createFsShim();
14847
+ if (shim) {
14848
+ cachedFsModule = shim;
14849
+ return cachedFsModule;
14850
+ }
14768
14851
  throw new Error('File system module is not accessible in this environment');
14769
14852
  }
14770
14853
  function readConfigFile(filePath) {
@@ -2,4 +2,4 @@
2
2
  * The package version, injected at build time.
3
3
  * @internal
4
4
  */
5
- export declare const VERSION = "0.3.5-test.913";
5
+ export declare const VERSION = "0.3.5-test.915";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naylence/runtime",
3
- "version": "0.3.5-test.913",
3
+ "version": "0.3.5-test.915",
4
4
  "type": "module",
5
5
  "description": "Naylence Runtime - Complete TypeScript runtime",
6
6
  "author": "Naylence Dev <naylencedev@gmail.com>",