opcjs-base 0.1.40-alpha → 0.1.41-alpha

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/dist/index.cjs CHANGED
@@ -86,9 +86,7 @@ var NodeId = class _NodeId {
86
86
  break;
87
87
  case 3 /* ByteString */:
88
88
  prefix = "b";
89
- if (typeof Buffer !== "undefined") {
90
- value = Buffer.from(this.identifier).toString("base64");
91
- } else {
89
+ {
92
90
  const bytes = this.identifier;
93
91
  let binary = "";
94
92
  for (let i = 0; i < bytes.length; i++) {
@@ -148,17 +146,14 @@ var NodeId = class _NodeId {
148
146
  case "g":
149
147
  return new _NodeId(namespace, value);
150
148
  // GUID as string
151
- case "b":
152
- if (typeof Buffer !== "undefined") {
153
- return new _NodeId(namespace, new Uint8Array(Buffer.from(value, "base64")));
154
- } else {
155
- const binary = atob(value);
156
- const bytes = new Uint8Array(binary.length);
157
- for (let i = 0; i < binary.length; i++) {
158
- bytes[i] = binary.charCodeAt(i);
159
- }
160
- return new _NodeId(namespace, bytes);
149
+ case "b": {
150
+ const binary = atob(value);
151
+ const bytes = new Uint8Array(binary.length);
152
+ for (let i = 0; i < binary.length; i++) {
153
+ bytes[i] = binary.charCodeAt(i);
161
154
  }
155
+ return new _NodeId(namespace, bytes);
156
+ }
162
157
  default:
163
158
  throw new Error(`Unknown NodeId type: ${type}`);
164
159
  }
@@ -318,9 +313,7 @@ var CodecError = class _CodecError extends Error {
318
313
  this.suggestedAction = options?.suggestedAction;
319
314
  this.typeName = options?.typeName;
320
315
  this.cause = options?.cause;
321
- if (Error.captureStackTrace) {
322
- Error.captureStackTrace(this, _CodecError);
323
- }
316
+ Error.captureStackTrace?.(this, _CodecError);
324
317
  }
325
318
  /**
326
319
  * Returns a detailed error message including all context.
@@ -903,7 +896,10 @@ var XmlReader = class {
903
896
  const text = this.getTextContent();
904
897
  if (text === "") return null;
905
898
  try {
906
- return Buffer.from(text, "base64");
899
+ const binary = atob(text);
900
+ const bytes = new Uint8Array(binary.length);
901
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
902
+ return bytes;
907
903
  } catch {
908
904
  throw new CodecError(`Invalid Base64 ByteString: ${text}`);
909
905
  }
@@ -16603,10 +16599,12 @@ var UserTokenTypeEnum = /* @__PURE__ */ ((UserTokenTypeEnum2) => {
16603
16599
 
16604
16600
  // src/utils/logger/consoleSink.ts
16605
16601
  function isNodeLike() {
16606
- return typeof process !== "undefined" && typeof process.versions !== "undefined" && typeof process.versions?.node !== "undefined";
16602
+ const g = globalThis;
16603
+ return typeof g.process !== "undefined" && typeof g.process?.versions !== "undefined" && typeof g.process?.versions?.node !== "undefined";
16607
16604
  }
16608
16605
  function supportsAnsiColors() {
16609
- return isNodeLike() && !!process.stdout?.isTTY;
16606
+ const g = globalThis;
16607
+ return isNodeLike() && !!g.process?.stdout?.isTTY;
16610
16608
  }
16611
16609
  function pad2(n) {
16612
16610
  return n < 10 ? `0${n}` : `${n}`;