@zuplo/cli 7.11.4 → 7.11.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.
Files changed (35) hide show
  1. package/node_modules/@posthog/core/dist/featureFlagUtils.d.ts +1 -1
  2. package/node_modules/@posthog/core/dist/featureFlagUtils.d.ts.map +1 -1
  3. package/node_modules/@posthog/core/dist/featureFlagUtils.js +1 -0
  4. package/node_modules/@posthog/core/dist/featureFlagUtils.mjs +1 -0
  5. package/node_modules/@posthog/core/package.json +1 -1
  6. package/node_modules/@posthog/core/src/featureFlagUtils.ts +1 -0
  7. package/node_modules/@zuplo/core/package.json +1 -1
  8. package/node_modules/@zuplo/graphql/package.json +1 -1
  9. package/node_modules/@zuplo/openapi-tools/package.json +1 -1
  10. package/node_modules/@zuplo/otel/package.json +1 -1
  11. package/node_modules/@zuplo/runtime/out/esm/chunk-5SHD5VGF.js +412 -0
  12. package/node_modules/@zuplo/runtime/out/esm/chunk-5SHD5VGF.js.map +1 -0
  13. package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
  14. package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
  15. package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
  16. package/node_modules/@zuplo/runtime/out/esm/mocks/index.js.map +1 -1
  17. package/node_modules/@zuplo/runtime/out/types/index.d.ts +50 -0
  18. package/node_modules/@zuplo/runtime/out/types/internal/index.d.ts +38 -0
  19. package/node_modules/@zuplo/runtime/out/types/mcp/messages/index.d.ts +38 -0
  20. package/node_modules/@zuplo/runtime/out/types/mcp-gateway/index.d.ts +38 -0
  21. package/node_modules/@zuplo/runtime/out/types/mocks/index.d.ts +38 -0
  22. package/node_modules/@zuplo/runtime/out/types/sdks/aws/index.d.ts +38 -0
  23. package/node_modules/@zuplo/runtime/package.json +1 -1
  24. package/node_modules/fast-copy/README.md +8 -1
  25. package/node_modules/fast-copy/dist/cjs/index.cjs +23 -3
  26. package/node_modules/fast-copy/dist/cjs/index.cjs.map +1 -1
  27. package/node_modules/fast-copy/dist/es/index.mjs +23 -3
  28. package/node_modules/fast-copy/dist/es/index.mjs.map +1 -1
  29. package/node_modules/fast-copy/dist/umd/index.js +23 -3
  30. package/node_modules/fast-copy/dist/umd/index.js.map +1 -1
  31. package/node_modules/fast-copy/package.json +1 -1
  32. package/package.json +11 -11
  33. package/node_modules/@zuplo/runtime/out/esm/chunk-3RVZUQKN.js +0 -412
  34. package/node_modules/@zuplo/runtime/out/esm/chunk-3RVZUQKN.js.map +0 -1
  35. /package/node_modules/@zuplo/runtime/out/esm/{chunk-3RVZUQKN.js.LEGAL.txt → chunk-5SHD5VGF.js.LEGAL.txt} +0 -0
@@ -22,5 +22,5 @@
22
22
  * DEALINGS IN THE SOFTWARE.
23
23
  *--------------------------------------------------------------------------------------------*/
24
24
 
25
- import{E as p,J as c,M as u}from"../chunk-3RVZUQKN.js";import"../chunk-NUVXDVLJ.js";import{a as d}from"../chunk-QGAJTUPE.js";import"../chunk-A3QGJZO7.js";import"../chunk-CDEAY3VY.js";import{aa as i}from"../chunk-LVSZ3WTO.js";import{a as o}from"../chunk-TYV53J3B.js";function w(l={request:new Request("https://api.example.com")}){let e=[];function t(s){e.push(Promise.resolve(s))}return o(t,"waitUntil"),{context:new a({event:{waitUntil:t},route:l.route,originalRequest:l.request}),invokeResponse:o(async()=>{await Promise.all(e)},"invokeResponse")}}o(w,"createMockContext");var g={path:"/",methods:["GET"],handler:{module:{},export:"default"},raw:o(()=>({}),"raw")},a=class extends EventTarget{static{o(this,"MockZuploContext")}#e;#t;contextId;requestId;log;route;custom;incomingRequestProperties;parentContext;analyticsContext;constructor({event:e,route:t=g,parentContext:n,originalRequest:r}){super(),this.requestId=crypto.randomUUID(),this.contextId=crypto.randomUUID(),this.log={info:i.console.info,log:i.console.log,debug:i.console.debug,warn:i.console.warn,error:i.console.error,setLogProperties:o(()=>{},"setLogProperties")},this.custom={},this.route=t,this.incomingRequestProperties={ip:"203.0.113.7",asn:1234,asOrganization:"ORGANIZATION",city:"Seattle",region:"Washington",regionCode:"WA",colo:"SEA",continent:"NA",country:"US",postalCode:"98004",metroCode:"SEA",latitude:void 0,longitude:void 0,timezone:void 0,httpProtocol:void 0,clientCert:void 0,clientMtlsVerificationStatus:void 0,clientMtlsVerificationReason:void 0,clientCertFingerprintSha256:void 0,clientCertNotBefore:void 0,clientCertNotAfter:void 0,clientCertIssuerDn:void 0,clientCertSubjectDn:void 0},this.parentContext=n,this.#e=e,this.#t=r,this.analyticsContext=new c(this.requestId)}waitUntil(e){this.#e.waitUntil(e)}invokeInboundPolicy(e,t){throw new Error("Not implemented")}invokeOutboundPolicy(e,t,n){throw new Error("Not implemented")}invokeRoute(e,t){throw new Error("Not implemented")}addResponseSendingHook(e){throw new Error("Not implemented")}addResponseSendingFinalHook(e){throw new Error("Not implemented")}addPreRequestHandler(e,t){let n;try{n=u.getContextExtensions(this)}catch{n=u.initialize(this,new d(this.#t??new Request("https://api.example.com")))}n.preRequestPhase??="active",p(this,n,e,t)}get preRequestHandlers(){let e;try{e=u.getContextExtensions(this)}catch{return[]}return(e.preRequestState?.entries??[]).map(t=>({policyName:t.policyName,name:t.name}))}addEventListener(e,t,n){let r=o(s=>{try{typeof t=="function"?t(s):t.handleEvent(s)}catch(m){throw this.log.error(`Error invoking event ${e}. See following logs for details.`),m}},"wrapped");super.addEventListener(e,r,n)}};export{a as MockZuploContext,w as createMockContext};
25
+ import{E as p,J as c,M as u}from"../chunk-5SHD5VGF.js";import"../chunk-NUVXDVLJ.js";import{a as d}from"../chunk-QGAJTUPE.js";import"../chunk-A3QGJZO7.js";import"../chunk-CDEAY3VY.js";import{aa as i}from"../chunk-LVSZ3WTO.js";import{a as o}from"../chunk-TYV53J3B.js";function w(l={request:new Request("https://api.example.com")}){let e=[];function t(s){e.push(Promise.resolve(s))}return o(t,"waitUntil"),{context:new a({event:{waitUntil:t},route:l.route,originalRequest:l.request}),invokeResponse:o(async()=>{await Promise.all(e)},"invokeResponse")}}o(w,"createMockContext");var g={path:"/",methods:["GET"],handler:{module:{},export:"default"},raw:o(()=>({}),"raw")},a=class extends EventTarget{static{o(this,"MockZuploContext")}#e;#t;contextId;requestId;log;route;custom;incomingRequestProperties;parentContext;analyticsContext;constructor({event:e,route:t=g,parentContext:n,originalRequest:r}){super(),this.requestId=crypto.randomUUID(),this.contextId=crypto.randomUUID(),this.log={info:i.console.info,log:i.console.log,debug:i.console.debug,warn:i.console.warn,error:i.console.error,setLogProperties:o(()=>{},"setLogProperties"),setRequestProperties:o(()=>{},"setRequestProperties")},this.custom={},this.route=t,this.incomingRequestProperties={ip:"203.0.113.7",asn:1234,asOrganization:"ORGANIZATION",city:"Seattle",region:"Washington",regionCode:"WA",colo:"SEA",continent:"NA",country:"US",postalCode:"98004",metroCode:"SEA",latitude:void 0,longitude:void 0,timezone:void 0,httpProtocol:void 0,clientCert:void 0,clientMtlsVerificationStatus:void 0,clientMtlsVerificationReason:void 0,clientCertFingerprintSha256:void 0,clientCertNotBefore:void 0,clientCertNotAfter:void 0,clientCertIssuerDn:void 0,clientCertSubjectDn:void 0},this.parentContext=n,this.#e=e,this.#t=r,this.analyticsContext=new c(this.requestId)}waitUntil(e){this.#e.waitUntil(e)}invokeInboundPolicy(e,t){throw new Error("Not implemented")}invokeOutboundPolicy(e,t,n){throw new Error("Not implemented")}invokeRoute(e,t){throw new Error("Not implemented")}addResponseSendingHook(e){throw new Error("Not implemented")}addResponseSendingFinalHook(e){throw new Error("Not implemented")}addPreRequestHandler(e,t){let n;try{n=u.getContextExtensions(this)}catch{n=u.initialize(this,new d(this.#t??new Request("https://api.example.com")))}n.preRequestPhase??="active",p(this,n,e,t)}get preRequestHandlers(){let e;try{e=u.getContextExtensions(this)}catch{return[]}return(e.preRequestState?.entries??[]).map(t=>({policyName:t.policyName,name:t.name}))}addEventListener(e,t,n){let r=o(s=>{try{typeof t=="function"?t(s):t.handleEvent(s)}catch(m){throw this.log.error(`Error invoking event ${e}. See following logs for details.`),m}},"wrapped");super.addEventListener(e,r,n)}};export{a as MockZuploContext,w as createMockContext};
26
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@zuplo/runtime/mocks/context.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;0QAkCO,SAASA,EACdC,EAA6D,CAC3D,QAAS,IAAI,QAAQ,yBAAyB,CAChD,EACA,CACA,IAAMC,EAAwC,CAAC,EAG/C,SAASC,EAAUC,EAA6B,CAC9CF,EAAkB,KAAK,QAAQ,QAAQE,CAAO,CAAC,CACjD,CAFS,OAAAC,EAAAF,EAAA,aAcF,CAAE,QAVO,IAAIG,EAAiB,CACnC,MAAO,CAAE,UAAAH,CAAU,EACnB,MAAOF,EAAQ,MACf,gBAAiBA,EAAQ,OAC3B,CAAC,EAMiB,eAJKI,EAAA,SAAY,CACjC,MAAM,QAAQ,IAAIH,CAAiB,CACrC,EAFuB,iBAIU,CACnC,CAvBgBG,EAAAL,EAAA,qBAyBhB,IAAMO,EAA2C,CAC/C,KAAM,IACN,QAAS,CAAC,KAAK,EACf,QAAS,CACP,OAAQ,CAAC,EACT,OAAQ,SACV,EACA,IAAKF,EAAA,KAAU,CAAC,GAAX,MACP,EAMaC,EAAN,cAA+B,WAAoC,CAzE1E,MAyE0E,CAAAD,EAAA,yBAC/DG,GACAC,GACA,UACA,UACA,IACA,MAEA,OACA,0BACA,cACA,iBAET,YAAY,CACV,MAAAC,EACA,MAAAC,EAAQJ,EACR,cAAAK,EACA,gBAAAC,CACF,EAUG,CACD,MAAM,EACN,KAAK,UAAY,OAAO,WAAW,EACnC,KAAK,UAAY,OAAO,WAAW,EAEnC,KAAK,IAAM,CACT,KAAMC,EAAU,QAAQ,KACxB,IAAKA,EAAU,QAAQ,IACvB,MAAOA,EAAU,QAAQ,MACzB,KAAMA,EAAU,QAAQ,KACxB,MAAOA,EAAU,QAAQ,MACzB,iBAAkBT,EAAA,IAAM,CAAC,EAAP,mBACpB,EACA,KAA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D,EAAI,iBAAiB,SAAW,CAAC,GAAG,IAAKI,IAAW,CAC1D,WAAYA,EAAM,WAClB,KAAMA,EAAM,IACd,EAAE,CACJ,CAES,iBACPC,EACAN,EACArB,EACM,CACN,IAAM4B,EAA8CxB,EAACyB,GAAM,CACzD,GAAI,CACF,OAAOR,GAAY,WAAaA,EAAQQ,CAAC,EAAIR,EAAQ,YAAYQ,CAAC,CACpE,OAASC,EAAK,CACZ,WAAK,IAAI,MACP,wBAAwBH,CAAI,mCAC9B,EACMG,CACR,CACF,EAToD,WAUpD,MAAM,iBAAiBH,EAAMC,EAAS5B,CAAO,CAC/C,CACF","names":["createMockContext","options","waitUntilPromises","waitUntil","promise","__name","MockZuploContext","DEFAULT_ROUTE_CONFIG","#event","#originalRequest","event","route","parentContext","originalRequest","internals_default","ZuploGatewayAnalyticsContext","policyName","request","response","input","init","hook","handler","ext","ZuploContextExtensions","ZuploRequest","registerPreRequestHandler","entry","type","wrapped","e","err"]}
1
+ {"version":3,"sources":["@zuplo/runtime/mocks/context.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;0QAkCO,SAASA,EACdC,EAA6D,CAC3D,QAAS,IAAI,QAAQ,yBAAyB,CAChD,EACA,CACA,IAAMC,EAAwC,CAAC,EAG/C,SAASC,EAAUC,EAA6B,CAC9CF,EAAkB,KAAK,QAAQ,QAAQE,CAAO,CAAC,CACjD,CAFS,OAAAC,EAAAF,EAAA,aAcF,CAAE,QAVO,IAAIG,EAAiB,CACnC,MAAO,CAAE,UAAAH,CAAU,EACnB,MAAOF,EAAQ,MACf,gBAAiBA,EAAQ,OAC3B,CAAC,EAMiB,eAJKI,EAAA,SAAY,CACjC,MAAM,QAAQ,IAAIH,CAAiB,CACrC,EAFuB,iBAIU,CACnC,CAvBgBG,EAAAL,EAAA,qBAyBhB,IAAMO,EAA2C,CAC/C,KAAM,IACN,QAAS,CAAC,KAAK,EACf,QAAS,CACP,OAAQ,CAAC,EACT,OAAQ,SACV,EACA,IAAKF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AAI,MAAM,iBAAiB,CACnC,CAKA,uBAAuBC,EAAmC,CACxD,MAAM,IAAI,MAAM,iBAAiB,CACnC,CAKA,4BAA4BA,EAAwC,CAClE,MAAM,IAAI,MAAM,iBAAiB,CACnC,CAQA,qBACEC,EACArB,EACM,CAIN,IAAIsB,EACJ,GAAI,CACFA,EAAMC,EAAuB,qBAAqB,IAAI,CACxD,MAAQ,CACND,EAAMC,EAAuB,WAC3B,KACA,IAAIC,EACF,KAAKhB,IAAoB,IAAI,QAAQ,yBAAyB,CAChE,CACF,CACF,CAKAc,EAAI,kBAAoB,SACxBG,EAA0B,KAAMH,EAAKD,EAASrB,CAAO,CACvD,CAgBA,IAAI,oBAAyE,CAC3E,IAAIsB,EACJ,GAAI,CACFA,EAAMC,EAAuB,qBAAqB,IAAI,CACxD,MAAQ,CACN,MAAO,CAAC,CACV,CACA,OAAQD,EAAI,iBAAiB,SAAW,CAAC,GAAG,IAAKI,IAAW,CAC1D,WAAYA,EAAM,WAClB,KAAMA,EAAM,IACd,EAAE,CACJ,CAES,iBACPC,EACAN,EACArB,EACM,CACN,IAAM4B,EAA8CxB,EAACyB,GAAM,CACzD,GAAI,CACF,OAAOR,GAAY,WAAaA,EAAQQ,CAAC,EAAIR,EAAQ,YAAYQ,CAAC,CACpE,OAASC,EAAK,CACZ,WAAK,IAAI,MACP,wBAAwBH,CAAI,mCAC9B,EACMG,CACR,CACF,EAToD,WAUpD,MAAM,iBAAiBH,EAAMC,EAAS5B,CAAO,CAC/C,CACF","names":["createMockContext","options","waitUntilPromises","waitUntil","promise","__name","MockZuploContext","DEFAULT_ROUTE_CONFIG","#event","#originalRequest","event","route","parentContext","originalRequest","internals_default","ZuploGatewayAnalyticsContext","policyName","request","response","input","init","hook","handler","ext","ZuploContextExtensions","ZuploRequest","registerPreRequestHandler","entry","type","wrapped","e","err"]}
@@ -8658,6 +8658,44 @@ export declare interface Logger extends SystemLogger {
8658
8658
  setLogProperties?(
8659
8659
  properties: Record<string, string | number | boolean>
8660
8660
  ): void;
8661
+ /**
8662
+ * Attach properties to this request's row in Zuplo's request log, the one
8663
+ * row per request that analytics and the request details view read.
8664
+ *
8665
+ * This differs from `setLogProperties`, which adds fields to every log
8666
+ * entry (each `context.log.info(...)` line) that log plugins ship. Use
8667
+ * `setRequestProperties` to label the request itself, for example with a
8668
+ * tenant ID, a feature flag or an experiment variant.
8669
+ *
8670
+ * Each call merges into the properties already set for this request, and a
8671
+ * later value for the same key overwrites an earlier one. Numbers and
8672
+ * booleans are stored as strings, and `null` or `undefined` values are
8673
+ * skipped. A request made with `context.invokeRoute` has a row of its own,
8674
+ * so properties set while it runs land on that row, not on the caller's.
8675
+ *
8676
+ * To keep rows small, a request holds at most 64 properties, a key can be
8677
+ * at most 128 characters, and a value at most 2048 characters. A longer
8678
+ * value is truncated, and a property over the other limits is dropped. The
8679
+ * method never throws.
8680
+ *
8681
+ * @param properties - Key-value pairs to attach to the request's log row.
8682
+ *
8683
+ * @example
8684
+ * ```ts
8685
+ * export default async function (request: ZuploRequest, context: ZuploContext) {
8686
+ * context.log.setRequestProperties({
8687
+ * tenantId: request.user?.data.tenantId,
8688
+ * pricingExperiment: "variant-b",
8689
+ * cached: false,
8690
+ * });
8691
+ *
8692
+ * return new Response("ok");
8693
+ * }
8694
+ * ```
8695
+ */
8696
+ setRequestProperties(
8697
+ properties: Record<string, string | number | boolean | undefined | null>
8698
+ ): void;
8661
8699
  }
8662
8700
 
8663
8701
  /* Excluded from this release type: LoggingContext */
@@ -10745,6 +10783,18 @@ declare interface MetricsData {
10745
10783
  parentContextId?: string;
10746
10784
  requestId: string;
10747
10785
  parentRequestId?: string;
10786
+ /**
10787
+ * The full URL, query string included, of the request as the gateway
10788
+ * received it for this route invocation. For a request made with
10789
+ * `context.invokeRoute` this is the invoked URL, for example
10790
+ * `http://localhost/some/path`.
10791
+ */
10792
+ url?: string;
10793
+ /**
10794
+ * Free-form properties attached with `context.log.setRequestProperties`.
10795
+ * Omitted when none were set.
10796
+ */
10797
+ properties?: Record<string, string>;
10748
10798
  routePath: string;
10749
10799
  systemRouteName?: string;
10750
10800
  method: HttpMethod;
@@ -1058,6 +1058,44 @@ declare interface Logger extends BaseLogger {
1058
1058
  setLogProperties?(
1059
1059
  properties: Record<string, string | number | boolean>
1060
1060
  ): void;
1061
+ /**
1062
+ * Attach properties to this request's row in Zuplo's request log, the one
1063
+ * row per request that analytics and the request details view read.
1064
+ *
1065
+ * This differs from `setLogProperties`, which adds fields to every log
1066
+ * entry (each `context.log.info(...)` line) that log plugins ship. Use
1067
+ * `setRequestProperties` to label the request itself, for example with a
1068
+ * tenant ID, a feature flag or an experiment variant.
1069
+ *
1070
+ * Each call merges into the properties already set for this request, and a
1071
+ * later value for the same key overwrites an earlier one. Numbers and
1072
+ * booleans are stored as strings, and `null` or `undefined` values are
1073
+ * skipped. A request made with `context.invokeRoute` has a row of its own,
1074
+ * so properties set while it runs land on that row, not on the caller's.
1075
+ *
1076
+ * To keep rows small, a request holds at most 64 properties, a key can be
1077
+ * at most 128 characters, and a value at most 2048 characters. A longer
1078
+ * value is truncated, and a property over the other limits is dropped. The
1079
+ * method never throws.
1080
+ *
1081
+ * @param properties - Key-value pairs to attach to the request's log row.
1082
+ *
1083
+ * @example
1084
+ * ```ts
1085
+ * export default async function (request: ZuploRequest, context: ZuploContext) {
1086
+ * context.log.setRequestProperties({
1087
+ * tenantId: request.user?.data.tenantId,
1088
+ * pricingExperiment: "variant-b",
1089
+ * cached: false,
1090
+ * });
1091
+ *
1092
+ * return new Response("ok");
1093
+ * }
1094
+ * ```
1095
+ */
1096
+ setRequestProperties(
1097
+ properties: Record<string, string | number | boolean | undefined | null>
1098
+ ): void;
1061
1099
  }
1062
1100
 
1063
1101
  declare type Modify<T, R> = Omit<T, keyof R> & R;
@@ -986,6 +986,44 @@ declare interface Logger extends BaseLogger {
986
986
  setLogProperties?(
987
987
  properties: Record<string, string | number | boolean>
988
988
  ): void;
989
+ /**
990
+ * Attach properties to this request's row in Zuplo's request log, the one
991
+ * row per request that analytics and the request details view read.
992
+ *
993
+ * This differs from `setLogProperties`, which adds fields to every log
994
+ * entry (each `context.log.info(...)` line) that log plugins ship. Use
995
+ * `setRequestProperties` to label the request itself, for example with a
996
+ * tenant ID, a feature flag or an experiment variant.
997
+ *
998
+ * Each call merges into the properties already set for this request, and a
999
+ * later value for the same key overwrites an earlier one. Numbers and
1000
+ * booleans are stored as strings, and `null` or `undefined` values are
1001
+ * skipped. A request made with `context.invokeRoute` has a row of its own,
1002
+ * so properties set while it runs land on that row, not on the caller's.
1003
+ *
1004
+ * To keep rows small, a request holds at most 64 properties, a key can be
1005
+ * at most 128 characters, and a value at most 2048 characters. A longer
1006
+ * value is truncated, and a property over the other limits is dropped. The
1007
+ * method never throws.
1008
+ *
1009
+ * @param properties - Key-value pairs to attach to the request's log row.
1010
+ *
1011
+ * @example
1012
+ * ```ts
1013
+ * export default async function (request: ZuploRequest, context: ZuploContext) {
1014
+ * context.log.setRequestProperties({
1015
+ * tenantId: request.user?.data.tenantId,
1016
+ * pricingExperiment: "variant-b",
1017
+ * cached: false,
1018
+ * });
1019
+ *
1020
+ * return new Response("ok");
1021
+ * }
1022
+ * ```
1023
+ */
1024
+ setRequestProperties(
1025
+ properties: Record<string, string | number | boolean | undefined | null>
1026
+ ): void;
989
1027
  }
990
1028
 
991
1029
  /**
@@ -1114,6 +1114,44 @@ declare interface Logger extends BaseLogger {
1114
1114
  setLogProperties?(
1115
1115
  properties: Record<string, string | number | boolean>
1116
1116
  ): void;
1117
+ /**
1118
+ * Attach properties to this request's row in Zuplo's request log, the one
1119
+ * row per request that analytics and the request details view read.
1120
+ *
1121
+ * This differs from `setLogProperties`, which adds fields to every log
1122
+ * entry (each `context.log.info(...)` line) that log plugins ship. Use
1123
+ * `setRequestProperties` to label the request itself, for example with a
1124
+ * tenant ID, a feature flag or an experiment variant.
1125
+ *
1126
+ * Each call merges into the properties already set for this request, and a
1127
+ * later value for the same key overwrites an earlier one. Numbers and
1128
+ * booleans are stored as strings, and `null` or `undefined` values are
1129
+ * skipped. A request made with `context.invokeRoute` has a row of its own,
1130
+ * so properties set while it runs land on that row, not on the caller's.
1131
+ *
1132
+ * To keep rows small, a request holds at most 64 properties, a key can be
1133
+ * at most 128 characters, and a value at most 2048 characters. A longer
1134
+ * value is truncated, and a property over the other limits is dropped. The
1135
+ * method never throws.
1136
+ *
1137
+ * @param properties - Key-value pairs to attach to the request's log row.
1138
+ *
1139
+ * @example
1140
+ * ```ts
1141
+ * export default async function (request: ZuploRequest, context: ZuploContext) {
1142
+ * context.log.setRequestProperties({
1143
+ * tenantId: request.user?.data.tenantId,
1144
+ * pricingExperiment: "variant-b",
1145
+ * cached: false,
1146
+ * });
1147
+ *
1148
+ * return new Response("ok");
1149
+ * }
1150
+ * ```
1151
+ */
1152
+ setRequestProperties(
1153
+ properties: Record<string, string | number | boolean | undefined | null>
1154
+ ): void;
1117
1155
  }
1118
1156
 
1119
1157
  /* Excluded from this release type: LookupResult */
@@ -893,6 +893,44 @@ declare interface Logger extends BaseLogger {
893
893
  setLogProperties?(
894
894
  properties: Record<string, string | number | boolean>
895
895
  ): void;
896
+ /**
897
+ * Attach properties to this request's row in Zuplo's request log, the one
898
+ * row per request that analytics and the request details view read.
899
+ *
900
+ * This differs from `setLogProperties`, which adds fields to every log
901
+ * entry (each `context.log.info(...)` line) that log plugins ship. Use
902
+ * `setRequestProperties` to label the request itself, for example with a
903
+ * tenant ID, a feature flag or an experiment variant.
904
+ *
905
+ * Each call merges into the properties already set for this request, and a
906
+ * later value for the same key overwrites an earlier one. Numbers and
907
+ * booleans are stored as strings, and `null` or `undefined` values are
908
+ * skipped. A request made with `context.invokeRoute` has a row of its own,
909
+ * so properties set while it runs land on that row, not on the caller's.
910
+ *
911
+ * To keep rows small, a request holds at most 64 properties, a key can be
912
+ * at most 128 characters, and a value at most 2048 characters. A longer
913
+ * value is truncated, and a property over the other limits is dropped. The
914
+ * method never throws.
915
+ *
916
+ * @param properties - Key-value pairs to attach to the request's log row.
917
+ *
918
+ * @example
919
+ * ```ts
920
+ * export default async function (request: ZuploRequest, context: ZuploContext) {
921
+ * context.log.setRequestProperties({
922
+ * tenantId: request.user?.data.tenantId,
923
+ * pricingExperiment: "variant-b",
924
+ * cached: false,
925
+ * });
926
+ *
927
+ * return new Response("ok");
928
+ * }
929
+ * ```
930
+ */
931
+ setRequestProperties(
932
+ properties: Record<string, string | number | boolean | undefined | null>
933
+ ): void;
896
934
  }
897
935
 
898
936
  /**
@@ -1270,6 +1270,44 @@ declare interface Logger extends BaseLogger {
1270
1270
  setLogProperties?(
1271
1271
  properties: Record<string, string | number | boolean>
1272
1272
  ): void;
1273
+ /**
1274
+ * Attach properties to this request's row in Zuplo's request log, the one
1275
+ * row per request that analytics and the request details view read.
1276
+ *
1277
+ * This differs from `setLogProperties`, which adds fields to every log
1278
+ * entry (each `context.log.info(...)` line) that log plugins ship. Use
1279
+ * `setRequestProperties` to label the request itself, for example with a
1280
+ * tenant ID, a feature flag or an experiment variant.
1281
+ *
1282
+ * Each call merges into the properties already set for this request, and a
1283
+ * later value for the same key overwrites an earlier one. Numbers and
1284
+ * booleans are stored as strings, and `null` or `undefined` values are
1285
+ * skipped. A request made with `context.invokeRoute` has a row of its own,
1286
+ * so properties set while it runs land on that row, not on the caller's.
1287
+ *
1288
+ * To keep rows small, a request holds at most 64 properties, a key can be
1289
+ * at most 128 characters, and a value at most 2048 characters. A longer
1290
+ * value is truncated, and a property over the other limits is dropped. The
1291
+ * method never throws.
1292
+ *
1293
+ * @param properties - Key-value pairs to attach to the request's log row.
1294
+ *
1295
+ * @example
1296
+ * ```ts
1297
+ * export default async function (request: ZuploRequest, context: ZuploContext) {
1298
+ * context.log.setRequestProperties({
1299
+ * tenantId: request.user?.data.tenantId,
1300
+ * pricingExperiment: "variant-b",
1301
+ * cached: false,
1302
+ * });
1303
+ *
1304
+ * return new Response("ok");
1305
+ * }
1306
+ * ```
1307
+ */
1308
+ setRequestProperties(
1309
+ properties: Record<string, string | number | boolean | undefined | null>
1310
+ ): void;
1273
1311
  }
1274
1312
 
1275
1313
  declare type Modify<T, R> = Omit<T, keyof R> & R;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
3
  "type": "module",
4
- "version": "7.11.4",
4
+ "version": "7.11.6",
5
5
  "repository": "https://github.com/zuplo/zuplo",
6
6
  "author": "Zuplo, Inc.",
7
7
  "exports": {
@@ -27,6 +27,7 @@ A [blazing fast](#benchmarks) deep object copier
27
27
  - [Aspects of default copiers](#aspects-of-default-copiers)
28
28
  - [Error references are copied directly, instead of creating a new `*Error` object](#error-references-are-copied-directly-instead-of-creating-a-new-error-object)
29
29
  - [The constructor of the original object is used, instead of using known globals](#the-constructor-of-the-original-object-is-used-instead-of-using-known-globals)
30
+ - [Sparse arrays are copied densely, unless using `copyStrict`](#sparse-arrays-are-copied-densely-unless-using-copystrict)
30
31
  - [Benchmarks](#benchmarks)
31
32
  - [Simple objects](#simple-objects)
32
33
  - [Complex objects](#complex-objects)
@@ -72,7 +73,8 @@ Deeply copy the object passed, but with additional strictness when replicating t
72
73
 
73
74
  - Properties retain their original property descriptor
74
75
  - Non-enumerable keys are copied
75
- - Non-standard properties (e.g., keys on arrays / maps / sets) are copied
76
+ - Non-standard properties (e.g., keys on arrays / dates / maps / sets) are copied
77
+ - Holes in sparse arrays are preserved
76
78
 
77
79
  ```js
78
80
  import { copyStrict } from 'fast-copy';
@@ -353,6 +355,11 @@ constructor of the original object. However, the expectation is that these subcl
353
355
  signature as their native base class. This is a common community practice, but there is the possibility of inaccuracy if
354
356
  the contract differs.
355
357
 
358
+ ### Sparse arrays are copied densely, unless using `copyStrict`
359
+
360
+ For performance, [`copy`](#copy) copies every index up to `length`, so holes in sparse arrays become explicit
361
+ `undefined` values (e.g., `copy([, 1])` has the key `0`). [`copyStrict`](#copystrict) preserves holes.
362
+
356
363
  ## Benchmarks
357
364
 
358
365
  #### Simple objects
@@ -29,7 +29,8 @@ function getCleanClone(prototype) {
29
29
  if (Constructor === Object) {
30
30
  return prototype === Object.prototype ? {} : Object.create(prototype);
31
31
  }
32
- if (Constructor && ~toStringFunction.call(Constructor).indexOf('[native code]')) {
32
+ // 2026-10-10: Prototype constructor properties may contain ordinary data.
33
+ if (typeof Constructor === 'function' && ~toStringFunction.call(Constructor).indexOf('[native code]')) {
33
34
  try {
34
35
  return new Constructor();
35
36
  }
@@ -144,6 +145,15 @@ function copyDataView(dataView, state) {
144
145
  function copyDate(date, state) {
145
146
  return new state.Constructor(date.getTime());
146
147
  }
148
+ /**
149
+ * Copy the time of the original Date, as well as any custom properties.
150
+ */
151
+ function copyDateStrict(date, state) {
152
+ const clone = copyDate(date, state);
153
+ // set in the cache immediately to be able to reuse the object recursively
154
+ state.cache.set(date, clone);
155
+ return copyOwnPropertiesStrict(date, clone, state);
156
+ }
147
157
  /**
148
158
  * Deeply copy the keys and values of the original.
149
159
  */
@@ -170,7 +180,17 @@ function copyObjectLoose(object, state) {
170
180
  // set in the cache immediately to be able to reuse the object recursively
171
181
  state.cache.set(object, clone);
172
182
  for (const key of Object.keys(object)) {
173
- clone[key] = state.copier(object[key], state);
183
+ if (key === '__proto__') {
184
+ Object.defineProperty(clone, key, {
185
+ configurable: true,
186
+ enumerable: true,
187
+ value: state.copier(object[key], state),
188
+ writable: true,
189
+ });
190
+ }
191
+ else {
192
+ clone[key] = state.copier(object[key], state);
193
+ }
174
194
  }
175
195
  for (const symbol of Object.getOwnPropertySymbols(object)) {
176
196
  if (propertyIsEnumerable.call(object, symbol)) {
@@ -250,7 +270,7 @@ function getOptions({ createCache: createCacheOverride, maxDepth, methods: metho
250
270
  asyncGenerator: copySelf,
251
271
  blob: copyBlob,
252
272
  dataView: copyDataView,
253
- date: copyDate,
273
+ date: strict ? copyDateStrict : copyDate,
254
274
  error: copySelf,
255
275
  generator: copySelf,
256
276
  map: strict ? copyMapStrict : copyMapLoose,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/utils.ts","../../../src/copier.ts","../../../src/options.ts","../../../src/index.ts"],"sourcesContent":["export interface Cache {\n has: (value: any) => boolean;\n set: (key: any, value: any) => void;\n get: (key: any) => any;\n}\n\n/**\n * Error thrown when the copier traverses deeper than the configured `maxDepth`.\n *\n * @note\n * Extends `RangeError` for backwards compatibility, since exceeding the maximum depth\n * previously surfaced as a native `RangeError` from stack exhaustion.\n */\nexport class MaxDepthExceededError extends RangeError {\n readonly maxDepth: number;\n\n constructor(maxDepth: number) {\n super(`Maximum copy depth of ${String(maxDepth)} exceeded; the value copied is nested too deeply.`);\n\n this.maxDepth = maxDepth;\n this.name = 'MaxDepthExceededError';\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/unbound-method\nconst toStringFunction = Function.prototype.toString;\n// eslint-disable-next-line @typescript-eslint/unbound-method\nconst toStringObject = Object.prototype.toString;\n\n/**\n * Get an empty version of the object with the same prototype it has.\n */\nexport function getCleanClone(prototype: any): any {\n if (!prototype) {\n return Object.create(null);\n }\n\n const Constructor = prototype.constructor;\n\n if (Constructor === Object) {\n return prototype === Object.prototype ? {} : Object.create(prototype as object | null);\n }\n\n if (Constructor && ~toStringFunction.call(Constructor).indexOf('[native code]')) {\n try {\n return new Constructor();\n } catch {\n // Ignore\n }\n }\n\n return Object.create(prototype as object | null);\n}\n\n/**\n * Get the tag of the value passed, so that the correct copier can be used.\n */\nexport function getTag(value: any): string {\n const stringTag = value[Symbol.toStringTag];\n\n if (stringTag) {\n return stringTag;\n }\n\n const type = toStringObject.call(value);\n\n return type.substring(8, type.length - 1);\n}\n","import { getCleanClone } from './utils.js';\nimport type { Cache } from './utils.ts';\n\nexport type InternalCopier<Value> = (value: Value, state: State) => Value;\n\nexport interface State {\n /**\n * The constructor of the value currently being copied, derived from its `prototype`.\n * Used to construct the clone for values that are not plain objects, such as subclasses\n * of `Array` or custom classes.\n *\n * @note\n * This is `undefined` for primitives and for values already present in the `cache`. It is\n * also reassigned for every value copied, so it must be read before any recursive\n * `copier` call is made, not after.\n */\n Constructor: any;\n /**\n * The cache of values already copied, mapping each original to its clone. Copiers should\n * populate it with the clone _before_ copying that value's contents, so that circular\n * references resolve to the clone rather than recursing infinitely.\n */\n cache: Cache;\n /**\n * The copier used for nested values. Call it as `state.copier(value, state)` to deeply\n * copy the contents of the value being copied.\n */\n copier: InternalCopier<any>;\n /**\n * The number of nested objects currently being copied, used to bound traversal of\n * deeply-nested values before the call stack is exhausted.\n *\n * @note\n * This is maintained by the copier itself; custom methods should not modify it.\n */\n depth: number;\n /**\n * The prototype of the value currently being copied, used to create a clone that\n * maintains the original's prototype chain.\n *\n * @note\n * This is `undefined` for primitives and for values already present in the `cache`. It is\n * also reassigned for every value copied, so it must be read before any recursive\n * `copier` call is made, not after.\n */\n prototype: any;\n}\n\n// eslint-disable-next-line @typescript-eslint/unbound-method\nconst { propertyIsEnumerable } = Object.prototype;\n\n/**\n * The shared `%TypedArray%.prototype.slice`, which every typed array inherits.\n *\n * @note\n * This is used instead of the `slice` found on the value itself because subclasses can\n * override it with one that does not copy. `Buffer` is the notable case: its `slice`\n * returns a view over the same memory, so copying through it would alias the original.\n */\nconst sliceTypedArray = Object.getPrototypeOf(Int8Array.prototype).slice as (\n this: ArrayBufferView,\n start: number,\n) => ArrayBufferView;\n\nfunction copyOwnDescriptor<Value extends object>(\n original: Value,\n clone: Value,\n property: string | symbol,\n state: State,\n): void {\n const ownDescriptor = Object.getOwnPropertyDescriptor(original, property) || {\n configurable: true,\n enumerable: true,\n value: original[property as keyof Value],\n writable: true,\n };\n const descriptor =\n ownDescriptor.get || ownDescriptor.set\n ? ownDescriptor\n : {\n configurable: ownDescriptor.configurable,\n enumerable: ownDescriptor.enumerable,\n value: state.copier(ownDescriptor.value, state),\n writable: ownDescriptor.writable,\n };\n\n try {\n Object.defineProperty(clone, property, descriptor);\n } catch {\n // The above can fail on node in extreme edge cases, so fall back to the loose assignment.\n clone[property as keyof Value] = descriptor.get ? descriptor.get() : descriptor.value;\n }\n}\n\n/**\n * Strictly copy all properties contained on the object.\n */\nfunction copyOwnPropertiesStrict<Value extends object>(value: Value, clone: Value, state: State): Value {\n for (const name of Object.getOwnPropertyNames(value)) {\n copyOwnDescriptor(value, clone, name, state);\n }\n\n for (const symbol of Object.getOwnPropertySymbols(value)) {\n copyOwnDescriptor(value, clone, symbol, state);\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the indexed values in the array.\n */\nexport function copyArrayLoose(array: any[], state: State) {\n const clone = new state.Constructor();\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(array, clone);\n\n for (let index = 0; index < array.length; ++index) {\n clone[index] = state.copier(array[index], state);\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the indexed values in the array, as well as any custom properties.\n */\nexport function copyArrayStrict<Value extends any[]>(array: Value, state: State) {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(array, clone);\n\n return copyOwnPropertiesStrict(array, clone, state);\n}\n\n/**\n * Copy the contents of the ArrayBuffer, or of the typed array viewing one.\n */\nexport function copyArrayBuffer<Value extends ArrayBufferLike | ArrayBufferView>(\n arrayBuffer: Value,\n _state: State,\n): Value {\n return ArrayBuffer.isView(arrayBuffer)\n ? (sliceTypedArray.call(arrayBuffer, 0) as Value)\n : (arrayBuffer.slice(0) as Value);\n}\n\n/**\n * Create a new Blob with the contents of the original.\n */\nexport function copyBlob<Value extends Blob>(blob: Value, _state: State): Value {\n return blob.slice(0, blob.size, blob.type) as Value;\n}\n\n/**\n * Create a new DataView with the contents of the original.\n */\nexport function copyDataView<Value extends DataView>(dataView: Value, state: State): Value {\n return new state.Constructor(copyArrayBuffer(dataView.buffer, state), dataView.byteOffset, dataView.byteLength);\n}\n\n/**\n * Create a new Date based on the time of the original.\n */\nexport function copyDate<Value extends Date>(date: Value, state: State): Value {\n return new state.Constructor(date.getTime());\n}\n\n/**\n * Deeply copy the keys and values of the original.\n */\nexport function copyMapLoose<Value extends Map<any, any>>(map: Value, state: State): Value {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(map, clone);\n\n for (const [key, value] of map) {\n clone.set(key, state.copier(value, state));\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the keys and values of the original, as well as any custom properties.\n */\nexport function copyMapStrict<Value extends Map<any, any>>(map: Value, state: State) {\n return copyOwnPropertiesStrict(map, copyMapLoose(map, state), state);\n}\n\n/**\n * Deeply copy the properties (keys and symbols) and values of the original.\n */\nexport function copyObjectLoose<Value extends Record<string, any>>(object: Value, state: State): Value {\n const clone = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n for (const key of Object.keys(object)) {\n clone[key] = state.copier(object[key], state);\n }\n\n for (const symbol of Object.getOwnPropertySymbols(object)) {\n if (propertyIsEnumerable.call(object, symbol)) {\n clone[symbol] = state.copier((object as any)[symbol], state);\n }\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the properties (keys and symbols) and values of the original, as well\n * as any hidden or non-enumerable properties.\n */\nexport function copyObjectStrict<Value extends Record<string, any>>(object: Value, state: State): Value {\n const clone = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n return copyOwnPropertiesStrict(object, clone, state);\n}\n\n/**\n * Create a new primitive wrapper from the value of the original.\n */\nexport function copyPrimitiveWrapper<\n // Specifically use the object constructor types\n // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\n Value extends Boolean | Number | String,\n>(primitiveObject: Value, state: State): Value {\n return new state.Constructor(primitiveObject.valueOf());\n}\n\n/**\n * Create a new RegExp based on the value and flags of the original.\n */\nexport function copyRegExp<Value extends RegExp>(regExp: Value, state: State): Value {\n const clone = new state.Constructor(regExp.source, regExp.flags) as Value;\n\n clone.lastIndex = regExp.lastIndex;\n\n return clone;\n}\n\n/**\n * Return the original value (an identity function).\n *\n * @note\n * THis is used for objects that cannot be copied, such as WeakMap.\n */\nexport function copySelf<Value>(value: Value, _state: State): Value {\n return value;\n}\n\n/**\n * Deeply copy the values of the original.\n */\nexport function copySetLoose<Value extends Set<any>>(set: Value, state: State): Value {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(set, clone);\n\n for (const value of set) {\n clone.add(state.copier(value, state));\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the values of the original, as well as any custom properties.\n */\nexport function copySetStrict<Value extends Set<any>>(set: Value, state: State): Value {\n return copyOwnPropertiesStrict(set, copySetLoose(set, state), state);\n}\n","import {\n copyArrayBuffer,\n copyArrayLoose,\n copyArrayStrict,\n copyBlob,\n copyDataView,\n copyDate,\n copyMapLoose,\n copyMapStrict,\n copyObjectLoose,\n copyObjectStrict,\n copyPrimitiveWrapper,\n copyRegExp,\n copySelf,\n copySetLoose,\n copySetStrict,\n} from './copier.js';\nimport type { InternalCopier } from './copier.ts';\nimport type { Cache } from './utils.ts';\n\nexport interface CopierMethods {\n array?: InternalCopier<any[]>;\n arrayBuffer?: InternalCopier<ArrayBuffer>;\n asyncGenerator?: InternalCopier<AsyncGenerator>;\n blob?: InternalCopier<Blob>;\n dataView?: InternalCopier<DataView>;\n date?: InternalCopier<Date>;\n error?: InternalCopier<Error>;\n generator?: InternalCopier<Generator>;\n map?: InternalCopier<Map<any, any>>;\n object?: InternalCopier<Record<string, any>>;\n regExp?: InternalCopier<RegExp>;\n set?: InternalCopier<Set<any>>;\n}\n\ninterface Copiers {\n [key: string]: InternalCopier<any> | undefined;\n\n Arguments: InternalCopier<Record<string, any>>;\n Array: InternalCopier<any[]>;\n ArrayBuffer: InternalCopier<ArrayBuffer>;\n AsyncGenerator: InternalCopier<AsyncGenerator>;\n BigInt64Array: InternalCopier<ArrayBuffer>;\n BigUint64Array: InternalCopier<ArrayBuffer>;\n Blob: InternalCopier<Blob>;\n // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\n Boolean: InternalCopier<Boolean>;\n DataView: InternalCopier<DataView>;\n Date: InternalCopier<Date>;\n Error: InternalCopier<Error>;\n Float32Array: InternalCopier<ArrayBuffer>;\n Float64Array: InternalCopier<ArrayBuffer>;\n Generator: InternalCopier<Generator>;\n Int8Array: InternalCopier<ArrayBuffer>;\n Int16Array: InternalCopier<ArrayBuffer>;\n Int32Array: InternalCopier<ArrayBuffer>;\n Map: InternalCopier<Map<any, any>>;\n // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\n Number: InternalCopier<Number>;\n Object: InternalCopier<Record<string, any>>;\n Promise: InternalCopier<Promise<any>>;\n RegExp: InternalCopier<RegExp>;\n Set: InternalCopier<Set<any>>;\n // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\n String: InternalCopier<String>;\n WeakMap: InternalCopier<WeakMap<any, any>>;\n WeakSet: InternalCopier<WeakSet<any>>;\n Uint8Array: InternalCopier<ArrayBuffer>;\n Uint8ClampedArray: InternalCopier<ArrayBuffer>;\n Uint16Array: InternalCopier<ArrayBuffer>;\n Uint32Array: InternalCopier<ArrayBuffer>;\n}\n\nexport interface CreateCopierOptions {\n /**\n * Creates the cache used to track values already copied, which is what allows circular\n * references to resolve to their clone instead of recursing infinitely. A new cache is\n * created for each top-level copy. Since it only needs to satisfy the `has` / `get` /\n * `set` contract, a bounded implementation such as an LRU cache can be used to trade\n * circular reference handling for a smaller memory footprint.\n *\n * @default () => new WeakMap()\n */\n createCache?: () => Cache;\n /**\n * The maximum number of nested objects to traverse before throwing a\n * `MaxDepthExceededError`. Pass `Infinity` to traverse without a limit.\n *\n * @default 1000\n */\n maxDepth?: number;\n /**\n * Overrides of the copiers used for specific object types, allowing custom copy\n * semantics for those types. Any type not overridden uses its default copier. Each\n * method receives the value to copy and the current `State`, and is responsible for\n * populating `state.cache` and recursing via `state.copier` if it wants circular\n * reference handling and deep copies respectively.\n */\n methods?: CopierMethods;\n /**\n * Copies all own properties with their original property descriptors, including\n * non-enumerable properties, symbols, and non-index properties on arrays.\n *\n * @note\n * This is significantly slower than the default \"loose\" copy, so it should only be used\n * when the exact shape of the original must be replicated.\n *\n * @default false\n */\n strict?: boolean;\n}\n\nexport interface RequiredCreateCopierOptions extends Omit<Required<CreateCopierOptions>, 'methods'> {\n copiers: Copiers;\n methods: Required<CopierMethods>;\n}\n\n/**\n * The maximum depth traversed when none is provided.\n *\n * @note\n * This is deliberately below the depth at which the native call stack is exhausted\n * (~1875 for strict copies in node), so that untrusted, deeply-nested values fail with a\n * catchable, descriptive error instead of a raw `RangeError`.\n */\nexport const DEFAULT_MAX_DEPTH = 1000;\n\nexport function createDefaultCache(): Cache {\n return new WeakMap();\n}\n\nexport function getOptions({\n createCache: createCacheOverride,\n maxDepth,\n methods: methodsOverride,\n strict,\n}: CreateCopierOptions): RequiredCreateCopierOptions {\n const defaultMethods = {\n array: strict ? copyArrayStrict : copyArrayLoose,\n arrayBuffer: copyArrayBuffer,\n asyncGenerator: copySelf,\n blob: copyBlob,\n dataView: copyDataView,\n date: copyDate,\n error: copySelf,\n generator: copySelf,\n map: strict ? copyMapStrict : copyMapLoose,\n object: strict ? copyObjectStrict : copyObjectLoose,\n regExp: copyRegExp,\n set: strict ? copySetStrict : copySetLoose,\n };\n\n const methods = methodsOverride ? Object.assign(defaultMethods, methodsOverride) : defaultMethods;\n const copiers = getTagSpecificCopiers(methods);\n const createCache = createCacheOverride || createDefaultCache;\n\n // Extra safety check to ensure that object and array copiers are always provided,\n // avoiding runtime errors.\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!copiers.Object || !copiers.Array) {\n throw new Error('An object and array copier must be provided.');\n }\n\n return {\n createCache,\n copiers,\n maxDepth: maxDepth == null ? DEFAULT_MAX_DEPTH : maxDepth,\n methods,\n strict: Boolean(strict),\n };\n}\n\n/**\n * Get the copiers used for each specific object tag.\n */\nexport function getTagSpecificCopiers(methods: Required<CopierMethods>): Copiers {\n // A `null` prototype is used so that a value carrying a custom `Symbol.toStringTag`\n // cannot resolve to an inherited `Object.prototype` member as its copier. Without it,\n // a tag such as `toString` or `valueOf` finds a function on the prototype chain and\n // that function is invoked in place of a real copier.\n return Object.assign(Object.create(null) as Copiers, {\n Arguments: methods.object,\n Array: methods.array,\n ArrayBuffer: methods.arrayBuffer,\n AsyncGenerator: methods.asyncGenerator,\n BigInt64Array: methods.arrayBuffer,\n BigUint64Array: methods.arrayBuffer,\n Blob: methods.blob,\n Boolean: copyPrimitiveWrapper,\n DataView: methods.dataView,\n Date: methods.date,\n Error: methods.error,\n Float32Array: methods.arrayBuffer,\n Float64Array: methods.arrayBuffer,\n Generator: methods.generator,\n Int8Array: methods.arrayBuffer,\n Int16Array: methods.arrayBuffer,\n Int32Array: methods.arrayBuffer,\n Map: methods.map,\n Number: copyPrimitiveWrapper,\n Object: methods.object,\n Promise: copySelf,\n RegExp: methods.regExp,\n Set: methods.set,\n String: copyPrimitiveWrapper,\n WeakMap: copySelf,\n WeakSet: copySelf,\n Uint8Array: methods.arrayBuffer,\n Uint8ClampedArray: methods.arrayBuffer,\n Uint16Array: methods.arrayBuffer,\n Uint32Array: methods.arrayBuffer,\n });\n}\n","import type { State } from './copier.ts';\nimport { getOptions } from './options.js';\nimport type { CreateCopierOptions } from './options.ts';\nimport { getTag, MaxDepthExceededError } from './utils.js';\n\nexport type { State } from './copier.ts';\nexport type { CreateCopierOptions } from './options.ts';\nexport { MaxDepthExceededError } from './utils.js';\n\n/**\n * Create a custom copier based on custom options for any of the following:\n * - `createCache` method to create a cache for copied objects\n * - custom copier `methods` for specific object types\n * - `strict` mode to copy all properties with their descriptors\n */\nexport function createCopier(options: CreateCopierOptions = {}) {\n const { createCache, copiers, maxDepth } = getOptions(options);\n const { Array: copyArray, Object: copyObject } = copiers;\n\n function copier(value: any, state: State): any {\n state.prototype = state.Constructor = undefined;\n\n if (!value || typeof value !== 'object') {\n return value;\n }\n\n if (state.cache.has(value)) {\n return state.cache.get(value);\n }\n\n // Bound the traversal of nested objects, so that values nested more deeply than the\n // call stack can handle fail with a descriptive error instead of a raw `RangeError`.\n if (++state.depth > maxDepth) {\n throw new MaxDepthExceededError(maxDepth);\n }\n\n state.prototype = Object.getPrototypeOf(value);\n // Using logical AND for speed, since optional chaining transforms to\n // a local variable usage.\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n state.Constructor = state.prototype && state.prototype.constructor;\n\n let clone: any;\n\n // plain objects\n if (!state.Constructor || state.Constructor === Object) {\n clone = copyObject(value as Record<string, any>, state);\n } else if (Array.isArray(value)) {\n // arrays\n clone = copyArray(value, state);\n } else {\n const tagSpecificCopier = copiers[getTag(value)];\n\n if (tagSpecificCopier) {\n clone = tagSpecificCopier(value, state);\n } else {\n clone = typeof value.then === 'function' ? value : copyObject(value as Record<string, any>, state);\n }\n }\n\n --state.depth;\n\n return clone;\n }\n\n return function copy<Value>(value: Value): Value {\n return copier(value, {\n Constructor: undefined,\n cache: createCache(),\n copier,\n depth: 0,\n prototype: undefined,\n });\n };\n}\n\n/**\n * Copy an value deeply as much as possible, where strict recreation of object properties\n * are maintained. All properties (including non-enumerable ones) are copied with their\n * original property descriptors on both objects and arrays.\n */\nexport const copyStrict = createCopier({ strict: true });\n\n/**\n * Copy an value deeply as much as possible.\n */\nexport const copy = createCopier();\n"],"names":[],"mappings":";;AAMA;;;;;;AAMG;AACG,MAAO,qBAAsB,SAAQ,UAAU,CAAA;AAGnD,IAAA,WAAA,CAAY,QAAgB,EAAA;QAC1B,KAAK,CAAC,yBAAyB,MAAM,CAAC,QAAQ,CAAC,CAAA,iDAAA,CAAmD,CAAC;AAEnG,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ;AACxB,QAAA,IAAI,CAAC,IAAI,GAAG,uBAAuB;IACrC;AACD;AAED;AACA,MAAM,gBAAgB,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ;AACpD;AACA,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ;AAEhD;;AAEG;AACG,SAAU,aAAa,CAAC,SAAc,EAAA;IAC1C,IAAI,CAAC,SAAS,EAAE;AACd,QAAA,OAAO,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AK,CAAC,CAAC;YAEhD,IAAI,iBAAiB,EAAE;AACrB,gBAAA,KAAK,GAAG,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC;YACzC;iBAAO;gBACL,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,GAAG,KAAK,GAAG,UAAU,CAAC,KAA4B,EAAE,KAAK,CAAC;YACpG;QACF;QAEA,EAAE,KAAK,CAAC,KAAK;AAEb,QAAA,OAAO,KAAK;IACd;IAEA,OAAO,SAAS,IAAI,CAAQ,KAAY,EAAA;QACtC,OAAO,MAAM,CAAC,KAAK,EAAE;AACnB,YAAA,WAAW,EAAE,SAAS;YACtB,KAAK,EAAE,WAAW,EAAE;YACpB,MAAM;AACN,YAAA,KAAK,EAAE,CAAC;AACR,YAAA,SAAS,EAAE,SAAS;AACrB,SAAA,CAAC;AACJ,IAAA,CAAC;AACH;AAEA;;;;AAIG;AACI,MAAM,UAAU,GAAG,YAAY,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE;AAEvD;;AAEG;AACI,MAAM,IAAI,GAAG,YAAY;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/utils.ts","../../../src/copier.ts","../../../src/options.ts","../../../src/index.ts"],"sourcesContent":["export interface Cache {\n has: (value: any) => boolean;\n set: (key: any, value: any) => void;\n get: (key: any) => any;\n}\n\n/**\n * Error thrown when the copier traverses deeper than the configured `maxDepth`.\n *\n * @note\n * Extends `RangeError` for backwards compatibility, since exceeding the maximum depth\n * previously surfaced as a native `RangeError` from stack exhaustion.\n */\nexport class MaxDepthExceededError extends RangeError {\n readonly maxDepth: number;\n\n constructor(maxDepth: number) {\n super(`Maximum copy depth of ${String(maxDepth)} exceeded; the value copied is nested too deeply.`);\n\n this.maxDepth = maxDepth;\n this.name = 'MaxDepthExceededError';\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/unbound-method\nconst toStringFunction = Function.prototype.toString;\n// eslint-disable-next-line @typescript-eslint/unbound-method\nconst toStringObject = Object.prototype.toString;\n\n/**\n * Get an empty version of the object with the same prototype it has.\n */\nexport function getCleanClone(prototype: any): any {\n if (!prototype) {\n return Object.create(null);\n }\n\n const Constructor = prototype.constructor;\n\n if (Constructor === Object) {\n return prototype === Object.prototype ? {} : Object.create(prototype as object | null);\n }\n\n // 2026-10-10: Prototype constructor properties may contain ordinary data.\n if (typeof Constructor === 'function' && ~toStringFunction.call(Constructor).indexOf('[native code]')) {\n try {\n return new Constructor();\n } catch {\n // Ignore\n }\n }\n\n return Object.create(prototype as object | null);\n}\n\n/**\n * Get the tag of the value passed, so that the correct copier can be used.\n */\nexport function getTag(value: any): string {\n const stringTag = value[Symbol.toStringTag];\n\n if (stringTag) {\n return stringTag;\n }\n\n const type = toStringObject.call(value);\n\n return type.substring(8, type.length - 1);\n}\n","import { getCleanClone } from './utils.js';\nimport type { Cache } from './utils.ts';\n\nexport type InternalCopier<Value> = (value: Value, state: State) => Value;\n\nexport interface State {\n /**\n * The constructor of the value currently being copied, derived from its `prototype`.\n * Used to construct the clone for values that are not plain objects, such as subclasses\n * of `Array` or custom classes.\n *\n * @note\n * This is `undefined` for primitives and for values already present in the `cache`. It is\n * also reassigned for every value copied, so it must be read before any recursive\n * `copier` call is made, not after.\n */\n Constructor: any;\n /**\n * The cache of values already copied, mapping each original to its clone. Copiers should\n * populate it with the clone _before_ copying that value's contents, so that circular\n * references resolve to the clone rather than recursing infinitely.\n */\n cache: Cache;\n /**\n * The copier used for nested values. Call it as `state.copier(value, state)` to deeply\n * copy the contents of the value being copied.\n */\n copier: InternalCopier<any>;\n /**\n * The number of nested objects currently being copied, used to bound traversal of\n * deeply-nested values before the call stack is exhausted.\n *\n * @note\n * This is maintained by the copier itself; custom methods should not modify it.\n */\n depth: number;\n /**\n * The prototype of the value currently being copied, used to create a clone that\n * maintains the original's prototype chain.\n *\n * @note\n * This is `undefined` for primitives and for values already present in the `cache`. It is\n * also reassigned for every value copied, so it must be read before any recursive\n * `copier` call is made, not after.\n */\n prototype: any;\n}\n\n// eslint-disable-next-line @typescript-eslint/unbound-method\nconst { propertyIsEnumerable } = Object.prototype;\n\n/**\n * The shared `%TypedArray%.prototype.slice`, which every typed array inherits.\n *\n * @note\n * This is used instead of the `slice` found on the value itself because subclasses can\n * override it with one that does not copy. `Buffer` is the notable case: its `slice`\n * returns a view over the same memory, so copying through it would alias the original.\n */\nconst sliceTypedArray = Object.getPrototypeOf(Int8Array.prototype).slice as (\n this: ArrayBufferView,\n start: number,\n) => ArrayBufferView;\n\nfunction copyOwnDescriptor<Value extends object>(\n original: Value,\n clone: Value,\n property: string | symbol,\n state: State,\n): void {\n const ownDescriptor = Object.getOwnPropertyDescriptor(original, property) || {\n configurable: true,\n enumerable: true,\n value: original[property as keyof Value],\n writable: true,\n };\n const descriptor =\n ownDescriptor.get || ownDescriptor.set\n ? ownDescriptor\n : {\n configurable: ownDescriptor.configurable,\n enumerable: ownDescriptor.enumerable,\n value: state.copier(ownDescriptor.value, state),\n writable: ownDescriptor.writable,\n };\n\n try {\n Object.defineProperty(clone, property, descriptor);\n } catch {\n // The above can fail on node in extreme edge cases, so fall back to the loose assignment.\n clone[property as keyof Value] = descriptor.get ? descriptor.get() : descriptor.value;\n }\n}\n\n/**\n * Strictly copy all properties contained on the object.\n */\nfunction copyOwnPropertiesStrict<Value extends object>(value: Value, clone: Value, state: State): Value {\n for (const name of Object.getOwnPropertyNames(value)) {\n copyOwnDescriptor(value, clone, name, state);\n }\n\n for (const symbol of Object.getOwnPropertySymbols(value)) {\n copyOwnDescriptor(value, clone, symbol, state);\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the indexed values in the array.\n */\nexport function copyArrayLoose(array: any[], state: State) {\n const clone = new state.Constructor();\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(array, clone);\n\n for (let index = 0; index < array.length; ++index) {\n clone[index] = state.copier(array[index], state);\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the indexed values in the array, as well as any custom properties.\n */\nexport function copyArrayStrict<Value extends any[]>(array: Value, state: State) {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(array, clone);\n\n return copyOwnPropertiesStrict(array, clone, state);\n}\n\n/**\n * Copy the contents of the ArrayBuffer, or of the typed array viewing one.\n */\nexport function copyArrayBuffer<Value extends ArrayBufferLike | ArrayBufferView>(\n arrayBuffer: Value,\n _state: State,\n): Value {\n return ArrayBuffer.isView(arrayBuffer)\n ? (sliceTypedArray.call(arrayBuffer, 0) as Value)\n : (arrayBuffer.slice(0) as Value);\n}\n\n/**\n * Create a new Blob with the contents of the original.\n */\nexport function copyBlob<Value extends Blob>(blob: Value, _state: State): Value {\n return blob.slice(0, blob.size, blob.type) as Value;\n}\n\n/**\n * Create a new DataView with the contents of the original.\n */\nexport function copyDataView<Value extends DataView>(dataView: Value, state: State): Value {\n return new state.Constructor(copyArrayBuffer(dataView.buffer, state), dataView.byteOffset, dataView.byteLength);\n}\n\n/**\n * Create a new Date based on the time of the original.\n */\nexport function copyDate<Value extends Date>(date: Value, state: State): Value {\n return new state.Constructor(date.getTime());\n}\n\n/**\n * Copy the time of the original Date, as well as any custom properties.\n */\nexport function copyDateStrict<Value extends Date>(date: Value, state: State): Value {\n const clone = copyDate(date, state);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(date, clone);\n\n return copyOwnPropertiesStrict(date, clone, state);\n}\n\n/**\n * Deeply copy the keys and values of the original.\n */\nexport function copyMapLoose<Value extends Map<any, any>>(map: Value, state: State): Value {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(map, clone);\n\n for (const [key, value] of map) {\n clone.set(key, state.copier(value, state));\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the keys and values of the original, as well as any custom properties.\n */\nexport function copyMapStrict<Value extends Map<any, any>>(map: Value, state: State) {\n return copyOwnPropertiesStrict(map, copyMapLoose(map, state), state);\n}\n\n/**\n * Deeply copy the properties (keys and symbols) and values of the original.\n */\nexport function copyObjectLoose<Value extends Record<string, any>>(object: Value, state: State): Value {\n const clone = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n for (const key of Object.keys(object)) {\n if (key === '__proto__') {\n Object.defineProperty(clone, key, {\n configurable: true,\n enumerable: true,\n value: state.copier(object[key], state),\n writable: true,\n });\n } else {\n clone[key] = state.copier(object[key], state);\n }\n }\n\n for (const symbol of Object.getOwnPropertySymbols(object)) {\n if (propertyIsEnumerable.call(object, symbol)) {\n clone[symbol] = state.copier((object as any)[symbol], state);\n }\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the properties (keys and symbols) and values of the original, as well\n * as any hidden or non-enumerable properties.\n */\nexport function copyObjectStrict<Value extends Record<string, any>>(object: Value, state: State): Value {\n const clone = getCleanClone(state.prototype);\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(object, clone);\n\n return copyOwnPropertiesStrict(object, clone, state);\n}\n\n/**\n * Create a new primitive wrapper from the value of the original.\n */\nexport function copyPrimitiveWrapper<\n // Specifically use the object constructor types\n // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\n Value extends Boolean | Number | String,\n>(primitiveObject: Value, state: State): Value {\n return new state.Constructor(primitiveObject.valueOf());\n}\n\n/**\n * Create a new RegExp based on the value and flags of the original.\n */\nexport function copyRegExp<Value extends RegExp>(regExp: Value, state: State): Value {\n const clone = new state.Constructor(regExp.source, regExp.flags) as Value;\n\n clone.lastIndex = regExp.lastIndex;\n\n return clone;\n}\n\n/**\n * Return the original value (an identity function).\n *\n * @note\n * THis is used for objects that cannot be copied, such as WeakMap.\n */\nexport function copySelf<Value>(value: Value, _state: State): Value {\n return value;\n}\n\n/**\n * Deeply copy the values of the original.\n */\nexport function copySetLoose<Value extends Set<any>>(set: Value, state: State): Value {\n const clone = new state.Constructor() as Value;\n\n // set in the cache immediately to be able to reuse the object recursively\n state.cache.set(set, clone);\n\n for (const value of set) {\n clone.add(state.copier(value, state));\n }\n\n return clone;\n}\n\n/**\n * Deeply copy the values of the original, as well as any custom properties.\n */\nexport function copySetStrict<Value extends Set<any>>(set: Value, state: State): Value {\n return copyOwnPropertiesStrict(set, copySetLoose(set, state), state);\n}\n","import {\n copyArrayBuffer,\n copyArrayLoose,\n copyArrayStrict,\n copyBlob,\n copyDataView,\n copyDate,\n copyDateStrict,\n copyMapLoose,\n copyMapStrict,\n copyObjectLoose,\n copyObjectStrict,\n copyPrimitiveWrapper,\n copyRegExp,\n copySelf,\n copySetLoose,\n copySetStrict,\n} from './copier.js';\nimport type { InternalCopier } from './copier.ts';\nimport type { Cache } from './utils.ts';\n\nexport interface CopierMethods {\n array?: InternalCopier<any[]>;\n arrayBuffer?: InternalCopier<ArrayBuffer>;\n asyncGenerator?: InternalCopier<AsyncGenerator>;\n blob?: InternalCopier<Blob>;\n dataView?: InternalCopier<DataView>;\n date?: InternalCopier<Date>;\n error?: InternalCopier<Error>;\n generator?: InternalCopier<Generator>;\n map?: InternalCopier<Map<any, any>>;\n object?: InternalCopier<Record<string, any>>;\n regExp?: InternalCopier<RegExp>;\n set?: InternalCopier<Set<any>>;\n}\n\ninterface Copiers {\n [key: string]: InternalCopier<any> | undefined;\n\n Arguments: InternalCopier<Record<string, any>>;\n Array: InternalCopier<any[]>;\n ArrayBuffer: InternalCopier<ArrayBuffer>;\n AsyncGenerator: InternalCopier<AsyncGenerator>;\n BigInt64Array: InternalCopier<ArrayBuffer>;\n BigUint64Array: InternalCopier<ArrayBuffer>;\n Blob: InternalCopier<Blob>;\n // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\n Boolean: InternalCopier<Boolean>;\n DataView: InternalCopier<DataView>;\n Date: InternalCopier<Date>;\n Error: InternalCopier<Error>;\n Float32Array: InternalCopier<ArrayBuffer>;\n Float64Array: InternalCopier<ArrayBuffer>;\n Generator: InternalCopier<Generator>;\n Int8Array: InternalCopier<ArrayBuffer>;\n Int16Array: InternalCopier<ArrayBuffer>;\n Int32Array: InternalCopier<ArrayBuffer>;\n Map: InternalCopier<Map<any, any>>;\n // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\n Number: InternalCopier<Number>;\n Object: InternalCopier<Record<string, any>>;\n Promise: InternalCopier<Promise<any>>;\n RegExp: InternalCopier<RegExp>;\n Set: InternalCopier<Set<any>>;\n // eslint-disable-next-line @typescript-eslint/no-wrapper-object-types\n String: InternalCopier<String>;\n WeakMap: InternalCopier<WeakMap<any, any>>;\n WeakSet: InternalCopier<WeakSet<any>>;\n Uint8Array: InternalCopier<ArrayBuffer>;\n Uint8ClampedArray: InternalCopier<ArrayBuffer>;\n Uint16Array: InternalCopier<ArrayBuffer>;\n Uint32Array: InternalCopier<ArrayBuffer>;\n}\n\nexport interface CreateCopierOptions {\n /**\n * Creates the cache used to track values already copied, which is what allows circular\n * references to resolve to their clone instead of recursing infinitely. A new cache is\n * created for each top-level copy. Since it only needs to satisfy the `has` / `get` /\n * `set` contract, a bounded implementation such as an LRU cache can be used to trade\n * circular reference handling for a smaller memory footprint.\n *\n * @default () => new WeakMap()\n */\n createCache?: () => Cache;\n /**\n * The maximum number of nested objects to traverse before throwing a\n * `MaxDepthExceededError`. Pass `Infinity` to traverse without a limit.\n *\n * @default 1000\n */\n maxDepth?: number;\n /**\n * Overrides of the copiers used for specific object types, allowing custom copy\n * semantics for those types. Any type not overridden uses its default copier. Each\n * method receives the value to copy and the current `State`, and is responsible for\n * populating `state.cache` and recursing via `state.copier` if it wants circular\n * reference handling and deep copies respectively.\n */\n methods?: CopierMethods;\n /**\n * Copies all own properties with their original property descriptors, including\n * non-enumerable properties, symbols, and non-index properties on arrays.\n *\n * @note\n * This is significantly slower than the default \"loose\" copy, so it should only be used\n * when the exact shape of the original must be replicated.\n *\n * @default false\n */\n strict?: boolean;\n}\n\nexport interface RequiredCreateCopierOptions extends Omit<Required<CreateCopierOptions>, 'methods'> {\n copiers: Copiers;\n methods: Required<CopierMethods>;\n}\n\n/**\n * The maximum depth traversed when none is provided.\n *\n * @note\n * This is deliberately below the depth at which the native call stack is exhausted\n * (~1875 for strict copies in node), so that untrusted, deeply-nested values fail with a\n * catchable, descriptive error instead of a raw `RangeError`.\n */\nexport const DEFAULT_MAX_DEPTH = 1000;\n\nexport function createDefaultCache(): Cache {\n return new WeakMap();\n}\n\nexport function getOptions({\n createCache: createCacheOverride,\n maxDepth,\n methods: methodsOverride,\n strict,\n}: CreateCopierOptions): RequiredCreateCopierOptions {\n const defaultMethods = {\n array: strict ? copyArrayStrict : copyArrayLoose,\n arrayBuffer: copyArrayBuffer,\n asyncGenerator: copySelf,\n blob: copyBlob,\n dataView: copyDataView,\n date: strict ? copyDateStrict : copyDate,\n error: copySelf,\n generator: copySelf,\n map: strict ? copyMapStrict : copyMapLoose,\n object: strict ? copyObjectStrict : copyObjectLoose,\n regExp: copyRegExp,\n set: strict ? copySetStrict : copySetLoose,\n };\n\n const methods = methodsOverride ? Object.assign(defaultMethods, methodsOverride) : defaultMethods;\n const copiers = getTagSpecificCopiers(methods);\n const createCache = createCacheOverride || createDefaultCache;\n\n // Extra safety check to ensure that object and array copiers are always provided,\n // avoiding runtime errors.\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!copiers.Object || !copiers.Array) {\n throw new Error('An object and array copier must be provided.');\n }\n\n return {\n createCache,\n copiers,\n maxDepth: maxDepth == null ? DEFAULT_MAX_DEPTH : maxDepth,\n methods,\n strict: Boolean(strict),\n };\n}\n\n/**\n * Get the copiers used for each specific object tag.\n */\nexport function getTagSpecificCopiers(methods: Required<CopierMethods>): Copiers {\n // A `null` prototype is used so that a value carrying a custom `Symbol.toStringTag`\n // cannot resolve to an inherited `Object.prototype` member as its copier. Without it,\n // a tag such as `toString` or `valueOf` finds a function on the prototype chain and\n // that function is invoked in place of a real copier.\n return Object.assign(Object.create(null) as Copiers, {\n Arguments: methods.object,\n Array: methods.array,\n ArrayBuffer: methods.arrayBuffer,\n AsyncGenerator: methods.asyncGenerator,\n BigInt64Array: methods.arrayBuffer,\n BigUint64Array: methods.arrayBuffer,\n Blob: methods.blob,\n Boolean: copyPrimitiveWrapper,\n DataView: methods.dataView,\n Date: methods.date,\n Error: methods.error,\n Float32Array: methods.arrayBuffer,\n Float64Array: methods.arrayBuffer,\n Generator: methods.generator,\n Int8Array: methods.arrayBuffer,\n Int16Array: methods.arrayBuffer,\n Int32Array: methods.arrayBuffer,\n Map: methods.map,\n Number: copyPrimitiveWrapper,\n Object: methods.object,\n Promise: copySelf,\n RegExp: methods.regExp,\n Set: methods.set,\n String: copyPrimitiveWrapper,\n WeakMap: copySelf,\n WeakSet: copySelf,\n Uint8Array: methods.arrayBuffer,\n Uint8ClampedArray: methods.arrayBuffer,\n Uint16Array: methods.arrayBuffer,\n Uint32Array: methods.arrayBuffer,\n });\n}\n","import type { State } from './copier.ts';\nimport { getOptions } from './options.js';\nimport type { CreateCopierOptions } from './options.ts';\nimport { getTag, MaxDepthExceededError } from './utils.js';\n\nexport type { State } from './copier.ts';\nexport type { CreateCopierOptions } from './options.ts';\nexport { MaxDepthExceededError } from './utils.js';\n\n/**\n * Create a custom copier based on custom options for any of the following:\n * - `createCache` method to create a cache for copied objects\n * - custom copier `methods` for specific object types\n * - `strict` mode to copy all properties with their descriptors\n */\nexport function createCopier(options: CreateCopierOptions = {}) {\n const { createCache, copiers, maxDepth } = getOptions(options);\n const { Array: copyArray, Object: copyObject } = copiers;\n\n function copier(value: any, state: State): any {\n state.prototype = state.Constructor = undefined;\n\n if (!value || typeof value !== 'object') {\n return value;\n }\n\n if (state.cache.has(value)) {\n return state.cache.get(value);\n }\n\n // Bound the traversal of nested objects, so that values nested more deeply than the\n // call stack can handle fail with a descriptive error instead of a raw `RangeError`.\n if (++state.depth > maxDepth) {\n throw new MaxDepthExceededError(maxDepth);\n }\n\n state.prototype = Object.getPrototypeOf(value);\n // Using logical AND for speed, since optional chaining transforms to\n // a local variable usage.\n // eslint-disable-next-line @typescript-eslint/prefer-optional-chain\n state.Constructor = state.prototype && state.prototype.constructor;\n\n let clone: any;\n\n // plain objects\n if (!state.Constructor || state.Constructor === Object) {\n clone = copyObject(value as Record<string, any>, state);\n } else if (Array.isArray(value)) {\n // arrays\n clone = copyArray(value, state);\n } else {\n const tagSpecificCopier = copiers[getTag(value)];\n\n if (tagSpecificCopier) {\n clone = tagSpecificCopier(value, state);\n } else {\n clone = typeof value.then === 'function' ? value : copyObject(value as Record<string, any>, state);\n }\n }\n\n --state.depth;\n\n return clone;\n }\n\n return function copy<Value>(value: Value): Value {\n return copier(value, {\n Constructor: undefined,\n cache: createCache(),\n copier,\n depth: 0,\n prototype: undefined,\n });\n };\n}\n\n/**\n * Copy an value deeply as much as possible, where strict recreation of object properties\n * are maintained. All properties (including non-enumerable ones) are copied with their\n * original property descriptors on both objects and arrays.\n */\nexport const copyStrict = createCopier({ strict: true });\n\n/**\n * Copy an value deeply as much as possible.\n */\nexport const copy = createCopier();\n"],"names":[],"mappings":";;AAMA;;;;;;AAMG;AACG,MAAO,qBAAsB,SAAQ,UAAU,CAAA;AAGnD,IAAA,WAAA,CAAY,QAAgB,EAAA;QAC1B,KAAK,CAAC,yBAAyB,MAAM,CAAC,QAAQ,CAAC,CAAA,iDAAA,CAAmD,CAAC;AAEnG,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ;AACxB,QAAA,IAAI,CAAC,IAAI,GAAG,uBAAuB;IACrC;AACD;AAED;AACA,MAAM,gBAAgB,GAAG,QAAQ,CAAC,SAAS,CAAC,QAAQ;AACpD;AACA,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,QAAQ;AAEhD;;AAEG;AACG,SAAU,aAAa,CAAC,SAAc,EAAA;IAC1C,IAAI,CAAC,SAAS,EAAE;AACd,QAAA,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;IAC5B;AAEA,IAAA,MAAM,WAAW,GAAG,SAAS,CAAC,WAAW;AAEzC,IAAA,IAAI,WAAW,KAAK,MAAM,EAAE;AAC1B,QAAA,OAAO,SAAS,KA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;;;AAI9C,QAAA,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,CAAC,WAAW;AAElE,QAAA,IAAI,KAAU;;QAGd,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,WAAW,KAAK,MAAM,EAAE;AACtD,YAAA,KAAK,GAAG,UAAU,CAAC,KAA4B,EAAE,KAAK,CAAC;QACzD;AAAO,aAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;;AAE/B,YAAA,KAAK,GAAG,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC;QACjC;aAAO;YACL,MAAM,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAEhD,IAAI,iBAAiB,EAAE;AACrB,gBAAA,KAAK,GAAG,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC;YACzC;iBAAO;gBACL,KAAK,GAAG,OAAO,KAAK,CAAC,IAAI,KAAK,UAAU,GAAG,KAAK,GAAG,UAAU,CAAC,KAA4B,EAAE,KAAK,CAAC;YACpG;QACF;QAEA,EAAE,KAAK,CAAC,KAAK;AAEb,QAAA,OAAO,KAAK;IACd;IAEA,OAAO,SAAS,IAAI,CAAQ,KAAY,EAAA;QACtC,OAAO,MAAM,CAAC,KAAK,EAAE;AACnB,YAAA,WAAW,EAAE,SAAS;YACtB,KAAK,EAAE,WAAW,EAAE;YACpB,MAAM;AACN,YAAA,KAAK,EAAE,CAAC;AACR,YAAA,SAAS,EAAE,SAAS;AACrB,SAAA,CAAC;AACJ,IAAA,CAAC;AACH;AAEA;;;;AAIG;AACI,MAAM,UAAU,GAAG,YAAY,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE;AAEvD;;AAEG;AACI,MAAM,IAAI,GAAG,YAAY;;;;;"}
@@ -27,7 +27,8 @@ function getCleanClone(prototype) {
27
27
  if (Constructor === Object) {
28
28
  return prototype === Object.prototype ? {} : Object.create(prototype);
29
29
  }
30
- if (Constructor && ~toStringFunction.call(Constructor).indexOf('[native code]')) {
30
+ // 2026-10-10: Prototype constructor properties may contain ordinary data.
31
+ if (typeof Constructor === 'function' && ~toStringFunction.call(Constructor).indexOf('[native code]')) {
31
32
  try {
32
33
  return new Constructor();
33
34
  }
@@ -142,6 +143,15 @@ function copyDataView(dataView, state) {
142
143
  function copyDate(date, state) {
143
144
  return new state.Constructor(date.getTime());
144
145
  }
146
+ /**
147
+ * Copy the time of the original Date, as well as any custom properties.
148
+ */
149
+ function copyDateStrict(date, state) {
150
+ const clone = copyDate(date, state);
151
+ // set in the cache immediately to be able to reuse the object recursively
152
+ state.cache.set(date, clone);
153
+ return copyOwnPropertiesStrict(date, clone, state);
154
+ }
145
155
  /**
146
156
  * Deeply copy the keys and values of the original.
147
157
  */
@@ -168,7 +178,17 @@ function copyObjectLoose(object, state) {
168
178
  // set in the cache immediately to be able to reuse the object recursively
169
179
  state.cache.set(object, clone);
170
180
  for (const key of Object.keys(object)) {
171
- clone[key] = state.copier(object[key], state);
181
+ if (key === '__proto__') {
182
+ Object.defineProperty(clone, key, {
183
+ configurable: true,
184
+ enumerable: true,
185
+ value: state.copier(object[key], state),
186
+ writable: true,
187
+ });
188
+ }
189
+ else {
190
+ clone[key] = state.copier(object[key], state);
191
+ }
172
192
  }
173
193
  for (const symbol of Object.getOwnPropertySymbols(object)) {
174
194
  if (propertyIsEnumerable.call(object, symbol)) {
@@ -248,7 +268,7 @@ function getOptions({ createCache: createCacheOverride, maxDepth, methods: metho
248
268
  asyncGenerator: copySelf,
249
269
  blob: copyBlob,
250
270
  dataView: copyDataView,
251
- date: copyDate,
271
+ date: strict ? copyDateStrict : copyDate,
252
272
  error: copySelf,
253
273
  generator: copySelf,
254
274
  map: strict ? copyMapStrict : copyMapLoose,