@jucie.io/engine-local-storage 1.0.7
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/README.md +21 -0
- package/dist/main.js +2 -0
- package/dist/main.js.map +7 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @jucie-engine/local-storage
|
|
2
|
+
|
|
3
|
+
Namespaced localStorage service for `@jucie.io/engine`. This service provides a clean API for managing browser localStorage with namespace isolation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @jucie-engine/local-storage
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Refer to the main [README.md](../../README.md) for comprehensive usage examples and API reference.
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- **Namespaced Storage**: Isolate storage by namespace to avoid key conflicts
|
|
18
|
+
- **Type-Safe Operations**: Automatic JSON serialization/deserialization
|
|
19
|
+
- **Storage Spaces**: Create isolated storage contexts within your application
|
|
20
|
+
- **Engine Integration**: Seamlessly integrates with @jucie.io/engine services
|
|
21
|
+
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var G=Object.freeze(Object.create(null));function $(t,e,r="value"){if(Array.isArray(e)){for(let n of e)if(I(t,n))return!0;let i=e.map(p).join(" | ");throw new TypeError(`${r} must be one of: ${i}. Got ${p(t)}`)}if(!I(t,e))throw new TypeError(`${r} must be ${p(e)}. Got ${p(t)}`);return!0}function I(t,e){return e===String?typeof t=="string":e===Number?typeof t=="number"&&!isNaN(t):e===Boolean?typeof t=="boolean":e===Symbol?typeof t=="symbol":e===BigInt?typeof t=="bigint":e===Function?typeof t=="function":e===Array?Array.isArray(t):e===Object?t!==null&&typeof t=="object"&&!Array.isArray(t):t instanceof e}function p(t){return t===String?"String":t===Number?"Number":t===Boolean?"Boolean":t===Array?"Array":t===Object?"Object":t===Function?"Function":t===Date?"Date":t===RegExp?"RegExp":t===Promise?"Promise":t===Map?"Map":t===Set?"Set":t===WeakMap?"WeakMap":t===WeakSet?"WeakSet":t===Symbol?"Symbol":t===BigInt?"BigInt":t===Error?"Error":typeof t=="string"?"string":typeof t=="number"?"number":typeof t=="boolean"?"boolean":typeof t=="symbol"?"symbol":typeof t=="bigint"?"bigint":typeof t=="function"?"function":Array.isArray(t)?"Array":t===null?"null":t===void 0?"undefined":typeof t=="object"?t.constructor?.name||"Object":"unknown"}function h(t,e="value"){return r=>$(r,t,e)}var m=new Map,j=new WeakMap;var c=(t,e=[])=>{let r=e.length>0?h(e,"return value"):null;if(m.has(t))return console.warn(`Definition type "${t}" already exists`),m.get(t);let i=(n,s,...l)=>{h(String,"name")(n),h(Function,"factory")(s);let a=(...o)=>{try{let d=[...o,...l],g=s(...d);if(r&&g===void 0)throw new Error(`Factory ${t} must return a value for ${n}`);return r&&r(g),g}catch(d){throw console.error(`Error creating definition "${n}"`,d),d}};return Object.defineProperty(a,"_name",{value:n,enumerable:!1,configurable:!1}),j.set(a,t),a};return m.set(t,i),i};var L=new Set(["__proto__","prototype","constructor"]),P=new Set(["use","install","uninstall","relay","state","debug"]),C=64,v=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function z(t,e="key"){if(L.has(t))throw new Error(`Illegal key "${t}" in ${e}`)}function w(t){if(z(t,"namespace"),typeof t!="string")throw new Error(`Namespace must be a string, got ${typeof t}`);if(!v.test(t))throw new Error(`Invalid namespace "${t}". Must be a valid JS identifier`);if(t.length>C)throw new Error(`Namespace "${t}" too long (max ${C} chars)`);if(P.has(t))throw new Error(`Namespace "${t}" is reserved`);return t}var b=c("MIDDLEWARE",[Function,Array]),A=c("ACTIONS",[Object]),E=c("UNINSTALL"),x=c("INITIALIZE"),S=c("GETTERS",[Object]);var y=class t{static create(e){return new t(e)}#e;#n;#t={MIDDLEWARE:null,GETTERS:null,ACTIONS:null,INITIALIZE:null,UNINSTALL:null};constructor(e){this.#e=e}#r(e,r,i){if(this.#t[e])throw new Error(`${e} already defined for ${this.#e}`);this.#t[e]=i(this.#e,r)}defineMiddleware=e=>this.#r("MIDDLEWARE",e,b);defineGetters=e=>this.#r("GETTERS",e,S);defineActions=e=>this.#r("ACTIONS",e,A);defineInitialize=e=>this.#r("INITIALIZE",e,x);defineUninstall=e=>this.#r("UNINSTALL",e,E);_toArray(){return[this.#t.MIDDLEWARE,this.#t.GETTERS,this.#t.ACTIONS,this.#t.INITIALIZE,this.#t.UNINSTALL].filter(Boolean)}};var f=class t{static#e=new Set;static manifest={name:"base",dependencies:[],version:"1.0.0",description:"Base extension template"};static config=null;static unique=!1;static configure(e={}){return{install:(r,i)=>this.install(r,i),manifest:this.manifest,config:{...this.config||this.manifest.defaults||{},...e},unique:!0,configured:!0}}static install(e,r){try{let{namespace:i}=this.manifest;w(i);let n=new this;t.#e.add(n),Object.defineProperty(n,"config",{value:Object.freeze({...r}),writable:!1,configurable:!1,enumerable:!1}),Object.defineProperty(n,"context",{get:()=>e(),configurable:!1,enumerable:!1}),Object.defineProperty(n,"useContext",{value:(...l)=>e(...l),writable:!1,configurable:!1,enumerable:!1});let s=y.create(i);if(n.setup){let l={defineActions:o=>s.defineActions(()=>o(e,r)),defineMiddleware:o=>s.defineMiddleware(()=>o(e,r)),defineGetters:o=>s.defineGetters(()=>o(e,r)),defineInitialize:o=>s.defineInitialize(()=>o(e,r)),defineUninstall:o=>s.defineUninstall(()=>o(e,r))},a=n.setup(l);return a?.then?a.then(()=>s._toArray()):s._toArray()}return n.middleware&&s.defineMiddleware(()=>n.middleware(e,r)),n.getters&&s.defineGetters(()=>n.getters(e,r)),n.actions&&s.defineActions(()=>n.actions(e,r)),n.initialize&&s.defineInitialize(()=>n.initialize(e,r)),n.uninstall&&s.defineUninstall(()=>n.uninstall(e,r)),s._toArray()}catch(i){throw i}}};var ze=Symbol("jucie.engine");var u=class{#e={};#n;constructor(e){if(!e)throw new Error("StorageSpace requires a space name");this.#n=e,this.#t()}#t(){try{let e=localStorage.getItem(this.#n);this.#e=e?JSON.parse(e):{}}catch(e){console.error(`Failed to load storage space "${this.#n}":`,e),this.#e={}}}#r(){try{localStorage.setItem(this.#n,JSON.stringify(this.#e))}catch(e){throw console.error(`Failed to save storage space "${this.#n}":`,e),e}}set(e,r){return this.#e[e]=r,this.#r(),r}get(e,r=null){return this.#e[e]??r}update(e,r){let i=this.get(e),n=r(i);return this.set(e,n),n}remove(e){let r=this.#e[e];return delete this.#e[e],this.#r(),r}getAll(){return{...this.#e}}clear(){this.#e={},this.#r()}has(e){return e in this.#e}keys(){return Object.keys(this.#e)}size(){return Object.keys(this.#e).length}getName(){return this.#n}};var O=class extends f{#e=new Map;static manifest={name:"LocalStorage",namespace:"localStorage",version:"1.0.0",description:"Namespaced localStorage service for browser storage"};initialize(){(typeof window>"u"||!window.localStorage)&&console.warn("localStorage not available - LocalStorage extension will use in-memory fallback")}actions(e){return{create:r=>{if(!r)throw new Error("Storage space name is required");return this.#e.has(r)||this.#e.set(r,new u(r)),this.#e.get(r)},use:r=>{if(!r)throw new Error("Storage space name is required");return this.#e.has(r)||this.#e.set(r,new u(r)),this.#e.get(r)},exists:r=>typeof window>"u"||!window.localStorage?this.#e.has(r):localStorage.getItem(r)!==null,destroy:r=>{typeof window<"u"&&window.localStorage&&localStorage.removeItem(r),this.#e.delete(r)},listSpaces:()=>{if(typeof window>"u"||!window.localStorage)return Array.from(this.#e.keys());let r=[];for(let i=0;i<localStorage.length;i++)r.push(localStorage.key(i));return r},clearAll:()=>{typeof window<"u"&&window.localStorage&&localStorage.clear(),this.#e.clear()}}}};export{O as LocalStorage};
|
|
2
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/lib/relay/src/Relay.js", "../../../src/utils/typeChecker.js", "../../../src/definitions/createDefinition.js", "../../../src/utils/asserts.js", "../../../src/definitions/defaults.js", "../../../src/definitions/DefinitionBuilder.js", "../../../src/ServiceProvider.js", "../../../src/global.js", "../src/StorageSpace.js", "../src/LocalStorage.js"],
|
|
4
|
+
"sourcesContent": ["// Simple, readable relay with wildcard matching and no indexing\n\nconst GLOBAL_NS_OBJ = Object.freeze(Object.create(null));\n\nfunction queueMicrotask(fn) {\n if (globalThis.queueMicrotask && typeof globalThis.queueMicrotask === 'function') {\n globalThis.queueMicrotask(fn);\n return;\n }\n setTimeout(fn, 0);\n}\n\nclass Channel {\n #nsObj; #relay;\n constructor(nsObj, relay) { this.#nsObj = nsObj; this.#relay = relay; }\n\n // Any source -> me\n on(event, handler) {\n return this.#relay.subscribe(event, GLOBAL_NS_OBJ, this.#nsObj, handler);\n }\n\n once(event, handler) {\n return this.#relay.once(event, GLOBAL_NS_OBJ, this.#nsObj, handler);\n }\n\n // Me -> everyone (sender never hears itself)\n broadcast(event, ...payload) {\n this.#relay.publish(event, this.#nsObj, GLOBAL_NS_OBJ, payload);\n }\n\n // Specific source -> me\n from(fromNs) {\n return {\n subscribe: (event, handler) => this.#relay.subscribe(event, fromNs, this.#nsObj, handler),\n once: (event, handler) => this.#relay.once(event, fromNs, this.#nsObj, handler),\n };\n }\n\n // Me -> specific target\n to(toNs) {\n return {\n publish: (event, ...payload) => this.#relay.publish(event, this.#nsObj, toNs, payload),\n publishAsync: (event, ...payload) => this.#relay.publishAsync(event, this.#nsObj, toNs, payload),\n };\n }\n}\n\nexport class Relay {\n #channels = new WeakMap(); // nsObj -> Channel\n #events = new Map(); // eventName -> Set<Listener>\n #onError = null;\n\n static create(config = {}) {\n return new Relay(config);\n }\n\n constructor({ onError = null } = {}) {\n this.#onError = onError;\n this.createChannel(GLOBAL_NS_OBJ);\n }\n\n // Public convenience\n channel(nsObj) { return this.createChannel(nsObj); }\n createChannel(nsObj) {\n if (this.#channels.has(nsObj)) return this.#channels.get(nsObj);\n const ch = new Channel(nsObj, this);\n this.#channels.set(nsObj, ch);\n return ch;\n }\n\n // Internal helpers\n #listeners(event) {\n let set = this.#events.get(event);\n if (!set) { set = new Set(); this.#events.set(event, set); }\n return set;\n }\n\n // Wildcard matcher:\n // - If published `from` is GLOBAL, it matches every listener.from\n // - If listener.from is GLOBAL, it matches every published from\n // Same for `to`. This makes broadcast (to = GLOBAL) hit specific targets too.\n static #matchSide(published, constraint) {\n return published === GLOBAL_NS_OBJ || constraint === GLOBAL_NS_OBJ || published === constraint;\n }\n\n static #matches(publishedFrom, publishedTo, listenerFrom, listenerTo) {\n return Relay.#matchSide(publishedFrom, listenerFrom)\n && Relay.#matchSide(publishedTo, listenerTo);\n }\n\n subscribe(event, from, to, handler) {\n const listener = { from, to, handler };\n this.#listeners(event).add(listener);\n return () => {\n const set = this.#events.get(event);\n if (set) set.delete(listener);\n };\n }\n\n once(event, from, to, handler) {\n let off = null;\n const wrapped = (payload) => {\n try { handler(payload); } finally { off && off(); }\n };\n off = this.subscribe(event, from, to, wrapped);\n return off;\n }\n\n offAllFor(nsObj) {\n for (const set of this.#events.values()) {\n for (const l of Array.from(set)) {\n if (l.from === nsObj || l.to === nsObj) set.delete(l);\n }\n }\n }\n\n listenerCount(event) {\n const set = this.#events.get(event);\n return set ? set.size : 0;\n }\n\n #deliver(event, from, to, payload) {\n const set = this.#events.get(event);\n if (!set || set.size === 0) return;\n\n for (const l of set) {\n // Always skip self-delivery\n if (l.to === from) continue;\n\n if (Relay.#matches(from, to, l.from, l.to)) {\n try { l.handler(...payload); }\n catch (err) { if (this.#onError) this.#onError(err, { event, from, to, listener: l }); }\n }\n }\n }\n\n publish(event, from, to, payload) {\n this.#deliver(event, from, to, payload);\n }\n\n publishAsync(event, from, to, payload) {\n queueMicrotask(() => this.#deliver(event, from, to, payload));\n }\n\n broadcast(event, from, payload) {\n this.publish(event, from, GLOBAL_NS_OBJ, payload);\n }\n}\n", "/**\n * Type Checker Utility\n * \n * Supports syntax like:\n * - createDefinition('action', [Array, Function]) // Array or Function\n * - createDefinition('name', String) // Must be String\n * - createDefinition('items', Array) // Must be Array\n * - createDefinition('callback', Function) // Must be Function\n * - createDefinition('value', [String, Number]) // String or Number\n */\n\n/**\n * Type definitions mapping constructor names to actual constructors\n */\nconst TYPE_MAP = {\n String,\n Number,\n Boolean,\n Array,\n Object,\n Function,\n Date,\n RegExp,\n Promise,\n Map,\n Set,\n WeakMap,\n WeakSet,\n Symbol,\n BigInt,\n Error,\n TypeError,\n RangeError,\n ReferenceError,\n SyntaxError,\n EvalError,\n URIError\n};\n\n/**\n * Checks if a value matches the expected type(s)\n * @param {*} value - The value to check\n * @param {Function|Array<Function>} expectedType - Single type or array of possible types\n * @param {string} name - Name of the parameter for error messages\n * @returns {boolean} - True if value matches expected type(s)\n */\nexport function checkType(value, expectedType, name = 'value') {\n // Handle array of possible types\n if (Array.isArray(expectedType)) {\n for (const type of expectedType) {\n if (matchesType(value, type)) {\n return true;\n }\n }\n \n const typeNames = expectedType.map(getTypeName).join(' | ');\n throw new TypeError(`${name} must be one of: ${typeNames}. Got ${getTypeName(value)}`);\n }\n \n // Handle single type\n if (!matchesType(value, expectedType)) {\n throw new TypeError(`${name} must be ${getTypeName(expectedType)}. Got ${getTypeName(value)}`);\n }\n \n return true;\n}\n\n/**\n * Checks if a value matches a specific type\n * @param {*} value - The value to check\n * @param {Function} type - The expected constructor/type\n * @returns {boolean} - True if value matches the type\n */\nfunction matchesType(value, type) {\n // Handle primitive constructors\n if (type === String) {\n return typeof value === 'string';\n }\n if (type === Number) {\n return typeof value === 'number' && !isNaN(value);\n }\n if (type === Boolean) {\n return typeof value === 'boolean';\n }\n if (type === Symbol) {\n return typeof value === 'symbol';\n }\n if (type === BigInt) {\n return typeof value === 'bigint';\n }\n if (type === Function) {\n return typeof value === 'function';\n }\n \n // Handle object constructors (including Array, Object, Date, etc.)\n if (type === Array) {\n return Array.isArray(value);\n }\n if (type === Object) {\n return value !== null && typeof value === 'object' && !Array.isArray(value);\n }\n \n // Handle other constructors (Date, RegExp, Map, Set, etc.)\n return value instanceof type;\n}\n\n/**\n * Gets a human-readable name for a type\n * @param {*} value - The value or constructor to get name for\n * @returns {string} - Human-readable type name\n */\nfunction getTypeName(value) {\n if (value === String) return 'String';\n if (value === Number) return 'Number';\n if (value === Boolean) return 'Boolean';\n if (value === Array) return 'Array';\n if (value === Object) return 'Object';\n if (value === Function) return 'Function';\n if (value === Date) return 'Date';\n if (value === RegExp) return 'RegExp';\n if (value === Promise) return 'Promise';\n if (value === Map) return 'Map';\n if (value === Set) return 'Set';\n if (value === WeakMap) return 'WeakMap';\n if (value === WeakSet) return 'WeakSet';\n if (value === Symbol) return 'Symbol';\n if (value === BigInt) return 'BigInt';\n if (value === Error) return 'Error';\n \n if (typeof value === 'string') return 'string';\n if (typeof value === 'number') return 'number';\n if (typeof value === 'boolean') return 'boolean';\n if (typeof value === 'symbol') return 'symbol';\n if (typeof value === 'bigint') return 'bigint';\n if (typeof value === 'function') return 'function';\n if (Array.isArray(value)) return 'Array';\n if (value === null) return 'null';\n if (value === undefined) return 'undefined';\n if (typeof value === 'object') {\n return value.constructor?.name || 'Object';\n }\n \n return 'unknown';\n}\n\n/**\n * Creates a type checker function for a specific parameter\n * @param {Function|Array<Function>} expectedType - Expected type(s)\n * @param {string} name - Parameter name\n * @returns {Function} - Type checker function\n */\nexport function createTypeChecker(expectedType, name = 'value') {\n return (value) => checkType(value, expectedType, name);\n}\n\n/**\n * Validates an object against a schema\n * @param {Object} obj - Object to validate\n * @param {Object} schema - Schema definition { prop: Type, prop2: [Type1, Type2] }\n * @param {string} objName - Name of the object for error messages\n */\nexport function validateObject(obj, schema, objName = 'object') {\n if (!obj || typeof obj !== 'object') {\n throw new TypeError(`${objName} must be an object`);\n }\n \n for (const [prop, expectedType] of Object.entries(schema)) {\n if (prop in obj) {\n checkType(obj[prop], expectedType, `${objName}.${prop}`);\n }\n }\n}\n\n/**\n * Creates a validator function for an object schema\n * @param {Object} schema - Schema definition\n * @param {string} objName - Name of the object\n * @returns {Function} - Validator function\n */\nexport function createObjectValidator(schema, objName = 'object') {\n return (obj) => validateObject(obj, schema, objName);\n}\n\n// Export the type map for advanced usage\nexport { TYPE_MAP };\n", "const DefinitionTypes = new Map();\nconst Definitions = new WeakMap();\nimport { createTypeChecker } from '../utils/typeChecker.js';\n\n/**\n * Creates a definition type with return type validation\n * @param {string} type - The definition type name\n * @param {Function|Array<Function>} returnTypes - Expected return type(s)\n * @returns {Function} - Definition creator function\n */\n\n\nexport const definitionType = (definition) => {\n if (Definitions.has(definition)) {\n return Definitions.get(definition);\n }\n return undefined;\n}\n\nexport const createDefinition = (type, returnTypes = []) => { \n // Create type checker for return values if returnTypes specified\n const returnTypeChecker = returnTypes.length > 0 ? createTypeChecker(returnTypes, 'return value') : null;\n \n if (DefinitionTypes.has(type)) {\n console.warn(`Definition type \"${type}\" already exists`);\n return DefinitionTypes.get(type);\n }\n\n const definitionType = (name, factory, ...defaultArgs) => {\n // Validate inputs using type checker\n createTypeChecker(String, 'name')(name);\n createTypeChecker(Function, 'factory')(factory);\n\n const definition = (...args) => {\n try {\n const combinedArgs = [...args, ...defaultArgs];\n const res = factory(...combinedArgs);\n \n if (returnTypeChecker && res === undefined) {\n throw new Error(`Factory ${type} must return a value for ${name}`);\n }\n\n // Use type checker to validate return value\n if (returnTypeChecker) {\n returnTypeChecker(res);\n }\n\n return res\n } catch (error) {\n console.error(`Error creating definition \"${name}\"`, error);\n throw error;\n }\n }\n\n Object.defineProperty(definition, '_name', {\n value: name,\n enumerable: false,\n configurable: false\n });\n\n Definitions.set(definition, type);\n\n return definition;\n }\n\n DefinitionTypes.set(type, definitionType);\n\n return definitionType;\n}; ", "// utils/asserts.js\n\nconst BAD_KEYS = new Set(['__proto__', 'prototype', 'constructor']);\nconst RESERVED_NAMESPACES = new Set(['use', 'install', 'uninstall', 'relay', 'state', 'debug']);\n\nconst MAX_NAME_LENGTH = 64;\nconst VALID_NAME = /^[a-zA-Z_$][a-zA-Z_$0-9]*$/;\n\n/**\n * Throw if key is unsafe (__proto__, constructor, etc.)\n */\nexport function assertSafeKey(key, where = 'key') {\n if (BAD_KEYS.has(key)) {\n throw new Error(`Illegal key \"${key}\" in ${where}`);\n }\n}\n\n/**\n * Validate a namespace string: format, length, reserved words, proto poisoning.\n */\nexport function assertNamespace(ns) {\n assertSafeKey(ns, 'namespace');\n if (typeof ns !== 'string') {\n throw new Error(`Namespace must be a string, got ${typeof ns}`);\n }\n if (!VALID_NAME.test(ns)) {\n throw new Error(`Invalid namespace \"${ns}\". Must be a valid JS identifier`);\n }\n if (ns.length > MAX_NAME_LENGTH) {\n throw new Error(`Namespace \"${ns}\" too long (max ${MAX_NAME_LENGTH} chars)`);\n }\n if (RESERVED_NAMESPACES.has(ns)) {\n throw new Error(`Namespace \"${ns}\" is reserved`);\n }\n return ns;\n}\n\n/**\n * Validate an action or getter name within a namespace.\n */\nexport function assertMemberName(name, namespace, kind = 'member') {\n assertSafeKey(name, `${kind}:${namespace}`);\n if (typeof name !== 'string') {\n throw new Error(`${kind} name in ${namespace} must be a string`);\n }\n if (!VALID_NAME.test(name)) {\n throw new Error(`Invalid ${kind} name \"${name}\" in ${namespace}`);\n }\n if (name.length > MAX_NAME_LENGTH) {\n throw new Error(\n `${kind} name \"${name}\" in ${namespace} too long (max ${MAX_NAME_LENGTH})`\n );\n }\n return name;\n}\n", "import { createDefinition, definitionType } from './createDefinition.js';\nexport const defineMiddleware = createDefinition('MIDDLEWARE', [Function, Array]);\nexport const defineActions = createDefinition('ACTIONS', [Object]);\nexport const defineUninstall = createDefinition('UNINSTALL');\nexport const defineInitialize = createDefinition('INITIALIZE');\nexport const defineGetters = createDefinition('GETTERS', [Object]);\nexport { createDefinition, definitionType };", "// DefinitionBuilder.js\nimport { defineActions, defineGetters, defineMiddleware, defineInitialize, defineUninstall } from './defaults.js';\n\nexport class DefinitionBuilder {\n static create(namespace) {\n return new DefinitionBuilder(namespace);\n }\n\n #ns; #args;\n #slots = { MIDDLEWARE:null, GETTERS:null, ACTIONS:null, INITIALIZE:null, UNINSTALL:null };\n constructor(namespace) { this.#ns = namespace }\n\n #set(type, factory, creator) {\n if (this.#slots[type]) throw new Error(`${type} already defined for ${this.#ns}`);\n this.#slots[type] = creator(this.#ns, factory);\n }\n\n defineMiddleware = (factory) => this.#set('MIDDLEWARE', factory, defineMiddleware);\n defineGetters = (factory) => this.#set('GETTERS', factory, defineGetters);\n defineActions = (factory) => this.#set('ACTIONS', factory, defineActions);\n defineInitialize = (factory) => this.#set('INITIALIZE', factory, defineInitialize);\n defineUninstall = (factory) => this.#set('UNINSTALL', factory, defineUninstall);\n\n _toArray() {\n return [\n this.#slots.MIDDLEWARE,\n this.#slots.GETTERS,\n this.#slots.ACTIONS,\n this.#slots.INITIALIZE,\n this.#slots.UNINSTALL\n ].filter(Boolean);\n }\n}\n\n", "import { assertNamespace } from './utils/asserts.js';\nimport { DefinitionBuilder } from './definitions/DefinitionBuilder.js';\n\n\nexport class ServiceProvider {\n static #services = new Set();\n\n static manifest = {\n name: 'base',\n dependencies: [],\n version: '1.0.0',\n description: 'Base extension template',\n };\n\n static config = null;\n\n static unique = false;\n\n static configure(options = {}) {\n return {\n install: (useContext, config) => this.install(useContext, config),\n manifest: this.manifest,\n config: { ...(this.config || this.manifest.defaults || {}), ...options },\n unique: true,\n configured: true\n };\n }\n\n static install(useContext, config) { \n try {\n const {namespace} = this.manifest;\n assertNamespace(namespace);\n\n // instantiate\n const instance = new this();\n ServiceProvider.#services.add(instance);\n\n // bind context/config\n // bind config (frozen to avoid accidental mutation)\n Object.defineProperty(instance, 'config', {\n value: Object.freeze({ ...config }),\n writable: false,\n configurable: false,\n enumerable: false,\n });\n\n // expose both a live context getter AND the keyed accessor\n Object.defineProperty(instance, 'context', {\n get: () => useContext(), // always fresh, via your proxy\n configurable: false,\n enumerable: false,\n });\n \n Object.defineProperty(instance, 'useContext', {\n value: (...keys) => useContext(...keys),\n writable: false,\n configurable: false,\n enumerable: false,\n });\n\n const builder = DefinitionBuilder.create(namespace);\n\n if (instance.setup) {\n // Create properly bound context for setup pattern\n const setupContext = {\n defineActions: (factory) => builder.defineActions(() => factory(useContext, config)),\n defineMiddleware: (factory) => builder.defineMiddleware(() => factory(useContext, config)),\n defineGetters: (factory) => builder.defineGetters(() => factory(useContext, config)),\n defineInitialize: (factory) => builder.defineInitialize(() => factory(useContext, config)),\n defineUninstall: (factory) => builder.defineUninstall(() => factory(useContext, config))\n };\n const maybe = instance.setup(setupContext);\n return maybe?.then ? maybe.then(() => builder._toArray()) : builder._toArray();\n }\n\n if (instance.middleware) builder.defineMiddleware(() => instance.middleware(useContext, config));\n if (instance.getters) builder.defineGetters (() => instance.getters(useContext, config));\n if (instance.actions) builder.defineActions (() => instance.actions(useContext, config));\n if (instance.initialize) builder.defineInitialize(() => instance.initialize(useContext, config));\n if (instance.uninstall) builder.defineUninstall (() => instance.uninstall(useContext, config));\n\n return builder._toArray();\n } catch (error) {\n throw error;\n }\n }\n}", "const ENGINE_CONTEXT = Symbol('jucie.engine');\n\n/**\n * Registers the engine globally, but only if no engine has already been set.\n * @param {object} engine \n */\n\nexport function provideEngine(engine) {\n if (!globalThis[ENGINE_CONTEXT]) {\n globalThis[ENGINE_CONTEXT] = engine;\n }\n}\n\nexport function hasEngine() {\n return globalThis[ENGINE_CONTEXT] !== undefined;\n}\n\n/**\n * Forcefully override the engine in the global context.\n * Useful for testing or resetting.\n */\nexport function forceEngine(engine) {\n globalThis[ENGINE_CONTEXT] = engine;\n}\n\n/**\n * Retrieves the globally registered engine.\n */\nexport function getEngine() {\n return globalThis[ENGINE_CONTEXT] || null;\n}\n\n/**\n * Retrieves the globally registered engine.\n */\nexport function useEngine() {\n return getEngine();\n}", "/**\n * StorageSpace - Manages a namespaced area in localStorage\n * Each space stores its data as a single JSON object\n */\nexport class StorageSpace {\n #data = {};\n #spaceName;\n\n constructor(spaceName) {\n if (!spaceName) {\n throw new Error('StorageSpace requires a space name');\n }\n \n this.#spaceName = spaceName;\n this.#loadData();\n }\n\n /**\n * Load data from localStorage\n * @private\n */\n #loadData() {\n try {\n const stored = localStorage.getItem(this.#spaceName);\n this.#data = stored ? JSON.parse(stored) : {};\n } catch (error) {\n console.error(`Failed to load storage space \"${this.#spaceName}\":`, error);\n this.#data = {};\n }\n }\n\n /**\n * Save data to localStorage\n * @private\n */\n #saveData() {\n try {\n localStorage.setItem(this.#spaceName, JSON.stringify(this.#data));\n } catch (error) {\n console.error(`Failed to save storage space \"${this.#spaceName}\":`, error);\n throw error;\n }\n }\n\n /**\n * Set a value in the storage space\n * @param {string} key - The key to set\n * @param {*} value - The value to store (will be JSON serialized)\n * @returns {*} The value that was set\n */\n set(key, value) {\n this.#data[key] = value;\n this.#saveData();\n return value;\n }\n\n /**\n * Get a value from the storage space\n * @param {string} key - The key to get\n * @param {*} defaultValue - Default value if key doesn't exist\n * @returns {*} The stored value or default\n */\n get(key, defaultValue = null) {\n return this.#data[key] ?? defaultValue;\n }\n\n /**\n * Update a value using an update function\n * @param {string} key - The key to update\n * @param {Function} updateFn - Function that receives current value and returns new value\n * @returns {*} The updated value\n */\n update(key, updateFn) {\n const current = this.get(key);\n const updated = updateFn(current);\n this.set(key, updated);\n return updated;\n }\n\n /**\n * Remove a key from the storage space\n * @param {string} key - The key to remove\n * @returns {*} The value that was removed\n */\n remove(key) {\n const value = this.#data[key];\n delete this.#data[key];\n this.#saveData();\n return value;\n }\n\n /**\n * Get all data in the storage space\n * @returns {Object} Copy of all data\n */\n getAll() {\n return { ...this.#data };\n }\n\n /**\n * Clear all data in the storage space\n */\n clear() {\n this.#data = {};\n this.#saveData();\n }\n\n /**\n * Check if a key exists in the storage space\n * @param {string} key - The key to check\n * @returns {boolean}\n */\n has(key) {\n return key in this.#data;\n }\n\n /**\n * Get all keys in the storage space\n * @returns {Array<string>}\n */\n keys() {\n return Object.keys(this.#data);\n }\n\n /**\n * Get the number of items in the storage space\n * @returns {number}\n */\n size() {\n return Object.keys(this.#data).length;\n }\n\n /**\n * Get the space name\n * @returns {string}\n */\n getName() {\n return this.#spaceName;\n }\n}\n", "import { ServiceProvider } from '@jucie.io/engine';\nimport { StorageSpace } from './StorageSpace.js';\n\n/**\n * LocalStorage Extension\n * Provides namespaced localStorage management for the Brickworks engine\n * \n * Usage:\n * engine.localStorage.create('navigation');\n * const nav = engine.localStorage.use('navigation');\n * nav.set('destination', { path: '/editor' });\n * nav.get('destination');\n */\nexport class LocalStorage extends ServiceProvider {\n #spaces = new Map();\n\n static manifest = {\n name: 'LocalStorage',\n namespace: 'localStorage',\n version: '1.0.0',\n description: 'Namespaced localStorage service for browser storage',\n };\n\n initialize() {\n // Check if localStorage is available\n if (typeof window === 'undefined' || !window.localStorage) {\n console.warn('localStorage not available - LocalStorage extension will use in-memory fallback');\n }\n }\n\n actions(useContext) {\n return {\n /**\n * Create a new storage space (or return existing)\n * @param {string} spaceName - Name of the storage space\n * @returns {StorageSpace} Storage space instance\n */\n create: (spaceName) => {\n if (!spaceName) {\n throw new Error('Storage space name is required');\n }\n\n if (!this.#spaces.has(spaceName)) {\n this.#spaces.set(spaceName, new StorageSpace(spaceName));\n }\n \n return this.#spaces.get(spaceName);\n },\n \n /**\n * Use an existing storage space (creates if doesn't exist)\n * @param {string} spaceName - Name of the storage space\n * @returns {StorageSpace} Storage space instance\n */\n use: (spaceName) => {\n if (!spaceName) {\n throw new Error('Storage space name is required');\n }\n\n if (!this.#spaces.has(spaceName)) {\n this.#spaces.set(spaceName, new StorageSpace(spaceName));\n }\n \n return this.#spaces.get(spaceName);\n },\n \n /**\n * Check if a storage space exists\n * @param {string} spaceName - Name to check\n * @returns {boolean}\n */\n exists: (spaceName) => {\n if (typeof window === 'undefined' || !window.localStorage) {\n return this.#spaces.has(spaceName);\n }\n return localStorage.getItem(spaceName) !== null;\n },\n \n /**\n * Destroy a storage space completely\n * @param {string} spaceName - Name of space to destroy\n */\n destroy: (spaceName) => {\n if (typeof window !== 'undefined' && window.localStorage) {\n localStorage.removeItem(spaceName);\n }\n this.#spaces.delete(spaceName);\n },\n \n /**\n * List all storage spaces\n * @returns {Array<string>} Array of space names\n */\n listSpaces: () => {\n if (typeof window === 'undefined' || !window.localStorage) {\n return Array.from(this.#spaces.keys());\n }\n\n const keys = [];\n for (let i = 0; i < localStorage.length; i++) {\n keys.push(localStorage.key(i));\n }\n return keys;\n },\n \n /**\n * Clear all storage spaces (use with caution!)\n */\n clearAll: () => {\n if (typeof window !== 'undefined' && window.localStorage) {\n localStorage.clear();\n }\n this.#spaces.clear();\n }\n };\n }\n}\n"],
|
|
5
|
+
"mappings": "AAEA,IAAMA,EAAgB,OAAO,OAAO,OAAO,OAAO,IAAI,CAAC,EC4ChD,SAASC,EAAUC,EAAOC,EAAcC,EAAO,QAAS,CAE7D,GAAI,MAAM,QAAQD,CAAY,EAAG,CAC/B,QAAWE,KAAQF,EACjB,GAAIG,EAAYJ,EAAOG,CAAI,EACzB,MAAO,GAIX,IAAME,EAAYJ,EAAa,IAAIK,CAAW,EAAE,KAAK,KAAK,EAC1D,MAAM,IAAI,UAAU,GAAGJ,CAAI,oBAAoBG,CAAS,SAASC,EAAYN,CAAK,CAAC,EAAE,CACvF,CAGA,GAAI,CAACI,EAAYJ,EAAOC,CAAY,EAClC,MAAM,IAAI,UAAU,GAAGC,CAAI,YAAYI,EAAYL,CAAY,CAAC,SAASK,EAAYN,CAAK,CAAC,EAAE,EAG/F,MAAO,EACT,CAQA,SAASI,EAAYJ,EAAOG,EAAM,CAEhC,OAAIA,IAAS,OACJ,OAAOH,GAAU,SAEtBG,IAAS,OACJ,OAAOH,GAAU,UAAY,CAAC,MAAMA,CAAK,EAE9CG,IAAS,QACJ,OAAOH,GAAU,UAEtBG,IAAS,OACJ,OAAOH,GAAU,SAEtBG,IAAS,OACJ,OAAOH,GAAU,SAEtBG,IAAS,SACJ,OAAOH,GAAU,WAItBG,IAAS,MACJ,MAAM,QAAQH,CAAK,EAExBG,IAAS,OACJH,IAAU,MAAQ,OAAOA,GAAU,UAAY,CAAC,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,KAAKF,GAAQ,IAAIE,EAAW,IAAIC,EAAaD,CAAS,CAAC,EAGlD,KAAKF,GAAQ,IAAIE,CAAS,CACnC,EAOA,OAASA,GACH,OAAO,OAAW,KAAe,CAAC,OAAO,aACpC,KAAKF,GAAQ,IAAIE,CAAS,EAE5B,aAAa,QAAQA,CAAS,IAAM,KAO7C,QAAUA,GAAc,CAClB,OAAO,OAAW,KAAe,OAAO,cAC1C,aAAa,WAAWA,CAAS,EAEnC,KAAKF,GAAQ,OAAOE,CAAS,CAC/B,EAMA,WAAY,IAAM,CAChB,GAAI,OAAO,OAAW,KAAe,CAAC,OAAO,aAC3C,OAAO,MAAM,KAAK,KAAKF,GAAQ,KAAK,CAAC,EAGvC,IAAMI,EAAO,CAAC,EACd,QAAS,EAAI,EAAG,EAAI,aAAa,OAAQ,IACvCA,EAAK,KAAK,aAAa,IAAI,CAAC,CAAC,EAE/B,OAAOA,CACT,EAKA,SAAU,IAAM,CACV,OAAO,OAAW,KAAe,OAAO,cAC1C,aAAa,MAAM,EAErB,KAAKJ,GAAQ,MAAM,CACrB,CACF,CACF,CACF",
|
|
6
|
+
"names": ["GLOBAL_NS_OBJ", "checkType", "value", "expectedType", "name", "type", "matchesType", "typeNames", "getTypeName", "createTypeChecker", "DefinitionTypes", "Definitions", "createDefinition", "type", "returnTypes", "returnTypeChecker", "createTypeChecker", "DefinitionTypes", "definitionType", "name", "factory", "defaultArgs", "definition", "args", "combinedArgs", "res", "error", "Definitions", "BAD_KEYS", "RESERVED_NAMESPACES", "MAX_NAME_LENGTH", "VALID_NAME", "assertSafeKey", "key", "where", "assertNamespace", "ns", "defineMiddleware", "createDefinition", "defineActions", "defineUninstall", "defineInitialize", "defineGetters", "DefinitionBuilder", "_DefinitionBuilder", "namespace", "#ns", "#args", "#slots", "#set", "type", "factory", "creator", "defineMiddleware", "defineGetters", "defineActions", "defineInitialize", "defineUninstall", "ServiceProvider", "_ServiceProvider", "#services", "options", "useContext", "config", "namespace", "assertNamespace", "instance", "keys", "builder", "DefinitionBuilder", "setupContext", "factory", "maybe", "error", "ENGINE_CONTEXT", "StorageSpace", "#data", "#spaceName", "spaceName", "#loadData", "stored", "error", "#saveData", "key", "value", "defaultValue", "updateFn", "current", "updated", "LocalStorage", "ServiceProvider", "#spaces", "useContext", "spaceName", "StorageSpace", "keys"]
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jucie.io/engine-local-storage",
|
|
3
|
+
"version": "1.0.7",
|
|
4
|
+
"description": "Namespaced localStorage service for @jucie.io/engine with browser storage management",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/main.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "vitest"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"localStorage",
|
|
19
|
+
"storage",
|
|
20
|
+
"browser",
|
|
21
|
+
"namespaced",
|
|
22
|
+
"engine-service"
|
|
23
|
+
],
|
|
24
|
+
"author": "Adrian Miller",
|
|
25
|
+
"license": "SEE LICENSE IN ../../LICENSE",
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/adrianjonmiller/engine.git",
|
|
32
|
+
"directory": "services/local-storage"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@jucie.io/engine": "^1.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"vitest": "^3.2.4"
|
|
39
|
+
}
|
|
40
|
+
}
|