@warp-drive/core 5.9.0-beta.3 → 5.9.0

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 (112) hide show
  1. package/dist/{-private-BL9zXgJB.js → -private-C4L-6BFr.js} +3 -3
  2. package/dist/{-private-BL9zXgJB.js.map → -private-C4L-6BFr.js.map} +1 -1
  3. package/dist/{-private-Cxa8cMBj.js → -private-DJ3g9bNk.js} +2 -2
  4. package/dist/{-private-Cxa8cMBj.js.map → -private-DJ3g9bNk.js.map} +1 -1
  5. package/dist/{-private-xK1KgxZJ.js → -private-r5p8QUr4.js} +2 -2
  6. package/dist/{-private-xK1KgxZJ.js.map → -private-r5p8QUr4.js.map} +1 -1
  7. package/dist/configure.js +1 -1
  8. package/dist/graph/-private.js +1 -1
  9. package/dist/index.js +1 -1
  10. package/dist/reactive/-private.js +1 -1
  11. package/dist/reactive.js +3 -3
  12. package/dist/{request-z2NByNx0.js → request-DZVW74wn.js} +2 -2
  13. package/dist/{request-z2NByNx0.js.map → request-DZVW74wn.js.map} +1 -1
  14. package/dist/request.js +1 -1
  15. package/dist/signals/-leaked.js +1 -1
  16. package/dist/{src-s5HHjglV.js → src-CsvKpo_j.js} +5 -5
  17. package/dist/{src-s5HHjglV.js.map → src-CsvKpo_j.js.map} +1 -1
  18. package/dist/store/-private.js +1 -1
  19. package/dist/types/-private.js +1 -1
  20. package/dist/types/request.js +1 -1
  21. package/dist/types/runtime.js +1 -1
  22. package/dist/types/symbols.js +1 -1
  23. package/dist/unpkg/dev/{-private-BGCYELwo.js → -private-CbWd-ZyQ.js} +2 -2
  24. package/dist/unpkg/{dev-deprecated/-private-BGCYELwo.js.map → dev/-private-CbWd-ZyQ.js.map} +1 -1
  25. package/dist/unpkg/dev/{-private-DhiS6yOR.js → -private-DKli7-dV.js} +2 -2
  26. package/dist/unpkg/dev/{-private-DhiS6yOR.js.map → -private-DKli7-dV.js.map} +1 -1
  27. package/dist/unpkg/dev/{-private-pNQae3qH.js → -private-FcLmzpRX.js} +3 -3
  28. package/dist/unpkg/{dev-deprecated/-private-pNQae3qH.js.map → dev/-private-FcLmzpRX.js.map} +1 -1
  29. package/dist/unpkg/dev/configure.js +1 -1
  30. package/dist/unpkg/dev/graph/-private.js +1 -1
  31. package/dist/unpkg/dev/index.js +1 -1
  32. package/dist/unpkg/dev/reactive/-private.js +1 -1
  33. package/dist/unpkg/dev/reactive.js +3 -3
  34. package/dist/unpkg/dev/{request-BbbzRou7.js → request-sIfZjSrT.js} +2 -2
  35. package/dist/unpkg/dev/{request-BbbzRou7.js.map → request-sIfZjSrT.js.map} +1 -1
  36. package/dist/unpkg/dev/request.js +1 -1
  37. package/dist/unpkg/dev/signals/-leaked.js +1 -1
  38. package/dist/unpkg/dev/{src-Cf7NXXR2.js → src-CIPYMS1G.js} +5 -5
  39. package/dist/unpkg/dev/{src-Cf7NXXR2.js.map → src-CIPYMS1G.js.map} +1 -1
  40. package/dist/unpkg/dev/store/-private.js +1 -1
  41. package/dist/unpkg/dev/types/-private.js +1 -1
  42. package/dist/unpkg/dev/types/request.js +1 -1
  43. package/dist/unpkg/dev/types/runtime.js +1 -1
  44. package/dist/unpkg/dev/types/symbols.js +1 -1
  45. package/dist/unpkg/dev-deprecated/{-private-BGCYELwo.js → -private-CbWd-ZyQ.js} +2 -2
  46. package/dist/unpkg/{prod/-private-8gd8hbwm.js.map → dev-deprecated/-private-CbWd-ZyQ.js.map} +1 -1
  47. package/dist/unpkg/dev-deprecated/{-private-DhiS6yOR.js → -private-DKli7-dV.js} +2 -2
  48. package/dist/unpkg/dev-deprecated/{-private-DhiS6yOR.js.map → -private-DKli7-dV.js.map} +1 -1
  49. package/dist/unpkg/dev-deprecated/{-private-pNQae3qH.js → -private-FcLmzpRX.js} +3 -3
  50. package/dist/unpkg/{dev/-private-pNQae3qH.js.map → dev-deprecated/-private-FcLmzpRX.js.map} +1 -1
  51. package/dist/unpkg/dev-deprecated/configure.js +1 -1
  52. package/dist/unpkg/dev-deprecated/graph/-private.js +1 -1
  53. package/dist/unpkg/dev-deprecated/index.js +1 -1
  54. package/dist/unpkg/dev-deprecated/reactive/-private.js +1 -1
  55. package/dist/unpkg/dev-deprecated/reactive.js +3 -3
  56. package/dist/unpkg/dev-deprecated/{request-BbbzRou7.js → request-sIfZjSrT.js} +2 -2
  57. package/dist/unpkg/dev-deprecated/{request-BbbzRou7.js.map → request-sIfZjSrT.js.map} +1 -1
  58. package/dist/unpkg/dev-deprecated/request.js +1 -1
  59. package/dist/unpkg/dev-deprecated/signals/-leaked.js +1 -1
  60. package/dist/unpkg/dev-deprecated/{src-CSuFUXv4.js → src-BW5t6nJR.js} +5 -5
  61. package/dist/unpkg/dev-deprecated/{src-CSuFUXv4.js.map → src-BW5t6nJR.js.map} +1 -1
  62. package/dist/unpkg/dev-deprecated/store/-private.js +1 -1
  63. package/dist/unpkg/dev-deprecated/types/-private.js +1 -1
  64. package/dist/unpkg/dev-deprecated/types/request.js +1 -1
  65. package/dist/unpkg/dev-deprecated/types/runtime.js +1 -1
  66. package/dist/unpkg/dev-deprecated/types/symbols.js +1 -1
  67. package/dist/unpkg/{prod-deprecated/-private-B6aLbrgV.js → prod/-private-BPbQ_hud.js} +2 -2
  68. package/dist/unpkg/prod/{-private-B6aLbrgV.js.map → -private-BPbQ_hud.js.map} +1 -1
  69. package/dist/unpkg/{prod-deprecated/-private-ggVX_Iob.js → prod/-private-D4leSvXQ.js} +3 -3
  70. package/dist/unpkg/{prod-deprecated/-private-ggVX_Iob.js.map → prod/-private-D4leSvXQ.js.map} +1 -1
  71. package/dist/unpkg/prod/-private-DXAng78m.js +22 -0
  72. package/dist/unpkg/{prod-deprecated/-private-8gd8hbwm.js.map → prod/-private-DXAng78m.js.map} +1 -1
  73. package/dist/unpkg/prod/configure.js +1 -1
  74. package/dist/unpkg/prod/graph/-private.js +1 -1
  75. package/dist/unpkg/prod/index.js +1 -1
  76. package/dist/unpkg/prod/reactive/-private.js +1 -1
  77. package/dist/unpkg/prod/reactive.js +3 -3
  78. package/dist/unpkg/{prod-deprecated/request-BoeppjDj.js → prod/request-BkQ1-Ihx.js} +2 -2
  79. package/dist/unpkg/{prod-deprecated/request-BoeppjDj.js.map → prod/request-BkQ1-Ihx.js.map} +1 -1
  80. package/dist/unpkg/prod/request.js +1 -1
  81. package/dist/unpkg/prod/signals/-leaked.js +1 -1
  82. package/dist/unpkg/prod/{src-C0wuASrN.js → src-EVyOB2IR.js} +5 -5
  83. package/dist/unpkg/prod/{src-C0wuASrN.js.map → src-EVyOB2IR.js.map} +1 -1
  84. package/dist/unpkg/prod/store/-private.js +1 -1
  85. package/dist/unpkg/prod/types/-private.js +1 -1
  86. package/dist/unpkg/prod/types/request.js +1 -1
  87. package/dist/unpkg/prod/types/runtime.js +1 -1
  88. package/dist/unpkg/prod/types/symbols.js +1 -1
  89. package/dist/unpkg/{prod/-private-B6aLbrgV.js → prod-deprecated/-private-BPbQ_hud.js} +2 -2
  90. package/dist/unpkg/prod-deprecated/{-private-B6aLbrgV.js.map → -private-BPbQ_hud.js.map} +1 -1
  91. package/dist/unpkg/{prod/-private-ggVX_Iob.js → prod-deprecated/-private-D4leSvXQ.js} +3 -3
  92. package/dist/unpkg/{prod/-private-ggVX_Iob.js.map → prod-deprecated/-private-D4leSvXQ.js.map} +1 -1
  93. package/dist/unpkg/prod-deprecated/{-private-8gd8hbwm.js → -private-DXAng78m.js} +2 -2
  94. package/dist/unpkg/{dev/-private-BGCYELwo.js.map → prod-deprecated/-private-DXAng78m.js.map} +1 -1
  95. package/dist/unpkg/prod-deprecated/configure.js +1 -1
  96. package/dist/unpkg/prod-deprecated/graph/-private.js +1 -1
  97. package/dist/unpkg/prod-deprecated/index.js +1 -1
  98. package/dist/unpkg/prod-deprecated/reactive/-private.js +1 -1
  99. package/dist/unpkg/prod-deprecated/reactive.js +3 -3
  100. package/dist/unpkg/{prod/request-BoeppjDj.js → prod-deprecated/request-BkQ1-Ihx.js} +2 -2
  101. package/dist/unpkg/{prod/request-BoeppjDj.js.map → prod-deprecated/request-BkQ1-Ihx.js.map} +1 -1
  102. package/dist/unpkg/prod-deprecated/request.js +1 -1
  103. package/dist/unpkg/prod-deprecated/signals/-leaked.js +1 -1
  104. package/dist/unpkg/prod-deprecated/{src-BXOgNqmz.js → src-Bankvkbq.js} +5 -5
  105. package/dist/unpkg/prod-deprecated/{src-BXOgNqmz.js.map → src-Bankvkbq.js.map} +1 -1
  106. package/dist/unpkg/prod-deprecated/store/-private.js +1 -1
  107. package/dist/unpkg/prod-deprecated/types/-private.js +1 -1
  108. package/dist/unpkg/prod-deprecated/types/request.js +1 -1
  109. package/dist/unpkg/prod-deprecated/types/runtime.js +1 -1
  110. package/dist/unpkg/prod-deprecated/types/symbols.js +1 -1
  111. package/package.json +3 -3
  112. package/dist/unpkg/prod/-private-8gd8hbwm.js +0 -22
@@ -2,7 +2,7 @@ import { getGlobalConfig, macroCondition } from "@embroider/macros";
2
2
 
3
3
  //#region package.json
4
4
  var name = "@warp-drive/core";
5
- var version = "5.9.0-beta.3";
5
+ var version = "5.9.0";
6
6
 
7
7
  //#endregion
8
8
  //#region src/types/-private.ts
@@ -117,4 +117,4 @@ function setUniversalTransient(key, value) {
117
117
 
118
118
  //#endregion
119
119
  export { setTransient as a, peekUniversalTransient as i, getOrSetUniversal as n, setUniversalTransient as o, peekTransient as r, getOrSetGlobal as t };
120
- //# sourceMappingURL=-private-Cxa8cMBj.js.map
120
+ //# sourceMappingURL=-private-DJ3g9bNk.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"-private-Cxa8cMBj.js","names":["name","version","getGlobalConfig","macroCondition","GlobalRef","globalThis","UniversalCache","__warpDrive_universalCache","__version","GlobalSink","WarpDrive","env","DEBUG","Error","ModuleScopedCaches","__warpDrive_ModuleScopedCaches","TESTING","console","warn","__warpDrive_hasOtherCopy","getOrSetGlobal","key","value","existing","undefined","peekTransient","globalKey","setTransient","getOrSetUniversal","peekUniversalTransient","setUniversalTransient"],"sources":["../package.json","../src/types/-private.ts"],"sourcesContent":["","// in testing mode, we utilize globals to ensure only one copy exists of\n// these maps, due to bugs in ember-auto-import\nimport { DEBUG, TESTING } from '@warp-drive/core/build-config/env';\n\nimport { name, version } from '../../package.json';\n\ntype UniversalTransientKey =\n // @warp-drive/core/request\n 'REQ_ID';\n\ntype UniversalKey =\n | `(transient) ${UniversalTransientKey}`\n // @warp-drive/core/request\n | 'RequestMap'\n | 'PromiseCache'\n | 'RequestCache'\n // @warp-drive/core-types/request\n | 'SkipCache'\n | 'EnableHydration'\n // @warp-drive/core-types/runtime\n | 'WarpDriveRuntimeConfig';\n\ntype TransientKey =\n // @warp-drive/core/graph\n | 'transactionRef'\n // @warp-drive/core/store\n | 'configuredGenerationMethod'\n | 'configuredUpdateMethod'\n | 'configuredForgetMethod'\n | 'configuredResetMethod'\n | 'configuredKeyInfoMethod'\n | 'signalHooks';\n\ntype GlobalKey =\n | `(transient) ${TransientKey}`\n // @warp-drive/legacy/adapter\n | 'AdapterError'\n | 'InvalidError'\n | 'TimeoutError'\n | 'AbortError'\n | 'UnauthorizedError'\n | 'ForbiddenError'\n | 'NotFoundError'\n | 'ConflictError'\n | 'ServerError'\n // @warp-drive/core/store/reactivity\n | '#{}'\n | '#[]'\n | 'Signals'\n // @warp-drive/legacy LegacySupport\n | 'AvailableShims'\n // @warp-drive/core RecordArrayManager\n | 'FAKE_ARR'\n // @warp-drive/core ReactiveArray\n | '#source'\n | '#update'\n | '#notify'\n | 'IS_COLLECTION'\n // @warp-drive/core RequestCache\n | 'Touching'\n | 'RequestPromise'\n // @warp-drive/legacy/compat FetchManager\n | 'SaveOp'\n // @warp-drive/legacy Model\n | 'LEGACY_SUPPORT'\n | 'LegacySupport'\n // @warp-drive/core/graph\n | 'Graphs'\n // @warp-drive/core/request\n | 'IS_FROZEN'\n | 'IS_CACHE_HANDLER'\n // @warp-drive/utilities\n | 'CONFIG'\n // @warp-drive/core CacheKeyManager\n | 'DEBUG_MAP'\n | 'IDENTIFIERS'\n | 'DOCUMENTS'\n // @warp-drive/core InstanceCache\n | 'RecordCache'\n | 'StoreMap'\n // @warp-drive/core/types/symbols\n | 'Store'\n | '$type'\n | 'TransformName'\n | 'RequestSignature'\n // @warp-drive/core/types/request\n | 'IS_FUTURE'\n | 'DOC'\n // @warp-drive/core NotificationManager\n | 'UnscopedChannel'\n // @warp-drive/core/reactive\n | 'ManagedArrayMap'\n | 'ManagedObjectMap'\n | 'Support'\n | 'SOURCE'\n | 'Destroy'\n | 'Checkout'\n | 'Commit'\n | 'Context';\n\ntype ModuleScopedCaches = Record<GlobalKey, unknown>;\n\nconst GlobalRef = globalThis as unknown as Record<\n string,\n {\n __warpDrive_ModuleScopedCaches?: ModuleScopedCaches;\n __warpDrive_hasOtherCopy?: boolean;\n __version: string;\n }\n> & {\n __warpDrive_universalCache: Record<UniversalKey, unknown>;\n};\nconst UniversalCache = (GlobalRef.__warpDrive_universalCache =\n GlobalRef.__warpDrive_universalCache ?? ({} as Record<UniversalKey, unknown>));\n\n// in order to support mirror packages, we ensure that each\n// unique package name has its own global cache\nGlobalRef[name] = GlobalRef[name] ?? { __version: version };\nconst GlobalSink = GlobalRef[name];\n\nif (DEBUG) {\n if (GlobalSink.__version !== version) {\n throw new Error('Multiple versions of WarpDrive detected, the application will malfunction.');\n }\n}\n\nconst ModuleScopedCaches = GlobalSink.__warpDrive_ModuleScopedCaches ?? ({} as ModuleScopedCaches);\nif (TESTING) {\n if (!GlobalSink.__warpDrive_ModuleScopedCaches) {\n GlobalSink.__warpDrive_ModuleScopedCaches = ModuleScopedCaches;\n } else {\n // oxlint-disable-next-line no-console\n console.warn(`\nMultiple copies of WarpDrive have been detected. This may be due to a bug in ember-auto-import\n in which test assets get their own copy of some v2-addons. This can cause the application to\n malfunction as each copy will maintain its own separate state.`);\n }\n} else {\n if (GlobalSink.__warpDrive_hasOtherCopy) {\n throw new Error('Multiple copies of WarpDrive detected, the application will malfunction.');\n }\n GlobalSink.__warpDrive_hasOtherCopy = true;\n}\n\ntype UniqueSymbol<T extends string> = `___(unique) Symbol(${T})`;\ntype UniqueSymbolOr<T, K extends string> = T extends symbol ? UniqueSymbol<K> : T;\n\n/**\n * Coordinates creation of a singleton `value` (e.g. a symbol, WeakMap, or\n * error class) for `key` so that duplicate copies of this package loaded\n * into the same process observe the same instance instead of each creating\n * their own.\n *\n * In `TESTING` builds this stores/reads `value` from a cache namespaced to\n * this package's name on `globalThis` (see the file-level comments above for\n * why this is necessary). Outside of `TESTING`, only one copy of the package\n * is expected to exist, so this is a no-op that always returns `value`\n * unchanged.\n *\n * The return type lies about symbols being unique to work around the d.ts\n * rollup issue described in `reactive/-private/symbols.ts`.\n *\n * @private\n */\nexport function getOrSetGlobal<T, K extends GlobalKey>(key: K, value: T): UniqueSymbolOr<T, K> {\n if (TESTING) {\n const existing = ModuleScopedCaches[key];\n if (existing === undefined) {\n return (ModuleScopedCaches[key] = value) as UniqueSymbolOr<T, K>;\n } else {\n return existing as UniqueSymbolOr<T, K>;\n }\n } else {\n return value as UniqueSymbolOr<T, K>;\n }\n}\n\n/**\n * Reads back the current value stored for `key` by {@link setTransient}, or\n * `null` if nothing has been stored yet.\n *\n * Unlike {@link getOrSetGlobal}, this always reads through the same\n * package-namespaced cache regardless of the `TESTING` flag, since this is\n * used for genuinely mutable state (not just singleton values) that must\n * stay in sync across any duplicate copies of this package.\n *\n * @private\n */\nexport function peekTransient<T>(key: TransientKey): T | null {\n const globalKey: `(transient) ${TransientKey}` = `(transient) ${key}`;\n return (ModuleScopedCaches[globalKey] as T) ?? null;\n}\n\n/**\n * Stores `value` for `key`, overwriting whatever was previously stored, so\n * that it can later be read back via {@link peekTransient}.\n *\n * See {@link peekTransient} for details on when/why this cache is shared.\n *\n * @private\n */\nexport function setTransient<T>(key: TransientKey, value: T): T {\n const globalKey: `(transient) ${TransientKey}` = `(transient) ${key}`;\n return (ModuleScopedCaches[globalKey] = value);\n}\n\n/**\n * Like {@link getOrSetGlobal}, but reads/writes a cache that is shared across\n * *all* copies of WarpDrive on `globalThis`, regardless of package name.\n *\n * This is used for keys (e.g. request/promise caches) that must be\n * coordinated even across \"mirror\" packages published under different\n * names, rather than only across duplicate copies of the same package name.\n *\n * @private\n */\nexport function getOrSetUniversal<T, K extends UniversalKey>(key: K, value: T): UniqueSymbolOr<T, K> {\n if (TESTING) {\n const existing = UniversalCache[key];\n if (existing === undefined) {\n return (UniversalCache[key] = value) as UniqueSymbolOr<T, K>;\n } else {\n return existing as UniqueSymbolOr<T, K>;\n }\n } else {\n return value as UniqueSymbolOr<T, K>;\n }\n}\n\n/**\n * Like {@link peekTransient}, but reads from the package-name-independent\n * cache used by {@link getOrSetUniversal}. Always reads through this shared\n * cache regardless of the `TESTING` flag.\n *\n * @private\n */\nexport function peekUniversalTransient<T>(key: UniversalTransientKey): T | null {\n const globalKey: `(transient) ${UniversalTransientKey}` = `(transient) ${key}`;\n return (UniversalCache[globalKey] as T) ?? null;\n}\n\n/**\n * Like {@link setTransient}, but writes to the package-name-independent\n * cache used by {@link getOrSetUniversal}, so it can later be read via\n * {@link peekUniversalTransient}.\n *\n * @private\n */\nexport function setUniversalTransient<T>(key: UniversalTransientKey, value: T): T {\n const globalKey: `(transient) ${UniversalTransientKey}` = `(transient) ${key}`;\n return (UniversalCache[globalKey] = value);\n}\n"],"mappings":";;;;;;;;ACsGA,MAAMI,YAAYC;AAUlB,MAAMC,iBAAkBF,UAAUG,6BAChCH,UAAUG,8BAA+B,CAAC;AAI5CH,UAAUJ,QAAQI,UAAUJ,SAAS,EAAEQ,WAAWP,QAAQ;AAC1D,MAAMQ,aAAaL,UAAUJ;AAE7B,IAAAG,eAAAD,gBAAA,CAAA,CAAAQ,UAAAC,IAAAC,KAAA,GACE;KAAIH,WAAWD,cAAcP,SAC3B,MAAM,IAAIY,MAAM,4EAA4E;AAC9F;AAGF,MAAMC,qBAAqBL,WAAWM,kCAAmC,CAAC;AAC1E,IAAAZ,eAAAD,gBAAA,CAAA,CAAAQ,UAAAC,IAAAK,OAAA,GAAa;CACX,IAAI,CAACP,WAAWM,gCACdN,WAAWM,iCAAiCD;MAG5CG,QAAQC,KAAK;;;iEAGgD;AAEjE,OAAO;CACL,IAAIT,WAAWU,0BACb,MAAM,IAAIN,MAAM,0EAA0E;CAE5FJ,WAAWU,2BAA2B;AACxC;;;;;;;;;;;;;;;;;;AAsBA,SAAgBC,eAAuCC,KAAQC,OAAgC;CAC7F,IAAAnB,eAAAD,gBAAA,CAAA,CAAAQ,UAAAC,IAAAK,OAAA,GAAa;EACX,MAAMO,WAAWT,mBAAmBO;EACpC,IAAIE,aAAaC,QACf,OAAQV,mBAAmBO,OAAOC;OAElC,OAAOC;CAEX,OACE,OAAOD;AAEX;;;;;;;;;;;;AAaA,SAAgBG,cAAiBJ,KAA6B;CAC5D,MAAMK,YAA2C,eAAeL;CAChE,OAAQP,mBAAmBY,cAAoB;AACjD;;;;;;;;;AAUA,SAAgBC,aAAgBN,KAAmBC,OAAa;CAC9D,MAAMI,YAA2C,eAAeL;CAChE,OAAQP,mBAAmBY,aAAaJ;AAC1C;;;;;;;;;;;AAYA,SAAgBM,kBAA6CP,KAAQC,OAAgC;CACnG,IAAAnB,eAAAD,gBAAA,CAAA,CAAAQ,UAAAC,IAAAK,OAAA,GAAa;EACX,MAAMO,WAAWjB,eAAee;EAChC,IAAIE,aAAaC,QACf,OAAQlB,eAAee,OAAOC;OAE9B,OAAOC;CAEX,OACE,OAAOD;AAEX;;;;;;;;AASA,SAAgBO,uBAA0BR,KAAsC;CAC9E,MAAMK,YAAoD,eAAeL;CACzE,OAAQf,eAAeoB,cAAoB;AAC7C;;;;;;;;AASA,SAAgBI,sBAAyBT,KAA4BC,OAAa;CAChF,MAAMI,YAAoD,eAAeL;CACzE,OAAQf,eAAeoB,aAAaJ;AACtC"}
1
+ {"version":3,"file":"-private-DJ3g9bNk.js","names":["name","version","getGlobalConfig","macroCondition","GlobalRef","globalThis","UniversalCache","__warpDrive_universalCache","__version","GlobalSink","WarpDrive","env","DEBUG","Error","ModuleScopedCaches","__warpDrive_ModuleScopedCaches","TESTING","console","warn","__warpDrive_hasOtherCopy","getOrSetGlobal","key","value","existing","undefined","peekTransient","globalKey","setTransient","getOrSetUniversal","peekUniversalTransient","setUniversalTransient"],"sources":["../package.json","../src/types/-private.ts"],"sourcesContent":["","// in testing mode, we utilize globals to ensure only one copy exists of\n// these maps, due to bugs in ember-auto-import\nimport { DEBUG, TESTING } from '@warp-drive/core/build-config/env';\n\nimport { name, version } from '../../package.json';\n\ntype UniversalTransientKey =\n // @warp-drive/core/request\n 'REQ_ID';\n\ntype UniversalKey =\n | `(transient) ${UniversalTransientKey}`\n // @warp-drive/core/request\n | 'RequestMap'\n | 'PromiseCache'\n | 'RequestCache'\n // @warp-drive/core-types/request\n | 'SkipCache'\n | 'EnableHydration'\n // @warp-drive/core-types/runtime\n | 'WarpDriveRuntimeConfig';\n\ntype TransientKey =\n // @warp-drive/core/graph\n | 'transactionRef'\n // @warp-drive/core/store\n | 'configuredGenerationMethod'\n | 'configuredUpdateMethod'\n | 'configuredForgetMethod'\n | 'configuredResetMethod'\n | 'configuredKeyInfoMethod'\n | 'signalHooks';\n\ntype GlobalKey =\n | `(transient) ${TransientKey}`\n // @warp-drive/legacy/adapter\n | 'AdapterError'\n | 'InvalidError'\n | 'TimeoutError'\n | 'AbortError'\n | 'UnauthorizedError'\n | 'ForbiddenError'\n | 'NotFoundError'\n | 'ConflictError'\n | 'ServerError'\n // @warp-drive/core/store/reactivity\n | '#{}'\n | '#[]'\n | 'Signals'\n // @warp-drive/legacy LegacySupport\n | 'AvailableShims'\n // @warp-drive/core RecordArrayManager\n | 'FAKE_ARR'\n // @warp-drive/core ReactiveArray\n | '#source'\n | '#update'\n | '#notify'\n | 'IS_COLLECTION'\n // @warp-drive/core RequestCache\n | 'Touching'\n | 'RequestPromise'\n // @warp-drive/legacy/compat FetchManager\n | 'SaveOp'\n // @warp-drive/legacy Model\n | 'LEGACY_SUPPORT'\n | 'LegacySupport'\n // @warp-drive/core/graph\n | 'Graphs'\n // @warp-drive/core/request\n | 'IS_FROZEN'\n | 'IS_CACHE_HANDLER'\n // @warp-drive/utilities\n | 'CONFIG'\n // @warp-drive/core CacheKeyManager\n | 'DEBUG_MAP'\n | 'IDENTIFIERS'\n | 'DOCUMENTS'\n // @warp-drive/core InstanceCache\n | 'RecordCache'\n | 'StoreMap'\n // @warp-drive/core/types/symbols\n | 'Store'\n | '$type'\n | 'TransformName'\n | 'RequestSignature'\n // @warp-drive/core/types/request\n | 'IS_FUTURE'\n | 'DOC'\n // @warp-drive/core NotificationManager\n | 'UnscopedChannel'\n // @warp-drive/core/reactive\n | 'ManagedArrayMap'\n | 'ManagedObjectMap'\n | 'Support'\n | 'SOURCE'\n | 'Destroy'\n | 'Checkout'\n | 'Commit'\n | 'Context';\n\ntype ModuleScopedCaches = Record<GlobalKey, unknown>;\n\nconst GlobalRef = globalThis as unknown as Record<\n string,\n {\n __warpDrive_ModuleScopedCaches?: ModuleScopedCaches;\n __warpDrive_hasOtherCopy?: boolean;\n __version: string;\n }\n> & {\n __warpDrive_universalCache: Record<UniversalKey, unknown>;\n};\nconst UniversalCache = (GlobalRef.__warpDrive_universalCache =\n GlobalRef.__warpDrive_universalCache ?? ({} as Record<UniversalKey, unknown>));\n\n// in order to support mirror packages, we ensure that each\n// unique package name has its own global cache\nGlobalRef[name] = GlobalRef[name] ?? { __version: version };\nconst GlobalSink = GlobalRef[name];\n\nif (DEBUG) {\n if (GlobalSink.__version !== version) {\n throw new Error('Multiple versions of WarpDrive detected, the application will malfunction.');\n }\n}\n\nconst ModuleScopedCaches = GlobalSink.__warpDrive_ModuleScopedCaches ?? ({} as ModuleScopedCaches);\nif (TESTING) {\n if (!GlobalSink.__warpDrive_ModuleScopedCaches) {\n GlobalSink.__warpDrive_ModuleScopedCaches = ModuleScopedCaches;\n } else {\n // oxlint-disable-next-line no-console\n console.warn(`\nMultiple copies of WarpDrive have been detected. This may be due to a bug in ember-auto-import\n in which test assets get their own copy of some v2-addons. This can cause the application to\n malfunction as each copy will maintain its own separate state.`);\n }\n} else {\n if (GlobalSink.__warpDrive_hasOtherCopy) {\n throw new Error('Multiple copies of WarpDrive detected, the application will malfunction.');\n }\n GlobalSink.__warpDrive_hasOtherCopy = true;\n}\n\ntype UniqueSymbol<T extends string> = `___(unique) Symbol(${T})`;\ntype UniqueSymbolOr<T, K extends string> = T extends symbol ? UniqueSymbol<K> : T;\n\n/**\n * Coordinates creation of a singleton `value` (e.g. a symbol, WeakMap, or\n * error class) for `key` so that duplicate copies of this package loaded\n * into the same process observe the same instance instead of each creating\n * their own.\n *\n * In `TESTING` builds this stores/reads `value` from a cache namespaced to\n * this package's name on `globalThis` (see the file-level comments above for\n * why this is necessary). Outside of `TESTING`, only one copy of the package\n * is expected to exist, so this is a no-op that always returns `value`\n * unchanged.\n *\n * The return type lies about symbols being unique to work around the d.ts\n * rollup issue described in `reactive/-private/symbols.ts`.\n *\n * @private\n */\nexport function getOrSetGlobal<T, K extends GlobalKey>(key: K, value: T): UniqueSymbolOr<T, K> {\n if (TESTING) {\n const existing = ModuleScopedCaches[key];\n if (existing === undefined) {\n return (ModuleScopedCaches[key] = value) as UniqueSymbolOr<T, K>;\n } else {\n return existing as UniqueSymbolOr<T, K>;\n }\n } else {\n return value as UniqueSymbolOr<T, K>;\n }\n}\n\n/**\n * Reads back the current value stored for `key` by {@link setTransient}, or\n * `null` if nothing has been stored yet.\n *\n * Unlike {@link getOrSetGlobal}, this always reads through the same\n * package-namespaced cache regardless of the `TESTING` flag, since this is\n * used for genuinely mutable state (not just singleton values) that must\n * stay in sync across any duplicate copies of this package.\n *\n * @private\n */\nexport function peekTransient<T>(key: TransientKey): T | null {\n const globalKey: `(transient) ${TransientKey}` = `(transient) ${key}`;\n return (ModuleScopedCaches[globalKey] as T) ?? null;\n}\n\n/**\n * Stores `value` for `key`, overwriting whatever was previously stored, so\n * that it can later be read back via {@link peekTransient}.\n *\n * See {@link peekTransient} for details on when/why this cache is shared.\n *\n * @private\n */\nexport function setTransient<T>(key: TransientKey, value: T): T {\n const globalKey: `(transient) ${TransientKey}` = `(transient) ${key}`;\n return (ModuleScopedCaches[globalKey] = value);\n}\n\n/**\n * Like {@link getOrSetGlobal}, but reads/writes a cache that is shared across\n * *all* copies of WarpDrive on `globalThis`, regardless of package name.\n *\n * This is used for keys (e.g. request/promise caches) that must be\n * coordinated even across \"mirror\" packages published under different\n * names, rather than only across duplicate copies of the same package name.\n *\n * @private\n */\nexport function getOrSetUniversal<T, K extends UniversalKey>(key: K, value: T): UniqueSymbolOr<T, K> {\n if (TESTING) {\n const existing = UniversalCache[key];\n if (existing === undefined) {\n return (UniversalCache[key] = value) as UniqueSymbolOr<T, K>;\n } else {\n return existing as UniqueSymbolOr<T, K>;\n }\n } else {\n return value as UniqueSymbolOr<T, K>;\n }\n}\n\n/**\n * Like {@link peekTransient}, but reads from the package-name-independent\n * cache used by {@link getOrSetUniversal}. Always reads through this shared\n * cache regardless of the `TESTING` flag.\n *\n * @private\n */\nexport function peekUniversalTransient<T>(key: UniversalTransientKey): T | null {\n const globalKey: `(transient) ${UniversalTransientKey}` = `(transient) ${key}`;\n return (UniversalCache[globalKey] as T) ?? null;\n}\n\n/**\n * Like {@link setTransient}, but writes to the package-name-independent\n * cache used by {@link getOrSetUniversal}, so it can later be read via\n * {@link peekUniversalTransient}.\n *\n * @private\n */\nexport function setUniversalTransient<T>(key: UniversalTransientKey, value: T): T {\n const globalKey: `(transient) ${UniversalTransientKey}` = `(transient) ${key}`;\n return (UniversalCache[globalKey] = value);\n}\n"],"mappings":";;;;;;;;ACsGA,MAAMI,YAAYC;AAUlB,MAAMC,iBAAkBF,UAAUG,6BAChCH,UAAUG,8BAA+B,CAAC;AAI5CH,UAAUJ,QAAQI,UAAUJ,SAAS,EAAEQ,WAAWP,QAAQ;AAC1D,MAAMQ,aAAaL,UAAUJ;AAE7B,IAAAG,eAAAD,gBAAA,CAAA,CAAAQ,UAAAC,IAAAC,KAAA,GACE;K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L;CACzE,OAAQf,eAAeoB,aAAaJ;AACtC"}
@@ -1,4 +1,4 @@
1
- import { t as getOrSetGlobal } from "./-private-Cxa8cMBj.js";
1
+ import { t as getOrSetGlobal } from "./-private-DJ3g9bNk.js";
2
2
 
3
3
  //#region src/reactive/-private/symbols.ts
4
4
  const SOURCE = getOrSetGlobal("SOURCE", Symbol("#source"));
@@ -19,4 +19,4 @@ const Context = getOrSetGlobal("Context", Symbol("Context"));
19
19
 
20
20
  //#endregion
21
21
  export { SOURCE as a, Destroy as i, Commit as n, Context as r, Checkout as t };
22
- //# sourceMappingURL=-private-xK1KgxZJ.js.map
22
+ //# sourceMappingURL=-private-r5p8QUr4.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"-private-xK1KgxZJ.js","names":["getOrSetGlobal","SOURCE","Symbol","Destroy","dispose","for","Checkout","Commit","Context"],"sources":["../src/reactive/-private/symbols.ts"],"sourcesContent":["///////////////////\n///// WARNING /////\n///////////////////\n\nimport { getOrSetGlobal } from '../../types/-private';\n\n// Great, got your attention with that warning didn't we?\n// Good. Here's the deal: typescript treats symbols as unique types.\n// If by accident a module creating a symbol is processed more than\n// once, the symbol will be different in each processing. This will\n// cause a type error.\n// It could also cause a runtime error if the symbol is used innapropriately.\n// However, this case is extremely hard to hit and would require other things\n// to go wrong first.\n//\n// So, why do the warning? And why do we lie about the types of the symbols?\n//\n// Because we intentionally create multiple copies of them within the types\n// at build time. This is because we rollup our d.ts files in order to give\n// our consumers a better experience.\n//\n// However, no tool today supports rolling up d.ts files with multiple entry\n// points correctly. The tool we use currently (vite-plugin-dts) uses @microsoft/api-extractor\n// which creates a fully unique stand-alone types file per-entry-point. Thus\n// every entry point that uses one of these symbols somewhere will have accidentally\n// created a new symbol type.\n//\n// This cast allows us to rollup these types using this tool while not encountering\n// the unique symbol type issue.\n//\n// Note that none of these symbols are part of the public API, these are used for\n// debugging DX and as a safe way to provide an intimate contract on public objects.\n\nexport const SOURCE: '___(unique) Symbol(SOURCE)' = getOrSetGlobal('SOURCE', Symbol('#source'));\n\nexport const Destroy: '___(unique) Symbol(Destroy)' = getOrSetGlobal(\n 'Destroy',\n Symbol.dispose || Symbol.for('Dispose')\n);\n/**\n * Symbol for the method used to request a mutable copy of an otherwise\n * immutable {@link ReactiveResource}.\n *\n * @deprecated use the {@link checkout} utility function instead.\n */\nexport const Checkout: '___(unique) Symbol(Checkout)' = getOrSetGlobal('Checkout', Symbol('Checkout'));\nexport const Commit: '___(unique) Symbol(Commit)' = getOrSetGlobal('Commit', Symbol('Commit'));\n\n/**\n * Symbol used to stash the internal field/resource context (schema, store,\n * mutability, etc.) on a {@link ReactiveResource} or reactive field instance.\n */\nexport const Context: '___(unique) Symbol(Context)' = getOrSetGlobal('Context', Symbol('Context'));\n"],"mappings":";;;AAiCA,MAAaC,SAAuCD,eAAe,UAAUE,OAAO,SAAS,CAAC;AAE9F,MAAaC,UAAyCH,eACpD,WACAE,OAAOE,WAAWF,OAAOG,IAAI,SAAS,CACxC;;;;;;;AAOA,MAAaC,WAA2CN,eAAe,YAAYE,OAAO,UAAU,CAAC;AACrG,MAAaK,SAAuCP,eAAe,UAAUE,OAAO,QAAQ,CAAC;;;;;AAM7F,MAAaM,UAAyCR,eAAe,WAAWE,OAAO,SAAS,CAAC"}
1
+ {"version":3,"file":"-private-r5p8QUr4.js","names":["getOrSetGlobal","SOURCE","Symbol","Destroy","dispose","for","Checkout","Commit","Context"],"sources":["../src/reactive/-private/symbols.ts"],"sourcesContent":["///////////////////\n///// WARNING /////\n///////////////////\n\nimport { getOrSetGlobal } from '../../types/-private';\n\n// Great, got your attention with that warning didn't we?\n// Good. Here's the deal: typescript treats symbols as unique types.\n// If by accident a module creating a symbol is processed more than\n// once, the symbol will be different in each processing. This will\n// cause a type error.\n// It could also cause a runtime error if the symbol is used innapropriately.\n// However, this case is extremely hard to hit and would require other things\n// to go wrong first.\n//\n// So, why do the warning? And why do we lie about the types of the symbols?\n//\n// Because we intentionally create multiple copies of them within the types\n// at build time. This is because we rollup our d.ts files in order to give\n// our consumers a better experience.\n//\n// However, no tool today supports rolling up d.ts files with multiple entry\n// points correctly. The tool we use currently (vite-plugin-dts) uses @microsoft/api-extractor\n// which creates a fully unique stand-alone types file per-entry-point. Thus\n// every entry point that uses one of these symbols somewhere will have accidentally\n// created a new symbol type.\n//\n// This cast allows us to rollup these types using this tool while not encountering\n// the unique symbol type issue.\n//\n// Note that none of these symbols are part of the public API, these are used for\n// debugging DX and as a safe way to provide an intimate contract on public objects.\n\nexport const SOURCE: '___(unique) Symbol(SOURCE)' = getOrSetGlobal('SOURCE', Symbol('#source'));\n\nexport const Destroy: '___(unique) Symbol(Destroy)' = getOrSetGlobal(\n 'Destroy',\n Symbol.dispose || Symbol.for('Dispose')\n);\n/**\n * Symbol for the method used to request a mutable copy of an otherwise\n * immutable {@link ReactiveResource}.\n *\n * @deprecated use the {@link checkout} utility function instead.\n */\nexport const Checkout: '___(unique) Symbol(Checkout)' = getOrSetGlobal('Checkout', Symbol('Checkout'));\nexport const Commit: '___(unique) Symbol(Commit)' = getOrSetGlobal('Commit', Symbol('Commit'));\n\n/**\n * Symbol used to stash the internal field/resource context (schema, store,\n * mutability, etc.) on a {@link ReactiveResource} or reactive field instance.\n */\nexport const Context: '___(unique) Symbol(Context)' = getOrSetGlobal('Context', Symbol('Context'));\n"],"mappings":";;;AAiCA,MAAaC,SAAuCD,eAAe,UAAUE,OAAO,SAAS,CAAC;AAE9F,MAAaC,UAAyCH,eACpD,WACAE,OAAOE,WAAWF,OAAOG,IAAI,SAAS,CACxC;;;;;;;AAOA,MAAaC,WAA2CN,eAAe,YAAYE,OAAO,UAAU,CAAC;AACrG,MAAaK,SAAuCP,eAAe,UAAUE,OAAO,QAAQ,CAAC;;;;;AAM7F,MAAaM,UAAyCR,eAAe,WAAWE,OAAO,SAAS,CAAC"}
package/dist/configure.js CHANGED
@@ -1,3 +1,3 @@
1
- import { M as setupSignals } from "./-private-BL9zXgJB.js";
1
+ import { M as setupSignals } from "./-private-C4L-6BFr.js";
2
2
 
3
3
  export { setupSignals };
@@ -1,4 +1,4 @@
1
- import { a as setTransient, r as peekTransient, t as getOrSetGlobal } from "../-private-Cxa8cMBj.js";
1
+ import { a as setTransient, r as peekTransient, t as getOrSetGlobal } from "../-private-DJ3g9bNk.js";
2
2
  import { getGlobalConfig, macroCondition } from "@embroider/macros";
3
3
  import { deprecate, warn } from "@ember/debug";
4
4
 
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { A as setIdentifierResetMethod, M as setKeyInfoForResource, O as setIdentifierForgetMethod, S as recordIdentifierFor, h as Store, j as setIdentifierUpdateMethod, k as setIdentifierGenerationMethod, m as CacheHandler, n as RequestManager, r as Fetch, t as useRecommendedStore, w as storeFor } from "./src-s5HHjglV.js";
1
+ import { A as setIdentifierResetMethod, M as setKeyInfoForResource, O as setIdentifierForgetMethod, S as recordIdentifierFor, h as Store, j as setIdentifierUpdateMethod, k as setIdentifierGenerationMethod, m as CacheHandler, n as RequestManager, r as Fetch, t as useRecommendedStore, w as storeFor } from "./src-CsvKpo_j.js";
2
2
 
3
3
  export { CacheHandler, Fetch, RequestManager, Store, recordIdentifierFor as cacheKeyFor, recordIdentifierFor, setIdentifierForgetMethod, setIdentifierGenerationMethod, setIdentifierResetMethod, setIdentifierUpdateMethod, setKeyInfoForResource, storeFor, useRecommendedStore };
@@ -1,3 +1,3 @@
1
- import { r as Context } from "../-private-xK1KgxZJ.js";
1
+ import { r as Context } from "../-private-r5p8QUr4.js";
2
2
 
3
3
  export { Context };
package/dist/reactive.js CHANGED
@@ -1,5 +1,5 @@
1
- import { d as getRequestState, t as getPromiseState, u as createRequestSubscription } from "./-private-BL9zXgJB.js";
2
- import { t as Checkout } from "./-private-xK1KgxZJ.js";
3
- import { a as fromIdentity, c as instantiateRecord, d as commit, i as SchemaService, l as teardownRecord, o as registerDerivations, s as withDefaults, u as checkout } from "./src-s5HHjglV.js";
1
+ import { d as getRequestState, t as getPromiseState, u as createRequestSubscription } from "./-private-C4L-6BFr.js";
2
+ import { t as Checkout } from "./-private-r5p8QUr4.js";
3
+ import { a as fromIdentity, c as instantiateRecord, d as commit, i as SchemaService, l as teardownRecord, o as registerDerivations, s as withDefaults, u as checkout } from "./src-CsvKpo_j.js";
4
4
 
5
5
  export { Checkout, SchemaService, checkout, commit, createRequestSubscription, fromIdentity, getPromiseState, getRequestState, instantiateRecord, registerDerivations, teardownRecord, withDefaults };
@@ -1,4 +1,4 @@
1
- import { n as getOrSetUniversal, t as getOrSetGlobal } from "./-private-Cxa8cMBj.js";
1
+ import { n as getOrSetUniversal, t as getOrSetGlobal } from "./-private-DJ3g9bNk.js";
2
2
  import { IS_FUTURE, STRUCTURED, SkipCache } from "./types/request.js";
3
3
  import { CACHE_OWNER } from "./types/identifier.js";
4
4
  import { getGlobalConfig, macroCondition } from "@embroider/macros";
@@ -763,4 +763,4 @@ const withBrand = withResponseType;
763
763
 
764
764
  //#endregion
765
765
  export { upgradePromise as a, executeNextHandler as c, getRequestResult as d, setPromiseResult as f, createDeferred as i, clearRequestResult as l, assertValidRequest as m, withReactiveResponse as n, DOMError as o, cloneResponseProperties as p, withResponseType as r, IS_CACHE_HANDLER as s, withBrand as t, getPromiseResult as u };
766
- //# sourceMappingURL=request-z2NByNx0.js.map
766
+ //# sourceMappingURL=request-DZVW74wn.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"request-z2NByNx0.js","names":["getOrSetGlobal","CACHE_OWNER","Context","upgradeHeaders","getGlobalConfig","macroCondition","BODY_TYPES","type","klass","ValidKeys","Map","IS_FROZEN","Symbol","IS_COLLECTION","for","freezeHeaders","headers","delete","set","append","Error","deepFreeze","value","_type","_niceType","niceTypeOf","arr","map","Object","freeze","keys","forEach","key","isMaybeContext","request","length","v","Array","isArray","Date","Set","ReadableStream","WritableStream","TransformStream","Headers","constructor","name","validateKey","errors","schema","get","IgnoredKeys","has","push","includes","join","JSON","stringify","e","message","k","String","assertValidRequest","isTopLevel","WarpDrive","env","DEBUG","validationErrors","isLegacyRequest","Boolean","url","error","SkipCache","deepFreeze","createDeferred","getGlobalConfig","macroCondition","upgradeHeaders","headers","clone","Headers","toJSON","Array","from","cloneResponseProperties","response","ok","redirected","status","statusText","type","url","ContextOwner","hasSetStream","hasSetResponse","hasSubscribers","stream","nextCalled","constructor","request","god","isRoot","requestId","id","controller","promise","sizeHint","signal","addEventListener","abort","reason","enhancedRequest","Object","assign","WarpDrive","env","DEBUG","cacheOptions","then","hasRequestedStream","getResponse","getStream","hint","get","parseInt","setStream","Promise","resolve","resolveStream","setResponse","Error","Response","responseData","Context","owner","isCacheHandler","___owner","_isCacheHandler","_finalized","setIdentifier","identifier","test","_finalize","getOrSetUniversal","PromiseCache","WeakMap","RequestMap","Map","setRequestResult","requestId","result","set","clearRequestResult","delete","getRequestResult","get","setPromiseResult","promise","getPromiseResult","getOrSetGlobal","STRUCTURED","Context","ContextOwner","assertValidRequest","createFuture","isFuture","setRequestResult","getGlobalConfig","macroCondition","IS_CACHE_HANDLER","Symbol","DOMError","DOMException","Error","curryFuture","owner","inbound","outbound","setStream","getStream","then","doc","document","request","response","content","resolve","error","isDoc","god","stream","e","Object","assign","message","getResponse","reject","promise","ensureDoc","isError","enhanceReason","reason","name","handleOutcome","controller","signal","aborted","isCacheHandler","handler","index","Boolean","executeNextHandler","wares","i","WarpDrive","env","DEBUG","length","next","r","nextCalled","_isCacheHandler","context","outcome","_finalize","Promise","requestId","result","console","log","undefined","future","IS_FUTURE","enhanceReason","getGlobalConfig","macroCondition","isFuture","maybe","Boolean","Promise","createDeferred","resolve","reject","promise","res","rej","upgradePromise","future","getStream","abort","onFinalize","id","lid","requester","WarpDrive","env","DEBUG","toJSON","createFuture","owner","deferred","cbs","finally","resolveStream","forEach","cb","fn","push","reason","requestId","god","identifier","createDeferred","setPromiseResult","getPromiseResult","withResponseType","obj","withReactiveResponse","withBrand"],"sources":["../src/request/-private/debug.ts","../src/request/-private/context.ts","../src/request/-private/promise-cache.ts","../src/request/-private/utils.ts","../src/request/-private/future.ts","../src/request.ts"],"sourcesContent":["import { DEBUG } from '@warp-drive/core/build-config/env';\n\nimport { getOrSetGlobal } from '../../types/-private';\nimport { CACHE_OWNER } from '../../types/identifier';\nimport type { ImmutableHeaders, RequestInfo } from '../../types/request';\nimport { Context, upgradeHeaders } from './context';\n\nconst BODY_TYPES = {\n type: 'string',\n klass: ['Blob', 'ArrayBuffer', 'TypedArray', 'DataView', 'FormData', 'URLSearchParams', 'ReadableStream'],\n};\nconst ValidKeys = new Map<string, string | string[] | typeof BODY_TYPES>([\n ['duplex', ['half']],\n ['records', 'array'],\n ['data', 'json'],\n ['body', BODY_TYPES],\n ['disableTestWaiter', 'boolean'],\n ['options', 'object'],\n ['cacheOptions', 'object'],\n ['priority', ['high', 'low', 'auto']],\n ['op', 'string'],\n ['store', 'object'],\n ['url', 'string'],\n ['cache', ['default', 'force-cache', 'no-cache', 'no-store', 'only-if-cached', 'reload']],\n ['credentials', ['include', 'omit', 'same-origin']],\n [\n 'destination',\n [\n '',\n 'object',\n 'audio',\n 'audioworklet',\n 'document',\n 'embed',\n 'font',\n 'frame',\n 'iframe',\n 'image',\n 'manifest',\n 'paintworklet',\n 'report',\n 'script',\n 'sharedworker',\n 'style',\n 'track',\n 'video',\n 'worker',\n 'xslt',\n ],\n ],\n ['headers', 'headers'],\n ['integrity', 'string'],\n ['keepalive', 'boolean'],\n ['method', ['QUERY', 'GET', 'PUT', 'PATCH', 'DELETE', 'POST', 'OPTIONS', 'HEAD', 'CONNECT', 'TRACE']],\n ['mode', ['same-origin', 'cors', 'navigate', 'no-cors']],\n ['redirect', ['error', 'follow', 'manual']],\n ['referrer', 'string'],\n ['signal', 'AbortSignal'],\n ['controller', 'AbortController'],\n [\n 'referrerPolicy',\n [\n '',\n 'same-origin',\n 'no-referrer',\n 'no-referrer-when-downgrade',\n 'origin',\n 'origin-when-cross-origin',\n 'strict-origin',\n 'strict-origin-when-cross-origin',\n 'unsafe-url',\n ],\n ],\n]);\n\nconst IS_FROZEN = getOrSetGlobal('IS_FROZEN', Symbol('FROZEN'));\nconst IS_COLLECTION = getOrSetGlobal('IS_COLLECTION', Symbol.for('Collection'));\n\nfunction freezeHeaders(headers: Headers | ImmutableHeaders): ImmutableHeaders {\n headers.delete =\n headers.set =\n headers.append =\n () => {\n throw new Error(`Cannot Mutate Immutatable Headers, use headers.clone to get a copy`);\n };\n upgradeHeaders(headers);\n return headers as ImmutableHeaders;\n}\n\nexport function deepFreeze<T = unknown>(value: T): T {\n if (value && (value as { [IS_FROZEN]?: true })[IS_FROZEN]) {\n return value;\n }\n const _type = typeof value;\n switch (_type) {\n case 'boolean':\n case 'string':\n case 'number':\n case 'symbol':\n case 'undefined':\n case 'bigint':\n return value;\n case 'function':\n throw new Error(`Cannot deep-freeze a function`);\n case 'object': {\n const _niceType = niceTypeOf(value);\n switch (_niceType) {\n case 'array': {\n if ((value as unknown[] & { [IS_COLLECTION]?: true })[IS_COLLECTION]) {\n return value;\n }\n const arr = (value as unknown[]).map(deepFreeze);\n arr[IS_FROZEN as unknown as number] = true;\n return Object.freeze(arr) as T;\n }\n case 'null':\n return value;\n case 'object':\n Object.keys(value as Record<string, unknown>).forEach((key) => {\n try {\n (value as Record<string, unknown>)[key] = deepFreeze((value as Record<string, unknown>)[key]);\n } catch {\n // continue\n }\n });\n (value as Record<string | symbol, unknown>)[IS_FROZEN] = true;\n return Object.freeze(value);\n case 'headers':\n return freezeHeaders(value as Headers) as T;\n case 'Collection':\n case 'Store':\n case 'AbortSignal':\n case 'identifier':\n return value;\n case 'date':\n case 'map':\n case 'set':\n case 'error':\n case 'stream':\n default:\n // console.log(`Cannot deep-freeze ${_niceType}`);\n return value;\n }\n }\n }\n}\n\nfunction isMaybeContext(request: unknown) {\n if (request && typeof request === 'object') {\n const keys = Object.keys(request);\n if (keys.length === 1 && keys[0] === 'request') {\n return true;\n }\n }\n return false;\n}\n\nfunction niceTypeOf(v: unknown) {\n if (v === null) {\n return 'null';\n }\n if (typeof v === 'string') {\n return v ? 'non-empty-string' : 'empty-string';\n }\n if (!v) {\n return typeof v;\n }\n if (Array.isArray(v)) {\n return 'array';\n }\n if (v instanceof Date) {\n return 'date';\n }\n if (v instanceof Map) {\n return 'map';\n }\n if (v instanceof Set) {\n return 'set';\n }\n if (v instanceof Error) {\n return 'error';\n }\n if (v instanceof ReadableStream || v instanceof WritableStream || v instanceof TransformStream) {\n return 'stream';\n }\n if (v instanceof Headers) {\n return 'headers';\n }\n // ResourceKey/RequestKey identifiers are owned by the store's identity cache and must\n // remain mutable (e.g. `.id` is assigned once the server confirms it); deep-freezing a\n // request's `record`/`data` reference to one would freeze the store's live identifier,\n // not a copy of it.\n if (typeof v === 'object' && CACHE_OWNER in v) {\n return 'identifier';\n }\n if (typeof v === 'object' && v.constructor && v.constructor.name !== 'Object') {\n return v.constructor.name;\n }\n return typeof v;\n}\n\nfunction validateKey(key: string, value: unknown, errors: string[]) {\n const schema = ValidKeys.get(key);\n if (!schema && !IgnoredKeys.has(key)) {\n errors.push(`InvalidKey: '${key}'`);\n return;\n }\n if (schema) {\n if (schema === BODY_TYPES) {\n if (typeof value === 'string' || value instanceof ReadableStream) {\n return;\n }\n const type = niceTypeOf(value);\n if (schema.klass.includes(type)) {\n return;\n }\n errors.push(\n `InvalidValue: key 'body' should be a string or one of '${schema.klass.join(\"', '\")}', received ${\n '<a value of type ' + niceTypeOf(value) + '>'\n }`\n );\n return;\n }\n if (Array.isArray(schema)) {\n if (!schema.includes(value as string)) {\n errors.push(\n `InvalidValue: key ${key} should be one of '${schema.join(\"', '\")}', received ${\n typeof value === 'string' ? value : '<a value of type ' + niceTypeOf(value) + '>'\n }`\n );\n }\n return;\n } else if (schema === 'json') {\n try {\n JSON.stringify(value);\n } catch (e) {\n errors.push(\n `InvalidValue: key ${key} should be a JSON serializable value, but failed to serialize with Error - ${\n (e as Error).message\n }`\n );\n }\n return;\n } else if (schema === 'headers') {\n if (!(value instanceof Headers)) {\n errors.push(`InvalidValue: key ${key} should be an instance of Headers, received ${niceTypeOf(value)}`);\n }\n return;\n } else if (schema === 'record') {\n const _type = typeof value;\n // record must extend plain object or Object.create(null)\n if (!value || _type !== 'object' || (value.constructor && value.constructor !== Object)) {\n errors.push(\n `InvalidValue: key ${key} should be a dictionary of string keys to string values, received ${niceTypeOf(\n value\n )}`\n );\n return;\n }\n const keys = Object.keys(value);\n keys.forEach((k) => {\n const v: unknown = (value as Record<string, unknown>)[k];\n if (typeof k !== 'string') {\n errors.push(`\\tThe key ${String(k)} on ${key} should be a string key`);\n } else if (typeof v !== 'string') {\n errors.push(`\\tThe value of ${key}.${k} should be a string not ${niceTypeOf(v)}`);\n }\n });\n return;\n } else if (schema === 'string') {\n if (typeof value !== 'string' || value.length === 0) {\n errors.push(\n `InvalidValue: key ${key} should be a non-empty string, received ${\n typeof value === 'string' ? \"''\" : typeof value\n }`\n );\n }\n return;\n } else if (schema === 'object') {\n if (!value || Array.isArray(value) || typeof value !== 'object') {\n errors.push(`InvalidValue: key ${key} should be an object`);\n }\n return;\n } else if (schema === 'boolean') {\n if (typeof value !== 'boolean') {\n errors.push(`InvalidValue: key ${key} should be a boolean, received ${typeof value}`);\n }\n return;\n } else if (schema === 'array') {\n if (!Array.isArray(value)) {\n errors.push(`InvalidValue: key ${key} should be an array, received ${typeof value}`);\n }\n return;\n }\n }\n}\n\nconst IgnoredKeys = new Set<string>([]);\n\nexport function assertValidRequest(\n request: RequestInfo | Context,\n isTopLevel: boolean\n): asserts request is RequestInfo {\n if (DEBUG) {\n // handle basic shape\n if (!request) {\n throw new Error(\n `Expected ${\n isTopLevel ? 'RequestManager.request' : 'next'\n }(<request>) to be called with a request, but none was provided.`\n );\n }\n if (Array.isArray(request) || typeof request !== 'object') {\n throw new Error(\n `The \\`request\\` passed to \\`${\n isTopLevel ? 'RequestManager.request' : 'next'\n }(<request>)\\` should be an object, received \\`${niceTypeOf(request)}\\``\n );\n }\n if (Object.keys(request).length === 0) {\n throw new Error(\n `The \\`request\\` passed to \\`${\n isTopLevel ? 'RequestManager.request' : 'next'\n }(<request>)\\` was empty (\\`{}\\`). Requests need at least one valid key.`\n );\n }\n\n // handle accidentally passing context entirely\n if (request instanceof Context) {\n throw new Error(\n `Expected a request passed to \\`${\n isTopLevel ? 'RequestManager.request' : 'next'\n }(<request>)\\` but received the previous handler's context instead`\n );\n }\n // handle Object.assign({}, context);\n if (isMaybeContext(request)) {\n throw new Error(\n `Expected a request passed to \\`${\n isTopLevel ? 'RequestManager.request' : 'next'\n }(<request>)\\` but received an object with a request key instead.`\n );\n }\n\n // handle schema\n const keys = Object.keys(request) as Array<keyof RequestInfo>;\n const validationErrors: string[] = [];\n const isLegacyRequest = Boolean('op' in request && !request.url);\n keys.forEach((key) => {\n if (isLegacyRequest && key === 'data') {\n return;\n }\n validateKey(key, request[key], validationErrors);\n });\n if (validationErrors.length) {\n const error: Error & { errors: string[] } = new Error(\n `Invalid Request passed to \\`${\n isTopLevel ? 'RequestManager.request' : 'next'\n }(<request>)\\`.\\n\\nThe following issues were found:\\n\\n\\t${validationErrors.join('\\n\\t')}`\n ) as Error & { errors: string[] };\n error.errors = validationErrors;\n throw error;\n }\n }\n}\n","import { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\n\nimport type { RequestKey } from '../../types/identifier';\nimport type { ImmutableHeaders, ImmutableRequestInfo, RequestInfo, ResponseInfo } from '../../types/request';\nimport { SkipCache } from '../../types/request';\nimport { deepFreeze } from './debug';\nimport { createDeferred } from './future';\nimport type { DeferredStream, GodContext } from './types';\n\nexport function upgradeHeaders(headers: Headers | ImmutableHeaders): ImmutableHeaders {\n (headers as ImmutableHeaders).clone = () => {\n return new Headers(headers);\n };\n (headers as ImmutableHeaders).toJSON = () => {\n return Array.from(headers as unknown as Iterable<[string, string]>);\n };\n return headers as ImmutableHeaders;\n}\n\nexport function cloneResponseProperties(response: Response): ResponseInfo {\n const { headers, ok, redirected, status, statusText, type, url } = response;\n upgradeHeaders(headers);\n return {\n headers: headers as ImmutableHeaders,\n ok,\n redirected,\n status,\n statusText,\n type,\n url,\n };\n}\n\nexport class ContextOwner {\n hasSetStream = false;\n hasSetResponse = false;\n hasSubscribers = false;\n stream: DeferredStream = createDeferred<ReadableStream | null>();\n response: ResponseInfo | null = null;\n declare request: ImmutableRequestInfo;\n declare enhancedRequest: ImmutableRequestInfo;\n nextCalled = 0;\n declare god: GodContext;\n declare controller: AbortController;\n declare requestId: number;\n declare isRoot: boolean;\n\n constructor(request: RequestInfo, god: GodContext, isRoot = false) {\n this.isRoot = isRoot;\n this.requestId = god.id;\n this.controller = request.controller || god.controller;\n this.stream.promise.sizeHint = 0;\n\n if (request.controller) {\n if (request.controller !== god.controller) {\n god.controller.signal.addEventListener('abort', () => {\n this.controller.abort(god.controller.signal.reason);\n });\n }\n delete request.controller;\n }\n let enhancedRequest: ImmutableRequestInfo = Object.assign(\n { signal: this.controller.signal },\n request\n ) as ImmutableRequestInfo;\n if (DEBUG) {\n if (!request?.cacheOptions?.[SkipCache]) {\n request = deepFreeze(request);\n enhancedRequest = deepFreeze(enhancedRequest);\n }\n } else {\n if (request.headers) {\n upgradeHeaders(request.headers);\n }\n }\n this.enhancedRequest = enhancedRequest;\n this.request = request as ImmutableRequestInfo;\n this.god = god;\n this.stream.promise = this.stream.promise.then((stream: ReadableStream | null) => {\n if (this.god.stream === stream && this.hasSubscribers) {\n this.god.stream = null;\n }\n return stream;\n });\n }\n\n get hasRequestedStream(): boolean {\n return this.god.hasRequestedStream;\n }\n\n getResponse(): ResponseInfo | null {\n if (this.hasSetResponse) {\n return this.response;\n }\n if (this.nextCalled === 1) {\n return this.god.response;\n }\n return null;\n }\n getStream(): Promise<ReadableStream | null> {\n if (this.isRoot) {\n this.god.hasRequestedStream = true;\n }\n if (!this.hasSetResponse) {\n const hint = this.god.response?.headers?.get('content-length');\n this.stream.promise.sizeHint = hint ? parseInt(hint, 10) : 0;\n }\n this.hasSubscribers = true;\n return this.stream.promise;\n }\n abort(reason: DOMException): void {\n this.controller.abort(reason);\n }\n\n setStream(stream: ReadableStream | Promise<ReadableStream | null> | null): void {\n if (!this.hasSetStream) {\n this.hasSetStream = true;\n\n if (!(stream instanceof Promise)) {\n this.god.stream = stream;\n }\n // @ts-expect-error\n this.stream.resolve(stream);\n }\n }\n\n resolveStream(): void {\n this.setStream(this.nextCalled === 1 ? this.god.stream : null);\n }\n\n setResponse(response: ResponseInfo | Response | null): void {\n if (this.hasSetResponse) {\n if (DEBUG) {\n throw new Error(`Cannot setResponse when a response has already been set`);\n }\n return;\n }\n this.hasSetResponse = true;\n if (response instanceof Response) {\n // TODO potentially avoid cloning in prod\n let responseData = cloneResponseProperties(response);\n\n if (DEBUG) {\n responseData = deepFreeze(responseData);\n }\n this.response = responseData;\n this.god.response = responseData;\n const sizeHint = response.headers?.get('content-length');\n this.stream.promise.sizeHint = sizeHint ? parseInt(sizeHint, 10) : 0;\n } else {\n this.response = response;\n this.god.response = response;\n }\n }\n}\n\n/**\n * The context object given to each {@link Handler} (or {@link CacheHandler})\n * as it processes a request. It exposes the (immutable, enhanced) request\n * along with the methods a handler uses to build up the {@link Future} and\n * {@link StructuredDataDocument} that will ultimately be returned by the\n * {@link RequestManager}.\n *\n * @public\n */\nexport class Context {\n /** @internal */\n declare private ___owner: ContextOwner;\n /**\n * A readonly, immutable version of the request being handled, including\n * any defaults or enhancements applied by the {@link RequestManager}.\n *\n * @public\n */\n declare request: ImmutableRequestInfo;\n /**\n * The id of this request as assigned by the {@link RequestManager}. Not\n * unique across manager instances.\n *\n * @public\n */\n declare id: number;\n /** @internal */\n declare private _isCacheHandler: boolean;\n /** @internal */\n declare private _finalized: boolean;\n\n constructor(owner: ContextOwner, isCacheHandler: boolean) {\n this.id = owner.requestId;\n this.___owner = owner;\n this.request = owner.enhancedRequest;\n this._isCacheHandler = isCacheHandler;\n this._finalized = false;\n }\n /**\n * Set the response stream for this request. May be called at most once,\n * and may be called at any point up until the handler's `request` method\n * resolves.\n *\n * @public\n */\n setStream(stream: ReadableStream | Promise<ReadableStream | null>): void {\n this.___owner.setStream(stream);\n }\n /**\n * Set the {@link ResponseInfo} (or raw `Response`) associated with this\n * request. Used to populate the response information available on the\n * resulting {@link StructuredDataDocument}.\n *\n * @public\n */\n setResponse(response: ResponseInfo | Response | null): void {\n this.___owner.setResponse(response);\n }\n\n /**\n * Associate a {@link RequestKey} with this request. May only be called\n * synchronously from a {@link CacheHandler}.\n *\n * @public\n */\n setIdentifier(identifier: RequestKey): void {\n assert(\n `setIdentifier may only be used synchronously from a CacheHandler`,\n identifier && this._isCacheHandler && !this._finalized\n );\n this.___owner.god.identifier = identifier;\n }\n\n /**\n * Whether the application (or a downstream handler) has requested access\n * to the response stream via {@link Future.getStream}. Handlers can use\n * this to avoid the cost of streaming when nothing will consume it.\n *\n * @public\n */\n get hasRequestedStream(): boolean {\n return this.___owner.hasRequestedStream;\n }\n\n /** @private */\n _finalize(): void {\n this._finalized = true;\n }\n}\nexport type HandlerRequestContext = Context;\n","import { getOrSetUniversal } from '../../types/-private';\n\nexport type CacheResult<T = unknown, E = unknown> = { isError: true; result: E } | { isError: false; result: T };\n\n/**\n * The minimal, structural subset of the `Promise` interface required to be\n * cached and inspected by {@link setPromiseResult} / {@link getPromiseResult}\n * (and by `getPromiseState`). Anything that is at least `then`/`catch`/`finally`\n * \"shaped\" (including a real `Promise` or {@link Future}) satisfies this.\n *\n * @public\n */\nexport type Awaitable<T = unknown, E = unknown> = {\n /**\n * Registers fulfillment/rejection handlers, `Promise.prototype.then`-style.\n *\n * @public\n */\n then: (onFulfilled: (value: T) => unknown, onRejected: (reason: E) => unknown) => unknown;\n /**\n * Registers a rejection handler, `Promise.prototype.catch`-style.\n *\n * @public\n */\n catch: (onRejected: (reason: E) => unknown) => unknown;\n /**\n * Registers a handler run on settlement, `Promise.prototype.finally`-style.\n *\n * @public\n */\n finally: (onFinally: () => unknown) => unknown;\n};\n\nexport const PromiseCache: WeakMap<Awaitable, CacheResult> = getOrSetUniversal(\n 'PromiseCache',\n new WeakMap<Awaitable, CacheResult>()\n);\nexport const RequestMap: Map<number, CacheResult> = getOrSetUniversal('RequestMap', new Map<number, CacheResult>());\n\nexport function setRequestResult(requestId: number, result: CacheResult): void {\n RequestMap.set(requestId, result);\n}\nexport function clearRequestResult(requestId: number): void {\n RequestMap.delete(requestId);\n}\nexport function getRequestResult(requestId: number): CacheResult | undefined {\n return RequestMap.get(requestId);\n}\n\n/**\n * Cache the settled result (or error) of a promise-like value so that its\n * outcome can be synchronously read later via {@link getPromiseResult},\n * without needing to await it again.\n *\n * @public\n */\nexport function setPromiseResult(promise: Promise<unknown> | Awaitable, result: CacheResult): void {\n PromiseCache.set(promise, result);\n}\n\n/**\n * Synchronously read the settled result (or error) previously recorded for\n * a promise-like value via {@link setPromiseResult}, if any.\n *\n * @public\n */\nexport function getPromiseResult<T, E>(promise: Promise<T> | Awaitable<T, E>): CacheResult<T, E> | undefined {\n return PromiseCache.get(promise) as CacheResult<T, E> | undefined;\n}\n","import { DEBUG } from '@warp-drive/core/build-config/env';\n\nimport { getOrSetGlobal } from '../../types/-private';\nimport type {\n RequestInfo,\n StructuredDataDocument,\n StructuredDocument,\n StructuredErrorDocument,\n} from '../../types/request';\nimport { STRUCTURED } from '../../types/request';\nimport { Context, ContextOwner } from './context';\nimport { assertValidRequest } from './debug';\n// oxlint-disable-next-line no-unused-vars\nimport type { Fetch } from './fetch.ts';\nimport { createFuture, isFuture } from './future';\nimport { setRequestResult } from './promise-cache';\nimport type { DeferredFuture, Future, GodContext, Handler } from './types';\n\nexport const IS_CACHE_HANDLER: '___(unique) Symbol(IS_CACHE_HANDLER)' = getOrSetGlobal(\n 'IS_CACHE_HANDLER',\n Symbol('IS_CACHE_HANDLER')\n);\n\n/**\n * A ponyfill for the global {@link DOMException} constructor.\n *\n * Some non-DOM environments (e.g. React Native, some Node/worker\n * environments) don't provide `DOMException` as a global, which would\n * otherwise throw a `ReferenceError` the first time any code referenced it\n * (for instance when classifying an abort/network error). `DOMError` falls\n * back to the global {@link Error} constructor in that case so callers can\n * uniformly use `new DOMError(...)` / `error instanceof DOMError` without\n * guarding for the global's presence themselves.\n *\n * @internal\n */\nexport const DOMError: typeof DOMException =\n typeof DOMException !== 'undefined' ? DOMException : (Error as unknown as typeof DOMException);\nexport function curryFuture<T>(owner: ContextOwner, inbound: Future<T>, outbound: DeferredFuture<T>): Future<T> {\n owner.setStream(inbound.getStream());\n\n inbound.then(\n (doc: StructuredDataDocument<T>) => {\n const document = {\n [STRUCTURED]: true as const,\n request: owner.request,\n response: doc.response,\n content: doc.content,\n };\n outbound.resolve(document);\n },\n (error: Error & StructuredErrorDocument) => {\n if (isDoc(error)) {\n owner.setStream(owner.god.stream);\n }\n if (!error || !(error instanceof Error)) {\n try {\n throw new Error(error ? error : `Request Rejected with an Unknown Error`);\n } catch (e: unknown) {\n if (error && typeof error === 'object') {\n Object.assign(e as Error, error);\n (e as Error & StructuredErrorDocument).message =\n (error as Error).message || `Request Rejected with an Unknown Error`;\n }\n error = e as Error & StructuredErrorDocument;\n }\n }\n\n error[STRUCTURED] = true;\n error.request = owner.request;\n error.response = owner.getResponse();\n error.error = error.error || error.message;\n\n outbound.reject(error);\n }\n );\n return outbound.promise;\n}\n\nfunction isDoc<T>(doc: T | StructuredDataDocument<T>): doc is StructuredDataDocument<T> {\n return doc && (doc as StructuredDataDocument<T>)[STRUCTURED] === true;\n}\n\nfunction ensureDoc<T>(owner: ContextOwner, content: T | Error, isError: boolean): StructuredDocument<T> {\n if (isDoc(content)) {\n return content as StructuredDocument<T>;\n }\n\n if (isError) {\n return {\n [STRUCTURED]: true,\n request: owner.request,\n response: owner.getResponse(),\n error: content as Error,\n } as StructuredErrorDocument<T>;\n }\n\n return {\n [STRUCTURED]: true,\n request: owner.request,\n response: owner.getResponse(),\n content: content as T,\n };\n}\n\n/**\n * Additional properties exposed on errors thrown by the\n * {@link Fetch | Fetch Handler}.\n *\n * In the case of an Abort or system/browser level issue,\n * this extends {@link DOMException}.\n *\n * Else it extends from {@link AggregateError} if the\n * response includes an array of errors, falling back\n * to {@link Error} as its base.\n */\nexport interface FetchError extends DOMException {\n /**\n * Alias for {@link FetchError.status | status}.\n *\n * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status)\n */\n code: number;\n /**\n * The name associated to the {@link FetchError.status | status code}.\n *\n * Typically this will be of the formula `StatusTextError` for instance\n * a 404 status with status text of `Not Found` would have the name\n * `NotFoundError`.\n */\n name: string;\n /**\n * The http status code associated to the returned error.\n *\n * Browser/System level network errors will often have an error code of `0` or `5`.\n * Aborted requests will have an error code of `20`.\n *\n * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status)\n */\n status: number;\n /**\n * The Status Text associated to the {@link FetchError.status | status code}\n * for the error.\n *\n * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText)\n *\n */\n statusText: string;\n /**\n * A property signifying that an Error uses the {@link FetchError}\n * interface.\n */\n isRequestError: true;\n}\n\nexport function enhanceReason(reason?: string): DOMException {\n const error = new DOMError(reason || 'The user aborted a request.', 'AbortError');\n // `DOMError` may be the `Error` constructor as a fallback, whose\n // constructor doesn't accept a `name`, so set it explicitly in that case.\n // We can't unconditionally assign `error.name` here: when `DOMError` is\n // the real `DOMException`, `name` is already `'AbortError'` (set by its\n // constructor) *and* `DOMException.prototype.name` is a getter-only\n // accessor with no setter, so reassigning it throws a `TypeError` in\n // strict-mode JS (which is how our ES modules run) - even when assigning\n // the very same value it already holds.\n if (error.name !== 'AbortError') {\n (error as unknown as { name: string }).name = 'AbortError';\n }\n return error;\n}\n\nexport function handleOutcome<T>(\n owner: ContextOwner,\n inbound: Promise<T | StructuredDataDocument<T>>,\n outbound: DeferredFuture<T>\n): Future<T> {\n inbound.then(\n (content: T | StructuredDataDocument<T>) => {\n if (owner.controller.signal.aborted) {\n // the next function did not respect the signal, we handle it here\n outbound.reject(enhanceReason(owner.controller.signal.reason as string));\n return;\n }\n if (isDoc(content)) {\n owner.setStream(owner.god.stream);\n content = content.content;\n }\n const document = {\n [STRUCTURED]: true as const,\n request: owner.request,\n response: owner.getResponse(),\n content,\n };\n outbound.resolve(document);\n },\n (error: Error & StructuredErrorDocument) => {\n if (isDoc(error)) {\n owner.setStream(owner.god.stream);\n }\n if (!error || !(error instanceof Error)) {\n try {\n throw new Error(error ? error : `Request Rejected with an Unknown Error`);\n } catch (e: unknown) {\n if (error && typeof error === 'object') {\n Object.assign(e as Error, error);\n (e as Error & StructuredErrorDocument).message =\n (error as Error).message || `Request Rejected with an Unknown Error`;\n }\n error = e as Error & StructuredErrorDocument;\n }\n }\n\n error[STRUCTURED] = true;\n error.request = owner.request;\n error.response = owner.getResponse();\n error.error = error.error || error.message;\n outbound.reject(error);\n }\n );\n return outbound.promise;\n}\n\nfunction isCacheHandler(handler: Handler & { [IS_CACHE_HANDLER]?: boolean }, index: number): boolean {\n return index === 0 && Boolean(handler[IS_CACHE_HANDLER]);\n}\n\nexport function executeNextHandler<T>(\n wares: Readonly<Handler[]>,\n request: RequestInfo,\n i: number,\n god: GodContext\n): Future<T> {\n if (DEBUG) {\n if (i === wares.length) {\n throw new Error(`No handler was able to handle this request.`);\n }\n assertValidRequest(request, false);\n }\n const owner = new ContextOwner(request, god, i === 0);\n\n function next(r: RequestInfo): Future<T> {\n owner.nextCalled++;\n return executeNextHandler(wares, r, i + 1, god);\n }\n\n const _isCacheHandler = isCacheHandler(wares[i], i);\n const context = new Context(owner, _isCacheHandler);\n let outcome: Promise<T | StructuredDataDocument<T>> | Future<T>;\n try {\n outcome = wares[i].request<T>(context, next);\n if (_isCacheHandler) {\n context._finalize();\n }\n if (!!outcome && _isCacheHandler) {\n if (!(outcome instanceof Promise)) {\n setRequestResult(owner.requestId, { isError: false, result: ensureDoc(owner, outcome, false) });\n outcome = Promise.resolve(outcome);\n }\n } else if (DEBUG) {\n if (!outcome || (!(outcome instanceof Promise) && !(typeof outcome === 'object' && 'then' in outcome))) {\n // oxlint-disable-next-line no-console\n console.log({ request, handler: wares[i], outcome });\n if (outcome === undefined) {\n throw new Error(`Expected handler.request to return a promise, instead received undefined.`);\n }\n throw new Error(`Expected handler.request to return a promise, instead received a synchronous value.`);\n }\n }\n } catch (e) {\n if (_isCacheHandler) {\n setRequestResult(owner.requestId, { isError: true, result: ensureDoc(owner, e, true) });\n }\n // oxlint-disable-next-line typescript/prefer-promise-reject-errors\n outcome = Promise.reject<StructuredDataDocument<T>>(e);\n }\n const future = createFuture<T>(owner);\n\n if (isFuture<T>(outcome)) {\n return curryFuture(owner, outcome, future);\n }\n\n return handleOutcome(owner, outcome, future);\n}\n","import { DEBUG } from '@warp-drive/build-config/env';\n\nimport { IS_FUTURE, type StructuredDocument } from '../../types/request';\nimport type { ContextOwner } from './context';\nimport type { Deferred, DeferredFuture, Future } from './types';\nimport { enhanceReason } from './utils';\n\nexport function isFuture<T>(maybe: unknown): maybe is Future<T> {\n return Boolean(maybe && maybe instanceof Promise && (maybe as Future<T>)[IS_FUTURE] === true);\n}\n\n/**\n * Create a {@link Deferred}: a promise along with the `resolve`/`reject`\n * callbacks that settle it, so the promise can be handed out before the\n * work that will settle it has started.\n *\n * @public\n */\nexport function createDeferred<T>(): Deferred<T> {\n let resolve!: (v: T) => void;\n let reject!: (v: unknown) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { resolve, reject, promise };\n}\n\nexport function upgradePromise<T>(promise: Promise<StructuredDocument<T>>, future: Future<T>): Future<T> {\n (promise as Future<T>)[IS_FUTURE] = true;\n // oxlint-disable-next-line typescript/unbound-method\n (promise as Future<T>).getStream = future.getStream;\n // oxlint-disable-next-line typescript/unbound-method\n (promise as Future<T>).abort = future.abort;\n // oxlint-disable-next-line typescript/unbound-method\n (promise as Future<T>).onFinalize = future.onFinalize;\n (promise as Future<T>).id = future.id;\n (promise as Future<T>).lid = future.lid;\n (promise as Future<T>).requester = future.requester;\n\n if (DEBUG) {\n // @ts-expect-error\n promise.toJSON = () => {\n const id = 'Future<' + (promise as Future<T>).id + '>';\n if ((promise as Future<T>).lid) {\n return `${id} (${(promise as Future<T>).lid!.lid})`;\n }\n return id;\n };\n }\n\n return promise as Future<T>;\n}\n\nexport function createFuture<T>(owner: ContextOwner): DeferredFuture<T> {\n const deferred = createDeferred<T>() as unknown as DeferredFuture<T>;\n let { promise } = deferred;\n let cbs: Array<() => void> | undefined;\n promise = promise.finally(() => {\n owner.resolveStream();\n if (cbs) {\n cbs.forEach((cb) => cb());\n }\n }) as Future<T>;\n promise.onFinalize = (fn: () => void) => {\n cbs = cbs || [];\n cbs.push(fn);\n };\n promise[IS_FUTURE] = true;\n promise.getStream = () => {\n return owner.getStream();\n };\n promise.abort = (reason?: string) => {\n owner.abort(enhanceReason(reason));\n };\n promise.id = owner.requestId;\n promise.lid = owner.god.identifier;\n promise.requester = owner.god.requester;\n\n if (DEBUG) {\n // @ts-expect-error\n promise.toJSON = () => {\n const id = 'Future<' + promise.id + '>';\n if (promise.lid) {\n return `${id} (${promise.lid.lid})`;\n }\n return id;\n };\n }\n\n deferred.promise = promise;\n return deferred;\n}\n","import type { ReactiveDataDocument } from './reactive.ts';\nimport type { RequestInfo } from './types/request.ts';\nimport type { RequestSignature } from './types/symbols.ts';\n\nexport { createDeferred } from './request/-private/future.ts';\nexport type {\n Future,\n Handler,\n CacheHandler,\n NextFn,\n Deferred,\n ManagedRequestPriority,\n} from './request/-private/types.ts';\nexport { setPromiseResult, getPromiseResult } from './request/-private/promise-cache.ts';\nexport type { Awaitable } from './request/-private/promise-cache.ts';\nexport type { Context } from './request/-private/context.ts';\n\n/**\n * Brands the supplied object with the supplied response type.\n *\n * ```ts\n * import type { ReactiveDataDocument } from '@warp-drive/core/reactive';\n * import { withResponseType } from '@warp-drive/core/request';\n * import type { User } from '#/data/user.ts'\n *\n * const result = await store.request(\n * withResponseType<ReactiveDataDocument<User>>({ url: '/users/1' })\n * );\n *\n * result.content.data; // will have type User\n * ```\n *\n */\nexport function withResponseType<T>(obj: RequestInfo): RequestInfo<T> & {\n /** The branded response type. Present only at the type level; carries no runtime value. */\n [RequestSignature]: T;\n} {\n return obj as RequestInfo<T> & {\n [RequestSignature]: T;\n };\n}\n\n/**\n * Brands the supplied object with the supplied response type\n * wrapped in {@link ReactiveDataDocument}. This is a convenience for\n * the common case of using {@link withResponseType} with `ReactiveDataDocument`.\n *\n * ```ts\n * import { withReactiveResponse } from '@warp-drive/core/request';\n * import type { User } from '#/data/user.ts'\n *\n * const result = await store.request(\n * withReactiveResponse<User>({ url: '/users/1' })\n * );\n *\n * result.content.data; // will have type User\n * ```\n *\n * @public\n */\nexport function withReactiveResponse<T>(obj: RequestInfo): RequestInfo<ReactiveDataDocument<T>> & {\n /** The branded response type. Present only at the type level; carries no runtime value. */\n [RequestSignature]: ReactiveDataDocument<T>;\n} {\n return obj as RequestInfo<ReactiveDataDocument<T>> & {\n [RequestSignature]: ReactiveDataDocument<T>;\n };\n}\n\n/**\n * @deprecated use {@link withResponseType} instead\n */\nexport const withBrand: typeof withResponseType = withResponseType;\n"],"mappings":";;;;;;AAOA,MAAMM,aAAa;CACjBC,MAAM;CACNC,OAAO;EAAC;EAAQ;EAAe;EAAc;EAAY;EAAY;EAAmB;CAAgB;AAC1G;AACA,MAAMC,4BAAY,IAAIC,IAAmD;CACvE,CAAC,UAAU,CAAC,MAAM,CAAC;CACnB,CAAC,WAAW,OAAO;CACnB,CAAC,QAAQ,MAAM;CACf,CAAC,QAAQJ,UAAU;CACnB,CAAC,qBAAqB,SAAS;CAC/B,CAAC,WAAW,QAAQ;CACpB,CAAC,gBAAgB,QAAQ;CACzB,CAAC,YAAY;EAAC;EAAQ;EAAO;CAAM,CAAC;CACpC,CAAC,MAAM,QAAQ;CACf,CAAC,SAAS,QAAQ;CAClB,CAAC,OAAO,QAAQ;CAChB,CAAC,SAAS;EAAC;EAAW;EAAe;EAAY;EAAY;EAAkB;CAAQ,CAAC;CACxF,CAAC,eAAe;EAAC;EAAW;EAAQ;CAAa,CAAC;CAClD,CACE,eACA;EACE;EAC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,UAAU;CACzB;CACAL,QAAQM,SAASmB,WAAoB;EACnCT,MAAMV,MAAMhB,cAAcmC,MAAM,CAAC;CACnC;CACAzB,QAAQQ,KAAKQ,MAAMU;CACnB1B,QAAQS,MAAMO,MAAMW,IAAIC;CACxB5B,QAAQU,YAAYM,MAAMW,IAAIjB;CAE9B,IAAAlB,eAAAD,gBAAA,CAAA,CAAAoB,UAAAC,IAAAC,KAAA,GAEEb,QAAQc,eAAe;EACrB,MAAMN,KAAK,YAAYR,QAAQQ,KAAK;EACpC,IAAIR,QAAQS,KACV,OAAO,GAAGD,GAAE,IAAKR,QAAQS,IAAIA,IAAG;EAElC,OAAOD;CACT;CAGFS,SAASjB,UAAUA;CACnB,OAAOiB;AACT;;;;;;;;;;;;;;;;;;;;AC3DA,SAAgBe,iBAAoBC,KAGlC;CACA,OAAOA;AAGT;;;;;;;;;;;;;;;;;;;AAoBA,SAAgBC,qBAAwBD,KAGtC;CACA,OAAOA;AAGT;;;;AAKA,MAAaE,YAAqCH"}
1
+ {"version":3,"file":"request-DZVW74wn.js","names":["getOrSetGlobal","CACHE_OWNER","Context","upgradeHeaders","getGlobalConfig","macroCondition","BODY_TYPES","type","klass","ValidKeys","Map","IS_FROZEN","Symbol","IS_COLLECTION","for","freezeHeaders","headers","delete","set","append","Error","deepFreeze","value","_type","_niceType","niceTypeOf","arr","map","Object","freeze","keys","forEach","key","isMaybeContext","request","length","v","Array","isArray","Date","Set","ReadableStream","WritableStream","TransformStream","Headers","constructor","name","validateKey","errors","schema","get","IgnoredKeys","has","push","includes","join","JSON","stringify","e","message","k","String","assertValidRequest","isTopLevel","WarpDrive","env","DEBUG","validationErrors","isLegacyRequest","Boolean","url","error","SkipCache","deepFreeze","createDeferred","getGlobalConfig","macroCondition","upgradeHeaders","headers","clone","Headers","toJSON","Array","from","cloneResponseProperties","response","ok","redirected","status","statusText","type","url","ContextOwner","hasSetStream","hasSetResponse","hasSubscribers","stream","nextCalled","constructor","request","god","isRoot","requestId","id","controller","promise","sizeHint","signal","addEventListener","abort","reason","enhancedRequest","Object","assign","WarpDrive","env","DEBUG","cacheOptions","then","hasRequestedStream","getResponse","getStream","hint","get","parseInt","setStream","Promise","resolve","resolveStream","setResponse","Error","Response","responseData","Context","owner","isCacheHandler","___owner","_isCacheHandler","_finalized","setIdentifier","identifier","test","_finalize","getOrSetUniversal","PromiseCache","WeakMap","RequestMap","Map","setRequestResult","requestId","result","set","clearRequestResult","delete","getRequestResult","get","setPromiseResult","promise","getPromiseResult","getOrSetGlobal","STRUCTURED","Context","ContextOwner","assertValidRequest","createFuture","isFuture","setRequestResult","getGlobalConfig","macroCondition","IS_CACHE_HANDLER","Symbol","DOMError","DOMException","Error","curryFuture","owner","inbound","outbound","setStream","getStream","then","doc","document","request","response","content","resolve","error","isDoc","god","stream","e","Object","assign","message","getResponse","reject","promise","ensureDoc","isError","enhanceReason","reason","name","handleOutcome","controller","signal","aborted","isCacheHandler","handler","index","Boolean","executeNextHandler","wares","i","WarpDrive","env","DEBUG","length","next","r","nextCalled","_isCacheHandler","context","outcome","_finalize","Promise","requestId","result","console","log","undefined","future","IS_FUTURE","enhanceReason","getGlobalConfig","macroCondition","isFuture","maybe","Boolean","Promise","createDeferred","resolve","reject","promise","res","rej","upgradePromise","future","getStream","abort","onFinalize","id","lid","requester","WarpDrive","env","DEBUG","toJSON","createFuture","owner","deferred","cbs","finally","resolveStream","forEach","cb","fn","push","reason","requestId","god","identifier","createDeferred","setPromiseResult","getPromiseResult","withResponseType","obj","withReactiveResponse","withBrand"],"sources":["../src/request/-private/debug.ts","../src/request/-private/context.ts","../src/request/-private/promise-cache.ts","../src/request/-private/utils.ts","../src/request/-private/future.ts","../src/request.ts"],"sourcesContent":["import { DEBUG } from '@warp-drive/core/build-config/env';\n\nimport { getOrSetGlobal } from '../../types/-private';\nimport { CACHE_OWNER } from '../../types/identifier';\nimport type { ImmutableHeaders, RequestInfo } from '../../types/request';\nimport { Context, upgradeHeaders } from './context';\n\nconst BODY_TYPES = {\n type: 'string',\n klass: ['Blob', 'ArrayBuffer', 'TypedArray', 'DataView', 'FormData', 'URLSearchParams', 'ReadableStream'],\n};\nconst ValidKeys = new Map<string, string | string[] | typeof BODY_TYPES>([\n ['duplex', ['half']],\n ['records', 'array'],\n ['data', 'json'],\n ['body', BODY_TYPES],\n ['disableTestWaiter', 'boolean'],\n ['options', 'object'],\n ['cacheOptions', 'object'],\n ['priority', ['high', 'low', 'auto']],\n ['op', 'string'],\n ['store', 'object'],\n ['url', 'string'],\n ['cache', ['default', 'force-cache', 'no-cache', 'no-store', 'only-if-cached', 'reload']],\n ['credentials', ['include', 'omit', 'same-origin']],\n [\n 'destination',\n [\n '',\n 'object',\n 'audio',\n 'audioworklet',\n 'document',\n 'embed',\n 'font',\n 'frame',\n 'iframe',\n 'image',\n 'manifest',\n 'paintworklet',\n 'report',\n 'script',\n 'sharedworker',\n 'style',\n 'track',\n 'video',\n 'worker',\n 'xslt',\n ],\n ],\n ['headers', 'headers'],\n ['integrity', 'string'],\n ['keepalive', 'boolean'],\n ['method', ['QUERY', 'GET', 'PUT', 'PATCH', 'DELETE', 'POST', 'OPTIONS', 'HEAD', 'CONNECT', 'TRACE']],\n ['mode', ['same-origin', 'cors', 'navigate', 'no-cors']],\n ['redirect', ['error', 'follow', 'manual']],\n ['referrer', 'string'],\n ['signal', 'AbortSignal'],\n ['controller', 'AbortController'],\n [\n 'referrerPolicy',\n [\n '',\n 'same-origin',\n 'no-referrer',\n 'no-referrer-when-downgrade',\n 'origin',\n 'origin-when-cross-origin',\n 'strict-origin',\n 'strict-origin-when-cross-origin',\n 'unsafe-url',\n ],\n ],\n]);\n\nconst IS_FROZEN = getOrSetGlobal('IS_FROZEN', Symbol('FROZEN'));\nconst IS_COLLECTION = getOrSetGlobal('IS_COLLECTION', Symbol.for('Collection'));\n\nfunction freezeHeaders(headers: Headers | ImmutableHeaders): ImmutableHeaders {\n headers.delete =\n headers.set =\n headers.append =\n () => {\n throw new Error(`Cannot Mutate Immutatable Headers, use headers.clone to get a copy`);\n };\n upgradeHeaders(headers);\n return headers as ImmutableHeaders;\n}\n\nexport function deepFreeze<T = unknown>(value: T): T {\n if (value && (value as { [IS_FROZEN]?: true })[IS_FROZEN]) {\n return value;\n }\n const _type = typeof value;\n switch (_type) {\n case 'boolean':\n case 'string':\n case 'number':\n case 'symbol':\n case 'undefined':\n case 'bigint':\n return value;\n case 'function':\n throw new Error(`Cannot deep-freeze a function`);\n case 'object': {\n const _niceType = niceTypeOf(value);\n switch (_niceType) {\n case 'array': {\n if ((value as unknown[] & { [IS_COLLECTION]?: true })[IS_COLLECTION]) {\n return value;\n }\n const arr = (value as unknown[]).map(deepFreeze);\n arr[IS_FROZEN as unknown as number] = true;\n return Object.freeze(arr) as T;\n }\n case 'null':\n return value;\n case 'object':\n Object.keys(value as Record<string, unknown>).forEach((key) => {\n try {\n (value as Record<string, unknown>)[key] = deepFreeze((value as Record<string, unknown>)[key]);\n } catch {\n // continue\n }\n });\n (value as Record<string | symbol, unknown>)[IS_FROZEN] = true;\n return Object.freeze(value);\n case 'headers':\n return freezeHeaders(value as Headers) as T;\n case 'Collection':\n case 'Store':\n case 'AbortSignal':\n case 'identifier':\n return value;\n case 'date':\n case 'map':\n case 'set':\n case 'error':\n case 'stream':\n default:\n // console.log(`Cannot deep-freeze ${_niceType}`);\n return value;\n }\n }\n }\n}\n\nfunction isMaybeContext(request: unknown) {\n if (request && typeof request === 'object') {\n const keys = Object.keys(request);\n if (keys.length === 1 && keys[0] === 'request') {\n return true;\n }\n }\n return false;\n}\n\nfunction niceTypeOf(v: unknown) {\n if (v === null) {\n return 'null';\n }\n if (typeof v === 'string') {\n return v ? 'non-empty-string' : 'empty-string';\n }\n if (!v) {\n return typeof v;\n }\n if (Array.isArray(v)) {\n return 'array';\n }\n if (v instanceof Date) {\n return 'date';\n }\n if (v instanceof Map) {\n return 'map';\n }\n if (v instanceof Set) {\n return 'set';\n }\n if (v instanceof Error) {\n return 'error';\n }\n if (v instanceof ReadableStream || v instanceof WritableStream || v instanceof TransformStream) {\n return 'stream';\n }\n if (v instanceof Headers) {\n return 'headers';\n }\n // ResourceKey/RequestKey identifiers are owned by the store's identity cache and must\n // remain mutable (e.g. `.id` is assigned once the server confirms it); deep-freezing a\n // request's `record`/`data` reference to one would freeze the store's live identifier,\n // not a copy of it.\n if (typeof v === 'object' && CACHE_OWNER in v) {\n return 'identifier';\n }\n if (typeof v === 'object' && v.constructor && v.constructor.name !== 'Object') {\n return v.constructor.name;\n }\n return typeof v;\n}\n\nfunction validateKey(key: string, value: unknown, errors: string[]) {\n const schema = ValidKeys.get(key);\n if (!schema && !IgnoredKeys.has(key)) {\n errors.push(`InvalidKey: '${key}'`);\n return;\n }\n if (schema) {\n if (schema === BODY_TYPES) {\n if (typeof value === 'string' || value instanceof ReadableStream) {\n return;\n }\n const type = niceTypeOf(value);\n if (schema.klass.includes(type)) {\n return;\n }\n errors.push(\n `InvalidValue: key 'body' should be a string or one of '${schema.klass.join(\"', '\")}', received ${\n '<a value of type ' + niceTypeOf(value) + '>'\n }`\n );\n return;\n }\n if (Array.isArray(schema)) {\n if (!schema.includes(value as string)) {\n errors.push(\n `InvalidValue: key ${key} should be one of '${schema.join(\"', '\")}', received ${\n typeof value === 'string' ? value : '<a value of type ' + niceTypeOf(value) + '>'\n }`\n );\n }\n return;\n } else if (schema === 'json') {\n try {\n JSON.stringify(value);\n } catch (e) {\n errors.push(\n `InvalidValue: key ${key} should be a JSON serializable value, but failed to serialize with Error - ${\n (e as Error).message\n }`\n );\n }\n return;\n } else if (schema === 'headers') {\n if (!(value instanceof Headers)) {\n errors.push(`InvalidValue: key ${key} should be an instance of Headers, received ${niceTypeOf(value)}`);\n }\n return;\n } else if (schema === 'record') {\n const _type = typeof value;\n // record must extend plain object or Object.create(null)\n if (!value || _type !== 'object' || (value.constructor && value.constructor !== Object)) {\n errors.push(\n `InvalidValue: key ${key} should be a dictionary of string keys to string values, received ${niceTypeOf(\n value\n )}`\n );\n return;\n }\n const keys = Object.keys(value);\n keys.forEach((k) => {\n const v: unknown = (value as Record<string, unknown>)[k];\n if (typeof k !== 'string') {\n errors.push(`\\tThe key ${String(k)} on ${key} should be a string key`);\n } else if (typeof v !== 'string') {\n errors.push(`\\tThe value of ${key}.${k} should be a string not ${niceTypeOf(v)}`);\n }\n });\n return;\n } else if (schema === 'string') {\n if (typeof value !== 'string' || value.length === 0) {\n errors.push(\n `InvalidValue: key ${key} should be a non-empty string, received ${\n typeof value === 'string' ? \"''\" : typeof value\n }`\n );\n }\n return;\n } else if (schema === 'object') {\n if (!value || Array.isArray(value) || typeof value !== 'object') {\n errors.push(`InvalidValue: key ${key} should be an object`);\n }\n return;\n } else if (schema === 'boolean') {\n if (typeof value !== 'boolean') {\n errors.push(`InvalidValue: key ${key} should be a boolean, received ${typeof value}`);\n }\n return;\n } else if (schema === 'array') {\n if (!Array.isArray(value)) {\n errors.push(`InvalidValue: key ${key} should be an array, received ${typeof value}`);\n }\n return;\n }\n }\n}\n\nconst IgnoredKeys = new Set<string>([]);\n\nexport function assertValidRequest(\n request: RequestInfo | Context,\n isTopLevel: boolean\n): asserts request is RequestInfo {\n if (DEBUG) {\n // handle basic shape\n if (!request) {\n throw new Error(\n `Expected ${\n isTopLevel ? 'RequestManager.request' : 'next'\n }(<request>) to be called with a request, but none was provided.`\n );\n }\n if (Array.isArray(request) || typeof request !== 'object') {\n throw new Error(\n `The \\`request\\` passed to \\`${\n isTopLevel ? 'RequestManager.request' : 'next'\n }(<request>)\\` should be an object, received \\`${niceTypeOf(request)}\\``\n );\n }\n if (Object.keys(request).length === 0) {\n throw new Error(\n `The \\`request\\` passed to \\`${\n isTopLevel ? 'RequestManager.request' : 'next'\n }(<request>)\\` was empty (\\`{}\\`). Requests need at least one valid key.`\n );\n }\n\n // handle accidentally passing context entirely\n if (request instanceof Context) {\n throw new Error(\n `Expected a request passed to \\`${\n isTopLevel ? 'RequestManager.request' : 'next'\n }(<request>)\\` but received the previous handler's context instead`\n );\n }\n // handle Object.assign({}, context);\n if (isMaybeContext(request)) {\n throw new Error(\n `Expected a request passed to \\`${\n isTopLevel ? 'RequestManager.request' : 'next'\n }(<request>)\\` but received an object with a request key instead.`\n );\n }\n\n // handle schema\n const keys = Object.keys(request) as Array<keyof RequestInfo>;\n const validationErrors: string[] = [];\n const isLegacyRequest = Boolean('op' in request && !request.url);\n keys.forEach((key) => {\n if (isLegacyRequest && key === 'data') {\n return;\n }\n validateKey(key, request[key], validationErrors);\n });\n if (validationErrors.length) {\n const error: Error & { errors: string[] } = new Error(\n `Invalid Request passed to \\`${\n isTopLevel ? 'RequestManager.request' : 'next'\n }(<request>)\\`.\\n\\nThe following issues were found:\\n\\n\\t${validationErrors.join('\\n\\t')}`\n ) as Error & { errors: string[] };\n error.errors = validationErrors;\n throw error;\n }\n }\n}\n","import { DEBUG } from '@warp-drive/core/build-config/env';\nimport { assert } from '@warp-drive/core/build-config/macros';\n\nimport type { RequestKey } from '../../types/identifier';\nimport type { ImmutableHeaders, ImmutableRequestInfo, RequestInfo, ResponseInfo } from '../../types/request';\nimport { SkipCache } from '../../types/request';\nimport { deepFreeze } from './debug';\nimport { createDeferred } from './future';\nimport type { DeferredStream, GodContext } from './types';\n\nexport function upgradeHeaders(headers: Headers | ImmutableHeaders): ImmutableHeaders {\n (headers as ImmutableHeaders).clone = () => {\n return new Headers(headers);\n };\n (headers as ImmutableHeaders).toJSON = () => {\n return Array.from(headers as unknown as Iterable<[string, string]>);\n };\n return headers as ImmutableHeaders;\n}\n\nexport function cloneResponseProperties(response: Response): ResponseInfo {\n const { headers, ok, redirected, status, statusText, type, url } = response;\n upgradeHeaders(headers);\n return {\n headers: headers as ImmutableHeaders,\n ok,\n redirected,\n status,\n statusText,\n type,\n url,\n };\n}\n\nexport class ContextOwner {\n hasSetStream = false;\n hasSetResponse = false;\n hasSubscribers = false;\n stream: DeferredStream = createDeferred<ReadableStream | null>();\n response: ResponseInfo | null = null;\n declare request: ImmutableRequestInfo;\n declare enhancedRequest: ImmutableRequestInfo;\n nextCalled = 0;\n declare god: GodContext;\n declare controller: AbortController;\n declare requestId: number;\n declare isRoot: boolean;\n\n constructor(request: RequestInfo, god: GodContext, isRoot = false) {\n this.isRoot = isRoot;\n this.requestId = god.id;\n this.controller = request.controller || god.controller;\n this.stream.promise.sizeHint = 0;\n\n if (request.controller) {\n if (request.controller !== god.controller) {\n god.controller.signal.addEventListener('abort', () => {\n this.controller.abort(god.controller.signal.reason);\n });\n }\n delete request.controller;\n }\n let enhancedRequest: ImmutableRequestInfo = Object.assign(\n { signal: this.controller.signal },\n request\n ) as ImmutableRequestInfo;\n if (DEBUG) {\n if (!request?.cacheOptions?.[SkipCache]) {\n request = deepFreeze(request);\n enhancedRequest = deepFreeze(enhancedRequest);\n }\n } else {\n if (request.headers) {\n upgradeHeaders(request.headers);\n }\n }\n this.enhancedRequest = enhancedRequest;\n this.request = request as ImmutableRequestInfo;\n this.god = god;\n this.stream.promise = this.stream.promise.then((stream: ReadableStream | null) => {\n if (this.god.stream === stream && this.hasSubscribers) {\n this.god.stream = null;\n }\n return stream;\n });\n }\n\n get hasRequestedStream(): boolean {\n return this.god.hasRequestedStream;\n }\n\n getResponse(): ResponseInfo | null {\n if (this.hasSetResponse) {\n return this.response;\n }\n if (this.nextCalled === 1) {\n return this.god.response;\n }\n return null;\n }\n getStream(): Promise<ReadableStream | null> {\n if (this.isRoot) {\n this.god.hasRequestedStream = true;\n }\n if (!this.hasSetResponse) {\n const hint = this.god.response?.headers?.get('content-length');\n this.stream.promise.sizeHint = hint ? parseInt(hint, 10) : 0;\n }\n this.hasSubscribers = true;\n return this.stream.promise;\n }\n abort(reason: DOMException): void {\n this.controller.abort(reason);\n }\n\n setStream(stream: ReadableStream | Promise<ReadableStream | null> | null): void {\n if (!this.hasSetStream) {\n this.hasSetStream = true;\n\n if (!(stream instanceof Promise)) {\n this.god.stream = stream;\n }\n // @ts-expect-error\n this.stream.resolve(stream);\n }\n }\n\n resolveStream(): void {\n this.setStream(this.nextCalled === 1 ? this.god.stream : null);\n }\n\n setResponse(response: ResponseInfo | Response | null): void {\n if (this.hasSetResponse) {\n if (DEBUG) {\n throw new Error(`Cannot setResponse when a response has already been set`);\n }\n return;\n }\n this.hasSetResponse = true;\n if (response instanceof Response) {\n // TODO potentially avoid cloning in prod\n let responseData = cloneResponseProperties(response);\n\n if (DEBUG) {\n responseData = deepFreeze(responseData);\n }\n this.response = responseData;\n this.god.response = responseData;\n const sizeHint = response.headers?.get('content-length');\n this.stream.promise.sizeHint = sizeHint ? parseInt(sizeHint, 10) : 0;\n } else {\n this.response = response;\n this.god.response = response;\n }\n }\n}\n\n/**\n * The context object given to each {@link Handler} (or {@link CacheHandler})\n * as it processes a request. It exposes the (immutable, enhanced) request\n * along with the methods a handler uses to build up the {@link Future} and\n * {@link StructuredDataDocument} that will ultimately be returned by the\n * {@link RequestManager}.\n *\n * @public\n */\nexport class Context {\n /** @internal */\n declare private ___owner: ContextOwner;\n /**\n * A readonly, immutable version of the request being handled, including\n * any defaults or enhancements applied by the {@link RequestManager}.\n *\n * @public\n */\n declare request: ImmutableRequestInfo;\n /**\n * The id of this request as assigned by the {@link RequestManager}. Not\n * unique across manager instances.\n *\n * @public\n */\n declare id: number;\n /** @internal */\n declare private _isCacheHandler: boolean;\n /** @internal */\n declare private _finalized: boolean;\n\n constructor(owner: ContextOwner, isCacheHandler: boolean) {\n this.id = owner.requestId;\n this.___owner = owner;\n this.request = owner.enhancedRequest;\n this._isCacheHandler = isCacheHandler;\n this._finalized = false;\n }\n /**\n * Set the response stream for this request. May be called at most once,\n * and may be called at any point up until the handler's `request` method\n * resolves.\n *\n * @public\n */\n setStream(stream: ReadableStream | Promise<ReadableStream | null>): void {\n this.___owner.setStream(stream);\n }\n /**\n * Set the {@link ResponseInfo} (or raw `Response`) associated with this\n * request. Used to populate the response information available on the\n * resulting {@link StructuredDataDocument}.\n *\n * @public\n */\n setResponse(response: ResponseInfo | Response | null): void {\n this.___owner.setResponse(response);\n }\n\n /**\n * Associate a {@link RequestKey} with this request. May only be called\n * synchronously from a {@link CacheHandler}.\n *\n * @public\n */\n setIdentifier(identifier: RequestKey): void {\n assert(\n `setIdentifier may only be used synchronously from a CacheHandler`,\n identifier && this._isCacheHandler && !this._finalized\n );\n this.___owner.god.identifier = identifier;\n }\n\n /**\n * Whether the application (or a downstream handler) has requested access\n * to the response stream via {@link Future.getStream}. Handlers can use\n * this to avoid the cost of streaming when nothing will consume it.\n *\n * @public\n */\n get hasRequestedStream(): boolean {\n return this.___owner.hasRequestedStream;\n }\n\n /** @private */\n _finalize(): void {\n this._finalized = true;\n }\n}\nexport type HandlerRequestContext = Context;\n","import { getOrSetUniversal } from '../../types/-private';\n\nexport type CacheResult<T = unknown, E = unknown> = { isError: true; result: E } | { isError: false; result: T };\n\n/**\n * The minimal, structural subset of the `Promise` interface required to be\n * cached and inspected by {@link setPromiseResult} / {@link getPromiseResult}\n * (and by `getPromiseState`). Anything that is at least `then`/`catch`/`finally`\n * \"shaped\" (including a real `Promise` or {@link Future}) satisfies this.\n *\n * @public\n */\nexport type Awaitable<T = unknown, E = unknown> = {\n /**\n * Registers fulfillment/rejection handlers, `Promise.prototype.then`-style.\n *\n * @public\n */\n then: (onFulfilled: (value: T) => unknown, onRejected: (reason: E) => unknown) => unknown;\n /**\n * Registers a rejection handler, `Promise.prototype.catch`-style.\n *\n * @public\n */\n catch: (onRejected: (reason: E) => unknown) => unknown;\n /**\n * Registers a handler run on settlement, `Promise.prototype.finally`-style.\n *\n * @public\n */\n finally: (onFinally: () => unknown) => unknown;\n};\n\nexport const PromiseCache: WeakMap<Awaitable, CacheResult> = getOrSetUniversal(\n 'PromiseCache',\n new WeakMap<Awaitable, CacheResult>()\n);\nexport const RequestMap: Map<number, CacheResult> = getOrSetUniversal('RequestMap', new Map<number, CacheResult>());\n\nexport function setRequestResult(requestId: number, result: CacheResult): void {\n RequestMap.set(requestId, result);\n}\nexport function clearRequestResult(requestId: number): void {\n RequestMap.delete(requestId);\n}\nexport function getRequestResult(requestId: number): CacheResult | undefined {\n return RequestMap.get(requestId);\n}\n\n/**\n * Cache the settled result (or error) of a promise-like value so that its\n * outcome can be synchronously read later via {@link getPromiseResult},\n * without needing to await it again.\n *\n * @public\n */\nexport function setPromiseResult(promise: Promise<unknown> | Awaitable, result: CacheResult): void {\n PromiseCache.set(promise, result);\n}\n\n/**\n * Synchronously read the settled result (or error) previously recorded for\n * a promise-like value via {@link setPromiseResult}, if any.\n *\n * @public\n */\nexport function getPromiseResult<T, E>(promise: Promise<T> | Awaitable<T, E>): CacheResult<T, E> | undefined {\n return PromiseCache.get(promise) as CacheResult<T, E> | undefined;\n}\n","import { DEBUG } from '@warp-drive/core/build-config/env';\n\nimport { getOrSetGlobal } from '../../types/-private';\nimport type {\n RequestInfo,\n StructuredDataDocument,\n StructuredDocument,\n StructuredErrorDocument,\n} from '../../types/request';\nimport { STRUCTURED } from '../../types/request';\nimport { Context, ContextOwner } from './context';\nimport { assertValidRequest } from './debug';\n// oxlint-disable-next-line no-unused-vars\nimport type { Fetch } from './fetch.ts';\nimport { createFuture, isFuture } from './future';\nimport { setRequestResult } from './promise-cache';\nimport type { DeferredFuture, Future, GodContext, Handler } from './types';\n\nexport const IS_CACHE_HANDLER: '___(unique) Symbol(IS_CACHE_HANDLER)' = getOrSetGlobal(\n 'IS_CACHE_HANDLER',\n Symbol('IS_CACHE_HANDLER')\n);\n\n/**\n * A ponyfill for the global {@link DOMException} constructor.\n *\n * Some non-DOM environments (e.g. React Native, some Node/worker\n * environments) don't provide `DOMException` as a global, which would\n * otherwise throw a `ReferenceError` the first time any code referenced it\n * (for instance when classifying an abort/network error). `DOMError` falls\n * back to the global {@link Error} constructor in that case so callers can\n * uniformly use `new DOMError(...)` / `error instanceof DOMError` without\n * guarding for the global's presence themselves.\n *\n * @internal\n */\nexport const DOMError: typeof DOMException =\n typeof DOMException !== 'undefined' ? DOMException : (Error as unknown as typeof DOMException);\nexport function curryFuture<T>(owner: ContextOwner, inbound: Future<T>, outbound: DeferredFuture<T>): Future<T> {\n owner.setStream(inbound.getStream());\n\n inbound.then(\n (doc: StructuredDataDocument<T>) => {\n const document = {\n [STRUCTURED]: true as const,\n request: owner.request,\n response: doc.response,\n content: doc.content,\n };\n outbound.resolve(document);\n },\n (error: Error & StructuredErrorDocument) => {\n if (isDoc(error)) {\n owner.setStream(owner.god.stream);\n }\n if (!error || !(error instanceof Error)) {\n try {\n throw new Error(error ? error : `Request Rejected with an Unknown Error`);\n } catch (e: unknown) {\n if (error && typeof error === 'object') {\n Object.assign(e as Error, error);\n (e as Error & StructuredErrorDocument).message =\n (error as Error).message || `Request Rejected with an Unknown Error`;\n }\n error = e as Error & StructuredErrorDocument;\n }\n }\n\n error[STRUCTURED] = true;\n error.request = owner.request;\n error.response = owner.getResponse();\n error.error = error.error || error.message;\n\n outbound.reject(error);\n }\n );\n return outbound.promise;\n}\n\nfunction isDoc<T>(doc: T | StructuredDataDocument<T>): doc is StructuredDataDocument<T> {\n return doc && (doc as StructuredDataDocument<T>)[STRUCTURED] === true;\n}\n\nfunction ensureDoc<T>(owner: ContextOwner, content: T | Error, isError: boolean): StructuredDocument<T> {\n if (isDoc(content)) {\n return content as StructuredDocument<T>;\n }\n\n if (isError) {\n return {\n [STRUCTURED]: true,\n request: owner.request,\n response: owner.getResponse(),\n error: content as Error,\n } as StructuredErrorDocument<T>;\n }\n\n return {\n [STRUCTURED]: true,\n request: owner.request,\n response: owner.getResponse(),\n content: content as T,\n };\n}\n\n/**\n * Additional properties exposed on errors thrown by the\n * {@link Fetch | Fetch Handler}.\n *\n * In the case of an Abort or system/browser level issue,\n * this extends {@link DOMException}.\n *\n * Else it extends from {@link AggregateError} if the\n * response includes an array of errors, falling back\n * to {@link Error} as its base.\n */\nexport interface FetchError extends DOMException {\n /**\n * Alias for {@link FetchError.status | status}.\n *\n * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status)\n */\n code: number;\n /**\n * The name associated to the {@link FetchError.status | status code}.\n *\n * Typically this will be of the formula `StatusTextError` for instance\n * a 404 status with status text of `Not Found` would have the name\n * `NotFoundError`.\n */\n name: string;\n /**\n * The http status code associated to the returned error.\n *\n * Browser/System level network errors will often have an error code of `0` or `5`.\n * Aborted requests will have an error code of `20`.\n *\n * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/status)\n */\n status: number;\n /**\n * The Status Text associated to the {@link FetchError.status | status code}\n * for the error.\n *\n * [MDN Reference](https://developer.mozilla.org/docs/Web/API/Response/statusText)\n *\n */\n statusText: string;\n /**\n * A property signifying that an Error uses the {@link FetchError}\n * interface.\n */\n isRequestError: true;\n}\n\nexport function enhanceReason(reason?: string): DOMException {\n const error = new DOMError(reason || 'The user aborted a request.', 'AbortError');\n // `DOMError` may be the `Error` constructor as a fallback, whose\n // constructor doesn't accept a `name`, so set it explicitly in that case.\n // We can't unconditionally assign `error.name` here: when `DOMError` is\n // the real `DOMException`, `name` is already `'AbortError'` (set by its\n // constructor) *and* `DOMException.prototype.name` is a getter-only\n // accessor with no setter, so reassigning it throws a `TypeError` in\n // strict-mode JS (which is how our ES modules run) - even when assigning\n // the very same value it already holds.\n if (error.name !== 'AbortError') {\n (error as unknown as { name: string }).name = 'AbortError';\n }\n return error;\n}\n\nexport function handleOutcome<T>(\n owner: ContextOwner,\n inbound: Promise<T | StructuredDataDocument<T>>,\n outbound: DeferredFuture<T>\n): Future<T> {\n inbound.then(\n (content: T | StructuredDataDocument<T>) => {\n if (owner.controller.signal.aborted) {\n // the next function did not respect the signal, we handle it here\n outbound.reject(enhanceReason(owner.controller.signal.reason as string));\n return;\n }\n if (isDoc(content)) {\n owner.setStream(owner.god.stream);\n content = content.content;\n }\n const document = {\n [STRUCTURED]: true as const,\n request: owner.request,\n response: owner.getResponse(),\n content,\n };\n outbound.resolve(document);\n },\n (error: Error & StructuredErrorDocument) => {\n if (isDoc(error)) {\n owner.setStream(owner.god.stream);\n }\n if (!error || !(error instanceof Error)) {\n try {\n throw new Error(error ? error : `Request Rejected with an Unknown Error`);\n } catch (e: unknown) {\n if (error && typeof error === 'object') {\n Object.assign(e as Error, error);\n (e as Error & StructuredErrorDocument).message =\n (error as Error).message || `Request Rejected with an Unknown Error`;\n }\n error = e as Error & StructuredErrorDocument;\n }\n }\n\n error[STRUCTURED] = true;\n error.request = owner.request;\n error.response = owner.getResponse();\n error.error = error.error || error.message;\n outbound.reject(error);\n }\n );\n return outbound.promise;\n}\n\nfunction isCacheHandler(handler: Handler & { [IS_CACHE_HANDLER]?: boolean }, index: number): boolean {\n return index === 0 && Boolean(handler[IS_CACHE_HANDLER]);\n}\n\nexport function executeNextHandler<T>(\n wares: Readonly<Handler[]>,\n request: RequestInfo,\n i: number,\n god: GodContext\n): Future<T> {\n if (DEBUG) {\n if (i === wares.length) {\n throw new Error(`No handler was able to handle this request.`);\n }\n assertValidRequest(request, false);\n }\n const owner = new ContextOwner(request, god, i === 0);\n\n function next(r: RequestInfo): Future<T> {\n owner.nextCalled++;\n return executeNextHandler(wares, r, i + 1, god);\n }\n\n const _isCacheHandler = isCacheHandler(wares[i], i);\n const context = new Context(owner, _isCacheHandler);\n let outcome: Promise<T | StructuredDataDocument<T>> | Future<T>;\n try {\n outcome = wares[i].request<T>(context, next);\n if (_isCacheHandler) {\n context._finalize();\n }\n if (!!outcome && _isCacheHandler) {\n if (!(outcome instanceof Promise)) {\n setRequestResult(owner.requestId, { isError: false, result: ensureDoc(owner, outcome, false) });\n outcome = Promise.resolve(outcome);\n }\n } else if (DEBUG) {\n if (!outcome || (!(outcome instanceof Promise) && !(typeof outcome === 'object' && 'then' in outcome))) {\n // oxlint-disable-next-line no-console\n console.log({ request, handler: wares[i], outcome });\n if (outcome === undefined) {\n throw new Error(`Expected handler.request to return a promise, instead received undefined.`);\n }\n throw new Error(`Expected handler.request to return a promise, instead received a synchronous value.`);\n }\n }\n } catch (e) {\n if (_isCacheHandler) {\n setRequestResult(owner.requestId, { isError: true, result: ensureDoc(owner, e, true) });\n }\n // oxlint-disable-next-line typescript/prefer-promise-reject-errors\n outcome = Promise.reject<StructuredDataDocument<T>>(e);\n }\n const future = createFuture<T>(owner);\n\n if (isFuture<T>(outcome)) {\n return curryFuture(owner, outcome, future);\n }\n\n return handleOutcome(owner, outcome, future);\n}\n","import { DEBUG } from '@warp-drive/build-config/env';\n\nimport { IS_FUTURE, type StructuredDocument } from '../../types/request';\nimport type { ContextOwner } from './context';\nimport type { Deferred, DeferredFuture, Future } from './types';\nimport { enhanceReason } from './utils';\n\nexport function isFuture<T>(maybe: unknown): maybe is Future<T> {\n return Boolean(maybe && maybe instanceof Promise && (maybe as Future<T>)[IS_FUTURE] === true);\n}\n\n/**\n * Create a {@link Deferred}: a promise along with the `resolve`/`reject`\n * callbacks that settle it, so the promise can be handed out before the\n * work that will settle it has started.\n *\n * @public\n */\nexport function createDeferred<T>(): Deferred<T> {\n let resolve!: (v: T) => void;\n let reject!: (v: unknown) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { resolve, reject, promise };\n}\n\nexport function upgradePromise<T>(promise: Promise<StructuredDocument<T>>, future: Future<T>): Future<T> {\n (promise as Future<T>)[IS_FUTURE] = true;\n // oxlint-disable-next-line typescript/unbound-method\n (promise as Future<T>).getStream = future.getStream;\n // oxlint-disable-next-line typescript/unbound-method\n (promise as Future<T>).abort = future.abort;\n // oxlint-disable-next-line typescript/unbound-method\n (promise as Future<T>).onFinalize = future.onFinalize;\n (promise as Future<T>).id = future.id;\n (promise as Future<T>).lid = future.lid;\n (promise as Future<T>).requester = future.requester;\n\n if (DEBUG) {\n // @ts-expect-error\n promise.toJSON = () => {\n const id = 'Future<' + (promise as Future<T>).id + '>';\n if ((promise as Future<T>).lid) {\n return `${id} (${(promise as Future<T>).lid!.lid})`;\n }\n return id;\n };\n }\n\n return promise as Future<T>;\n}\n\nexport function createFuture<T>(owner: ContextOwner): DeferredFuture<T> {\n const deferred = createDeferred<T>() as unknown as DeferredFuture<T>;\n let { promise } = deferred;\n let cbs: Array<() => void> | undefined;\n promise = promise.finally(() => {\n owner.resolveStream();\n if (cbs) {\n cbs.forEach((cb) => cb());\n }\n }) as Future<T>;\n promise.onFinalize = (fn: () => void) => {\n cbs = cbs || [];\n cbs.push(fn);\n };\n promise[IS_FUTURE] = true;\n promise.getStream = () => {\n return owner.getStream();\n };\n promise.abort = (reason?: string) => {\n owner.abort(enhanceReason(reason));\n };\n promise.id = owner.requestId;\n promise.lid = owner.god.identifier;\n promise.requester = owner.god.requester;\n\n if (DEBUG) {\n // @ts-expect-error\n promise.toJSON = () => {\n const id = 'Future<' + promise.id + '>';\n if (promise.lid) {\n return `${id} (${promise.lid.lid})`;\n }\n return id;\n };\n }\n\n deferred.promise = promise;\n return deferred;\n}\n","import type { ReactiveDataDocument } from './reactive.ts';\nimport type { RequestInfo } from './types/request.ts';\nimport type { RequestSignature } from './types/symbols.ts';\n\nexport { createDeferred } from './request/-private/future.ts';\nexport type {\n Future,\n Handler,\n CacheHandler,\n NextFn,\n Deferred,\n ManagedRequestPriority,\n} from './request/-private/types.ts';\nexport { setPromiseResult, getPromiseResult } from './request/-private/promise-cache.ts';\nexport type { Awaitable } from './request/-private/promise-cache.ts';\nexport type { Context } from './request/-private/context.ts';\n\n/**\n * Brands the supplied object with the supplied response type.\n *\n * ```ts\n * import type { ReactiveDataDocument } from '@warp-drive/core/reactive';\n * import { withResponseType } from '@warp-drive/core/request';\n * import type { User } from '#/data/user.ts'\n *\n * const result = await store.request(\n * withResponseType<ReactiveDataDocument<User>>({ url: '/users/1' })\n * );\n *\n * result.content.data; // will have type User\n * ```\n *\n */\nexport function withResponseType<T>(obj: RequestInfo): RequestInfo<T> & {\n /** The branded response type. Present only at the type level; carries no runtime value. */\n [RequestSignature]: T;\n} {\n return obj as RequestInfo<T> & {\n [RequestSignature]: T;\n };\n}\n\n/**\n * Brands the supplied object with the supplied response type\n * wrapped in {@link ReactiveDataDocument}. This is a convenience for\n * the common case of using {@link withResponseType} with `ReactiveDataDocument`.\n *\n * ```ts\n * import { withReactiveResponse } from '@warp-drive/core/request';\n * import type { User } from '#/data/user.ts'\n *\n * const result = await store.request(\n * withReactiveResponse<User>({ url: '/users/1' })\n * );\n *\n * result.content.data; // will have type User\n * ```\n *\n * @public\n */\nexport function withReactiveResponse<T>(obj: RequestInfo): RequestInfo<ReactiveDataDocument<T>> & {\n /** The branded response type. Present only at the type level; carries no runtime value. */\n [RequestSignature]: ReactiveDataDocument<T>;\n} {\n return obj as RequestInfo<ReactiveDataDocument<T>> & {\n [RequestSignature]: ReactiveDataDocument<T>;\n };\n}\n\n/**\n * @deprecated use {@link withResponseType} instead\n */\nexport const withBrand: typeof withResponseType = withResponseType;\n"],"mappings":";;;;;;AAOA,MAAMM,aAAa;CACjBC,MAAM;CACNC,OAAO;EAAC;EAAQ;EAAe;EAAc;EAAY;EAAY;EAAmB;CAAgB;AAC1G;AACA,MAAMC,4BAAY,IAAIC,IAAmD;CACvE,CAAC,UAAU,CAAC,MAAM,CAAC;CACnB,CAAC,WAAW,OAAO;CACnB,CAAC,QAAQ,MAAM;CACf,CAAC,QAAQJ,UAAU;CACnB,CAAC,qBAAqB,SAAS;CAC/B,CAAC,WAAW,QAAQ;CACpB,CAAC,gBAAgB,QAAQ;CACzB,CAAC,YAAY;EAAC;EAAQ;EAAO;CAAM,CAAC;CACpC,CAAC,MAAM,QAAQ;CACf,CAAC,SAAS,QAAQ;CAClB,CAAC,OAAO,QAAQ;CAChB,CAAC,SAAS;EAAC;EAAW;EAAe;EAAY;EAAY;EAAkB;CAAQ,CAAC;CACxF,CAAC,eAAe;EAAC;EAAW;EAAQ;CAAa,CAAC;CAClD,CACE,eACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAAM,CACP;CAEH,CAAC,WAAW,SAAS;CACrB,CAAC,aAAa,QAAQ;CACtB,CAAC,aAAa,SAAS;CACvB,CAAC,UAAU;EAAC;EAAS;EAAO;EA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,eAAAD,gBAAA,CAAA,CAAAoB,UAAAC,IAAAC,KAAA,GAEEb,QAAQc,eAAe;EACrB,MAAMN,KAAK,YAAYR,QAAQQ,KAAK;EACpC,IAAIR,QAAQS,KACV,OAAO,GAAGD,GAAE,IAAKR,QAAQS,IAAIA,IAAG;EAElC,OAAOD;CACT;CAGFS,SAASjB,UAAUA;CACnB,OAAOiB;AACT;;;;;;;;;;;;;;;;;;;;AC3DA,SAAgBe,iBAAoBC,KAGlC;CACA,OAAOA;AAGT;;;;;;;;;;;;;;;;;;;AAoBA,SAAgBC,qBAAwBD,KAGtC;CACA,OAAOA;AAGT;;;;AAKA,MAAaE,YAAqCH"}
package/dist/request.js CHANGED
@@ -1,3 +1,3 @@
1
- import { f as setPromiseResult, i as createDeferred, n as withReactiveResponse, r as withResponseType, t as withBrand, u as getPromiseResult } from "./request-z2NByNx0.js";
1
+ import { f as setPromiseResult, i as createDeferred, n as withReactiveResponse, r as withResponseType, t as withBrand, u as getPromiseResult } from "./request-DZVW74wn.js";
2
2
 
3
3
  export { createDeferred, getPromiseResult, setPromiseResult, withBrand, withReactiveResponse, withResponseType };
@@ -1,3 +1,3 @@
1
- import { D as notifyInternalSignal, E as makeInitializer, N as waitFor, O as peekInternalSignal, T as getOrCreateInternalSignal, _ as entangleSignal, a as getPaginationState, b as signal, c as getPaginationCache, h as defineSignal, i as getPaginationLinks, k as withSignalStore, l as DISPOSE, m as defineNonEnumerableSignal, n as createPaginationLinksSubscription, o as clearPaginationCache, p as defineGate, r as createPaginationSubscription, s as defaultPageHints, v as gate, y as memoized } from "../-private-BL9zXgJB.js";
1
+ import { D as notifyInternalSignal, E as makeInitializer, N as waitFor, O as peekInternalSignal, T as getOrCreateInternalSignal, _ as entangleSignal, a as getPaginationState, b as signal, c as getPaginationCache, h as defineSignal, i as getPaginationLinks, k as withSignalStore, l as DISPOSE, m as defineNonEnumerableSignal, n as createPaginationLinksSubscription, o as clearPaginationCache, p as defineGate, r as createPaginationSubscription, s as defaultPageHints, v as gate, y as memoized } from "../-private-C4L-6BFr.js";
2
2
 
3
3
  export { DISPOSE, clearPaginationCache, createPaginationLinksSubscription, createPaginationSubscription, defaultPageHints, defineGate, defineNonEnumerableSignal, defineSignal, entangleSignal, gate, getOrCreateInternalSignal, getPaginationCache, getPaginationLinks, getPaginationState, makeInitializer, memoized, notifyInternalSignal, peekInternalSignal, signal, waitFor, withSignalStore };
@@ -1,10 +1,10 @@
1
- import { a as setTransient, i as peekUniversalTransient, o as setUniversalTransient, r as peekTransient, t as getOrSetGlobal } from "./-private-Cxa8cMBj.js";
2
- import { A as ARRAY_SIGNAL, C as createInternalMemo, D as notifyInternalSignal, N as waitFor, O as peekInternalSignal, P as willSyncFlushWatchers, S as consumeInternalSignal, T as getOrCreateInternalSignal, _ as entangleSignal, f as createSignalDescriptor, g as entangleInitiallyStaleSignal, h as defineSignal, j as OBJECT_SIGNAL, k as withSignalStore, p as defineGate, w as createInternalSignal, x as Signals } from "./-private-BL9zXgJB.js";
1
+ import { a as setTransient, i as peekUniversalTransient, o as setUniversalTransient, r as peekTransient, t as getOrSetGlobal } from "./-private-DJ3g9bNk.js";
2
+ import { A as ARRAY_SIGNAL, C as createInternalMemo, D as notifyInternalSignal, N as waitFor, O as peekInternalSignal, P as willSyncFlushWatchers, S as consumeInternalSignal, T as getOrCreateInternalSignal, _ as entangleSignal, f as createSignalDescriptor, g as entangleInitiallyStaleSignal, h as defineSignal, j as OBJECT_SIGNAL, k as withSignalStore, p as defineGate, w as createInternalSignal, x as Signals } from "./-private-C4L-6BFr.js";
3
3
  import { EnableHydration, STRUCTURED, SkipCache } from "./types/request.js";
4
4
  import { CACHE_OWNER, DEBUG_CLIENT_ORIGINATED, DEBUG_KEY_TYPE, DEBUG_STALE_CACHE_OWNER } from "./types/identifier.js";
5
- import { a as upgradePromise, c as executeNextHandler, d as getRequestResult, f as setPromiseResult, l as clearRequestResult, m as assertValidRequest, o as DOMError, p as cloneResponseProperties, s as IS_CACHE_HANDLER, t as withBrand } from "./request-z2NByNx0.js";
5
+ import { a as upgradePromise, c as executeNextHandler, d as getRequestResult, f as setPromiseResult, l as clearRequestResult, m as assertValidRequest, o as DOMError, p as cloneResponseProperties, s as IS_CACHE_HANDLER, t as withBrand } from "./request-DZVW74wn.js";
6
6
  import { getRuntimeConfig, setIsMaybeMirage, setLogging } from "./types/runtime.js";
7
- import { a as SOURCE, i as Destroy, n as Commit, r as Context, t as Checkout } from "./-private-xK1KgxZJ.js";
7
+ import { a as SOURCE, i as Destroy, n as Commit, r as Context, t as Checkout } from "./-private-r5p8QUr4.js";
8
8
  import { dasherize } from "./utils/string.js";
9
9
  import { RecordStore, Type } from "./types/symbols.js";
10
10
  import { isResourceSchema } from "./types/schema/fields.js";
@@ -9224,4 +9224,4 @@ function useRecommendedStore(options, StoreKlass = Store) {
9224
9224
 
9225
9225
  //#endregion
9226
9226
  export { setIdentifierResetMethod as A, setRecordIdentifier as C, isResourceKey as D, isRequestKey as E, ensureStringId as F, log as I, logGroup as L, setKeyInfoForResource as M, normalizeModelName as N, setIdentifierForgetMethod as O, coerceId as P, recordIdentifierFor as S, assertPrivateCapabilities as T, isPrivateStore as _, fromIdentity as a, StoreMap as b, instantiateRecord as c, commit as d, createLegacyManyArray as f, assertPrivateStore as g, Store as h, SchemaService as i, setIdentifierUpdateMethod as j, setIdentifierGenerationMethod as k, teardownRecord as l, CacheHandler as m, RequestManager as n, registerDerivations as o, constructResource as p, Fetch as r, withDefaults as s, useRecommendedStore as t, checkout as u, RecordArrayManager as v, storeFor as w, _clearCaches as x, fastPush as y };
9227
- //# sourceMappingURL=src-s5HHjglV.js.map
9227
+ //# sourceMappingURL=src-CsvKpo_j.js.map