@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.
@@ -98,12 +98,12 @@ installProcessEnvShim();
98
98
  // --- END ENV SHIM ---
99
99
 
100
100
  // This file is auto-generated during build - do not edit manually
101
- // Generated from package.json version: 0.3.5-test.913
101
+ // Generated from package.json version: 0.3.5-test.915
102
102
  /**
103
103
  * The package version, injected at build time.
104
104
  * @internal
105
105
  */
106
- const VERSION = '0.3.5-test.913';
106
+ const VERSION = '0.3.5-test.915';
107
107
 
108
108
  /**
109
109
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -13099,47 +13099,125 @@ const currentModuleUrl = (() => {
13099
13099
  return undefined;
13100
13100
  }
13101
13101
  })();
13102
- // Shared flag that allows synchronous waiting for the Node-specific require shim
13103
- const requireReadyFlag = isNode && typeof SharedArrayBuffer !== 'undefined'
13104
- ? new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))
13105
- : null;
13106
- if (requireReadyFlag) {
13107
- // 0 means initializing, 1 means ready (success or failure)
13108
- Atomics.store(requireReadyFlag, 0, 0);
13109
- // Prepare a CommonJS-style require when running in pure ESM contexts
13110
- void (async () => {
13111
- try {
13112
- if (typeof require !== 'function') {
13113
- const moduleNamespace = (await import('node:module'));
13114
- const createRequire = moduleNamespace.createRequire;
13115
- if (typeof createRequire === 'function') {
13116
- const fallbackPath = `${process.cwd()}/.__naylence_require_shim__.mjs`;
13117
- const nodeRequire = createRequire(currentModuleUrl ?? fallbackPath);
13118
- globalThis.require = nodeRequire;
13102
+ let cachedNodeRequire = typeof require === 'function' ? require : null;
13103
+ function createFsShim() {
13104
+ if (!isNode) {
13105
+ return null;
13106
+ }
13107
+ const processBinding = process.binding;
13108
+ if (typeof processBinding !== 'function') {
13109
+ return null;
13110
+ }
13111
+ try {
13112
+ const fsBinding = processBinding('fs');
13113
+ if (!fsBinding || typeof fsBinding.readFileUtf8 !== 'function') {
13114
+ return null;
13115
+ }
13116
+ const shim = {
13117
+ readFileSync: (...args) => {
13118
+ const [pathOrDescriptor, options] = args;
13119
+ if (typeof pathOrDescriptor !== 'string') {
13120
+ throw new Error('FS shim only supports string file paths');
13119
13121
  }
13120
- }
13122
+ let encoding;
13123
+ if (typeof options === 'string') {
13124
+ encoding = options;
13125
+ }
13126
+ else if (options &&
13127
+ typeof options === 'object' &&
13128
+ 'encoding' in options &&
13129
+ typeof options.encoding === 'string') {
13130
+ encoding = options.encoding;
13131
+ }
13132
+ const data = fsBinding.readFileUtf8(pathOrDescriptor, 0);
13133
+ if (!encoding) {
13134
+ return typeof Buffer !== 'undefined'
13135
+ ? Buffer.from(data, 'utf-8')
13136
+ : data;
13137
+ }
13138
+ const lowered = encoding.toLowerCase();
13139
+ if (lowered === 'utf-8' || lowered === 'utf8') {
13140
+ return data;
13141
+ }
13142
+ if (typeof Buffer === 'undefined') {
13143
+ throw new Error(`Buffer API is not available to convert encoding ${String(encoding)}`);
13144
+ }
13145
+ return Buffer.from(data, 'utf-8').toString(encoding);
13146
+ },
13147
+ existsSync: (...args) => {
13148
+ const [pathLike] = args;
13149
+ if (typeof pathLike !== 'string') {
13150
+ return false;
13151
+ }
13152
+ if (typeof fsBinding.existsSync === 'function') {
13153
+ try {
13154
+ return Boolean(fsBinding.existsSync(pathLike));
13155
+ }
13156
+ catch {
13157
+ // fall through to the internal stat fallback
13158
+ }
13159
+ }
13160
+ if (typeof fsBinding.internalModuleStat === 'function') {
13161
+ try {
13162
+ return (fsBinding.internalModuleStat(pathLike) >= 0);
13163
+ }
13164
+ catch {
13165
+ return false;
13166
+ }
13167
+ }
13168
+ return false;
13169
+ },
13170
+ };
13171
+ return shim;
13172
+ }
13173
+ catch {
13174
+ return null;
13175
+ }
13176
+ }
13177
+ function fileUrlToPath(url) {
13178
+ try {
13179
+ const parsed = new URL(url);
13180
+ if (parsed.protocol !== 'file:') {
13181
+ return null;
13121
13182
  }
13122
- catch {
13123
- // Ignore failures getFsModule will surface a helpful error when needed
13124
- }
13125
- })()
13126
- .catch(() => {
13127
- // Ignore async errors – the ready flag will still unblock consumers
13128
- })
13129
- .finally(() => {
13130
- Atomics.store(requireReadyFlag, 0, 1);
13131
- Atomics.notify(requireReadyFlag, 0);
13132
- });
13183
+ let pathname = parsed.pathname;
13184
+ if (typeof process !== 'undefined' &&
13185
+ process.platform === 'win32' &&
13186
+ pathname.startsWith('/')) {
13187
+ pathname = pathname.slice(1);
13188
+ }
13189
+ return decodeURIComponent(pathname);
13190
+ }
13191
+ catch {
13192
+ return null;
13193
+ }
13133
13194
  }
13134
- function ensureRequireReady() {
13135
- if (!requireReadyFlag) {
13136
- return;
13195
+ function getNodeRequire() {
13196
+ if (cachedNodeRequire) {
13197
+ return cachedNodeRequire;
13137
13198
  }
13138
- if (Atomics.load(requireReadyFlag, 0) === 1) {
13139
- return;
13199
+ if (!isNode) {
13200
+ return null;
13201
+ }
13202
+ const processBinding = process.binding;
13203
+ if (typeof processBinding !== 'function') {
13204
+ return null;
13205
+ }
13206
+ try {
13207
+ const moduleWrap = processBinding('module_wrap');
13208
+ if (typeof moduleWrap?.createRequire !== 'function') {
13209
+ return null;
13210
+ }
13211
+ const modulePathFromUrl = currentModuleUrl
13212
+ ? fileUrlToPath(currentModuleUrl)
13213
+ : null;
13214
+ const requireSource = modulePathFromUrl ?? `${process.cwd()}/.naylence-require-shim.js`;
13215
+ cachedNodeRequire = moduleWrap.createRequire(requireSource);
13216
+ return cachedNodeRequire;
13217
+ }
13218
+ catch {
13219
+ return null;
13140
13220
  }
13141
- // Block until the asynchronous loader finishes initialising
13142
- Atomics.wait(requireReadyFlag, 0, 0);
13143
13221
  }
13144
13222
  function getFsModule() {
13145
13223
  if (cachedFsModule) {
@@ -13148,16 +13226,21 @@ function getFsModule() {
13148
13226
  if (!isNode) {
13149
13227
  throw new Error('File system access is not available in this environment');
13150
13228
  }
13151
- ensureRequireReady();
13152
- if (typeof require === 'function') {
13229
+ const nodeRequire = typeof require === 'function' ? require : getNodeRequire();
13230
+ if (nodeRequire) {
13153
13231
  try {
13154
- cachedFsModule = require(fsModuleSpecifier);
13232
+ cachedFsModule = nodeRequire(fsModuleSpecifier);
13155
13233
  return cachedFsModule;
13156
13234
  }
13157
13235
  catch (error) {
13158
13236
  throw new Error(`Unable to load file system module: ${error instanceof Error ? error.message : String(error)}`);
13159
13237
  }
13160
13238
  }
13239
+ const shim = createFsShim();
13240
+ if (shim) {
13241
+ cachedFsModule = shim;
13242
+ return cachedFsModule;
13243
+ }
13161
13244
  throw new Error('File system module is not accessible in this environment');
13162
13245
  }
13163
13246
  function readConfigFile(filePath) {
@@ -96,12 +96,12 @@ installProcessEnvShim();
96
96
  // --- END ENV SHIM ---
97
97
 
98
98
  // This file is auto-generated during build - do not edit manually
99
- // Generated from package.json version: 0.3.5-test.913
99
+ // Generated from package.json version: 0.3.5-test.915
100
100
  /**
101
101
  * The package version, injected at build time.
102
102
  * @internal
103
103
  */
104
- const VERSION = '0.3.5-test.913';
104
+ const VERSION = '0.3.5-test.915';
105
105
 
106
106
  /**
107
107
  * Fame protocol specific error classes with WebSocket close codes and proper inheritance.
@@ -13097,47 +13097,125 @@ const currentModuleUrl = (() => {
13097
13097
  return undefined;
13098
13098
  }
13099
13099
  })();
13100
- // Shared flag that allows synchronous waiting for the Node-specific require shim
13101
- const requireReadyFlag = isNode && typeof SharedArrayBuffer !== 'undefined'
13102
- ? new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))
13103
- : null;
13104
- if (requireReadyFlag) {
13105
- // 0 means initializing, 1 means ready (success or failure)
13106
- Atomics.store(requireReadyFlag, 0, 0);
13107
- // Prepare a CommonJS-style require when running in pure ESM contexts
13108
- void (async () => {
13109
- try {
13110
- if (typeof require !== 'function') {
13111
- const moduleNamespace = (await import('node:module'));
13112
- const createRequire = moduleNamespace.createRequire;
13113
- if (typeof createRequire === 'function') {
13114
- const fallbackPath = `${process.cwd()}/.__naylence_require_shim__.mjs`;
13115
- const nodeRequire = createRequire(currentModuleUrl ?? fallbackPath);
13116
- globalThis.require = nodeRequire;
13100
+ let cachedNodeRequire = typeof require === 'function' ? require : null;
13101
+ function createFsShim() {
13102
+ if (!isNode) {
13103
+ return null;
13104
+ }
13105
+ const processBinding = process.binding;
13106
+ if (typeof processBinding !== 'function') {
13107
+ return null;
13108
+ }
13109
+ try {
13110
+ const fsBinding = processBinding('fs');
13111
+ if (!fsBinding || typeof fsBinding.readFileUtf8 !== 'function') {
13112
+ return null;
13113
+ }
13114
+ const shim = {
13115
+ readFileSync: (...args) => {
13116
+ const [pathOrDescriptor, options] = args;
13117
+ if (typeof pathOrDescriptor !== 'string') {
13118
+ throw new Error('FS shim only supports string file paths');
13117
13119
  }
13118
- }
13120
+ let encoding;
13121
+ if (typeof options === 'string') {
13122
+ encoding = options;
13123
+ }
13124
+ else if (options &&
13125
+ typeof options === 'object' &&
13126
+ 'encoding' in options &&
13127
+ typeof options.encoding === 'string') {
13128
+ encoding = options.encoding;
13129
+ }
13130
+ const data = fsBinding.readFileUtf8(pathOrDescriptor, 0);
13131
+ if (!encoding) {
13132
+ return typeof Buffer !== 'undefined'
13133
+ ? Buffer.from(data, 'utf-8')
13134
+ : data;
13135
+ }
13136
+ const lowered = encoding.toLowerCase();
13137
+ if (lowered === 'utf-8' || lowered === 'utf8') {
13138
+ return data;
13139
+ }
13140
+ if (typeof Buffer === 'undefined') {
13141
+ throw new Error(`Buffer API is not available to convert encoding ${String(encoding)}`);
13142
+ }
13143
+ return Buffer.from(data, 'utf-8').toString(encoding);
13144
+ },
13145
+ existsSync: (...args) => {
13146
+ const [pathLike] = args;
13147
+ if (typeof pathLike !== 'string') {
13148
+ return false;
13149
+ }
13150
+ if (typeof fsBinding.existsSync === 'function') {
13151
+ try {
13152
+ return Boolean(fsBinding.existsSync(pathLike));
13153
+ }
13154
+ catch {
13155
+ // fall through to the internal stat fallback
13156
+ }
13157
+ }
13158
+ if (typeof fsBinding.internalModuleStat === 'function') {
13159
+ try {
13160
+ return (fsBinding.internalModuleStat(pathLike) >= 0);
13161
+ }
13162
+ catch {
13163
+ return false;
13164
+ }
13165
+ }
13166
+ return false;
13167
+ },
13168
+ };
13169
+ return shim;
13170
+ }
13171
+ catch {
13172
+ return null;
13173
+ }
13174
+ }
13175
+ function fileUrlToPath(url) {
13176
+ try {
13177
+ const parsed = new URL(url);
13178
+ if (parsed.protocol !== 'file:') {
13179
+ return null;
13119
13180
  }
13120
- catch {
13121
- // Ignore failures getFsModule will surface a helpful error when needed
13122
- }
13123
- })()
13124
- .catch(() => {
13125
- // Ignore async errors – the ready flag will still unblock consumers
13126
- })
13127
- .finally(() => {
13128
- Atomics.store(requireReadyFlag, 0, 1);
13129
- Atomics.notify(requireReadyFlag, 0);
13130
- });
13181
+ let pathname = parsed.pathname;
13182
+ if (typeof process !== 'undefined' &&
13183
+ process.platform === 'win32' &&
13184
+ pathname.startsWith('/')) {
13185
+ pathname = pathname.slice(1);
13186
+ }
13187
+ return decodeURIComponent(pathname);
13188
+ }
13189
+ catch {
13190
+ return null;
13191
+ }
13131
13192
  }
13132
- function ensureRequireReady() {
13133
- if (!requireReadyFlag) {
13134
- return;
13193
+ function getNodeRequire() {
13194
+ if (cachedNodeRequire) {
13195
+ return cachedNodeRequire;
13135
13196
  }
13136
- if (Atomics.load(requireReadyFlag, 0) === 1) {
13137
- return;
13197
+ if (!isNode) {
13198
+ return null;
13199
+ }
13200
+ const processBinding = process.binding;
13201
+ if (typeof processBinding !== 'function') {
13202
+ return null;
13203
+ }
13204
+ try {
13205
+ const moduleWrap = processBinding('module_wrap');
13206
+ if (typeof moduleWrap?.createRequire !== 'function') {
13207
+ return null;
13208
+ }
13209
+ const modulePathFromUrl = currentModuleUrl
13210
+ ? fileUrlToPath(currentModuleUrl)
13211
+ : null;
13212
+ const requireSource = modulePathFromUrl ?? `${process.cwd()}/.naylence-require-shim.js`;
13213
+ cachedNodeRequire = moduleWrap.createRequire(requireSource);
13214
+ return cachedNodeRequire;
13215
+ }
13216
+ catch {
13217
+ return null;
13138
13218
  }
13139
- // Block until the asynchronous loader finishes initialising
13140
- Atomics.wait(requireReadyFlag, 0, 0);
13141
13219
  }
13142
13220
  function getFsModule() {
13143
13221
  if (cachedFsModule) {
@@ -13146,16 +13224,21 @@ function getFsModule() {
13146
13224
  if (!isNode) {
13147
13225
  throw new Error('File system access is not available in this environment');
13148
13226
  }
13149
- ensureRequireReady();
13150
- if (typeof require === 'function') {
13227
+ const nodeRequire = typeof require === 'function' ? require : getNodeRequire();
13228
+ if (nodeRequire) {
13151
13229
  try {
13152
- cachedFsModule = require(fsModuleSpecifier);
13230
+ cachedFsModule = nodeRequire(fsModuleSpecifier);
13153
13231
  return cachedFsModule;
13154
13232
  }
13155
13233
  catch (error) {
13156
13234
  throw new Error(`Unable to load file system module: ${error instanceof Error ? error.message : String(error)}`);
13157
13235
  }
13158
13236
  }
13237
+ const shim = createFsShim();
13238
+ if (shim) {
13239
+ cachedFsModule = shim;
13240
+ return cachedFsModule;
13241
+ }
13159
13242
  throw new Error('File system module is not accessible in this environment');
13160
13243
  }
13161
13244
  function readConfigFile(filePath) {
@@ -66,47 +66,125 @@ const currentModuleUrl = (() => {
66
66
  return undefined;
67
67
  }
68
68
  })();
69
- // Shared flag that allows synchronous waiting for the Node-specific require shim
70
- const requireReadyFlag = logging_types_js_1.isNode && typeof SharedArrayBuffer !== 'undefined'
71
- ? new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT))
72
- : null;
73
- if (requireReadyFlag) {
74
- // 0 means initializing, 1 means ready (success or failure)
75
- Atomics.store(requireReadyFlag, 0, 0);
76
- // Prepare a CommonJS-style require when running in pure ESM contexts
77
- void (async () => {
78
- try {
79
- if (typeof require !== 'function') {
80
- const moduleNamespace = (await Promise.resolve().then(() => __importStar(require('node:module'))));
81
- const createRequire = moduleNamespace.createRequire;
82
- if (typeof createRequire === 'function') {
83
- const fallbackPath = `${process.cwd()}/.__naylence_require_shim__.mjs`;
84
- const nodeRequire = createRequire(currentModuleUrl ?? fallbackPath);
85
- globalThis.require = nodeRequire;
69
+ let cachedNodeRequire = typeof require === 'function' ? require : null;
70
+ function createFsShim() {
71
+ if (!logging_types_js_1.isNode) {
72
+ return null;
73
+ }
74
+ const processBinding = process.binding;
75
+ if (typeof processBinding !== 'function') {
76
+ return null;
77
+ }
78
+ try {
79
+ const fsBinding = processBinding('fs');
80
+ if (!fsBinding || typeof fsBinding.readFileUtf8 !== 'function') {
81
+ return null;
82
+ }
83
+ const shim = {
84
+ readFileSync: (...args) => {
85
+ const [pathOrDescriptor, options] = args;
86
+ if (typeof pathOrDescriptor !== 'string') {
87
+ throw new Error('FS shim only supports string file paths');
86
88
  }
87
- }
89
+ let encoding;
90
+ if (typeof options === 'string') {
91
+ encoding = options;
92
+ }
93
+ else if (options &&
94
+ typeof options === 'object' &&
95
+ 'encoding' in options &&
96
+ typeof options.encoding === 'string') {
97
+ encoding = options.encoding;
98
+ }
99
+ const data = fsBinding.readFileUtf8(pathOrDescriptor, 0);
100
+ if (!encoding) {
101
+ return typeof Buffer !== 'undefined'
102
+ ? Buffer.from(data, 'utf-8')
103
+ : data;
104
+ }
105
+ const lowered = encoding.toLowerCase();
106
+ if (lowered === 'utf-8' || lowered === 'utf8') {
107
+ return data;
108
+ }
109
+ if (typeof Buffer === 'undefined') {
110
+ throw new Error(`Buffer API is not available to convert encoding ${String(encoding)}`);
111
+ }
112
+ return Buffer.from(data, 'utf-8').toString(encoding);
113
+ },
114
+ existsSync: (...args) => {
115
+ const [pathLike] = args;
116
+ if (typeof pathLike !== 'string') {
117
+ return false;
118
+ }
119
+ if (typeof fsBinding.existsSync === 'function') {
120
+ try {
121
+ return Boolean(fsBinding.existsSync(pathLike));
122
+ }
123
+ catch {
124
+ // fall through to the internal stat fallback
125
+ }
126
+ }
127
+ if (typeof fsBinding.internalModuleStat === 'function') {
128
+ try {
129
+ return (fsBinding.internalModuleStat(pathLike) >= 0);
130
+ }
131
+ catch {
132
+ return false;
133
+ }
134
+ }
135
+ return false;
136
+ },
137
+ };
138
+ return shim;
139
+ }
140
+ catch {
141
+ return null;
142
+ }
143
+ }
144
+ function fileUrlToPath(url) {
145
+ try {
146
+ const parsed = new URL(url);
147
+ if (parsed.protocol !== 'file:') {
148
+ return null;
88
149
  }
89
- catch {
90
- // Ignore failures getFsModule will surface a helpful error when needed
150
+ let pathname = parsed.pathname;
151
+ if (typeof process !== 'undefined' &&
152
+ process.platform === 'win32' &&
153
+ pathname.startsWith('/')) {
154
+ pathname = pathname.slice(1);
91
155
  }
92
- })()
93
- .catch(() => {
94
- // Ignore async errors – the ready flag will still unblock consumers
95
- })
96
- .finally(() => {
97
- Atomics.store(requireReadyFlag, 0, 1);
98
- Atomics.notify(requireReadyFlag, 0);
99
- });
156
+ return decodeURIComponent(pathname);
157
+ }
158
+ catch {
159
+ return null;
160
+ }
100
161
  }
101
- function ensureRequireReady() {
102
- if (!requireReadyFlag) {
103
- return;
162
+ function getNodeRequire() {
163
+ if (cachedNodeRequire) {
164
+ return cachedNodeRequire;
104
165
  }
105
- if (Atomics.load(requireReadyFlag, 0) === 1) {
106
- return;
166
+ if (!logging_types_js_1.isNode) {
167
+ return null;
168
+ }
169
+ const processBinding = process.binding;
170
+ if (typeof processBinding !== 'function') {
171
+ return null;
172
+ }
173
+ try {
174
+ const moduleWrap = processBinding('module_wrap');
175
+ if (typeof moduleWrap?.createRequire !== 'function') {
176
+ return null;
177
+ }
178
+ const modulePathFromUrl = currentModuleUrl
179
+ ? fileUrlToPath(currentModuleUrl)
180
+ : null;
181
+ const requireSource = modulePathFromUrl ?? `${process.cwd()}/.naylence-require-shim.js`;
182
+ cachedNodeRequire = moduleWrap.createRequire(requireSource);
183
+ return cachedNodeRequire;
184
+ }
185
+ catch {
186
+ return null;
107
187
  }
108
- // Block until the asynchronous loader finishes initialising
109
- Atomics.wait(requireReadyFlag, 0, 0);
110
188
  }
111
189
  function getFsModule() {
112
190
  if (cachedFsModule) {
@@ -115,16 +193,21 @@ function getFsModule() {
115
193
  if (!logging_types_js_1.isNode) {
116
194
  throw new Error('File system access is not available in this environment');
117
195
  }
118
- ensureRequireReady();
119
- if (typeof require === 'function') {
196
+ const nodeRequire = typeof require === 'function' ? require : getNodeRequire();
197
+ if (nodeRequire) {
120
198
  try {
121
- cachedFsModule = require(fsModuleSpecifier);
199
+ cachedFsModule = nodeRequire(fsModuleSpecifier);
122
200
  return cachedFsModule;
123
201
  }
124
202
  catch (error) {
125
203
  throw new Error(`Unable to load file system module: ${error instanceof Error ? error.message : String(error)}`);
126
204
  }
127
205
  }
206
+ const shim = createFsShim();
207
+ if (shim) {
208
+ cachedFsModule = shim;
209
+ return cachedFsModule;
210
+ }
128
211
  throw new Error('File system module is not accessible in this environment');
129
212
  }
130
213
  function readConfigFile(filePath) {
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  // This file is auto-generated during build - do not edit manually
3
- // Generated from package.json version: 0.3.5-test.913
3
+ // Generated from package.json version: 0.3.5-test.915
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.VERSION = void 0;
6
6
  /**
7
7
  * The package version, injected at build time.
8
8
  * @internal
9
9
  */
10
- exports.VERSION = '0.3.5-test.913';
10
+ exports.VERSION = '0.3.5-test.915';