@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.
@@ -23,47 +23,125 @@ const currentModuleUrl = (() => {
23
23
  return undefined;
24
24
  }
25
25
  })();
26
- // Shared flag that allows synchronous waiting for the Node-specific require shim
27
- const requireReadyFlag = isNode && typeof SharedArrayBuffer !== 'undefined'
28
- ? new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))
29
- : null;
30
- if (requireReadyFlag) {
31
- // 0 means initializing, 1 means ready (success or failure)
32
- Atomics.store(requireReadyFlag, 0, 0);
33
- // Prepare a CommonJS-style require when running in pure ESM contexts
34
- void (async () => {
35
- try {
36
- if (typeof require !== 'function') {
37
- const moduleNamespace = (await import('node:module'));
38
- const createRequire = moduleNamespace.createRequire;
39
- if (typeof createRequire === 'function') {
40
- const fallbackPath = `${process.cwd()}/.__naylence_require_shim__.mjs`;
41
- const nodeRequire = createRequire(currentModuleUrl ?? fallbackPath);
42
- globalThis.require = nodeRequire;
26
+ let cachedNodeRequire = typeof require === 'function' ? require : null;
27
+ function createFsShim() {
28
+ if (!isNode) {
29
+ return null;
30
+ }
31
+ const processBinding = process.binding;
32
+ if (typeof processBinding !== 'function') {
33
+ return null;
34
+ }
35
+ try {
36
+ const fsBinding = processBinding('fs');
37
+ if (!fsBinding || typeof fsBinding.readFileUtf8 !== 'function') {
38
+ return null;
39
+ }
40
+ const shim = {
41
+ readFileSync: (...args) => {
42
+ const [pathOrDescriptor, options] = args;
43
+ if (typeof pathOrDescriptor !== 'string') {
44
+ throw new Error('FS shim only supports string file paths');
43
45
  }
44
- }
46
+ let encoding;
47
+ if (typeof options === 'string') {
48
+ encoding = options;
49
+ }
50
+ else if (options &&
51
+ typeof options === 'object' &&
52
+ 'encoding' in options &&
53
+ typeof options.encoding === 'string') {
54
+ encoding = options.encoding;
55
+ }
56
+ const data = fsBinding.readFileUtf8(pathOrDescriptor, 0);
57
+ if (!encoding) {
58
+ return typeof Buffer !== 'undefined'
59
+ ? Buffer.from(data, 'utf-8')
60
+ : data;
61
+ }
62
+ const lowered = encoding.toLowerCase();
63
+ if (lowered === 'utf-8' || lowered === 'utf8') {
64
+ return data;
65
+ }
66
+ if (typeof Buffer === 'undefined') {
67
+ throw new Error(`Buffer API is not available to convert encoding ${String(encoding)}`);
68
+ }
69
+ return Buffer.from(data, 'utf-8').toString(encoding);
70
+ },
71
+ existsSync: (...args) => {
72
+ const [pathLike] = args;
73
+ if (typeof pathLike !== 'string') {
74
+ return false;
75
+ }
76
+ if (typeof fsBinding.existsSync === 'function') {
77
+ try {
78
+ return Boolean(fsBinding.existsSync(pathLike));
79
+ }
80
+ catch {
81
+ // fall through to the internal stat fallback
82
+ }
83
+ }
84
+ if (typeof fsBinding.internalModuleStat === 'function') {
85
+ try {
86
+ return (fsBinding.internalModuleStat(pathLike) >= 0);
87
+ }
88
+ catch {
89
+ return false;
90
+ }
91
+ }
92
+ return false;
93
+ },
94
+ };
95
+ return shim;
96
+ }
97
+ catch {
98
+ return null;
99
+ }
100
+ }
101
+ function fileUrlToPath(url) {
102
+ try {
103
+ const parsed = new URL(url);
104
+ if (parsed.protocol !== 'file:') {
105
+ return null;
45
106
  }
46
- catch {
47
- // Ignore failures getFsModule will surface a helpful error when needed
107
+ let pathname = parsed.pathname;
108
+ if (typeof process !== 'undefined' &&
109
+ process.platform === 'win32' &&
110
+ pathname.startsWith('/')) {
111
+ pathname = pathname.slice(1);
48
112
  }
49
- })()
50
- .catch(() => {
51
- // Ignore async errors – the ready flag will still unblock consumers
52
- })
53
- .finally(() => {
54
- Atomics.store(requireReadyFlag, 0, 1);
55
- Atomics.notify(requireReadyFlag, 0);
56
- });
113
+ return decodeURIComponent(pathname);
114
+ }
115
+ catch {
116
+ return null;
117
+ }
57
118
  }
58
- function ensureRequireReady() {
59
- if (!requireReadyFlag) {
60
- return;
119
+ function getNodeRequire() {
120
+ if (cachedNodeRequire) {
121
+ return cachedNodeRequire;
61
122
  }
62
- if (Atomics.load(requireReadyFlag, 0) === 1) {
63
- return;
123
+ if (!isNode) {
124
+ return null;
125
+ }
126
+ const processBinding = process.binding;
127
+ if (typeof processBinding !== 'function') {
128
+ return null;
129
+ }
130
+ try {
131
+ const moduleWrap = processBinding('module_wrap');
132
+ if (typeof moduleWrap?.createRequire !== 'function') {
133
+ return null;
134
+ }
135
+ const modulePathFromUrl = currentModuleUrl
136
+ ? fileUrlToPath(currentModuleUrl)
137
+ : null;
138
+ const requireSource = modulePathFromUrl ?? `${process.cwd()}/.naylence-require-shim.js`;
139
+ cachedNodeRequire = moduleWrap.createRequire(requireSource);
140
+ return cachedNodeRequire;
141
+ }
142
+ catch {
143
+ return null;
64
144
  }
65
- // Block until the asynchronous loader finishes initialising
66
- Atomics.wait(requireReadyFlag, 0, 0);
67
145
  }
68
146
  function getFsModule() {
69
147
  if (cachedFsModule) {
@@ -72,16 +150,21 @@ function getFsModule() {
72
150
  if (!isNode) {
73
151
  throw new Error('File system access is not available in this environment');
74
152
  }
75
- ensureRequireReady();
76
- if (typeof require === 'function') {
153
+ const nodeRequire = typeof require === 'function' ? require : getNodeRequire();
154
+ if (nodeRequire) {
77
155
  try {
78
- cachedFsModule = require(fsModuleSpecifier);
156
+ cachedFsModule = nodeRequire(fsModuleSpecifier);
79
157
  return cachedFsModule;
80
158
  }
81
159
  catch (error) {
82
160
  throw new Error(`Unable to load file system module: ${error instanceof Error ? error.message : String(error)}`);
83
161
  }
84
162
  }
163
+ const shim = createFsShim();
164
+ if (shim) {
165
+ cachedFsModule = shim;
166
+ return cachedFsModule;
167
+ }
85
168
  throw new Error('File system module is not accessible in this environment');
86
169
  }
87
170
  function readConfigFile(filePath) {
@@ -1,7 +1,7 @@
1
1
  // This file is auto-generated during build - do not edit manually
2
- // Generated from package.json version: 0.3.5-test.913
2
+ // Generated from package.json version: 0.3.5-test.915
3
3
  /**
4
4
  * The package version, injected at build time.
5
5
  * @internal
6
6
  */
7
- export const VERSION = '0.3.5-test.913';
7
+ export const VERSION = '0.3.5-test.915';
@@ -14,12 +14,12 @@ var websocketPlugin = require('@fastify/websocket');
14
14
  var ed25519 = require('@noble/ed25519');
15
15
 
16
16
  // This file is auto-generated during build - do not edit manually
17
- // Generated from package.json version: 0.3.5-test.913
17
+ // Generated from package.json version: 0.3.5-test.915
18
18
  /**
19
19
  * The package version, injected at build time.
20
20
  * @internal
21
21
  */
22
- const VERSION = '0.3.5-test.913';
22
+ const VERSION = '0.3.5-test.915';
23
23
 
24
24
  /**
25
25
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -13015,47 +13015,125 @@ const currentModuleUrl = (() => {
13015
13015
  return undefined;
13016
13016
  }
13017
13017
  })();
13018
- // Shared flag that allows synchronous waiting for the Node-specific require shim
13019
- const requireReadyFlag = isNode && typeof SharedArrayBuffer !== 'undefined'
13020
- ? new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))
13021
- : null;
13022
- if (requireReadyFlag) {
13023
- // 0 means initializing, 1 means ready (success or failure)
13024
- Atomics.store(requireReadyFlag, 0, 0);
13025
- // Prepare a CommonJS-style require when running in pure ESM contexts
13026
- void (async () => {
13027
- try {
13028
- if (typeof require !== 'function') {
13029
- const moduleNamespace = (await import('node:module'));
13030
- const createRequire = moduleNamespace.createRequire;
13031
- if (typeof createRequire === 'function') {
13032
- const fallbackPath = `${process.cwd()}/.__naylence_require_shim__.mjs`;
13033
- const nodeRequire = createRequire(currentModuleUrl ?? fallbackPath);
13034
- globalThis.require = nodeRequire;
13018
+ let cachedNodeRequire = typeof require === 'function' ? require : null;
13019
+ function createFsShim() {
13020
+ if (!isNode) {
13021
+ return null;
13022
+ }
13023
+ const processBinding = process.binding;
13024
+ if (typeof processBinding !== 'function') {
13025
+ return null;
13026
+ }
13027
+ try {
13028
+ const fsBinding = processBinding('fs');
13029
+ if (!fsBinding || typeof fsBinding.readFileUtf8 !== 'function') {
13030
+ return null;
13031
+ }
13032
+ const shim = {
13033
+ readFileSync: (...args) => {
13034
+ const [pathOrDescriptor, options] = args;
13035
+ if (typeof pathOrDescriptor !== 'string') {
13036
+ throw new Error('FS shim only supports string file paths');
13035
13037
  }
13036
- }
13038
+ let encoding;
13039
+ if (typeof options === 'string') {
13040
+ encoding = options;
13041
+ }
13042
+ else if (options &&
13043
+ typeof options === 'object' &&
13044
+ 'encoding' in options &&
13045
+ typeof options.encoding === 'string') {
13046
+ encoding = options.encoding;
13047
+ }
13048
+ const data = fsBinding.readFileUtf8(pathOrDescriptor, 0);
13049
+ if (!encoding) {
13050
+ return typeof Buffer !== 'undefined'
13051
+ ? Buffer.from(data, 'utf-8')
13052
+ : data;
13053
+ }
13054
+ const lowered = encoding.toLowerCase();
13055
+ if (lowered === 'utf-8' || lowered === 'utf8') {
13056
+ return data;
13057
+ }
13058
+ if (typeof Buffer === 'undefined') {
13059
+ throw new Error(`Buffer API is not available to convert encoding ${String(encoding)}`);
13060
+ }
13061
+ return Buffer.from(data, 'utf-8').toString(encoding);
13062
+ },
13063
+ existsSync: (...args) => {
13064
+ const [pathLike] = args;
13065
+ if (typeof pathLike !== 'string') {
13066
+ return false;
13067
+ }
13068
+ if (typeof fsBinding.existsSync === 'function') {
13069
+ try {
13070
+ return Boolean(fsBinding.existsSync(pathLike));
13071
+ }
13072
+ catch {
13073
+ // fall through to the internal stat fallback
13074
+ }
13075
+ }
13076
+ if (typeof fsBinding.internalModuleStat === 'function') {
13077
+ try {
13078
+ return (fsBinding.internalModuleStat(pathLike) >= 0);
13079
+ }
13080
+ catch {
13081
+ return false;
13082
+ }
13083
+ }
13084
+ return false;
13085
+ },
13086
+ };
13087
+ return shim;
13088
+ }
13089
+ catch {
13090
+ return null;
13091
+ }
13092
+ }
13093
+ function fileUrlToPath(url) {
13094
+ try {
13095
+ const parsed = new URL(url);
13096
+ if (parsed.protocol !== 'file:') {
13097
+ return null;
13037
13098
  }
13038
- catch {
13039
- // Ignore failures getFsModule will surface a helpful error when needed
13040
- }
13041
- })()
13042
- .catch(() => {
13043
- // Ignore async errors – the ready flag will still unblock consumers
13044
- })
13045
- .finally(() => {
13046
- Atomics.store(requireReadyFlag, 0, 1);
13047
- Atomics.notify(requireReadyFlag, 0);
13048
- });
13099
+ let pathname = parsed.pathname;
13100
+ if (typeof process !== 'undefined' &&
13101
+ process.platform === 'win32' &&
13102
+ pathname.startsWith('/')) {
13103
+ pathname = pathname.slice(1);
13104
+ }
13105
+ return decodeURIComponent(pathname);
13106
+ }
13107
+ catch {
13108
+ return null;
13109
+ }
13049
13110
  }
13050
- function ensureRequireReady() {
13051
- if (!requireReadyFlag) {
13052
- return;
13111
+ function getNodeRequire() {
13112
+ if (cachedNodeRequire) {
13113
+ return cachedNodeRequire;
13053
13114
  }
13054
- if (Atomics.load(requireReadyFlag, 0) === 1) {
13055
- return;
13115
+ if (!isNode) {
13116
+ return null;
13117
+ }
13118
+ const processBinding = process.binding;
13119
+ if (typeof processBinding !== 'function') {
13120
+ return null;
13121
+ }
13122
+ try {
13123
+ const moduleWrap = processBinding('module_wrap');
13124
+ if (typeof moduleWrap?.createRequire !== 'function') {
13125
+ return null;
13126
+ }
13127
+ const modulePathFromUrl = currentModuleUrl
13128
+ ? fileUrlToPath(currentModuleUrl)
13129
+ : null;
13130
+ const requireSource = modulePathFromUrl ?? `${process.cwd()}/.naylence-require-shim.js`;
13131
+ cachedNodeRequire = moduleWrap.createRequire(requireSource);
13132
+ return cachedNodeRequire;
13133
+ }
13134
+ catch {
13135
+ return null;
13056
13136
  }
13057
- // Block until the asynchronous loader finishes initialising
13058
- Atomics.wait(requireReadyFlag, 0, 0);
13059
13137
  }
13060
13138
  function getFsModule() {
13061
13139
  if (cachedFsModule) {
@@ -13064,16 +13142,21 @@ function getFsModule() {
13064
13142
  if (!isNode) {
13065
13143
  throw new Error('File system access is not available in this environment');
13066
13144
  }
13067
- ensureRequireReady();
13068
- if (typeof require === 'function') {
13145
+ const nodeRequire = typeof require === 'function' ? require : getNodeRequire();
13146
+ if (nodeRequire) {
13069
13147
  try {
13070
- cachedFsModule = require(fsModuleSpecifier);
13148
+ cachedFsModule = nodeRequire(fsModuleSpecifier);
13071
13149
  return cachedFsModule;
13072
13150
  }
13073
13151
  catch (error) {
13074
13152
  throw new Error(`Unable to load file system module: ${error instanceof Error ? error.message : String(error)}`);
13075
13153
  }
13076
13154
  }
13155
+ const shim = createFsShim();
13156
+ if (shim) {
13157
+ cachedFsModule = shim;
13158
+ return cachedFsModule;
13159
+ }
13077
13160
  throw new Error('File system module is not accessible in this environment');
13078
13161
  }
13079
13162
  function readConfigFile(filePath) {
@@ -13,12 +13,12 @@ import websocketPlugin from '@fastify/websocket';
13
13
  import { sign, hashes, verify } from '@noble/ed25519';
14
14
 
15
15
  // This file is auto-generated during build - do not edit manually
16
- // Generated from package.json version: 0.3.5-test.913
16
+ // Generated from package.json version: 0.3.5-test.915
17
17
  /**
18
18
  * The package version, injected at build time.
19
19
  * @internal
20
20
  */
21
- const VERSION = '0.3.5-test.913';
21
+ const VERSION = '0.3.5-test.915';
22
22
 
23
23
  /**
24
24
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -13014,47 +13014,125 @@ const currentModuleUrl = (() => {
13014
13014
  return undefined;
13015
13015
  }
13016
13016
  })();
13017
- // Shared flag that allows synchronous waiting for the Node-specific require shim
13018
- const requireReadyFlag = isNode && typeof SharedArrayBuffer !== 'undefined'
13019
- ? new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))
13020
- : null;
13021
- if (requireReadyFlag) {
13022
- // 0 means initializing, 1 means ready (success or failure)
13023
- Atomics.store(requireReadyFlag, 0, 0);
13024
- // Prepare a CommonJS-style require when running in pure ESM contexts
13025
- void (async () => {
13026
- try {
13027
- if (typeof require !== 'function') {
13028
- const moduleNamespace = (await import('node:module'));
13029
- const createRequire = moduleNamespace.createRequire;
13030
- if (typeof createRequire === 'function') {
13031
- const fallbackPath = `${process.cwd()}/.__naylence_require_shim__.mjs`;
13032
- const nodeRequire = createRequire(currentModuleUrl ?? fallbackPath);
13033
- globalThis.require = nodeRequire;
13017
+ let cachedNodeRequire = typeof require === 'function' ? require : null;
13018
+ function createFsShim() {
13019
+ if (!isNode) {
13020
+ return null;
13021
+ }
13022
+ const processBinding = process.binding;
13023
+ if (typeof processBinding !== 'function') {
13024
+ return null;
13025
+ }
13026
+ try {
13027
+ const fsBinding = processBinding('fs');
13028
+ if (!fsBinding || typeof fsBinding.readFileUtf8 !== 'function') {
13029
+ return null;
13030
+ }
13031
+ const shim = {
13032
+ readFileSync: (...args) => {
13033
+ const [pathOrDescriptor, options] = args;
13034
+ if (typeof pathOrDescriptor !== 'string') {
13035
+ throw new Error('FS shim only supports string file paths');
13034
13036
  }
13035
- }
13037
+ let encoding;
13038
+ if (typeof options === 'string') {
13039
+ encoding = options;
13040
+ }
13041
+ else if (options &&
13042
+ typeof options === 'object' &&
13043
+ 'encoding' in options &&
13044
+ typeof options.encoding === 'string') {
13045
+ encoding = options.encoding;
13046
+ }
13047
+ const data = fsBinding.readFileUtf8(pathOrDescriptor, 0);
13048
+ if (!encoding) {
13049
+ return typeof Buffer !== 'undefined'
13050
+ ? Buffer.from(data, 'utf-8')
13051
+ : data;
13052
+ }
13053
+ const lowered = encoding.toLowerCase();
13054
+ if (lowered === 'utf-8' || lowered === 'utf8') {
13055
+ return data;
13056
+ }
13057
+ if (typeof Buffer === 'undefined') {
13058
+ throw new Error(`Buffer API is not available to convert encoding ${String(encoding)}`);
13059
+ }
13060
+ return Buffer.from(data, 'utf-8').toString(encoding);
13061
+ },
13062
+ existsSync: (...args) => {
13063
+ const [pathLike] = args;
13064
+ if (typeof pathLike !== 'string') {
13065
+ return false;
13066
+ }
13067
+ if (typeof fsBinding.existsSync === 'function') {
13068
+ try {
13069
+ return Boolean(fsBinding.existsSync(pathLike));
13070
+ }
13071
+ catch {
13072
+ // fall through to the internal stat fallback
13073
+ }
13074
+ }
13075
+ if (typeof fsBinding.internalModuleStat === 'function') {
13076
+ try {
13077
+ return (fsBinding.internalModuleStat(pathLike) >= 0);
13078
+ }
13079
+ catch {
13080
+ return false;
13081
+ }
13082
+ }
13083
+ return false;
13084
+ },
13085
+ };
13086
+ return shim;
13087
+ }
13088
+ catch {
13089
+ return null;
13090
+ }
13091
+ }
13092
+ function fileUrlToPath(url) {
13093
+ try {
13094
+ const parsed = new URL(url);
13095
+ if (parsed.protocol !== 'file:') {
13096
+ return null;
13036
13097
  }
13037
- catch {
13038
- // Ignore failures getFsModule will surface a helpful error when needed
13039
- }
13040
- })()
13041
- .catch(() => {
13042
- // Ignore async errors – the ready flag will still unblock consumers
13043
- })
13044
- .finally(() => {
13045
- Atomics.store(requireReadyFlag, 0, 1);
13046
- Atomics.notify(requireReadyFlag, 0);
13047
- });
13098
+ let pathname = parsed.pathname;
13099
+ if (typeof process !== 'undefined' &&
13100
+ process.platform === 'win32' &&
13101
+ pathname.startsWith('/')) {
13102
+ pathname = pathname.slice(1);
13103
+ }
13104
+ return decodeURIComponent(pathname);
13105
+ }
13106
+ catch {
13107
+ return null;
13108
+ }
13048
13109
  }
13049
- function ensureRequireReady() {
13050
- if (!requireReadyFlag) {
13051
- return;
13110
+ function getNodeRequire() {
13111
+ if (cachedNodeRequire) {
13112
+ return cachedNodeRequire;
13052
13113
  }
13053
- if (Atomics.load(requireReadyFlag, 0) === 1) {
13054
- return;
13114
+ if (!isNode) {
13115
+ return null;
13116
+ }
13117
+ const processBinding = process.binding;
13118
+ if (typeof processBinding !== 'function') {
13119
+ return null;
13120
+ }
13121
+ try {
13122
+ const moduleWrap = processBinding('module_wrap');
13123
+ if (typeof moduleWrap?.createRequire !== 'function') {
13124
+ return null;
13125
+ }
13126
+ const modulePathFromUrl = currentModuleUrl
13127
+ ? fileUrlToPath(currentModuleUrl)
13128
+ : null;
13129
+ const requireSource = modulePathFromUrl ?? `${process.cwd()}/.naylence-require-shim.js`;
13130
+ cachedNodeRequire = moduleWrap.createRequire(requireSource);
13131
+ return cachedNodeRequire;
13132
+ }
13133
+ catch {
13134
+ return null;
13055
13135
  }
13056
- // Block until the asynchronous loader finishes initialising
13057
- Atomics.wait(requireReadyFlag, 0, 0);
13058
13136
  }
13059
13137
  function getFsModule() {
13060
13138
  if (cachedFsModule) {
@@ -13063,16 +13141,21 @@ function getFsModule() {
13063
13141
  if (!isNode) {
13064
13142
  throw new Error('File system access is not available in this environment');
13065
13143
  }
13066
- ensureRequireReady();
13067
- if (typeof require === 'function') {
13144
+ const nodeRequire = typeof require === 'function' ? require : getNodeRequire();
13145
+ if (nodeRequire) {
13068
13146
  try {
13069
- cachedFsModule = require(fsModuleSpecifier);
13147
+ cachedFsModule = nodeRequire(fsModuleSpecifier);
13070
13148
  return cachedFsModule;
13071
13149
  }
13072
13150
  catch (error) {
13073
13151
  throw new Error(`Unable to load file system module: ${error instanceof Error ? error.message : String(error)}`);
13074
13152
  }
13075
13153
  }
13154
+ const shim = createFsShim();
13155
+ if (shim) {
13156
+ cachedFsModule = shim;
13157
+ return cachedFsModule;
13158
+ }
13076
13159
  throw new Error('File system module is not accessible in this environment');
13077
13160
  }
13078
13161
  function readConfigFile(filePath) {