@arcote.tech/arc-cli 0.8.5 → 0.8.6

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.js CHANGED
@@ -10191,8 +10191,72 @@ function apply(state, patches, applyOptions) {
10191
10191
  }
10192
10192
  return create(state, mutate, Object.assign(Object.assign({}, applyOptions), { enablePatches: false }));
10193
10193
  }
10194
- function hasLocalStorage() {
10195
- return typeof localStorage !== "undefined";
10194
+ function hasDocument() {
10195
+ return typeof document !== "undefined";
10196
+ }
10197
+ function signalCrossTabChange() {
10198
+ if (typeof localStorage === "undefined")
10199
+ return;
10200
+ try {
10201
+ localStorage.setItem(TOKEN_BUMP_KEY, String(Date.now()));
10202
+ } catch {}
10203
+ }
10204
+ function isSecureContext() {
10205
+ return typeof location !== "undefined" && location.protocol === "https:";
10206
+ }
10207
+ function tokenCookieName(scopeKey) {
10208
+ return scopeKey === "default" ? COOKIE_PREFIX : `${COOKIE_PREFIX}_${scopeKey.replace(/:/g, ".")}`;
10209
+ }
10210
+ function scopeKeyFromCookieName(name) {
10211
+ if (name === COOKIE_PREFIX)
10212
+ return "default";
10213
+ if (!name.startsWith(`${COOKIE_PREFIX}_`))
10214
+ return null;
10215
+ return name.slice(COOKIE_PREFIX.length + 1).replace(/\./g, ":");
10216
+ }
10217
+ function maxAgeFromExp(exp) {
10218
+ const THIRTY_DAYS = 30 * 24 * 60 * 60;
10219
+ if (typeof exp !== "number" || !Number.isFinite(exp))
10220
+ return THIRTY_DAYS;
10221
+ const expMs = exp > 1000000000000 ? exp : exp * 1000;
10222
+ const secs = Math.floor((expMs - Date.now()) / 1000);
10223
+ return secs > 0 ? secs : THIRTY_DAYS;
10224
+ }
10225
+ function writeTokenCookie(scopeKey, jwt, exp) {
10226
+ if (!hasDocument())
10227
+ return;
10228
+ const attrs = [
10229
+ "Path=/",
10230
+ "SameSite=Lax",
10231
+ `Max-Age=${maxAgeFromExp(exp)}`
10232
+ ];
10233
+ if (isSecureContext())
10234
+ attrs.push("Secure");
10235
+ document.cookie = `${tokenCookieName(scopeKey)}=${encodeURIComponent(jwt)}; ${attrs.join("; ")}`;
10236
+ signalCrossTabChange();
10237
+ }
10238
+ function removeTokenCookie(scopeKey) {
10239
+ if (!hasDocument())
10240
+ return;
10241
+ document.cookie = `${tokenCookieName(scopeKey)}=; Path=/; SameSite=Lax; Max-Age=0`;
10242
+ signalCrossTabChange();
10243
+ }
10244
+ function readAllTokenCookies() {
10245
+ if (!hasDocument() || !document.cookie)
10246
+ return [];
10247
+ const out = [];
10248
+ for (const part of document.cookie.split(";")) {
10249
+ const eq = part.indexOf("=");
10250
+ if (eq < 0)
10251
+ continue;
10252
+ const scopeKey = scopeKeyFromCookieName(part.slice(0, eq).trim());
10253
+ if (scopeKey === null)
10254
+ continue;
10255
+ const jwt = decodeURIComponent(part.slice(eq + 1).trim());
10256
+ if (jwt)
10257
+ out.push({ scopeKey, jwt });
10258
+ }
10259
+ return out;
10196
10260
  }
10197
10261
  function notifyTokenChange(scope) {
10198
10262
  if (typeof window !== "undefined") {
@@ -10208,24 +10272,21 @@ class AuthAdapter {
10208
10272
  constructor(options) {
10209
10273
  this.namespace = options?.storageNamespace || undefined;
10210
10274
  }
10211
- storageKey(scope) {
10212
- return this.namespace ? `${TOKEN_PREFIX}${this.namespace}:${scope}` : TOKEN_PREFIX + scope;
10275
+ scopeKey(scope) {
10276
+ return this.namespace ? `${this.namespace}:${scope}` : scope;
10213
10277
  }
10214
10278
  setToken(token, scope = "default") {
10215
10279
  if (!token) {
10216
10280
  this.scopes.delete(scope);
10217
- if (hasLocalStorage()) {
10218
- localStorage.removeItem(this.storageKey(scope));
10219
- notifyTokenChange(scope);
10220
- }
10281
+ removeTokenCookie(this.scopeKey(scope));
10282
+ notifyTokenChange(scope);
10221
10283
  return;
10222
10284
  }
10223
10285
  try {
10224
10286
  const parts = token.split(".");
10225
10287
  if (parts.length !== 3) {
10226
10288
  this.scopes.delete(scope);
10227
- if (hasLocalStorage())
10228
- localStorage.removeItem(this.storageKey(scope));
10289
+ removeTokenCookie(this.scopeKey(scope));
10229
10290
  return;
10230
10291
  }
10231
10292
  const payload = JSON.parse(atob(parts[1]));
@@ -10238,49 +10299,45 @@ class AuthAdapter {
10238
10299
  exp: payload.exp
10239
10300
  }
10240
10301
  });
10241
- if (hasLocalStorage()) {
10242
- localStorage.setItem(this.storageKey(scope), token);
10243
- notifyTokenChange(scope);
10244
- }
10302
+ writeTokenCookie(this.scopeKey(scope), token, payload.exp);
10303
+ notifyTokenChange(scope);
10245
10304
  } catch {
10246
10305
  this.scopes.delete(scope);
10247
- if (hasLocalStorage())
10248
- localStorage.removeItem(this.storageKey(scope));
10306
+ removeTokenCookie(this.scopeKey(scope));
10249
10307
  }
10250
10308
  }
10251
10309
  setDecoded(decoded, scope = "default") {
10252
10310
  this.scopes.set(scope, { raw: "", decoded });
10253
10311
  }
10254
10312
  loadPersisted() {
10255
- if (!hasLocalStorage())
10256
- return;
10257
- const prefix = this.namespace ? `${TOKEN_PREFIX}${this.namespace}:` : TOKEN_PREFIX;
10258
- for (let i = 0;i < localStorage.length; i++) {
10259
- const key = localStorage.key(i);
10260
- if (key?.startsWith(prefix)) {
10261
- const scope = key.slice(prefix.length);
10262
- if (!this.namespace && scope.includes(":"))
10313
+ const nsPrefix = this.namespace ? `${this.namespace}:` : "";
10314
+ for (const { scopeKey, jwt } of readAllTokenCookies()) {
10315
+ let scope;
10316
+ if (this.namespace) {
10317
+ if (!scopeKey.startsWith(nsPrefix))
10263
10318
  continue;
10264
- const raw = localStorage.getItem(key);
10265
- if (raw) {
10266
- try {
10267
- const parts = raw.split(".");
10268
- if (parts.length !== 3)
10269
- continue;
10270
- const payload = JSON.parse(atob(parts[1]));
10271
- this.scopes.set(scope, {
10272
- raw,
10273
- decoded: {
10274
- tokenName: payload.tokenName,
10275
- params: payload.params || {},
10276
- iat: payload.iat,
10277
- exp: payload.exp
10278
- }
10279
- });
10280
- } catch {
10281
- localStorage.removeItem(key);
10319
+ scope = scopeKey.slice(nsPrefix.length);
10320
+ } else {
10321
+ if (scopeKey.includes(":"))
10322
+ continue;
10323
+ scope = scopeKey;
10324
+ }
10325
+ try {
10326
+ const parts = jwt.split(".");
10327
+ if (parts.length !== 3)
10328
+ continue;
10329
+ const payload = JSON.parse(atob(parts[1]));
10330
+ this.scopes.set(scope, {
10331
+ raw: jwt,
10332
+ decoded: {
10333
+ tokenName: payload.tokenName,
10334
+ params: payload.params || {},
10335
+ iat: payload.iat,
10336
+ exp: payload.exp
10282
10337
  }
10283
- }
10338
+ });
10339
+ } catch {
10340
+ removeTokenCookie(scopeKey);
10284
10341
  }
10285
10342
  }
10286
10343
  }
@@ -10312,10 +10369,8 @@ class AuthAdapter {
10312
10369
  return Array.from(this.scopes.keys());
10313
10370
  }
10314
10371
  clear() {
10315
- if (hasLocalStorage()) {
10316
- for (const scope of this.scopes.keys()) {
10317
- localStorage.removeItem(this.storageKey(scope));
10318
- }
10372
+ for (const scope of this.scopes.keys()) {
10373
+ removeTokenCookie(this.scopeKey(scope));
10319
10374
  }
10320
10375
  this.scopes.clear();
10321
10376
  }
@@ -14595,7 +14650,7 @@ var Operation, PROXY_DRAFT, RAW_RETURN_SYMBOL, iteratorSymbol, dataTypes, intern
14595
14650
  }
14596
14651
  return returnValue(result);
14597
14652
  };
14598
- }, create, constructorString, TOKEN_PREFIX = "arc:token:", DEFAULT_TIMEOUT_MS = 8000, provider = null, latestSync = null, syncSeq = 0, eventWireInstanceCounter = 0, EVENT_TABLES, arrayValidator, ArcArray, objectValidator, ArcObject, ScopedDataStorage, ArcAuthenticationError, ArcAuthorizationError2, ArcValidationError2, ArcPrimitive, stringValidator, ArcString, ArcContextElement, ArcBoolean, ArcId, numberValidator, ArcNumber, ArcEvent, ArcCommand, ArcListener, ArcRoute, ForkedStoreState, ForkedDataStorage, MasterStoreState, MasterDataStorage2, dateValidator, _te, _td, originCache, originStackCache, originError, CLOSE, Query, PostgresError, Errors, types2, Identifier, Parameter, Builder, defaultHandlers, builders, serializers, parsers, mergeUserTypes = function(types22) {
14653
+ }, create, constructorString, COOKIE_PREFIX = "arc_token", TOKEN_BUMP_KEY = "arc:token-bump", DEFAULT_TIMEOUT_MS = 8000, provider = null, latestSync = null, syncSeq = 0, eventWireInstanceCounter = 0, EVENT_TABLES, arrayValidator, ArcArray, objectValidator, ArcObject, ScopedDataStorage, ArcAuthenticationError, ArcAuthorizationError2, ArcValidationError2, ArcPrimitive, stringValidator, ArcString, ArcContextElement, ArcBoolean, ArcId, numberValidator, ArcNumber, ArcEvent, ArcCommand, ArcListener, ArcRoute, ForkedStoreState, ForkedDataStorage, MasterStoreState, MasterDataStorage2, dateValidator, _te, _td, originCache, originStackCache, originError, CLOSE, Query, PostgresError, Errors, types2, Identifier, Parameter, Builder, defaultHandlers, builders, serializers, parsers, mergeUserTypes = function(types22) {
14599
14654
  const user = typeHandlers(types22 || {});
14600
14655
  return {
14601
14656
  serializers: Object.assign({}, serializers, user.serializers),
@@ -17838,8 +17893,72 @@ function apply2(state, patches, applyOptions) {
17838
17893
  }
17839
17894
  return create2(state, mutate, Object.assign(Object.assign({}, applyOptions), { enablePatches: false }));
17840
17895
  }
17841
- function hasLocalStorage2() {
17842
- return typeof localStorage !== "undefined";
17896
+ function hasDocument2() {
17897
+ return typeof document !== "undefined";
17898
+ }
17899
+ function signalCrossTabChange2() {
17900
+ if (typeof localStorage === "undefined")
17901
+ return;
17902
+ try {
17903
+ localStorage.setItem(TOKEN_BUMP_KEY2, String(Date.now()));
17904
+ } catch {}
17905
+ }
17906
+ function isSecureContext2() {
17907
+ return typeof location !== "undefined" && location.protocol === "https:";
17908
+ }
17909
+ function tokenCookieName2(scopeKey) {
17910
+ return scopeKey === "default" ? COOKIE_PREFIX2 : `${COOKIE_PREFIX2}_${scopeKey.replace(/:/g, ".")}`;
17911
+ }
17912
+ function scopeKeyFromCookieName2(name) {
17913
+ if (name === COOKIE_PREFIX2)
17914
+ return "default";
17915
+ if (!name.startsWith(`${COOKIE_PREFIX2}_`))
17916
+ return null;
17917
+ return name.slice(COOKIE_PREFIX2.length + 1).replace(/\./g, ":");
17918
+ }
17919
+ function maxAgeFromExp2(exp) {
17920
+ const THIRTY_DAYS = 30 * 24 * 60 * 60;
17921
+ if (typeof exp !== "number" || !Number.isFinite(exp))
17922
+ return THIRTY_DAYS;
17923
+ const expMs = exp > 1000000000000 ? exp : exp * 1000;
17924
+ const secs = Math.floor((expMs - Date.now()) / 1000);
17925
+ return secs > 0 ? secs : THIRTY_DAYS;
17926
+ }
17927
+ function writeTokenCookie2(scopeKey, jwt, exp) {
17928
+ if (!hasDocument2())
17929
+ return;
17930
+ const attrs = [
17931
+ "Path=/",
17932
+ "SameSite=Lax",
17933
+ `Max-Age=${maxAgeFromExp2(exp)}`
17934
+ ];
17935
+ if (isSecureContext2())
17936
+ attrs.push("Secure");
17937
+ document.cookie = `${tokenCookieName2(scopeKey)}=${encodeURIComponent(jwt)}; ${attrs.join("; ")}`;
17938
+ signalCrossTabChange2();
17939
+ }
17940
+ function removeTokenCookie2(scopeKey) {
17941
+ if (!hasDocument2())
17942
+ return;
17943
+ document.cookie = `${tokenCookieName2(scopeKey)}=; Path=/; SameSite=Lax; Max-Age=0`;
17944
+ signalCrossTabChange2();
17945
+ }
17946
+ function readAllTokenCookies2() {
17947
+ if (!hasDocument2() || !document.cookie)
17948
+ return [];
17949
+ const out = [];
17950
+ for (const part of document.cookie.split(";")) {
17951
+ const eq = part.indexOf("=");
17952
+ if (eq < 0)
17953
+ continue;
17954
+ const scopeKey = scopeKeyFromCookieName2(part.slice(0, eq).trim());
17955
+ if (scopeKey === null)
17956
+ continue;
17957
+ const jwt = decodeURIComponent(part.slice(eq + 1).trim());
17958
+ if (jwt)
17959
+ out.push({ scopeKey, jwt });
17960
+ }
17961
+ return out;
17843
17962
  }
17844
17963
  function notifyTokenChange2(scope) {
17845
17964
  if (typeof window !== "undefined") {
@@ -17855,24 +17974,21 @@ class AuthAdapter2 {
17855
17974
  constructor(options) {
17856
17975
  this.namespace = options?.storageNamespace || undefined;
17857
17976
  }
17858
- storageKey(scope) {
17859
- return this.namespace ? `${TOKEN_PREFIX2}${this.namespace}:${scope}` : TOKEN_PREFIX2 + scope;
17977
+ scopeKey(scope) {
17978
+ return this.namespace ? `${this.namespace}:${scope}` : scope;
17860
17979
  }
17861
17980
  setToken(token, scope = "default") {
17862
17981
  if (!token) {
17863
17982
  this.scopes.delete(scope);
17864
- if (hasLocalStorage2()) {
17865
- localStorage.removeItem(this.storageKey(scope));
17866
- notifyTokenChange2(scope);
17867
- }
17983
+ removeTokenCookie2(this.scopeKey(scope));
17984
+ notifyTokenChange2(scope);
17868
17985
  return;
17869
17986
  }
17870
17987
  try {
17871
17988
  const parts = token.split(".");
17872
17989
  if (parts.length !== 3) {
17873
17990
  this.scopes.delete(scope);
17874
- if (hasLocalStorage2())
17875
- localStorage.removeItem(this.storageKey(scope));
17991
+ removeTokenCookie2(this.scopeKey(scope));
17876
17992
  return;
17877
17993
  }
17878
17994
  const payload = JSON.parse(atob(parts[1]));
@@ -17885,49 +18001,45 @@ class AuthAdapter2 {
17885
18001
  exp: payload.exp
17886
18002
  }
17887
18003
  });
17888
- if (hasLocalStorage2()) {
17889
- localStorage.setItem(this.storageKey(scope), token);
17890
- notifyTokenChange2(scope);
17891
- }
18004
+ writeTokenCookie2(this.scopeKey(scope), token, payload.exp);
18005
+ notifyTokenChange2(scope);
17892
18006
  } catch {
17893
18007
  this.scopes.delete(scope);
17894
- if (hasLocalStorage2())
17895
- localStorage.removeItem(this.storageKey(scope));
18008
+ removeTokenCookie2(this.scopeKey(scope));
17896
18009
  }
17897
18010
  }
17898
18011
  setDecoded(decoded, scope = "default") {
17899
18012
  this.scopes.set(scope, { raw: "", decoded });
17900
18013
  }
17901
18014
  loadPersisted() {
17902
- if (!hasLocalStorage2())
17903
- return;
17904
- const prefix = this.namespace ? `${TOKEN_PREFIX2}${this.namespace}:` : TOKEN_PREFIX2;
17905
- for (let i = 0;i < localStorage.length; i++) {
17906
- const key = localStorage.key(i);
17907
- if (key?.startsWith(prefix)) {
17908
- const scope = key.slice(prefix.length);
17909
- if (!this.namespace && scope.includes(":"))
18015
+ const nsPrefix = this.namespace ? `${this.namespace}:` : "";
18016
+ for (const { scopeKey, jwt } of readAllTokenCookies2()) {
18017
+ let scope;
18018
+ if (this.namespace) {
18019
+ if (!scopeKey.startsWith(nsPrefix))
17910
18020
  continue;
17911
- const raw = localStorage.getItem(key);
17912
- if (raw) {
17913
- try {
17914
- const parts = raw.split(".");
17915
- if (parts.length !== 3)
17916
- continue;
17917
- const payload = JSON.parse(atob(parts[1]));
17918
- this.scopes.set(scope, {
17919
- raw,
17920
- decoded: {
17921
- tokenName: payload.tokenName,
17922
- params: payload.params || {},
17923
- iat: payload.iat,
17924
- exp: payload.exp
17925
- }
17926
- });
17927
- } catch {
17928
- localStorage.removeItem(key);
18021
+ scope = scopeKey.slice(nsPrefix.length);
18022
+ } else {
18023
+ if (scopeKey.includes(":"))
18024
+ continue;
18025
+ scope = scopeKey;
18026
+ }
18027
+ try {
18028
+ const parts = jwt.split(".");
18029
+ if (parts.length !== 3)
18030
+ continue;
18031
+ const payload = JSON.parse(atob(parts[1]));
18032
+ this.scopes.set(scope, {
18033
+ raw: jwt,
18034
+ decoded: {
18035
+ tokenName: payload.tokenName,
18036
+ params: payload.params || {},
18037
+ iat: payload.iat,
18038
+ exp: payload.exp
17929
18039
  }
17930
- }
18040
+ });
18041
+ } catch {
18042
+ removeTokenCookie2(scopeKey);
17931
18043
  }
17932
18044
  }
17933
18045
  }
@@ -17959,10 +18071,8 @@ class AuthAdapter2 {
17959
18071
  return Array.from(this.scopes.keys());
17960
18072
  }
17961
18073
  clear() {
17962
- if (hasLocalStorage2()) {
17963
- for (const scope of this.scopes.keys()) {
17964
- localStorage.removeItem(this.storageKey(scope));
17965
- }
18074
+ for (const scope of this.scopes.keys()) {
18075
+ removeTokenCookie2(this.scopeKey(scope));
17966
18076
  }
17967
18077
  this.scopes.clear();
17968
18078
  }
@@ -20673,7 +20783,7 @@ var Operation2, PROXY_DRAFT2, RAW_RETURN_SYMBOL2, iteratorSymbol2, dataTypes2, i
20673
20783
  }
20674
20784
  return returnValue(result);
20675
20785
  };
20676
- }, create2, constructorString2, TOKEN_PREFIX2 = "arc:token:", DEFAULT_TIMEOUT_MS2 = 8000, provider2 = null, latestSync2 = null, syncSeq2 = 0, eventWireInstanceCounter2 = 0, EVENT_TABLES2, arrayValidator2, ArcArray2, objectValidator2, ArcObject2, ScopedDataStorage2, ArcAuthenticationError2, ArcAuthorizationError3, ArcValidationError3, ArcPrimitive2, stringValidator2, ArcString2, ArcContextElement2, ArcBoolean2, ArcId2, numberValidator2, ArcNumber2, ArcEvent2, ArcCommand2, ArcListener2, ArcRoute2, ForkedStoreState2, ForkedDataStorage2, MasterStoreState2, MasterDataStorage3, dateValidator2, _te2, _td2, SQLiteReadWriteTransaction, createSQLiteAdapterFactory = (db) => {
20786
+ }, create2, constructorString2, COOKIE_PREFIX2 = "arc_token", TOKEN_BUMP_KEY2 = "arc:token-bump", DEFAULT_TIMEOUT_MS2 = 8000, provider2 = null, latestSync2 = null, syncSeq2 = 0, eventWireInstanceCounter2 = 0, EVENT_TABLES2, arrayValidator2, ArcArray2, objectValidator2, ArcObject2, ScopedDataStorage2, ArcAuthenticationError2, ArcAuthorizationError3, ArcValidationError3, ArcPrimitive2, stringValidator2, ArcString2, ArcContextElement2, ArcBoolean2, ArcId2, numberValidator2, ArcNumber2, ArcEvent2, ArcCommand2, ArcListener2, ArcRoute2, ForkedStoreState2, ForkedDataStorage2, MasterStoreState2, MasterDataStorage3, dateValidator2, _te2, _td2, SQLiteReadWriteTransaction, createSQLiteAdapterFactory = (db) => {
20677
20787
  return async (context) => {
20678
20788
  const adapter = new SQLiteAdapter(db, context);
20679
20789
  await adapter.initialize();
@@ -31692,7 +31802,7 @@ function workspaceSourcePlugin(srcByName) {
31692
31802
  }
31693
31803
  };
31694
31804
  }
31695
- var SERVER_ONLY_NODE_BUILTINS = new Set([
31805
+ var SERVER_ONLY_NODE_BUILTINS = [
31696
31806
  "crypto",
31697
31807
  "stream",
31698
31808
  "zlib",
@@ -31720,15 +31830,13 @@ var SERVER_ONLY_NODE_BUILTINS = new Set([
31720
31830
  "diagnostics_channel",
31721
31831
  "module",
31722
31832
  "constants"
31723
- ]);
31833
+ ];
31834
+ var NODE_STUB_FILTER = new RegExp(`^(node:)?(${SERVER_ONLY_NODE_BUILTINS.map((b) => b.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&")).join("|")})$`);
31724
31835
  function nodeServerBuiltinStubPlugin() {
31725
31836
  return {
31726
31837
  name: "node-server-builtin-stub",
31727
31838
  setup(build2) {
31728
- build2.onResolve({ filter: /^(node:)?[a-z_/]+$/ }, (args) => {
31729
- const bare = args.path.replace(/^node:/, "");
31730
- if (!SERVER_ONLY_NODE_BUILTINS.has(bare))
31731
- return;
31839
+ build2.onResolve({ filter: NODE_STUB_FILTER }, (args) => {
31732
31840
  return { path: args.path, namespace: "node-server-stub" };
31733
31841
  });
31734
31842
  build2.onLoad({ filter: /.*/, namespace: "node-server-stub" }, (args) => ({
@@ -36917,11 +37025,11 @@ async function runSurvey(appName) {
36917
37025
  });
36918
37026
  if (BD(serverType))
36919
37027
  cancel();
36920
- const location = await ue({
37028
+ const location2 = await ue({
36921
37029
  message: "Hetzner datacenter location",
36922
37030
  initialValue: "nbg1"
36923
37031
  });
36924
- if (BD(location))
37032
+ if (BD(location2))
36925
37033
  cancel();
36926
37034
  const firstEnv = Object.keys(envs)[0] ?? "host";
36927
37035
  const appSlug = sanitizeImageName(appName ?? "arc-app").replace(/[^a-z0-9-]+/g, "-");
@@ -36929,7 +37037,7 @@ async function runSurvey(appName) {
36929
37037
  const terraform = {
36930
37038
  provider: "hcloud",
36931
37039
  serverType,
36932
- location,
37040
+ location: location2,
36933
37041
  image: "ubuntu-22.04",
36934
37042
  tokenEnv,
36935
37043
  serverName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcote.tech/arc-cli",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "description": "CLI tool for Arc framework",
5
5
  "module": "index.ts",
6
6
  "main": "dist/index.js",
@@ -12,13 +12,13 @@
12
12
  "build": "bun build --target=bun ./src/index.ts --outdir=dist --external @arcote.tech/arc --external @arcote.tech/arc-ds --external @arcote.tech/arc-react --external @arcote.tech/platform --external @arcote.tech/arc-map --external '@opentelemetry/*' && chmod +x dist/index.js"
13
13
  },
14
14
  "dependencies": {
15
- "@arcote.tech/arc": "^0.8.5",
16
- "@arcote.tech/arc-ds": "^0.8.5",
17
- "@arcote.tech/arc-react": "^0.8.5",
18
- "@arcote.tech/arc-host": "^0.8.5",
19
- "@arcote.tech/arc-adapter-db-sqlite": "^0.8.5",
20
- "@arcote.tech/arc-adapter-db-postgres": "^0.8.5",
21
- "@arcote.tech/arc-otel": "^0.8.5",
15
+ "@arcote.tech/arc": "^0.8.6",
16
+ "@arcote.tech/arc-ds": "^0.8.6",
17
+ "@arcote.tech/arc-react": "^0.8.6",
18
+ "@arcote.tech/arc-host": "^0.8.6",
19
+ "@arcote.tech/arc-adapter-db-sqlite": "^0.8.6",
20
+ "@arcote.tech/arc-adapter-db-postgres": "^0.8.6",
21
+ "@arcote.tech/arc-otel": "^0.8.6",
22
22
  "@opentelemetry/api": "^1.9.0",
23
23
  "@opentelemetry/api-logs": "^0.57.0",
24
24
  "@opentelemetry/core": "^1.30.0",
@@ -31,8 +31,8 @@
31
31
  "@opentelemetry/sdk-trace-base": "^1.30.0",
32
32
  "@opentelemetry/sdk-trace-node": "^1.30.0",
33
33
  "@opentelemetry/semantic-conventions": "^1.27.0",
34
- "@arcote.tech/platform": "^0.8.5",
35
- "@arcote.tech/arc-map": "^0.8.5",
34
+ "@arcote.tech/platform": "^0.8.6",
35
+ "@arcote.tech/arc-map": "^0.8.6",
36
36
  "@clack/prompts": "^0.9.0",
37
37
  "commander": "^11.1.0",
38
38
  "chokidar": "^3.5.3",
@@ -248,12 +248,27 @@ function workspaceSourcePlugin(srcByName: Map<string, string>): import("bun").Bu
248
248
  // CELOWO NIE stubujemy „przeglądarkowo-bezpiecznych" builtinów (buffer, util,
249
249
  // events, path, url, string_decoder, querystring, assert, process) — te bywają
250
250
  // realnie używane po stronie klienta i mają lekkie, działające polyfille.
251
- const SERVER_ONLY_NODE_BUILTINS = new Set([
251
+ const SERVER_ONLY_NODE_BUILTINS = [
252
252
  "crypto", "stream", "zlib", "fs", "fs/promises", "net", "tls", "http",
253
253
  "https", "http2", "dns", "dgram", "child_process", "worker_threads",
254
254
  "cluster", "os", "v8", "vm", "readline", "repl", "tty", "perf_hooks",
255
255
  "inspector", "async_hooks", "diagnostics_channel", "module", "constants",
256
- ]);
256
+ ];
257
+
258
+ /**
259
+ * Filtr onResolve dopasowujący DOKŁADNIE serwerowe builtiny (`node:crypto`,
260
+ * `crypto`, `fs/promises`, …) i NIC innego. KRYTYCZNE, że jest precyzyjny:
261
+ * szeroki filtr `/^(node:)?[a-z_/]+$/` łapał też gołe pakiety npm (np. `unified`,
262
+ * `vfile`, `micromark`), a samo przepuszczenie ich przez onResolve — nawet ze
263
+ * zwrotem `undefined` — korumpuje tree-shaking Buna pod minify: pakiet znika z
264
+ * bundla, ale zostaje wiszące wywołanie (`ReferenceError: X is not defined` w
265
+ * produkcji — react-markdown/`unified()` na stronach z markdownem).
266
+ */
267
+ const NODE_STUB_FILTER = new RegExp(
268
+ `^(node:)?(${SERVER_ONLY_NODE_BUILTINS.map((b) =>
269
+ b.replace(/[.*+?^${}()|[\]\\/]/g, "\\$&"),
270
+ ).join("|")})$`,
271
+ );
257
272
 
258
273
  /**
259
274
  * Zastępuje serwerowe builtiny node (SERVER_ONLY_NODE_BUILTINS) rzucającym
@@ -266,9 +281,7 @@ function nodeServerBuiltinStubPlugin(): import("bun").BunPlugin {
266
281
  return {
267
282
  name: "node-server-builtin-stub",
268
283
  setup(build) {
269
- build.onResolve({ filter: /^(node:)?[a-z_/]+$/ }, (args) => {
270
- const bare = args.path.replace(/^node:/, "");
271
- if (!SERVER_ONLY_NODE_BUILTINS.has(bare)) return undefined;
284
+ build.onResolve({ filter: NODE_STUB_FILTER }, (args) => {
272
285
  return { path: args.path, namespace: "node-server-stub" };
273
286
  });
274
287
  build.onLoad({ filter: /.*/, namespace: "node-server-stub" }, (args) => ({