driftjs-shared 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index-cjs.js +1 -1
- package/dist/index-es.js +15 -7
- package/package.json +1 -1
package/dist/index-cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=256,t=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);function n(e){return Array.isArray(e)?e:e&&typeof e[Symbol.iterator]==`function`?Array.from(e):[]}function r(e,t,r){if(typeof e==`function`)return e(t,r,f,p,n,m);if(typeof e.__drift_fn__==`function`)return e.__drift_fn__(t,r,f,p,n,m);if(typeof e._executableFn==`function`)return e._executableFn(t,r,f,p,n,m)}function i(e,t,a){if(e==null)return e;if(typeof e==`function`)return e(t,a,f,p,n,m);if(typeof e==`object`&&e){if(`__drift_fn__`in e||typeof e._executableFn==`function`)return r(e,t,a);if(Array.isArray(e)){let n;for(let r of e)n=i(r,t,a);return n}}return e}function a(e){return!e||typeof e!=`object`?null:Array.isArray(e.bytecode)||ArrayBuffer.isView(e.bytecode)?e:e.program&&(Array.isArray(e.program.bytecode)||ArrayBuffer.isView(e.program.bytecode))?e.program:e.default?a(e.default):e.compiledModule?a(e.compiledModule):null}function o(e,t,n){if(!e||typeof e!=`object`)return{};let r={};for(let a of Object.keys(e)){if(a===`__drift_props__`||a===`__drift_children__`||a===`__proto__`||a===`constructor`||a===`prototype`)continue;let o=e[a];r[a]=i(o,t,n)}return r}function s(e,t){let n=t-1;for(;n>=0&&/\s/.test(e[n]);)n--;if(n<0)return!0;let r=e[n];return/[(,=:[!&|?+\-*/%^~<>]/.test(r)}function c(e,t){let n=0,r=0,i=0,a=null,o=!1,c=!1,l=!1,u=!1,d=!1,f=[];for(let p=0;p<e.length;p++){let m=e[p];if(a!==null){if(o){o=!1;continue}if(m===`\\`){o=!0;continue}if(a==="`"&&m===`$`&&e[p+1]===`{`){f.push(i),a=null,p++,i++;continue}if(m===a){a=null;continue}continue}if(c){m===`
|
|
2
|
-
`&&(c=!1);continue}if(l){m===`*`&&e[p+1]===`/`&&(l=!1,p++);continue}if(u){if(o){o=!1;continue}if(m===`\\`){o=!0;continue}if(d){m===`]`&&(d=!1);continue}if(m===`[`){d=!0;continue}if(m===`/`){u=!1;continue}continue}if(m===`/`&&e[p+1]===`/`){c=!0,p++;continue}if(m===`/`&&e[p+1]===`*`){l=!0,p++;continue}if(m===`/`&&s(e,p)){u=!0,d=!1;continue}if(m===`'`||m===`"`||m==="`"){a=m;continue}if(m===`(`){n++;continue}if(m===`)`){n=Math.max(0,n-1);continue}if(m===`[`){r++;continue}if(m===`]`){r=Math.max(0,r-1);continue}if(m===`{`){i++;continue}if(m===`}`){i=Math.max(0,i-1),f.length>0&&i===f[f.length-1]&&(f.pop(),a="`");continue}if(n===0&&r===0&&i===0&&a===null&&!c&&!l&&!u){let e=t(p,m);if(typeof e==`number`)return e;if(e===!0)return p}}return-1}function l(e,t){return c(e,(e,n)=>n===t)}function u(e,t=`,`){let n=[],r=0;c(e,(i,a)=>{if(a===t){let t=e.slice(r,i).trim();t&&n.push(t),r=i+1}});let i=e.slice(r).trim();return i&&n.push(i),n}function d(e){let t=e.trim();if(!t.startsWith(`(`)||!t.endsWith(`)`))return!1;let n=0,r=null,i=!1;for(let e=0;e<t.length-1;e++){let a=t[e];if(r!==null){i?i=!1:a===`\\`?i=!0:a===r&&(r=null);continue}if(a===`"`||a===`'`||a==="`"){r=a;continue}if(a===`(`?n++:a===`)`&&n--,n===0)return!1}return n===1}function f(e,t,n){if(!e||typeof e!=`object`||t===`__proto__`||t===`constructor`||t===`prototype`||t===`__drift_mark_dirty__`)return n;let r=e,i=null,a=[];for(;r&&r!==Object.prototype;){if(typeof r.__drift_mark_dirty__==`function`&&a.push(r.__drift_mark_dirty__),Object.prototype.hasOwnProperty.call(r,t)){r[t]=n,i=r;break}r=Object.getPrototypeOf(r)}if(i||(e[t]=n),!t.startsWith(`__drift_`))for(let e=0;e<a.length;e++)try{a[e](t)}catch(e){console.error(`[DriftJS] Error notifying dirty update for "${t}":`,e)}return n}function p(e,t){if(!e||typeof e!=`object`)return!1;let n=e;for(;n&&n!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(n,t))return!0;n=Object.getPrototypeOf(n)}return!1}function m(e,t){if(!(t===`__proto__`||t===`constructor`||t===`prototype`||t===`__drift_mark_dirty__`)){if(e&&typeof e==`object`){let n=e;for(;n&&n!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(n,t))return n[t];n=Object.getPrototypeOf(n)}}if(typeof globalThis<`u`&&globalThis){let e=globalThis;for(;e&&e!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(e,t))return globalThis[t];e=Object.getPrototypeOf(e)}}}}var h=m;typeof globalThis<`u`&&!globalThis._get&&(globalThis._get=m);function g(e,t,n){!e||typeof e!=`object`||t===`__proto__`||t===`constructor`||t===`prototype`||t===`__drift_mark_dirty__`||(e[t]=n)}function _(e,t,r,i,a){if(g(e,t,r),i&&g(e,i,a),t.startsWith(`{`)&&t.endsWith(`}`)){let n=r&&typeof r==`object`?r:{},i=u(t.slice(1,-1));for(let t of i){let r=l(t,`:`);if(r!==-1){let i=t.slice(0,r).trim(),a=t.slice(r+1).trim(),o=l(a,`=`);if(o!==-1){let t=a.slice(0,o).trim(),r=a.slice(o+1).trim(),s=Object.prototype.hasOwnProperty.call(n,i)?n[i]:void 0;g(e,t,s===void 0?v(r,e):s)}else a.startsWith(`{`)||a.startsWith(`[`)?_(e,a,Object.prototype.hasOwnProperty.call(n,i)?n[i]:void 0,null,0):g(e,a,Object.prototype.hasOwnProperty.call(n,i)?n[i]:void 0)}else{let r=l(t,`=`);if(r!==-1){let i=t.slice(0,r).trim(),a=t.slice(r+1).trim(),o=Object.prototype.hasOwnProperty.call(n,i)?n[i]:void 0;g(e,i,o===void 0?v(a,e):o)}else g(e,t,Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0)}}}else if(t.startsWith(`[`)&&t.endsWith(`]`)){let i=n(r),a=u(t.slice(1,-1));for(let t=0;t<a.length;t++){let n=a[t],r=l(n,`=`);if(r!==-1){let a=n.slice(0,r).trim(),o=n.slice(r+1).trim(),s=i[t];g(e,a,s===void 0?v(o,e):s)}else n.startsWith(`{`)||n.startsWith(`[`)?_(e,n,i[t],null,0):g(e,n,i[t])}}}function v(e,t){let n=e.trim();if(n===`true`)return!0;if(n===`false`)return!1;if(n===`null`)return null;if(n!==`undefined`){if(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`)||n.startsWith("`")&&n.endsWith("`"))return n.slice(1,-1);if(!Number.isNaN(Number(n))&&n!==``)return Number(n);try{return JSON.parse(n)}catch{return t&&p(t,n)?m(t,n):n}}}var y=Symbol.for(`__drift_vm_stack__`);function b(){let e=globalThis;return e[y]||(e[y]=[]),e[y]}function x(e){b().push(e)}function S(){b().pop()}function C(){let e=b();return e.length>0?e[e.length-1]:null}function w(e,t){let n={id:Symbol(t||`DriftContext`),name:t,defaultValue:e,provide(e){T(n,e)},inject(e){return E(n,e)}};return n}function T(e,t){let n=C();if(!n||!n.contextMap)throw Error(`provide() can only be called inside the <script> block of a DriftJS component during instantiation.`);n.contextMap.set(e.id,t)}function E(e,t){let n=C();if(!n)return t===void 0?e.defaultValue:t;let r=n;for(;r;){if(r.contextMap&&r.contextMap.has(e.id))return r.contextMap.get(e.id);r=r.parentVM}return t===void 0?e.defaultValue:t}var D=T,O=E;function k(e){let t=C();t?(t.unmountCallbacks||=[],t.unmountCallbacks.push(e)):console.warn(`[DriftJS] onUnmount() was called outside a component execution context. Lifecycle hooks must be called synchronously during component setup.`)}var
|
|
2
|
+
`&&(c=!1);continue}if(l){m===`*`&&e[p+1]===`/`&&(l=!1,p++);continue}if(u){if(o){o=!1;continue}if(m===`\\`){o=!0;continue}if(d){m===`]`&&(d=!1);continue}if(m===`[`){d=!0;continue}if(m===`/`){u=!1;continue}continue}if(m===`/`&&e[p+1]===`/`){c=!0,p++;continue}if(m===`/`&&e[p+1]===`*`){l=!0,p++;continue}if(m===`/`&&s(e,p)){u=!0,d=!1;continue}if(m===`'`||m===`"`||m==="`"){a=m;continue}if(m===`(`){n++;continue}if(m===`)`){n=Math.max(0,n-1);continue}if(m===`[`){r++;continue}if(m===`]`){r=Math.max(0,r-1);continue}if(m===`{`){i++;continue}if(m===`}`){i=Math.max(0,i-1),f.length>0&&i===f[f.length-1]&&(f.pop(),a="`");continue}if(n===0&&r===0&&i===0&&a===null&&!c&&!l&&!u){let e=t(p,m);if(typeof e==`number`)return e;if(e===!0)return p}}return-1}function l(e,t){return c(e,(e,n)=>n===t)}function u(e,t=`,`){let n=[],r=0;c(e,(i,a)=>{if(a===t){let t=e.slice(r,i).trim();t&&n.push(t),r=i+1}});let i=e.slice(r).trim();return i&&n.push(i),n}function d(e){let t=e.trim();if(!t.startsWith(`(`)||!t.endsWith(`)`))return!1;let n=0,r=null,i=!1;for(let e=0;e<t.length-1;e++){let a=t[e];if(r!==null){i?i=!1:a===`\\`?i=!0:a===r&&(r=null);continue}if(a===`"`||a===`'`||a==="`"){r=a;continue}if(a===`(`?n++:a===`)`&&n--,n===0)return!1}return n===1}function f(e,t,n){if(!e||typeof e!=`object`||t===`__proto__`||t===`constructor`||t===`prototype`||t===`__drift_mark_dirty__`)return n;let r=e,i=null,a=[];for(;r&&r!==Object.prototype;){if(typeof r.__drift_mark_dirty__==`function`&&a.push(r.__drift_mark_dirty__),Object.prototype.hasOwnProperty.call(r,t)){r[t]=n,i=r;break}r=Object.getPrototypeOf(r)}if(i||(e[t]=n),!t.startsWith(`__drift_`))for(let e=0;e<a.length;e++)try{a[e](t)}catch(e){console.error(`[DriftJS] Error notifying dirty update for "${t}":`,e)}return n}function p(e,t){if(!e||typeof e!=`object`)return!1;let n=e;for(;n&&n!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(n,t))return!0;n=Object.getPrototypeOf(n)}return!1}function m(e,t){if(!(t===`__proto__`||t===`constructor`||t===`prototype`||t===`__drift_mark_dirty__`)){if(e&&typeof e==`object`){let n=e;for(;n&&n!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(n,t))return n[t];n=Object.getPrototypeOf(n)}}if(typeof globalThis<`u`&&globalThis){let e=globalThis;for(;e&&e!==Object.prototype;){if(Object.prototype.hasOwnProperty.call(e,t))return globalThis[t];e=Object.getPrototypeOf(e)}}}}var h=m;typeof globalThis<`u`&&!globalThis._get&&(globalThis._get=m);function g(e,t,n){!e||typeof e!=`object`||t===`__proto__`||t===`constructor`||t===`prototype`||t===`__drift_mark_dirty__`||(e[t]=n)}function _(e,t,r,i,a){if(g(e,t,r),i&&g(e,i,a),t.startsWith(`{`)&&t.endsWith(`}`)){let n=r&&typeof r==`object`?r:{},i=u(t.slice(1,-1));for(let t of i){let r=l(t,`:`);if(r!==-1){let i=t.slice(0,r).trim(),a=t.slice(r+1).trim(),o=l(a,`=`);if(o!==-1){let t=a.slice(0,o).trim(),r=a.slice(o+1).trim(),s=Object.prototype.hasOwnProperty.call(n,i)?n[i]:void 0;g(e,t,s===void 0?v(r,e):s)}else a.startsWith(`{`)||a.startsWith(`[`)?_(e,a,Object.prototype.hasOwnProperty.call(n,i)?n[i]:void 0,null,0):g(e,a,Object.prototype.hasOwnProperty.call(n,i)?n[i]:void 0)}else{let r=l(t,`=`);if(r!==-1){let i=t.slice(0,r).trim(),a=t.slice(r+1).trim(),o=Object.prototype.hasOwnProperty.call(n,i)?n[i]:void 0;g(e,i,o===void 0?v(a,e):o)}else g(e,t,Object.prototype.hasOwnProperty.call(n,t)?n[t]:void 0)}}}else if(t.startsWith(`[`)&&t.endsWith(`]`)){let i=n(r),a=u(t.slice(1,-1));for(let t=0;t<a.length;t++){let n=a[t],r=l(n,`=`);if(r!==-1){let a=n.slice(0,r).trim(),o=n.slice(r+1).trim(),s=i[t];g(e,a,s===void 0?v(o,e):s)}else n.startsWith(`{`)||n.startsWith(`[`)?_(e,n,i[t],null,0):g(e,n,i[t])}}}function v(e,t){let n=e.trim();if(n===`true`)return!0;if(n===`false`)return!1;if(n===`null`)return null;if(n!==`undefined`){if(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`)||n.startsWith("`")&&n.endsWith("`"))return n.slice(1,-1);if(!Number.isNaN(Number(n))&&n!==``)return Number(n);try{return JSON.parse(n)}catch{return t&&p(t,n)?m(t,n):n}}}var y=Symbol.for(`__drift_vm_stack__`);function b(){let e=globalThis;return e[y]||(e[y]=[]),e[y]}function x(e){b().push(e)}function S(){b().pop()}function C(){let e=b();return e.length>0?e[e.length-1]:null}function w(e,t){let n={id:Symbol(t||`DriftContext`),name:t,defaultValue:e,provide(e){T(n,e)},inject(e){return E(n,e)}};return n}function T(e,t){let n=C();if(!n||!n.contextMap)throw Error(`provide() can only be called inside the <script> block of a DriftJS component during instantiation.`);n.contextMap.set(e.id,t)}function E(e,t){let n=C();if(!n)return t===void 0?e.defaultValue:t;let r=n;for(;r;){if(r.contextMap&&r.contextMap.has(e.id))return r.contextMap.get(e.id);r=r.parentVM}return t===void 0?e.defaultValue:t}var D=T,O=E;function k(e){let t=C();t&&typeof t.registerProgrammaticEffect==`function`?t.registerProgrammaticEffect(e):t||console.warn(`[DriftJS] effect() was called outside a component execution context. Lifecycle hooks must be called synchronously during component setup.`)}function A(e){let t=C();t&&typeof t.registerProgrammaticEffect==`function`?t.registerProgrammaticEffect(e,!0):t||console.warn(`[DriftJS] onMount() was called outside a component execution context. Lifecycle hooks must be called synchronously during component setup.`)}function j(e){let t=C();t?(t.unmountCallbacks||=[],t.unmountCallbacks.push(e)):console.warn(`[DriftJS] onUnmount() was called outside a component execution context. Lifecycle hooks must be called synchronously during component setup.`)}var M=new Set(`animationIterationCount.borderImageOutset.borderImageSlice.borderImageWidth.boxFlex.boxFlexGroup.boxOrdinalGroup.columnCount.columns.flex.flexGrow.flexPositive.flexShrink.flexNegative.flexOrder.gridArea.gridRow.gridRowEnd.gridRowSpan.gridRowStart.gridColumn.gridColumnEnd.gridColumnSpan.gridColumnStart.fontWeight.lineClamp.lineHeight.opacity.order.orphans.tabSize.widows.zIndex.zoom.fillOpacity.floodOpacity.stopOpacity.strokeDasharray.strokeDashoffset.strokeMiterlimit.strokeOpacity.strokeWidth`.split(`.`));function N(e){return e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function P(e){if(e==null||e===!1||e===``)return``;if(typeof e==`string`)return e.trim();if(Array.isArray(e))return e.map(e=>P(e)).filter(e=>!!(e&&e.length>0)).join(`; `);if(typeof e==`object`){let t=[];for(let[n,r]of Object.entries(e)){if(r==null||r===!1||r===``)continue;let e=N(n),i=r;typeof r==`number`&&r!==0&&!M.has(n)&&(i=`${r}px`),t.push(`${e}: ${i}`)}return t.join(`; `)}return String(e)}exports.MAX_REGISTERS=e,exports.VOID_ELEMENTS=t,exports._get=h,exports.camelToKebab=N,exports.createContext=w,exports.effect=k,exports.evaluateExpression=i,exports.evaluatePropsSpec=o,exports.executePrecompiledFn=r,exports.findTopLevelChar=l,exports.getActiveVM=C,exports.getScopeValue=m,exports.hasMatchingOuterParens=d,exports.inScopeChain=p,exports.inject=O,exports.injectContext=E,exports.isRegexStartChar=s,exports.normalizeStyle=P,exports.onMount=A,exports.onUnmount=j,exports.popActiveVM=S,exports.populateItemScope=_,exports.provide=D,exports.provideContext=T,exports.pushActiveVM=x,exports.resolveComponentModule=a,exports.resolveIterable=n,exports.scanBalancedDelimiters=c,exports.setScopeValue=f,exports.splitPatternEntries=u;
|
package/dist/index-es.js
CHANGED
|
@@ -338,29 +338,37 @@ function E(e, t) {
|
|
|
338
338
|
}
|
|
339
339
|
var D = T, O = E;
|
|
340
340
|
function k(e) {
|
|
341
|
+
let t = C();
|
|
342
|
+
t && typeof t.registerProgrammaticEffect == "function" ? t.registerProgrammaticEffect(e) : t || console.warn("[DriftJS] effect() was called outside a component execution context. Lifecycle hooks must be called synchronously during component setup.");
|
|
343
|
+
}
|
|
344
|
+
function A(e) {
|
|
345
|
+
let t = C();
|
|
346
|
+
t && typeof t.registerProgrammaticEffect == "function" ? t.registerProgrammaticEffect(e, !0) : t || console.warn("[DriftJS] onMount() was called outside a component execution context. Lifecycle hooks must be called synchronously during component setup.");
|
|
347
|
+
}
|
|
348
|
+
function j(e) {
|
|
341
349
|
let t = C();
|
|
342
350
|
t ? (t.unmountCallbacks ||= [], t.unmountCallbacks.push(e)) : console.warn("[DriftJS] onUnmount() was called outside a component execution context. Lifecycle hooks must be called synchronously during component setup.");
|
|
343
351
|
}
|
|
344
352
|
//#endregion
|
|
345
353
|
//#region src/style.ts
|
|
346
|
-
var
|
|
347
|
-
function
|
|
354
|
+
var M = /* @__PURE__ */ new Set(/* @__PURE__ */ "animationIterationCount.borderImageOutset.borderImageSlice.borderImageWidth.boxFlex.boxFlexGroup.boxOrdinalGroup.columnCount.columns.flex.flexGrow.flexPositive.flexShrink.flexNegative.flexOrder.gridArea.gridRow.gridRowEnd.gridRowSpan.gridRowStart.gridColumn.gridColumnEnd.gridColumnSpan.gridColumnStart.fontWeight.lineClamp.lineHeight.opacity.order.orphans.tabSize.widows.zIndex.zoom.fillOpacity.floodOpacity.stopOpacity.strokeDasharray.strokeDashoffset.strokeMiterlimit.strokeOpacity.strokeWidth".split("."));
|
|
355
|
+
function N(e) {
|
|
348
356
|
return e.startsWith("--") ? e : e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
|
|
349
357
|
}
|
|
350
|
-
function
|
|
358
|
+
function P(e) {
|
|
351
359
|
if (e == null || e === !1 || e === "") return "";
|
|
352
360
|
if (typeof e == "string") return e.trim();
|
|
353
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
361
|
+
if (Array.isArray(e)) return e.map((e) => P(e)).filter((e) => !!(e && e.length > 0)).join("; ");
|
|
354
362
|
if (typeof e == "object") {
|
|
355
363
|
let t = [];
|
|
356
364
|
for (let [n, r] of Object.entries(e)) {
|
|
357
365
|
if (r == null || r === !1 || r === "") continue;
|
|
358
|
-
let e =
|
|
359
|
-
typeof r == "number" && r !== 0 && !
|
|
366
|
+
let e = N(n), i = r;
|
|
367
|
+
typeof r == "number" && r !== 0 && !M.has(n) && (i = `${r}px`), t.push(`${e}: ${i}`);
|
|
360
368
|
}
|
|
361
369
|
return t.join("; ");
|
|
362
370
|
}
|
|
363
371
|
return String(e);
|
|
364
372
|
}
|
|
365
373
|
//#endregion
|
|
366
|
-
export { e as MAX_REGISTERS, t as VOID_ELEMENTS, h as _get,
|
|
374
|
+
export { e as MAX_REGISTERS, t as VOID_ELEMENTS, h as _get, N as camelToKebab, w as createContext, k as effect, i as evaluateExpression, o as evaluatePropsSpec, r as executePrecompiledFn, l as findTopLevelChar, C as getActiveVM, m as getScopeValue, d as hasMatchingOuterParens, p as inScopeChain, O as inject, E as injectContext, s as isRegexStartChar, P as normalizeStyle, A as onMount, j as onUnmount, S as popActiveVM, _ as populateItemScope, D as provide, T as provideContext, x as pushActiveVM, a as resolveComponentModule, n as resolveIterable, c as scanBalancedDelimiters, f as setScopeValue, u as splitPatternEntries };
|