@adartem/adlib-attributes 0.1.7 → 0.1.8
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/attributes.js +30 -30
- package/attributes.js.map +1 -1
- package/dist/{chunk-IEGIKJKW.js → chunk-5M74UMX2.js} +9 -5
- package/dist/chunk-5M74UMX2.js.map +7 -0
- package/dist/{chunk-NS2GB4WB.js → chunk-UIV7OVTN.js} +2 -2
- package/dist/{chunk-M2KO765Q.js → chunk-XUPOHV3Q.js} +2 -2
- package/dist/{dist-RQZGUXDL.js → dist-3BLHGYNR.js} +3 -3
- package/dist/{dist-H4ILPDRU.js → dist-3EOSRL3F.js} +2 -2
- package/dist/{dist-D2X7FLMD.js → dist-5DVLAJX5.js} +2 -2
- package/dist/{dist-ALT6N2V6.js → dist-5UUESGNG.js} +2 -2
- package/dist/{dist-RAOZ6VUA.js → dist-DJUTU32K.js} +2 -2
- package/dist/{dist-KU26ZFEG.js → dist-DN5N4ST4.js} +2 -2
- package/dist/{dist-D2J4YZM6.js → dist-EAHK557K.js} +2 -2
- package/dist/{dist-XTGERRGU.js → dist-EMS7RS72.js} +2 -2
- package/dist/{dist-KDCRSMGT.js → dist-EOXPLOSM.js} +2 -2
- package/dist/{dist-4EIQOOMJ.js → dist-GQELAMZW.js} +2 -2
- package/dist/{dist-UFMW7V6T.js → dist-HUIPJXH7.js} +3 -3
- package/dist/{dist-YAVVMJ7W.js → dist-IE7YTDEI.js} +2 -2
- package/dist/{dist-QPNIGMZA.js → dist-IVRPGD7K.js} +2 -2
- package/dist/{dist-V7I3FQX7.js → dist-IZE4BFP6.js} +2 -2
- package/dist/{dist-KF5AKQ52.js → dist-NGUFAZCM.js} +2 -2
- package/dist/{dist-IDJRFWAH.js → dist-NO72HDAS.js} +2 -2
- package/dist/{dist-DOOWCYTM.js → dist-OVX6MUFU.js} +2 -2
- package/dist/{dist-T4V65O5X.js → dist-Q6DJ7QAM.js} +2 -2
- package/dist/{dist-46N2ZXQQ.js → dist-QCYMONV3.js} +2 -2
- package/dist/{dist-YGJKGMK6.js → dist-QURXL6SQ.js} +2 -2
- package/dist/{dist-GQHJZHTH.js → dist-SECMRLIE.js} +2 -2
- package/dist/{dist-MBFKX56S.js → dist-UDAN4UWT.js} +3 -3
- package/dist/{dist-7GSHUMRU.js → dist-V4UG63VI.js} +2 -2
- package/dist/{dist-M6QCD7TL.js → dist-VMECMESW.js} +4 -4
- package/dist/{dist-BXD5YEF3.js → dist-VPOLJT37.js} +3 -3
- package/dist/{dist-NOIPAOTU.js → dist-VTPYNBIM.js} +2 -2
- package/dist/{dist-6YSNCGWO.js → dist-X423DKFG.js} +3 -3
- package/dist/{dist-GLBAV2CS.js → dist-ZDRNCFPI.js} +2 -2
- package/package.json +8 -8
- package/dist/chunk-IEGIKJKW.js.map +0 -7
- /package/dist/{chunk-NS2GB4WB.js.map → chunk-UIV7OVTN.js.map} +0 -0
- /package/dist/{chunk-M2KO765Q.js.map → chunk-XUPOHV3Q.js.map} +0 -0
- /package/dist/{dist-RQZGUXDL.js.map → dist-3BLHGYNR.js.map} +0 -0
- /package/dist/{dist-H4ILPDRU.js.map → dist-3EOSRL3F.js.map} +0 -0
- /package/dist/{dist-D2X7FLMD.js.map → dist-5DVLAJX5.js.map} +0 -0
- /package/dist/{dist-ALT6N2V6.js.map → dist-5UUESGNG.js.map} +0 -0
- /package/dist/{dist-RAOZ6VUA.js.map → dist-DJUTU32K.js.map} +0 -0
- /package/dist/{dist-KU26ZFEG.js.map → dist-DN5N4ST4.js.map} +0 -0
- /package/dist/{dist-D2J4YZM6.js.map → dist-EAHK557K.js.map} +0 -0
- /package/dist/{dist-XTGERRGU.js.map → dist-EMS7RS72.js.map} +0 -0
- /package/dist/{dist-KDCRSMGT.js.map → dist-EOXPLOSM.js.map} +0 -0
- /package/dist/{dist-4EIQOOMJ.js.map → dist-GQELAMZW.js.map} +0 -0
- /package/dist/{dist-UFMW7V6T.js.map → dist-HUIPJXH7.js.map} +0 -0
- /package/dist/{dist-YAVVMJ7W.js.map → dist-IE7YTDEI.js.map} +0 -0
- /package/dist/{dist-QPNIGMZA.js.map → dist-IVRPGD7K.js.map} +0 -0
- /package/dist/{dist-V7I3FQX7.js.map → dist-IZE4BFP6.js.map} +0 -0
- /package/dist/{dist-KF5AKQ52.js.map → dist-NGUFAZCM.js.map} +0 -0
- /package/dist/{dist-IDJRFWAH.js.map → dist-NO72HDAS.js.map} +0 -0
- /package/dist/{dist-DOOWCYTM.js.map → dist-OVX6MUFU.js.map} +0 -0
- /package/dist/{dist-T4V65O5X.js.map → dist-Q6DJ7QAM.js.map} +0 -0
- /package/dist/{dist-46N2ZXQQ.js.map → dist-QCYMONV3.js.map} +0 -0
- /package/dist/{dist-YGJKGMK6.js.map → dist-QURXL6SQ.js.map} +0 -0
- /package/dist/{dist-GQHJZHTH.js.map → dist-SECMRLIE.js.map} +0 -0
- /package/dist/{dist-MBFKX56S.js.map → dist-UDAN4UWT.js.map} +0 -0
- /package/dist/{dist-7GSHUMRU.js.map → dist-V4UG63VI.js.map} +0 -0
- /package/dist/{dist-M6QCD7TL.js.map → dist-VMECMESW.js.map} +0 -0
- /package/dist/{dist-BXD5YEF3.js.map → dist-VPOLJT37.js.map} +0 -0
- /package/dist/{dist-NOIPAOTU.js.map → dist-VTPYNBIM.js.map} +0 -0
- /package/dist/{dist-6YSNCGWO.js.map → dist-X423DKFG.js.map} +0 -0
- /package/dist/{dist-GLBAV2CS.js.map → dist-ZDRNCFPI.js.map} +0 -0
package/attributes.js
CHANGED
|
@@ -4,101 +4,101 @@ import {
|
|
|
4
4
|
init_live_reload,
|
|
5
5
|
ir,
|
|
6
6
|
xn
|
|
7
|
-
} from "./dist/chunk-
|
|
7
|
+
} from "./dist/chunk-5M74UMX2.js";
|
|
8
8
|
|
|
9
9
|
// src/attributes.ts
|
|
10
10
|
init_live_reload();
|
|
11
11
|
|
|
12
12
|
// package.json
|
|
13
|
-
var version = "0.1.
|
|
13
|
+
var version = "0.1.8";
|
|
14
14
|
|
|
15
15
|
// src/load.ts
|
|
16
16
|
init_live_reload();
|
|
17
17
|
var loadAttribute = async (key) => {
|
|
18
18
|
switch (key) {
|
|
19
19
|
case "accordion": {
|
|
20
|
-
return import("./dist/dist-
|
|
20
|
+
return import("./dist/dist-5UUESGNG.js");
|
|
21
21
|
}
|
|
22
22
|
case "autovideo": {
|
|
23
|
-
return import("./dist/dist-
|
|
23
|
+
return import("./dist/dist-V4UG63VI.js");
|
|
24
24
|
}
|
|
25
25
|
case "codehighlight": {
|
|
26
|
-
return import("./dist/dist-
|
|
26
|
+
return import("./dist/dist-DJUTU32K.js");
|
|
27
27
|
}
|
|
28
28
|
case "combobox": {
|
|
29
|
-
return import("./dist/dist-
|
|
29
|
+
return import("./dist/dist-UDAN4UWT.js");
|
|
30
30
|
}
|
|
31
31
|
case "copyclip": {
|
|
32
|
-
return import("./dist/dist-
|
|
32
|
+
return import("./dist/dist-NGUFAZCM.js");
|
|
33
33
|
}
|
|
34
34
|
case "displayvalues": {
|
|
35
|
-
return import("./dist/dist-
|
|
35
|
+
return import("./dist/dist-SECMRLIE.js");
|
|
36
36
|
}
|
|
37
37
|
case "favcustom": {
|
|
38
|
-
return import("./dist/dist-
|
|
38
|
+
return import("./dist/dist-Q6DJ7QAM.js");
|
|
39
39
|
}
|
|
40
40
|
case "formsubmit": {
|
|
41
|
-
return import("./dist/dist-
|
|
41
|
+
return import("./dist/dist-ZDRNCFPI.js");
|
|
42
42
|
}
|
|
43
43
|
case "inject": {
|
|
44
|
-
return import("./dist/dist-
|
|
44
|
+
return import("./dist/dist-EMS7RS72.js");
|
|
45
45
|
}
|
|
46
46
|
case "inputactive": {
|
|
47
|
-
return import("./dist/dist-
|
|
47
|
+
return import("./dist/dist-NO72HDAS.js");
|
|
48
48
|
}
|
|
49
49
|
case "inputcounter": {
|
|
50
|
-
return import("./dist/dist-
|
|
50
|
+
return import("./dist/dist-QURXL6SQ.js");
|
|
51
51
|
}
|
|
52
52
|
case "list": {
|
|
53
|
-
return import("./dist/dist-
|
|
53
|
+
return import("./dist/dist-VMECMESW.js");
|
|
54
54
|
}
|
|
55
55
|
case "mirrorclick": {
|
|
56
|
-
return import("./dist/dist-
|
|
56
|
+
return import("./dist/dist-EOXPLOSM.js");
|
|
57
57
|
}
|
|
58
58
|
case "mirrorinput": {
|
|
59
|
-
return import("./dist/dist-
|
|
59
|
+
return import("./dist/dist-IE7YTDEI.js");
|
|
60
60
|
}
|
|
61
61
|
case "modal": {
|
|
62
|
-
return import("./dist/dist-
|
|
62
|
+
return import("./dist/dist-IZE4BFP6.js");
|
|
63
63
|
}
|
|
64
64
|
case "numbercount": {
|
|
65
|
-
return import("./dist/dist-
|
|
65
|
+
return import("./dist/dist-3BLHGYNR.js");
|
|
66
66
|
}
|
|
67
67
|
case "queryparam": {
|
|
68
|
-
return import("./dist/dist-
|
|
68
|
+
return import("./dist/dist-QCYMONV3.js");
|
|
69
69
|
}
|
|
70
70
|
case "rangeslider": {
|
|
71
|
-
return import("./dist/dist-
|
|
71
|
+
return import("./dist/dist-VPOLJT37.js");
|
|
72
72
|
}
|
|
73
73
|
case "readtime": {
|
|
74
|
-
return import("./dist/dist-
|
|
74
|
+
return import("./dist/dist-EAHK557K.js");
|
|
75
75
|
}
|
|
76
76
|
case "removequery": {
|
|
77
|
-
return import("./dist/dist-
|
|
77
|
+
return import("./dist/dist-3EOSRL3F.js");
|
|
78
78
|
}
|
|
79
79
|
case "scrolldisable": {
|
|
80
|
-
return import("./dist/dist-
|
|
80
|
+
return import("./dist/dist-HUIPJXH7.js");
|
|
81
81
|
}
|
|
82
82
|
case "selectcustom": {
|
|
83
|
-
return import("./dist/dist-
|
|
83
|
+
return import("./dist/dist-X423DKFG.js");
|
|
84
84
|
}
|
|
85
85
|
case "sliderdots": {
|
|
86
|
-
return import("./dist/dist-
|
|
86
|
+
return import("./dist/dist-VTPYNBIM.js");
|
|
87
87
|
}
|
|
88
88
|
case "smartlightbox": {
|
|
89
|
-
return import("./dist/dist-
|
|
89
|
+
return import("./dist/dist-OVX6MUFU.js");
|
|
90
90
|
}
|
|
91
91
|
case "socialshare": {
|
|
92
|
-
return import("./dist/dist-
|
|
92
|
+
return import("./dist/dist-DN5N4ST4.js");
|
|
93
93
|
}
|
|
94
94
|
case "starrating": {
|
|
95
|
-
return import("./dist/dist-
|
|
95
|
+
return import("./dist/dist-5DVLAJX5.js");
|
|
96
96
|
}
|
|
97
97
|
case "toc": {
|
|
98
|
-
return import("./dist/dist-
|
|
98
|
+
return import("./dist/dist-GQELAMZW.js");
|
|
99
99
|
}
|
|
100
100
|
case "videohls": {
|
|
101
|
-
return import("./dist/dist-
|
|
101
|
+
return import("./dist/dist-IVRPGD7K.js");
|
|
102
102
|
}
|
|
103
103
|
default: {
|
|
104
104
|
throw `Adartem Attribute "${key}" is not supported.`;
|
package/attributes.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["src/attributes.ts", "package.json", "src/load.ts", "src/loader/discover-loader-scripts.ts", "src/loader/read-loader-config.ts", "src/loader/scan-script-keys.ts", "src/runtime/apply-loader-config.ts", "src/runtime/devtools.ts", "src/runtime/errors.ts", "src/runtime/dom-ready.ts", "src/runtime/env.ts", "src/runtime/drain-prequeue.ts", "src/runtime/events.ts", "src/runtime/logger.ts", "src/runtime/observer.ts", "src/runtime/scan-dom-keys.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type AdLibAttributeKey,\n attachExternalStylesheets,\n ATTRIBUTES,\n fetchPage,\n waitDOMReady,\n} from '@adartem/adlib-utils';\n\nimport { version } from '../package.json';\nimport { loadAttribute } from './load';\nimport { discoverLoaderScripts } from './loader/discover-loader-scripts';\nimport { readLoaderConfigFromScripts } from './loader/read-loader-config';\nimport { scanRequestedKeysFromScripts } from './loader/scan-script-keys';\nimport { applyLoaderConfigCumulative } from './runtime/apply-loader-config';\nimport { attachRuntimeDevtools } from './runtime/devtools';\nimport { onDOMReady } from './runtime/dom-ready';\nimport { drainPreLoaderQueueIntoRuntime } from './runtime/drain-prequeue';\nimport { isBrowser } from './runtime/env';\nimport { AdLibRuntimeError, asRuntimeError } from './runtime/errors';\nimport { emitRuntimeEvent } from './runtime/events';\nimport type { AdLibLogger } from './runtime/logger';\nimport { createLogger, parseDebugChannels } from './runtime/logger';\nimport type { RuntimeObserverController } from './runtime/observer';\nimport { createRuntimeObserverController } from './runtime/observer';\nimport type { AdLibRuntime, RuntimeModuleState, RuntimeQueueItem } from './runtime/types';\n\nconst ATTRIBUTES_ATTRIBUTE_PREFIX = 'ad-attributes';\nconst ATTRIBUTE_KEYS = new Set(Object.values(ATTRIBUTES));\n\ntype RuntimeWithInternals = AdLibRuntime & {\n process: Set<AdLibAttributeKey>;\n utils: {\n fetchPage: typeof fetchPage;\n attachExternalStylesheets: typeof attachExternalStylesheets;\n };\n observerCtl?: RuntimeObserverController;\n logger?: AdLibLogger;\n debugChannels?: ReadonlySet<string>;\n};\n\nconst isQueueTuple = (\n value: RuntimeQueueItem,\n): value is [AdLibAttributeKey, (state: RuntimeModuleState) => void] => Array.isArray(value);\n\n/**\n * Inits the Adartem Attributes library.\n */\nconst init = () => {\n const { AdLibAttributes } = window;\n\n // Avoid initting the Attributes API more than once.\n // If the API is already initted, just init the individual Attributes and escape.\n const existingRuntime =\n AdLibAttributes && !Array.isArray(AdLibAttributes)\n ? (AdLibAttributes as unknown as RuntimeWithInternals)\n : undefined;\n\n const runtime =\n existingRuntime ??\n ({\n version,\n scripts: [],\n config: {},\n debug: false,\n auto: false,\n observeAttributes: false,\n modules: {},\n process: new Set<AdLibAttributeKey>(),\n utils: {\n fetchPage,\n attachExternalStylesheets,\n },\n\n load: initAttribute,\n\n async reload(key, options) {\n const state = this.modules[key] ?? (await this.load(key));\n\n if (state.status === 'ready') {\n const inst = state.instance as { restart?: (options?: { rescan?: boolean }) => void };\n if (inst && typeof inst.restart === 'function') {\n try {\n await inst.restart({ rescan: options?.rescan });\n return state;\n } catch {\n // fallback\n state.destroy();\n return await this.load(key);\n }\n }\n }\n\n state.destroy();\n return await this.load(key);\n },\n\n push(...items: RuntimeQueueItem[]) {\n for (const item of items) {\n const [rawKey, callback] = isQueueTuple(item) ? item : [item.key, item.cb];\n const key = rawKey as AdLibAttributeKey;\n let state = this.modules[key];\n\n if (state && (state.status === 'ready' || state.status === 'error')) {\n callback(state);\n continue;\n }\n\n if (!state || state.status !== 'loading') {\n this.load(key);\n state = this.modules[key];\n }\n\n if (!state) continue;\n\n if (state.promise) {\n state.promise.then(() => callback(state)).catch(() => callback(state));\n } else {\n callback(state);\n }\n }\n },\n\n applyLoaderConfig: () => {},\n\n destroy(options) {\n for (const solution in this.modules) {\n this.modules[solution as keyof typeof this.modules]?.destroy?.();\n }\n\n observerCtl.stop();\n\n if (!options?.keepGlobal) {\n return;\n }\n },\n\n getState(key) {\n if (!key) {\n return this.modules;\n }\n\n return (\n this.modules[key] ?? {\n key,\n status: 'idle',\n reload: (options) => this.reload(key, options),\n destroy: () => {\n this.process.delete(key);\n },\n }\n );\n },\n\n getErrors() {\n const errors = [];\n for (const [key, state] of Object.entries(this.modules)) {\n if (state?.status === 'error' && state.error) {\n errors.push({ key: key as AdLibAttributeKey, error: state.error });\n }\n }\n return errors;\n },\n\n isLoaded(key) {\n return this.modules[key]?.status === 'ready';\n },\n\n initFromScripts(source) {\n const nextScripts = source?.scripts ?? [];\n\n const seen = new Set<HTMLScriptElement>(this.scripts);\n for (const s of nextScripts) {\n if (!seen.has(s)) {\n seen.add(s);\n this.scripts.push(s);\n }\n }\n\n const scanned = scanRequestedKeysFromScripts(this.scripts);\n const provided = source?.requestedKeys ?? [];\n const requestedKeys = Array.from(new Set([...provided, ...scanned]));\n\n if (!this.auto) return;\n\n void (async () => {\n for (const key of requestedKeys) {\n try {\n await this.load(key);\n } catch {\n // best-effort: l'erreur est port\u00E9e par l'\u00E9tat module\n }\n }\n })();\n },\n } as RuntimeWithInternals);\n\n const observerCtl =\n runtime.observerCtl ?? createRuntimeObserverController(runtime as RuntimeWithInternals);\n runtime.observerCtl = observerCtl;\n\n runtime.applyLoaderConfig = (patch) => {\n const wasDebug = runtime.debug;\n applyLoaderConfigCumulative(runtime, patch);\n\n // If debug just activated, create logger + attach devtools\n if (!wasDebug && runtime.debug) {\n const ir = runtime as RuntimeWithInternals;\n if (!ir.logger?.enabled) {\n ir.logger = createLogger({\n enabled: true,\n channels: ir.debugChannels,\n });\n }\n attachRuntimeDevtools(runtime);\n }\n\n observerCtl.ensureStarted();\n };\n\n if (!existingRuntime) {\n window.AdLibAttributes = runtime;\n }\n\n drainPreLoaderQueueIntoRuntime(runtime);\n\n const scripts = discoverLoaderScripts(import.meta.url);\n const { config, flags } = readLoaderConfigFromScripts(scripts);\n const requestedKeys = scanRequestedKeysFromScripts(scripts);\n\n // Store debugChannels before applying config (applyLoaderConfig may need them)\n const ir = runtime as RuntimeWithInternals;\n ir.debugChannels = parseDebugChannels(flags.debugChannels);\n\n runtime.applyLoaderConfig({\n config,\n debug: flags.debug,\n auto: flags.auto,\n observeAttributes: flags.observeAttributes,\n });\n\n // Ensure a logger exists (no-op logger when debug=false)\n if (!ir.logger) {\n ir.logger = createLogger({ enabled: false });\n }\n\n ir.logger.info('runtime', 'boot', {\n version: runtime.version,\n debug: runtime.debug,\n auto: runtime.auto,\n });\n ir.logger.debug('loader', 'scripts discovered', {\n count: scripts.length,\n keys: requestedKeys,\n });\n\n runtime.initFromScripts({ scripts, requestedKeys });\n\n // Init Attributes\n initAttributes();\n};\n\nexport function bootstrapAttributesLoader(): void {\n if (!isBrowser()) return;\n\n onDOMReady(() => {\n init();\n });\n}\n\n/**\n * Inits all Attributes that are defined in the current script\n * or in the DOM if ad-attributes-auto is enabled.\n */\nconst initAttributes = () => {\n let autoLoad = false;\n\n for (const script of window.AdLibAttributes.scripts) {\n autoLoad ||= script.getAttribute(`${ATTRIBUTES_ATTRIBUTE_PREFIX}-auto`) === 'true';\n\n for (const key of ATTRIBUTE_KEYS) {\n const isDefined = script.hasAttribute(`ad-${key}`);\n if (!isDefined) continue;\n\n initAttribute(key);\n }\n }\n\n if (!autoLoad) return;\n\n waitDOMReady().then(() => {\n const usedAttributes = new Set<AdLibAttributeKey>();\n const allElements = document.querySelectorAll('*');\n\n for (const element of allElements) {\n for (const name of element.getAttributeNames()) {\n const adMatch = name.match(/^ad-([^-]+)/);\n const key = adMatch?.[1] as AdLibAttributeKey | undefined;\n\n if (key && ATTRIBUTE_KEYS.has(key)) {\n usedAttributes.add(key);\n }\n }\n }\n\n for (const attribute of usedAttributes) {\n initAttribute(attribute);\n }\n });\n};\n\n/**\n * Inits an individual Attribute.\n * @param key\n * @param script The <script> tag that defines the Attribute.\n *\n * @returns A Promise that resolves once the Attribute has loaded and executed.\n */\nconst initAttribute = async (key: AdLibAttributeKey) => {\n const isModuleKey = (k: string) => /^[a-z][a-z0-9-]*$/i.test(k);\n const runtime = window.AdLibAttributes as unknown as RuntimeWithInternals;\n const state = (runtime.modules[key] ??= {\n key,\n status: 'idle',\n reload: (options) => runtime.reload(key, options),\n destroy: () => {\n runtime.process.delete(key);\n },\n }) satisfies RuntimeModuleState;\n\n if (!isModuleKey(String(key))) {\n const err = new AdLibRuntimeError({\n code: 'UNKNOWN_MODULE_KEY',\n message: `Unknown module key: ${String(key)}`,\n key,\n });\n state.status = 'error';\n state.error = err;\n emitRuntimeEvent('ad:module:error', { key, state, error: err });\n return state;\n }\n\n // Ensure that the attribute is only initted once\n if (runtime.process.has(key)) return state;\n\n runtime.process.add(key);\n state.status = 'loading';\n runtime.logger?.debug('module', `loading ${key}`, { key });\n emitRuntimeEvent('ad:module:before', { key, state });\n\n // Load Attribute package\n const loadPromise = (async () => {\n let mod: Awaited<ReturnType<typeof loadAttribute>>;\n\n try {\n mod = await loadAttribute(key);\n } catch (err) {\n runtime.logger?.error('module', `Failed to import module ${key}`, { key, cause: err });\n const runtimeError = asRuntimeError(err, {\n code: 'MODULE_IMPORT_FAILED',\n message: `Failed to import module ${key}`,\n key,\n meta: {},\n });\n state.status = 'error';\n state.error = runtimeError;\n state.instance = undefined;\n emitRuntimeEvent('ad:module:error', { key, state, error: runtimeError });\n return undefined;\n }\n\n try {\n const { init } = mod;\n\n // Init attribute\n const { result, destroy } = (await init()) || {};\n\n state.instance = result;\n state.status = 'ready';\n state.error = undefined;\n emitRuntimeEvent('ad:module:after', { key, state });\n\n state.destroy = () => {\n try {\n destroy?.();\n runtime.process.delete(key);\n state.status = 'idle';\n state.instance = undefined;\n state.error = undefined;\n state.promise = undefined;\n } catch (err) {\n runtime.logger?.error('module', `Failed to destroy module ${key}`, { key, cause: err });\n const runtimeError = asRuntimeError(err, {\n code: 'MODULE_DESTROY_FAILED',\n message: `Failed to destroy module ${key}`,\n key,\n meta: {},\n });\n state.status = 'error';\n state.error = runtimeError;\n state.instance = undefined;\n emitRuntimeEvent('ad:module:error', { key, state, error: runtimeError });\n }\n };\n\n return result;\n } catch (err) {\n runtime.logger?.error('module', `Failed to init module ${key}`, { key, cause: err });\n const runtimeError = asRuntimeError(err, {\n code: 'MODULE_INIT_FAILED',\n message: `Failed to init module ${key}`,\n key,\n meta: {},\n });\n state.status = 'error';\n state.error = runtimeError;\n state.instance = undefined;\n emitRuntimeEvent('ad:module:error', { key, state, error: runtimeError });\n return undefined;\n }\n })();\n\n state.promise = loadPromise;\n\n await loadPromise;\n\n return state;\n};\n\n// Init\nbootstrapAttributesLoader();\n", "{\n \"name\": \"@adartem/adlib-attributes\",\n \"version\": \"0.1.7\",\n \"description\": \"ADARTEM AdLib Attributes (ad-*).\",\n \"homepage\": \"https://adartem.fr/attributes\",\n \"license\": \"MIT\",\n \"private\": false,\n \"publishConfig\": { \"access\": \"public\" },\n \"type\": \"module\",\n \"main\": \"attributes.js\",\n \"types\": \"./src/attributes.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./src/attributes.ts\",\n \"import\": \"./attributes.js\"\n },\n \"./attributes.js\": {\n \"import\": \"./attributes.js\"\n }\n },\n \"sideEffects\": [\n \"./attributes.js\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/adartem/adlib.git\",\n \"directory\": \"packages/adlib-attributes\"\n },\n \"files\": [\n \"dist\",\n \"attributes.js\",\n \"attributes.js.map\",\n \"README.md\",\n \"LICENSE\"\n ],\n \"scripts\": {\n \"build\": \"cross-env NODE_ENV=production tsx ./bin/build.ts\",\n \"lint\": \"eslint ./src && prettier --check ./src\",\n \"lint:fix\": \"eslint ./src --fix && prettier --write ./src\",\n \"typecheck\": \"tsc --noEmit\",\n \"test:unit\": \"vitest run -c ../../vitest.config.ts\",\n \"test:e2e\": \"pnpm playwright test --pass-with-no-tests\",\n \"test:headed\": \"pnpm playwright test --headed --pass-with-no-tests\",\n \"test\": \"pnpm test:unit && pnpm test:e2e\",\n \"clean\": \"rimraf dist node_modules test-results playwright-report attributes.js attributes.js.map\",\n \"dev\": \"cross-env NODE_ENV=development tsx ./bin/build.ts\"\n },\n \"keywords\": [\n \"adlib\",\n \"adartem\",\n \"attributes\",\n \"runtime\",\n \"cdn\",\n \"declarative\"\n ],\n \"author\": {\n \"name\": \"Adartem\",\n \"url\": \"https://adartem.fr/\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/adartem/adlib/issues\"\n },\n \"dependencies\": {\n \"@adartem/ad-accordion\": \"workspace:*\",\n \"@adartem/adlib-utils\": \"workspace:*\",\n \"@adartem/ad-codehighlight\": \"workspace:*\",\n \"@adartem/ad-autovideo\": \"workspace:*\",\n \"@adartem/ad-combobox\": \"workspace:*\",\n \"@adartem/ad-copyclip\": \"workspace:*\",\n \"@adartem/ad-displayvalues\": \"workspace:*\",\n \"@adartem/ad-favcustom\": \"workspace:*\",\n \"@adartem/ad-formsubmit\": \"workspace:*\",\n \"@adartem/ad-inject\": \"workspace:*\",\n \"@adartem/ad-inputactive\": \"workspace:*\",\n \"@adartem/ad-inputcounter\": \"workspace:*\",\n \"@adartem/ad-list\": \"workspace:*\",\n \"@adartem/ad-mirrorclick\": \"workspace:*\",\n \"@adartem/ad-mirrorinput\": \"workspace:*\",\n \"@adartem/ad-modal\": \"workspace:*\",\n \"@adartem/ad-numbercount\": \"workspace:*\",\n \"@adartem/ad-queryparam\": \"workspace:*\",\n \"@adartem/ad-rangeslider\": \"workspace:*\",\n \"@adartem/ad-readtime\": \"workspace:*\",\n \"@adartem/ad-removequery\": \"workspace:*\",\n \"@adartem/ad-scrolldisable\": \"workspace:*\",\n \"@adartem/ad-selectcustom\": \"workspace:*\",\n \"@adartem/ad-sliderdots\": \"workspace:*\",\n \"@adartem/ad-smartlightbox\": \"workspace:*\",\n \"@adartem/ad-socialshare\": \"workspace:*\",\n \"@adartem/ad-starrating\": \"workspace:*\",\n \"@adartem/ad-toc\": \"workspace:*\",\n \"@adartem/ad-videohls\": \"workspace:*\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^20.14.9\",\n \"cross-env\": \"^10.1.0\",\n \"esbuild\": \"^0.27.2\",\n \"esbuild-plugin-inline-worker\": \"^0.1.1\",\n \"tsx\": \"^4.19.2\"\n }\n}", "import { type AdLibAttributeKey } from '@adartem/adlib-utils';\n\n/**\n * Dynamically loads an attribute package.\n * @param key\n */\nexport const loadAttribute = async (key: AdLibAttributeKey) => {\n switch (key) {\n case 'accordion': {\n return import('@adartem/ad-accordion');\n }\n\n case 'autovideo': {\n return import('@adartem/ad-autovideo');\n }\n\n case 'codehighlight': {\n return import('@adartem/ad-codehighlight');\n }\n\n case 'combobox': {\n return import('@adartem/ad-combobox');\n }\n\n case 'copyclip': {\n return import('@adartem/ad-copyclip');\n }\n\n case 'displayvalues': {\n return import('@adartem/ad-displayvalues');\n }\n\n case 'favcustom': {\n return import('@adartem/ad-favcustom');\n }\n\n case 'formsubmit': {\n return import('@adartem/ad-formsubmit');\n }\n\n case 'inject': {\n return import('@adartem/ad-inject');\n }\n\n case 'inputactive': {\n return import('@adartem/ad-inputactive');\n }\n\n case 'inputcounter': {\n return import('@adartem/ad-inputcounter');\n }\n\n case 'list': {\n return import('@adartem/ad-list');\n }\n\n case 'mirrorclick': {\n return import('@adartem/ad-mirrorclick');\n }\n\n case 'mirrorinput': {\n return import('@adartem/ad-mirrorinput');\n }\n\n case 'modal': {\n return import('@adartem/ad-modal');\n }\n\n case 'numbercount': {\n return import('@adartem/ad-numbercount');\n }\n\n case 'queryparam': {\n return import('@adartem/ad-queryparam');\n }\n\n case 'rangeslider': {\n return import('@adartem/ad-rangeslider');\n }\n\n case 'readtime': {\n return import('@adartem/ad-readtime');\n }\n\n case 'removequery': {\n return import('@adartem/ad-removequery');\n }\n\n case 'scrolldisable': {\n return import('@adartem/ad-scrolldisable');\n }\n\n case 'selectcustom': {\n return import('@adartem/ad-selectcustom');\n }\n\n case 'sliderdots': {\n return import('@adartem/ad-sliderdots');\n }\n\n case 'smartlightbox': {\n return import('@adartem/ad-smartlightbox');\n }\n\n case 'socialshare': {\n return import('@adartem/ad-socialshare');\n }\n\n case 'starrating': {\n return import('@adartem/ad-starrating');\n }\n\n case 'toc': {\n return import('@adartem/ad-toc');\n }\n\n case 'videohls': {\n return import('@adartem/ad-videohls');\n }\n\n default: {\n throw `Adartem Attribute \"${key}\" is not supported.`;\n }\n }\n};\n", "function stripHashAndQuery(u: string): string {\n const i = u.search(/[?#]/);\n return i === -1 ? u : u.slice(0, i);\n}\n\nfunction safeToURL(u: string, base: string): URL | null {\n try {\n return new URL(u, base);\n } catch {\n return null;\n }\n}\n\nfunction sameNormalizedPath(a: URL, b: URL): boolean {\n // Compare by pathname suffix to tolerate origin/CDN rewrites; ignore query/hash\n return stripHashAndQuery(a.pathname).endsWith(stripHashAndQuery(b.pathname));\n}\n\nexport function discoverLoaderScripts(currentImportMetaUrl: string): HTMLScriptElement[] {\n if (typeof document === 'undefined') return [];\n\n const scripts = Array.from(\n document.querySelectorAll('script[type=\"module\"][src]'),\n ) as HTMLScriptElement[];\n const base =\n document.baseURI || (typeof location !== 'undefined' ? location.href : 'http://localhost/');\n const current = safeToURL(currentImportMetaUrl, base);\n if (!current) return [];\n\n const matches: HTMLScriptElement[] = [];\n\n for (const s of scripts) {\n const src = s.getAttribute('src');\n if (!src) continue;\n const u = safeToURL(src, base);\n if (!u) continue;\n\n if (sameNormalizedPath(u, current)) {\n matches.push(s);\n }\n }\n\n return matches;\n}\n", "import type { AdLibRuntimeConfig } from '../runtime/types';\n\nexport type LoaderFlags = {\n debug?: boolean;\n auto?: boolean;\n observeAttributes?: boolean;\n debugChannels?: string;\n};\n\nfunction readBoolAttr(s: HTMLScriptElement, name: string): boolean | undefined {\n const v = s.getAttribute(name);\n if (v === null) return undefined;\n // presence-only => true\n if (v === '' || v.toLowerCase() === 'true') return true;\n if (v.toLowerCase() === 'false') return false;\n return true;\n}\n\nexport function readLoaderConfigFromScripts(scripts: HTMLScriptElement[]): {\n config: AdLibRuntimeConfig;\n flags: LoaderFlags;\n} {\n const config: AdLibRuntimeConfig = {};\n const flags: LoaderFlags = {};\n\n for (const s of scripts) {\n // Shallow-merge config: last-one-wins (DOM order is deterministic)\n const registry = s.getAttribute('data-adlib-registry');\n const version = s.getAttribute('data-adlib-version');\n const base = s.getAttribute('data-adlib-base');\n\n if (registry) config.registry = registry;\n if (version) config.version = version;\n if (base) config.base = base;\n\n // Flags OR-only: once true, stay true\n const debug = readBoolAttr(s, 'data-adlib-debug');\n const auto = readBoolAttr(s, 'data-adlib-auto');\n const observe = readBoolAttr(s, 'data-adlib-observe-attributes');\n\n if (debug === true) flags.debug = true;\n if (auto === true) flags.auto = true;\n if (observe === true) flags.observeAttributes = true;\n\n const channels = s.getAttribute('data-adlib-debug-channels');\n if (channels) flags.debugChannels = channels;\n }\n\n return { config, flags };\n}\n", "import type { AdLibAttributeKey } from '@adartem/adlib-utils';\n\nconst AD_KEY_RE = /^ad-[a-z0-9-]+$/i;\nconst DATA_AD_KEY_RE = /^data-ad-[a-z0-9-]+$/i;\n\nfunction toModuleKey(attrName: string): AdLibAttributeKey | null {\n // data-ad-foo -> foo\n if (DATA_AD_KEY_RE.test(attrName)) {\n return attrName.slice('data-ad-'.length) as AdLibAttributeKey;\n }\n // ad-foo -> foo\n if (AD_KEY_RE.test(attrName)) {\n return attrName.slice('ad-'.length) as AdLibAttributeKey;\n }\n return null;\n}\n\nexport function scanRequestedKeysFromScripts(scripts: HTMLScriptElement[]): AdLibAttributeKey[] {\n const out = new Set<AdLibAttributeKey>();\n\n for (const s of scripts) {\n // IMPORTANT: on scanne les noms d\u2019attributs, pas leurs valeurs\n // Objectif: <script ... ad-foo ad-bar data-ad-baz ...>\n for (const { name } of Array.from(s.attributes)) {\n // Ignore reserved loader config namespace\n if (name.startsWith('data-adlib-')) continue;\n\n const key = toModuleKey(name);\n if (key) out.add(key);\n }\n }\n\n return Array.from(out);\n}\n", "import type { AdLibRuntime, AdLibRuntimeConfig } from './types';\n\nexport type LoaderConfigPatch = Partial<\n Pick<AdLibRuntime, 'debug' | 'auto' | 'observeAttributes'>\n> & {\n config?: Partial<AdLibRuntimeConfig>;\n};\n\nexport function applyLoaderConfigCumulative(runtime: AdLibRuntime, patch: LoaderConfigPatch): void {\n // Shallow merge of config (only defined keys)\n if (patch.config) {\n runtime.config = {\n ...runtime.config,\n ...patch.config,\n };\n }\n\n // OR-only toggles: once true, always true\n if (patch.debug === true) runtime.debug = true;\n if (patch.auto === true) runtime.auto = true;\n if (patch.observeAttributes === true) runtime.observeAttributes = true;\n\n // Important: do NOT allow turning flags off\n // - if patch.debug is false/undefined -> no-op\n // - same for auto/observeAttributes\n}\n", "import { AdLibRuntimeError } from './errors';\nimport type { AdLibLogger } from './logger';\nimport type { RuntimeObserverController } from './observer';\nimport type {\n AdLibRuntime,\n RuntimeDevtools,\n RuntimeObserverDiagnostics,\n RuntimeSnapshot,\n RuntimeSnapshotModule,\n} from './types';\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Build module snapshots, omitting keys whose value is `undefined`.\n */\nfunction toSnapshotModules(runtime: AdLibRuntime): RuntimeSnapshotModule[] {\n const out: RuntimeSnapshotModule[] = [];\n\n for (const [key, state] of Object.entries(runtime.modules)) {\n if (!state) continue;\n\n const entry: RuntimeSnapshotModule = {\n key,\n status: state.status,\n };\n\n const errorCode = state.error instanceof AdLibRuntimeError ? state.error.code : undefined;\n if (errorCode !== undefined) {\n entry.errorCode = errorCode;\n }\n\n out.push(entry);\n }\n\n // stable order for diffs/logs\n out.sort((a, b) => a.key.localeCompare(b.key));\n return out;\n}\n\n/**\n * Return a clean copy of observer diagnostics with no `undefined` keys.\n */\nfunction cleanDiagnostics(diag: RuntimeObserverDiagnostics): RuntimeObserverDiagnostics {\n const out: RuntimeObserverDiagnostics = {\n flushCount: diag.flushCount,\n receivedMutations: diag.receivedMutations,\n droppedMutations: diag.droppedMutations,\n };\n if (diag.lastCapReason !== undefined) {\n out.lastCapReason = diag.lastCapReason;\n }\n return out;\n}\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\n\nexport function createRuntimeDevtools(\n runtime: AdLibRuntime,\n logger?: AdLibLogger,\n): RuntimeDevtools {\n function getObserverDiagnostics(): RuntimeObserverDiagnostics | undefined {\n const ctl = (runtime as AdLibRuntime & { observerCtl?: RuntimeObserverController }).observerCtl;\n return ctl?.getDiagnostics?.();\n }\n\n const snapshot = (): RuntimeSnapshot => {\n const s: RuntimeSnapshot = {\n version: runtime.version,\n debug: runtime.debug,\n auto: runtime.auto,\n observeAttributes: runtime.observeAttributes,\n config: runtime.config,\n scriptsCount: runtime.scripts.length,\n modules: toSnapshotModules(runtime),\n };\n\n const observerDiag = getObserverDiagnostics();\n if (observerDiag) {\n s.observer = cleanDiagnostics(observerDiag);\n }\n\n return s;\n };\n\n const devtoolsLog = logger?.child('devtools');\n\n return {\n runtime,\n snapshot,\n modules: () => toSnapshotModules(runtime),\n dump: () => {\n const s = snapshot();\n\n // Human-friendly output (best-effort, never crash)\n try {\n if (typeof console.groupCollapsed === 'function') {\n console.groupCollapsed('[adlib:devtools] Runtime snapshot');\n console.info(\n 'version:',\n s.version,\n '| debug:',\n s.debug,\n '| auto:',\n s.auto,\n '| observeAttributes:',\n s.observeAttributes,\n );\n if (s.modules.length > 0 && typeof console.table === 'function') {\n console.table(s.modules);\n }\n if (s.observer) {\n console.info('observer:', s.observer);\n }\n console.groupEnd();\n } else {\n console.info('[adlib:devtools] Runtime snapshot', s);\n }\n } catch {\n // best-effort\n }\n\n // Structured log (filterable via channels)\n devtoolsLog?.debug('dump', s);\n\n return s;\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Window attachment (conditional on debug)\n// ---------------------------------------------------------------------------\n\nexport function attachRuntimeDevtools(runtime: AdLibRuntime): void {\n if (typeof window === 'undefined') return;\n\n const w = window as Window & { __ADLIB_DEBUG__?: RuntimeDevtools };\n\n // Idempotent attach\n if (w.__ADLIB_DEBUG__?.runtime === runtime) return;\n\n const { logger } = runtime as AdLibRuntime & { logger?: AdLibLogger };\n w.__ADLIB_DEBUG__ = createRuntimeDevtools(runtime, logger);\n}\n", "import type { AdLibAttributeKey } from '@adartem/adlib-utils';\n\nexport type AdLibRuntimeErrorCode =\n | 'UNKNOWN_MODULE_KEY'\n | 'MODULE_IMPORT_FAILED'\n | 'MODULE_INIT_FAILED'\n | 'MODULE_DESTROY_FAILED';\n\nexport class AdLibRuntimeError extends Error {\n public readonly code: AdLibRuntimeErrorCode;\n public readonly key?: AdLibAttributeKey;\n public readonly cause?: unknown;\n public readonly meta?: Record<string, unknown>;\n\n constructor(args: {\n code: AdLibRuntimeErrorCode;\n message: string;\n key?: AdLibAttributeKey;\n cause?: unknown;\n meta?: Record<string, unknown>;\n }) {\n super(args.message);\n this.name = 'AdLibRuntimeError';\n this.code = args.code;\n this.key = args.key;\n this.cause = args.cause;\n this.meta = args.meta;\n }\n}\n\nexport function asRuntimeError(\n err: unknown,\n fallback: {\n code: AdLibRuntimeErrorCode;\n message: string;\n key?: AdLibAttributeKey;\n meta?: Record<string, unknown>;\n },\n): AdLibRuntimeError {\n if (err instanceof AdLibRuntimeError) return err;\n return new AdLibRuntimeError({\n code: fallback.code,\n message: fallback.message,\n key: fallback.key,\n cause: err,\n meta: fallback.meta,\n });\n}\n", "import { isBrowser } from './env';\n\nexport function onDOMReady(fn: () => void): void {\n if (!isBrowser()) return;\n\n if (document.readyState === 'interactive' || document.readyState === 'complete') {\n fn();\n return;\n }\n\n document.addEventListener(\n 'DOMContentLoaded',\n () => {\n fn();\n },\n { once: true },\n );\n}\n", "export function isBrowser(): boolean {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n}\n\nexport function hasDOMBody(): boolean {\n return isBrowser() && !!document.body;\n}\n", "import type { AdLibRuntime, RuntimeQueueItem } from './types';\n\ntype GlobalQueue = Array<unknown> & { __adlib_drained__?: true };\ntype GlobalAttributes = AdLibRuntime | GlobalQueue | undefined;\ntype WindowWithAdLibAttributes = Omit<Window, 'AdLibAttributes'> & {\n AdLibAttributes?: GlobalAttributes;\n};\n\nfunction isQueue(x: unknown): x is GlobalQueue {\n return Array.isArray(x);\n}\n\nfunction isRuntimeLike(x: unknown): x is AdLibRuntime {\n return (\n !!x &&\n typeof x === 'object' &&\n 'push' in x &&\n typeof (x as { push?: unknown }).push === 'function'\n );\n}\n\nexport function drainPreLoaderQueueIntoRuntime(runtime: AdLibRuntime): void {\n if (typeof window === 'undefined') return;\n\n const globalWindow = window as unknown as WindowWithAdLibAttributes;\n const current = globalWindow.AdLibAttributes as unknown;\n\n // If runtime is already installed, nothing to do.\n if (isRuntimeLike(current)) return;\n\n // Only drain if it\u2019s an array queue.\n if (!isQueue(current)) return;\n\n // Idempotence guard: avoid draining twice.\n if (current.__adlib_drained__ === true) return;\n\n const items = current.slice() as RuntimeQueueItem[];\n current.length = 0;\n current.__adlib_drained__ = true;\n\n if (items.length > 0) {\n runtime.push(...items);\n }\n\n // Replace global with the runtime instance.\n globalWindow.AdLibAttributes = runtime;\n}\n", "import type { RuntimeModuleEventDetail, RuntimeModuleEventName } from './types';\n\nexport function emitRuntimeEvent(\n name: RuntimeModuleEventName,\n detail: RuntimeModuleEventDetail,\n): void {\n if (typeof window === 'undefined') return;\n\n try {\n const ev = new CustomEvent<RuntimeModuleEventDetail>(name, { detail });\n window.dispatchEvent(ev);\n } catch {\n // best-effort: never crash runtime because of event emission\n }\n}\n", "// ---------------------------------------------------------------------------\n// Structured logger \u2013 silent by default, channel-filterable\n// ---------------------------------------------------------------------------\n\nexport type AdLibLogLevel = 'debug' | 'info' | 'warn' | 'error';\n\nexport type AdLibLogChannel = 'runtime' | 'loader' | 'core' | 'module' | 'observer' | 'devtools';\n\nexport type LoggerConfig = {\n enabled: boolean;\n channels?: ReadonlySet<string>;\n namespace?: string;\n};\n\nexport type StructuredLog = {\n ns: string;\n ch: string;\n level: string;\n msg: string;\n time: number;\n data?: unknown;\n};\n\nexport type ChildLogger = {\n debug(msg: string, data?: unknown): void;\n info(msg: string, data?: unknown): void;\n warn(msg: string, data?: unknown): void;\n error(msg: string, data?: unknown): void;\n};\n\nexport type AdLibLogger = {\n enabled: boolean;\n channels?: ReadonlySet<string>;\n log(level: AdLibLogLevel, channel: string, msg: string, data?: unknown): void;\n debug(channel: string, msg: string, data?: unknown): void;\n info(channel: string, msg: string, data?: unknown): void;\n warn(channel: string, msg: string, data?: unknown): void;\n error(channel: string, msg: string, data?: unknown): void;\n child(channel: string): ChildLogger;\n};\n\n// ---------------------------------------------------------------------------\n// No-op singletons (zero-alloc when disabled)\n// ---------------------------------------------------------------------------\n\nconst NOOP = () => {};\n\nconst noopChild: ChildLogger = {\n debug: NOOP,\n info: NOOP,\n warn: NOOP,\n error: NOOP,\n};\n\nconst noopLogger: AdLibLogger = {\n enabled: false,\n log: NOOP,\n debug: NOOP,\n info: NOOP,\n warn: NOOP,\n error: NOOP,\n child: () => noopChild,\n};\n\n// ---------------------------------------------------------------------------\n// Console method mapping\n// ---------------------------------------------------------------------------\n\nconst CONSOLE_METHOD: Record<AdLibLogLevel, 'debug' | 'info' | 'warn' | 'error'> = {\n debug: 'debug',\n info: 'info',\n warn: 'warn',\n error: 'error',\n};\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\n\nexport function createLogger(config: LoggerConfig): AdLibLogger {\n if (!config.enabled) return noopLogger;\n\n const ns = config.namespace ?? 'adlib';\n const { channels } = config;\n\n function log(level: AdLibLogLevel, channel: string, msg: string, data?: unknown): void {\n if (channels && !channels.has(channel)) return;\n\n const payload: StructuredLog = {\n ns,\n ch: channel,\n level,\n msg,\n time: Date.now(),\n };\n\n if (data !== undefined) {\n payload.data = data;\n }\n\n try {\n const method = CONSOLE_METHOD[level];\n console[method](`[${ns}:${channel}] ${msg}`, payload);\n } catch {\n // best-effort: never crash on logging\n }\n }\n\n return {\n enabled: true,\n channels,\n log,\n debug: (ch, msg, data) => log('debug', ch, msg, data),\n info: (ch, msg, data) => log('info', ch, msg, data),\n warn: (ch, msg, data) => log('warn', ch, msg, data),\n error: (ch, msg, data) => log('error', ch, msg, data),\n child(channel: string): ChildLogger {\n return {\n debug: (msg, data) => log('debug', channel, msg, data),\n info: (msg, data) => log('info', channel, msg, data),\n warn: (msg, data) => log('warn', channel, msg, data),\n error: (msg, data) => log('error', channel, msg, data),\n };\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Debug-channels parser (CSV \u2192 Set)\n// ---------------------------------------------------------------------------\n\n/**\n * Parse a CSV string of debug channels into a `Set`.\n * Returns `undefined` when absent / empty (= all channels allowed).\n */\nexport function parseDebugChannels(raw: string | null | undefined): Set<string> | undefined {\n if (!raw) return undefined;\n\n const channels = raw\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean);\n\n return channels.length > 0 ? new Set(channels) : undefined;\n}\n", "import type { AdLibAttributeKey } from '@adartem/adlib-utils';\n\nimport type { AdLibLogger } from './logger';\nimport { scanKeysFromNodes } from './scan-dom-keys';\nimport type { AdLibRuntime, ObserverCapReason, RuntimeObserverDiagnostics } from './types';\n\n// ---------------------------------------------------------------------------\n// Attribute-name \u2192 module-key helpers\n// ---------------------------------------------------------------------------\n\nconst AD_KEY_RE = /^ad-[a-z0-9-]+$/i;\nconst DATA_AD_KEY_RE = /^data-ad-[a-z0-9-]+$/i;\n\nfunction attrNameToKey(name: string): AdLibAttributeKey | null {\n if (DATA_AD_KEY_RE.test(name)) return name.slice('data-ad-'.length) as AdLibAttributeKey;\n if (AD_KEY_RE.test(name)) return name.slice('ad-'.length) as AdLibAttributeKey;\n return null;\n}\n\n// ---------------------------------------------------------------------------\n// Caps (internal, non-public)\n// ---------------------------------------------------------------------------\n\nconst MAX_MUTATIONS_PER_FLUSH = 200;\nconst MAX_NODES_PER_FLUSH = 1000;\nconst MAX_KEYS_PER_FLUSH = 50;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ntype Mode = 'nodes' | 'nodes+attrs';\n\nexport type RuntimeObserverController = {\n isActive: () => boolean;\n ensureStarted: () => void;\n stop: () => void;\n getDiagnostics: () => RuntimeObserverDiagnostics;\n};\n\n// ---------------------------------------------------------------------------\n// Scheduling helper (microtask-first, never synchronous loop)\n// ---------------------------------------------------------------------------\n\nfunction scheduleMicrotask(fn: () => void): void {\n if (typeof queueMicrotask === 'function') {\n queueMicrotask(fn);\n } else {\n void Promise.resolve().then(fn);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Controller factory\n// ---------------------------------------------------------------------------\n\nexport function createRuntimeObserverController(runtime: AdLibRuntime): RuntimeObserverController {\n let observer: MutationObserver | null = null;\n let observing = false;\n let lastMode: Mode | null = null;\n\n // ---- Backlog (raw MutationRecords) ------------------------------------\n\n let backlog: MutationRecord[] = [];\n let flushScheduled = false;\n\n // ---- Diagnostics (best-effort) ----------------------------------------\n\n const diagnostics: RuntimeObserverDiagnostics = {\n flushCount: 0,\n receivedMutations: 0,\n droppedMutations: 0,\n lastCapReason: undefined,\n };\n\n // ---- Logger accessor (runtime.logger is set after observer creation) ---\n\n type RuntimeWithLogger = AdLibRuntime & { logger?: AdLibLogger };\n\n function log(level: 'debug' | 'info', msg: string, data?: unknown): void {\n (runtime as RuntimeWithLogger).logger?.[level]('observer', msg, data);\n }\n\n // ---- Enqueue ----------------------------------------------------------\n\n function enqueue(mutations: MutationRecord[]): void {\n diagnostics.receivedMutations += mutations.length;\n for (const m of mutations) backlog.push(m);\n log('debug', 'enqueue', { count: mutations.length, backlog: backlog.length });\n scheduleFlush();\n }\n\n // ---- Flush with caps --------------------------------------------------\n\n function flush(): void {\n flushScheduled = false;\n\n if (backlog.length === 0) return;\n\n diagnostics.flushCount++;\n\n // Cap 1: mutations processed this flush\n const mutationsToProcess = backlog.slice(0, MAX_MUTATIONS_PER_FLUSH);\n const remaining = backlog.slice(MAX_MUTATIONS_PER_FLUSH);\n\n let capReason: ObserverCapReason | undefined;\n\n if (remaining.length > 0) {\n capReason = 'MAX_MUTATIONS';\n diagnostics.droppedMutations += remaining.length;\n }\n\n // Collect nodes + attr names from the chunk\n const addedNodes: Node[] = [];\n const attrNames: string[] = [];\n\n let nodeCount = 0;\n let nodeCapped = false;\n\n for (const m of mutationsToProcess) {\n if (m.type === 'childList') {\n for (const n of Array.from(m.addedNodes)) {\n if (nodeCount >= MAX_NODES_PER_FLUSH) {\n nodeCapped = true;\n break;\n }\n addedNodes.push(n);\n nodeCount++;\n }\n if (nodeCapped) break;\n continue;\n }\n\n if (m.type === 'attributes') {\n if (!runtime.observeAttributes) continue;\n const name = m.attributeName;\n if (!name) continue;\n attrNames.push(name);\n }\n }\n\n if (nodeCapped && !capReason) {\n capReason = 'MAX_NODES';\n }\n\n // Derive keys (capped)\n const keysFromNodes = scanKeysFromNodes(addedNodes);\n\n const keysFromAttrs = new Set<AdLibAttributeKey>();\n for (const name of attrNames) {\n if (name.startsWith('data-adlib-')) continue;\n const key = attrNameToKey(name);\n if (key) keysFromAttrs.add(key);\n }\n\n let allKeys = Array.from(new Set([...keysFromNodes, ...Array.from(keysFromAttrs)]));\n\n if (allKeys.length > MAX_KEYS_PER_FLUSH) {\n if (!capReason) capReason = 'MAX_KEYS';\n allKeys = allKeys.slice(0, MAX_KEYS_PER_FLUSH);\n }\n\n if (capReason) {\n diagnostics.lastCapReason = capReason;\n }\n\n log('debug', 'flush', {\n processed: mutationsToProcess.length,\n keys: allKeys,\n ...(capReason ? { capReason } : {}),\n });\n\n // Replace backlog with leftovers\n backlog = remaining;\n\n // Trigger loads (best-effort, async, never blocks)\n if (allKeys.length > 0) {\n void (async () => {\n for (const key of allKeys) {\n try {\n await runtime.load(key);\n } catch {\n // best-effort; error is stored in module state\n }\n }\n })();\n }\n\n // Reschedule if backlog still has items\n if (backlog.length > 0) {\n scheduleFlush();\n }\n }\n\n // ---- Schedule (one flush per tick, never sync loop) -------------------\n\n function scheduleFlush(): void {\n if (flushScheduled) return;\n flushScheduled = true;\n scheduleMicrotask(flush);\n }\n\n // ---- MutationObserver callback ----------------------------------------\n\n function handleMutations(mutations: MutationRecord[]): void {\n enqueue(mutations);\n }\n\n // ---- Connection management --------------------------------------------\n\n function desiredMode(): Mode {\n return runtime.observeAttributes ? 'nodes+attrs' : 'nodes';\n }\n\n function connect(mode: Mode): void {\n if (typeof document === 'undefined') return;\n const root = document.body;\n if (!root) return;\n\n if (!observer) observer = new MutationObserver(handleMutations);\n\n // If already observing with the right mode, no-op.\n if (observing && lastMode === mode) return;\n\n // Reconnect when mode changes.\n observer.disconnect();\n\n const base: MutationObserverInit = {\n subtree: true,\n childList: true,\n };\n\n const opts: MutationObserverInit =\n mode === 'nodes+attrs' ? { ...base, attributes: true, attributeOldValue: false } : base;\n\n observer.observe(root, opts);\n observing = true;\n lastMode = mode;\n }\n\n // ---- Public API -------------------------------------------------------\n\n return {\n isActive: () => observing,\n\n ensureStarted: () => {\n connect(desiredMode());\n },\n\n stop: () => {\n if (!observer) return;\n observer.disconnect();\n observing = false;\n lastMode = null;\n flushScheduled = false;\n backlog = [];\n },\n\n getDiagnostics: () => ({ ...diagnostics }),\n };\n}\n", "import type { AdLibAttributeKey } from '@adartem/adlib-utils';\n\nconst AD_KEY_RE = /^ad-[a-z0-9-]+$/i;\nconst DATA_AD_KEY_RE = /^data-ad-[a-z0-9-]+$/i;\n\nfunction attrNameToKey(name: string): AdLibAttributeKey | null {\n if (name.startsWith('data-adlib-')) return null; // reserved namespace\n if (DATA_AD_KEY_RE.test(name)) return name.slice('data-ad-'.length) as AdLibAttributeKey;\n if (AD_KEY_RE.test(name)) return name.slice('ad-'.length) as AdLibAttributeKey;\n return null;\n}\n\nfunction scanElement(el: Element, out: Set<AdLibAttributeKey>) {\n for (const { name } of Array.from(el.attributes)) {\n const key = attrNameToKey(name);\n if (key) out.add(key);\n }\n}\n\nexport function scanKeysFromNodes(nodes: Node[]): AdLibAttributeKey[] {\n const out = new Set<AdLibAttributeKey>();\n\n for (const n of nodes) {\n if (n.nodeType !== 1) continue;\n const el = n as Element;\n\n scanElement(el, out);\n\n // Also scan descendants (best-effort)\n for (const child of Array.from(el.querySelectorAll('*'))) {\n scanElement(child, out);\n }\n }\n\n return Array.from(out);\n}\n"],
|
|
4
|
+
"sourcesContent": ["import {\n type AdLibAttributeKey,\n attachExternalStylesheets,\n ATTRIBUTES,\n fetchPage,\n waitDOMReady,\n} from '@adartem/adlib-utils';\n\nimport { version } from '../package.json';\nimport { loadAttribute } from './load';\nimport { discoverLoaderScripts } from './loader/discover-loader-scripts';\nimport { readLoaderConfigFromScripts } from './loader/read-loader-config';\nimport { scanRequestedKeysFromScripts } from './loader/scan-script-keys';\nimport { applyLoaderConfigCumulative } from './runtime/apply-loader-config';\nimport { attachRuntimeDevtools } from './runtime/devtools';\nimport { onDOMReady } from './runtime/dom-ready';\nimport { drainPreLoaderQueueIntoRuntime } from './runtime/drain-prequeue';\nimport { isBrowser } from './runtime/env';\nimport { AdLibRuntimeError, asRuntimeError } from './runtime/errors';\nimport { emitRuntimeEvent } from './runtime/events';\nimport type { AdLibLogger } from './runtime/logger';\nimport { createLogger, parseDebugChannels } from './runtime/logger';\nimport type { RuntimeObserverController } from './runtime/observer';\nimport { createRuntimeObserverController } from './runtime/observer';\nimport type { AdLibRuntime, RuntimeModuleState, RuntimeQueueItem } from './runtime/types';\n\nconst ATTRIBUTES_ATTRIBUTE_PREFIX = 'ad-attributes';\nconst ATTRIBUTE_KEYS = new Set(Object.values(ATTRIBUTES));\n\ntype RuntimeWithInternals = AdLibRuntime & {\n process: Set<AdLibAttributeKey>;\n utils: {\n fetchPage: typeof fetchPage;\n attachExternalStylesheets: typeof attachExternalStylesheets;\n };\n observerCtl?: RuntimeObserverController;\n logger?: AdLibLogger;\n debugChannels?: ReadonlySet<string>;\n};\n\nconst isQueueTuple = (\n value: RuntimeQueueItem,\n): value is [AdLibAttributeKey, (state: RuntimeModuleState) => void] => Array.isArray(value);\n\n/**\n * Inits the Adartem Attributes library.\n */\nconst init = () => {\n const { AdLibAttributes } = window;\n\n // Avoid initting the Attributes API more than once.\n // If the API is already initted, just init the individual Attributes and escape.\n const existingRuntime =\n AdLibAttributes && !Array.isArray(AdLibAttributes)\n ? (AdLibAttributes as unknown as RuntimeWithInternals)\n : undefined;\n\n const runtime =\n existingRuntime ??\n ({\n version,\n scripts: [],\n config: {},\n debug: false,\n auto: false,\n observeAttributes: false,\n modules: {},\n process: new Set<AdLibAttributeKey>(),\n utils: {\n fetchPage,\n attachExternalStylesheets,\n },\n\n load: initAttribute,\n\n async reload(key, options) {\n const state = this.modules[key] ?? (await this.load(key));\n\n if (state.status === 'ready') {\n const inst = state.instance as { restart?: (options?: { rescan?: boolean }) => void };\n if (inst && typeof inst.restart === 'function') {\n try {\n await inst.restart({ rescan: options?.rescan });\n return state;\n } catch {\n // fallback\n state.destroy();\n return await this.load(key);\n }\n }\n }\n\n state.destroy();\n return await this.load(key);\n },\n\n push(...items: RuntimeQueueItem[]) {\n for (const item of items) {\n const [rawKey, callback] = isQueueTuple(item) ? item : [item.key, item.cb];\n const key = rawKey as AdLibAttributeKey;\n let state = this.modules[key];\n\n if (state && (state.status === 'ready' || state.status === 'error')) {\n callback(state);\n continue;\n }\n\n if (!state || state.status !== 'loading') {\n this.load(key);\n state = this.modules[key];\n }\n\n if (!state) continue;\n\n if (state.promise) {\n state.promise.then(() => callback(state)).catch(() => callback(state));\n } else {\n callback(state);\n }\n }\n },\n\n applyLoaderConfig: () => {},\n\n destroy(options) {\n for (const solution in this.modules) {\n this.modules[solution as keyof typeof this.modules]?.destroy?.();\n }\n\n observerCtl.stop();\n\n if (!options?.keepGlobal) {\n return;\n }\n },\n\n getState(key) {\n if (!key) {\n return this.modules;\n }\n\n return (\n this.modules[key] ?? {\n key,\n status: 'idle',\n reload: (options) => this.reload(key, options),\n destroy: () => {\n this.process.delete(key);\n },\n }\n );\n },\n\n getErrors() {\n const errors = [];\n for (const [key, state] of Object.entries(this.modules)) {\n if (state?.status === 'error' && state.error) {\n errors.push({ key: key as AdLibAttributeKey, error: state.error });\n }\n }\n return errors;\n },\n\n isLoaded(key) {\n return this.modules[key]?.status === 'ready';\n },\n\n initFromScripts(source) {\n const nextScripts = source?.scripts ?? [];\n\n const seen = new Set<HTMLScriptElement>(this.scripts);\n for (const s of nextScripts) {\n if (!seen.has(s)) {\n seen.add(s);\n this.scripts.push(s);\n }\n }\n\n const scanned = scanRequestedKeysFromScripts(this.scripts);\n const provided = source?.requestedKeys ?? [];\n const requestedKeys = Array.from(new Set([...provided, ...scanned]));\n\n if (!this.auto) return;\n\n void (async () => {\n for (const key of requestedKeys) {\n try {\n await this.load(key);\n } catch {\n // best-effort: l'erreur est port\u00E9e par l'\u00E9tat module\n }\n }\n })();\n },\n } as RuntimeWithInternals);\n\n const observerCtl =\n runtime.observerCtl ?? createRuntimeObserverController(runtime as RuntimeWithInternals);\n runtime.observerCtl = observerCtl;\n\n runtime.applyLoaderConfig = (patch) => {\n const wasDebug = runtime.debug;\n applyLoaderConfigCumulative(runtime, patch);\n\n // If debug just activated, create logger + attach devtools\n if (!wasDebug && runtime.debug) {\n const ir = runtime as RuntimeWithInternals;\n if (!ir.logger?.enabled) {\n ir.logger = createLogger({\n enabled: true,\n channels: ir.debugChannels,\n });\n }\n attachRuntimeDevtools(runtime);\n }\n\n observerCtl.ensureStarted();\n };\n\n if (!existingRuntime) {\n window.AdLibAttributes = runtime;\n }\n\n drainPreLoaderQueueIntoRuntime(runtime);\n\n const scripts = discoverLoaderScripts(import.meta.url);\n const { config, flags } = readLoaderConfigFromScripts(scripts);\n const requestedKeys = scanRequestedKeysFromScripts(scripts);\n\n // Store debugChannels before applying config (applyLoaderConfig may need them)\n const ir = runtime as RuntimeWithInternals;\n ir.debugChannels = parseDebugChannels(flags.debugChannels);\n\n runtime.applyLoaderConfig({\n config,\n debug: flags.debug,\n auto: flags.auto,\n observeAttributes: flags.observeAttributes,\n });\n\n // Ensure a logger exists (no-op logger when debug=false)\n if (!ir.logger) {\n ir.logger = createLogger({ enabled: false });\n }\n\n ir.logger.info('runtime', 'boot', {\n version: runtime.version,\n debug: runtime.debug,\n auto: runtime.auto,\n });\n ir.logger.debug('loader', 'scripts discovered', {\n count: scripts.length,\n keys: requestedKeys,\n });\n\n runtime.initFromScripts({ scripts, requestedKeys });\n\n // Init Attributes\n initAttributes();\n};\n\nexport function bootstrapAttributesLoader(): void {\n if (!isBrowser()) return;\n\n onDOMReady(() => {\n init();\n });\n}\n\n/**\n * Inits all Attributes that are defined in the current script\n * or in the DOM if ad-attributes-auto is enabled.\n */\nconst initAttributes = () => {\n let autoLoad = false;\n\n for (const script of window.AdLibAttributes.scripts) {\n autoLoad ||= script.getAttribute(`${ATTRIBUTES_ATTRIBUTE_PREFIX}-auto`) === 'true';\n\n for (const key of ATTRIBUTE_KEYS) {\n const isDefined = script.hasAttribute(`ad-${key}`);\n if (!isDefined) continue;\n\n initAttribute(key);\n }\n }\n\n if (!autoLoad) return;\n\n waitDOMReady().then(() => {\n const usedAttributes = new Set<AdLibAttributeKey>();\n const allElements = document.querySelectorAll('*');\n\n for (const element of allElements) {\n for (const name of element.getAttributeNames()) {\n const adMatch = name.match(/^ad-([^-]+)/);\n const key = adMatch?.[1] as AdLibAttributeKey | undefined;\n\n if (key && ATTRIBUTE_KEYS.has(key)) {\n usedAttributes.add(key);\n }\n }\n }\n\n for (const attribute of usedAttributes) {\n initAttribute(attribute);\n }\n });\n};\n\n/**\n * Inits an individual Attribute.\n * @param key\n * @param script The <script> tag that defines the Attribute.\n *\n * @returns A Promise that resolves once the Attribute has loaded and executed.\n */\nconst initAttribute = async (key: AdLibAttributeKey) => {\n const isModuleKey = (k: string) => /^[a-z][a-z0-9-]*$/i.test(k);\n const runtime = window.AdLibAttributes as unknown as RuntimeWithInternals;\n const state = (runtime.modules[key] ??= {\n key,\n status: 'idle',\n reload: (options) => runtime.reload(key, options),\n destroy: () => {\n runtime.process.delete(key);\n },\n }) satisfies RuntimeModuleState;\n\n if (!isModuleKey(String(key))) {\n const err = new AdLibRuntimeError({\n code: 'UNKNOWN_MODULE_KEY',\n message: `Unknown module key: ${String(key)}`,\n key,\n });\n state.status = 'error';\n state.error = err;\n emitRuntimeEvent('ad:module:error', { key, state, error: err });\n return state;\n }\n\n // Ensure that the attribute is only initted once\n if (runtime.process.has(key)) return state;\n\n runtime.process.add(key);\n state.status = 'loading';\n runtime.logger?.debug('module', `loading ${key}`, { key });\n emitRuntimeEvent('ad:module:before', { key, state });\n\n // Load Attribute package\n const loadPromise = (async () => {\n let mod: Awaited<ReturnType<typeof loadAttribute>>;\n\n try {\n mod = await loadAttribute(key);\n } catch (err) {\n runtime.logger?.error('module', `Failed to import module ${key}`, { key, cause: err });\n const runtimeError = asRuntimeError(err, {\n code: 'MODULE_IMPORT_FAILED',\n message: `Failed to import module ${key}`,\n key,\n meta: {},\n });\n state.status = 'error';\n state.error = runtimeError;\n state.instance = undefined;\n emitRuntimeEvent('ad:module:error', { key, state, error: runtimeError });\n return undefined;\n }\n\n try {\n const { init } = mod;\n\n // Init attribute\n const { result, destroy } = (await init()) || {};\n\n state.instance = result;\n state.status = 'ready';\n state.error = undefined;\n emitRuntimeEvent('ad:module:after', { key, state });\n\n state.destroy = () => {\n try {\n destroy?.();\n runtime.process.delete(key);\n state.status = 'idle';\n state.instance = undefined;\n state.error = undefined;\n state.promise = undefined;\n } catch (err) {\n runtime.logger?.error('module', `Failed to destroy module ${key}`, { key, cause: err });\n const runtimeError = asRuntimeError(err, {\n code: 'MODULE_DESTROY_FAILED',\n message: `Failed to destroy module ${key}`,\n key,\n meta: {},\n });\n state.status = 'error';\n state.error = runtimeError;\n state.instance = undefined;\n emitRuntimeEvent('ad:module:error', { key, state, error: runtimeError });\n }\n };\n\n return result;\n } catch (err) {\n runtime.logger?.error('module', `Failed to init module ${key}`, { key, cause: err });\n const runtimeError = asRuntimeError(err, {\n code: 'MODULE_INIT_FAILED',\n message: `Failed to init module ${key}`,\n key,\n meta: {},\n });\n state.status = 'error';\n state.error = runtimeError;\n state.instance = undefined;\n emitRuntimeEvent('ad:module:error', { key, state, error: runtimeError });\n return undefined;\n }\n })();\n\n state.promise = loadPromise;\n\n await loadPromise;\n\n return state;\n};\n\n// Init\nbootstrapAttributesLoader();\n", "{\n \"name\": \"@adartem/adlib-attributes\",\n \"version\": \"0.1.8\",\n \"description\": \"ADARTEM AdLib Attributes (ad-*).\",\n \"homepage\": \"https://adartem.fr/attributes\",\n \"license\": \"MIT\",\n \"private\": false,\n \"publishConfig\": { \"access\": \"public\" },\n \"type\": \"module\",\n \"main\": \"attributes.js\",\n \"types\": \"./src/attributes.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./src/attributes.ts\",\n \"import\": \"./attributes.js\"\n },\n \"./attributes.js\": {\n \"import\": \"./attributes.js\"\n }\n },\n \"sideEffects\": [\n \"./attributes.js\"\n ],\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/adartem/adlib.git\",\n \"directory\": \"packages/adlib-attributes\"\n },\n \"files\": [\n \"dist\",\n \"attributes.js\",\n \"attributes.js.map\",\n \"README.md\",\n \"LICENSE\"\n ],\n \"scripts\": {\n \"build\": \"cross-env NODE_ENV=production tsx ./bin/build.ts\",\n \"lint\": \"eslint ./src && prettier --check ./src\",\n \"lint:fix\": \"eslint ./src --fix && prettier --write ./src\",\n \"typecheck\": \"tsc --noEmit\",\n \"test:unit\": \"vitest run -c ../../vitest.config.ts\",\n \"test:e2e\": \"pnpm playwright test --pass-with-no-tests\",\n \"test:headed\": \"pnpm playwright test --headed --pass-with-no-tests\",\n \"test\": \"pnpm test:unit && pnpm test:e2e\",\n \"clean\": \"rimraf dist node_modules test-results playwright-report attributes.js attributes.js.map\",\n \"dev\": \"cross-env NODE_ENV=development tsx ./bin/build.ts\"\n },\n \"keywords\": [\n \"adlib\",\n \"adartem\",\n \"attributes\",\n \"runtime\",\n \"cdn\",\n \"declarative\"\n ],\n \"author\": {\n \"name\": \"Adartem\",\n \"url\": \"https://adartem.fr/\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/adartem/adlib/issues\"\n },\n \"dependencies\": {\n \"@adartem/ad-accordion\": \"workspace:*\",\n \"@adartem/adlib-utils\": \"workspace:*\",\n \"@adartem/ad-codehighlight\": \"workspace:*\",\n \"@adartem/ad-autovideo\": \"workspace:*\",\n \"@adartem/ad-combobox\": \"workspace:*\",\n \"@adartem/ad-copyclip\": \"workspace:*\",\n \"@adartem/ad-displayvalues\": \"workspace:*\",\n \"@adartem/ad-favcustom\": \"workspace:*\",\n \"@adartem/ad-formsubmit\": \"workspace:*\",\n \"@adartem/ad-inject\": \"workspace:*\",\n \"@adartem/ad-inputactive\": \"workspace:*\",\n \"@adartem/ad-inputcounter\": \"workspace:*\",\n \"@adartem/ad-list\": \"workspace:*\",\n \"@adartem/ad-mirrorclick\": \"workspace:*\",\n \"@adartem/ad-mirrorinput\": \"workspace:*\",\n \"@adartem/ad-modal\": \"workspace:*\",\n \"@adartem/ad-numbercount\": \"workspace:*\",\n \"@adartem/ad-queryparam\": \"workspace:*\",\n \"@adartem/ad-rangeslider\": \"workspace:*\",\n \"@adartem/ad-readtime\": \"workspace:*\",\n \"@adartem/ad-removequery\": \"workspace:*\",\n \"@adartem/ad-scrolldisable\": \"workspace:*\",\n \"@adartem/ad-selectcustom\": \"workspace:*\",\n \"@adartem/ad-sliderdots\": \"workspace:*\",\n \"@adartem/ad-smartlightbox\": \"workspace:*\",\n \"@adartem/ad-socialshare\": \"workspace:*\",\n \"@adartem/ad-starrating\": \"workspace:*\",\n \"@adartem/ad-toc\": \"workspace:*\",\n \"@adartem/ad-videohls\": \"workspace:*\"\n },\n \"devDependencies\": {\n \"@types/node\": \"^20.14.9\",\n \"cross-env\": \"^10.1.0\",\n \"esbuild\": \"^0.27.2\",\n \"esbuild-plugin-inline-worker\": \"^0.1.1\",\n \"tsx\": \"^4.19.2\"\n }\n}", "import { type AdLibAttributeKey } from '@adartem/adlib-utils';\n\n/**\n * Dynamically loads an attribute package.\n * @param key\n */\nexport const loadAttribute = async (key: AdLibAttributeKey) => {\n switch (key) {\n case 'accordion': {\n return import('@adartem/ad-accordion');\n }\n\n case 'autovideo': {\n return import('@adartem/ad-autovideo');\n }\n\n case 'codehighlight': {\n return import('@adartem/ad-codehighlight');\n }\n\n case 'combobox': {\n return import('@adartem/ad-combobox');\n }\n\n case 'copyclip': {\n return import('@adartem/ad-copyclip');\n }\n\n case 'displayvalues': {\n return import('@adartem/ad-displayvalues');\n }\n\n case 'favcustom': {\n return import('@adartem/ad-favcustom');\n }\n\n case 'formsubmit': {\n return import('@adartem/ad-formsubmit');\n }\n\n case 'inject': {\n return import('@adartem/ad-inject');\n }\n\n case 'inputactive': {\n return import('@adartem/ad-inputactive');\n }\n\n case 'inputcounter': {\n return import('@adartem/ad-inputcounter');\n }\n\n case 'list': {\n return import('@adartem/ad-list');\n }\n\n case 'mirrorclick': {\n return import('@adartem/ad-mirrorclick');\n }\n\n case 'mirrorinput': {\n return import('@adartem/ad-mirrorinput');\n }\n\n case 'modal': {\n return import('@adartem/ad-modal');\n }\n\n case 'numbercount': {\n return import('@adartem/ad-numbercount');\n }\n\n case 'queryparam': {\n return import('@adartem/ad-queryparam');\n }\n\n case 'rangeslider': {\n return import('@adartem/ad-rangeslider');\n }\n\n case 'readtime': {\n return import('@adartem/ad-readtime');\n }\n\n case 'removequery': {\n return import('@adartem/ad-removequery');\n }\n\n case 'scrolldisable': {\n return import('@adartem/ad-scrolldisable');\n }\n\n case 'selectcustom': {\n return import('@adartem/ad-selectcustom');\n }\n\n case 'sliderdots': {\n return import('@adartem/ad-sliderdots');\n }\n\n case 'smartlightbox': {\n return import('@adartem/ad-smartlightbox');\n }\n\n case 'socialshare': {\n return import('@adartem/ad-socialshare');\n }\n\n case 'starrating': {\n return import('@adartem/ad-starrating');\n }\n\n case 'toc': {\n return import('@adartem/ad-toc');\n }\n\n case 'videohls': {\n return import('@adartem/ad-videohls');\n }\n\n default: {\n throw `Adartem Attribute \"${key}\" is not supported.`;\n }\n }\n};\n", "function stripHashAndQuery(u: string): string {\n const i = u.search(/[?#]/);\n return i === -1 ? u : u.slice(0, i);\n}\n\nfunction safeToURL(u: string, base: string): URL | null {\n try {\n return new URL(u, base);\n } catch {\n return null;\n }\n}\n\nfunction sameNormalizedPath(a: URL, b: URL): boolean {\n // Compare by pathname suffix to tolerate origin/CDN rewrites; ignore query/hash\n return stripHashAndQuery(a.pathname).endsWith(stripHashAndQuery(b.pathname));\n}\n\nexport function discoverLoaderScripts(currentImportMetaUrl: string): HTMLScriptElement[] {\n if (typeof document === 'undefined') return [];\n\n const scripts = Array.from(\n document.querySelectorAll('script[type=\"module\"][src]'),\n ) as HTMLScriptElement[];\n const base =\n document.baseURI || (typeof location !== 'undefined' ? location.href : 'http://localhost/');\n const current = safeToURL(currentImportMetaUrl, base);\n if (!current) return [];\n\n const matches: HTMLScriptElement[] = [];\n\n for (const s of scripts) {\n const src = s.getAttribute('src');\n if (!src) continue;\n const u = safeToURL(src, base);\n if (!u) continue;\n\n if (sameNormalizedPath(u, current)) {\n matches.push(s);\n }\n }\n\n return matches;\n}\n", "import type { AdLibRuntimeConfig } from '../runtime/types';\n\nexport type LoaderFlags = {\n debug?: boolean;\n auto?: boolean;\n observeAttributes?: boolean;\n debugChannels?: string;\n};\n\nfunction readBoolAttr(s: HTMLScriptElement, name: string): boolean | undefined {\n const v = s.getAttribute(name);\n if (v === null) return undefined;\n // presence-only => true\n if (v === '' || v.toLowerCase() === 'true') return true;\n if (v.toLowerCase() === 'false') return false;\n return true;\n}\n\nexport function readLoaderConfigFromScripts(scripts: HTMLScriptElement[]): {\n config: AdLibRuntimeConfig;\n flags: LoaderFlags;\n} {\n const config: AdLibRuntimeConfig = {};\n const flags: LoaderFlags = {};\n\n for (const s of scripts) {\n // Shallow-merge config: last-one-wins (DOM order is deterministic)\n const registry = s.getAttribute('data-adlib-registry');\n const version = s.getAttribute('data-adlib-version');\n const base = s.getAttribute('data-adlib-base');\n\n if (registry) config.registry = registry;\n if (version) config.version = version;\n if (base) config.base = base;\n\n // Flags OR-only: once true, stay true\n const debug = readBoolAttr(s, 'data-adlib-debug');\n const auto = readBoolAttr(s, 'data-adlib-auto');\n const observe = readBoolAttr(s, 'data-adlib-observe-attributes');\n\n if (debug === true) flags.debug = true;\n if (auto === true) flags.auto = true;\n if (observe === true) flags.observeAttributes = true;\n\n const channels = s.getAttribute('data-adlib-debug-channels');\n if (channels) flags.debugChannels = channels;\n }\n\n return { config, flags };\n}\n", "import type { AdLibAttributeKey } from '@adartem/adlib-utils';\n\nconst AD_KEY_RE = /^ad-[a-z0-9-]+$/i;\nconst DATA_AD_KEY_RE = /^data-ad-[a-z0-9-]+$/i;\n\nfunction toModuleKey(attrName: string): AdLibAttributeKey | null {\n // data-ad-foo -> foo\n if (DATA_AD_KEY_RE.test(attrName)) {\n return attrName.slice('data-ad-'.length) as AdLibAttributeKey;\n }\n // ad-foo -> foo\n if (AD_KEY_RE.test(attrName)) {\n return attrName.slice('ad-'.length) as AdLibAttributeKey;\n }\n return null;\n}\n\nexport function scanRequestedKeysFromScripts(scripts: HTMLScriptElement[]): AdLibAttributeKey[] {\n const out = new Set<AdLibAttributeKey>();\n\n for (const s of scripts) {\n // IMPORTANT: on scanne les noms d\u2019attributs, pas leurs valeurs\n // Objectif: <script ... ad-foo ad-bar data-ad-baz ...>\n for (const { name } of Array.from(s.attributes)) {\n // Ignore reserved loader config namespace\n if (name.startsWith('data-adlib-')) continue;\n\n const key = toModuleKey(name);\n if (key) out.add(key);\n }\n }\n\n return Array.from(out);\n}\n", "import type { AdLibRuntime, AdLibRuntimeConfig } from './types';\n\nexport type LoaderConfigPatch = Partial<\n Pick<AdLibRuntime, 'debug' | 'auto' | 'observeAttributes'>\n> & {\n config?: Partial<AdLibRuntimeConfig>;\n};\n\nexport function applyLoaderConfigCumulative(runtime: AdLibRuntime, patch: LoaderConfigPatch): void {\n // Shallow merge of config (only defined keys)\n if (patch.config) {\n runtime.config = {\n ...runtime.config,\n ...patch.config,\n };\n }\n\n // OR-only toggles: once true, always true\n if (patch.debug === true) runtime.debug = true;\n if (patch.auto === true) runtime.auto = true;\n if (patch.observeAttributes === true) runtime.observeAttributes = true;\n\n // Important: do NOT allow turning flags off\n // - if patch.debug is false/undefined -> no-op\n // - same for auto/observeAttributes\n}\n", "import { AdLibRuntimeError } from './errors';\nimport type { AdLibLogger } from './logger';\nimport type { RuntimeObserverController } from './observer';\nimport type {\n AdLibRuntime,\n RuntimeDevtools,\n RuntimeObserverDiagnostics,\n RuntimeSnapshot,\n RuntimeSnapshotModule,\n} from './types';\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\n/**\n * Build module snapshots, omitting keys whose value is `undefined`.\n */\nfunction toSnapshotModules(runtime: AdLibRuntime): RuntimeSnapshotModule[] {\n const out: RuntimeSnapshotModule[] = [];\n\n for (const [key, state] of Object.entries(runtime.modules)) {\n if (!state) continue;\n\n const entry: RuntimeSnapshotModule = {\n key,\n status: state.status,\n };\n\n const errorCode = state.error instanceof AdLibRuntimeError ? state.error.code : undefined;\n if (errorCode !== undefined) {\n entry.errorCode = errorCode;\n }\n\n out.push(entry);\n }\n\n // stable order for diffs/logs\n out.sort((a, b) => a.key.localeCompare(b.key));\n return out;\n}\n\n/**\n * Return a clean copy of observer diagnostics with no `undefined` keys.\n */\nfunction cleanDiagnostics(diag: RuntimeObserverDiagnostics): RuntimeObserverDiagnostics {\n const out: RuntimeObserverDiagnostics = {\n flushCount: diag.flushCount,\n receivedMutations: diag.receivedMutations,\n droppedMutations: diag.droppedMutations,\n };\n if (diag.lastCapReason !== undefined) {\n out.lastCapReason = diag.lastCapReason;\n }\n return out;\n}\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\n\nexport function createRuntimeDevtools(\n runtime: AdLibRuntime,\n logger?: AdLibLogger,\n): RuntimeDevtools {\n function getObserverDiagnostics(): RuntimeObserverDiagnostics | undefined {\n const ctl = (runtime as AdLibRuntime & { observerCtl?: RuntimeObserverController }).observerCtl;\n return ctl?.getDiagnostics?.();\n }\n\n const snapshot = (): RuntimeSnapshot => {\n const s: RuntimeSnapshot = {\n version: runtime.version,\n debug: runtime.debug,\n auto: runtime.auto,\n observeAttributes: runtime.observeAttributes,\n config: runtime.config,\n scriptsCount: runtime.scripts.length,\n modules: toSnapshotModules(runtime),\n };\n\n const observerDiag = getObserverDiagnostics();\n if (observerDiag) {\n s.observer = cleanDiagnostics(observerDiag);\n }\n\n return s;\n };\n\n const devtoolsLog = logger?.child('devtools');\n\n return {\n runtime,\n snapshot,\n modules: () => toSnapshotModules(runtime),\n dump: () => {\n const s = snapshot();\n\n // Human-friendly output (best-effort, never crash)\n try {\n if (typeof console.groupCollapsed === 'function') {\n console.groupCollapsed('[adlib:devtools] Runtime snapshot');\n console.info(\n 'version:',\n s.version,\n '| debug:',\n s.debug,\n '| auto:',\n s.auto,\n '| observeAttributes:',\n s.observeAttributes,\n );\n if (s.modules.length > 0 && typeof console.table === 'function') {\n console.table(s.modules);\n }\n if (s.observer) {\n console.info('observer:', s.observer);\n }\n console.groupEnd();\n } else {\n console.info('[adlib:devtools] Runtime snapshot', s);\n }\n } catch {\n // best-effort\n }\n\n // Structured log (filterable via channels)\n devtoolsLog?.debug('dump', s);\n\n return s;\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Window attachment (conditional on debug)\n// ---------------------------------------------------------------------------\n\nexport function attachRuntimeDevtools(runtime: AdLibRuntime): void {\n if (typeof window === 'undefined') return;\n\n const w = window as Window & { __ADLIB_DEBUG__?: RuntimeDevtools };\n\n // Idempotent attach\n if (w.__ADLIB_DEBUG__?.runtime === runtime) return;\n\n const { logger } = runtime as AdLibRuntime & { logger?: AdLibLogger };\n w.__ADLIB_DEBUG__ = createRuntimeDevtools(runtime, logger);\n}\n", "import type { AdLibAttributeKey } from '@adartem/adlib-utils';\n\nexport type AdLibRuntimeErrorCode =\n | 'UNKNOWN_MODULE_KEY'\n | 'MODULE_IMPORT_FAILED'\n | 'MODULE_INIT_FAILED'\n | 'MODULE_DESTROY_FAILED';\n\nexport class AdLibRuntimeError extends Error {\n public readonly code: AdLibRuntimeErrorCode;\n public readonly key?: AdLibAttributeKey;\n public readonly cause?: unknown;\n public readonly meta?: Record<string, unknown>;\n\n constructor(args: {\n code: AdLibRuntimeErrorCode;\n message: string;\n key?: AdLibAttributeKey;\n cause?: unknown;\n meta?: Record<string, unknown>;\n }) {\n super(args.message);\n this.name = 'AdLibRuntimeError';\n this.code = args.code;\n this.key = args.key;\n this.cause = args.cause;\n this.meta = args.meta;\n }\n}\n\nexport function asRuntimeError(\n err: unknown,\n fallback: {\n code: AdLibRuntimeErrorCode;\n message: string;\n key?: AdLibAttributeKey;\n meta?: Record<string, unknown>;\n },\n): AdLibRuntimeError {\n if (err instanceof AdLibRuntimeError) return err;\n return new AdLibRuntimeError({\n code: fallback.code,\n message: fallback.message,\n key: fallback.key,\n cause: err,\n meta: fallback.meta,\n });\n}\n", "import { isBrowser } from './env';\n\nexport function onDOMReady(fn: () => void): void {\n if (!isBrowser()) return;\n\n if (document.readyState === 'interactive' || document.readyState === 'complete') {\n fn();\n return;\n }\n\n document.addEventListener(\n 'DOMContentLoaded',\n () => {\n fn();\n },\n { once: true },\n );\n}\n", "export function isBrowser(): boolean {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n}\n\nexport function hasDOMBody(): boolean {\n return isBrowser() && !!document.body;\n}\n", "import type { AdLibRuntime, RuntimeQueueItem } from './types';\n\ntype GlobalQueue = Array<unknown> & { __adlib_drained__?: true };\ntype GlobalAttributes = AdLibRuntime | GlobalQueue | undefined;\ntype WindowWithAdLibAttributes = Omit<Window, 'AdLibAttributes'> & {\n AdLibAttributes?: GlobalAttributes;\n};\n\nfunction isQueue(x: unknown): x is GlobalQueue {\n return Array.isArray(x);\n}\n\nfunction isRuntimeLike(x: unknown): x is AdLibRuntime {\n return (\n !!x &&\n typeof x === 'object' &&\n 'push' in x &&\n typeof (x as { push?: unknown }).push === 'function'\n );\n}\n\nexport function drainPreLoaderQueueIntoRuntime(runtime: AdLibRuntime): void {\n if (typeof window === 'undefined') return;\n\n const globalWindow = window as unknown as WindowWithAdLibAttributes;\n const current = globalWindow.AdLibAttributes as unknown;\n\n // If runtime is already installed, nothing to do.\n if (isRuntimeLike(current)) return;\n\n // Only drain if it\u2019s an array queue.\n if (!isQueue(current)) return;\n\n // Idempotence guard: avoid draining twice.\n if (current.__adlib_drained__ === true) return;\n\n const items = current.slice() as RuntimeQueueItem[];\n current.length = 0;\n current.__adlib_drained__ = true;\n\n if (items.length > 0) {\n runtime.push(...items);\n }\n\n // Replace global with the runtime instance.\n globalWindow.AdLibAttributes = runtime;\n}\n", "import type { RuntimeModuleEventDetail, RuntimeModuleEventName } from './types';\n\nexport function emitRuntimeEvent(\n name: RuntimeModuleEventName,\n detail: RuntimeModuleEventDetail,\n): void {\n if (typeof window === 'undefined') return;\n\n try {\n const ev = new CustomEvent<RuntimeModuleEventDetail>(name, { detail });\n window.dispatchEvent(ev);\n } catch {\n // best-effort: never crash runtime because of event emission\n }\n}\n", "// ---------------------------------------------------------------------------\n// Structured logger \u2013 silent by default, channel-filterable\n// ---------------------------------------------------------------------------\n\nexport type AdLibLogLevel = 'debug' | 'info' | 'warn' | 'error';\n\nexport type AdLibLogChannel = 'runtime' | 'loader' | 'core' | 'module' | 'observer' | 'devtools';\n\nexport type LoggerConfig = {\n enabled: boolean;\n channels?: ReadonlySet<string>;\n namespace?: string;\n};\n\nexport type StructuredLog = {\n ns: string;\n ch: string;\n level: string;\n msg: string;\n time: number;\n data?: unknown;\n};\n\nexport type ChildLogger = {\n debug(msg: string, data?: unknown): void;\n info(msg: string, data?: unknown): void;\n warn(msg: string, data?: unknown): void;\n error(msg: string, data?: unknown): void;\n};\n\nexport type AdLibLogger = {\n enabled: boolean;\n channels?: ReadonlySet<string>;\n log(level: AdLibLogLevel, channel: string, msg: string, data?: unknown): void;\n debug(channel: string, msg: string, data?: unknown): void;\n info(channel: string, msg: string, data?: unknown): void;\n warn(channel: string, msg: string, data?: unknown): void;\n error(channel: string, msg: string, data?: unknown): void;\n child(channel: string): ChildLogger;\n};\n\n// ---------------------------------------------------------------------------\n// No-op singletons (zero-alloc when disabled)\n// ---------------------------------------------------------------------------\n\nconst NOOP = () => {};\n\nconst noopChild: ChildLogger = {\n debug: NOOP,\n info: NOOP,\n warn: NOOP,\n error: NOOP,\n};\n\nconst noopLogger: AdLibLogger = {\n enabled: false,\n log: NOOP,\n debug: NOOP,\n info: NOOP,\n warn: NOOP,\n error: NOOP,\n child: () => noopChild,\n};\n\n// ---------------------------------------------------------------------------\n// Console method mapping\n// ---------------------------------------------------------------------------\n\nconst CONSOLE_METHOD: Record<AdLibLogLevel, 'debug' | 'info' | 'warn' | 'error'> = {\n debug: 'debug',\n info: 'info',\n warn: 'warn',\n error: 'error',\n};\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\n\nexport function createLogger(config: LoggerConfig): AdLibLogger {\n if (!config.enabled) return noopLogger;\n\n const ns = config.namespace ?? 'adlib';\n const { channels } = config;\n\n function log(level: AdLibLogLevel, channel: string, msg: string, data?: unknown): void {\n if (channels && !channels.has(channel)) return;\n\n const payload: StructuredLog = {\n ns,\n ch: channel,\n level,\n msg,\n time: Date.now(),\n };\n\n if (data !== undefined) {\n payload.data = data;\n }\n\n try {\n const method = CONSOLE_METHOD[level];\n console[method](`[${ns}:${channel}] ${msg}`, payload);\n } catch {\n // best-effort: never crash on logging\n }\n }\n\n return {\n enabled: true,\n channels,\n log,\n debug: (ch, msg, data) => log('debug', ch, msg, data),\n info: (ch, msg, data) => log('info', ch, msg, data),\n warn: (ch, msg, data) => log('warn', ch, msg, data),\n error: (ch, msg, data) => log('error', ch, msg, data),\n child(channel: string): ChildLogger {\n return {\n debug: (msg, data) => log('debug', channel, msg, data),\n info: (msg, data) => log('info', channel, msg, data),\n warn: (msg, data) => log('warn', channel, msg, data),\n error: (msg, data) => log('error', channel, msg, data),\n };\n },\n };\n}\n\n// ---------------------------------------------------------------------------\n// Debug-channels parser (CSV \u2192 Set)\n// ---------------------------------------------------------------------------\n\n/**\n * Parse a CSV string of debug channels into a `Set`.\n * Returns `undefined` when absent / empty (= all channels allowed).\n */\nexport function parseDebugChannels(raw: string | null | undefined): Set<string> | undefined {\n if (!raw) return undefined;\n\n const channels = raw\n .split(',')\n .map((s) => s.trim())\n .filter(Boolean);\n\n return channels.length > 0 ? new Set(channels) : undefined;\n}\n", "import type { AdLibAttributeKey } from '@adartem/adlib-utils';\n\nimport type { AdLibLogger } from './logger';\nimport { scanKeysFromNodes } from './scan-dom-keys';\nimport type { AdLibRuntime, ObserverCapReason, RuntimeObserverDiagnostics } from './types';\n\n// ---------------------------------------------------------------------------\n// Attribute-name \u2192 module-key helpers\n// ---------------------------------------------------------------------------\n\nconst AD_KEY_RE = /^ad-[a-z0-9-]+$/i;\nconst DATA_AD_KEY_RE = /^data-ad-[a-z0-9-]+$/i;\n\nfunction attrNameToKey(name: string): AdLibAttributeKey | null {\n if (DATA_AD_KEY_RE.test(name)) return name.slice('data-ad-'.length) as AdLibAttributeKey;\n if (AD_KEY_RE.test(name)) return name.slice('ad-'.length) as AdLibAttributeKey;\n return null;\n}\n\n// ---------------------------------------------------------------------------\n// Caps (internal, non-public)\n// ---------------------------------------------------------------------------\n\nconst MAX_MUTATIONS_PER_FLUSH = 200;\nconst MAX_NODES_PER_FLUSH = 1000;\nconst MAX_KEYS_PER_FLUSH = 50;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\ntype Mode = 'nodes' | 'nodes+attrs';\n\nexport type RuntimeObserverController = {\n isActive: () => boolean;\n ensureStarted: () => void;\n stop: () => void;\n getDiagnostics: () => RuntimeObserverDiagnostics;\n};\n\n// ---------------------------------------------------------------------------\n// Scheduling helper (microtask-first, never synchronous loop)\n// ---------------------------------------------------------------------------\n\nfunction scheduleMicrotask(fn: () => void): void {\n if (typeof queueMicrotask === 'function') {\n queueMicrotask(fn);\n } else {\n void Promise.resolve().then(fn);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Controller factory\n// ---------------------------------------------------------------------------\n\nexport function createRuntimeObserverController(runtime: AdLibRuntime): RuntimeObserverController {\n let observer: MutationObserver | null = null;\n let observing = false;\n let lastMode: Mode | null = null;\n\n // ---- Backlog (raw MutationRecords) ------------------------------------\n\n let backlog: MutationRecord[] = [];\n let flushScheduled = false;\n\n // ---- Diagnostics (best-effort) ----------------------------------------\n\n const diagnostics: RuntimeObserverDiagnostics = {\n flushCount: 0,\n receivedMutations: 0,\n droppedMutations: 0,\n lastCapReason: undefined,\n };\n\n // ---- Logger accessor (runtime.logger is set after observer creation) ---\n\n type RuntimeWithLogger = AdLibRuntime & { logger?: AdLibLogger };\n\n function log(level: 'debug' | 'info', msg: string, data?: unknown): void {\n (runtime as RuntimeWithLogger).logger?.[level]('observer', msg, data);\n }\n\n // ---- Enqueue ----------------------------------------------------------\n\n function enqueue(mutations: MutationRecord[]): void {\n diagnostics.receivedMutations += mutations.length;\n for (const m of mutations) backlog.push(m);\n log('debug', 'enqueue', { count: mutations.length, backlog: backlog.length });\n scheduleFlush();\n }\n\n // ---- Flush with caps --------------------------------------------------\n\n function flush(): void {\n flushScheduled = false;\n\n if (backlog.length === 0) return;\n\n diagnostics.flushCount++;\n\n // Cap 1: mutations processed this flush\n const mutationsToProcess = backlog.slice(0, MAX_MUTATIONS_PER_FLUSH);\n const remaining = backlog.slice(MAX_MUTATIONS_PER_FLUSH);\n\n let capReason: ObserverCapReason | undefined;\n\n if (remaining.length > 0) {\n capReason = 'MAX_MUTATIONS';\n diagnostics.droppedMutations += remaining.length;\n }\n\n // Collect nodes + attr names from the chunk\n const addedNodes: Node[] = [];\n const attrNames: string[] = [];\n\n let nodeCount = 0;\n let nodeCapped = false;\n\n for (const m of mutationsToProcess) {\n if (m.type === 'childList') {\n for (const n of Array.from(m.addedNodes)) {\n if (nodeCount >= MAX_NODES_PER_FLUSH) {\n nodeCapped = true;\n break;\n }\n addedNodes.push(n);\n nodeCount++;\n }\n if (nodeCapped) break;\n continue;\n }\n\n if (m.type === 'attributes') {\n if (!runtime.observeAttributes) continue;\n const name = m.attributeName;\n if (!name) continue;\n attrNames.push(name);\n }\n }\n\n if (nodeCapped && !capReason) {\n capReason = 'MAX_NODES';\n }\n\n // Derive keys (capped)\n const keysFromNodes = scanKeysFromNodes(addedNodes);\n\n const keysFromAttrs = new Set<AdLibAttributeKey>();\n for (const name of attrNames) {\n if (name.startsWith('data-adlib-')) continue;\n const key = attrNameToKey(name);\n if (key) keysFromAttrs.add(key);\n }\n\n let allKeys = Array.from(new Set([...keysFromNodes, ...Array.from(keysFromAttrs)]));\n\n if (allKeys.length > MAX_KEYS_PER_FLUSH) {\n if (!capReason) capReason = 'MAX_KEYS';\n allKeys = allKeys.slice(0, MAX_KEYS_PER_FLUSH);\n }\n\n if (capReason) {\n diagnostics.lastCapReason = capReason;\n }\n\n log('debug', 'flush', {\n processed: mutationsToProcess.length,\n keys: allKeys,\n ...(capReason ? { capReason } : {}),\n });\n\n // Replace backlog with leftovers\n backlog = remaining;\n\n // Trigger loads (best-effort, async, never blocks)\n if (allKeys.length > 0) {\n void (async () => {\n for (const key of allKeys) {\n try {\n await runtime.load(key);\n } catch {\n // best-effort; error is stored in module state\n }\n }\n })();\n }\n\n // Reschedule if backlog still has items\n if (backlog.length > 0) {\n scheduleFlush();\n }\n }\n\n // ---- Schedule (one flush per tick, never sync loop) -------------------\n\n function scheduleFlush(): void {\n if (flushScheduled) return;\n flushScheduled = true;\n scheduleMicrotask(flush);\n }\n\n // ---- MutationObserver callback ----------------------------------------\n\n function handleMutations(mutations: MutationRecord[]): void {\n enqueue(mutations);\n }\n\n // ---- Connection management --------------------------------------------\n\n function desiredMode(): Mode {\n return runtime.observeAttributes ? 'nodes+attrs' : 'nodes';\n }\n\n function connect(mode: Mode): void {\n if (typeof document === 'undefined') return;\n const root = document.body;\n if (!root) return;\n\n if (!observer) observer = new MutationObserver(handleMutations);\n\n // If already observing with the right mode, no-op.\n if (observing && lastMode === mode) return;\n\n // Reconnect when mode changes.\n observer.disconnect();\n\n const base: MutationObserverInit = {\n subtree: true,\n childList: true,\n };\n\n const opts: MutationObserverInit =\n mode === 'nodes+attrs' ? { ...base, attributes: true, attributeOldValue: false } : base;\n\n observer.observe(root, opts);\n observing = true;\n lastMode = mode;\n }\n\n // ---- Public API -------------------------------------------------------\n\n return {\n isActive: () => observing,\n\n ensureStarted: () => {\n connect(desiredMode());\n },\n\n stop: () => {\n if (!observer) return;\n observer.disconnect();\n observing = false;\n lastMode = null;\n flushScheduled = false;\n backlog = [];\n },\n\n getDiagnostics: () => ({ ...diagnostics }),\n };\n}\n", "import type { AdLibAttributeKey } from '@adartem/adlib-utils';\n\nconst AD_KEY_RE = /^ad-[a-z0-9-]+$/i;\nconst DATA_AD_KEY_RE = /^data-ad-[a-z0-9-]+$/i;\n\nfunction attrNameToKey(name: string): AdLibAttributeKey | null {\n if (name.startsWith('data-adlib-')) return null; // reserved namespace\n if (DATA_AD_KEY_RE.test(name)) return name.slice('data-ad-'.length) as AdLibAttributeKey;\n if (AD_KEY_RE.test(name)) return name.slice('ad-'.length) as AdLibAttributeKey;\n return null;\n}\n\nfunction scanElement(el: Element, out: Set<AdLibAttributeKey>) {\n for (const { name } of Array.from(el.attributes)) {\n const key = attrNameToKey(name);\n if (key) out.add(key);\n }\n}\n\nexport function scanKeysFromNodes(nodes: Node[]): AdLibAttributeKey[] {\n const out = new Set<AdLibAttributeKey>();\n\n for (const n of nodes) {\n if (n.nodeType !== 1) continue;\n const el = n as Element;\n\n scanElement(el, out);\n\n // Also scan descendants (best-effort)\n for (const child of Array.from(el.querySelectorAll('*'))) {\n scanElement(child, out);\n }\n }\n\n return Array.from(out);\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;AAAA;;;ACEE,cAAW;;;ACFb;AAMO,IAAM,gBAAgB,OAAO,QAA2B;AAC7D,UAAQ,KAAK;AAAA,IACX,KAAK,aAAa;AAChB,aAAO,OAAO,yBAAuB;AAAA,IACvC;AAAA,IAEA,KAAK,aAAa;AAChB,aAAO,OAAO,yBAAuB;AAAA,IACvC;AAAA,IAEA,KAAK,iBAAiB;AACpB,aAAO,OAAO,yBAA2B;AAAA,IAC3C;AAAA,IAEA,KAAK,YAAY;AACf,aAAO,OAAO,yBAAsB;AAAA,IACtC;AAAA,IAEA,KAAK,YAAY;AACf,aAAO,OAAO,yBAAsB;AAAA,IACtC;AAAA,IAEA,KAAK,iBAAiB;AACpB,aAAO,OAAO,yBAA2B;AAAA,IAC3C;AAAA,IAEA,KAAK,aAAa;AAChB,aAAO,OAAO,yBAAuB;AAAA,IACvC;AAAA,IAEA,KAAK,cAAc;AACjB,aAAO,OAAO,yBAAwB;AAAA,IACxC;AAAA,IAEA,KAAK,UAAU;AACb,aAAO,OAAO,yBAAoB;AAAA,IACpC;AAAA,IAEA,KAAK,eAAe;AAClB,aAAO,OAAO,yBAAyB;AAAA,IACzC;AAAA,IAEA,KAAK,gBAAgB;AACnB,aAAO,OAAO,yBAA0B;AAAA,IAC1C;AAAA,IAEA,KAAK,QAAQ;AACX,aAAO,OAAO,yBAAkB;AAAA,IAClC;AA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,KAAK;AAAA,QACvC,MAAM;AAAA,QACN,SAAS,yBAAyB,GAAG;AAAA,QACrC;AAAA,QACA,MAAM,CAAC;AAAA,MACT,CAAC;AACD,YAAM,SAAS;AACf,YAAM,QAAQ;AACd,YAAM,WAAW;AACjB,uBAAiB,mBAAmB,EAAE,KAAK,OAAO,OAAO,aAAa,CAAC;AACvE,aAAO;AAAA,IACT;AAAA,EACF,GAAG;AAEH,QAAM,UAAU;AAEhB,QAAM;AAEN,SAAO;AACT;AAGA,0BAA0B;",
|
|
6
6
|
"names": ["version", "AD_KEY_RE", "DATA_AD_KEY_RE", "AD_KEY_RE", "DATA_AD_KEY_RE", "attrNameToKey", "requestedKeys", "ir", "init"]
|
|
7
7
|
}
|
|
@@ -28,13 +28,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
));
|
|
29
29
|
|
|
30
30
|
// bin/live-reload.js
|
|
31
|
+
var LOCAL_HOSTS;
|
|
31
32
|
var init_live_reload = __esm({
|
|
32
33
|
"bin/live-reload.js"() {
|
|
33
34
|
"use strict";
|
|
34
|
-
new
|
|
35
|
-
|
|
36
|
-
()
|
|
37
|
-
|
|
35
|
+
LOCAL_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1"]);
|
|
36
|
+
if (LOCAL_HOSTS.has(window.location.hostname)) {
|
|
37
|
+
new EventSource(`http://localhost:${3001}/esbuild`).addEventListener(
|
|
38
|
+
"change",
|
|
39
|
+
() => location.reload()
|
|
40
|
+
);
|
|
41
|
+
}
|
|
38
42
|
}
|
|
39
43
|
});
|
|
40
44
|
|
|
@@ -5773,4 +5777,4 @@ export {
|
|
|
5773
5777
|
ir,
|
|
5774
5778
|
Ae
|
|
5775
5779
|
};
|
|
5776
|
-
//# sourceMappingURL=chunk-
|
|
5780
|
+
//# sourceMappingURL=chunk-5M74UMX2.js.map
|