zudoku 0.3.0-dev.27 → 0.3.0-dev.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/plugins/openapi/client/createMemoryClient.d.ts +12 -0
- package/dist/lib/plugins/openapi/client/createMemoryClient.js +46 -0
- package/dist/lib/plugins/openapi/client/createMemoryClient.js.map +1 -0
- package/dist/lib/plugins/openapi/client/createServer.d.ts +4 -0
- package/dist/lib/plugins/openapi/{worker/worker.js → client/createServer.js} +5 -19
- package/dist/lib/plugins/openapi/client/createServer.js.map +1 -0
- package/dist/lib/plugins/openapi/client/createWorkerClient.d.ts +10 -0
- package/dist/lib/plugins/openapi/{worker/createSharedWorkerClient.js → client/createWorkerClient.js} +8 -2
- package/dist/lib/plugins/openapi/client/createWorkerClient.js.map +1 -0
- package/dist/lib/plugins/openapi/client/interfaces.d.ts +2 -0
- package/dist/lib/plugins/openapi/client/interfaces.js +2 -0
- package/dist/lib/plugins/openapi/client/interfaces.js.map +1 -0
- package/dist/lib/plugins/openapi/client/worker.js +20 -0
- package/dist/lib/plugins/openapi/client/worker.js.map +1 -0
- package/dist/lib/plugins/openapi/index.js +2 -2
- package/dist/lib/plugins/openapi/index.js.map +1 -1
- package/dist/lib/plugins/openapi-worker.d.ts +1 -1
- package/dist/lib/plugins/openapi-worker.js +1 -1
- package/dist/lib/plugins/openapi-worker.js.map +1 -1
- package/dist/vite/config.js +1 -0
- package/dist/vite/config.js.map +1 -1
- package/dist/vite/plugin-openapi-worker.js +11 -3
- package/dist/vite/plugin-openapi-worker.js.map +1 -1
- package/lib/AnchorLink-BtVKbEwm.js +1 -0
- package/lib/AnchorLink-BtVKbEwm.js.map +1 -0
- package/lib/DevPortalProvider--xZTs0RJ.js +1 -0
- package/lib/DevPortalProvider--xZTs0RJ.js.map +1 -0
- package/lib/Markdown-oJFqm0uk.js +1 -0
- package/lib/Markdown-oJFqm0uk.js.map +1 -0
- package/lib/MdxComponents-CsU8yR42.js +1 -0
- package/lib/MdxComponents-CsU8yR42.js.map +1 -0
- package/lib/MdxPage-BV_9ncEk.js +1 -0
- package/lib/MdxPage-BV_9ncEk.js.map +1 -0
- package/lib/{OperationList-C9t7wPj8.js → OperationList-DfG_E0Xa.js} +2 -1
- package/lib/OperationList-DfG_E0Xa.js.map +1 -0
- package/lib/Route-CHqr53jb.js +1 -0
- package/lib/Route-CHqr53jb.js.map +1 -0
- package/lib/Select-CNmXi4JU.js +1 -0
- package/lib/Select-CNmXi4JU.js.map +1 -0
- package/lib/Spinner-By5opWs5.js +1 -0
- package/lib/Spinner-By5opWs5.js.map +1 -0
- package/lib/_commonjsHelpers-BkfeUUK-.js +1 -0
- package/lib/_commonjsHelpers-BkfeUUK-.js.map +1 -0
- package/lib/assets/index-BPdJm2ty.js +1 -0
- package/lib/assets/index-BPdJm2ty.js.map +1 -0
- package/lib/assets/{worker-DGvzLstc.js → worker-BXS8hiSM.js} +5 -4
- package/lib/assets/worker-BXS8hiSM.js.map +1 -0
- package/lib/cn-DpqTslo9.js +1 -0
- package/lib/cn-DpqTslo9.js.map +1 -0
- package/lib/context-_fYfJFgk.js +1 -0
- package/lib/context-_fYfJFgk.js.map +1 -0
- package/lib/hook-kVJ4gpk5.js +1 -0
- package/lib/hook-kVJ4gpk5.js.map +1 -0
- package/lib/{index-CySUl0uj.js → index-B2qLeglF.js} +6 -5
- package/lib/index-B2qLeglF.js.map +1 -0
- package/lib/index-CUIxJAeE.js +1 -0
- package/lib/index-CUIxJAeE.js.map +1 -0
- package/lib/index-Cr3hgaqt.js +1 -0
- package/lib/index-Cr3hgaqt.js.map +1 -0
- package/lib/index-fXFJf9Ua.js +1 -0
- package/lib/index-fXFJf9Ua.js.map +1 -0
- package/lib/jsx-runtime-D7DwziLW.js +1 -0
- package/lib/jsx-runtime-D7DwziLW.js.map +1 -0
- package/lib/loglevel-CA34MiFn.js +1 -0
- package/lib/loglevel-CA34MiFn.js.map +1 -0
- package/lib/prism-bash.min-DadFsM4Z.js +1 -0
- package/lib/prism-bash.min-DadFsM4Z.js.map +1 -0
- package/lib/prism-csharp.min-Yizuc34Y.js +1 -0
- package/lib/prism-csharp.min-Yizuc34Y.js.map +1 -0
- package/lib/prism-java.min-d5iT_mOd.js +1 -0
- package/lib/prism-java.min-d5iT_mOd.js.map +1 -0
- package/lib/prism-json.min-B1GJqK1k.js +1 -0
- package/lib/prism-json.min-B1GJqK1k.js.map +1 -0
- package/lib/prism-markup-templating-DZrrEs0A.js +1 -0
- package/lib/prism-markup-templating-DZrrEs0A.js.map +1 -0
- package/lib/prism-objectivec.min-BXSWqpJJ.js +1 -0
- package/lib/prism-objectivec.min-BXSWqpJJ.js.map +1 -0
- package/lib/prism-php.min-o7FpoMP_.js +1 -0
- package/lib/prism-php.min-o7FpoMP_.js.map +1 -0
- package/lib/prism-ruby.min-C7LwcKyz.js +1 -0
- package/lib/prism-ruby.min-C7LwcKyz.js.map +1 -0
- package/lib/state-Ds_OxRHP.js +1 -0
- package/lib/state-Ds_OxRHP.js.map +1 -0
- package/lib/urql-DMlBWUKL.js +1 -0
- package/lib/urql-DMlBWUKL.js.map +1 -0
- package/lib/util-DnDPBx_j.js +1 -0
- package/lib/util-DnDPBx_j.js.map +1 -0
- package/lib/zudoku.auth-auth0.js +1 -0
- package/lib/zudoku.auth-auth0.js.map +1 -0
- package/lib/zudoku.auth-clerk.js +1 -0
- package/lib/zudoku.auth-clerk.js.map +1 -0
- package/lib/zudoku.auth-openid.js +1 -0
- package/lib/zudoku.auth-openid.js.map +1 -0
- package/lib/zudoku.components.js +1 -0
- package/lib/zudoku.components.js.map +1 -0
- package/lib/zudoku.openapi-worker.js +10 -9
- package/lib/zudoku.openapi-worker.js.map +1 -0
- package/lib/zudoku.plugin-api-keys.js +1 -0
- package/lib/zudoku.plugin-api-keys.js.map +1 -0
- package/lib/zudoku.plugin-markdown.js +1 -0
- package/lib/zudoku.plugin-markdown.js.map +1 -0
- package/lib/zudoku.plugin-openapi.js +2 -1
- package/lib/zudoku.plugin-openapi.js.map +1 -0
- package/lib/zudoku.plugin-redirect.js +1 -0
- package/lib/zudoku.plugin-redirect.js.map +1 -0
- package/package.json +3 -3
- package/src/app/demo-cdn.html +10 -2
- package/src/lib/plugins/openapi/client/createMemoryClient.ts +56 -0
- package/src/lib/plugins/openapi/client/createServer.ts +33 -0
- package/src/lib/plugins/openapi/{worker/createSharedWorkerClient.ts → client/createWorkerClient.ts} +9 -1
- package/src/lib/plugins/openapi/client/interfaces.ts +3 -0
- package/src/lib/plugins/openapi/client/worker.ts +30 -0
- package/src/lib/plugins/openapi/index.tsx +2 -2
- package/src/lib/plugins/openapi-worker.ts +1 -1
- package/dist/lib/plugins/openapi/worker/createSharedWorkerClient.d.ts +0 -5
- package/dist/lib/plugins/openapi/worker/createSharedWorkerClient.js.map +0 -1
- package/dist/lib/plugins/openapi/worker/shared-worker.d.ts +0 -1
- package/dist/lib/plugins/openapi/worker/shared-worker.js +0 -6
- package/dist/lib/plugins/openapi/worker/shared-worker.js.map +0 -1
- package/dist/lib/plugins/openapi/worker/worker.js.map +0 -1
- package/src/lib/plugins/openapi/worker/shared-worker.ts +0 -5
- package/src/lib/plugins/openapi/worker/worker.ts +0 -56
- /package/dist/lib/plugins/openapi/{worker → client}/worker.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zudoku.openapi-worker.js","sources":["../../../node_modules/.pnpm/layerr@2.1.0/node_modules/layerr/dist/error.js","../../../node_modules/.pnpm/layerr@2.1.0/node_modules/layerr/dist/tools.js","../../../node_modules/.pnpm/layerr@2.1.0/node_modules/layerr/dist/layerr.js","../../../node_modules/.pnpm/ulidx@2.3.0/node_modules/ulidx/dist/browser/index.js","../src/lib/util/createWaitForNotify.ts","../src/lib/plugins/openapi/client/createWorkerClient.ts"],"sourcesContent":["export function assertError(err) {\n if (!isError(err)) {\n throw new Error(\"Parameter was not an error\");\n }\n}\nexport function isError(err) {\n return objectToString(err) === \"[object Error]\" || err instanceof Error;\n}\nfunction objectToString(obj) {\n return Object.prototype.toString.call(obj);\n}\n","import { isError } from \"./error.js\";\nexport function parseArguments(args) {\n let options, shortMessage = \"\";\n if (args.length === 0) {\n options = {};\n }\n else if (isError(args[0])) {\n options = {\n cause: args[0]\n };\n shortMessage = args.slice(1).join(\" \") || \"\";\n }\n else if (args[0] && typeof args[0] === \"object\") {\n options = Object.assign({}, args[0]);\n shortMessage = args.slice(1).join(\" \") || \"\";\n }\n else if (typeof args[0] === \"string\") {\n options = {};\n shortMessage = shortMessage = args.join(\" \") || \"\";\n }\n else {\n throw new Error(\"Invalid arguments passed to Layerr\");\n }\n return {\n options,\n shortMessage\n };\n}\n","import { assertError, isError } from \"./error.js\";\nimport { parseArguments } from \"./tools.js\";\nexport class Layerr extends Error {\n constructor(errorOptionsOrMessage, messageText) {\n const args = [...arguments];\n const { options, shortMessage } = parseArguments(args);\n let message = shortMessage;\n if (options.cause) {\n message = `${message}: ${options.cause.message}`;\n }\n super(message);\n this.message = message;\n if (options.name && typeof options.name === \"string\") {\n this.name = options.name;\n }\n else {\n this.name = \"Layerr\";\n }\n if (options.cause) {\n Object.defineProperty(this, \"_cause\", { value: options.cause });\n }\n Object.defineProperty(this, \"_info\", { value: {} });\n if (options.info && typeof options.info === \"object\") {\n Object.assign(this._info, options.info);\n }\n if (Error.captureStackTrace) {\n const ctor = options.constructorOpt || this.constructor;\n Error.captureStackTrace(this, ctor);\n }\n }\n static cause(err) {\n assertError(err);\n if (!err._cause)\n return null;\n return isError(err._cause) ? err._cause : null;\n }\n static fullStack(err) {\n assertError(err);\n const cause = Layerr.cause(err);\n if (cause) {\n return `${err.stack}\\ncaused by: ${Layerr.fullStack(cause)}`;\n }\n return err.stack;\n }\n static info(err) {\n assertError(err);\n const output = {};\n const cause = Layerr.cause(err);\n if (cause) {\n Object.assign(output, Layerr.info(cause));\n }\n if (err._info) {\n Object.assign(output, err._info);\n }\n return output;\n }\n cause() {\n return Layerr.cause(this);\n }\n toString() {\n let output = this.name || this.constructor.name || this.constructor.prototype.name;\n if (this.message) {\n output = `${output}: ${this.message}`;\n }\n return output;\n }\n}\n","import { Layerr } from 'layerr';\n\nconst B32_CHARACTERS = \"0123456789ABCDEFGHJKMNPQRSTVWXYZ\";\nconst MAX_ULID = \"7ZZZZZZZZZZZZZZZZZZZZZZZZZ\";\nconst MIN_ULID = \"00000000000000000000000000\";\nconst ULID_REGEX = /^[0-7][0-9a-hjkmnp-tv-zA-HJKMNP-TV-Z]{25}$/;\nconst UUID_REGEX = /^[0-9a-fA-F]{8}-(?:[0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$/;\n\n// Code from https://github.com/devbanana/crockford-base32/blob/develop/src/index.ts\nfunction crockfordEncode(input) {\n const output = [];\n let bitsRead = 0;\n let buffer = 0;\n const reversedInput = new Uint8Array(input.slice().reverse());\n for (const byte of reversedInput) {\n buffer |= byte << bitsRead;\n bitsRead += 8;\n while (bitsRead >= 5) {\n output.unshift(buffer & 0x1f);\n buffer >>>= 5;\n bitsRead -= 5;\n }\n }\n if (bitsRead > 0) {\n output.unshift(buffer & 0x1f);\n }\n return output.map(byte => B32_CHARACTERS.charAt(byte)).join(\"\");\n}\nfunction crockfordDecode(input) {\n const sanitizedInput = input.toUpperCase().split(\"\").reverse().join(\"\");\n const output = [];\n let bitsRead = 0;\n let buffer = 0;\n for (const character of sanitizedInput) {\n const byte = B32_CHARACTERS.indexOf(character);\n if (byte === -1) {\n throw new Error(`Invalid base 32 character found in string: ${character}`);\n }\n buffer |= byte << bitsRead;\n bitsRead += 5;\n while (bitsRead >= 8) {\n output.unshift(buffer & 0xff);\n buffer >>>= 8;\n bitsRead -= 8;\n }\n }\n if (bitsRead >= 5 || buffer > 0) {\n output.unshift(buffer & 0xff);\n }\n return new Uint8Array(output);\n}\n\n// These values should NEVER change. The values are precisely for\n// generating ULIDs.\nconst ENCODING = \"0123456789ABCDEFGHJKMNPQRSTVWXYZ\"; // Crockford's Base32\nconst ENCODING_LEN = 32; // from ENCODING.length;\nconst TIME_MAX = 281474976710655; // from Math.pow(2, 48) - 1;\nconst TIME_LEN = 10;\nconst RANDOM_LEN = 16;\nconst ERROR_INFO = Object.freeze({\n source: \"ulid\"\n});\n/**\n * Decode time from a ULID\n * @param id The ULID\n * @returns The decoded timestamp\n */\nfunction decodeTime(id) {\n if (id.length !== TIME_LEN + RANDOM_LEN) {\n throw new Layerr({\n info: {\n code: \"DEC_TIME_MALFORMED\",\n ...ERROR_INFO\n }\n }, \"Malformed ULID\");\n }\n const time = id\n .substr(0, TIME_LEN)\n .toUpperCase()\n .split(\"\")\n .reverse()\n .reduce((carry, char, index) => {\n const encodingIndex = ENCODING.indexOf(char);\n if (encodingIndex === -1) {\n throw new Layerr({\n info: {\n code: \"DEC_TIME_CHAR\",\n ...ERROR_INFO\n }\n }, `Time decode error: Invalid character: ${char}`);\n }\n return (carry += encodingIndex * Math.pow(ENCODING_LEN, index));\n }, 0);\n if (time > TIME_MAX) {\n throw new Layerr({\n info: {\n code: \"DEC_TIME_CHAR\",\n ...ERROR_INFO\n }\n }, `Malformed ULID: timestamp too large: ${time}`);\n }\n return time;\n}\n/**\n * Detect the best PRNG (pseudo-random number generator)\n * @param root The root to check from (global/window)\n * @returns The PRNG function\n */\nfunction detectPRNG(root) {\n const rootLookup = root || detectRoot();\n const globalCrypto = (rootLookup && (rootLookup.crypto || rootLookup.msCrypto)) ||\n (null);\n if (typeof globalCrypto?.getRandomValues === \"function\") {\n return () => {\n const buffer = new Uint8Array(1);\n globalCrypto.getRandomValues(buffer);\n return buffer[0] / 0xff;\n };\n }\n else if (typeof globalCrypto?.randomBytes === \"function\") {\n return () => globalCrypto.randomBytes(1).readUInt8() / 0xff;\n }\n else ;\n throw new Layerr({\n info: {\n code: \"PRNG_DETECT\",\n ...ERROR_INFO\n }\n }, \"Failed to find a reliable PRNG\");\n}\nfunction detectRoot() {\n if (inWebWorker())\n return self;\n if (typeof window !== \"undefined\") {\n return window;\n }\n if (typeof global !== \"undefined\") {\n return global;\n }\n if (typeof globalThis !== \"undefined\") {\n return globalThis;\n }\n return null;\n}\nfunction encodeRandom(len, prng) {\n let str = \"\";\n for (; len > 0; len--) {\n str = randomChar(prng) + str;\n }\n return str;\n}\n/**\n * Encode the time portion of a ULID\n * @param now The current timestamp\n * @param len Length to generate\n * @returns The encoded time\n */\nfunction encodeTime(now, len) {\n if (isNaN(now)) {\n throw new Layerr({\n info: {\n code: \"ENC_TIME_NAN\",\n ...ERROR_INFO\n }\n }, `Time must be a number: ${now}`);\n }\n else if (now > TIME_MAX) {\n throw new Layerr({\n info: {\n code: \"ENC_TIME_SIZE_EXCEED\",\n ...ERROR_INFO\n }\n }, `Cannot encode a time larger than ${TIME_MAX}: ${now}`);\n }\n else if (now < 0) {\n throw new Layerr({\n info: {\n code: \"ENC_TIME_NEG\",\n ...ERROR_INFO\n }\n }, `Time must be positive: ${now}`);\n }\n else if (Number.isInteger(now) === false) {\n throw new Layerr({\n info: {\n code: \"ENC_TIME_TYPE\",\n ...ERROR_INFO\n }\n }, `Time must be an integer: ${now}`);\n }\n let mod, str = \"\";\n for (let currentLen = len; currentLen > 0; currentLen--) {\n mod = now % ENCODING_LEN;\n str = ENCODING.charAt(mod) + str;\n now = (now - mod) / ENCODING_LEN;\n }\n return str;\n}\n/**\n * Fix a ULID's Base32 encoding -\n * i and l (case-insensitive) will be treated as 1 and o (case-insensitive) will be treated as 0.\n * hyphens are ignored during decoding.\n * @param id The ULID\n * @returns The cleaned up ULID\n */\nfunction fixULIDBase32(id) {\n return id.replace(/i/gi, \"1\").replace(/l/gi, \"1\").replace(/o/gi, \"0\").replace(/-/g, \"\");\n}\nfunction incrementBase32(str) {\n let done = undefined, index = str.length, char, charIndex, output = str;\n const maxCharIndex = ENCODING_LEN - 1;\n while (!done && index-- >= 0) {\n char = output[index];\n charIndex = ENCODING.indexOf(char);\n if (charIndex === -1) {\n throw new Layerr({\n info: {\n code: \"B32_INC_ENC\",\n ...ERROR_INFO\n }\n }, \"Incorrectly encoded string\");\n }\n if (charIndex === maxCharIndex) {\n output = replaceCharAt(output, index, ENCODING[0]);\n continue;\n }\n done = replaceCharAt(output, index, ENCODING[charIndex + 1]);\n }\n if (typeof done === \"string\") {\n return done;\n }\n throw new Layerr({\n info: {\n code: \"B32_INC_INVALID\",\n ...ERROR_INFO\n }\n }, \"Failed incrementing string\");\n}\nfunction inWebWorker() {\n // @ts-ignore\n return typeof WorkerGlobalScope !== \"undefined\" && self instanceof WorkerGlobalScope;\n}\n/**\n * Check if a ULID is valid\n * @param id The ULID to test\n * @returns True if valid, false otherwise\n * @example\n * isValid(\"01HNZX8JGFACFA36RBXDHEQN6E\"); // true\n * isValid(\"\"); // false\n */\nfunction isValid(id) {\n return (typeof id === \"string\" &&\n id.length === TIME_LEN + RANDOM_LEN &&\n id\n .toUpperCase()\n .split(\"\")\n .every(char => ENCODING.indexOf(char) !== -1));\n}\n/**\n * Create a ULID factory to generate monotonically-increasing\n * ULIDs\n * @param prng The PRNG to use\n * @returns A ulid factory\n * @example\n * const ulid = monotonicFactory();\n * ulid(); // \"01HNZXD07M5CEN5XA66EMZSRZW\"\n */\nfunction monotonicFactory(prng) {\n const currentPRNG = prng || detectPRNG();\n let lastTime = 0, lastRandom;\n return function _ulid(seedTime) {\n const seed = isNaN(seedTime) ? Date.now() : seedTime;\n if (seed <= lastTime) {\n const incrementedRandom = (lastRandom = incrementBase32(lastRandom));\n return encodeTime(lastTime, TIME_LEN) + incrementedRandom;\n }\n lastTime = seed;\n const newRandom = (lastRandom = encodeRandom(RANDOM_LEN, currentPRNG));\n return encodeTime(seed, TIME_LEN) + newRandom;\n };\n}\nfunction randomChar(prng) {\n let rand = Math.floor(prng() * ENCODING_LEN);\n if (rand === ENCODING_LEN) {\n rand = ENCODING_LEN - 1;\n }\n return ENCODING.charAt(rand);\n}\nfunction replaceCharAt(str, index, char) {\n if (index > str.length - 1) {\n return str;\n }\n return str.substr(0, index) + char + str.substr(index + 1);\n}\n/**\n * Generate a ULID\n * @param seedTime Optional time seed\n * @param prng Optional PRNG function\n * @returns A ULID string\n * @example\n * ulid(); // \"01HNZXD07M5CEN5XA66EMZSRZW\"\n */\nfunction ulid(seedTime, prng) {\n const currentPRNG = prng || detectPRNG();\n const seed = isNaN(seedTime) ? Date.now() : seedTime;\n return encodeTime(seed, TIME_LEN) + encodeRandom(RANDOM_LEN, currentPRNG);\n}\n/**\n * Convert a ULID to a UUID\n * @param ulid The ULID to convert\n * @returns A UUID string\n */\nfunction ulidToUUID(ulid) {\n const isValid = ULID_REGEX.test(ulid);\n if (!isValid) {\n throw new Layerr({ info: { code: \"INVALID_ULID\", ...ERROR_INFO } }, \"Invalid ULID\");\n }\n const uint8Array = crockfordDecode(ulid);\n let uuid = Array.from(uint8Array)\n .map(byte => byte.toString(16).padStart(2, \"0\"))\n .join(\"\");\n uuid =\n uuid.substring(0, 8) +\n \"-\" +\n uuid.substring(8, 12) +\n \"-\" +\n uuid.substring(12, 16) +\n \"-\" +\n uuid.substring(16, 20) +\n \"-\" +\n uuid.substring(20);\n return uuid;\n}\n/**\n * Convert a UUID to a ULID\n * @param uuid The UUID to convert\n * @returns A ULID string\n */\nfunction uuidToULID(uuid) {\n const isValid = UUID_REGEX.test(uuid);\n if (!isValid) {\n throw new Layerr({ info: { code: \"INVALID_UUID\", ...ERROR_INFO } }, \"Invalid UUID\");\n }\n const uint8Array = new Uint8Array(uuid\n .replace(/-/g, \"\")\n .match(/.{1,2}/g)\n .map(byte => parseInt(byte, 16)));\n return crockfordEncode(uint8Array);\n}\n\nexport { B32_CHARACTERS, MAX_ULID, MIN_ULID, ULID_REGEX, UUID_REGEX, decodeTime, detectPRNG, encodeTime, fixULIDBase32, isValid, monotonicFactory, ulid, ulidToUUID, uuidToULID };\n","export const createWaitForNotify = <T extends NonNullable<unknown>>() => {\n const resolveMap = new Map<string, (value: T | PromiseLike<T>) => void>();\n\n const waitFor = (id: string) =>\n new Promise<T>((resolve) => {\n resolveMap.set(id, resolve);\n });\n\n const notify = (id: string, data: T) => {\n const resolveFn = resolveMap.get(id);\n if (resolveFn) {\n resolveFn(data);\n resolveMap.delete(id);\n }\n };\n\n return [waitFor, notify] as const;\n};\n","/* eslint-disable no-console */\nimport { monotonicFactory } from \"ulidx\";\nimport { createWaitForNotify } from \"../../../util/createWaitForNotify.js\";\nimport {\n cacheExchange,\n Client,\n fetchExchange,\n mapExchange,\n} from \"../util/urql.js\";\nimport { CreateClientFunction } from \"./interfaces.js\";\n\nexport type WorkerGraphQLMessage = { id: string; body: string };\n\nconst ulid = monotonicFactory();\n\n/**\n * This loads the client from a worker and uses mess port to send requests\n * and responses between the main thread and the worker.\n */\nexport const createClient: CreateClientFunction = () => {\n // NOTE: This URL needs to be inline with the SharedWorker otherwse\n // vite build does not recognize the worker file as a module.\n const worker = new SharedWorker(new URL(\"./worker.ts\", import.meta.url), {\n type: \"module\",\n });\n\n worker.onerror = (e) => {\n console.error(e);\n };\n\n worker.port.start();\n\n const [waitFor, notify] = createWaitForNotify<string>();\n\n worker.port.onmessage = (e: MessageEvent<WorkerGraphQLMessage>) => {\n notify(e.data.id, e.data.body);\n };\n\n return new Client({\n url: \"/__z/graphql\",\n // Custom fetch to send the GraphQL request to the worker and convert the response back to a `Response` object\n fetch: async (_req, init) => {\n if (!init?.body) throw new Error(\"No body\");\n\n const id = ulid();\n worker.port.postMessage({\n id,\n body: init.body as string,\n } satisfies WorkerGraphQLMessage);\n\n const body = await waitFor(id);\n\n return new Response(body, {\n headers: {\n \"Content-Type\": \"application/json\",\n },\n });\n },\n exchanges: [\n cacheExchange,\n mapExchange({\n onError(error, operation) {\n console.error(error);\n console.groupCollapsed(\"Operation info\");\n console.log(\"body\", operation.query.loc?.source.body.trim());\n console.log(\"variables\", operation.variables);\n console.groupEnd();\n },\n }),\n fetchExchange,\n ],\n });\n};\n"],"names":["assertError","err","isError","objectToString","obj","parseArguments","args","options","shortMessage","Layerr","errorOptionsOrMessage","messageText","message","ctor","cause","output","ENCODING","ENCODING_LEN","TIME_MAX","TIME_LEN","RANDOM_LEN","ERROR_INFO","detectPRNG","root","rootLookup","detectRoot","globalCrypto","buffer","inWebWorker","encodeRandom","len","prng","str","randomChar","encodeTime","now","mod","currentLen","incrementBase32","done","index","char","charIndex","maxCharIndex","replaceCharAt","monotonicFactory","currentPRNG","lastTime","lastRandom","seedTime","seed","incrementedRandom","newRandom","rand","createWaitForNotify","resolveMap","id","resolve","data","resolveFn","ulid","createClient","worker","e","waitFor","notify","Client","_req","init","body","cacheExchange","mapExchange","error","operation","_a","fetchExchange"],"mappings":";AAAO,SAASA,EAAYC,GAAK;AAC7B,MAAI,CAACC,EAAQD,CAAG;AACZ,UAAM,IAAI,MAAM,4BAA4B;AAEpD;AACO,SAASC,EAAQD,GAAK;AACzB,SAAOE,EAAeF,CAAG,MAAM,oBAAoBA,aAAe;AACtE;AACA,SAASE,EAAeC,GAAK;AACzB,SAAO,OAAO,UAAU,SAAS,KAAKA,CAAG;AAC7C;ACTO,SAASC,EAAeC,GAAM;AACjC,MAAIC,GAASC,IAAe;AAC5B,MAAIF,EAAK,WAAW;AAChB,IAAAC,IAAU,CAAA;AAAA,WAELL,EAAQI,EAAK,CAAC,CAAC;AACpB,IAAAC,IAAU;AAAA,MACN,OAAOD,EAAK,CAAC;AAAA,IACzB,GACQE,IAAeF,EAAK,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK;AAAA,WAErCA,EAAK,CAAC,KAAK,OAAOA,EAAK,CAAC,KAAM;AACnC,IAAAC,IAAU,OAAO,OAAO,CAAE,GAAED,EAAK,CAAC,CAAC,GACnCE,IAAeF,EAAK,MAAM,CAAC,EAAE,KAAK,GAAG,KAAK;AAAA,WAErC,OAAOA,EAAK,CAAC,KAAM;AACxB,IAAAC,IAAU,CAAA,GACVC,IAAeA,IAAeF,EAAK,KAAK,GAAG,KAAK;AAAA;AAGhD,UAAM,IAAI,MAAM,oCAAoC;AAExD,SAAO;AAAA,IACH,SAAAC;AAAA,IACA,cAAAC;AAAA,E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AC,EAAqB,OAAO,KAAK,MAAM,GACnD,QAAA,IAAI,aAAaD,EAAU,SAAS,GAC5C,QAAQ,SAAS;AAAA,QACnB;AAAA,MAAA,CACD;AAAA,MACDE;AAAA,IACF;AAAA,EAAA,CACD;AACH;","x_google_ignoreList":[0,1,2,3]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zudoku.plugin-api-keys.js","sources":["../../../node_modules/.pnpm/lucide-react@0.378.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/eye-off.js","../../../node_modules/.pnpm/lucide-react@0.378.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/eye.js","../../../node_modules/.pnpm/lucide-react@0.378.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/rotate-cw.js","../../../node_modules/.pnpm/lucide-react@0.378.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/trash.js","../../../node_modules/.pnpm/tiny-invariant@1.3.3/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","../src/lib/components/Input.tsx","../src/lib/plugins/api-keys/CreateApiKey.tsx","../src/lib/plugins/api-keys/SettingsApiKeys.tsx","../src/lib/plugins/api-keys/index.tsx"],"sourcesContent":["/**\n * @license lucide-react v0.378.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst EyeOff = createLucideIcon(\"EyeOff\", [\n [\"path\", { d: \"M9.88 9.88a3 3 0 1 0 4.24 4.24\", key: \"1jxqfv\" }],\n [\n \"path\",\n {\n d: \"M10.73 5.08A10.43 10.43 0 0 1 12 5c7 0 10 7 10 7a13.16 13.16 0 0 1-1.67 2.68\",\n key: \"9wicm4\"\n }\n ],\n [\n \"path\",\n { d: \"M6.61 6.61A13.526 13.526 0 0 0 2 12s3 7 10 7a9.74 9.74 0 0 0 5.39-1.61\", key: \"1jreej\" }\n ],\n [\"line\", { x1: \"2\", x2: \"22\", y1: \"2\", y2: \"22\", key: \"a6p6uj\" }]\n]);\n\nexport { EyeOff as default };\n//# sourceMappingURL=eye-off.js.map\n","/**\n * @license lucide-react v0.378.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst Eye = createLucideIcon(\"Eye\", [\n [\"path\", { d: \"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z\", key: \"rwhkz3\" }],\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"3\", key: \"1v7zrd\" }]\n]);\n\nexport { Eye as default };\n//# sourceMappingURL=eye.js.map\n","/**\n * @license lucide-react v0.378.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst RotateCw = createLucideIcon(\"RotateCw\", [\n [\"path\", { d: \"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8\", key: \"1p45f6\" }],\n [\"path\", { d: \"M21 3v5h-5\", key: \"1q7to0\" }]\n]);\n\nexport { RotateCw as default };\n//# sourceMappingURL=rotate-cw.js.map\n","/**\n * @license lucide-react v0.378.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.js';\n\nconst Trash = createLucideIcon(\"Trash\", [\n [\"path\", { d: \"M3 6h18\", key: \"d0wm0j\" }],\n [\"path\", { d: \"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6\", key: \"4alrt4\" }],\n [\"path\", { d: \"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2\", key: \"v07s0e\" }]\n]);\n\nexport { Trash as default };\n//# sourceMappingURL=trash.js.map\n","var isProduction = process.env.NODE_ENV === 'production';\nvar prefix = 'Invariant failed';\nfunction invariant(condition, message) {\n if (condition) {\n return;\n }\n if (isProduction) {\n throw new Error(prefix);\n }\n var provided = typeof message === 'function' ? message() : message;\n var value = provided ? \"\".concat(prefix, \": \").concat(provided) : prefix;\n throw new Error(value);\n}\n\nexport { invariant as default };\n","import * as React from \"react\";\nimport { cn } from \"../util/cn.js\";\n\nexport interface InputProps\n extends React.InputHTMLAttributes<HTMLInputElement> {}\n\nconst Input = React.forwardRef<HTMLInputElement, InputProps>(\n ({ className, type, ...props }, ref) => {\n return (\n <input\n type={type}\n className={cn(\n \"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\",\n className,\n )}\n ref={ref}\n {...props}\n />\n );\n },\n);\nInput.displayName = \"Input\";\n\nexport { Input };\n","import { useMutation } from \"@tanstack/react-query\";\nimport { useForm } from \"react-hook-form\";\nimport { Link, useNavigate } from \"react-router-dom\";\nimport { useDevPortal } from \"../../components/context/DevPortalProvider.js\";\nimport { Input } from \"../../components/Input.js\";\nimport {\n Select,\n SelectContent,\n SelectGroup,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from \"../../components/Select.js\";\nimport { Button } from \"../../ui/Button.js\";\nimport { ApiKeyService } from \"./index.js\";\n\ntype CreateApiKey = { description: string; expiresOn?: string };\n\nexport const CreateApiKey = ({ service }: { service: ApiKeyService }) => {\n const context = useDevPortal();\n const navigate = useNavigate();\n const form = useForm<CreateApiKey>({\n defaultValues: {\n expiresOn: \"30\",\n },\n });\n const createKeyMutation = useMutation({\n mutationFn: ({ description, expiresOn }: CreateApiKey) => {\n if (!service.createKey) {\n throw new Error(\"deleteKey not implemented\");\n }\n\n const expiresOnDate =\n expiresOn !== \"never\" ? addDaysToDate(Number(expiresOn)) : undefined;\n\n return service.createKey(\n { description: description, expiresOn: expiresOnDate },\n context,\n );\n },\n onSuccess: () => navigate(\"/settings/api-keys/\"),\n });\n\n if (!service.createKey) {\n return null;\n }\n\n return (\n <div className=\"max-w-screen-lg pt-[--padding-content-top] pb-[--padding-content-bottom]\">\n <div className=\"flex justify-between mb-4 border-b border-border pb-1\">\n <h1 className=\"font-medium text-2xl\">New API Key</h1>\n </div>\n <form\n onSubmit={form.handleSubmit((data) => createKeyMutation.mutate(data))}\n >\n <div className=\"flex gap-2 flex-col\">\n Note\n <Input {...form.register(\"description\")} />\n Expiration\n <Select\n onValueChange={(value) => form.setValue(\"expiresOn\", value)}\n defaultValue={form.getValues(\"expiresOn\")}\n >\n <SelectTrigger>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectGroup>\n {[7, 30, 60, 90].map((option) => (\n <SelectItem value={String(option)} key={option}>\n {option} days\n </SelectItem>\n ))}\n <SelectItem value=\"never\">Never</SelectItem>\n </SelectGroup>\n </SelectContent>\n </Select>\n <div className=\"flex gap-2\">\n <Button>Generate Key</Button>\n <Button variant=\"outline\" asChild>\n <Link to=\"/settings/api-keys/\">Cancel</Link>\n </Button>\n </div>\n </div>\n </form>\n </div>\n );\n};\n\nconst addDaysToDate = (days: number): string => {\n const date = new Date();\n date.setDate(date.getDate() + days);\n return date.toISOString();\n};\n","import {\n useMutation,\n useQueryClient,\n useSuspenseQuery,\n} from \"@tanstack/react-query\";\nimport { EyeIcon, EyeOffIcon, RotateCwIcon, TrashIcon } from \"lucide-react\";\nimport { useState } from \"react\";\nimport { Link } from \"react-router-dom\";\nimport { useDevPortal } from \"../../components/context/DevPortalProvider.js\";\nimport { Button } from \"../../ui/Button.js\";\nimport { ApiKeyService } from \"./index.js\";\n\nexport const SettingsApiKeys = ({ service }: { service: ApiKeyService }) => {\n const context = useDevPortal();\n const queryClient = useQueryClient();\n const { data } = useSuspenseQuery({\n queryFn: () => service.getKeys(context),\n queryKey: [\"api-keys\"],\n retry: false,\n });\n\n const deleteKeyMutation = useMutation({\n mutationFn: (id: string) => {\n if (!service.deleteKey) {\n throw new Error(\"deleteKey not implemented\");\n }\n\n return service.deleteKey(id, context);\n },\n onSuccess: () => {\n void queryClient.invalidateQueries({ queryKey: [\"api-keys\"] });\n },\n });\n\n return (\n <div className=\"max-w-screen-lg h-full pt-[--padding-content-top] pb-[--padding-content-bottom]\">\n <div className=\"flex justify-between mb-4 border-b border-border pb-3\">\n <h1 className=\"font-medium text-2xl\">API Keys</h1>\n {service.createKey && (\n <Button asChild>\n <Link to=\"/settings/api-keys/new\">Create API Key</Link>\n </Button>\n )}\n </div>\n\n {data.length === 0 ? (\n <div className=\"flex flex-col justify-center gap-4 items-center h-1/2 my-8\">\n <div className=\"text-center\">\n No API keys created yet.\n <br />\n Get started and create the first one now\n </div>\n {service.createKey && (\n <Button asChild>\n <Link to=\"/settings/api-keys/new\">Create API Key</Link>\n </Button>\n )}\n </div>\n ) : (\n <ul className=\"grid grid-cols-[minmax(250px,min-content)_1fr_min-content] \">\n {data.map((key: any) => (\n <li\n className=\"border-b border-border p-5 grid grid-cols-subgrid col-span-full gap-2 items-center\"\n key={key.id}\n >\n <div className=\"flex flex-col gap-1 text-sm\">\n {key.description ?? key.id}\n <div className=\"text-muted-foreground text-xs\">\n {key.createdOn && (\n <div>\n Created on {new Date(key.createdOn).toLocaleDateString()}\n </div>\n )}\n {key.expiresOn && (\n <div>\n Expires on {new Date(key.expiresOn).toLocaleDateString()}\n </div>\n )}\n </div>\n </div>\n <div className=\"items-center flex justify-center\">\n <RevealApiKey apiKey={key.key} />\n </div>\n <div className=\"flex gap-2\">\n {service.rollKey && (\n <Button size=\"icon\">\n <RotateCwIcon size={16} />\n </Button>\n )}\n {service.deleteKey && (\n <Button\n variant=\"ghost\"\n size=\"icon\"\n onClick={() => {\n if (!confirm(\"Do you want to delete this key?\")) {\n return;\n }\n\n deleteKeyMutation.mutate(key.id);\n }}\n disabled={deleteKeyMutation.isPending}\n >\n <TrashIcon size={16} />\n </Button>\n )}\n </div>\n </li>\n ))}\n </ul>\n )}\n </div>\n );\n};\n\nconst RevealApiKey = ({ apiKey }: { apiKey: string }) => {\n const [revealed, setRevealed] = useState(false);\n\n return (\n <div className=\"flex gap-2 items-center text-sm\">\n <code className=\"border border-border rounded bg-gray-100 dark:bg-gray-950 p-1 font-mono\">\n {revealed ? apiKey : \"•\".repeat(apiKey.length)}\n </code>\n <Button\n variant=\"outline\"\n onClick={() => setRevealed((prev) => !prev)}\n size=\"icon\"\n >\n {revealed ? <EyeOffIcon size={16} /> : <EyeIcon size={16} />}\n </Button>\n </div>\n );\n};\n","import logger from \"loglevel\";\nimport { Outlet, useRouteError } from \"react-router-dom\";\nimport invariant from \"tiny-invariant\";\nimport { useAuth } from \"../../authentication/hook.js\";\nimport { DevPortalContext } from \"../../core/DevPortalContext.js\";\nimport {\n type ApiIdentityPlugin,\n type DevPortalPlugin,\n} from \"../../core/plugins.js\";\nimport { Button } from \"../../ui/Button.js\";\nimport { CreateApiKey } from \"./CreateApiKey.js\";\nimport { SettingsApiKeys } from \"./SettingsApiKeys.js\";\n\nexport type ApiKeyResults = Promise<ApiKey[]>;\nconst DEFAULT_API_KEY_ENDPOINT =\n \"https://zudoku-rewiringamerica-main-ef9c9c0.d2.zuplo.dev\";\n\nexport type ApiKeyService = {\n getKeys: (context: DevPortalContext) => ApiKeyResults;\n rollKey?: (id: string, context: DevPortalContext) => Promise<void>;\n deleteKey?: (id: string, context: DevPortalContext) => Promise<void>;\n updateKeyDescription?: (\n apiKey: { jd: string; description: string },\n context: DevPortalContext,\n ) => Promise<void>;\n getUsage?: (apiKeys: string[], context: DevPortalContext) => Promise<void>;\n createKey?: (\n apiKey: { description: string; expiresOn?: string },\n context: DevPortalContext,\n ) => Promise<void>;\n};\n\nexport type GetApiKeysOptions = ApiKeyService | { endpoint: string } | object;\n\nexport type ApiKeyPluginOptions = object & GetApiKeysOptions;\n\nexport interface ApiKey {\n id: string;\n description?: string;\n createdOn?: string;\n updatedOn?: string;\n expiresOn?: string;\n key: string;\n}\n\nconst createDefaultHandler = (endpoint: string): ApiKeyService => {\n return {\n deleteKey: async (id, context) => {\n const request = new Request(endpoint + `/v1/developer/api-keys/${id}`, {\n method: \"DELETE\",\n });\n\n await context.signRequest(request);\n\n const response = await fetch(request);\n invariant(response.ok, \"Failed to delete API key\");\n },\n createKey: async (apiKey, context) => {\n const request = new Request(endpoint + `/v1/developer/api-keys`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(apiKey),\n });\n\n await context.signRequest(request);\n\n const response = await fetch(request);\n invariant(response.ok, \"Failed to create API key\");\n },\n getKeys: async (context) => {\n const request = new Request(endpoint + `/v1/developer/api-keys`);\n\n await context.signRequest(request);\n\n const keys = await fetch(request);\n invariant(keys.ok, \"Failed to fetch API keys\");\n\n return await keys.json();\n },\n };\n};\n\nconst ProtectedRoute = () => {\n const auth = useAuth();\n\n // TODO: should we suspend here somehow?\n if (auth.isPending) {\n return null;\n }\n\n return auth.isAuthenticated ? (\n <Outlet />\n ) : (\n <div className=\"flex flex-col justify-center gap-2 items-center h-1/2 my-12\">\n Please login first to view this page\n <Button onClick={() => auth.login()}>Login</Button>\n </div>\n );\n};\n\nconst SettingsErrorBoundary = () => {\n const error = useRouteError();\n logger.error(String(error));\n\n return (\n <div className=\"flex flex-col justify-center gap-2 items-center h-1/2 my-12\">\n <h1>Something went wrong</h1>\n {error instanceof Error && <p>{error.message}</p>}\n </div>\n );\n};\n\nexport const apiKeyPlugin = (\n options: ApiKeyPluginOptions,\n): DevPortalPlugin & ApiIdentityPlugin => {\n const endpoint =\n \"endpoint\" in options ? options.endpoint : DEFAULT_API_KEY_ENDPOINT;\n\n const service =\n \"getKeys\" in options ? options : createDefaultHandler(endpoint);\n\n return {\n getIdentities: async (context) => {\n try {\n const keys = await service.getKeys(context);\n\n return keys.map((key) => ({\n authorizeRequest: (request) => {\n request.headers.set(\"Authorization\", `Bearer ${key.key}`);\n return request;\n },\n id: key.id,\n label: key.description ?? key.id,\n }));\n } catch {\n return [];\n }\n },\n getRoutes: () => {\n // TODO: Make lazy\n return [\n {\n element: <ProtectedRoute />,\n errorElement: <SettingsErrorBoundary />,\n children: [\n {\n path: \"/settings/api-keys\",\n element: <SettingsApiKeys service={service} />,\n },\n {\n path: \"/settings/api-keys/new\",\n element: <CreateApiKey service={service} />,\n },\n ],\n },\n ];\n },\n };\n};\n"],"names":["EyeOff","createLucideIcon","Eye","RotateCw","Trash","isProduction","prefix","invariant","condition","message","provided","value","Input","React","className","type","props","ref","jsx","cn","CreateApiKey","service","context","useDevPortal","navigate","useNavigate","form","useForm","createKeyMutation","useMutation","description","expiresOn","expiresOnDate","addDaysToDate","jsxs","data","Select","SelectTrigger","SelectValue","SelectContent","SelectGroup","option","SelectItem","Button","Link","days","date","SettingsApiKeys","queryClient","useQueryClient","useSuspenseQuery","deleteKeyMutation","id","key","RevealApiKey","RotateCwIcon","TrashIcon","apiKey","revealed","setRevealed","useState","prev","EyeOffIcon","EyeIcon","DEFAULT_API_KEY_ENDPOINT","createDefaultHandler","endpoint","request","response","keys","ProtectedRoute","auth","useAuth","Outlet","SettingsErrorBoundary","error","useRouteError","logger","apiKeyPlugin","options"],"mappings":";;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMA,IAASC,EAAiB,UAAU;AAAA,EACxC,CAAC,QAAQ,EAAE,GAAG,kCAAkC,KAAK,SAAQ,CAAE;AAAA,EAC/D;AAAA,IACE;AAAA,IACA;AAAA,MACE,GAAG;AAAA,MACH,KAAK;AAAA,IACN;AAAA,EACF;AAAA,EACD;AAAA,IACE;AAAA,IACA,EAAE,GAAG,0EAA0E,KAAK,SAAU;AAAA,EAC/F;AAAA,EACD,CAAC,QAAQ,EAAE,IAAI,KAAK,IAAI,MAAM,IAAI,KAAK,IAAI,MAAM,KAAK,SAAQ,CAAE;AAClE,CAAC;ACvBD;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,MAAMC,IAAMD,EAAiB,OAAO;AAAA,EAClC,CAAC,QAAQ,EAAE,GAAG,gDAAgD,KAAK,SAAQ,CAAE;AAAA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MAEF;AAAA,MACL;AAAA,QACE,+BAAUiB,GAAe,EAAA;AAAA,QACzB,oCAAeI,GAAsB,EAAA;AAAA,QACrC,UAAU;AAAA,UACR;AAAA,YACE,MAAM;AAAA,YACN,SAAUxD,gBAAAA,EAAA,IAAA6B,GAAA,EAAgB,SAAA1B,EAAkB,CAAA;AAAA,UAC9C;AAAA,UACA;AAAA,YACE,MAAM;AAAA,YACN,SAAUH,gBAAAA,EAAA,IAAAE,GAAA,EAAa,SAAAC,EAAkB,CAAA;AAAA,UAC3C;AAAA,QACF;AAAA,MACF;AAAA,IAAA;AAAA,EAEJ;AAEJ;","x_google_ignoreList":[0,1,2,3,4]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zudoku.plugin-markdown.js","sources":["../src/lib/plugins/markdown/generateRoutes.tsx","../src/lib/plugins/markdown/index.tsx"],"sourcesContent":["import { Navigate, type RouteObject } from \"react-router-dom\";\nimport { useTopNavigationItem } from \"../../components/context/DevPortalProvider.js\";\nimport { isPathItem } from \"../../components/navigation/util.js\";\nimport { traverseNavigation } from \"../../util/traverseNavigation.js\";\n\nimport {\n MarkdownPluginDefaultOptions,\n MarkdownPluginOptions,\n} from \"./index.js\";\n\nexport const generateRoutes = (\n markdownFiles: MarkdownPluginOptions[\"markdownFiles\"],\n defaultOptions?: MarkdownPluginDefaultOptions,\n): RouteObject[] => {\n const routes = Object.entries(markdownFiles).flatMap(\n ([file, importPromise]) => {\n // @todo we can pass in the folder name and then filter the markdown files based on that path\n const match = file.match(/pages\\/(.*).mdx?$/);\n const path = match?.at(1);\n\n if (!path) return [];\n\n const pathSegments = path.split(\"/\");\n const isIndexFile = pathSegments.at(-1) === \"index\";\n const routePath = isIndexFile\n ? pathSegments.slice(0, -1).join(\"/\")\n : path;\n\n return {\n path: routePath,\n lazy: async () => {\n const { MdxPage } = await import(\"./MdxPage.js\");\n const { default: Component, ...props } = await importPromise();\n return {\n element: (\n <MdxPage\n mdxComponent={Component}\n {...props}\n defaultOptions={defaultOptions}\n />\n ),\n };\n },\n } satisfies RouteObject;\n },\n );\n\n const rootRoutes = Array.from(\n new Set(routes.map((route) => route.path.split(\"/\").at(0))),\n ).map((dir) => ({\n path: `/${dir}`,\n element: <Redirect />,\n }));\n\n return [...routes, ...rootRoutes];\n};\n\nconst Redirect = () => {\n const navItem = useTopNavigationItem();\n\n if (!navItem) return null;\n\n return traverseNavigation(navItem, (node, fullPath) => {\n if (\"children\" in node || !isPathItem(node)) return;\n return <Navigate to={fullPath} replace />;\n });\n};\n","import type { Toc } from \"@stefanprobst/rehype-extract-toc\";\nimport type { MDXProps } from \"mdx/types.js\";\nimport type { DevPortalPlugin } from \"../../core/plugins.js\";\nimport { generateRoutes } from \"./generateRoutes.js\";\n\nexport type MarkdownPluginOptions = {\n markdownFiles: Record<string, () => Promise<MDXImport>>;\n defaultOptions?: MarkdownPluginDefaultOptions;\n};\nexport type MarkdownPluginDefaultOptions = Pick<\n Frontmatter,\n \"toc\" | \"disablePager\"\n>;\n\nexport type Frontmatter = {\n title?: string;\n description?: string;\n category?: string;\n toc?: boolean;\n disablePager?: boolean;\n};\n\nexport type MDXImport = {\n tableOfContents: Toc;\n frontmatter: Frontmatter;\n default: (props: MDXProps) => JSX.Element;\n};\n\nexport const markdownPlugin = ({\n markdownFiles,\n defaultOptions,\n}: MarkdownPluginOptions): DevPortalPlugin => {\n return {\n getRoutes() {\n return generateRoutes(markdownFiles, defaultOptions);\n },\n };\n};\n"],"names":["generateRoutes","markdownFiles","defaultOptions","routes","file","importPromise","match","path","pathSegments","MdxPage","Component","props","jsx","rootRoutes","route","dir","Redirect","navItem","useTopNavigationItem","traverseNavigation","node","fullPath","isPathItem","Navigate","markdownPlugin"],"mappings":";;;;AAUa,MAAAA,IAAiB,CAC5BC,GACAC,MACkB;AAClB,QAAMC,IAAS,OAAO,QAAQF,CAAa,EAAE;AAAA,IAC3C,CAAC,CAACG,GAAMC,CAAa,MAAM;AAEnB,YAAAC,IAAQF,EA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,EAAeC,GAAeC,CAAc;AAAA,EACrD;AAAA;"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import "./jsx-runtime-D7DwziLW.js";
|
|
2
|
-
import { o as t } from "./index-
|
|
2
|
+
import { o as t } from "./index-B2qLeglF.js";
|
|
3
3
|
import "./urql-DMlBWUKL.js";
|
|
4
4
|
import "virtual:zudoku-openapi-worker";
|
|
5
5
|
export {
|
|
6
6
|
t as openApiPlugin
|
|
7
7
|
};
|
|
8
|
+
//# sourceMappingURL=zudoku.plugin-openapi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zudoku.plugin-openapi.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zudoku.plugin-redirect.js","sources":["../src/lib/plugins/redirect/index.tsx"],"sourcesContent":["import { Navigate } from \"react-router-dom\";\nimport type { DevPortalPlugin } from \"../../core/plugins.js\";\n\nexport type Redirect = {\n from: string;\n to: string;\n replace?: boolean;\n};\n\nexport const redirectPlugin = (options: {\n redirects: Redirect[];\n}): DevPortalPlugin => {\n return {\n getRoutes: () =>\n options.redirects.map(({ from, to, replace }) => ({\n path: from,\n element: <Navigate to={to} replace={replace} />,\n })),\n };\n};\n"],"names":["redirectPlugin","options","from","to","replace","jsx","Navigate"],"mappings":";;AASa,MAAAA,IAAiB,CAACC,OAGtB;AAAA,EACL,WAAW,MACTA,EAAQ,UAAU,IAAI,CAAC,EAAE,MAAAC,GAAM,IAAAC,GAAI,SAAAC,SAAe;AAAA,IAChD,MAAMF;AAAA,IACN,SAASG,gBAAAA,EAAAA,IAACC,GAAS,EAAA,IAAAH,GAAQ,SAAAC,EAAkB,CAAA;AAAA,EAAA,EAC7C;AAAA;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zudoku",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.29",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -159,8 +159,8 @@
|
|
|
159
159
|
},
|
|
160
160
|
"scripts": {
|
|
161
161
|
"build": "tsc --project tsconfig.json",
|
|
162
|
-
"build:vite": "vite build && pnpm run hack:fix-worker-paths",
|
|
163
|
-
"build:standalone:vite": "vite build --config vite.standalone.config.ts
|
|
162
|
+
"build:vite": "vite build && pnpm run hack:fix-worker-paths lib",
|
|
163
|
+
"build:standalone:vite": "vite build --config vite.standalone.config.ts",
|
|
164
164
|
"build:standalone:html": "cp ./src/app/standalone.html ./standalone/standalone.html && cp ./src/app/demo.html ./standalone/demo.html && cp ./src/app/demo-cdn.html ./standalone/index.html",
|
|
165
165
|
"hack:fix-worker-paths": "node ./scripts/hack-worker.mjs",
|
|
166
166
|
"clean": "tsc --build --clean",
|
package/src/app/demo-cdn.html
CHANGED
|
@@ -5,8 +5,16 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Zudoku Demo</title>
|
|
8
|
-
<script
|
|
9
|
-
|
|
8
|
+
<script
|
|
9
|
+
type="module"
|
|
10
|
+
crossorigin
|
|
11
|
+
src="https://cdn.zudoku.dev/latest/demo.js"
|
|
12
|
+
></script>
|
|
13
|
+
<link
|
|
14
|
+
rel="stylesheet"
|
|
15
|
+
crossorigin
|
|
16
|
+
href="https://cdn.zudoku.dev/latest/style.css"
|
|
17
|
+
/>
|
|
10
18
|
</head>
|
|
11
19
|
<body>
|
|
12
20
|
<div id="root"></div>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import {
|
|
3
|
+
cacheExchange,
|
|
4
|
+
Client,
|
|
5
|
+
fetchExchange,
|
|
6
|
+
mapExchange,
|
|
7
|
+
} from "../util/urql.js";
|
|
8
|
+
import { createServer } from "./createServer.js";
|
|
9
|
+
import { CreateClientFunction } from "./interfaces.js";
|
|
10
|
+
|
|
11
|
+
export type WorkerGraphQLMessage = { id: string; body: string };
|
|
12
|
+
|
|
13
|
+
const localServer = createServer();
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates an in memory Client that does not use Workers. This allows
|
|
17
|
+
* developers to run the simple standalone version of zudoku using the CDN
|
|
18
|
+
* hosted scripts. Worker's cannot be loaded cross domain so in this case
|
|
19
|
+
* we sacrifice performance for making it work cross domain.
|
|
20
|
+
*/
|
|
21
|
+
export const createClient: CreateClientFunction = () => {
|
|
22
|
+
return new Client({
|
|
23
|
+
url: "/__z/graphql",
|
|
24
|
+
// Custom fetch to send the GraphQL request to the worker and convert the response back to a `Response` object
|
|
25
|
+
fetch: async (req, init) => {
|
|
26
|
+
if (!init?.body) throw new Error("No body");
|
|
27
|
+
const response = await localServer.fetch(
|
|
28
|
+
new Request("/__z/graphql", {
|
|
29
|
+
method: "POST",
|
|
30
|
+
body: init.body,
|
|
31
|
+
headers: {
|
|
32
|
+
"Content-Type": "application/json",
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
);
|
|
36
|
+
return response;
|
|
37
|
+
// port.postMessage({
|
|
38
|
+
// id: e.data.id,
|
|
39
|
+
// body: await response.text(),
|
|
40
|
+
// } satisfies WorkerGraphQLMessage);
|
|
41
|
+
},
|
|
42
|
+
exchanges: [
|
|
43
|
+
cacheExchange,
|
|
44
|
+
mapExchange({
|
|
45
|
+
onError(error, operation) {
|
|
46
|
+
console.error(error);
|
|
47
|
+
console.groupCollapsed("Operation info");
|
|
48
|
+
console.log("body", operation.query.loc?.source.body.trim());
|
|
49
|
+
console.log("variables", operation.variables);
|
|
50
|
+
console.groupEnd();
|
|
51
|
+
},
|
|
52
|
+
}),
|
|
53
|
+
fetchExchange,
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { useLogger } from "@envelop/core";
|
|
2
|
+
import { createGraphQLServer } from "../../../oas/graphql/index.js";
|
|
3
|
+
|
|
4
|
+
const map = new Map<string, number>();
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Creates the GraphQL server
|
|
8
|
+
*/
|
|
9
|
+
export const createServer = () =>
|
|
10
|
+
createGraphQLServer({
|
|
11
|
+
plugins: [
|
|
12
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
13
|
+
useLogger({
|
|
14
|
+
logFn: (eventName, { args }) => {
|
|
15
|
+
if (import.meta.env.PROD) return;
|
|
16
|
+
|
|
17
|
+
if (eventName.endsWith("-start")) {
|
|
18
|
+
map.set(`${eventName}-${args.operationName}`, performance.now());
|
|
19
|
+
} else if (eventName.endsWith("-end")) {
|
|
20
|
+
const startEvent = eventName.replace("-end", "-start");
|
|
21
|
+
const start = map.get(`${startEvent}-${args.operationName}`);
|
|
22
|
+
if (start) {
|
|
23
|
+
// eslint-disable-next-line no-console
|
|
24
|
+
console.log(
|
|
25
|
+
`${args.operationName} query took ${performance.now() - start}ms`,
|
|
26
|
+
);
|
|
27
|
+
map.delete(`${startEvent}-${args.operationName}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
],
|
|
33
|
+
});
|
package/src/lib/plugins/openapi/{worker/createSharedWorkerClient.ts → client/createWorkerClient.ts}
RENAMED
|
@@ -7,11 +7,19 @@ import {
|
|
|
7
7
|
fetchExchange,
|
|
8
8
|
mapExchange,
|
|
9
9
|
} from "../util/urql.js";
|
|
10
|
+
import { CreateClientFunction } from "./interfaces.js";
|
|
10
11
|
|
|
11
12
|
export type WorkerGraphQLMessage = { id: string; body: string };
|
|
12
13
|
|
|
13
14
|
const ulid = monotonicFactory();
|
|
14
|
-
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* This loads the client from a worker and uses mess port to send requests
|
|
18
|
+
* and responses between the main thread and the worker.
|
|
19
|
+
*/
|
|
20
|
+
export const createClient: CreateClientFunction = () => {
|
|
21
|
+
// NOTE: This URL needs to be inline with the SharedWorker otherwse
|
|
22
|
+
// vite build does not recognize the worker file as a module.
|
|
15
23
|
const worker = new SharedWorker(new URL("./worker.ts", import.meta.url), {
|
|
16
24
|
type: "module",
|
|
17
25
|
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { createServer } from "./createServer.js";
|
|
2
|
+
import { type WorkerGraphQLMessage } from "./createWorkerClient.js";
|
|
3
|
+
|
|
4
|
+
const localServer = createServer();
|
|
5
|
+
|
|
6
|
+
const worker = self as unknown as SharedWorkerGlobalScope;
|
|
7
|
+
|
|
8
|
+
worker.addEventListener(
|
|
9
|
+
"connect",
|
|
10
|
+
function (event: MessageEvent<{ id: string; body: string }>) {
|
|
11
|
+
const port = event.ports[0];
|
|
12
|
+
|
|
13
|
+
port.onmessage = async function (e) {
|
|
14
|
+
const response = await localServer.fetch(
|
|
15
|
+
new Request("/__z/graphql", {
|
|
16
|
+
method: "POST",
|
|
17
|
+
body: e.data.body,
|
|
18
|
+
headers: {
|
|
19
|
+
"Content-Type": "application/json",
|
|
20
|
+
},
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
port.postMessage({
|
|
25
|
+
id: e.data.id,
|
|
26
|
+
body: await response.text(),
|
|
27
|
+
} satisfies WorkerGraphQLMessage);
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
);
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
fetchExchange,
|
|
12
12
|
} from "./util/urql.js";
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { createClient } from "virtual:zudoku-openapi-worker";
|
|
15
15
|
import { OasPluginConfig } from "./interfaces.js";
|
|
16
16
|
|
|
17
17
|
const GetCategoriesQuery = graphql(`
|
|
@@ -42,7 +42,7 @@ export const openApiPlugin = (config: OasPluginConfig): DevPortalPlugin => {
|
|
|
42
42
|
url: config.server,
|
|
43
43
|
exchanges: [cacheExchange, fetchExchange],
|
|
44
44
|
})
|
|
45
|
-
:
|
|
45
|
+
: createClient();
|
|
46
46
|
|
|
47
47
|
return {
|
|
48
48
|
getHead: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { createClient } from "./openapi/client/createWorkerClient.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createSharedWorkerClient.js","sourceRoot":"","sources":["../../../../../src/lib/plugins/openapi/worker/createSharedWorkerClient.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EACL,aAAa,EACb,MAAM,EACN,aAAa,EACb,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAIzB,MAAM,IAAI,GAAG,gBAAgB,EAAE,CAAC;AAChC,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,MAAM,MAAM,GAAG,IAAI,YAAY,CAAC,IAAI,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;QACvE,IAAI,EAAE,QAAQ;KACf,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE,EAAE;QACrB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC,CAAC;IAEF,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;IAEpB,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,mBAAmB,EAAU,CAAC;IAExD,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAqC,EAAE,EAAE;QAChE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC,CAAC;IAEF,OAAO,IAAI,MAAM,CAAC;QAChB,GAAG,EAAE,cAAc;QACnB,8GAA8G;QAC9G,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;YAC1B,IAAI,CAAC,IAAI,EAAE,IAAI;gBAAE,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;YAE5C,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC;YAClB,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;gBACtB,EAAE;gBACF,IAAI,EAAE,IAAI,CAAC,IAAc;aACK,CAAC,CAAC;YAElC,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,EAAE,CAAC,CAAC;YAE/B,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;gBACxB,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;iBACnC;aACF,CAAC,CAAC;QACL,CAAC;QACD,SAAS,EAAE;YACT,aAAa;YACb,WAAW,CAAC;gBACV,OAAO,CAAC,KAAK,EAAE,SAAS;oBACtB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;oBACrB,OAAO,CAAC,cAAc,CAAC,gBAAgB,CAAC,CAAC;oBACzC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;oBAC7D,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;oBAC9C,OAAO,CAAC,QAAQ,EAAE,CAAC;gBACrB,CAAC;aACF,CAAC;YACF,aAAa;SACd;KACF,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function createSharedWorker(): SharedWorker;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shared-worker.js","sourceRoot":"","sources":["../../../../../src/lib/plugins/openapi/worker/shared-worker.ts"],"names":[],"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WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAClE,CAAC;wBACF,GAAG,CAAC,MAAM,CAAC,GAAG,UAAU,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC;oBACpD,CAAC;gBACH,CAAC;YACH,CAAC;SACF,CAAC;KACH;CACF,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,IAA0C,CAAC;AAE1D,MAAM,CAAC,gBAAgB,CACrB,SAAS,EACT,UAAU,KAAiD;IACzD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE5B,IAAI,CAAC,SAAS,GAAG,KAAK,WAAW,CAAC;QAChC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,KAAK,CACtC,IAAI,OAAO,CAAC,cAAc,EAAE;YAC1B,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI;YACjB,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CACH,CAAC;QAEF,IAAI,CAAC,WAAW,CAAC;YACf,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE;YACb,IAAI,EAAE,MAAM,QAAQ,CAAC,IAAI,EAAE;SACG,CAAC,CAAC;IACpC,CAAC,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { useLogger } from "@envelop/core";
|
|
2
|
-
import { createGraphQLServer } from "../../../oas/graphql/index.js";
|
|
3
|
-
import { type WorkerGraphQLMessage } from "./createSharedWorkerClient.js";
|
|
4
|
-
|
|
5
|
-
const map = new Map<string, number>();
|
|
6
|
-
|
|
7
|
-
const localServer = createGraphQLServer({
|
|
8
|
-
plugins: [
|
|
9
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
10
|
-
useLogger({
|
|
11
|
-
logFn: (eventName, { args }) => {
|
|
12
|
-
if (import.meta.env.PROD) return;
|
|
13
|
-
|
|
14
|
-
if (eventName.endsWith("-start")) {
|
|
15
|
-
map.set(`${eventName}-${args.operationName}`, performance.now());
|
|
16
|
-
} else if (eventName.endsWith("-end")) {
|
|
17
|
-
const startEvent = eventName.replace("-end", "-start");
|
|
18
|
-
const start = map.get(`${startEvent}-${args.operationName}`);
|
|
19
|
-
if (start) {
|
|
20
|
-
// eslint-disable-next-line no-console
|
|
21
|
-
console.log(
|
|
22
|
-
`${args.operationName} query took ${performance.now() - start}ms`,
|
|
23
|
-
);
|
|
24
|
-
map.delete(`${startEvent}-${args.operationName}`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
}),
|
|
29
|
-
],
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const worker = self as unknown as SharedWorkerGlobalScope;
|
|
33
|
-
|
|
34
|
-
worker.addEventListener(
|
|
35
|
-
"connect",
|
|
36
|
-
function (event: MessageEvent<{ id: string; body: string }>) {
|
|
37
|
-
const port = event.ports[0];
|
|
38
|
-
|
|
39
|
-
port.onmessage = async function (e) {
|
|
40
|
-
const response = await localServer.fetch(
|
|
41
|
-
new Request("/__z/graphql", {
|
|
42
|
-
method: "POST",
|
|
43
|
-
body: e.data.body,
|
|
44
|
-
headers: {
|
|
45
|
-
"Content-Type": "application/json",
|
|
46
|
-
},
|
|
47
|
-
}),
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
port.postMessage({
|
|
51
|
-
id: e.data.id,
|
|
52
|
-
body: await response.text(),
|
|
53
|
-
} satisfies WorkerGraphQLMessage);
|
|
54
|
-
};
|
|
55
|
-
},
|
|
56
|
-
);
|
|
File without changes
|