diff --git a/deno.jsonc b/deno.jsonc index a67ef7e..07d66ce 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -3,7 +3,7 @@ "imports": { "deno_std/": "https://deno.land/std@0.208.0/", "esm.sh/": "https://esm.sh/v135/", - "rollup": "npm:@rollup/wasm-node@4.6.0", + "rollup": "npm:@rollup/wasm-node@4.6.1", "@happy-dom/global-registrator": "npm:@happy-dom/global-registrator" }, "scopes": {}, diff --git a/deno.lock b/deno.lock index 2d5af3c..a99e921 100644 --- a/deno.lock +++ b/deno.lock @@ -3,8 +3,8 @@ "packages": { "specifiers": { "npm:@happy-dom/global-registrator": "npm:@happy-dom/global-registrator@12.10.3", - "npm:@rollup/wasm-node@4.6.0": "npm:@rollup/wasm-node@4.6.0", - "npm:@swc/wasm@1.3.99": "npm:@swc/wasm@1.3.99" + "npm:@rollup/wasm-node@4.6.1": "npm:@rollup/wasm-node@4.6.1", + "npm:@swc/wasm@1.3.100": "npm:@swc/wasm@1.3.100" }, "npm": { "@happy-dom/global-registrator@12.10.3": { @@ -13,14 +13,14 @@ "happy-dom": "happy-dom@12.10.3" } }, - "@rollup/wasm-node@4.6.0": { - "integrity": "sha512-8uWEACE/DodiN8Bjqlo2IvqphQ2taMCT9S02Ol6ra64a5PsD/s7KGSZXwqQgcY5N/ntRhlUO5ryQ/C6oT4TIXA==", + "@rollup/wasm-node@4.6.1": { + "integrity": "sha512-Mh6TSuMLoK9n3uLKa5r1NdX+BGZJyl5L+dx/MH9K2l9Dzk/R0w1XQMs1aP/quv3KB/kn6UIUbJmXNReIW5032Q==", "dependencies": { "fsevents": "fsevents@2.3.3" } }, - "@swc/wasm@1.3.99": { - "integrity": "sha512-9TYR7Gdh5fWi019r5TaerZfdKCjSdgf+IM7XMJnSH7ZAWjTNw0TmXVxSOY+7xXHHFbY0+lzje1qJ+lfgdvZYag==", + "@swc/wasm@1.3.100": { + "integrity": "sha512-rCi5+dUBta1jgrT5xGeAIY8yeJ/o/8PSFmcpsTVe2I2aSXkcHX2c1G1/tS86O65rMlwEiBmGvm1txEMG89me6Q==", "dependencies": {} }, "css.escape@1.5.1": { diff --git a/notion-kroki.user.js b/notion-kroki.user.js index ae438bd..4c663d9 100644 --- a/notion-kroki.user.js +++ b/notion-kroki.user.js @@ -67,9 +67,8 @@ function main() { _debug(`svgUrl:${svgUrl}`); if (preSvgUrl === svgUrl) { continue; - } else { - parentElement.removeChild(preCreatedNode); } + parentElement.removeChild(preCreatedNode); } parentElement.appendChild(div); } diff --git a/notion-kroki.user.js.map b/notion-kroki.user.js.map index e750a43..b2d3dd0 100644 --- a/notion-kroki.user.js.map +++ b/notion-kroki.user.js.map @@ -1 +1 @@ -{"version":3,"file":"notion-kroki.user.js","sources":["src/common/utils.ts","src/main.ts","src/index.ts"],"sourcesContent":["export type Any = Parameters[0];\n\nexport function debounce<\n T extends (...args: Any[]) => void,\n P extends Parameters,\n>(func: T, wait: number): (...args: P) => void {\n let timeoutId: ReturnType | undefined;\n return (...args: P) => {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => {\n timeoutId = undefined;\n func(...args);\n }, wait);\n };\n}\n\nexport function _debug(...data: Any[]): void {\n if (isDebugMode()) {\n console.log(...data);\n }\n}\n\nexport function isDebugMode(): boolean {\n return !!localStorage.getItem(\"debug\");\n}\n","import type { KrokiOption } from \"./@types/types.ts\";\nimport { _debug, debounce } from \"./common/utils.ts\";\nconst defaultConfig: KrokiOption = {\n serverPath: \"https://kroki.io/\",\n};\n\nexport function main(element: HTMLElement | null = null) {\n const blocks: HTMLElement[] = Array.from(\n (element || document.body).querySelectorAll(\"*\"),\n ).filter((it) => it.innerHTML.trim().startsWith(\"//kroki \")) as HTMLElement[];\n for (const codeDiv of blocks) {\n const lines = codeDiv.textContent!.split(\"\\n\");\n const type = lines[0].replace(\"//kroki\", \"\").trim();\n if (!type.trim()) continue;\n const data = lines.filter((_value, index) => index !== 0).join(\"\\n\");\n if (!data.trim()) continue;\n const svgUrl = plant(data, type, defaultConfig);\n const div = document.createElement(\"div\");\n div.setAttribute(\n \"style\",\n \"display: flex; flex-direction: row; place-content: center;\",\n );\n div.setAttribute(\"notion-kroki\", \"true\");\n div.innerHTML =\n ``;\n\n const parentElement = codeDiv.parentElement!.parentElement!;\n const preCreatedNode = parentElement.querySelector(\"div[notion-kroki]\");\n if (preCreatedNode) {\n const preSvgUrl = preCreatedNode.firstElementChild!.getAttribute(\"data\");\n _debug(`preSvgUrl:${preSvgUrl}`);\n _debug(`svgUrl:${svgUrl}`);\n if (preSvgUrl === svgUrl) {\n continue;\n } else {\n parentElement.removeChild(preCreatedNode);\n }\n }\n\n parentElement.appendChild(div);\n }\n}\n\nfunction textEncode(str: string) {\n return new TextEncoder().encode(str);\n}\n\nfunction plant(content: string, type: string, config: KrokiOption) {\n _debug(`kroki render type: ${type}`);\n _debug(`kroki render content:\\n${content}`);\n\n const urlPrefix = `${config.serverPath + type}/svg/`;\n const data: Uint8Array = textEncode(content);\n const compressed: string = strFromU8(fflate.zlibSync(data, { level: 9 }));\n const result: string = btoa(compressed)\n .replace(/\\+/g, \"-\")\n .replace(/\\//g, \"_\");\n const svgUrl: string = urlPrefix + result;\n\n return svgUrl;\n}\n\nexport function init_listener() {\n if (typeof MutationObserver !== typeof undefined) {\n new MutationObserver(check).observe(document, {\n childList: true,\n subtree: true,\n });\n }\n}\n\nconst render = debounce(main, 100);\n\nfunction check(mutations: MutationRecord[], _observer: MutationObserver) {\n // _debug(\"mutations\", mutations);\n render();\n}\n\nfunction strFromU8(dat: Uint8Array) {\n let r = \"\";\n const s = 2 ** 15;\n for (let i = 0; i < dat.length; i += s) {\n r += String.fromCharCode(...dat.subarray(i, i + s));\n }\n return r;\n}\n","import { init_listener, main } from \"./main.ts\";\nmain();\ninit_listener();\n"],"names":["debounce","func","wait","timeoutId","args","clearTimeout","setTimeout","undefined","_debug","data","isDebugMode","console","log","localStorage","getItem","defaultConfig","serverPath","main","element","blocks","Array","from","document","body","querySelectorAll","filter","it","innerHTML","trim","startsWith","codeDiv","lines","textContent","split","type","replace","_value","index","join","svgUrl","plant","div","createElement","setAttribute","parentElement","preCreatedNode","querySelector","preSvgUrl","firstElementChild","getAttribute","removeChild","appendChild","textEncode","str","TextEncoder","encode","content","config","urlPrefix","compressed","strFromU8","fflate","zlibSync","level","result","btoa","init_listener","MutationObserver","check","observe","childList","subtree","render","mutations","_observer","dat","r","s","i","length","String","fromCharCode","subarray"],"mappings":";;;;;;;;;;;;;;;;;;;AAEO,SAASA,QAAAA,CAGdC,IAAO,EAAEC,IAAY,EAAA;IACrB,IAAIC,SAAAA,CAAAA;IACJ,OAAO,WAAA;AAAIC,QAAAA,IAAAA,IAAAA,IAAAA,GAAAA,SAAAA,CAAAA,MAAAA,EAAAA,IAAAA,GAAAA,IAAAA,KAAAA,CAAAA,IAAAA,CAAAA,EAAAA,IAAAA,GAAAA,CAAAA,EAAAA,IAAAA,GAAAA,IAAAA,EAAAA,IAAAA,EAAAA,CAAAA;AAAAA,YAAAA,IAAAA,CAAAA,IAAAA,CAAAA,GAAAA,SAAAA,CAAAA,IAAAA,CAAAA,CAAAA;;QACTC,YAAaF,CAAAA,SAAAA,CAAAA,CAAAA;AACbA,QAAAA,SAAAA,GAAYG,UAAW,CAAA,IAAA;YACrBH,SAAYI,GAAAA,SAAAA,CAAAA;YACZN,IAAQG,CAAAA,GAAAA,IAAAA,CAAAA,CAAAA;SACPF,EAAAA,IAAAA,CAAAA,CAAAA;AACL,KAAA,CAAA;AACF,CAAA;AAEO,SAASM,MAAAA,GAAAA;IAAO,IAAA,IAAA,IAAA,GAAA,SAAA,CAAA,MAAA,EAAGC,IAAH,GAAA,IAAA,KAAA,CAAA,IAAA,CAAA,EAAA,IAAA,GAAA,CAAA,EAAA,IAAA,GAAA,IAAA,EAAA,IAAA,EAAA,CAAA;QAAGA,IAAH,CAAA,IAAA,CAAA,GAAA,SAAA,CAAA,IAAc,CAAA,CAAA;;AACnC,IAAA,IAAIC,WAAe,EAAA,EAAA;AACjBC,QAAAA,OAA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AAI,GAAA,EAAA,CAAA;AACR,IAAA,MAAMC,IAAI,CAAK,IAAA,EAAA,CAAA;IACf,IAAK,IAAIC,IAAI,CAAGA,EAAAA,CAAAA,GAAIH,IAAII,MAAM,EAAED,KAAKD,CAAG,CAAA;AACtCD,QAAAA,CAAAA,IAAKI,OAAOC,YAAY,CAAA,GAAIN,IAAIO,QAAQ,CAACJ,GAAGA,CAAID,GAAAA,CAAAA,CAAAA,CAAAA,CAAAA;AAClD,KAAA;IACA,OAAOD,CAAAA,CAAAA;AACT;;ACpFA3D,IAAAA,EAAAA,CAAAA;AACAiD,aAAAA,EAAAA"} \ No newline at end of file +{"version":3,"file":"notion-kroki.user.js","sources":["src/common/utils.ts","src/main.ts","src/index.ts"],"sourcesContent":["export type Any = Parameters[0];\n\nexport function debounce<\n T extends (...args: Any[]) => void,\n P extends Parameters,\n>(func: T, wait: number): (...args: P) => void {\n let timeoutId: ReturnType | undefined;\n return (...args: P) => {\n clearTimeout(timeoutId);\n timeoutId = setTimeout(() => {\n timeoutId = undefined;\n func(...args);\n }, wait);\n };\n}\n\nexport function _debug(...data: Any[]): void {\n if (isDebugMode()) {\n console.log(...data);\n }\n}\n\nexport function isDebugMode(): boolean {\n return !!localStorage.getItem(\"debug\");\n}\n","import type { KrokiOption } from \"./@types/types.ts\";\nimport { _debug, debounce } from \"./common/utils.ts\";\nconst defaultConfig: KrokiOption = {\n serverPath: \"https://kroki.io/\",\n};\n\nexport function main(element: HTMLElement | null = null) {\n const blocks: HTMLElement[] = Array.from(\n (element || document.body).querySelectorAll(\"*\"),\n ).filter((it) => it.innerHTML.trim().startsWith(\"//kroki \")) as HTMLElement[];\n for (const codeDiv of blocks) {\n const lines = codeDiv.textContent!.split(\"\\n\");\n const type = lines[0].replace(\"//kroki\", \"\").trim();\n if (!type.trim()) continue;\n const data = lines.filter((_value, index) => index !== 0).join(\"\\n\");\n if (!data.trim()) continue;\n const svgUrl = plant(data, type, defaultConfig);\n const div = document.createElement(\"div\");\n div.setAttribute(\n \"style\",\n \"display: flex; flex-direction: row; place-content: center;\",\n );\n div.setAttribute(\"notion-kroki\", \"true\");\n div.innerHTML =\n ``;\n\n const parentElement = codeDiv.parentElement!.parentElement!;\n const preCreatedNode = parentElement.querySelector(\"div[notion-kroki]\");\n if (preCreatedNode) {\n const preSvgUrl = preCreatedNode.firstElementChild!.getAttribute(\"data\");\n _debug(`preSvgUrl:${preSvgUrl}`);\n _debug(`svgUrl:${svgUrl}`);\n if (preSvgUrl === svgUrl) {\n continue;\n }\n parentElement.removeChild(preCreatedNode);\n }\n\n parentElement.appendChild(div);\n }\n}\n\nfunction textEncode(str: string) {\n return new TextEncoder().encode(str);\n}\n\nfunction plant(content: string, type: string, config: KrokiOption) {\n _debug(`kroki render type: ${type}`);\n _debug(`kroki render content:\\n${content}`);\n\n const urlPrefix = `${config.serverPath + type}/svg/`;\n const data: Uint8Array = textEncode(content);\n const compressed: string = strFromU8(fflate.zlibSync(data, { level: 9 }));\n const result: string = btoa(compressed)\n .replace(/\\+/g, \"-\")\n .replace(/\\//g, \"_\");\n const svgUrl: string = urlPrefix + result;\n\n return svgUrl;\n}\n\nexport function init_listener() {\n if (typeof MutationObserver !== typeof undefined) {\n new MutationObserver(check).observe(document, {\n childList: true,\n subtree: true,\n });\n }\n}\n\nconst render = debounce(main, 100);\n\nfunction check(mutations: MutationRecord[], _observer: MutationObserver) {\n // _debug(\"mutations\", mutations);\n render();\n}\n\nfunction strFromU8(dat: Uint8Array) {\n let r = \"\";\n const s = 2 ** 15;\n for (let i = 0; i < dat.length; i += s) {\n r += String.fromCharCode(...dat.subarray(i, i + s));\n }\n return r;\n}\n","import { init_listener, main } from \"./main.ts\";\nmain();\ninit_listener();\n"],"names":["debounce","func","wait","timeoutId","args","clearTimeout","setTimeout","undefined","_debug","data","isDebugMode","console","log","localStorage","getItem","defaultConfig","serverPath","main","element","blocks","Array","from","document","body","querySelectorAll","filter","it","innerHTML","trim","startsWith","codeDiv","lines","textContent","split","type","replace","_value","index","join","svgUrl","plant","div","createElement","setAttribute","parentElement","preCreatedNode","querySelector","preSvgUrl","firstElementChild","getAttribute","removeChild","appendChild","textEncode","str","TextEncoder","encode","content","config","urlPrefix","compressed","strFromU8","fflate","zlibSync","level","result","btoa","init_listener","MutationObserver","check","observe","childList","subtree","render","mutations","_observer","dat","r","s","i","length","String","fromCharCode","subarray"],"mappings":";;;;;;;;;;;;;;;;;;;AAEO,SAASA,QAAAA,CAGdC,IAAO,EAAEC,IAAY,EAAA;IACrB,IAAIC,SAAAA,CAAAA;IACJ,OAAO,WAAA;AAAIC,QAAAA,IAAAA,IAAAA,IAAAA,GAAAA,SAAAA,CAAAA,MAAAA,EAAAA,IAAAA,GAAAA,IAAAA,KAAAA,CAAAA,IAAAA,CAAAA,EAAAA,IAAAA,GAAAA,CAAAA,EAAAA,IAAAA,GAAAA,IAAAA,EAAAA,IAAAA,EAAAA,CAAAA;AAAAA,YAAAA,IAAAA,CAAAA,IAAAA,CAAAA,GAAAA,SAAAA,CAAAA,IAAAA,CAAAA,CAAAA;;QACTC,YAAaF,CAAAA,SAAAA,CAAAA,CAAAA;AACbA,QAAAA,SAAAA,GAAYG,UAAW,CAAA,IAAA;YACrBH,SAAYI,GAAAA,SAAAA,CAAAA;YACZN,IAAQG,CAAAA,GAAAA,IAAAA,CAAAA,CAAAA;SACPF,EAAAA,IAAAA,CAAAA,CAAAA;AACL,KAAA,CAAA;AACF,CAAA;AAEO,SAASM,MAAAA,GAAAA;IAAO,IAAA,IAAA,IAAA,GAAA,SAAA,CAAA,MAAA,EAAGC,IAAH,GAAA,IAAA,KAAA,CAAA,IAAA,CAAA,EAAA,IAAA,GAAA,CAAA,EAAA,IAAA,GAAA,IAAA,EAAA,IAAA,EAAA,CAAA;QAAGA,IAAH,CAAA,IAAA,CAAA,GAAA,SAAA,CAAA,IAAc,CAAA,CAAA;;AACnC,IAAA,IAAIC,WAAe,EAAA,EAAA;AACjBC,QAAAA,OAAAA,CAAQC,GAAG,CAAIH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AAMC,IAAI,CAAK,IAAA,EAAA,CAAA;IACf,IAAK,IAAIC,IAAI,CAAGA,EAAAA,CAAAA,GAAIH,IAAII,MAAM,EAAED,KAAKD,CAAG,CAAA;AACtCD,QAAAA,CAAAA,IAAKI,OAAOC,YAAY,CAAA,GAAIN,IAAIO,QAAQ,CAACJ,GAAGA,CAAID,GAAAA,CAAAA,CAAAA,CAAAA,CAAAA;AAClD,KAAA;IACA,OAAOD,CAAAA,CAAAA;AACT;;ACnFA3D,IAAAA,EAAAA,CAAAA;AACAiD,aAAAA,EAAAA"} \ No newline at end of file diff --git a/rollup.config.ts b/rollup.config.ts index a52815b..483d28b 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -1,4 +1,4 @@ -import * as swc from "npm:@swc/wasm@1.3.99"; +import * as swc from "npm:@swc/wasm@1.3.100"; import { meta } from "./build-common.ts"; import { rollup } from "./deps.ts"; import denoResolve from "./rollup-deno-plugin.ts"; diff --git a/src/main.ts b/src/main.ts index f6e177d..73e9623 100644 --- a/src/main.ts +++ b/src/main.ts @@ -32,9 +32,8 @@ export function main(element: HTMLElement | null = null) { _debug(`svgUrl:${svgUrl}`); if (preSvgUrl === svgUrl) { continue; - } else { - parentElement.removeChild(preCreatedNode); } + parentElement.removeChild(preCreatedNode); } parentElement.appendChild(div); diff --git a/test/common/base-test.ts b/test/common/base-test.ts index 2a691dc..28ab2da 100644 --- a/test/common/base-test.ts +++ b/test/common/base-test.ts @@ -1,5 +1,5 @@ import { afterEach, beforeEach, describe } from "deno_std/testing/bdd.ts"; -import { init, tearDown } from "../common/dom-env-init.ts"; +import { init, tearDown } from "./dom-env-init.ts"; export const baseTest = describe("base case", () => { beforeEach(async () => {