driftjs-shared 0.0.13 → 0.0.14
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 +14 -13
- 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)}}}}
|
|
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)}}}}function h(e,t,n){!e||typeof e!=`object`||t===`__proto__`||t===`constructor`||t===`prototype`||t===`__drift_mark_dirty__`||(e[t]=n)}function g(e,t,r,i,a){if(h(e,t,r),i&&h(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;h(e,t,s===void 0?_(r,e):s)}else a.startsWith(`{`)||a.startsWith(`[`)?g(e,a,Object.prototype.hasOwnProperty.call(n,i)?n[i]:void 0,null,0):h(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;h(e,i,o===void 0?_(a,e):o)}else h(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];h(e,a,s===void 0?_(o,e):s)}else n.startsWith(`{`)||n.startsWith(`[`)?g(e,n,i[t],null,0):h(e,n,i[t])}}}function _(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}}}function v(e,t,n){g(e,t,n,null,0)}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.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.populateAsyncScope=v,exports.populateItemScope=g,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
|
@@ -240,13 +240,11 @@ function m(e, t) {
|
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
|
|
244
|
-
typeof globalThis < "u" && !globalThis._get && (globalThis._get = m);
|
|
245
|
-
function g(e, t, n) {
|
|
243
|
+
function h(e, t, n) {
|
|
246
244
|
!e || typeof e != "object" || t === "__proto__" || t === "constructor" || t === "prototype" || t === "__drift_mark_dirty__" || (e[t] = n);
|
|
247
245
|
}
|
|
248
|
-
function
|
|
249
|
-
if (
|
|
246
|
+
function g(e, t, r, i, a) {
|
|
247
|
+
if (h(e, t, r), i && h(e, i, a), t.startsWith("{") && t.endsWith("}")) {
|
|
250
248
|
let n = r && typeof r == "object" ? r : {}, i = u(t.slice(1, -1));
|
|
251
249
|
for (let t of i) {
|
|
252
250
|
let r = l(t, ":");
|
|
@@ -254,14 +252,14 @@ function _(e, t, r, i, a) {
|
|
|
254
252
|
let i = t.slice(0, r).trim(), a = t.slice(r + 1).trim(), o = l(a, "=");
|
|
255
253
|
if (o !== -1) {
|
|
256
254
|
let t = a.slice(0, o).trim(), r = a.slice(o + 1).trim(), s = Object.prototype.hasOwnProperty.call(n, i) ? n[i] : void 0;
|
|
257
|
-
|
|
258
|
-
} else a.startsWith("{") || a.startsWith("[") ?
|
|
255
|
+
h(e, t, s === void 0 ? _(r, e) : s);
|
|
256
|
+
} else a.startsWith("{") || a.startsWith("[") ? g(e, a, Object.prototype.hasOwnProperty.call(n, i) ? n[i] : void 0, null, 0) : h(e, a, Object.prototype.hasOwnProperty.call(n, i) ? n[i] : void 0);
|
|
259
257
|
} else {
|
|
260
258
|
let r = l(t, "=");
|
|
261
259
|
if (r !== -1) {
|
|
262
260
|
let i = t.slice(0, r).trim(), a = t.slice(r + 1).trim(), o = Object.prototype.hasOwnProperty.call(n, i) ? n[i] : void 0;
|
|
263
|
-
|
|
264
|
-
} else
|
|
261
|
+
h(e, i, o === void 0 ? _(a, e) : o);
|
|
262
|
+
} else h(e, t, Object.prototype.hasOwnProperty.call(n, t) ? n[t] : void 0);
|
|
265
263
|
}
|
|
266
264
|
}
|
|
267
265
|
} else if (t.startsWith("[") && t.endsWith("]")) {
|
|
@@ -270,12 +268,12 @@ function _(e, t, r, i, a) {
|
|
|
270
268
|
let n = a[t], r = l(n, "=");
|
|
271
269
|
if (r !== -1) {
|
|
272
270
|
let a = n.slice(0, r).trim(), o = n.slice(r + 1).trim(), s = i[t];
|
|
273
|
-
|
|
274
|
-
} else n.startsWith("{") || n.startsWith("[") ?
|
|
271
|
+
h(e, a, s === void 0 ? _(o, e) : s);
|
|
272
|
+
} else n.startsWith("{") || n.startsWith("[") ? g(e, n, i[t], null, 0) : h(e, n, i[t]);
|
|
275
273
|
}
|
|
276
274
|
}
|
|
277
275
|
}
|
|
278
|
-
function
|
|
276
|
+
function _(e, t) {
|
|
279
277
|
let n = e.trim();
|
|
280
278
|
if (n === "true") return !0;
|
|
281
279
|
if (n === "false") return !1;
|
|
@@ -290,6 +288,9 @@ function v(e, t) {
|
|
|
290
288
|
}
|
|
291
289
|
}
|
|
292
290
|
}
|
|
291
|
+
function v(e, t, n) {
|
|
292
|
+
g(e, t, n, null, 0);
|
|
293
|
+
}
|
|
293
294
|
//#endregion
|
|
294
295
|
//#region src/context.ts
|
|
295
296
|
var y = Symbol.for("__drift_vm_stack__");
|
|
@@ -371,4 +372,4 @@ function P(e) {
|
|
|
371
372
|
return String(e);
|
|
372
373
|
}
|
|
373
374
|
//#endregion
|
|
374
|
-
export { e as MAX_REGISTERS, t as VOID_ELEMENTS,
|
|
375
|
+
export { e as MAX_REGISTERS, t as VOID_ELEMENTS, 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, v as populateAsyncScope, g 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 };
|